The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui2::generator< minimum_selection, maximum_selection, my_placement, select_action > Class Template Reference

Basic template class to generate new items. More...

#include <generator_private.hpp>

Inheritance diagram for gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >:
Inheritance graph

Classes

struct  calculate_order_helper
 
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...
 
griditem (const unsigned index) override
 Inherited from generator_base. More...
 
const griditem (const unsigned index) const override
 Inherited from generator_base. More...
 
griditem_ordered (const unsigned index) override
 Inherited from generator_base. More...
 
const griditem_ordered (const unsigned index) const override
 Inherited from generator_base. More...
 
gridcreate_item (const int index, builder_grid_const_ptr list_builder, const string_map &item_data, const std::function< void(widget &)> &callback) override
 Inherited from generator_base. More...
 
gridcreate_item (const int index, builder_grid_const_ptr list_builder, const std::map< std::string, string_map > &item_data, const std::function< void(widget &)> &callback) override
 Inherited from generator_base. More...
 
virtual void create_items (const int index, builder_grid_const_ptr list_builder, const std::vector< std::map< std::string, string_map >> &data, const std::function< void(widget &)> &callback) override
 Inherited from generator_base. More...
 
virtual void create_items (const int index, builder_grid_const_ptr list_builder, const std::vector< string_map > &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 (surface &frame_buffer, int x_offset, int y_offset) override
 See widget::impl_draw_children. More...
 
virtual void child_populate_dirty_list (window &caller, const std::vector< widget * > &call_stack) override
 See widget::child_populate_dirty_list. More...
 
virtual widgetfind_at (const point &coordinate, const bool must_be_active) override
 See widget::find_at. More...
 
virtual const widgetfind_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_basecreate_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, builder_grid_const_ptr list_builder, const std::vector< T > &data, const std::function< void(widget &)> &callback)
 Helper function for create_items(). More...
 
void init (grid *grid, const std::map< std::string, string_map > &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< 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_
 

Detailed Description

template<class minimum_selection, class maximum_selection, class my_placement, class select_action>
class gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >

Basic template class to generate new items.

The class is policy based so the behavior can be selected.

Definition at line 554 of file generator_private.hpp.

Member Typedef Documentation

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
typedef std::vector<std::unique_ptr<child> > gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::child_list
private

The items in the generator.

Definition at line 971 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
typedef std::function<bool(unsigned, unsigned)> gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_func
private

Definition at line 979 of file generator_private.hpp.

Constructor & Destructor Documentation

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::generator ( )
inline

Definition at line 560 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::~generator ( )
inline

Member Function Documentation

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual point gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_best_size ( ) const
inlineoverridevirtual

See widget::calculate_best_size.

Definition at line 799 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::calculate_order ( ) const
inlineprivate
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::child_populate_dirty_list ( window caller,
const std::vector< widget * > &  call_stack 
)
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::clear ( )
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item ( const int  index,
builder_grid_const_ptr  list_builder,
const string_map item_data,
const std::function< void(widget &)> &  callback 
)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item ( const int  index,
builder_grid_const_ptr  list_builder,
const std::map< std::string, string_map > &  item_data,
const std::function< void(widget &)> &  callback 
)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_items ( const int  index,
builder_grid_const_ptr  list_builder,
const std::vector< std::map< std::string, string_map >> &  data,
const std::function< void(widget &)> &  callback 
)
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_items ( const int  index,
builder_grid_const_ptr  list_builder,
const std::vector< string_map > &  data,
const std::function< void(widget &)> &  callback 
)
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual iteration::walker_base* gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_walker ( )
inlineoverridevirtual

See widget::create_walker.

Todo:
Implement properly.

Definition at line 882 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::delete_item ( const unsigned  index)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
bool gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::disable_click_dismiss ( ) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_deselect_item ( const unsigned  index)
inlineoverrideprotected
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::do_select_item ( const unsigned  index)
inlineoverrideprotected
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual widget* gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::find_at ( const point coordinate,
const bool  must_be_active 
)
inlineoverridevirtual

See widget::find_at.

Definition at line 854 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual const widget* gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::find_at ( const point coordinate,
const bool  must_be_active 
) const
inlineoverridevirtual

See widget::find_at.

Definition at line 860 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual unsigned gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_at_ordered ( unsigned  index_ordered) const
inlineoverrideprivatevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
unsigned gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_count ( ) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual bool gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_item_shown ( const unsigned  index) const
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual unsigned gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_ordered_index ( unsigned  index) const
inlineoverrideprivatevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
int gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item ( ) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
unsigned gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item_count ( ) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::handle_key_down_arrow ( SDL_Keymod  modifier,
bool &  handled 
)
inlineoverride

Inherited from generator_base.

Definition at line 896 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::handle_key_left_arrow ( SDL_Keymod  modifier,
bool &  handled 
)
inlineoverride

Inherited from generator_base.

Definition at line 902 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::handle_key_right_arrow ( SDL_Keymod  modifier,
bool &  handled 
)
inlineoverride

Inherited from generator_base.

Definition at line 908 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::handle_key_up_arrow ( SDL_Keymod  modifier,
bool &  handled 
)
inlineoverride

Inherited from generator_base.

Definition at line 890 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
template<class T >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_create_items ( const int  index,
builder_grid_const_ptr  list_builder,
const std::vector< T > &  data,
const std::function< void(widget &)> &  callback 
)
inlineprivate

Helper function for create_items().

Template Parameters
TType of the data, this should be one of the valid parameters for create_item().
Parameters
indexThe item before which to add the new item, 0 == begin, -1 == end.
list_builderA grid builder that's will build the contents of the new item.
dataThe data to initialize the parameters of the new item.
callbackThe callback function to call when an item in the grid is (de)selected.

Definition at line 1074 of file generator_private.hpp.

References gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), i, and utf8::index().

Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_items().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children ( surface frame_buffer,
int  x_offset,
int  y_offset 
)
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::init ( grid grid,
const std::map< std::string, string_map > &  data,
const std::function< void(widget &)> &  callback 
)
inlineprivate

Helper function to initialize a grid.

The actual part is implemented in select_action, see those implementations for more information.

Parameters
gridThe grid to initialize.
dataThe data to initialize the parameters of the new item.
callbackThe callback function to call when an item in the grid is (de)selected.

Definition at line 1101 of file generator_private.hpp.

References ai::registry::init(), and gui2::widget::set_parent().

Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
bool gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::is_selected ( const unsigned  index) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item ( const unsigned  index)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
const grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item ( const unsigned  index) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item_ordered ( const unsigned  index)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
const grid& gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::item_ordered ( const unsigned  index) const
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize ( const bool  full_initialization)
inlineoverridevirtual
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::place ( const point origin,
const point size 
)
inlineoverridevirtual

See widget::place.

Definition at line 805 of file generator_private.hpp.

References gui2::widget::place().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::request_reduce_height ( const unsigned  maximum_height)
inlineoverridevirtual

See widget::request_reduce_height.

Definition at line 793 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::request_reduce_width ( const unsigned  maximum_width)
inlineoverridevirtual

See widget::request_reduce_width.

Definition at line 787 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::select_item ( const unsigned  index,
const bool  select = true 
)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_selected ( const unsigned  index,
const bool  selected 
)
inlineprivate

Sets the selected state of an item.

Parameters
indexThe item to modify.
selectedSelect or deselect.

Definition at line 1050 of file generator_private.hpp.

References utf8::index().

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().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_shown ( const unsigned  index,
const bool  show 
)
inlineoverride
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_order ( const order_func order)
inlineoverrideprivatevirtual

Definition at line 982 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_origin ( const point origin)
inlineoverridevirtual

See widget::set_origin.

Definition at line 814 of file generator_private.hpp.

References gui2::widget::set_origin().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual void gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_visible_rectangle ( const SDL_Rect &  rectangle)
inlineoverridevirtual

See widget::set_visible_rectangle.

Definition at line 823 of file generator_private.hpp.

Member Data Documentation

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
child_list gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::items_
private

Definition at line 972 of file generator_private.hpp.

Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::child_populate_dirty_list(), 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_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_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(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_item_shown().

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
int gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::last_selected_item_
private
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
std::vector<size_t> gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_
mutableprivate
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
bool gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_dirty_
mutableprivate
template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
order_func gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_func_
private

Definition at line 980 of file generator_private.hpp.

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
unsigned gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::selected_item_count_
private

The documentation for this class was generated from the following file: