/************************************************************************* Handler called whenever the mouse moves while dragging a segment *************************************************************************/ bool ListHeader::segmentDragHandler(const EventArgs&) { // what we do here is monitor the position and scroll if we can when mouse is outside area. // get mouse position as something local const Vector2f localMousePos(CoordConverter::screenToWindow(*this, getUnprojectedPosition(getGUIContext(). getMouseCursor().getPosition()))); // scroll left? if (localMousePos.d_x < 0.0f) { if (d_segmentOffset > 0.0f) { setSegmentOffset(ceguimax(0.0f, d_segmentOffset - ScrollSpeed)); } } // scroll right? else if (localMousePos.d_x >= d_pixelSize.d_width) { float maxOffset = ceguimax(0.0f, getTotalSegmentsPixelExtent() - d_pixelSize.d_width); // if we have not scrolled to the limit if (d_segmentOffset < maxOffset) { // scroll, but never beyond the limit setSegmentOffset(ceguimin(maxOffset, d_segmentOffset + ScrollSpeed)); } } return true; }
//----------------------------------------------------------------------------// void ButtonBase::setPushedState(const bool pushed) { d_pushed = pushed; if (!pushed) updateInternalState(getUnprojectedPosition( getGUIContext().getCursor().getPosition())); else d_hovering = true; invalidate(); }
/************************************************************************* Handler for when mouse capture is lost *************************************************************************/ void MenuItem::onCaptureLost(WindowEventArgs& e) { // Default processing ItemEntry::onCaptureLost(e); d_pushed = false; updateInternalState(getUnprojectedPosition( getGUIContext().getMouseCursor().getPosition())); invalidate(); // event was handled by us. ++e.handled; }
/************************************************************************* Handler method for when a segment is dragged & dropped. *************************************************************************/ bool ListHeader::segmentMovedHandler(const EventArgs& e) { const Vector2f mousePos(getUnprojectedPosition( getGUIContext().getMouseCursor().getPosition())); // segment must be dropped within the window if (isHit(mousePos)) { // get mouse position as something local Vector2f localMousePos(CoordConverter::screenToWindow(*this, mousePos)); // set up to allow for current offsets float currwidth = -d_segmentOffset; // calculate column where dragged segment was dropped uint col; for (col = 0; col < getColumnCount(); ++col) { currwidth += d_segments[col]->getPixelSize().d_width; if (localMousePos.d_x < currwidth) { // this is the column, exit loop early break; } } // find original column for dragged segment. ListHeaderSegment* seg = ((ListHeaderSegment*)((WindowEventArgs&)e).window); uint curcol = getColumnFromSegment(*seg); // move column moveColumn(curcol, col); } return true; }