Codechange: introduce and use function to raise and dirty a set of widgets when they are lowered

This commit is contained in:
Rubidium
2023-09-17 06:40:28 +02:00
committed by rubidium42
parent 6580ff1adb
commit 7ef22af2bb
6 changed files with 31 additions and 36 deletions

View File

@@ -413,6 +413,18 @@ public:
SetWidgetLoweredState(widget_index, false);
}
/**
* Marks a widget as raised and dirty (redraw), when it is marked as lowered.
* @param widget_index index of this widget in the window
*/
inline void RaiseWidgetWhenLowered(byte widget_index)
{
if (this->IsWidgetLowered(widget_index)) {
this->RaiseWidget(widget_index);
this->SetWidgetDirty(widget_index);
}
}
/**
* Gets the lowered state of a widget.
* @param widget_index index of this widget in the window
@@ -458,6 +470,16 @@ public:
{
(SetWidgetLoweredState(widgets, lowered_stat), ...);
}
/**
* Raises the widgets and sets widgets dirty that are lowered.
* @param widgets list of widgets
*/
template<typename... Args>
void RaiseWidgetsWhenLowered(Args... widgets) {
(this->RaiseWidgetWhenLowered(widgets), ...);
}
void SetWidgetDirty(byte widget_index) const;
void DrawWidgets() const;