void Slider::KnobDraggedListener::mouseDragged(const MouseEventUnrecPtr e) { if(e->getButton() == e->BUTTON1) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), _Slider, e->getViewport()); Pnt2f BorderTopLeft, BorderBottomRight; _Slider->getInsideInsetsBounds(BorderTopLeft, BorderBottomRight); UInt16 MajorAxis, MinorAxis; if(_Slider->getOrientation() == VERTICAL_ORIENTATION) { MajorAxis = 1; } else { MajorAxis = 0; } MinorAxis = (MajorAxis+1)%2; if(_Slider->getInverted()) { MousePosInComponent[MajorAxis] = _Slider->getTrackMax() - (MousePosInComponent[MajorAxis] - _Slider->getTrackMin()); } _Slider->setValue( _Slider->getMinimum() + (_Slider->getMaximum() - _Slider->getMinimum()) * (MousePosInComponent[MajorAxis] - _Slider->getTrackMin())/static_cast<Int32>(_Slider->getTrackLength()) ); } }
void TableHeader::handleColBorderMouseDragged(MouseEventDetails* const e) { if(e->getButton() == MouseEventDetails::BUTTON1) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport()); TableColumnRefPtr TheColumn(getColumnModel()->getColumn(_ResizingColumn)); Real32 NewWidth(MousePosInComponent.x() - getColumnHeaders(_ResizingColumn)->getPosition().x()); if(NewWidth <= 0 || NewWidth < TheColumn->getMinWidth()) { NewWidth = TheColumn->getMinWidth(); } if(NewWidth > TheColumn->getMaxWidth()) { NewWidth = TheColumn->getMaxWidth(); } //Get the new desired center for this margin TheColumn->setWidth(NewWidth); updateLayout(); } }
void ScrollBar::ScrollBarDraggedListener::mouseDragged(const MouseEventUnrecPtr e) { Pnt2f ComponentMousePosition(ViewportToComponent(e->getLocation(), _ScrollBar, e->getViewport())); _ScrollBar->setMajorAxisScrollBarPosition(_InitialScrollBarPosition + (ComponentMousePosition - _InitialMousePosition)); //std::cout << "Diff "<< _InitialMousePosition[AxisIndex] - ComponentMousePosition[AxisIndex] << std::endl; }
void SplitPanel::dividerDragMouseDragged(MouseEventDetails* const e) { UInt32 AxisIndex(0); if(getOrientation() != SplitPanel::HORIZONTAL_ORIENTATION ) AxisIndex = 1; if(e->getButton() == MouseEventDetails::BUTTON1) { Pnt2f temp = ViewportToComponent(e->getLocation(), this, e->getViewport()); if (getDividerPosition() <= 1.0) { if (temp[AxisIndex] >= 0) // this ensures it stays as a percentage position { Pnt2f TopLeft, BottomRight; getInsideBorderBounds(TopLeft, BottomRight); Vec2f BorderSize(BottomRight - TopLeft); setDividerPosition((Real32)temp[AxisIndex]/(Real32)BorderSize[AxisIndex]); } } else { if (temp[AxisIndex] > 1) // this ensures it stays absolute position { setDividerPosition(temp[AxisIndex]); } } //updateLayout(); } }
void TableHeader::MarginDraggedListener::mouseDragged(const MouseEventUnrecPtr e) { if(e->getButton() == e->BUTTON1) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), TableHeaderRefPtr(_TableHeader), e->getViewport()); TableColumnRefPtr TheColumn(_TableHeader->getColumnModel()->getColumn(_TableHeader->_ResizingColumn)); Real32 NewWidth(MousePosInComponent.x() - _TableHeader->getColumnHeaders(_TableHeader->_ResizingColumn)->getPosition().x()); if(NewWidth <= 0 || NewWidth < TheColumn->getMinWidth()) { NewWidth = TheColumn->getMinWidth(); } if(NewWidth > TheColumn->getMaxWidth()) { NewWidth = TheColumn->getMaxWidth(); } //Get the new desired center for this margin TheColumn->setWidth(NewWidth); _TableHeader->updateLayout(); } }
void ScrollBar::ScrollBarListener::mousePressed(const MouseEventUnrecPtr e) { if(_ScrollBar->getEnabled() && e->getButton() == e->BUTTON1) { _ScrollBar->_ScrollBarDraggedListener.setInitialMousePosition(ViewportToComponent(e->getLocation(), _ScrollBar, e->getViewport())); _ScrollBar->_ScrollBarDraggedListener.setInitialScrollBarPosition(_ScrollBar->editScrollBar()->getPosition()); _ScrollBar->getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseMotionListener(&(_ScrollBar->_ScrollBarDraggedListener)); _ScrollBar->getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseListener(&(_ScrollBar->_ScrollBarDraggedListener)); } }
void ScrollBar::handleScrollBarMousePressed(MouseEventDetails* const e) { if(getEnabled() && e->getButton() == MouseEventDetails::BUTTON1) { _ScrollBarInitialMousePosition = ViewportToComponent(e->getLocation(), this, e->getViewport()); _ScrollBarInitialScrollBarPosition = getScrollBar()->getPosition(); _ScrollBarDragMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&ScrollBar::handleScrollBarDragMouseDragged, this, _1)); _ScrollBarDragMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&ScrollBar::handleScrollBarDragMouseReleased, this, _1)); } }
void Component::mousePressed(MouseEventDetails* const e) { produceMousePressed(e); if(e->getButton() == MouseEventDetails::BUTTON3 && getPopupMenu() != NULL) { getPopupMenu()->setInvoker(this); getPopupMenu()->setVisible(true); getPopupMenu()->setPosition(ViewportToComponent(e->getLocation(),getParentWindow(),e->getViewport())); getParentWindow()->pushToActivePopupMenus(getPopupMenu()); } }
void TableHeader::checkMouseMargins(MouseEventDetails* const e) { if(isContainedClipBounds(e->getLocation(), this)) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport()); UInt32 CumulativeHeaderWidth(0); for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i) { CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x(); if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() && MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance()) { getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_RESIZE_W_TO_E); return; } CumulativeHeaderWidth += getColumnModel()->getColumnMargin(); } } getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_POINTER); }
void TableHeader::mousePressed(MouseEventDetails* const e) { if(getResizingAllowed()) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport()); UInt32 CumulativeHeaderWidth(0); for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i) { CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x(); if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() && MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance()) { _ColBorderMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&TableHeader::handleColBorderMouseDragged, this, _1)); _ColBorderMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&TableHeader::mouseColBorderMouseReleased, this, _1)); _ResizingColumn = i; return; } CumulativeHeaderWidth += getColumnModel()->getColumnMargin(); } } Inherited::mousePressed(e); }
void TableHeader::mousePressed(const MouseEventUnrecPtr e) { if(getResizingAllowed()) { Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), TableHeaderRefPtr(this), e->getViewport()); UInt32 CumulativeHeaderWidth(0); for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i) { CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x(); if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() && MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance()) { getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseMotionListener(&(_MarginDraggedListener)); getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseListener(&(_MarginDraggedListener)); _ResizingColumn = i; return; } CumulativeHeaderWidth += getColumnModel()->getColumnMargin(); } } Inherited::mousePressed(e); }
void ScrollBar::handleScrollBarDragMouseDragged(MouseEventDetails* const e) { Pnt2f ComponentMousePosition(ViewportToComponent(e->getLocation(), this, e->getViewport())); setMajorAxisScrollBarPosition(_ScrollBarInitialScrollBarPosition + (ComponentMousePosition - _ScrollBarInitialMousePosition)); }