dialog: pass value to Select_button::click

This eliminates the need to distinguish enum values in the body of the
handler, easing the forwarding of the selected value.

Issue #5008
Issue #5053
This commit is contained in:
Norman Feske 2023-11-06 12:21:59 +01:00 committed by Christian Helmuth
parent e3881163c4
commit 1aba8182a4
3 changed files with 6 additions and 6 deletions

View File

@ -68,7 +68,7 @@ struct Dialog::Select_button : Widget<Button>
}
template <typename FN>
void click(Clicked_at const &, FN const &select_fn) { select_fn(); }
void click(Clicked_at const &, FN const &select_fn) { select_fn(_value); }
};

View File

@ -75,9 +75,9 @@ struct Sculpt::Panel_dialog : Top_level_dialog
_settings_button.propagate(at, [&] { _action.toggle_settings_visibility(); });
_network_button .propagate(at, [&] { _action.toggle_network_visibility(); });
_log_button .propagate(at, [&] { _action.toggle_log_visibility(); });
_files_tab .propagate(at, [&] { _action.select_tab(Tab::FILES); });
_components_tab .propagate(at, [&] { _action.select_tab(Tab::COMPONENTS); });
_inspect_tab .propagate(at, [&] { _action.select_tab(Tab::INSPECT); });
_files_tab .propagate(at, [&] (Tab t) { _action.select_tab(t); });
_components_tab .propagate(at, [&] (Tab t) { _action.select_tab(t); });
_inspect_tab .propagate(at, [&] (Tab t) { _action.select_tab(t); });
}
Panel_dialog(State const &state, Action &action)

View File

@ -101,8 +101,8 @@ struct Dialog_test::Main
_inspect.propagate(at, [&] { log("inspect activated!"); });
_confirm.propagate(at);
_cancel .propagate(at);
_cash .propagate(at, [&] { _payment = Payment::CASH; });
_card .propagate(at, [&] { _payment = Payment::CARD; });
_cash .propagate(at, [&] (Payment p) { _payment = p; });
_card .propagate(at, [&] (Payment p) { _payment = p; });
}
void clack(Clacked_at const &at) override