mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Codechange: Remove unused parameter for Height()
DropDownListItem::Height does not need to take an argument so remove it Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
This commit is contained in:
parent
59a2abd298
commit
ac42dea7b2
@ -597,7 +597,7 @@ public:
|
|||||||
return ScaleGUITrad(28) + WidgetDimensions::scaled.hsep_normal + GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal();
|
return ScaleGUITrad(28) + WidgetDimensions::scaled.hsep_normal + GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint Height(uint) const override
|
uint Height() const override
|
||||||
{
|
{
|
||||||
return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal);
|
return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal);
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ struct GameOptionsWindow : Window {
|
|||||||
Dimension string_dim;
|
Dimension string_dim;
|
||||||
int width = ddli->Width();
|
int width = ddli->Width();
|
||||||
string_dim.width = width + padding.width;
|
string_dim.width = width + padding.width;
|
||||||
string_dim.height = ddli->Height(width) + padding.height;
|
string_dim.height = ddli->Height() + padding.height;
|
||||||
*size = maxdim(*size, string_dim);
|
*size = maxdim(*size, string_dim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + WidgetDimensions::scaled.dropdowntext.Horizontal() + WidgetDimensions::scaled.hsep_wide;
|
return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + WidgetDimensions::scaled.dropdowntext.Horizontal() + WidgetDimensions::scaled.hsep_wide;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint Height(uint) const override
|
uint Height() const override
|
||||||
{
|
{
|
||||||
return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)FONT_HEIGHT_NORMAL);
|
return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)FONT_HEIGHT_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
|
|||||||
this->sprite_y = dim.height;
|
this->sprite_y = dim.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint DropDownListIconItem::Height(uint) const
|
uint DropDownListIconItem::Height() const
|
||||||
{
|
{
|
||||||
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
|
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ struct DropdownWindow : Window {
|
|||||||
/* Total length of list */
|
/* Total length of list */
|
||||||
int list_height = 0;
|
int list_height = 0;
|
||||||
for (const auto &item : this->list) {
|
for (const auto &item : this->list) {
|
||||||
list_height += item->Height(items_width);
|
list_height += item->Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Capacity is the average number of items visible */
|
/* Capacity is the average number of items visible */
|
||||||
@ -213,14 +213,13 @@ struct DropdownWindow : Window {
|
|||||||
|
|
||||||
const Rect &r = this->GetWidget<NWidgetBase>(WID_DM_ITEMS)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
const Rect &r = this->GetWidget<NWidgetBase>(WID_DM_ITEMS)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
||||||
int y = _cursor.pos.y - this->top - r.top - WidgetDimensions::scaled.fullbevel.top;
|
int y = _cursor.pos.y - this->top - r.top - WidgetDimensions::scaled.fullbevel.top;
|
||||||
int width = r.Width();
|
|
||||||
int pos = this->vscroll->GetPosition();
|
int pos = this->vscroll->GetPosition();
|
||||||
|
|
||||||
for (const auto &item : this->list) {
|
for (const auto &item : this->list) {
|
||||||
/* Skip items that are scrolled up */
|
/* Skip items that are scrolled up */
|
||||||
if (--pos >= 0) continue;
|
if (--pos >= 0) continue;
|
||||||
|
|
||||||
int item_height = item->Height(width);
|
int item_height = item->Height();
|
||||||
|
|
||||||
if (y < item_height) {
|
if (y < item_height) {
|
||||||
if (item->masked || !item->Selectable()) return false;
|
if (item->masked || !item->Selectable()) return false;
|
||||||
@ -244,7 +243,7 @@ struct DropdownWindow : Window {
|
|||||||
int y = ir.top;
|
int y = ir.top;
|
||||||
int pos = this->vscroll->GetPosition();
|
int pos = this->vscroll->GetPosition();
|
||||||
for (const auto &item : this->list) {
|
for (const auto &item : this->list) {
|
||||||
int item_height = item->Height(ir.Width());
|
int item_height = item->Height();
|
||||||
|
|
||||||
/* Skip items that are scrolled up */
|
/* Skip items that are scrolled up */
|
||||||
if (--pos >= 0) continue;
|
if (--pos >= 0) continue;
|
||||||
@ -353,7 +352,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
|||||||
uint height = 0;
|
uint height = 0;
|
||||||
|
|
||||||
for (const auto &item : list) {
|
for (const auto &item : list) {
|
||||||
height += item->Height(width);
|
height += item->Height();
|
||||||
max_item_width = std::max(max_item_width, item->Width());
|
max_item_width = std::max(max_item_width, item->Width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
virtual ~DropDownListItem() = default;
|
virtual ~DropDownListItem() = default;
|
||||||
|
|
||||||
virtual bool Selectable() const { return false; }
|
virtual bool Selectable() const { return false; }
|
||||||
virtual uint Height([[maybe_unused]] uint) const { return FONT_HEIGHT_NORMAL; }
|
virtual uint Height() const { return FONT_HEIGHT_NORMAL; }
|
||||||
virtual uint Width() const { return 0; }
|
virtual uint Width() const { return 0; }
|
||||||
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
|
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
|
||||||
};
|
};
|
||||||
@ -61,7 +61,7 @@ class DropDownListIconItem : public DropDownListStringItem {
|
|||||||
public:
|
public:
|
||||||
DropDownListIconItem(SpriteID sprite, PaletteID pal, StringID string, int result, bool masked);
|
DropDownListIconItem(SpriteID sprite, PaletteID pal, StringID string, int result, bool masked);
|
||||||
|
|
||||||
uint Height(uint width) const override;
|
uint Height() const override;
|
||||||
uint Width() const override;
|
uint Width() const override;
|
||||||
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
|
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
|
||||||
void SetDimension(Dimension d);
|
void SetDimension(Dimension d);
|
||||||
|
Loading…
Reference in New Issue
Block a user