From 136551408c344a605fb1d493aca9da0aeddec358 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 6 Nov 2023 22:35:01 +0000 Subject: [PATCH] Change: Show empty string drop down entries as divider. (#11447) --- src/widgets/dropdown.cpp | 10 +++++++--- src/widgets/dropdown_type.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 3b8054233a..492b6edb62 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -48,10 +48,14 @@ uint DropDownListStringItem::Width() const return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); } -void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours) const +void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours bg_colour) const { - Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext); - DrawString(ir.left, ir.right, r.top, this->String(), sel ? TC_WHITE : TC_BLACK); + if (this->String().empty()) { + this->DropDownListItem::Draw(r, sel, bg_colour); + } else { + Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext); + DrawString(ir.left, ir.right, r.top, this->String(), sel ? TC_WHITE : TC_BLACK); + } } /** diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index 424b9906ae..3135073a0d 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -42,7 +42,7 @@ public: DropDownListStringItem(StringID string, int result, bool masked); DropDownListStringItem(const std::string &string, int result, bool masked); - bool Selectable() const override { return true; } + bool Selectable() const override { return !this->String().empty(); } uint Width() const override; void Draw(const Rect &r, bool sel, Colours bg_colour) const override; virtual const std::string &String() const { return this->string; }