The Battle for Wesnoth  1.17.10+dev
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
editor::editor_palette< Item > Class Template Referenceabstract

#include <editor_palettes.hpp>

Inheritance diagram for editor::editor_palette< Item >:

Public Member Functions

 editor_palette (editor_display &gui, const game_config_view &, std::size_t item_size, std::size_t columns, editor_toolkit &toolkit)
 
virtual sdl_handler_vector handler_members () override
 
void set_start_item (std::size_t index) override
 
std::size_t start_num (void) override
 
void expand_palette_groups_menu (std::vector< config > &items, int i) override
 Menu expanding for palette group list. More...
 
void set_group (std::size_t index) override
 
const std::vector< item_group > & get_groups () const override
 
virtual void layout () override
 Called by draw_manager to validate layout before drawing. More...
 
virtual void draw_contents () override
 Called by widget::draw() More...
 
void next_group () override
 
void prev_group () override
 
void adjust_size (const SDL_Rect &target) override
 Update the size of this widget. More...
 
virtual bool scroll_up () override
 Scroll the editor-palette up one step if possible. More...
 
virtual bool can_scroll_up () override
 
virtual bool scroll_down () override
 Scroll the editor-palette down one step if possible. More...
 
virtual bool can_scroll_down () override
 
void swap () override
 
virtual std::string get_help_string ()=0
 
const Item & selected_fg_item () const
 Return the currently selected foreground/background item. More...
 
const Item & selected_bg_item () const
 
- Public Member Functions inherited from editor::tristate_palette
 tristate_palette ()
 
- Public Member Functions inherited from editor::common_palette
 common_palette ()
 
virtual ~common_palette ()
 
virtual bool supports_swap ()
 
virtual std::vector< std::string > action_pressed () const
 
- Public Member Functions inherited from gui::widget
const rectlocation () const
 
virtual void set_location (const SDL_Rect &rect)
 
void set_location (int x, int y)
 
void set_width (int w)
 
void set_height (int h)
 
void set_measurements (int w, int h)
 
int width () const
 
int height () const
 
bool focus (const SDL_Event *event)
 
void set_focus (bool focus)
 
bool hidden () const
 
virtual void enable (bool new_val=true)
 
bool enabled () const
 
void set_clip_rect (const SDL_Rect &rect)
 
void queue_redraw ()
 Indicate that the widget should be redrawn. More...
 
void queue_redraw (const rect &)
 Indicate that a specific region of the screen should be redrawn. More...
 
void set_dirty (bool dirty=true)
 
bool dirty () const
 
const std::string & id () const
 
void set_id (const std::string &id)
 
void set_help_string (const std::string &str)
 
void set_tooltip_string (const std::string &str)
 
virtual void process_help_string (int mousex, int mousey) override
 
virtual void process_tooltip_string (int mousex, int mousey) override
 
virtual bool expose (const rect &region) override
 Called by draw_manager when it believes a redraw is necessary. More...
 
virtual rect screen_location () override
 The current draw location of the display, on the screen. More...
 
- Public Member Functions inherited from events::sdl_handler
virtual void handle_window_event (const SDL_Event &)
 
virtual void process_event ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
virtual void join ()
 
virtual void join (context &c)
 
virtual void join_same (sdl_handler *parent)
 
virtual void leave ()
 
virtual void join_global ()
 
virtual void leave_global ()
 
virtual bool has_joined ()
 
virtual bool has_joined_global ()
 
sdl_handleroperator= (sdl_handler &&)=delete
 Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More...
 
 sdl_handler (sdl_handler &&)=delete
 
- Public Member Functions inherited from gui2::top_level_drawable
virtual void update ()
 Update state and any parameters that may effect layout, or any of the later stages. More...
 
virtual void render ()
 Perform any internal rendering necessary to prepare the drawable. More...
 

Protected Types

typedef std::map< std::string, Item > item_map
 

Protected Member Functions

virtual void set_group (const std::string &id)
 Sets a group active id. More...
 
const std::vector< std::string > & active_group ()
 
virtual void select_fg_item (const std::string &item_id) override
 Select a foreground item. More...
 
virtual void select_bg_item (const std::string &item_id) override
 
- Protected Member Functions inherited from gui::widget
 widget (const bool auto_join=true)
 
virtual ~widget ()
 
virtual void update_location (const SDL_Rect &)
 
virtual void handle_event (const SDL_Event &) override
 
bool mouse_locked () const
 
void aquire_mouse_lock ()
 
void free_mouse_lock ()
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
 sdl_handler (const sdl_handler &)
 
sdl_handleroperator= (const sdl_handler &)
 
virtual ~sdl_handler ()
 
- Protected Member Functions inherited from gui2::top_level_drawable
 top_level_drawable ()
 
virtual ~top_level_drawable ()
 
 top_level_drawable (const top_level_drawable &)
 
top_level_drawableoperator= (const top_level_drawable &)
 
 top_level_drawable (top_level_drawable &&)
 
top_level_drawableoperator= (top_level_drawable &&)
 

Protected Attributes

std::vector< item_groupgroups_
 The editor_groups as defined in editor-groups.cfg. More...
 
editor_displaygui_
 
int item_size_
 Both the width and the height of the square buttons. More...
 
int item_space_
 item_space_ plus some padding. More...
 
std::size_t columns_
 Number of items per row. More...
 
std::map< std::string, std::vector< std::string > > group_map_
 
item_map item_map_
 
std::size_t items_start_
 Index of the item at the top-left of the visible area, used for scrolling up and down. More...
 
std::set< std::string > non_core_items_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Private Member Functions

std::size_t active_group_index ()
 
virtual void setup_item (const Item &item, texture &item_base_image, texture &item_overlay_image, std::stringstream &tooltip)=0
 Setup item image and tooltip. More...
 
virtual const std::string & get_id (const Item &item)=0
 
virtual void setup (const game_config_view &cfg)=0
 Setup the internal data structure. More...
 
virtual const std::string & active_group_id ()
 
virtual bool is_selected_fg_item (const std::string &id)
 
virtual bool is_selected_bg_item (const std::string &id)
 
std::size_t num_items () override
 Return the number of items in the currently-active group. More...
 
void hide (bool hidden) override
 

Private Attributes

std::string active_group_
 
std::string selected_fg_item_
 
std::string selected_bg_item_
 
editor_toolkittoolkit_
 
std::vector< gui::tristate_buttonbuttons_
 

Detailed Description

template<class Item>
class editor::editor_palette< Item >

Definition at line 27 of file editor_palettes.hpp.

Member Typedef Documentation

◆ item_map

template<class Item>
typedef std::map<std::string, Item> editor::editor_palette< Item >::item_map
protected

Definition at line 168 of file editor_palettes.hpp.

Constructor & Destructor Documentation

◆ editor_palette()

template<class Item>
editor::editor_palette< Item >::editor_palette ( editor_display gui,
const game_config_view ,
std::size_t  item_size,
std::size_t  columns,
editor_toolkit toolkit 
)
inline

Definition at line 31 of file editor_palettes.hpp.

Member Function Documentation

◆ active_group()

template<class Item>
const std::vector<std::string>& editor::editor_palette< Item >::active_group ( )
inlineprotected

Definition at line 135 of file editor_palettes.hpp.

◆ active_group_id()

template<class Item>
virtual const std::string& editor::editor_palette< Item >::active_group_id ( )
inlineprivatevirtual

Definition at line 117 of file editor_palettes.hpp.

◆ active_group_index()

template<class Item >
std::size_t editor::editor_palette< Item >::active_group_index ( )
private

◆ adjust_size()

template<class Item >
void editor::editor_palette< Item >::adjust_size ( const SDL_Rect &  target)
overridevirtual

Update the size of this widget.

Use if the size_specs have changed.

Implements editor::common_palette.

Definition at line 164 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::prev_group().

◆ can_scroll_down()

template<class Item >
bool editor::editor_palette< Item >::can_scroll_down ( )
overridevirtual

◆ can_scroll_up()

template<class Item >
bool editor::editor_palette< Item >::can_scroll_up ( )
overridevirtual

Implements editor::common_palette.

Definition at line 94 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::prev_group().

◆ draw_contents()

template<class Item >
void editor::editor_palette< Item >::draw_contents ( )
overridevirtual

Called by widget::draw()

Reimplemented from gui::widget.

Definition at line 354 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::get_groups().

◆ expand_palette_groups_menu()

template<class Item >
void editor::editor_palette< Item >::expand_palette_groups_menu ( std::vector< config > &  items,
int  i 
)
overridevirtual

Menu expanding for palette group list.

Implements editor::common_palette.

Definition at line 43 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::start_num().

◆ get_groups()

template<class Item>
const std::vector<item_group>& editor::editor_palette< Item >::get_groups ( ) const
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 66 of file editor_palettes.hpp.

◆ get_help_string()

template<class Item>
virtual std::string editor::editor_palette< Item >::get_help_string ( )
pure virtual

◆ get_id()

template<class Item>
virtual const std::string& editor::editor_palette< Item >::get_id ( const Item &  item)
privatepure virtual

◆ handler_members()

template<class Item >
sdl_handler_vector editor::editor_palette< Item >::handler_members ( )
overridevirtual

Reimplemented from editor::common_palette.

Definition at line 33 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::editor_palette().

◆ hide()

template<class Item >
void editor::editor_palette< Item >::hide ( bool  hidden)
overrideprivatevirtual

Reimplemented from gui::widget.

Definition at line 237 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::active_group_id().

◆ is_selected_bg_item()

template<class Item >
bool editor::editor_palette< Item >::is_selected_bg_item ( const std::string &  id)
privatevirtual

Reimplemented in editor::unit_palette.

Definition at line 260 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::active_group_id().

◆ is_selected_fg_item()

template<class Item >
bool editor::editor_palette< Item >::is_selected_fg_item ( const std::string &  id)
privatevirtual

◆ layout()

template<class Item >
void editor::editor_palette< Item >::layout ( )
overridevirtual

Called by draw_manager to validate layout before drawing.

Reimplemented from gui::widget.

Definition at line 266 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::get_groups().

◆ next_group()

template<class Item>
void editor::editor_palette< Item >::next_group ( )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 73 of file editor_palettes.hpp.

◆ num_items()

template<class Item >
std::size_t editor::editor_palette< Item >::num_items ( )
overrideprivatevirtual

Return the number of items in the currently-active group.

Implements editor::common_palette.

Definition at line 230 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::active_group_id().

◆ prev_group()

template<class Item>
void editor::editor_palette< Item >::prev_group ( )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 76 of file editor_palettes.hpp.

◆ scroll_down()

template<class Item >
bool editor::editor_palette< Item >::scroll_down ( )
overridevirtual

Scroll the editor-palette down one step if possible.

Implements editor::common_palette.

Definition at line 106 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::prev_group().

◆ scroll_up()

template<class Item >
bool editor::editor_palette< Item >::scroll_up ( )
overridevirtual

Scroll the editor-palette up one step if possible.

Implements editor::common_palette.

Definition at line 77 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::prev_group().

◆ select_bg_item()

template<class Item >
void editor::editor_palette< Item >::select_bg_item ( const std::string &  item_id)
overrideprotectedvirtual

◆ select_fg_item()

template<class Item >
void editor::editor_palette< Item >::select_fg_item ( const std::string &  item_id)
overrideprotectedvirtual

Select a foreground item.

Implements editor::tristate_palette.

Reimplemented in editor::terrain_palette.

Definition at line 199 of file editor_palettes.cpp.

Referenced by editor::editor_palette< overlay >::active_group(), and editor::terrain_palette::select_fg_item().

◆ selected_bg_item()

template<class Item>
const Item& editor::editor_palette< Item >::selected_bg_item ( ) const
inline

Definition at line 98 of file editor_palettes.hpp.

◆ selected_fg_item()

template<class Item>
const Item& editor::editor_palette< Item >::selected_fg_item ( ) const
inline

◆ set_group() [1/2]

template<class Item >
void editor::editor_palette< Item >::set_group ( std::size_t  index)
overridevirtual

◆ set_group() [2/2]

template<class Item >
void editor::editor_palette< Item >::set_group ( const std::string &  id)
protectedvirtual

Sets a group active id.

This can result in no visible selected items.

Definition at line 118 of file editor_palettes.cpp.

◆ set_start_item()

template<class Item>
void editor::editor_palette< Item >::set_start_item ( std::size_t  index)
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 56 of file editor_palettes.hpp.

◆ setup()

template<class Item>
virtual void editor::editor_palette< Item >::setup ( const game_config_view cfg)
privatepure virtual

◆ setup_item()

template<class Item>
virtual void editor::editor_palette< Item >::setup_item ( const Item &  item,
texture item_base_image,
texture item_overlay_image,
std::stringstream &  tooltip 
)
privatepure virtual

Setup item image and tooltip.

Implemented in editor::terrain_palette, and editor::item_palette.

Referenced by editor::editor_palette< overlay >::selected_bg_item().

◆ start_num()

template<class Item>
std::size_t editor::editor_palette< Item >::start_num ( void  )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 58 of file editor_palettes.hpp.

◆ swap()

template<class Item >
void editor::editor_palette< Item >::swap ( )
overridevirtual

Member Data Documentation

◆ active_group_

template<class Item>
std::string editor::editor_palette< Item >::active_group_
private

◆ buttons_

template<class Item>
std::vector<gui::tristate_button> editor::editor_palette< Item >::buttons_
private

Definition at line 182 of file editor_palettes.hpp.

◆ columns_

template<class Item>
std::size_t editor::editor_palette< Item >::columns_
protected

Number of items per row.

Definition at line 163 of file editor_palettes.hpp.

◆ group_map_

template<class Item>
std::map<std::string, std::vector<std::string> > editor::editor_palette< Item >::group_map_
protected

◆ groups_

template<class Item>
std::vector<item_group> editor::editor_palette< Item >::groups_
protected

The editor_groups as defined in editor-groups.cfg.

Note the user must make sure the id's here are the same as the editor_group in terrain.cfg.

Definition at line 147 of file editor_palettes.hpp.

Referenced by editor::editor_palette< overlay >::get_groups(), editor::editor_palette< overlay >::next_group(), and editor::editor_palette< overlay >::prev_group().

◆ gui_

template<class Item>
editor_display& editor::editor_palette< Item >::gui_
protected

Definition at line 149 of file editor_palettes.hpp.

◆ item_map_

template<class Item>
item_map editor::editor_palette< Item >::item_map_
protected

◆ item_size_

template<class Item>
int editor::editor_palette< Item >::item_size_
protected

Both the width and the height of the square buttons.

Definition at line 154 of file editor_palettes.hpp.

◆ item_space_

template<class Item>
int editor::editor_palette< Item >::item_space_
protected

item_space_ plus some padding.

Definition at line 158 of file editor_palettes.hpp.

◆ items_start_

template<class Item>
std::size_t editor::editor_palette< Item >::items_start_
protected

Index of the item at the top-left of the visible area, used for scrolling up and down.

Definition at line 173 of file editor_palettes.hpp.

Referenced by editor::editor_palette< overlay >::set_start_item(), and editor::editor_palette< overlay >::start_num().

◆ non_core_items_

template<class Item>
std::set<std::string> editor::editor_palette< Item >::non_core_items_
protected

Definition at line 174 of file editor_palettes.hpp.

◆ selected_bg_item_

template<class Item>
std::string editor::editor_palette< Item >::selected_bg_item_
private

◆ selected_fg_item_

template<class Item>
std::string editor::editor_palette< Item >::selected_fg_item_
private

◆ toolkit_

template<class Item>
editor_toolkit& editor::editor_palette< Item >::toolkit_
private

Definition at line 181 of file editor_palettes.hpp.


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