#include <group.hpp>
Public Member Functions | |
void | add_member (selectable_item *w, const T &value) |
Adds a widget/value pair to the group map. More... | |
void | remove_member (const T &value) |
Removes a member from the group map. More... | |
void | clear () |
Clears the entire group of members. More... | |
group_map & | members () |
Group member getters. More... | |
const group_map & | members () const |
template<typename W > | |
W & | member (const T &value) |
T | get_active_member_value () const |
Returns the value paired with the currently actively toggled member of the group. More... | |
void | set_member_states (const T &value) |
Sets the toggle values for all widgets besides the one associated with the specified value to false. More... | |
void | set_callback_on_value_change (std::function< void(widget &, const T)> func) |
Sets a common callback function for all members. More... | |
void | set_members_enabled (std::function< bool(const T &)> predicate) |
Wrapper for enabling or disabling member widgets. More... | |
Private Types | |
using | group_map = std::map< T, selectable_item * > |
using | order_vector = std::vector< styled_widget * > |
Private Member Functions | |
void | group_operator () |
The default actions to take when clicking on one of the widgets in the group. More... | |
Private Attributes | |
group_map | members_ |
Container map for group members, organized by member value, associated widget. More... | |
order_vector | member_order_ |
Since iterating over std::map is specified by operator< for it's key values, we can't guarantee the order would line up with the logical order - ie, that which the widgets appear in in a specific dialog. More... | |
|
private |
|
private |
|
inline |
Adds a widget/value pair to the group map.
A callback is set that toggles each members' state to false when clicked. This happens before individual widget handlers fire, ensuring that the clicked widget will remain the only one selected.
Definition at line 42 of file group.hpp.
References gui2::event::dispatcher::connect_signal(), ERR_GUI_G, gui2::event::dispatcher::front_child, gui2::group< T >::group_operator(), gui2::event::LEFT_BUTTON_CLICK, gui2::group< T >::member_order_, gui2::group< T >::members_, and w.
Referenced by gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::editor_edit_side::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::unit_create::pre_show(), and gui2::dialogs::select_orb_colors::setup_orb_group().
|
inline |
Clears the entire group of members.
Definition at line 69 of file group.hpp.
References gui2::group< T >::members_.
|
inline |
Returns the value paired with the currently actively toggled member of the group.
Definition at line 96 of file group.hpp.
References gui2::group< T >::member(), and gui2::group< T >::members_.
Referenced by gui2::dialogs::editor_edit_side::post_show().
|
inlineprivate |
The default actions to take when clicking on one of the widgets in the group.
Definition at line 200 of file group.hpp.
References gui2::group< T >::member(), and gui2::group< T >::members_.
Referenced by gui2::group< T >::add_member().
Definition at line 88 of file group.hpp.
References gui2::group< T >::members_.
Referenced by gui2::group< T >::get_active_member_value(), gui2::group< T >::group_operator(), gui2::group< T >::set_callback_on_value_change(), gui2::group< T >::set_member_states(), and gui2::group< T >::set_members_enabled().
|
inline |
Group member getters.
Definition at line 77 of file group.hpp.
References gui2::group< T >::members_.
|
inline |
Definition at line 82 of file group.hpp.
References gui2::group< T >::members_.
|
inline |
Removes a member from the group map.
Definition at line 61 of file group.hpp.
References gui2::group< T >::members_.
|
inline |
Sets a common callback function for all members.
Definition at line 121 of file group.hpp.
References gui2::event::connect_signal_notify_modified(), gui2::selectable_item::get_value_bool(), gui2::group< T >::member(), gui2::group< T >::members_, and w.
Referenced by gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::faction_select::pre_show(), and gui2::dialogs::unit_create::pre_show().
|
inline |
Sets the toggle values for all widgets besides the one associated with the specified value to false.
Definition at line 111 of file group.hpp.
References gui2::group< T >::member(), and gui2::group< T >::members_.
Referenced by gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::editor_edit_side::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::unit_create::pre_show(), and gui2::dialogs::select_orb_colors::setup_orb_group().
|
inline |
Wrapper for enabling or disabling member widgets.
Each member widget will be enabled or disabled based on the result of the specified predicate, which takes its associated value.
If a selected widget is to be disabled, it is deselected and the first active member selected instead. The same happens if no members were previously active at all.
Definition at line 150 of file group.hpp.
References gui2::group< T >::member(), gui2::group< T >::member_order_, gui2::group< T >::members_, gui2::selectable_item::set_value_bool(), and w.
Referenced by gui2::dialogs::unit_create::list_item_clicked(), and gui2::dialogs::faction_select::on_leader_select().
|
private |
Since iterating over std::map is specified by operator< for it's key values, we can't guarantee the order would line up with the logical order - ie, that which the widgets appear in in a specific dialog.
Keeping a separate vector here allows iterating over members in the order which they are added to the group.
Definition at line 195 of file group.hpp.
Referenced by gui2::group< T >::add_member(), and gui2::group< T >::set_members_enabled().
|
private |
Container map for group members, organized by member value, associated widget.
Definition at line 187 of file group.hpp.
Referenced by gui2::group< T >::add_member(), gui2::group< T >::clear(), gui2::group< T >::get_active_member_value(), gui2::group< T >::group_operator(), gui2::group< T >::member(), gui2::group< T >::members(), gui2::group< T >::remove_member(), gui2::group< T >::set_callback_on_value_change(), gui2::group< T >::set_member_states(), and gui2::group< T >::set_members_enabled().