#include <editor_palettes.hpp>
Public Member Functions | |
editor_palette (editor_display &gui, int 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 |
For tools which support fg and bg items, exchange the two items. More... | |
virtual std::string | get_help_string () const =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 () |
Whether the hotkey system should the enable GUI button connected to swap(). More... | |
virtual std::vector< std::string > | action_pressed () const |
Public Member Functions inherited from gui::widget | |
const rect & | location () 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 ®ion) 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_handler & | operator= (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_handler & | operator= (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_drawable & | operator= (const top_level_drawable &) |
top_level_drawable (top_level_drawable &&) | |
top_level_drawable & | operator= (top_level_drawable &&) |
Protected Attributes | |
std::vector< item_group > | groups_ |
The editor_groups as defined in editor-groups.cfg. More... | |
editor_display & | gui_ |
int | item_size_ |
Both the width and the height of the square buttons. More... | |
int | item_space_ |
item_size_ 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_toolkit & | toolkit_ |
std::vector< gui::tristate_button > | buttons_ |
Definition at line 27 of file editor_palettes.hpp.
|
protected |
Definition at line 167 of file editor_palettes.hpp.
|
inline |
Definition at line 31 of file editor_palettes.hpp.
|
inlineprotected |
Definition at line 131 of file editor_palettes.hpp.
References editor::editor_palette< Item >::active_group_, and editor::editor_palette< Item >::group_map_.
|
inlineprivatevirtual |
Definition at line 113 of file editor_palettes.hpp.
References editor::editor_palette< Item >::active_group_.
|
private |
Definition at line 147 of file editor_palettes.cpp.
References i.
Referenced by editor::editor_palette< Item >::next_group(), and editor::editor_palette< Item >::prev_group().
|
overridevirtual |
Update the size of this widget.
Use if the size_specs have changed.
Implements editor::common_palette.
Definition at line 160 of file editor_palettes.cpp.
References i.
|
overridevirtual |
Implements editor::common_palette.
Definition at line 97 of file editor_palettes.cpp.
|
overridevirtual |
Implements editor::common_palette.
Definition at line 91 of file editor_palettes.cpp.
|
overridevirtual |
Called by widget::draw()
Reimplemented from gui::widget.
Definition at line 337 of file editor_palettes.cpp.
|
overridevirtual |
Menu expanding for palette group list.
Implements editor::common_palette.
Definition at line 40 of file editor_palettes.cpp.
|
inlineoverridevirtual |
Implements editor::common_palette.
Definition at line 62 of file editor_palettes.hpp.
References editor::editor_palette< Item >::groups_.
|
pure virtual |
Implemented in editor::unit_palette, editor::terrain_palette, and editor::item_palette.
|
privatepure virtual |
Implemented in editor::terrain_palette, and editor::item_palette.
|
overridevirtual |
Reimplemented from editor::common_palette.
Definition at line 30 of file editor_palettes.cpp.
|
overrideprivatevirtual |
|
privatevirtual |
Reimplemented in editor::unit_palette.
Definition at line 256 of file editor_palettes.cpp.
References id.
|
privatevirtual |
Definition at line 250 of file editor_palettes.cpp.
References id.
|
overridevirtual |
Called by draw_manager to validate layout before drawing.
Reimplemented from gui::widget.
Definition at line 262 of file editor_palettes.cpp.
References _(), font::BAD_COLOR, gui::tristate_button::BOTH, gui::widget::hide(), i, gui::tristate_button::LEFT, gui::tristate_button::NONE, gui::tristate_button::RIGHT, gui::widget::set_dirty(), gui::tristate_button::set_item_id(), gui::tristate_button::set_item_image(), gui::tristate_button::set_pressed(), gui::widget::set_tooltip_string(), and markup::span_color().
|
inlineoverridevirtual |
Implements editor::common_palette.
Definition at line 69 of file editor_palettes.hpp.
References editor::editor_palette< Item >::active_group_index(), editor::editor_palette< Item >::groups_, and editor::editor_palette< Item >::set_group().
|
overrideprivatevirtual |
Return the number of items in the currently-active group.
Implements editor::common_palette.
Definition at line 226 of file editor_palettes.cpp.
|
inlineoverridevirtual |
Implements editor::common_palette.
Definition at line 72 of file editor_palettes.hpp.
References editor::editor_palette< Item >::active_group_index(), editor::editor_palette< Item >::groups_, and editor::editor_palette< Item >::set_group().
|
overridevirtual |
Scroll the editor-palette down one step if possible.
Implements editor::common_palette.
Definition at line 103 of file editor_palettes.cpp.
|
overridevirtual |
Scroll the editor-palette up one step if possible.
Implements editor::common_palette.
Definition at line 74 of file editor_palettes.cpp.
|
overrideprotectedvirtual |
Implements editor::tristate_palette.
Reimplemented in editor::unit_palette, and editor::terrain_palette.
Definition at line 207 of file editor_palettes.cpp.
Referenced by editor::terrain_palette::select_bg_item().
|
overrideprotectedvirtual |
Select a foreground item.
Implements editor::tristate_palette.
Reimplemented in editor::terrain_palette.
Definition at line 197 of file editor_palettes.cpp.
Referenced by editor::terrain_palette::select_fg_item().
|
inline |
Definition at line 94 of file editor_palettes.hpp.
References editor::editor_palette< Item >::item_map_, and editor::editor_palette< Item >::selected_bg_item_.
|
inline |
Return the currently selected foreground/background item.
Definition at line 93 of file editor_palettes.hpp.
References editor::editor_palette< Item >::item_map_, and editor::editor_palette< Item >::selected_fg_item_.
Referenced by editor::mouse_action_item::click_left(), editor::mouse_action_item::set_mouse_overlay(), editor::mouse_action_unit::set_mouse_overlay(), and editor::mouse_action_unit::up_left().
|
protectedvirtual |
Sets a group active id.
This can result in no visible selected items.
Definition at line 115 of file editor_palettes.cpp.
|
overridevirtual |
Implements editor::common_palette.
Definition at line 140 of file editor_palettes.cpp.
References utf8::index().
Referenced by editor::editor_palette< Item >::next_group(), and editor::editor_palette< Item >::prev_group().
|
inlineoverridevirtual |
Implements editor::common_palette.
Definition at line 53 of file editor_palettes.hpp.
References utf8::index(), and editor::editor_palette< Item >::items_start_.
|
privatepure virtual |
Setup the internal data structure.
Implemented in editor::unit_palette, editor::terrain_palette, and editor::item_palette.
|
privatepure virtual |
Setup item image and tooltip.
Implemented in editor::terrain_palette, and editor::item_palette.
|
inlineoverridevirtual |
Implements editor::common_palette.
Definition at line 55 of file editor_palettes.hpp.
References editor::editor_palette< Item >::items_start_.
|
overridevirtual |
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 217 of file editor_palettes.cpp.
References swap().
|
private |
Definition at line 176 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::active_group(), and editor::editor_palette< Item >::active_group_id().
|
private |
Definition at line 181 of file editor_palettes.hpp.
|
protected |
Number of items per row.
Definition at line 162 of file editor_palettes.hpp.
|
protected |
Definition at line 165 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::active_group().
|
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 143 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::get_groups(), editor::editor_palette< Item >::next_group(), and editor::editor_palette< Item >::prev_group().
|
protected |
Definition at line 145 of file editor_palettes.hpp.
|
protected |
Definition at line 168 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::selected_bg_item(), and editor::editor_palette< Item >::selected_fg_item().
|
protected |
Both the width and the height of the square buttons.
This is a size measured in pixels, and should match the type of SDL_rect.w and SDL_rect.h.
Definition at line 153 of file editor_palettes.hpp.
|
protected |
item_size_ plus some padding.
Definition at line 157 of file editor_palettes.hpp.
|
protected |
Index of the item at the top-left of the visible area, used for scrolling up and down.
Definition at line 172 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::set_start_item(), and editor::editor_palette< Item >::start_num().
|
protected |
Definition at line 173 of file editor_palettes.hpp.
|
private |
Definition at line 178 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::selected_bg_item().
|
private |
Definition at line 177 of file editor_palettes.hpp.
Referenced by editor::editor_palette< Item >::selected_fg_item().
|
private |
Definition at line 180 of file editor_palettes.hpp.