void ScrollBox::__Update(const Point2i & mousePosition, const Point2i & /*lastMousePosition*/) { // update position of items because of dragging if (HasScrollBar() && scroll_mode!=SCROLL_MODE_NONE) { int max_offset = GetMaxOffset(); int new_offset = offset; if (scroll_mode == SCROLL_MODE_THUMB) { Point2i track_pos = GetScrollTrackPos(); int height = GetTrackHeight(); new_offset = start_drag_offset + ((mousePosition.y - start_drag_y) * (size.y+max_offset))/height; } else if (scroll_mode == SCROLL_MODE_DRAG) { // Act as if the scroll corresponds to bringing the starting point to the // current point new_offset = start_drag_offset + start_drag_y - mousePosition.y; } if (new_offset < 0) new_offset = 0; if (new_offset > max_offset) new_offset = max_offset; if (new_offset != offset) { offset = new_offset; Pack(); } } }
void SetArrangeScrollTo(MediaTrack* track, VerticalZoomCenter center) { int offsetY; int height = GetTrackHeight(track, &offsetY); SetArrangeScroll(offsetY, height, center); }