Esempio n. 1
0
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;
}
Esempio n. 2
0
void MVScrollBar::setBounds(const MVRect& bounds)
/****************************************************************************
*
* Function:		MVScrollBar::setBounds
* Parameters:	bounds	- New bounding box for the scroll bar
*
* Description:	Changes the bounds for the scroll bar.
*
****************************************************************************/
{
	MVView::setBounds(bounds);
	vertical = (size.x < size.y);

	// Compute the location of the left and right arrow buttons
	leftArrow = bounds;
	leftArrow.inset(1,1);
	rightArrow = leftArrow;

	if (vertical) {
		leftArrow.bottom() = leftArrow.top()+(_MV_sysScrollBarWidth+1);
		rightArrow.top() = rightArrow.bottom()-(_MV_sysScrollBarWidth+1);
		}
	else {
		leftArrow.right() = leftArrow.left()+(_MV_sysScrollBarWidth+1);
		rightArrow.left() = rightArrow.right()-(_MV_sysScrollBarWidth+1);
		}

	// Compute the location of the thumb
	moveThumb();
}
Esempio n. 3
0
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());
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
void Slider::mouseWheelMoved(wxMouseEvent& event) {
  TraceOp.trc( "slider", TRCLEVEL_DEBUG, __LINE__, 9999, "mouseWheelMoved %d %d", event.m_wheelDelta, event.m_wheelRotation );
  if( event.m_wheelRotation < 0 ) {
    ThumbPos++;
  }
  else {
    ThumbPos--;
  }

  PrevWheelTime = SystemOp.getTick();
  moveThumb();
}
Esempio n. 8
0
void MVScrollBar::setMaxVal(int v)
/****************************************************************************
*
* Function:		MVScrollBar::setMaxVal
* Parameters:	v	- New maximum value for the scroll bar
*
* Description:	Sets the maximum value for the scroll bar.
*
****************************************************************************/
{
	maxVal = v;
	if (value > maxVal)	value = maxVal;
	moveThumb();
	if (owner)
		owner->repaint(bounds);
}
Esempio n. 9
0
void MVScrollBar::changeValue(int part)
/****************************************************************************
*
* Function:		MVScrollBar::changeValue
* Parameters:	part	- Scroll bar arrow hit
*
* Description:	Adjusts the scroll bar value depending on which part of
*				the scroll bar was hit.
*
****************************************************************************/
{
	int	oldValue = value;

	switch (part) {
		case sbLeftArrow:
			value -= arrowStep;
			break;
		case sbRightArrow:
			value += arrowStep;
			break;
		case sbPageLeft:
			value -= pageStep;
			break;
		case sbPageRight:
			value += pageStep;
			break;
		}
	if (value < minVal)	value = minVal;
	if (value > maxVal)	value = maxVal;

	if (oldValue != value) {
		moveThumb();
		drawThumb(part);

		// We need to redraw the opposite arrow if the arrow just became
		// active again.
		if (oldValue == minVal)
			drawLeftArrow(false);
		if (oldValue == maxVal)
			drawRightArrow(false);

		MV_message(owner,evBroadcast,cmScrollBarChanged,this);
		}
}
Esempio n. 10
0
void MVScrollBar::setRange(int min,int max)
/****************************************************************************
*
* Function:		MVScrollBar::setRange
* Parameters:	min	- New minimum value for scroll bar
*				max	- New maximum value for scroll bar
*
* Description:	Sets the minimum and maximum values for the scroll bar.
*
****************************************************************************/
{
	minVal = min;
	maxVal = max;
	if (value < minVal)	value = minVal;
	if (value > maxVal)	value = maxVal;
	moveThumb();
	if (owner)
		owner->repaint(bounds);
}
Esempio n. 11
0
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
    switch (evt.type()) {
    case PlatformEvent::GestureTapDown:
        // FIXME(sky): Is setting the pressed part needed since we only have overlay scrollbars?
        setPressedPart(NoPart);
        m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y();
        return true;
    case PlatformEvent::GestureTapDownCancel:
    case PlatformEvent::GestureScrollBegin:
        if (m_pressedPart != ThumbPart)
            return false;
        m_scrollPos = m_pressedPos;
        return true;
    case PlatformEvent::GestureScrollUpdate:
    case PlatformEvent::GestureScrollUpdateWithoutPropagation:
        if (m_pressedPart != ThumbPart)
            return false;
        m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
        moveThumb(m_scrollPos);
        return true;
    case PlatformEvent::GestureScrollEnd:
    case PlatformEvent::GestureLongPress:
    case PlatformEvent::GestureFlingStart:
        m_scrollPos = 0;
        m_pressedPos = 0;
        setPressedPart(NoPart);
        return false;
    case PlatformEvent::GestureTap: {
        if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollableArea
            && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) {
            return true;
        }
        m_scrollPos = 0;
        m_pressedPos = 0;
        setPressedPart(NoPart);
        return false;
    }
    default:
        // By default, we assume that gestures don't deselect the scrollbar.
        return true;
    }
}
Esempio n. 12
0
void MVScrollBar::changeValue(const MVPoint& global)
/****************************************************************************
*
* Function:		MVScrollBar::changeValue
* Parameters:	global	- New location of the mouse cursor
*
* Description:	Converts the mouse cursor location into a new value for
*				the scroll bar thumb, repositions the thumb and redraws
*				it.
*
****************************************************************************/
{
	MVPoint p(global);
	globalToLocal(p);

	int		left,right,start;
	int	oldValue = value;

	if (vertical) {
		start = p.y - 7;
		left = leftArrow.bottom();
		right = rightArrow.top();
		}
	else {
		start = p.x - 7;
		left = leftArrow.right();
		right = rightArrow.left();
		}

	if (start < left)		start = left;
	if (start > right-(_MV_sysScrollBarWidth+1))
		start = right-(_MV_sysScrollBarWidth+1);

	value = ((2*(maxVal-minVal)*(long)(start-left))
			/ (right-left-(_MV_sysScrollBarWidth+1))+1)/2;

	if (oldValue != value) {
		moveThumb();
		drawThumb(sbThumb);
		MV_message(owner,evBroadcast,cmScrollBarChanged,this);
		}
}
Esempio n. 13
0
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;
}
Esempio n. 14
0
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
    switch (evt.type()) {
    case PlatformEvent::GestureTapDown:
        setPressedPart(theme()->hitTest(this, evt.position()));
        m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y();
        return true;
    case PlatformEvent::GestureTapDownCancel:
    case PlatformEvent::GestureScrollBegin:
        if (m_pressedPart != ThumbPart)
            return false;
        m_scrollPos = m_pressedPos;
        return true;
    case PlatformEvent::GestureScrollUpdate:
        if (m_pressedPart != ThumbPart)
            return false;
        m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
        moveThumb(m_scrollPos, false);
        return true;
    case PlatformEvent::GestureScrollEnd:
    case PlatformEvent::GestureLongPress:
    case PlatformEvent::GestureFlingStart:
        m_scrollPos = 0;
        m_pressedPos = 0;
        setPressedPart(NoPart);
        return false;
    case PlatformEvent::GestureTap: {
        if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollableArea
            && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) {
            return true;
        }
        m_scrollPos = 0;
        m_pressedPos = 0;
        setPressedPart(NoPart);
        return false;
    }
    default:
        // By default, we assume that gestures don't deselect the scrollbar.
        return true;
    }
}
Esempio n. 15
0
void Slider::keyPressed(wxKeyEvent& event) {
  TraceOp.trc( "slider", TRCLEVEL_INFO, __LINE__, 9999, "keyPressed %d", event.GetKeyCode());
  if( event.GetKeyCode() == WXK_DOWN) {
    ThumbPos++;
  }
  else if( event.GetKeyCode() == WXK_UP) {
    ThumbPos--;
  }
  else if( event.GetKeyCode() == WXK_PAGEDOWN) {
    ThumbPos+=10;
  }
  else if( event.GetKeyCode() == WXK_PAGEUP) {
    ThumbPos-=10;
  }
  else {
    event.Skip();
    return;
  }
  PrevWheelTime = SystemOp.getTick();
  moveThumb();
}
Esempio n. 16
0
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;
}
Esempio n. 17
0
void MVScrollBar::setValue(int v)
/****************************************************************************
*
* Function:		MVScrollBar::setValue
* Parameters:	v	- New value for the scroll bar
*
* Description:	Sets the value for the scroll bar, and updates it.
*
****************************************************************************/
{
	if (value == v)
		return;
	if (value < minVal)	value = minVal;		// Clamp to specified range
	if (value > maxVal)	value = maxVal;
	if (value == minVal || v == minVal)
		flags |= sbDirtyLeft;
	if (value == maxVal || v == maxVal)
		flags |= sbDirtyRight;
	flags |= sbDirtyThumb;
	value = v;
	moveThumb();
	update();
}
Esempio n. 18
0
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
    bool handled = false;
    switch (evt.type()) {
    case PlatformEvent::GestureTapDown:
        setPressedPart(theme()->hitTest(this, evt.position()));
        m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
        return true;
    case PlatformEvent::GestureTapDownCancel:
    case PlatformEvent::GestureScrollBegin:
        if (m_pressedPart == ThumbPart) {
            m_scrollPos = m_pressedPos;
            return true;
        }
        break;
    case PlatformEvent::GestureScrollUpdate:
    case PlatformEvent::GestureScrollUpdateWithoutPropagation:
        if (m_pressedPart == ThumbPart) {
            m_scrollPos += HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
            moveThumb(m_scrollPos, false);
            return true;
        }
        break;
    case PlatformEvent::GestureScrollEnd:
        m_scrollPos = 0;
        break;
    case PlatformEvent::GestureTap:
        if (m_pressedPart != ThumbPart && m_pressedPart != NoPart)
            handled = m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity());
        break;
    default:
        break;
    }
    setPressedPart(NoPart);
    m_pressedPos = 0;
    return handled;
}
Esempio n. 19
0
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt,
                             bool* shouldUpdateCapture) {
  DCHECK(shouldUpdateCapture);
  switch (evt.type()) {
    case PlatformEvent::GestureTapDown:
      setPressedPart(theme().hitTest(*this, evt.position()));
      m_pressedPos = orientation() == HorizontalScrollbar
                         ? convertFromRootFrame(evt.position()).x()
                         : convertFromRootFrame(evt.position()).y();
      *shouldUpdateCapture = true;
      return true;
    case PlatformEvent::GestureTapDownCancel:
      if (m_pressedPart != ThumbPart)
        return false;
      m_scrollPos = m_pressedPos;
      return true;
    case PlatformEvent::GestureScrollBegin:
      switch (evt.source()) {
        case PlatformGestureSourceTouchpad:
          // Update the state on GSB for touchpad since GestureTapDown
          // is not generated by that device. Touchscreen uses the tap down
          // gesture since the scrollbar enters a visual active state.
          *shouldUpdateCapture = true;
          setPressedPart(NoPart);
          m_pressedPos = 0;
          return true;
        case PlatformGestureSourceTouchscreen:
          if (m_pressedPart != ThumbPart)
            return false;
          m_scrollPos = m_pressedPos;
          return true;
        default:
          ASSERT_NOT_REACHED();
          return true;
      }
      break;
    case PlatformEvent::GestureScrollUpdate:
      switch (evt.source()) {
        case PlatformGestureSourceTouchpad: {
          FloatSize delta(-evt.deltaX(), -evt.deltaY());
          if (m_scrollableArea &&
              m_scrollableArea->userScroll(evt.deltaUnits(), delta)
                  .didScroll()) {
            return true;
          }
          return false;
        }
        case PlatformGestureSourceTouchscreen:
          if (m_pressedPart != ThumbPart)
            return false;
          m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX()
                                                              : evt.deltaY();
          moveThumb(m_scrollPos, false);
          return true;
        default:
          ASSERT_NOT_REACHED();
          return true;
      }
      break;
    case PlatformEvent::GestureScrollEnd:
    case PlatformEvent::GestureLongPress:
    case PlatformEvent::GestureFlingStart:
      m_scrollPos = 0;
      m_pressedPos = 0;
      setPressedPart(NoPart);
      return false;
    case PlatformEvent::GestureTap: {
      if (m_pressedPart != ThumbPart && m_pressedPart != NoPart &&
          m_scrollableArea &&
          m_scrollableArea
              ->userScroll(
                  pressedPartScrollGranularity(),
                  toScrollDelta(pressedPartScrollDirectionPhysical(), 1))
              .didScroll()) {
        return true;
      }
      m_scrollPos = 0;
      m_pressedPos = 0;
      setPressedPart(NoPart);
      return false;
    }
    default:
      // By default, we assume that gestures don't deselect the scrollbar.
      return true;
  }
}
Esempio n. 20
0
void Slider::mouseReleased(wxMouseEvent& event)
{
  TraceOp.trc( "slider", TRCLEVEL_DEBUG, __LINE__, 9999, "mouseReleased");
  Drag = false;
  moveThumb(true);
}