Example #1
0
bool
ListControl::OnMouseUp(PixelScalar x, PixelScalar y)
{
  if (scroll_bar.IsDragging()) {
    scroll_bar.DragEnd(this);
    return true;
  }

  if (drag_mode == DragMode::CURSOR &&
      x >= 0 && x <= ((PixelScalar)GetWidth() - scroll_bar.GetWidth())) {
    drag_end();
    ActivateItem();
    return true;
  }

  if (drag_mode == DragMode::SCROLL || drag_mode == DragMode::CURSOR) {
    drag_end();

#ifndef _WIN32_WCE
    kinetic.MouseUp(GetPixelOrigin());
    kinetic_timer.Schedule(30);
#endif

    return true;
  } else
    return PaintWindow::OnMouseUp(x, y);
}
Example #2
0
bool
ListControl::OnMouseUp(PixelPoint p)
{
  if (scroll_bar.IsDragging()) {
    scroll_bar.DragEnd(this);
    return true;
  }

  if (drag_mode == DragMode::CURSOR &&
      p.x >= 0 && p.x <= ((int)GetWidth() - scroll_bar.GetWidth())) {
    drag_end();
    ActivateItem();
    return true;
  }

  if (drag_mode == DragMode::SCROLL || drag_mode == DragMode::CURSOR) {
    const bool enable_kinetic = UsePixelPan() && drag_mode == DragMode::SCROLL;

    drag_end();

    if (enable_kinetic) {
      kinetic.MouseUp(GetPixelOrigin());
      kinetic_timer.Schedule(30);
    }

    return true;
  } else
    return PaintWindow::OnMouseUp(p);
}
Example #3
0
    bool CinderInteractItem::mouseUp(ci::app::MouseEvent mouse_event) {
        if (drag_in_progress_) {
            drag_end(mouse_event);
            drag_in_progress_ = false;
        }

        return false;
    }
Example #4
0
void
ListControl::OnCancelMode()
{
  PaintWindow::OnCancelMode();

  scroll_bar.DragEnd(this);
  drag_end();

  kinetic_timer.Cancel();
}
Example #5
0
void
ListControl::OnCancelMode()
{
  PaintWindow::OnCancelMode();

  scroll_bar.DragEnd(this);
  drag_end();

#ifndef _WIN32_WCE
  kinetic_timer.Cancel();
#endif
}
Example #6
0
bool
ListControl::OnMouseWheel(PixelPoint p, int delta)
{
  scroll_bar.DragEnd(this);
  drag_end();

  kinetic_timer.Cancel();

  if (delta > 0) {
    // scroll up
    MoveOrigin(-1);
  } else if (delta < 0) {
    // scroll down
    MoveOrigin(1);
  }

  return true;
}
Example #7
0
bool
ListControl::OnMouseWheel(PixelScalar x, PixelScalar y, int delta)
{
  scroll_bar.DragEnd(this);
  drag_end();

#ifndef _WIN32_WCE
  kinetic_timer.Cancel();
#endif

  if (delta > 0) {
    // scroll up
    MoveOrigin(-1);
  } else if (delta < 0) {
    // scroll down
    MoveOrigin(1);
  }

  return true;
}
Example #8
0
bool
ListControl::OnMouseDown(PixelScalar x, PixelScalar y)
{
  // End any previous drag
  scroll_bar.DragEnd(this);
  drag_end();

#ifndef _WIN32_WCE
  kinetic_timer.Cancel();
#endif

  RasterPoint Pos;
  Pos.x = x;
  Pos.y = y;

  // If possible -> Give focus to the Control
  const bool had_focus = HasFocus();
  if (!had_focus)
    SetFocus();

  if (scroll_bar.IsInsideSlider(Pos)) {
    // if click is on scrollbar handle
    // -> start mouse drag
    scroll_bar.DragBegin(this, Pos.y);
  } else if (scroll_bar.IsInside(Pos)) {
    // if click in scroll bar up/down/pgup/pgdn
    if (scroll_bar.IsInsideUpArrow(Pos.y))
      // up
      MoveOrigin(-1);
    else if (scroll_bar.IsInsideDownArrow(Pos.y))
      // down
      MoveOrigin(1);
    else if (scroll_bar.IsAboveSlider(Pos.y))
      // page up
      MoveOrigin(-(int)items_visible);
    else if (scroll_bar.IsBelowSlider(Pos.y))
      // page down
      MoveOrigin(items_visible);
  } else {
    // if click in ListBox area
    // -> select appropriate item

    int index = ItemIndexAt(y);
    // If mouse was clicked outside the list items -> cancel
    if (index < 0)
      return false;

    drag_y = GetPixelOrigin() + y;
    drag_y_window = y;

    if (had_focus && (unsigned)index == GetCursorIndex() &&
        CanActivateItem()) {
      drag_mode = DragMode::CURSOR;
      Invalidate_item(cursor);
    } else {
      // If item was not selected before
      // -> select it
      SetCursorIndex(index);
      drag_mode = DragMode::SCROLL;
    }
#ifndef _WIN32_WCE
    kinetic.MouseDown(GetPixelOrigin());
#endif
    SetCapture();
  }

  return true;
}