diff --git a/src/gui/widgets/status_label_helper.hpp b/src/gui/widgets/status_label_helper.hpp index c1d8c36d4047..8351442a7bb1 100644 --- a/src/gui/widgets/status_label_helper.hpp +++ b/src/gui/widgets/status_label_helper.hpp @@ -14,13 +14,36 @@ #ifndef GUI_WIDGETS_STATUS_LABEL_HELPER_HPP_INCLUDED #define GUI_WIDGETS_STATUS_LABEL_HELPER_HPP_INCLUDED +#include "gettext.hpp" #include "gui/core/event/dispatcher.hpp" #include "gui/widgets/control.hpp" +#include "gui/widgets/integer_selector.hpp" +#include "gui/widgets/selectable.hpp" #include "utils/functional.hpp" namespace gui2 { +/** + * Default value getter for selectable widgets (like toggle buttons) + */ +template +static inline typename std::enable_if::value, std::string>::type +default_value_getter(T& w) +{ + return w.get_value_bool() ? _("yes") : _("no"); +} + +/** + * Default value getter for integer-based widgets (like sliders) + */ +template +static inline typename std::enable_if::value, std::string>::type +default_value_getter(T& w) +{ + return w.get_value_label(); +} + /** * Creates a bound status label that will reflect the label state of a widget. The initial label * value is set here, and then again any time the widget is modified. A function is also returned @@ -31,7 +54,7 @@ namespace gui2 { */ template std::function bind_status_label(twidget& find_in, const std::string& id, - const std::function value_getter = [](W& w)->std::string { return std::to_string(w.get_value()); }, + const std::function value_getter = default_value_getter, const std::string& label_id = "") { const std::string label_id_ = label_id.empty() ? id + "_label" : label_id;