The menu to the left in the help browser, where topics can be navigated through and chosen. More...
#include <help_menu.hpp>
Classes | |
struct | visible_item |
Information about an item that is visible in the menu. More... | |
Public Member Functions | |
help_menu (CVideo &video, const section &toplevel, int max_height=-1) | |
int | process () |
void | select_topic (const topic &t) |
Make the topic the currently selected one, and expand all sections that need to be expanded to show it. More... | |
const topic * | chosen_topic () |
If a topic has been chosen, return that topic, otherwise nullptr. More... | |
![]() | |
menu (CVideo &video, const std::vector< std::string > &items, bool click_selects=false, int max_height=-1, int max_width=-1, const sorter *sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true) | |
~menu () | |
Default implementation, but defined out-of-line for efficiency reasons. More... | |
int | selection () const |
void | move_selection (size_t id) |
void | move_selection_keeping_viewport (size_t id) |
void | reset_selection () |
const item & | get_item (int index) const |
const item & | get_selected_item () const |
void | change_item (int pos1, int pos2, const std::string &str) |
virtual void | erase_item (size_t index) |
void | set_heading (const std::vector< std::string > &heading) |
virtual void | set_items (const std::vector< std::string > &items, bool strip_spaces=true, bool keep_viewport=false) |
Set new items to show and redraw/recalculate everything. More... | |
void | set_max_height (const int new_max_height) |
Set a new max height for this menu. More... | |
void | set_max_width (const int new_max_width) |
int | get_max_height () |
int | get_max_width () |
size_t | number_of_items () const |
int | process () |
bool | double_clicked () |
void | set_click_selects (bool value) |
void | set_numeric_keypress_selection (bool value) |
void | scroll (unsigned int pos) |
void | set_sorter (sorter *s) |
void | sort_by (int column) |
int | get_sort_by () |
bool | get_sort_reversed () |
![]() | |
scrollarea (CVideo &video, bool auto_join=true) | |
Create a zone with automatic handling of scrollbar. More... | |
virtual void | hide (bool value=true) |
![]() | |
SDL_Rect const & | location () const |
virtual void | set_location (SDL_Rect const &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 | set_volatile (bool val=true) |
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_tooltip_string (int mousex, int mousey) |
![]() | |
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 () |
Private Member Functions | |
void | update_visible_items (const section &top_level, unsigned starting_level=0) |
Regenerate what items are visible by checking what sections are expanded. More... | |
bool | expanded (const section &sec) |
Return true if the section is expanded. More... | |
void | expand (const section &sec) |
Mark a section as expanded. More... | |
void | contract (const section &sec) |
Contract (close) a section. More... | |
std::string | indent_list (const std::string &icon, const unsigned level) |
Return the string to use as the prefix for the icon part of the menu-string at the specified level. More... | |
std::string | get_string_to_show (const section &sec, const unsigned level) |
Return the string to use as the menu-string for sections at the specified level. More... | |
std::string | get_string_to_show (const topic &topic, const unsigned level) |
Return the string to use as the menu-string for topics at the specified level. More... | |
void | display_visible_items () |
Draw the currently visible items. More... | |
bool | select_topic_internal (const topic &t, const section &sec) |
Internal recursive thingie. More... | |
Private Attributes | |
std::vector< visible_item > | visible_items_ |
const section & | toplevel_ |
std::set< const section * > | expanded_ |
surface_restorer | restorer_ |
topic const * | chosen_topic_ |
visible_item | selected_item_ |
Additional Inherited Members | |
![]() | |
enum | ROW_TYPE { NORMAL_ROW, SELECTED_ROW, HEADING_ROW } |
![]() | |
static style & | default_style = menu::bluebg_style |
static style | simple_style |
static imgsel_style | bluebg_style |
![]() | |
bool | item_ends_with_image (const std::string &item) const |
virtual void | handle_event (const SDL_Event &event) |
void | set_inner_location (const SDL_Rect &rect) |
bool | requires_event_focus (const SDL_Event *event=nullptr) const |
const std::vector< int > & | column_widths () const |
virtual void | draw_row (const size_t row_index, const SDL_Rect &rect, ROW_TYPE type) |
int | hit (int x, int y) const |
std::pair< int, int > | hit_cell (int x, int y) const |
int | hit_column (int x) const |
int | hit_heading (int x, int y) const |
void | invalidate_row (size_t id) |
void | invalidate_row_pos (size_t pos) |
void | invalidate_heading () |
![]() | |
virtual sdl_handler_vector | handler_members () |
virtual void | update_location (SDL_Rect const &rect) |
virtual void | process_event () |
SDL_Rect | inner_location () const |
unsigned | scrollbar_width () const |
unsigned | get_position () const |
unsigned | get_max_position () const |
void | set_position (unsigned pos) |
void | adjust_position (unsigned pos) |
void | move_position (int dep) |
void | set_shown_size (unsigned h) |
void | set_full_size (unsigned h) |
void | set_scroll_rate (unsigned r) |
bool | has_scrollbar () const |
![]() | |
widget (widget const &o) | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (SDL_Rect const &rect) |
void | bg_restore () const |
void | bg_restore (SDL_Rect const &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_window_event (SDL_Event const &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
![]() | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
![]() | |
style * | style_ |
bool | silent_ |
![]() | |
bool | focus_ |
The menu to the left in the help browser, where topics can be navigated through and chosen.
Definition at line 31 of file help_menu.hpp.
Definition at line 32 of file help_menu.cpp.
References display_visible_items(), selected_item_, gui::menu::silent_, toplevel_, update_visible_items(), and visible_items_.
const topic * help::help_menu::chosen_topic | ( | ) |
If a topic has been chosen, return that topic, otherwise nullptr.
If one topic is returned, it will not be returned again, if it is not re-chosen.
Definition at line 197 of file help_menu.cpp.
References chosen_topic_.
Referenced by help::help_browser::process_event().
Contract (close) a section.
That is, mark it as not expanded, visible items are not updated.
Definition at line 60 of file help_menu.cpp.
References expanded_, game_config::sounds::menu_contract, and sound::play_UI_sound().
Referenced by process().
|
private |
Draw the currently visible items.
Definition at line 204 of file help_menu.cpp.
References selected_item_, gui::menu::set_items(), and visible_items_.
Referenced by help_menu(), process(), and select_topic().
Mark a section as expanded.
Do not update the visible items or anything.
Definition at line 53 of file help_menu.cpp.
References expanded_, help::section::id, game_config::sounds::menu_expand, and sound::play_UI_sound().
Referenced by process(), and select_topic_internal().
|
private |
Return true if the section is expanded.
Definition at line 48 of file help_menu.cpp.
References expanded_.
Referenced by get_string_to_show(), process(), and update_visible_items().
|
private |
Return the string to use as the menu-string for sections at the specified level.
Definition at line 102 of file help_menu.cpp.
References help::closed_section_img, expanded(), IMG_TEXT_SEPARATOR, indent_list(), help::open_section_img, and help::section::title.
Referenced by update_visible_items().
|
private |
Return the string to use as the menu-string for topics at the specified level.
Definition at line 110 of file help_menu.cpp.
References IMG_TEXT_SEPARATOR, indent_list(), help::topic::title, and help::topic_img.
|
private |
Return the string to use as the prefix for the icon part of the menu-string at the specified level.
Definition at line 92 of file help_menu.cpp.
References i, IMAGE_PREFIX, and IMG_TEXT_SEPARATOR.
Referenced by get_string_to_show(), and process().
int help::help_menu::process | ( | ) |
Choose a topic if it is clicked.
Definition at line 158 of file help_menu.cpp.
References chosen_topic_, help::closed_section_img, contract(), display_visible_items(), expand(), expanded(), help::find_topic(), gui::menu::style::get_thickness(), help::section::id, indent_list(), gui::menu::style::item_size(), help::section::level, help::open_section_img, tooltips::process(), help::help_menu::visible_item::sec, selected_item_, gui::menu::style_, help::help_menu::visible_item::t, help::toplevel, toplevel_, update_visible_items(), visible_items_, and map_location::x.
Referenced by help::help_browser::process_event().
Make the topic the currently selected one, and expand all sections that need to be expanded to show it.
Definition at line 139 of file help_menu.cpp.
References display_visible_items(), select_topic_internal(), selected_item_, toplevel_, update_visible_items(), and visible_items_.
Referenced by help::help_browser::show_topic().
Internal recursive thingie.
did_expand will be true if any section was expanded, otherwise untouched.
Definition at line 118 of file help_menu.cpp.
References expand(), gui2::event::find(), help::topic::id, help::section::sections, and help::section::topics.
Referenced by select_topic().
|
private |
Regenerate what items are visible by checking what sections are expanded.
Definition at line 67 of file help_menu.cpp.
References expanded(), get_string_to_show(), help::is_visible_id(), help::section::sections, help::section::topics, and visible_items_.
Referenced by help_menu(), process(), and select_topic().
|
private |
Definition at line 97 of file help_menu.hpp.
Referenced by chosen_topic(), and process().
|
private |
Definition at line 95 of file help_menu.hpp.
Referenced by contract(), expand(), and expanded().
|
private |
Definition at line 96 of file help_menu.hpp.
|
private |
Definition at line 98 of file help_menu.hpp.
Referenced by display_visible_items(), help_menu(), process(), and select_topic().
|
private |
Definition at line 94 of file help_menu.hpp.
Referenced by help_menu(), process(), and select_topic().
|
private |
Definition at line 93 of file help_menu.hpp.
Referenced by display_visible_items(), help_menu(), process(), select_topic(), and update_visible_items().