From e3dfd59df0b2495ea701db04e9c1b09ed795291a Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 19 Jun 2026 21:13:01 +0100 Subject: [PATCH] Change: clip content in purchase list to each row --- src/build_vehicle_gui.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 8a7a560947..ac81a73cc3 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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); } }