void Scrollbar::offsetDidChange() { float position = static_cast<float>(m_scrollableArea.scrollOffset(m_orientation)); 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); }
void Scrollbar::offsetDidChange() { ASSERT(m_scrollableArea); float position = static_cast<float>(m_scrollableArea->scrollPosition(this)); 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); }
void Scrollbar::offsetDidChange() { ASSERT(m_scrollableArea); float position = scrollableAreaCurrentPos(); if (position == m_currentPos) return; int oldThumbPosition = thumbPosition(); m_currentPos = position; updateThumb(); if (m_pressedPart == ThumbPart) setPressedPos(m_pressedPos + thumbPosition() - oldThumbPosition); }
void Scrollbar::moveThumb(int pos) { // Drag the thumb. int thumbPos = theme()->thumbPosition(this); int thumbLen = theme()->thumbLength(this); int trackLen = theme()->trackLength(this); int maxPos = trackLen - thumbLen; int delta = pos - pressedPos(); if (delta > 0) delta = min(maxPos - thumbPos, delta); else if (delta < 0) delta = max(-thumbPos, delta); if (delta) { setValue(static_cast<int>(static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen))); setPressedPos(pressedPos() + theme()->thumbPosition(this) - thumbPos); } }
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); }
bool Scrollbar::setCurrentPos(float pos, ScrollSource source) { if ((source != FromScrollAnimator) && client()) client()->setScrollPositionAndStopAnimation(m_orientation, pos); if (pos == m_currentPos) return false; int oldValue = value(); int oldThumbPos = theme()->thumbPosition(this); m_currentPos = pos; updateThumbPosition(); if (m_pressedPart == ThumbPart) setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPos); if (value() != oldValue && client()) client()->valueChanged(this); return true; }
bool Scrollbar::setCurrentPos(float pos) { if (pos == m_currentPos) #if PLATFORM(SDL) return true; #else return false; #endif int oldValue = value(); int oldThumbPos = theme()->thumbPosition(this); m_currentPos = pos; updateThumbPosition(); if (m_pressedPart == ThumbPart) setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPos); if (value() != oldValue && client()) client()->valueChanged(this); return true; }