The Battle for Wesnoth  1.17.12+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

Definition at line 577 of file generator_private.hpp.

References gui2::generator_base::clear().

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

Definition at line 996 of file generator_private.hpp.

References i.

◆ 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

Inherited from generator_base.

Definition at line 603 of file generator_private.hpp.

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

Inherited from generator_base.

Definition at line 719 of file generator_private.hpp.

References gui2::policy::minimum_selection::one_item::create_item(), and data.

◆ 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_data 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

Inherited from generator_base.

Definition at line 761 of file generator_private.hpp.

◆ 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

Inherited from generator_base.

Definition at line 770 of file generator_private.hpp.

◆ 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

Inherited from generator_base.

Definition at line 917 of file generator_private.hpp.

◆ 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

Inherited from generator_base.

Definition at line 908 of file generator_private.hpp.

◆ find_at() [1/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.

◆ find_at() [2/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.

◆ 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

Definition at line 989 of file generator_private.hpp.

◆ 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

Inherited from generator_base.

Definition at line 656 of file generator_private.hpp.

◆ 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

Inherited from generator_base.

Definition at line 649 of file generator_private.hpp.

References utf8::index(), and gui2::widget::invisible.

◆ 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

Definition at line 982 of file generator_private.hpp.

References utf8::index().

◆ 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

Inherited from generator_base.

Definition at line 668 of file generator_private.hpp.

References FAIL_WITH_DEV_MESSAGE, and i.

◆ 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

Inherited from generator_base.

Definition at line 662 of file generator_private.hpp.

◆ 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::policy::minimum_selection::one_item::create_item(), i, and utf8::index().

◆ 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 utils::detail::init, and gui2::widget::set_parent().

◆ 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

Inherited from generator_base.

Definition at line 628 of file generator_private.hpp.

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

Inherited from generator_base.

Definition at line 689 of file generator_private.hpp.

References utf8::index().

◆ item() [2/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

Inherited from generator_base.

Definition at line 696 of file generator_private.hpp.

References utf8::index().

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

Inherited from generator_base.

Definition at line 703 of file generator_private.hpp.

References utf8::index().

◆ item_ordered() [2/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

Inherited from generator_base.

Definition at line 711 of file generator_private.hpp.

References utf8::index().

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

◆ 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

Sets the selected state of an item.

Parameters
indexThe item to modify.
selectedSelect or deselect.

Definition at line 1026 of file generator_private.hpp.

References utf8::index().

◆ 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

Definition at line 975 of file generator_private.hpp.

References gui2::widget::queue_redraw().

◆ 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.

◆ 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

The last item selected.

Definition at line 961 of file generator_private.hpp.

◆ 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

the elements of order_ are indexes to items_

Definition at line 968 of file generator_private.hpp.

◆ 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

whether need to recalculate order_dirty_

Definition at line 970 of file generator_private.hpp.

◆ 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

Definition at line 973 of file generator_private.hpp.

◆ 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 number of selected items.

Definition at line 958 of file generator_private.hpp.


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