mirror of https://github.com/OpenTTD/OpenTTD
When there are many more items than fit in a list, the scrollbar slider scales to fit but there is no minimum size. It becomes too small to click on and use. Ensure scrollbar slider is at least the same size as the buttons either end.pull/13122/head
parent
0b0b4f50c4
commit
0c04966dc3
|
@ -145,15 +145,17 @@ static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom, bo
|
||||||
top += button_size; // top points to just below the up-button
|
top += button_size; // top points to just below the up-button
|
||||||
bottom -= button_size; // bottom points to top of the down-button
|
bottom -= button_size; // bottom points to top of the down-button
|
||||||
|
|
||||||
int height = (bottom - top);
|
|
||||||
int pos = sb->GetPosition();
|
|
||||||
int count = sb->GetCount();
|
int count = sb->GetCount();
|
||||||
int cap = sb->GetCapacity();
|
int cap = sb->GetCapacity();
|
||||||
|
|
||||||
if (count != 0) top += height * pos / count;
|
if (count > cap) {
|
||||||
|
int height = (bottom - top);
|
||||||
|
int slider_height = std::max(button_size, cap * height / count);
|
||||||
|
height -= slider_height;
|
||||||
|
|
||||||
if (cap > count) cap = count;
|
top += height * sb->GetPosition() / (count - cap);
|
||||||
if (count != 0) bottom -= (count - pos - cap) * height / count;
|
bottom = top + slider_height;
|
||||||
|
}
|
||||||
|
|
||||||
Point pt;
|
Point pt;
|
||||||
if (horizontal && _current_text_dir == TD_RTL) {
|
if (horizontal && _current_text_dir == TD_RTL) {
|
||||||
|
@ -216,7 +218,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
|
||||||
changed = sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG);
|
changed = sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG);
|
||||||
} else {
|
} else {
|
||||||
_scrollbar_start_pos = pt.x - mi - button_size;
|
_scrollbar_start_pos = pt.x - mi - button_size;
|
||||||
_scrollbar_size = ma - mi - button_size * 2;
|
_scrollbar_size = ma - mi - button_size * 2 - (pt.y - pt.x);
|
||||||
w->mouse_capture_widget = sb->index;
|
w->mouse_capture_widget = sb->index;
|
||||||
_cursorpos_drag_start = _cursor.pos;
|
_cursorpos_drag_start = _cursor.pos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2308,8 +2308,10 @@ static void HandleScrollbarScrolling(Window *w)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the item we want to move to. SetPosition will make sure it's inside bounds. */
|
/* Find the item we want to move to. SetPosition will make sure it's inside bounds. */
|
||||||
int pos = RoundDivSU((i + _scrollbar_start_pos) * sb->GetCount(), _scrollbar_size);
|
int range = sb->GetCount() - sb->GetCapacity();
|
||||||
if (rtl) pos = sb->GetCount() - sb->GetCapacity() - pos;
|
|
||||||
|
int pos = RoundDivSU((i + _scrollbar_start_pos) * range, _scrollbar_size);
|
||||||
|
if (rtl) pos = range - pos;
|
||||||
if (sb->SetPosition(pos)) w->SetDirty();
|
if (sb->SetPosition(pos)) w->SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue