The Battle for Wesnoth  1.19.7+dev
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 >:

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...
 
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, const builder_grid &list_builder, const widget_item &item_data, const std::function< void(widget &)> &callback) override
 Inherited from generator_base. More...
 
gridcreate_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 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_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_
 

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 557 of file generator_private.hpp.

Member Typedef Documentation

◆ child_list

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 964 of file generator_private.hpp.

◆ order_func

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 972 of file generator_private.hpp.

Constructor & Destructor Documentation

◆ generator()

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 563 of file generator_private.hpp.

◆ ~generator()

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

◆ calculate_best_size()

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 801 of file generator_private.hpp.

◆ calculate_order()

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

◆ clear()

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

◆ create_item() [1/2]

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,
const builder_grid list_builder,
const widget_data item_data,
const std::function< void(widget &)> &  callback 
)
inlineoverride

◆ create_item() [2/2]

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,
const builder_grid list_builder,
const widget_item item_data,
const std::function< void(widget &)> &  callback 
)
inlineoverride

◆ create_items() [1/2]

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,
const builder_grid list_builder,
const std::vector< widget_data > &  data,
const std::function< void(widget &)> &  callback 
)
inlineoverridevirtual

◆ create_items() [2/2]

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,
const builder_grid list_builder,
const std::vector< widget_item > &  data,
const std::function< void(widget &)> &  callback 
)
inlineoverridevirtual

◆ create_walker()

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
virtual iteration::walker_ptr gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_walker ( )
inlineoverridevirtual

See widget::create_walker.

Todo:
Implement properly.

Definition at line 875 of file generator_private.hpp.

◆ delete_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 >::delete_item ( const unsigned  index)
inlineoverride

◆ disable_click_dismiss()

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

◆ do_deselect_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 >::do_deselect_item ( const unsigned  index)
inlineoverrideprotected

◆ 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 >::do_select_item ( const unsigned  index)
inlineoverrideprotected

◆ find_at() [1/2]

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 853 of file generator_private.hpp.

◆ find_at() [2/2]

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 847 of file generator_private.hpp.

◆ get_item_at_ordered()

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

◆ get_item_count()

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

◆ get_item_shown()

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

◆ get_ordered_index()

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

◆ get_selected_item()

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

◆ get_selected_item_count()

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

◆ handle_key_down_arrow()

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 889 of file generator_private.hpp.

◆ handle_key_left_arrow()

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 895 of file generator_private.hpp.

◆ handle_key_right_arrow()

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 901 of file generator_private.hpp.

◆ handle_key_up_arrow()

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 883 of file generator_private.hpp.

◆ impl_create_items()

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,
const builder_grid 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 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().

◆ impl_draw_children()

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

◆ init()

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

◆ is_selected()

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

◆ item() [1/2]

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

◆ item() [2/2]

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

◆ item_ordered() [1/2]

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

◆ item_ordered() [2/2]

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

◆ layout_initialize()

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

◆ 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 >::place ( const point origin,
const point size 
)
inlineoverridevirtual

See widget::place.

Definition at line 807 of file generator_private.hpp.

References gui2::widget::place(), and utf8::size().

◆ request_reduce_height()

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 795 of file generator_private.hpp.

◆ request_reduce_width()

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 789 of file generator_private.hpp.

◆ 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 >::select_item ( const unsigned  index,
const bool  select = true 
)
inlineoverride

◆ set_item_selected()

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

◆ set_item_shown()

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

◆ set_order()

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

◆ 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_origin ( const point origin)
inlineoverridevirtual

See widget::set_origin.

Definition at line 816 of file generator_private.hpp.

References gui2::widget::set_origin().

◆ set_visible_rectangle()

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 825 of file generator_private.hpp.

Member Data Documentation

◆ items_

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

◆ last_selected_item_

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

◆ order_

template<class minimum_selection , class maximum_selection , class my_placement , class select_action >
std::vector<std::size_t> gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::order_
mutableprivate

◆ order_dirty_

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

◆ order_func_

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

◆ selected_item_count_

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: