The Battle for Wesnoth  1.15.13+dev
Public Member Functions | Static Public Member Functions | List of all members
gui2::placer_base Class Referenceabstract

Base class for the placement helper. More...

#include <placer.hpp>

Inheritance diagram for gui2::placer_base:

Public Member Functions

 MAKE_ENUM (grow_direction,(horizontal, "horizontal")(vertical, "vertical"))
 The direction the placer should grow towards. More...
 
virtual ~placer_base ()
 
virtual void initialize ()=0
 Initialises the placer. More...
 
virtual void add_item (const point &size)=0
 Adds a item to be placed. More...
 
virtual point get_size () const =0
 Gets the required size of all items. More...
 
virtual point get_origin (const unsigned index) const =0
 Gets the origin for an item. More...
 

Static Public Member Functions

static placer_basebuild (const grow_direction grow_direction, const unsigned parallel_items)
 Builder function. More...
 

Detailed Description

Base class for the placement helper.

The normal operation for the usage of the class is:

Note
The origins can only be retrieved after all items are added since the adding of a later item may influence a previous item. E.g. in a vertical list with two columns the position of the second column depends on the width of the first and a later row may have a wider column 1 as an earlier row.

Definition at line 50 of file placer.hpp.

Constructor & Destructor Documentation

◆ ~placer_base()

gui2::placer_base::~placer_base ( )
virtual

Definition at line 40 of file placer.cpp.

Member Function Documentation

◆ add_item()

virtual void gui2::placer_base::add_item ( const point size)
pure virtual

Adds a item to be placed.

Parameters
sizeThe required size for the item.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

◆ build()

placer_base * gui2::placer_base::build ( const grow_direction  grow_direction,
const unsigned  parallel_items 
)
static

Builder function.

Precondition
parallel_items > 0
Parameters
grow_directionThe direction in which the items will be added.
parallel_itemsThe direction perpendicular towards the grow direction has a fixed number of items. This value sets that limit. For a list containing only horizontally or vertically placed items the value should be 1.

Definition at line 27 of file placer.cpp.

◆ get_origin()

virtual point gui2::placer_base::get_origin ( const unsigned  index) const
pure virtual

Gets the origin for an item.

Parameters
indexThe index of the item whose origin to return. The index is the index of the call to add_item().
Returns
The origin where to place the widget.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

◆ get_size()

virtual point gui2::placer_base::get_size ( ) const
pure virtual

Gets the required size of all items.

Returns
The required size.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

◆ initialize()

virtual void gui2::placer_base::initialize ( )
pure virtual

Initialises the placer.

When the placement needs to be calculated the state often needs to be reset, items are placed, removed or changed visibility causing the old placement to be invalid.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

◆ MAKE_ENUM()

gui2::placer_base::MAKE_ENUM ( grow_direction  ,
(horizontal, "horizontal")(vertical, "vertical")   
)

The direction the placer should grow towards.


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