The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
gui2::dialogs::modeless_dialog Class Referenceabstract

The popup class shows windows that are shown non-modal. More...

#include <modeless_dialog.hpp>

Inheritance diagram for gui2::dialogs::modeless_dialog:
Inheritance graph

Public Member Functions

 modeless_dialog ()
 
virtual ~modeless_dialog ()
 
void show (const bool allow_interaction=false, const unsigned auto_close_time=0)
 Shows the window. More...
 
void hide ()
 Hides the window. More...
 
windowget_window () const
 Returns a pointer to the dialog's window. More...
 

Protected Attributes

std::unique_ptr< windowwindow_
 The window, used in show. More...
 

Private Member Functions

virtual const std::string & window_id () const =0
 The id of the window to build. More...
 
windowbuild_window () const
 Builds the window. More...
 
virtual void post_build (window &window)
 Actions to be taken directly after the window is build. More...
 
virtual void pre_show (window &window)
 Actions to be taken before showing the window. More...
 

Friends

std::string unit_test_mark_popup_as_tested (const modeless_dialog &dialog)
 Special helper function to get the id of the window. More...
 
windowunit_test_window (const modeless_dialog &dialog)
 Special helper function for the unit test to the the window. More...
 

Detailed Description

The popup class shows windows that are shown non-modal.

At the moment these windows also don't capture the mouse and keyboard so can only be used for things like tooltips. This behavior might change later.

Definition at line 34 of file modeless_dialog.hpp.

Constructor & Destructor Documentation

◆ modeless_dialog()

gui2::dialogs::modeless_dialog::modeless_dialog ( )

Definition at line 27 of file modeless_dialog.cpp.

◆ ~modeless_dialog()

gui2::dialogs::modeless_dialog::~modeless_dialog ( )
virtual

Definition at line 31 of file modeless_dialog.cpp.

References hide().

Member Function Documentation

◆ build_window()

window * gui2::dialogs::modeless_dialog::build_window ( ) const
private

Builds the window.

Every dialog shows it's own kind of window, this function should return the window to show.

Returns
The window to show.

Definition at line 70 of file modeless_dialog.cpp.

References gui2::build(), and window_id().

Referenced by show().

◆ get_window()

window* gui2::dialogs::modeless_dialog::get_window ( ) const
inline

Returns a pointer to the dialog's window.

Will be null if it hasn't been built yet.

Definition at line 82 of file modeless_dialog.hpp.

References window_.

Referenced by gui2::dialogs::debug_clock::post_show().

◆ hide()

void gui2::dialogs::modeless_dialog::hide ( )

Hides the window.

The hiding also destroys the window. It is save to call the function when the window is not shown.

Definition at line 58 of file modeless_dialog.cpp.

References gui2::window::modeless, gui2::remove_from_window_stack(), and window_.

Referenced by gui2::dialogs::tip::remove(), show(), and ~modeless_dialog().

◆ post_build()

void gui2::dialogs::modeless_dialog::post_build ( window window)
privatevirtual

Actions to be taken directly after the window is build.

Parameters
windowThe window just created.

Definition at line 75 of file modeless_dialog.cpp.

Referenced by show().

◆ pre_show()

void gui2::dialogs::modeless_dialog::pre_show ( window window)
privatevirtual

Actions to be taken before showing the window.

Parameters
windowThe window to be shown.

Reimplemented in gui2::dialogs::debug_clock, and gui2::dialogs::tooltip.

Definition at line 80 of file modeless_dialog.cpp.

Referenced by show().

◆ show()

void gui2::dialogs::modeless_dialog::show ( const bool  allow_interaction = false,
const unsigned  auto_close_time = 0 
)

Shows the window.

Parameters
allow_interactionDoes the dialog allow interaction?
  • true a non modal window is shown
  • false a tooltip window is shown
auto_close_timeThe time in ms after which the dialog will automatically close, if 0 it doesn't close.
Note
the timeout is a minimum time and there's no guarantee about how fast it closes after the minimum.

Definition at line 36 of file modeless_dialog.cpp.

References build_window(), CVideo::get_singleton(), hide(), gui2::open_window_stack, post_build(), pre_show(), and window_.

Referenced by gui2::dialogs::tip::show().

◆ window_id()

virtual const std::string& gui2::dialogs::modeless_dialog::window_id ( ) const
privatepure virtual

The id of the window to build.

Implemented in gui2::dialogs::debug_clock, and gui2::dialogs::tooltip.

Referenced by build_window(), and gui2::dialogs::unit_test_mark_popup_as_tested().

Friends And Related Function Documentation

◆ unit_test_mark_popup_as_tested

std::string unit_test_mark_popup_as_tested ( const modeless_dialog dialog)
friend

Special helper function to get the id of the window.

This is used in the unit tests, but these implementation details shouldn't be used in the normal code.

Definition at line 147 of file test_gui2.cpp.

◆ unit_test_window

window* unit_test_window ( const modeless_dialog dialog)
friend

Special helper function for the unit test to the the window.

This is used in the unit tests, but these implementation details shouldn't be used in the normal code.

Definition at line 154 of file test_gui2.cpp.

Member Data Documentation

◆ window_

std::unique_ptr<window> gui2::dialogs::modeless_dialog::window_
protected

The window, used in show.

Definition at line 89 of file modeless_dialog.hpp.

Referenced by get_window(), hide(), show(), and gui2::dialogs::unit_test_window().


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