Changeset - r28113:df733d075692
[Not reviewed]
master
0 2 0
Peter Nelson - 7 months ago 2023-11-06 22:35:01
peter1138@openttd.org
Change: Show empty string drop down entries as divider. (#11447)
2 files changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/widgets/dropdown.cpp
Show inline comments
 
@@ -48,10 +48,14 @@ uint DropDownListStringItem::Width() con
 
	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);
 
	}
 
}
 

	
 
/**
src/widgets/dropdown_type.h
Show inline comments
 
@@ -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; }
0 comments (0 inline, 0 general)