Basic template class to generate new items. More...
#include <generator_private.hpp>
Classes | |
struct | child |
Definition of an item. More... | |
Public Member Functions | |
generator () | |
~generator () | |
void | delete_item (const unsigned index) override |
Inherited from generator_base. More... | |
void | clear () override |
Inherited from generator_base. More... | |
void | select_item (const unsigned index, const bool select=true) override |
Inherited from generator_base. More... | |
bool | is_selected (const unsigned index) const override |
Inherited from generator_base. More... | |
void | set_item_shown (const unsigned index, const bool show) override |
Inherited from generator_base. More... | |
virtual bool | get_item_shown (const unsigned index) const override |
Inherited from generator_base. More... | |
unsigned | get_item_count () const override |
Inherited from generator_base. More... | |
unsigned | get_selected_item_count () const override |
Inherited from generator_base. More... | |
int | get_selected_item () const override |
Inherited from generator_base. More... | |
grid & | item (const unsigned index) override |
Inherited from generator_base. More... | |
const grid & | item (const unsigned index) const override |
Inherited from generator_base. More... | |
grid & | item_ordered (const unsigned index) override |
Inherited from generator_base. More... | |
const grid & | item_ordered (const unsigned index) const override |
Inherited from generator_base. More... | |
grid & | create_item (const int index, const builder_grid &list_builder, const widget_item &item_data, const std::function< void(widget &)> &callback) override |
Inherited from generator_base. More... | |
grid & | create_item (const int index, const builder_grid &list_builder, const widget_data &item_data, const std::function< void(widget &)> &callback) override |
Inherited from generator_base. More... | |
virtual void | create_items (const int index, const builder_grid &list_builder, const std::vector< widget_data > &data, const std::function< void(widget &)> &callback) override |
Inherited from generator_base. More... | |
virtual void | create_items (const int index, const builder_grid &list_builder, const std::vector< widget_item > &data, const std::function< void(widget &)> &callback) override |
Inherited from generator_base. More... | |
virtual void | layout_initialize (const bool full_initialization) override |
See widget::layout_initialize. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See widget::request_reduce_height. More... | |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
virtual void | set_origin (const point &origin) override |
See widget::set_origin. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See widget::set_visible_rectangle. More... | |
virtual void | impl_draw_children () override |
See widget::impl_draw_children. More... | |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) override |
See widget::find_at. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const override |
See widget::find_at. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
void | handle_key_up_arrow (SDL_Keymod modifier, bool &handled) override |
Inherited from generator_base. More... | |
void | handle_key_down_arrow (SDL_Keymod modifier, bool &handled) override |
Inherited from generator_base. More... | |
void | handle_key_left_arrow (SDL_Keymod modifier, bool &handled) override |
Inherited from generator_base. More... | |
void | handle_key_right_arrow (SDL_Keymod modifier, bool &handled) override |
Inherited from generator_base. More... | |
Protected Member Functions | |
void | do_select_item (const unsigned index) override |
Inherited from generator_base. More... | |
void | do_deselect_item (const unsigned index) override |
Inherited from generator_base. More... | |
Private Types | |
typedef std::vector< std::unique_ptr< child > > | child_list |
The items in the generator. More... | |
typedef std::function< bool(unsigned, unsigned)> | order_func |
Private Member Functions | |
virtual void | set_order (const order_func &order) override |
virtual unsigned | get_ordered_index (unsigned index) const override |
virtual unsigned | get_item_at_ordered (unsigned index_ordered) const override |
void | calculate_order () const |
void | set_item_selected (const unsigned index, const bool selected) |
Sets the selected state of an item. More... | |
template<class T > | |
void | impl_create_items (const int index, const builder_grid &list_builder, const std::vector< T > &data, const std::function< void(widget &)> &callback) |
Helper function for create_items(). More... | |
void | init (grid *grid, const widget_data &data, const std::function< void(widget &)> &callback) |
Helper function to initialize a grid. More... | |
Private Attributes | |
unsigned | selected_item_count_ |
The number of selected items. More... | |
int | last_selected_item_ |
The last item selected. More... | |
child_list | items_ |
std::vector< std::size_t > | order_ |
the elements of order_ are indexes to items_ More... | |
bool | order_dirty_ |
whether need to recalculate order_dirty_ More... | |
order_func | order_func_ |
Basic template class to generate new items.
The class is policy based so the behavior can be selected.
Definition at line 557 of file generator_private.hpp.
|
private |
The items in the generator.
Definition at line 964 of file generator_private.hpp.
|
private |
Definition at line 972 of file generator_private.hpp.
|
inline |
Definition at line 563 of file generator_private.hpp.
|
inline |
Definition at line 577 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::clear().
|
inlineoverridevirtual |
See widget::calculate_best_size.
Definition at line 801 of file generator_private.hpp.
|
inlineprivate |
Definition at line 996 of file generator_private.hpp.
References i, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_dirty_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_func_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_at_ordered(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_ordered_index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item_ordered().
|
inlineoverride |
Inherited from generator_base.
Definition at line 603 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_dirty_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::~generator().
|
inlineoverride |
Inherited from generator_base.
Definition at line 731 of file generator_private.hpp.
References gui2::builder_grid::build(), utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::init(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::is_selected(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_dirty_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 719 of file generator_private.hpp.
References data, and utf8::index().
Referenced by gui2::tab_container::finalize(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_create_items(), and gui2::stacked_widget::stacked_widget().
|
inlineoverridevirtual |
Inherited from generator_base.
Definition at line 761 of file generator_private.hpp.
References data, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_create_items(), and utf8::index().
Referenced by gui2::listbox::listbox(), and gui2::multi_page::multi_page().
|
inlineoverridevirtual |
Inherited from generator_base.
Definition at line 770 of file generator_private.hpp.
References data, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_create_items(), and utf8::index().
|
inlineoverridevirtual |
Definition at line 875 of file generator_private.hpp.
|
inlineoverride |
Inherited from generator_base.
Definition at line 585 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::is_selected(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_dirty_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item().
|
inlineoverride |
See widget::disable_click_dismiss.
Definition at line 859 of file generator_private.hpp.
References gui2::grid::disable_click_dismiss(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
|
inlineoverrideprotected |
Inherited from generator_base.
Definition at line 917 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_selected().
|
inlineoverrideprotected |
Inherited from generator_base.
Definition at line 908 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_selected().
|
inlineoverridevirtual |
See widget::find_at.
Definition at line 853 of file generator_private.hpp.
|
inlineoverridevirtual |
See widget::find_at.
Definition at line 847 of file generator_private.hpp.
|
inlineoverrideprivatevirtual |
Definition at line 989 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 656 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
|
inlineoverridevirtual |
Inherited from generator_base.
Definition at line 649 of file generator_private.hpp.
References utf8::index(), gui2::widget::invisible, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
|
inlineoverrideprivatevirtual |
|
inlineoverride |
Inherited from generator_base.
Definition at line 668 of file generator_private.hpp.
References FAIL_WITH_DEV_MESSAGE, i, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::last_selected_item_, game_config::images::selected, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 662 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 889 of file generator_private.hpp.
|
inlineoverride |
Inherited from generator_base.
Definition at line 895 of file generator_private.hpp.
|
inlineoverride |
Inherited from generator_base.
Definition at line 901 of file generator_private.hpp.
|
inlineoverride |
Inherited from generator_base.
Definition at line 883 of file generator_private.hpp.
|
inlineprivate |
Helper function for create_items().
T | Type of the data, this should be one of the valid parameters for create_item(). |
index | The item before which to add the new item, 0 == begin, -1 == end. |
list_builder | A grid builder that's will build the contents of the new item. |
data | The data to initialize the parameters of the new item. |
callback | The callback function to call when an item in the grid is (de)selected. |
Definition at line 1050 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), data, i, and utf8::index().
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_items().
|
inlineoverridevirtual |
See widget::impl_draw_children.
Definition at line 831 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), gui2::widget::draw_children(), gui2::widget::get_visible(), utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_, and gui2::widget::visible.
|
inlineprivate |
Helper function to initialize a grid.
The actual part is implemented in select_action, see those implementations for more information.
grid | The grid to initialize. |
data | The data to initialize the parameters of the new item. |
callback | The callback function to call when an item in the grid is (de)selected. |
Definition at line 1077 of file generator_private.hpp.
References data, utils::detail::init, and gui2::widget::set_parent().
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item().
|
inlineoverride |
Inherited from generator_base.
Definition at line 628 of file generator_private.hpp.
References utf8::index(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::delete_item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item().
|
inlineoverride |
Inherited from generator_base.
Definition at line 696 of file generator_private.hpp.
References utf8::index(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 689 of file generator_private.hpp.
References utf8::index(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::disable_click_dismiss(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item().
|
inlineoverride |
Inherited from generator_base.
Definition at line 711 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_.
|
inlineoverride |
Inherited from generator_base.
Definition at line 703 of file generator_private.hpp.
References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_.
|
inlineoverridevirtual |
See widget::layout_initialize.
Definition at line 779 of file generator_private.hpp.
References gui2::widget::get_visible(), gui2::widget::invisible, gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::grid::layout_initialize().
|
inlineoverridevirtual |
See widget::place.
Definition at line 807 of file generator_private.hpp.
References gui2::widget::place(), and utf8::size().
|
inlineoverridevirtual |
See widget::request_reduce_height.
Definition at line 795 of file generator_private.hpp.
|
inlineoverridevirtual |
See widget::request_reduce_width.
Definition at line 789 of file generator_private.hpp.
|
inlineoverride |
Inherited from generator_base.
Definition at line 611 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::is_selected(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::last_selected_item_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::delete_item().
|
inlineprivate |
Sets the selected state of an item.
index | The item to modify. |
selected | Select or deselect. |
Definition at line 1026 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and game_config::images::selected.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_deselect_item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_select_item().
|
inlineoverride |
Inherited from generator_base.
Definition at line 635 of file generator_private.hpp.
References utf8::index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_, and gui2::dialogs::tip::show().
|
inlineoverrideprivatevirtual |
|
inlineoverridevirtual |
See widget::set_origin.
Definition at line 816 of file generator_private.hpp.
References gui2::widget::set_origin().
|
inlineoverridevirtual |
See widget::set_visible_rectangle.
Definition at line 825 of file generator_private.hpp.
|
private |
Definition at line 965 of file generator_private.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::clear(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::delete_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::disable_click_dismiss(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_deselect_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_select_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_at_ordered(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_count(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_shown(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_ordered_index(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::is_selected(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item_ordered(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_selected(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_shown().
|
private |
The last item selected.
Definition at line 961 of file generator_private.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item().
|
mutableprivate |
the elements of order_ are indexes to items_
Definition at line 968 of file generator_private.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_at_ordered(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item_ordered().
|
mutableprivate |
whether need to recalculate order_dirty_
Definition at line 970 of file generator_private.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::clear(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::delete_item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_order().
|
private |
|
private |
The number of selected items.
Definition at line 958 of file generator_private.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::clear(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_deselect_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_select_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item_count().