The Battle for Wesnoth  1.19.0-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, const game_config_view &, 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
 
void swap () override
 
bool can_swap ()
 
virtual std::string get_help_string ()
 
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 ()
 
virtual bool supports_swap ()
 
- 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,
const game_config_view ,
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 407 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 398 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 225 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 220 of file location_palette.cpp.

References items_start_.

Referenced by layout(), and scroll_up().

◆ can_swap()

bool editor::location_palette::can_swap ( )
inline

Definition at line 75 of file location_palette.hpp.

◆ draw_contents()

void editor::location_palette::draw_contents ( )
overridevirtual

Called by widget::draw()

Reimplemented from gui::widget.

Definition at line 389 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 47 of file location_palette.hpp.

References i, and mp::ui_alerts::items.

◆ get_groups()

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

Implements editor::common_palette.

Definition at line 55 of file location_palette.hpp.

◆ get_help_string()

virtual std::string editor::location_palette::get_help_string ( )
inlinevirtual

Definition at line 77 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 182 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 330 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 53 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 321 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 325 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 54 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 230 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 209 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 80 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 52 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 42 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 44 of file location_palette.hpp.

References items_start_.

◆ swap()

void editor::location_palette::swap ( )
inlineoverridevirtual

Implements editor::common_palette.

Definition at line 74 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 116 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 117 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 118 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 115 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 119 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 103 of file location_palette.hpp.

Referenced by adjust_size().

◆ item_space_

int editor::location_palette::item_space_
protected

Definition at line 105 of file location_palette.hpp.

Referenced by adjust_size().

◆ items_

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

Definition at line 113 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 114 of file location_palette.hpp.

Referenced by layout().


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