mirror of https://github.com/OpenTTD/OpenTTD
Fix #12976: Incorrect widget rect scrolling for RTL languages.
Industry directory window did not consider RTL when applying horizontal scrolling.pull/12978/head
parent
26c2255897
commit
da739204ca
|
@ -1712,8 +1712,7 @@ public:
|
||||||
|
|
||||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||||
|
|
||||||
ir.left -= this->hscroll->GetPosition();
|
ir = ScrollRect(ir, *this->hscroll, 1);
|
||||||
ir.right += this->hscroll->GetCapacity() - this->hscroll->GetPosition();
|
|
||||||
|
|
||||||
if (this->industries.empty()) {
|
if (this->industries.empty()) {
|
||||||
DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE);
|
DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE);
|
||||||
|
|
|
@ -910,7 +910,7 @@ struct ScriptDebugWindow : public Window {
|
||||||
|
|
||||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||||
|
|
||||||
fr.left -= this->hscroll->GetPosition();
|
fr = ScrollRect(fr, *this->hscroll, 1);
|
||||||
|
|
||||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(log);
|
auto [first, last] = this->vscroll->GetVisibleRangeIterators(log);
|
||||||
for (auto it = first; it != last; ++it) {
|
for (auto it = first; it != last; ++it) {
|
||||||
|
|
|
@ -2401,6 +2401,35 @@ void Scrollbar::SetCapacityFromWidget(Window *w, WidgetID widget, int padding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply 'scroll' to a rect to be drawn in.
|
||||||
|
* @param r Rect to be 'scrolled'.
|
||||||
|
* @param sb The scrollbar affecting the scroll.
|
||||||
|
* @param resize_step Resize step of the widget/scrollbar (1 if the scrollbar is pixel-based.)
|
||||||
|
* @returns Scrolled rect.
|
||||||
|
*/
|
||||||
|
Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step)
|
||||||
|
{
|
||||||
|
const int count = sb.GetCount() * resize_step;
|
||||||
|
const int position = sb.GetPosition() * resize_step;
|
||||||
|
|
||||||
|
if (sb.IsVertical()) {
|
||||||
|
r.top -= position;
|
||||||
|
r.bottom = r.top + count;
|
||||||
|
} else {
|
||||||
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
|
if (rtl) {
|
||||||
|
r.right += position;
|
||||||
|
r.left = r.right - count;
|
||||||
|
} else {
|
||||||
|
r.left -= position;
|
||||||
|
r.right = r.left + count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrollbar widget.
|
* Scrollbar widget.
|
||||||
* @param tp Scrollbar type. (horizontal/vertical)
|
* @param tp Scrollbar type. (horizontal/vertical)
|
||||||
|
|
|
@ -1051,5 +1051,6 @@ extern SpecialMouseMode _special_mouse_mode;
|
||||||
void SetFocusedWindow(Window *w);
|
void SetFocusedWindow(Window *w);
|
||||||
|
|
||||||
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);
|
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);
|
||||||
|
Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step = 1);
|
||||||
|
|
||||||
#endif /* WINDOW_GUI_H */
|
#endif /* WINDOW_GUI_H */
|
||||||
|
|
Loading…
Reference in New Issue