Пример #1
0
Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, ScrollbarTheme* theme)
    : m_scrollableArea(scrollableArea)
    , m_orientation(orientation)
    , m_controlSize(controlSize)
    , m_theme(theme)
    , m_visibleSize(0)
    , m_totalSize(0)
    , m_currentPos(0)
    , m_dragOrigin(0)
    , m_hoveredPart(NoPart)
    , m_pressedPart(NoPart)
    , m_pressedPos(0)
    , m_scrollPos(0)
    , m_draggingDocument(false)
    , m_documentDragPos(0)
    , m_enabled(true)
    , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
    , m_overlapsResizer(false)
    , m_isAlphaLocked(false)
    , m_elasticOverscroll(0)
{
    if (!m_theme)
        m_theme = ScrollbarTheme::theme();

    m_theme->registerScrollbar(this);

    // FIXME: This is ugly and would not be necessary if we fix cross-platform code to actually query for
    // scrollbar thickness and use it when sizing scrollbars (rather than leaving one dimension of the scrollbar
    // alone when sizing).
    int thickness = m_theme->scrollbarThickness(controlSize);
    Widget::setFrameRect(IntRect(0, 0, thickness, thickness));

    m_currentPos = scrollableAreaCurrentPos();
}
Пример #2
0
void Scrollbar::offsetDidChange()
{
    ASSERT(m_scrollableArea);

    float position = scrollableAreaCurrentPos();
    if (position == m_currentPos)
        return;

    int oldThumbPosition = theme()->thumbPosition(this);
    m_currentPos = position;
    updateThumbPosition();
    if (m_pressedPart == ThumbPart)
        setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosition);
}
Пример #3
0
void Scrollbar::offsetDidChange() {
  ASSERT(m_scrollableArea);

  float position = scrollableAreaCurrentPos();
  if (position == m_currentPos)
    return;

  float oldPosition = m_currentPos;
  int oldThumbPosition = theme().thumbPosition(*this);
  m_currentPos = position;

  ScrollbarPart invalidParts =
      theme().invalidateOnThumbPositionChange(*this, oldPosition, position);
  setNeedsPaintInvalidation(invalidParts);

  if (m_pressedPart == ThumbPart)
    setPressedPos(m_pressedPos + theme().thumbPosition(*this) -
                  oldThumbPosition);
}
Пример #4
0
Scrollbar::Scrollbar(ScrollableArea* scrollableArea,
                     ScrollbarOrientation orientation,
                     ScrollbarControlSize controlSize,
                     HostWindow* hostWindow,
                     ScrollbarTheme* theme)
    : m_scrollableArea(scrollableArea),
      m_orientation(orientation),
      m_controlSize(controlSize),
      m_theme(theme ? *theme : ScrollbarTheme::theme()),
      m_hostWindow(hostWindow),
      m_visibleSize(0),
      m_totalSize(0),
      m_currentPos(0),
      m_dragOrigin(0),
      m_hoveredPart(NoPart),
      m_pressedPart(NoPart),
      m_pressedPos(0),
      m_scrollPos(0),
      m_draggingDocument(false),
      m_documentDragPos(0),
      m_enabled(true),
      m_scrollTimer(this, &Scrollbar::autoscrollTimerFired),
      m_elasticOverscroll(0),
      m_trackNeedsRepaint(true),
      m_thumbNeedsRepaint(true) {
  m_theme.registerScrollbar(*this);

  // FIXME: This is ugly and would not be necessary if we fix cross-platform
  // code to actually query for scrollbar thickness and use it when sizing
  // scrollbars (rather than leaving one dimension of the scrollbar alone when
  // sizing).
  int thickness = m_theme.scrollbarThickness(controlSize);
  m_themeScrollbarThickness = thickness;
  if (m_hostWindow)
    thickness = m_hostWindow->windowToViewportScalar(thickness);
  Widget::setFrameRect(IntRect(0, 0, thickness, thickness));

  m_currentPos = scrollableAreaCurrentPos();
}
Пример #5
0
Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation)
    : m_scrollableArea(scrollableArea)
    , m_orientation(orientation)
    , m_visibleSize(0)
    , m_totalSize(0)
    , m_currentPos(0)
    , m_dragOrigin(0)
    , m_hoveredPart(NoPart)
    , m_pressedPart(NoPart)
    , m_pressedPos(0)
    , m_scrollPos(0)
    , m_documentDragPos(0)
    , m_enabled(true)
    , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
    , m_overlapsResizer(false)
{
    // FIXME: This is ugly and would not be necessary if we fix cross-platform code to actually query for
    // scrollbar thickness and use it when sizing scrollbars (rather than leaving one dimension of the scrollbar
    // alone when sizing).
    int thickness = scrollbarThickness();
    Widget::setFrameRect(IntRect(0, 0, thickness, thickness));

    m_currentPos = scrollableAreaCurrentPos();
}