taddon_filter_options: simplify radio buttons with groups
This commit is contained in:
parent
82b089e478
commit
dfe6f6c935
2 changed files with 17 additions and 38 deletions
|
@ -175,38 +175,14 @@ void taddon_filter_options::toggle_all_displayed_types_button_callback(
|
|||
}
|
||||
}
|
||||
|
||||
void taddon_filter_options::toggle_sort_callback(ttoggle_button* active)
|
||||
void taddon_filter_options::toggle_sort_callback()
|
||||
{
|
||||
FOREACH(const AUTO & e, sort_tgroup_)
|
||||
{
|
||||
ttoggle_button* const b = e.first;
|
||||
if(b == NULL) {
|
||||
continue;
|
||||
} else if(b == active && !b->get_value()) {
|
||||
b->set_value(true);
|
||||
} else if(b == active) {
|
||||
sort_ = e.second;
|
||||
} else if(b != active && b->get_value()) {
|
||||
b->set_value(false);
|
||||
}
|
||||
}
|
||||
sort_ = sort_tgroup_.get_active_member_value();
|
||||
}
|
||||
|
||||
void taddon_filter_options::toggle_dir_callback(ttoggle_button* active)
|
||||
void taddon_filter_options::toggle_dir_callback()
|
||||
{
|
||||
FOREACH(const AUTO & e, dir_tgroup_)
|
||||
{
|
||||
ttoggle_button* const b = e.first;
|
||||
if(b == NULL) {
|
||||
continue;
|
||||
} else if(b == active && !b->get_value()) {
|
||||
b->set_value(true);
|
||||
} else if(b == active) {
|
||||
dir_ = e.second;
|
||||
} else if(b != active && b->get_value()) {
|
||||
b->set_value(false);
|
||||
}
|
||||
}
|
||||
dir_ = dir_tgroup_.get_active_member_value();
|
||||
}
|
||||
|
||||
void taddon_filter_options::pre_show(CVideo& /*video*/, twindow& window)
|
||||
|
@ -251,11 +227,12 @@ void taddon_filter_options::register_sort_toggle(twindow& window,
|
|||
= &find_widget<ttoggle_button>(&window, "sort_" + toggle_id, false);
|
||||
|
||||
b->set_value(value == sort_);
|
||||
|
||||
sort_tgroup_.add_member(b, value);
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
*b,
|
||||
boost::bind(&taddon_filter_options::toggle_sort_callback, this, b));
|
||||
|
||||
sort_tgroup_.push_back(std::make_pair(b, value));
|
||||
boost::bind(&taddon_filter_options::toggle_sort_callback, this));
|
||||
}
|
||||
|
||||
void taddon_filter_options::register_dir_toggle(twindow& window,
|
||||
|
@ -266,11 +243,12 @@ void taddon_filter_options::register_dir_toggle(twindow& window,
|
|||
= &find_widget<ttoggle_button>(&window, "sort_" + toggle_id, false);
|
||||
|
||||
b->set_value(value == dir_);
|
||||
|
||||
dir_tgroup_.add_member(b, value);
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
*b,
|
||||
boost::bind(&taddon_filter_options::toggle_dir_callback, this, b));
|
||||
|
||||
dir_tgroup_.push_back(std::make_pair(b, value));
|
||||
boost::bind(&taddon_filter_options::toggle_dir_callback, this));
|
||||
}
|
||||
|
||||
void taddon_filter_options::post_show(twindow& window)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define GUI_DIALOGS_ADDON_FILTER_OPTIONS_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
#include "gui/widgets/group.hpp"
|
||||
|
||||
#include "addon/validation.hpp"
|
||||
#include "addon/state.hpp"
|
||||
|
@ -85,8 +86,8 @@ private:
|
|||
typedef std::pair<ttoggle_button*, ADDON_SORT_DIRECTION> dir_toggle;
|
||||
|
||||
// Dialog display state variables.
|
||||
std::vector<sort_toggle> sort_tgroup_;
|
||||
std::vector<dir_toggle> dir_tgroup_;
|
||||
tgroup<ADDON_SORT> sort_tgroup_;
|
||||
tgroup<ADDON_SORT_DIRECTION> dir_tgroup_;
|
||||
|
||||
void register_displayed_type_field(const std::string& field_id,
|
||||
ADDON_TYPE addon_type);
|
||||
|
@ -102,8 +103,8 @@ private:
|
|||
const std::string& toggle_id,
|
||||
ADDON_SORT_DIRECTION value);
|
||||
|
||||
void toggle_sort_callback(ttoggle_button* active);
|
||||
void toggle_dir_callback(ttoggle_button* active);
|
||||
void toggle_sort_callback();
|
||||
void toggle_dir_callback();
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue