dialog: allow custom 'Select_button' attributes

This is useful to conditionally set the style to "unimportant", or to
use text other than the widget Id::Value.

Issue #5008
Issue #5053
This commit is contained in:
Norman Feske 2023-11-07 17:27:27 +01:00 committed by Christian Helmuth
parent 133cbd272e
commit fa6c7204cd

View File

@ -56,7 +56,7 @@ struct Dialog::Select_button : Widget<Button>
Select_button(ENUM value) : _value(value) { }
void view(Scope<Button> &s, ENUM selected_value) const
void view(Scope<Button> &s, ENUM selected_value, auto const &fn) const
{
bool const selected = (selected_value == _value),
hovered = (s.hovered() && !s.dragged() && !selected);
@ -64,7 +64,13 @@ struct Dialog::Select_button : Widget<Button>
if (selected) s.attribute("selected", "yes");
if (hovered) s.attribute("hovered", "yes");
s.sub_scope<Dialog::Label>(s.id.value);
fn(s);
}
void view(Scope<Button> &s, ENUM selected_value) const
{
view(s, selected_value, [&] (auto &s) {
s.template sub_scope<Dialog::Label>(s.id.value); });
}
template <typename FN>