The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
editor::location_palette Class Reference

List of starting locations and location ids. More...

#include <location_palette.hpp>

Inheritance diagram for editor::location_palette:

Public Member Functions

 location_palette (editor_display &gui, 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...
 
virtual void set_group (std::size_t) override
 
virtual void next_group () override
 
virtual void prev_group () override
 
virtual 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 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
 
virtual void swap () override
 For tools which support fg and bg items, exchange the two items. More...
 
virtual bool supports_swap () override
 Whether the hotkey system should the enable GUI button connected to swap(). More...
 
std::string get_help_string () const
 
const std::string & selected_item () const
 Return the currently selected item. More...
 
virtual void select_item (const std::string &item_id)
 
virtual std::vector< std::string > action_pressed () const override
 
void add_item (const std::string &id)
 
 ~location_palette ()
 
void hide (bool hidden) override
 
- Public Member Functions inherited from editor::common_palette
 common_palette ()
 
virtual ~common_palette ()
 
- 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_tooltip_string (const std::string &str)
 
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 Attributes

int item_size_
 
int item_space_
 
std::size_t items_start_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Private Member Functions

void scroll_top ()
 Scroll the editor-palette to the top. More...
 
virtual bool is_selected_item (const std::string &id)
 
std::size_t num_items () override
 Return the number of items in the palette. More...
 
std::size_t num_visible_items ()
 Return the number of GUI elements that can show items. More...
 

Private Attributes

std::string selected_item_
 
std::vector< std::string > items_
 
editor_toolkittoolkit_
 
std::vector< location_palette_itembuttons_
 
std::unique_ptr< location_palette_buttonbutton_add_
 
std::unique_ptr< location_palette_buttonbutton_delete_
 
std::unique_ptr< location_palette_buttonbutton_goto_
 
editor_displaydisp_
 

Additional Inherited Members

- 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 &&)
 

Detailed Description

List of starting locations and location ids.

Shows a single-column list, with buttons to add new items to the list and to jump to that location on the map.

Definition at line 32 of file location_palette.hpp.

Constructor & Destructor Documentation

◆ location_palette()

editor::location_palette::location_palette ( editor_display gui,
editor_toolkit toolkit 
)

Definition at line 160 of file location_palette.cpp.

References i, items_, and selected_item_.

◆ ~location_palette()

editor::location_palette::~location_palette ( )

Definition at line 406 of file location_palette.cpp.

Member Function Documentation

◆ action_pressed()

std::vector< std::string > editor::location_palette::action_pressed ( ) const
overridevirtual

Reimplemented from editor::common_palette.

Definition at line 397 of file location_palette.cpp.

References button_delete_.

◆ add_item()

void editor::location_palette::add_item ( const std::string &  id)

◆ adjust_size()

void editor::location_palette::adjust_size ( const SDL_Rect &  target)
overridevirtual

◆ can_scroll_down()

bool editor::location_palette::can_scroll_down ( )
overridevirtual

Implements editor::common_palette.

Definition at line 224 of file location_palette.cpp.

References items_start_, num_items(), and num_visible_items().

Referenced by layout(), and scroll_down().

◆ can_scroll_up()

bool editor::location_palette::can_scroll_up ( )
overridevirtual

Implements editor::common_palette.

Definition at line 219 of file location_palette.cpp.

References items_start_.

Referenced by layout(), and scroll_up().

◆ draw_contents()

void editor::location_palette::draw_contents ( )
overridevirtual

Called by widget::draw()

Reimplemented from gui::widget.

Definition at line 388 of file location_palette.cpp.

◆ expand_palette_groups_menu()

void editor::location_palette::expand_palette_groups_menu ( std::vector< config > &  items,
int  i 
)
inlineoverridevirtual

Menu expanding for palette group list.

Implements editor::common_palette.

Definition at line 46 of file location_palette.hpp.

References i.

◆ get_groups()

virtual const std::vector<item_group>& editor::location_palette::get_groups ( ) const
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 54 of file location_palette.hpp.

◆ get_help_string()

std::string editor::location_palette::get_help_string ( ) const
inline

Definition at line 76 of file location_palette.hpp.

Referenced by adjust_size(), and select_item().

◆ handler_members()

sdl_handler_vector editor::location_palette::handler_members ( )
overridevirtual

Reimplemented from editor::common_palette.

Definition at line 181 of file location_palette.cpp.

References b, button_add_, button_delete_, button_goto_, buttons_, and h.

Referenced by hide().

◆ hide()

void editor::location_palette::hide ( bool  hidden)
overridevirtual

◆ is_selected_item()

bool editor::location_palette::is_selected_item ( const std::string &  id)
privatevirtual

Definition at line 329 of file location_palette.cpp.

References gui::widget::id(), and selected_item_.

Referenced by layout().

◆ layout()

void editor::location_palette::layout ( )
overridevirtual

◆ next_group()

virtual void editor::location_palette::next_group ( )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 52 of file location_palette.hpp.

◆ num_items()

std::size_t editor::location_palette::num_items ( )
overrideprivatevirtual

Return the number of items in the palette.

Implements editor::common_palette.

Definition at line 320 of file location_palette.cpp.

References items_.

Referenced by add_item(), can_scroll_down(), and layout().

◆ num_visible_items()

std::size_t editor::location_palette::num_visible_items ( )
private

Return the number of GUI elements that can show items.

Some of these may be hidden, if there are more of them than items to show, or if the palette has been scrolled to the bottom.

Definition at line 324 of file location_palette.cpp.

References buttons_.

Referenced by add_item(), can_scroll_down(), and layout().

◆ prev_group()

virtual void editor::location_palette::prev_group ( )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 53 of file location_palette.hpp.

◆ scroll_down()

bool editor::location_palette::scroll_down ( )
overridevirtual

Scroll the editor-palette down one step if possible.

Implements editor::common_palette.

Definition at line 229 of file location_palette.cpp.

References can_scroll_down(), items_start_, and gui::widget::set_dirty().

◆ scroll_top()

void editor::location_palette::scroll_top ( )
private

Scroll the editor-palette to the top.

◆ scroll_up()

bool editor::location_palette::scroll_up ( )
overridevirtual

Scroll the editor-palette up one step if possible.

Implements editor::common_palette.

Definition at line 208 of file location_palette.cpp.

References can_scroll_up(), items_start_, and gui::widget::set_dirty().

◆ select_item()

void editor::location_palette::select_item ( const std::string &  item_id)
virtual

◆ selected_item()

const std::string& editor::location_palette::selected_item ( ) const
inline

Return the currently selected item.

Definition at line 79 of file location_palette.hpp.

References selected_item_.

Referenced by editor::editor_controller::do_execute_command(), and editor::mouse_action_starting_position::up_left().

◆ set_group()

virtual void editor::location_palette::set_group ( std::size_t  )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 51 of file location_palette.hpp.

◆ set_start_item()

void editor::location_palette::set_start_item ( std::size_t  index)
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 41 of file location_palette.hpp.

References utf8::index(), and items_start_.

◆ start_num()

std::size_t editor::location_palette::start_num ( void  )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 43 of file location_palette.hpp.

References items_start_.

◆ supports_swap()

virtual bool editor::location_palette::supports_swap ( )
inlineoverridevirtual

Whether the hotkey system should the enable GUI button connected to swap().

Reimplemented from editor::common_palette.

Definition at line 74 of file location_palette.hpp.

◆ swap()

virtual void editor::location_palette::swap ( )
inlineoverridevirtual

For tools which support fg and bg items, exchange the two items.

Typically, fg and bg mean that they're placed by left or right mouse clicks, respectively.

There's a mismatch between class structure and responsibilities here, as part of the UX isn't part of the palette. The tool decides what right-click does. Even for the scenery item tool, where right-click deletes an item, fg and bg provide a way to switch between two items.

Implements editor::common_palette.

Definition at line 73 of file location_palette.hpp.

Member Data Documentation

◆ button_add_

std::unique_ptr<location_palette_button> editor::location_palette::button_add_
private

Definition at line 115 of file location_palette.hpp.

Referenced by adjust_size(), handler_members(), and layout().

◆ button_delete_

std::unique_ptr<location_palette_button> editor::location_palette::button_delete_
private

Definition at line 116 of file location_palette.hpp.

Referenced by action_pressed(), adjust_size(), handler_members(), and layout().

◆ button_goto_

std::unique_ptr<location_palette_button> editor::location_palette::button_goto_
private

Definition at line 117 of file location_palette.hpp.

Referenced by adjust_size(), handler_members(), and layout().

◆ buttons_

std::vector<location_palette_item> editor::location_palette::buttons_
private

Definition at line 114 of file location_palette.hpp.

Referenced by adjust_size(), handler_members(), layout(), and num_visible_items().

◆ disp_

editor_display& editor::location_palette::disp_
private

Definition at line 118 of file location_palette.hpp.

Referenced by adjust_size(), hide(), layout(), and select_item().

◆ item_size_

int editor::location_palette::item_size_
protected

Definition at line 102 of file location_palette.hpp.

Referenced by adjust_size().

◆ item_space_

int editor::location_palette::item_space_
protected

Definition at line 104 of file location_palette.hpp.

Referenced by adjust_size().

◆ items_

std::vector<std::string> editor::location_palette::items_
private

Definition at line 112 of file location_palette.hpp.

Referenced by add_item(), layout(), location_palette(), and num_items().

◆ items_start_

std::size_t editor::location_palette::items_start_
protected

◆ selected_item_

std::string editor::location_palette::selected_item_
private

◆ toolkit_

editor_toolkit& editor::location_palette::toolkit_
private

Definition at line 113 of file location_palette.hpp.

Referenced by layout().


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