void Scrollbar::startTimerIfNeeded(double delay) { // Don't do anything for the thumb. if (m_pressedPart == ThumbPart) return; // Handle the track. We halt track scrolling once the thumb is level // with us. if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) { theme()->invalidatePart(this, m_pressedPart); setHoveredPart(ThumbPart); return; } // We can't scroll if we've hit the beginning or end. ScrollDirection dir = pressedPartScrollDirection(); if (dir == ScrollUp || dir == ScrollLeft) { if (m_currentPos == 0) return; } else { if (m_currentPos == maximum()) return; } m_scrollTimer.startOneShot(delay); }
bool Scrollbar::mouseDown(const PlatformMouseEvent& evt) { // Early exit for right click if (evt.button() == RightButton) return true; // FIXME: Handled as context menu by Qt right now. Should just avoid even calling this method on a right click though. setPressedPart(theme()->hitTest(this, evt)); int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme()->shouldCenterOnThumb(this, evt)) { setHoveredPart(ThumbPart); setPressedPart(ThumbPart); m_dragOrigin = m_currentPos; int thumbLen = theme()->thumbLength(this); int desiredPos = pressedPos; // Set the pressed position to the middle of the thumb so that when we do the move, the delta // will be from the current pixel position of the thumb to the new desired position for the thumb. m_pressedPos = theme()->trackPosition(this) + theme()->thumbPosition(this) + thumbLen / 2; moveThumb(desiredPos); return true; } else if (m_pressedPart == ThumbPart) m_dragOrigin = m_currentPos; m_pressedPos = pressedPos; autoscrollPressedPart(theme()->initialAutoscrollTimerDelay()); return true; }
void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { // Early exit for right click if (evt.pointerProperties().button == WebPointerProperties::Button::Right) return; setPressedPart(theme().hitTest(*this, evt.position())); int pressedPos = orientation() == HorizontalScrollbar ? convertFromRootFrame(evt.position()).x() : convertFromRootFrame(evt.position()).y(); if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme().shouldCenterOnThumb(*this, evt)) { setHoveredPart(ThumbPart); setPressedPart(ThumbPart); m_dragOrigin = m_currentPos; int thumbLen = theme().thumbLength(*this); int desiredPos = pressedPos; // Set the pressed position to the middle of the thumb so that when we do // the move, the delta will be from the current pixel position of the thumb // to the new desired position for the thumb. m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + thumbLen / 2; moveThumb(desiredPos); return; } if (m_pressedPart == ThumbPart) { m_dragOrigin = m_currentPos; if (m_scrollableArea) m_scrollableArea->mouseCapturedScrollbar(); } m_pressedPos = pressedPos; autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); }
bool Scrollbar::mouseDown(const PlatformMouseEvent& evt) { ScrollbarPart pressedPart = theme().hitTest(*this, evt.position()); auto action = theme().handleMousePressEvent(*this, evt, pressedPart); if (action == ScrollbarButtonPressAction::None) return true; m_scrollableArea.mouseIsDownInScrollbar(this, true); setPressedPart(pressedPart); int pressedPosition = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y()); if (action == ScrollbarButtonPressAction::CenterOnThumb) { setHoveredPart(ThumbPart); setPressedPart(ThumbPart); m_dragOrigin = m_currentPos; // Set the pressed position to the middle of the thumb so that when we do the move, the delta // will be from the current pixel position of the thumb to the new desired position for the thumb. m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + theme().thumbLength(*this) / 2; moveThumb(pressedPosition); return true; } m_pressedPos = pressedPosition; if (action == ScrollbarButtonPressAction::StartDrag) m_dragOrigin = m_currentPos; if (action == ScrollbarButtonPressAction::Scroll) autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); return true; }
bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { moveThumb(m_orientation == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); return true; } if (m_pressedPart != NoPart) m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); ScrollbarPart part = theme()->hitTest(this, evt); if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { // The mouse is moving back over the pressed part. We // need to start up the timer action again. startTimerIfNeeded(theme()->autoscrollTimerDelay()); theme()->invalidatePart(this, m_pressedPart); } else if (m_hoveredPart == m_pressedPart) { // The mouse is leaving the pressed part. Kill our timer // if needed. stopTimerIfNeeded(); theme()->invalidatePart(this, m_pressedPart); } } setHoveredPart(part); } return true; }
bool Scrollbar::mouseExited() { if (m_scrollableArea) m_scrollableArea->mouseExitedScrollbar(this); setHoveredPart(NoPart); return true; }
void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { moveThumb(m_orientation == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y()); return; } if (m_pressedPart != NoPart) m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y(); // FIXME(sky): Cleanup this code now that part is always NoPart. ScrollbarPart part = NoPart; if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { // The mouse is moving back over the pressed part. We // need to start up the timer action again. startTimerIfNeeded(autoscrollTimerDelay()); invalidatePart(m_pressedPart); } else if (m_hoveredPart == m_pressedPart) { // The mouse is leaving the pressed part. Kill our timer // if needed. stopTimerIfNeeded(); invalidatePart(m_pressedPart); } } setHoveredPart(part); } return; }
void Scrollbar::autoscrollPressedPart(double delay) { // Don't do anything for the thumb or if nothing was pressed. if (m_pressedPart == ThumbPart || m_pressedPart == NoPart) return; // Handle the track. if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbWillBeUnderMouse()) { setHoveredPart(ThumbPart); return; } // Handle the arrows and track. if (m_scrollableArea && m_scrollableArea->userScroll(pressedPartScrollGranularity(), toScrollDelta(pressedPartScrollDirectionPhysical(), 1)).didScroll()) startTimerIfNeeded(delay); }
void Scrollbar::autoscrollPressedPart(double delay) { // Don't do anything for the thumb or if nothing was pressed. if (m_pressedPart == ThumbPart || m_pressedPart == NoPart) return; // Handle the track. if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) { theme()->invalidatePart(this, m_pressedPart); setHoveredPart(ThumbPart); return; } // Handle the arrows and track. if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) startTimerIfNeeded(delay); }
void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { if (theme().shouldSnapBackToDragOrigin(*this, evt)) { if (m_scrollableArea) { m_scrollableArea->setScrollOffsetSingleAxis( m_orientation, m_dragOrigin + m_scrollableArea->minimumScrollOffset(m_orientation), UserScroll); } } else { moveThumb(m_orientation == HorizontalScrollbar ? convertFromRootFrame(evt.position()).x() : convertFromRootFrame(evt.position()).y(), theme().shouldDragDocumentInsteadOfThumb(*this, evt)); } return; } if (m_pressedPart != NoPart) m_pressedPos = orientation() == HorizontalScrollbar ? convertFromRootFrame(evt.position()).x() : convertFromRootFrame(evt.position()).y(); ScrollbarPart part = theme().hitTest(*this, evt.position()); if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { // The mouse is moving back over the pressed part. We // need to start up the timer action again. startTimerIfNeeded(theme().autoscrollTimerDelay()); } else if (m_hoveredPart == m_pressedPart) { // The mouse is leaving the pressed part. Kill our timer // if needed. stopTimerIfNeeded(); } } setHoveredPart(part); } return; }
bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { if (theme()->shouldSnapBackToDragOrigin(this, evt)) { if (m_scrollableArea) m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin); } else { moveThumb(m_orientation == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y(), theme()->shouldDragDocumentInsteadOfThumb(this, evt)); } return true; } if (m_pressedPart != NoPart) m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); ScrollbarPart part = theme()->hitTest(this, evt); if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { // The mouse is moving back over the pressed part. We // need to start up the timer action again. startTimerIfNeeded(theme()->autoscrollTimerDelay()); theme()->invalidatePart(this, m_pressedPart); } else if (m_hoveredPart == m_pressedPart) { // The mouse is leaving the pressed part. Kill our timer // if needed. stopTimerIfNeeded(); theme()->invalidatePart(this, m_pressedPart); } } setHoveredPart(part); } return true; }
bool Scrollbar::mouseExited() { setHoveredPart(NoPart); return true; }
void Scrollbar::mouseExited() { if (m_scrollableArea) m_scrollableArea->mouseExitedScrollbar(this); setHoveredPart(NoPart); }