GUI2/[Multi]Menu Button: removed retval handling
Retvals are only relevant for widgets that are supposed to trigger something like a window closure, and that makes sense for neither of these widgets. The only reason the Menu Button widget has it is its original implementation was largely copied from the Button widget, and the Multimenu Button widget copied from the Menu Button widget.
This commit is contained in:
parent
d7edb83b16
commit
2d9b7d82c6
4 changed files with 1 additions and 52 deletions
|
@ -41,7 +41,6 @@ menu_button::menu_button(const implementation::builder_menu_button& builder)
|
|||
: styled_widget(builder, type())
|
||||
, selectable_item()
|
||||
, state_(ENABLED)
|
||||
, retval_(retval::NONE)
|
||||
, values_()
|
||||
, selected_()
|
||||
, keep_open_(false)
|
||||
|
@ -143,13 +142,6 @@ void menu_button::signal_handler_left_button_click(const event::ui_event event,
|
|||
}
|
||||
|
||||
set_selected(selected, true);
|
||||
|
||||
if(retval_ != retval::NONE) {
|
||||
if(window* window = get_window()) {
|
||||
window->set_retval(retval_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handled = true;
|
||||
|
@ -271,8 +263,6 @@ namespace implementation
|
|||
|
||||
builder_menu_button::builder_menu_button(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, retval_id_(cfg["return_value_id"])
|
||||
, retval_(cfg["return_value"])
|
||||
, options_()
|
||||
{
|
||||
for(const auto& option : cfg.child_range("option")) {
|
||||
|
@ -284,7 +274,6 @@ widget_ptr builder_menu_button::build() const
|
|||
{
|
||||
auto widget = std::make_shared<menu_button>(*this);
|
||||
|
||||
widget->set_retval(get_retval(retval_id_, retval_, id));
|
||||
if(!options_.empty()) {
|
||||
widget->set_values(options_);
|
||||
}
|
||||
|
|
|
@ -68,11 +68,6 @@ public:
|
|||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
|
||||
void set_retval(const int retval)
|
||||
{
|
||||
retval_ = retval;
|
||||
}
|
||||
|
||||
void set_values(const std::vector<::config>& values, int selected = 0);
|
||||
|
||||
void set_selected(int selected, bool fire_event = true);
|
||||
|
@ -126,14 +121,6 @@ private:
|
|||
*/
|
||||
state_t state_;
|
||||
|
||||
/**
|
||||
* The return value of the button.
|
||||
*
|
||||
* If this value is not 0 and the button is clicked it sets the retval of
|
||||
* the window and the window closes itself.
|
||||
*/
|
||||
int retval_;
|
||||
|
||||
std::vector<::config> values_;
|
||||
|
||||
int selected_;
|
||||
|
@ -190,8 +177,6 @@ public:
|
|||
virtual widget_ptr build() const override;
|
||||
|
||||
private:
|
||||
std::string retval_id_;
|
||||
int retval_;
|
||||
std::vector<::config> options_;
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ REGISTER_WIDGET(multimenu_button)
|
|||
multimenu_button::multimenu_button(const implementation::builder_multimenu_button& builder)
|
||||
: styled_widget(builder, type())
|
||||
, state_(ENABLED)
|
||||
, retval_(retval::NONE)
|
||||
, max_shown_(1)
|
||||
, values_()
|
||||
, toggle_states_()
|
||||
|
@ -139,13 +138,6 @@ void multimenu_button::signal_handler_left_button_click(const event::ui_event ev
|
|||
droplist.show();
|
||||
droplist_ = nullptr;
|
||||
|
||||
if(retval_ != retval::NONE) {
|
||||
if(window* window = get_window()) {
|
||||
window->set_retval(retval_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* In order to allow toggle button states to be specified by various dialogs in the values config, we write the state
|
||||
* bools to the values_ config here, but only if a checkbox= key was already provided. The value of the checkbox= key
|
||||
* is handled by the drop_down_menu widget.
|
||||
|
@ -329,8 +321,6 @@ namespace implementation
|
|||
|
||||
builder_multimenu_button::builder_multimenu_button(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, retval_id_(cfg["return_value_id"])
|
||||
, retval_(cfg["return_value"])
|
||||
, max_shown_(cfg["maximum_shown"])
|
||||
, options_()
|
||||
{
|
||||
|
@ -343,7 +333,6 @@ widget_ptr builder_multimenu_button::build() const
|
|||
{
|
||||
auto widget = std::make_shared<multimenu_button>(*this);
|
||||
|
||||
widget->set_retval(get_retval(retval_id_, retval_, id));
|
||||
widget->set_max_shown(max_shown_);
|
||||
if(!options_.empty()) {
|
||||
widget->set_values(options_);
|
||||
|
|
|
@ -68,11 +68,6 @@ public:
|
|||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
|
||||
void set_retval(const int retval)
|
||||
{
|
||||
retval_ = retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of selected elements shown on the label.
|
||||
* If more are selected, the label will say "and N others".
|
||||
|
@ -164,14 +159,6 @@ private:
|
|||
*/
|
||||
state_t state_;
|
||||
|
||||
/**
|
||||
* The return value of the button.
|
||||
*
|
||||
* If this value is not 0 and the button is clicked it sets the retval of
|
||||
* the window and the window closes itself.
|
||||
*/
|
||||
int retval_;
|
||||
|
||||
/**
|
||||
* The maximum number of selected states to list in the label
|
||||
*/
|
||||
|
@ -238,8 +225,7 @@ public:
|
|||
virtual widget_ptr build() const override;
|
||||
|
||||
private:
|
||||
std::string retval_id_;
|
||||
int retval_, max_shown_;
|
||||
int max_shown_;
|
||||
std::vector<::config> options_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue