void ScrollBar::SetSlider(unsigned size, unsigned view_size, unsigned origin) { const int netto_height = GetNettoHeight(); // If (no size) slider fills the whole area (no scrolling) int height = size > 0 ? (int)(netto_height * view_size / size) : netto_height; // Prevent the slider from getting to small if (height < GetWidth()) height = GetWidth(); if (height > netto_height) height = netto_height; // Calculate highest origin (counted in ListItems) unsigned max_origin = size - view_size; // Move the slider to the appropriate position int top = (max_origin > 0) ? ((netto_height - height) * origin / max_origin) : 0; // Prevent the slider from getting to big // TODO: not needed?! if (top + height > netto_height) height = netto_height - top; // Update slider coordinates rc_slider.left = rc.left; rc_slider.top = rc.top + GetWidth() + top; rc_slider.right = rc.right; rc_slider.bottom = rc_slider.top + height; }
/** * Returns the height of the visible scroll area of the ScrollBar * (the area thats not covered with the slider) */ PixelScalar GetScrollHeight() const { return GetNettoHeight() - GetSliderHeight(); }