The Battle for Wesnoth  1.19.0-dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
help::help_menu Class Reference

The menu to the left in the help browser, where topics can be navigated through and chosen. More...

#include <help_menu.hpp>

Inheritance diagram for help::help_menu:

Classes

struct  visible_item
 Information about an item that is visible in the menu. More...
 

Public Member Functions

 help_menu (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 topicchosen_topic ()
 If a topic has been chosen, return that topic, otherwise nullptr. More...
 
- Public Member Functions inherited from gui::menu
 menu (bool click_selects=false, int max_height=-1, int max_width=-1, 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 (std::size_t id)
 
void move_selection_keeping_viewport (std::size_t id)
 
void reset_selection ()
 
virtual void set_items (const std::vector< indented_menu_item > &items, std::optional< std::size_t > selected)
 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 () const
 
int get_max_width () const
 
std::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) override
 
- Public Member Functions inherited from gui::scrollarea
 scrollarea (bool auto_join=true)
 Create a zone with automatic handling of scrollbar. More...
 
virtual void hide (bool value=true)
 
- 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 void layout () override
 Called by draw_manager to validate layout. More...
 
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 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...
 

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) const
 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...
 
gui::indented_menu_item get_item_to_show (const section &sec, const unsigned level)
 Return the data to use with the superclass's set_items() for sections at the specified level. More...
 
gui::indented_menu_item get_item_to_show (const topic &topic, const unsigned level)
 Return the data to use with the superclass's set_items() 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_itemvisible_items_
 
const sectiontoplevel_
 
std::set< const section * > expanded_
 
topic const * chosen_topic_
 
visible_item selected_item_
 

Additional Inherited Members

- Public Types inherited from gui::menu
enum  ROW_TYPE { NORMAL_ROW , SELECTED_ROW }
 
- Static Public Attributes inherited from gui::menu
static styledefault_style = menu::bluebg_style
 
static imgsel_style bluebg_style
 
- Protected Member Functions inherited from gui::menu
virtual void handle_event (const SDL_Event &event) override
 
void set_inner_location (const SDL_Rect &rect) override
 
bool requires_event_focus (const SDL_Event *event=nullptr) const override
 
int widest_row_width () const
 
virtual void draw_row (const std::size_t row_index, const SDL_Rect &rect, ROW_TYPE type)
 
int hit (int x, int y) const
 
bool hit_on_indent_or_icon (std::size_t row_index, int x) const
 Returns true if a mouse-click with the given x-coordinate, and an appropriate y-coordinate would lie within the indent or icon part of the given row. More...
 
void invalidate_row (std::size_t id)
 
void invalidate_row_pos (std::size_t pos)
 
- Protected Member Functions inherited from gui::scrollarea
virtual sdl_handler_vector handler_members ()
 
virtual void update_location (const SDL_Rect &rect)
 
virtual void process_event ()
 
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
 
- Protected Member Functions inherited from gui::widget
 widget (const bool auto_join=true)
 
virtual ~widget ()
 
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 inherited from gui::menu
stylestyle_
 
bool silent_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

The menu to the left in the help browser, where topics can be navigated through and chosen.

Definition at line 32 of file help_menu.hpp.

Constructor & Destructor Documentation

◆ help_menu()

help::help_menu::help_menu ( const section toplevel,
int  max_height = -1 
)

Member Function Documentation

◆ chosen_topic()

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 158 of file help_menu.cpp.

References chosen_topic_.

Referenced by help::help_browser::process_event().

◆ contract()

void help::help_menu::contract ( const section sec)
private

Contract (close) a section.

That is, mark it as not expanded, visible items are not updated.

Definition at line 56 of file help_menu.cpp.

References expanded_, game_config::sounds::menu_contract, and sound::play_UI_sound().

Referenced by process().

◆ display_visible_items()

void help::help_menu::display_visible_items ( )
private

Draw the currently visible items.

Definition at line 165 of file help_menu.cpp.

References game_config::images::selected, selected_item_, gui::menu::set_items(), and visible_items_.

Referenced by help_menu(), process(), and select_topic().

◆ expand()

void help::help_menu::expand ( const section sec)
private

Mark a section as expanded.

Do not update the visible items or anything.

Definition at line 49 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().

◆ expanded()

bool help::help_menu::expanded ( const section sec) const
private

Return true if the section is expanded.

Definition at line 44 of file help_menu.cpp.

References expanded_.

Referenced by help::help_menu::visible_item::get_menu_item(), process(), and update_visible_items().

◆ get_item_to_show() [1/2]

gui::indented_menu_item help::help_menu::get_item_to_show ( const section sec,
const unsigned  level 
)
private

Return the data to use with the superclass's set_items() for sections at the specified level.

◆ get_item_to_show() [2/2]

gui::indented_menu_item help::help_menu::get_item_to_show ( const topic topic,
const unsigned  level 
)
private

Return the data to use with the superclass's set_items() for topics at the specified level.

◆ indent_list()

std::string help::help_menu::indent_list ( const std::string &  icon,
const unsigned  level 
)
private

Return the string to use as the prefix for the icon part of the menu-string at the specified level.

◆ process()

int help::help_menu::process ( )

◆ select_topic()

void help::help_menu::select_topic ( const topic t)

Make the topic the currently selected one, and expand all sections that need to be expanded to show it.

Definition at line 104 of file help_menu.cpp.

References display_visible_items(), select_topic_internal(), selected_item_, t, toplevel_, update_visible_items(), and visible_items_.

Referenced by help::help_browser::show_topic().

◆ select_topic_internal()

bool help::help_menu::select_topic_internal ( const topic t,
const section sec 
)
private

Internal recursive thingie.

did_expand will be true if any section was expanded, otherwise untouched.

Definition at line 84 of file help_menu.cpp.

References expand(), s, help::section::sections, t, and help::section::topics.

Referenced by select_topic().

◆ update_visible_items()

void help::help_menu::update_visible_items ( const section top_level,
unsigned  starting_level = 0 
)
private

Regenerate what items are visible by checking what sections are expanded.

Definition at line 63 of file help_menu.cpp.

References expanded(), help::is_visible_id(), game_config::images::level, s, help::section::sections, t, help::section::topics, and visible_items_.

Referenced by help_menu(), process(), and select_topic().

Member Data Documentation

◆ chosen_topic_

topic const* help::help_menu::chosen_topic_
private

Definition at line 105 of file help_menu.hpp.

Referenced by chosen_topic(), and process().

◆ expanded_

std::set<const section*> help::help_menu::expanded_
private

Definition at line 104 of file help_menu.hpp.

Referenced by contract(), expand(), and expanded().

◆ selected_item_

visible_item help::help_menu::selected_item_
private

Definition at line 106 of file help_menu.hpp.

Referenced by display_visible_items(), help_menu(), process(), and select_topic().

◆ toplevel_

const section& help::help_menu::toplevel_
private

Definition at line 103 of file help_menu.hpp.

Referenced by help_menu(), process(), and select_topic().

◆ visible_items_

std::vector<visible_item> help::help_menu::visible_items_
private

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