Basic template class to generate new items. More...
#include <generator_private.hpp>
Classes | |
struct | calculate_order_helper |
struct | titem |
Definition of an item. More... | |
Public Member Functions | |
tgenerator () | |
~tgenerator () | |
void | delete_item (const unsigned index) |
Inherited from tgenerator_. More... | |
void | clear () |
Inherited from tgenerator_. More... | |
void | select_item (const unsigned index, const bool select=true) |
Inherited from tgenerator_. More... | |
bool | is_selected (const unsigned index) const |
Inherited from tgenerator_. More... | |
void | set_item_shown (const unsigned index, const bool show) |
Inherited from tgenerator_. More... | |
virtual bool | get_item_shown (const unsigned index) const |
Inherited from tgenerator_. More... | |
unsigned | get_item_count () const |
Inherited from tgenerator_. More... | |
unsigned | get_selected_item_count () const |
Inherited from tgenerator_. More... | |
int | get_selected_item () const |
Inherited from tgenerator_. More... | |
tgrid & | item (const unsigned index) |
Inherited from tgenerator_. More... | |
const tgrid & | item (const unsigned index) const |
Inherited from tgenerator_. More... | |
tgrid & | item_ordered (const unsigned index) |
Inherited from tgenerator_. More... | |
const tgrid & | item_ordered (const unsigned index) const |
Inherited from tgenerator_. More... | |
tgrid & | create_item (const int index, tbuilder_grid_const_ptr list_builder, const string_map &item_data, const std::function< void(twidget &)> &callback) |
Inherited from tgenerator_. More... | |
tgrid & | create_item (const int index, tbuilder_grid_const_ptr list_builder, const std::map< std::string, string_map > &item_data, const std::function< void(twidget &)> &callback) |
Inherited from tgenerator_. More... | |
virtual void | create_items (const int index, tbuilder_grid_const_ptr list_builder, const std::vector< std::map< std::string, string_map > > &data, const std::function< void(twidget &)> &callback) |
Inherited from tgenerator_. More... | |
virtual void | create_items (const int index, tbuilder_grid_const_ptr list_builder, const std::vector< string_map > &data, const std::function< void(twidget &)> &callback) |
Inherited from tgenerator_. More... | |
virtual void | layout_initialise (const bool full_initialisation) override |
See twidget::layout_initialise. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See twidget::request_reduce_width. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See twidget::request_reduce_height. More... | |
virtual tpoint | calculate_best_size () const override |
See twidget::calculate_best_size. More... | |
virtual void | place (const tpoint &origin, const tpoint &size) override |
See twidget::place. More... | |
virtual void | set_origin (const tpoint &origin) override |
See twidget::set_origin. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See twidget::set_visible_rectangle. More... | |
virtual void | impl_draw_children (surface &frame_buffer, int x_offset, int y_offset) override |
See twidget::impl_draw_children. More... | |
virtual void | child_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack) override |
See twidget::child_populate_dirty_list. More... | |
virtual twidget * | find_at (const tpoint &coordinate, const bool must_be_active) override |
See twidget::find_at. More... | |
virtual const twidget * | find_at (const tpoint &coordinate, const bool must_be_active) const override |
See twidget::find_at. More... | |
bool | disable_click_dismiss () const override |
See twidget::disable_click_dismiss. More... | |
virtual iterator::twalker_ * | create_walker () override |
See twidget::create_walker. More... | |
void | handle_key_up_arrow (SDLMod modifier, bool &handled) |
Inherited from tgenerator_. More... | |
void | handle_key_down_arrow (SDLMod modifier, bool &handled) |
Inherited from tgenerator_. More... | |
void | handle_key_left_arrow (SDLMod modifier, bool &handled) |
Inherited from tgenerator_. More... | |
void | handle_key_right_arrow (SDLMod modifier, bool &handled) |
Inherited from tgenerator_. More... | |
Protected Member Functions | |
void | do_select_item (const unsigned index) |
Inherited from tgenerator_. More... | |
void | do_deselect_item (const unsigned index) |
Inherited from tgenerator_. More... | |
Private Types | |
typedef std::vector< titem * > | titems |
The items in the generator. More... | |
typedef std::function< bool(unsigned, unsigned)> | torder_func |
Private Member Functions | |
virtual void | set_order (const torder_func &order) override |
virtual unsigned | get_ordered_index (unsigned index) const |
virtual unsigned | get_item_at_ordered (unsigned index_ordered) const |
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, tbuilder_grid_const_ptr list_builder, const std::vector< T > &data, const std::function< void(twidget &)> &callback) |
Helper function for create_items(). More... | |
void | init (tgrid *grid, const std::map< std::string, string_map > &data, const std::function< void(twidget &)> &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... | |
titems | items_ |
std::vector< size_t > | order_ |
the elements of order_ are indexes to items_ More... | |
bool | order_dirty_ |
whether need to recalculate order_dirty_ More... | |
torder_func | order_func_ |
Basic template class to generate new items.
The class is policy based so the behavior can be selected.
Definition at line 590 of file generator_private.hpp.
|
private |
The items in the generator.
Definition at line 1021 of file generator_private.hpp.
|
private |
Definition at line 1029 of file generator_private.hpp.
|
inline |
Definition at line 596 of file generator_private.hpp.
|
inline |
Definition at line 610 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::clear().
|
inlineoverridevirtual |
See twidget::calculate_best_size.
Definition at line 845 of file generator_private.hpp.
|
inlineprivate |
Definition at line 1071 of file generator_private.hpp.
References i.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_item_at_ordered(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_ordered_index(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item_ordered().
|
inlineoverridevirtual |
See twidget::child_populate_dirty_list.
Definition at line 894 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::twidget::populate_dirty_list().
|
inline |
Inherited from tgenerator_.
Definition at line 637 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_dirty_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::selected_item_count_.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::~tgenerator().
|
inline |
Inherited from tgenerator_.
Definition at line 762 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_create_items().
|
inline |
Inherited from tgenerator_.
Definition at line 774 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::init(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::is_selected(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_dirty_.
|
inlinevirtual |
Inherited from tgenerator_.
Definition at line 800 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_create_items().
|
inlinevirtual |
Inherited from tgenerator_.
Definition at line 811 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_create_items().
|
inlineoverridevirtual |
Definition at line 935 of file generator_private.hpp.
|
inline |
Inherited from tgenerator_.
Definition at line 618 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::is_selected(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_dirty_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::select_item().
|
inlineoverride |
See twidget::disable_click_dismiss.
Definition at line 919 of file generator_private.hpp.
References gui2::tgrid::disable_click_dismiss(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
|
inlineprotected |
Inherited from tgenerator_.
Definition at line 977 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::selected_item_count_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::set_item_selected().
|
inlineprotected |
Inherited from tgenerator_.
Definition at line 968 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::selected_item_count_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::set_item_selected().
|
inlineoverridevirtual |
See twidget::find_at.
Definition at line 905 of file generator_private.hpp.
|
inlineoverridevirtual |
See twidget::find_at.
Definition at line 912 of file generator_private.hpp.
|
inlineprivatevirtual |
Definition at line 1064 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::calculate_order().
|
inline |
Inherited from tgenerator_.
Definition at line 697 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
|
inlinevirtual |
Inherited from tgenerator_.
Definition at line 689 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
|
inlineprivatevirtual |
Definition at line 1057 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::calculate_order().
|
inline |
Inherited from tgenerator_.
Definition at line 709 of file generator_private.hpp.
References ERROR_LOG, i, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::last_selected_item_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::selected_item_count_.
|
inline |
Inherited from tgenerator_.
Definition at line 703 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::selected_item_count_.
|
inline |
Inherited from tgenerator_.
Definition at line 949 of file generator_private.hpp.
|
inline |
Inherited from tgenerator_.
Definition at line 955 of file generator_private.hpp.
|
inline |
Inherited from tgenerator_.
Definition at line 961 of file generator_private.hpp.
|
inline |
Inherited from tgenerator_.
Definition at line 943 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 1123 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item(), and i.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_items().
|
inlineoverridevirtual |
See twidget::impl_draw_children.
Definition at line 875 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::calculate_order(), gui2::twidget::draw_children(), gui2::twidget::get_visible(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::titem::grid, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::titem::shown, and gui2::twidget::tvisible::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 1150 of file generator_private.hpp.
References ai::registry::init(), and gui2::twidget::set_parent().
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item().
|
inline |
Inherited from tgenerator_.
Definition at line 665 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::delete_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::select_item().
|
inline |
Inherited from tgenerator_.
Definition at line 731 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::child_populate_dirty_list(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::clear(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::disable_click_dismiss(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::layout_initialise(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::select_item().
|
inline |
Inherited from tgenerator_.
Definition at line 738 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_.
|
inline |
Inherited from tgenerator_.
Definition at line 745 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::calculate_order(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_.
|
inline |
Inherited from tgenerator_.
Definition at line 753 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::calculate_order(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::order_.
|
inlineoverridevirtual |
See twidget::layout_initialise.
Definition at line 820 of file generator_private.hpp.
References gui2::twidget::get_visible(), gui2::twidget::tvisible::invisible, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::tgrid::layout_initialise().
|
inlineoverridevirtual |
See twidget::place.
Definition at line 851 of file generator_private.hpp.
References gui2::twidget::place().
|
inlineoverridevirtual |
See twidget::request_reduce_height.
Definition at line 839 of file generator_private.hpp.
|
inlineoverridevirtual |
See twidget::request_reduce_width.
Definition at line 833 of file generator_private.hpp.
|
inline |
Inherited from tgenerator_.
Definition at line 648 of file generator_private.hpp.
References gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::is_selected(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::last_selected_item_.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, 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 1099 of file generator_private.hpp.
References preferences::grid().
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_deselect_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_select_item().
|
inline |
Inherited from tgenerator_.
Definition at line 672 of file generator_private.hpp.
References gui2::twidget::tvisible::invisible, gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::items_, gui2::tip::show(), and gui2::twidget::tvisible::visible.
|
inlineoverrideprivatevirtual |
Definition at line 1033 of file generator_private.hpp.
|
inlineoverridevirtual |
See twidget::set_origin.
Definition at line 860 of file generator_private.hpp.
References gui2::twidget::set_origin().
|
inlineoverridevirtual |
See twidget::set_visible_rectangle.
Definition at line 869 of file generator_private.hpp.
|
private |
Definition at line 1022 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::child_populate_dirty_list(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::clear(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::delete_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::disable_click_dismiss(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_deselect_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_select_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_item_count(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_item_shown(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_selected_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::is_selected(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item_ordered(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::layout_initialise(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::select_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::set_item_shown().
|
private |
The last item selected.
Definition at line 1018 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_selected_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::select_item().
|
mutableprivate |
the elements of order_ are indexes to items_
Definition at line 1025 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::item_ordered().
|
mutableprivate |
whether need to recalculate order_dirty_
Definition at line 1027 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::clear(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::create_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::delete_item().
|
private |
Definition at line 1030 of file generator_private.hpp.
|
private |
The number of selected items.
Definition at line 1015 of file generator_private.hpp.
Referenced by gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::clear(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_deselect_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::do_select_item(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_selected_item(), and gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::get_selected_item_count().