Change: clip content in purchase list to each row

This commit is contained in:
Peter Nelson
2026-06-19 21:13:01 +01:00
committed by Peter Nelson
parent 0366278c9d
commit e3dfd59df0
+8 -3
View File
@@ -962,7 +962,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
const int offset = (rtl ? -circle_width : circle_width) / 2;
const int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
for (auto it = first; it != last; ++it) {
for (auto it = first; it != last; ++it, ir = ir.Translate(0, step_size)) {
const auto &item = *it;
const Engine *e = Engine::Get(item.engine_id);
@@ -971,6 +971,13 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
bool is_folded = item.flags.Test(EngineDisplayFlag::IsFolded);
bool shaded = item.flags.Test(EngineDisplayFlag::Shaded);
/* Set up clipping area for the row, keeping coordinates relative to the window. */
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, ir)) continue;
tmp_dpi.left += ir.left;
tmp_dpi.top += ir.top;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
Rect textr = ir.Shrink(WidgetDimensions::scaled.matrix);
Rect tr = ir.Indent(indent, rtl);
@@ -1146,8 +1153,6 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
/* The left/right bounds are adjusted to not overlap with the sort detail that is on the left/right depending on the RTL setting. */
DrawString(tr.left + (rtl ? sort_detail_width : 0), tr.right - (rtl ? 0 : sort_detail_width), textr.top + normal_text_y_offset, name, tc);
ir = ir.Translate(0, step_size);
}
}