Beispiel #1
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();
}
Beispiel #2
0
void Widget::setDraggable(bool newState)
{
  m_draggable = newState;

  if (!m_draggable)
    cancelDragging();
}
Beispiel #3
0
void Layer::removedWidget(Widget& widget)
{
  if (activeWidget)
  {
    if (activeWidget == &widget || activeWidget->isChildOf(widget))
      setActiveWidget(widget.parent);
  }

  if (hoveredWidget)
  {
    if (hoveredWidget == &widget || hoveredWidget->isChildOf(widget))
      updateHoveredWidget();
  }

  if (captureWidget)
  {
    if (captureWidget == &widget || captureWidget->isChildOf(widget))
      releaseCursor();
  }

  if (dragging)
  {
    if (draggedWidget)
    {
      if (draggedWidget == &widget || draggedWidget->isChildOf(widget))
        cancelDragging();
    }
  }
}
Beispiel #4
0
void Button::onDragBegun(vec2 point, MouseButton button)
{
  if (button == MOUSE_BUTTON_LEFT)
    Widget::onDragBegun(point, button);
  else
    cancelDragging();
}
Beispiel #5
0
void Layer::onFocusChanged(bool activated)
{
  if (!activated)
  {
    cancelDragging();
    releaseCursor();
  }
}
Beispiel #6
0
void Layer::captureCursor()
{
  if (!activeWidget)
    return;

  releaseCursor();
  cancelDragging();

  captureWidget = activeWidget;
  hoveredWidget = activeWidget;
  window.captureCursor();
}
Beispiel #7
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();
  }
}
Beispiel #8
0
void MapEditorToolBase::gestureStarted()
{
	if (dragging)
		cancelDragging();
}