Exemplo n.º 1
0
float Scroller::handleOffset() const
{
  const float scale = (m_value - m_minValue) / (m_maxValue - m_minValue);

  if (m_orientation == HORIZONTAL)
    return (width() - handleSize()) * scale;
  else
    return (height() - handleSize()) * scale;
}
Exemplo n.º 2
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::GetRotateHandle( )
//
//  Description:		Retrieves a vector rect representing the rotation handle.
//
//  Returns:			Nothing
//
//  Exceptions:		Nothing
//
// ****************************************************************************
//
void RSingleSelection::GetRotateHandle( RRealVectorRect& rotateHandleRect ) const
	{
	// Get the bounding rect
	YSelectionBoundingRect boundingRect;
	GetSelectionBoundingRect( boundingRect );

	RRealPoint		centerPoint = boundingRect.GetCenterPoint( );
	R2dTransform	transform( boundingRect.GetTransform( ) );
	transform.PostTranslate( centerPoint.m_x-boundingRect.m_TopLeft.m_x, centerPoint.m_y-boundingRect.m_TopLeft.m_y );

	//	Break the transform into its components
	YAngle			angle;
	YRealDimension	xScale;
	YRealDimension	yScale;
	transform.Decompose( angle, xScale, yScale );

	// Figure out where to end the line
	RRealPoint		lineEndPoint	= GetRotateHandleCenterPoint( );
	YRealDimension	distance			= centerPoint.Distance( lineEndPoint );

	if ( xScale < 0 )
		xScale = -xScale;
	rotateHandleRect.Set( RRealSize(distance/xScale,1), transform );

	// Convert to device units
	RRealSize	handleSize( kRotateHandleHitSize/2, kRotateHandleHitSize/2 );
	::DeviceUnitsToLogicalUnits( handleSize, *m_pView );

	rotateHandleRect.Inflate( handleSize );
	}
Exemplo n.º 3
0
void Scroller::onMouseButton(Widget& widget,
                             vec2 point,
                             MouseButton button,
                             Action action,
                             uint mods)
{
  if (action != PRESSED)
    return;

  const vec2 local = transformToLocal(point);
  const float size = handleSize();
  const float offset = handleOffset();

  if (m_orientation == HORIZONTAL)
  {
    if (local.x < offset)
      setValue(m_value - valueStep(), true);
    else if (local.x >= offset + size)
      setValue(m_value + valueStep(), true);
  }
  else
  {
    if (local.y > height() - offset)
      setValue(m_value - valueStep(), true);
    else if (local.y <= height() - offset - size)
      setValue(m_value + valueStep(), true);
  }
}
Exemplo n.º 4
0
Selection::Handle Selection::handleAt(const QPointF &point, float zoom) const
{
    const qreal H = handleSize() / zoom;

    const QRectF R = m_shape.boundingRect();

    if(!R.contains(point))
        return OUTSIDE;

    QPointF p = point - R.topLeft();

    if(p.x() < H) {
        if(p.y() < H)
            return RS_TOPLEFT;
        else if(p.y() > R.height()-H)
            return RS_BOTTOMLEFT;
        return RS_LEFT;
    } else if(p.x() > R.width() - H) {
        if(p.y() < H)
            return RS_TOPRIGHT;
        else if(p.y() > R.height()-H)
            return RS_BOTTOMRIGHT;
        return RS_RIGHT;
    } else if(p.y() < H)
        return RS_TOP;
    else if(p.y() > R.height()-H)
        return RS_BOTTOM;

    return TRANSLATE;
}
Exemplo n.º 5
0
void Scroller::onDragBegun(vec2 point, MouseButton button)
{
  if (button == MOUSE_BUTTON_LEFT)
  {
    const vec2 local = transformToLocal(point);
    const float size = handleSize();
    const float offset = handleOffset();

    if (m_orientation == HORIZONTAL)
    {
      if (local.x >= offset && local.x < offset + size)
        m_reference = local.x - offset;
      else
        cancelDragging();
    }
    else
    {
      if (local.y <= height() - offset && local.y > height() - offset - size)
        m_reference = height() - local.y - offset;
      else
        cancelDragging();
    }

    Widget::onDragBegun(point, button);
  }
  else
    cancelDragging();
}
Exemplo n.º 6
0
int QwtSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QwtAbstractSlider::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break;
        case 1: *reinterpret_cast< ScalePosition*>(_v) = scalePosition(); break;
        case 2: *reinterpret_cast< bool*>(_v) = hasTrough(); break;
        case 3: *reinterpret_cast< bool*>(_v) = hasGroove(); break;
        case 4: *reinterpret_cast< QSize*>(_v) = handleSize(); break;
        case 5: *reinterpret_cast< int*>(_v) = borderWidth(); break;
        case 6: *reinterpret_cast< int*>(_v) = spacing(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break;
        case 1: setScalePosition(*reinterpret_cast< ScalePosition*>(_v)); break;
        case 2: setTrough(*reinterpret_cast< bool*>(_v)); break;
        case 3: setGroove(*reinterpret_cast< bool*>(_v)); break;
        case 4: setHandleSize(*reinterpret_cast< QSize*>(_v)); break;
        case 5: setBorderWidth(*reinterpret_cast< int*>(_v)); break;
        case 6: setSpacing(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 7)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 7
0
void Scroller::onDragMoved(Widget& widget, vec2 point)
{
  const vec2 local = transformToLocal(point);
  const float size = handleSize();

  float scale;

  if (m_orientation == HORIZONTAL)
    scale = (local.x - m_reference) / (width() - size);
  else
    scale = (height() - local.y - m_reference) / (height() - size);

  setValue(m_minValue + (m_maxValue - m_minValue) * scale, true);
}
//--------------------------------------------------------------------------
void GuiRectHandles::onRender(Point2I offset, const RectI &updateRect)
{
   Parent::onRender( offset, updateRect );

   ColorI handleColor = mProfile->mBorderColor;
   if(mUseCustomColor)
      handleColor = mHandleColor;

   // The handles range from 0-1, so scale to fit within the
   // control's bounds.
   const Point2I& extent = getExtent();
   Point2I pos(extent.x*mHandleRect.point.x, extent.y*mHandleRect.point.y);
   Point2I size(extent.x*mHandleRect.extent.x, extent.y*mHandleRect.extent.y);
   RectI box(offset+pos, size);

   // Draw border
   GFX->getDrawUtil()->drawRect(box, handleColor);

   // Draw each handle
   Point2I handleSize(mHandleSize, mHandleSize);
   RectI handleRect(box.point, handleSize);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Upper left
   handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Upper right
   handleRect.point = Point2I(box.point.x, box.point.y+size.y-handleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Lower left
   handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+size.y-handleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Lower right

   Point2I halfSize = size / 2;
   Point2I halfHandleSize = handleSize / 2;
   handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Upper middle
   handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+size.y-handleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Lower middle
   handleRect.point = Point2I(box.point.x, box.point.y+halfSize.y-halfHandleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Left middle
   handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+halfSize.y-halfHandleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Right middle

   handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+halfSize.y-halfHandleSize.y);
   GFX->getDrawUtil()->drawRectFill(handleRect, handleColor);      // Middle

   renderChildControls(offset, updateRect);
}
Exemplo n.º 9
0
int QwtSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QwtAbstractSlider::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< ScalePos*>(_v) = scalePosition(); break;
        case 1: *reinterpret_cast< BackgroundStyles*>(_v) = backgroundStyle(); break;
        case 2: *reinterpret_cast< QSize*>(_v) = handleSize(); break;
        case 3: *reinterpret_cast< int*>(_v) = borderWidth(); break;
        case 4: *reinterpret_cast< int*>(_v) = spacing(); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setScalePosition(*reinterpret_cast< ScalePos*>(_v)); break;
        case 1: setBackgroundStyle(*reinterpret_cast< BackgroundStyles*>(_v)); break;
        case 2: setHandleSize(*reinterpret_cast< QSize*>(_v)); break;
        case 3: setBorderWidth(*reinterpret_cast< int*>(_v)); break;
        case 4: setSpacing(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 5;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 10
0
void Scroller::onDragBegun(Widget& widget, vec2 point)
{
  const vec2 local = transformToLocal(point);
  const float size = handleSize();
  const float offset = handleOffset();

  if (m_orientation == HORIZONTAL)
  {
    if (local.x >= offset && local.x < offset + size)
      m_reference = local.x - offset;
    else
      cancelDragging();
  }
  else
  {
    if (local.y <= height() - offset && local.y > height() - offset - size)
      m_reference = height() - local.y - offset;
    else
      cancelDragging();
  }
}
Exemplo n.º 11
0
void Scroller::draw() const
{
  Drawer& drawer = layer().drawer();

  const Rect area = globalArea();
  if (drawer.pushClipArea(area))
  {
    drawer.drawWell(area, state());

    if (m_minValue != m_maxValue)
    {
      const float size = handleSize();
      const float offset = handleOffset();

      Rect handleArea;

      if (m_orientation == HORIZONTAL)
      {
        handleArea.set(area.position.x + offset,
                       area.position.y,
                       size,
                       area.size.y);
      }
      else
      {
        handleArea.set(area.position.x,
                       area.position.y + area.size.y - offset - size,
                       area.size.x,
                       size);
      }

      drawer.drawHandle(handleArea, state());
    }

    Widget::draw();

    drawer.popClipArea();
  }
}