base class of top level items, the only item which needs to store the final canvases to draw on. More...
#include <window.hpp>
Classes | |
class | invalidate_layout_blocker |
Helper class to block invalidate_layout. More... | |
struct | linked_size |
Helper struct to force widgets the have the same size. More... | |
Public Member Functions | |
window (const builder_window::window_resolution &definition) | |
< Needs to be initialized in show. More... | |
~window () | |
int | show (const bool restore=true, const unsigned auto_close_timeout=0) |
Shows the window. More... | |
void | show_tooltip () |
Shows the window as a tooltip. More... | |
void | show_non_modal () |
Shows the window non modal. More... | |
void | draw () |
Draws the window. More... | |
void | undraw () |
Undraws the window. More... | |
void | add_to_dirty_list (const std::vector< widget *> &call_stack) |
Adds an item to the dirty_list_. More... | |
void | close () |
Requests to close the window. More... | |
bool | invalidate_layout_blocked () const |
Is invalidate_layout blocked, see invalidate_layout_blocker. More... | |
void | invalidate_layout () |
Updates the size of the window. More... | |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) override |
See widget::find_at. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const override |
See widget::find_at. More... | |
dialogs::modal_dialog * | dialog () |
Inherited from widget. More... | |
widget * | find (const std::string &id, const bool must_be_active) override |
See widget::find. More... | |
const widget * | find (const std::string &id, const bool must_be_active) const override |
See widget::find. More... | |
bool | does_click_dismiss () const |
Does the window close easily? More... | |
void | set_enter_disabled (const bool enter_disabled) |
Disable the enter key. More... | |
void | set_escape_disabled (const bool escape_disabled) |
Disable the escape key. More... | |
void | init_linked_size_group (const std::string &id, const bool fixed_width, const bool fixed_height) |
Initializes a linked size group. More... | |
bool | has_linked_size_group (const std::string &id) |
Is the linked size group defined for this window? More... | |
void | add_linked_widget (const std::string &id, widget *widget) |
Adds a widget to a linked size group. More... | |
void | remove_linked_widget (const std::string &id, const widget *widget) |
Removes a widget from a linked size group. More... | |
void | set_retval (const int retval, const bool close_window=true) |
Sets there return value of the window. More... | |
int | get_retval () |
void | set_owner (dialogs::modal_dialog *owner) |
void | set_click_dismiss (const bool click_dismiss) |
bool | get_need_layout () const |
void | set_variable (const std::string &key, const wfl::variant &value) |
point | get_linked_size (const std::string &linked_group_id) const |
void | set_exit_hook (std::function< bool(window &)> func) |
Sets the window's exit hook. More... | |
void | set_exit_hook_ok_only (std::function< bool(window &)> func) |
void | set_callback_next_draw (std::function< void()> func) |
Sets a callback that will be called after the window is drawn next time. More... | |
void | set_suspend_drawing (bool s=true) |
const event::distributor & | get_distributor () const |
Gets a reference to the window's distributor to allow some state peeking. More... | |
show_mode | mode () const |
Returns the dialog mode for this window. More... | |
void | mouse_capture (const bool capture=true) |
void | keyboard_capture (widget *widget) |
void | add_to_keyboard_chain (widget *widget) |
Adds the widget to the keyboard chain. More... | |
void | remove_from_keyboard_chain (widget *widget) |
Remove the widget from the keyboard chain. More... | |
void | add_to_tab_order (widget *widget, int at=-1) |
Add the widget to the tabbing order. More... | |
![]() | |
panel (const implementation::builder_styled_widget &builder, const std::string &control_type="") | |
Constructor. More... | |
virtual SDL_Rect | get_client_rect () const override |
See container_base::get_client_rect. More... | |
virtual bool | get_active () const override |
See styled_widget::get_active. More... | |
virtual unsigned | get_state () const override |
See styled_widget::get_state. More... | |
![]() | |
container_base (const implementation::builder_styled_widget &builder, const std::string &control_type) | |
virtual void | layout_initialize (const bool full_initialization) override |
See widget::layout_initialize. More... | |
void | reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a container. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
virtual void | demand_reduce_width (const unsigned maximum_width) override |
See widget::demand_reduce_width. More... | |
void | reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a container. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See widget::request_reduce_height. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) override |
See widget::demand_reduce_height. More... | |
virtual bool | can_wrap () const override |
See widget::can_wrap. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
virtual bool | has_widget (const widget &widget) const override |
See widget::has_widget. More... | |
virtual void | set_origin (const point &origin) override |
See widget::set_origin. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See widget::set_visible_rectangle. More... | |
virtual void | impl_draw_children (int x_offset, int y_offset) override |
See widget::impl_draw_children. More... | |
virtual void | set_active (const bool active) override |
See styled_widget::set_active. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
void | init_grid (const builder_grid &grid_builder) |
Initializes and builds the grid. More... | |
grid::iterator | begin () |
grid::iterator | end () |
unsigned | add_row (const unsigned count=1) |
void | set_rows (const unsigned rows) |
unsigned int | get_rows () const |
void | set_cols (const unsigned cols) |
unsigned int | get_cols () const |
void | set_rows_cols (const unsigned rows, const unsigned cols) |
void | set_child (std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size) |
void | set_row_grow_factor (const unsigned row, const unsigned factor) |
void | set_column_grow_factor (const unsigned column, const unsigned factor) |
const grid & | get_grid () const |
grid & | get_grid () |
![]() | |
styled_widget (const implementation::builder_styled_widget &builder, const std::string &control_type) | |
Constructor. More... | |
virtual void | set_members (const string_map &data) |
Sets the members of the styled_widget. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
point | get_config_minimum_size () const |
Gets the minimum size as defined in the config. More... | |
point | get_config_default_size () const |
Gets the default size as defined in the config. More... | |
point | get_config_maximum_size () const |
Gets the best size as defined in the config. More... | |
virtual unsigned | get_characters_per_line () const |
Returns the number of characters per line. More... | |
virtual bool | get_link_aware () const |
Returns whether the label should be link_aware, in in rendering and in searching for links with get_link. More... | |
virtual color_t | get_link_color () const |
Returns the color string to be used with links. More... | |
bool | get_use_tooltip_on_label_overflow () const |
void | set_use_tooltip_on_label_overflow (const bool use_tooltip=true) |
const t_string & | get_label () const |
virtual void | set_label (const t_string &label) |
virtual void | set_use_markup (bool use_markup) |
bool | get_use_markup () const |
const t_string & | tooltip () const |
void | set_tooltip (const t_string &tooltip) |
const t_string & | help_message () const |
void | set_help_message (const t_string &help_message) |
std::vector< canvas > & | get_canvases () |
canvas & | get_canvas (const unsigned index) |
virtual void | set_text_alignment (const PangoAlignment text_alignment) |
PangoAlignment | get_text_alignment () const |
void | set_text_ellipse_mode (const PangoEllipsizeMode ellipse_mode) |
PangoEllipsizeMode | get_text_ellipse_mode () const |
Get the text's ellipsize mode. More... | |
![]() | |
widget (const widget &)=delete | |
widget & | operator= (const widget &)=delete |
widget () | |
widget (const builder_widget &builder) | |
Constructor. More... | |
virtual | ~widget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
window * | get_window () |
Get the parent window. More... | |
const window * | get_window () const |
The constant version of get_window. More... | |
grid * | get_parent_grid () |
Get the parent grid. More... | |
void | set_parent (widget *parent) |
widget * | parent () |
point | get_best_size () const |
Gets the best size for the widget. More... | |
virtual bool | can_mouse_focus () const |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual void | set_size (const point &size) |
Sets the size of the widget. More... | |
virtual void | move (const int x_offset, const int y_offset) |
Moves a widget. More... | |
virtual void | set_horizontal_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | set_vertical_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
point | get_origin () const |
Returns the screen origin of the widget. More... | |
point | get_size () const |
Returns the size of the widget. More... | |
SDL_Rect | get_rectangle () const |
Gets the bounding rectangle of the widget on the screen. More... | |
int | get_x () const |
int | get_y () const |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_linked_group (const std::string &linked_group) |
SDL_Rect | calculate_blitting_rectangle (const int x_offset, const int y_offset) |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle (const int x_offset, const int y_offset) |
Calculates the clipping rectangle of the widget. More... | |
void | draw_background (int x_offset, int y_offset) |
Draws the background of a widget. More... | |
void | draw_children (int x_offset, int y_offset) |
Draws the children of a widget. More... | |
void | draw_foreground (int x_offset, int y_offset) |
Draws the foreground of the widget. More... | |
void | populate_dirty_list (window &caller, std::vector< widget *> &call_stack) |
Adds a widget to the dirty list if it is dirty. More... | |
SDL_Rect | get_dirty_rectangle () const |
Gets the dirty rectangle of the widget. More... | |
void | set_is_dirty (const bool is_dirty) |
bool | get_is_dirty () const |
void | set_visible (const visibility visible) |
visibility | get_visible () const |
redraw_action | get_drawing_action () const |
void | set_debug_border_mode (const debug_border debug_border_mode) |
void | set_debug_border_color (const color_t debug_border_color) |
![]() | |
event_executor () | |
virtual | ~event_executor () |
void | set_wants_mouse_hover (const bool hover=true) |
bool | wants_mouse_hover () const |
void | set_wants_mouse_left_double_click (const bool click=true) |
bool | wants_mouse_left_double_click () const |
void | set_wants_mouse_middle_double_click (const bool click=true) |
bool | wants_mouse_middle_double_click () const |
event_executor & | set_wants_mouse_right_double_click (const bool click=true) |
bool | wants_mouse_right_double_click () const |
![]() | |
dispatcher () | |
virtual | ~dispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
bool | has_event (const ui_event event, const event_queue_type event_type) |
bool | fire (const ui_event event, widget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const std::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &pos, const point &distance) |
Fires an event which takes touch-motion parameters. More... | |
bool | fire (const ui_event event, widget &target, const point ¢er, float dTheta, float dDist, uint8_t numFingers) |
Fires an event which takes touch-gesture parameters. More... | |
bool | fire (const ui_event event, widget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const ui_event event, widget &target, const message &msg) |
Fires an event which takes message parameters. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Event &sdlevent) |
Fires an event that's a raw SDL event. More... | |
bool | fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len) |
Fires an event which takes text input parameters. More... | |
template<ui_event E, typename F > | |
void | connect_signal (const F &func, const queue_position position=back_child) |
Adds a callback to the appropriate queue based on event type. More... | |
template<ui_event E, typename F > | |
void | disconnect_signal (const F &func, const queue_position position=back_child) |
Removes a callback from the appropriate queue based on event type. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const mouse_behavior mouse_behavior) |
mouse_behavior | get_mouse_behavior () const |
void | set_want_keyboard_input (const bool want_keyboard_input) |
bool | get_want_keyboard_input () const |
void | register_hotkey (const hotkey::HOTKEY_COMMAND id, const hotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
![]() | |
enable_lua_ptr (widget *tp) | |
Static Public Member Functions | |
static window * | window_instance (const unsigned handle) |
Returns the instance of a window. More... | |
static retval | get_retval_by_id (const std::string &id) |
Gets the retval for the default buttons. More... | |
static const std::string & | type () |
Static type getter that does not rely on the widget being constructed. More... | |
![]() | |
static const std::string & | type () |
Static type getter that does not rely on the widget being constructed. More... | |
Private Member Functions | |
void | layout () |
Layouts the window. More... | |
void | layout_linked_widgets () |
Layouts the linked widgets. More... | |
bool | click_dismiss (const int mouse_button_mask) |
Handles a mouse click event for dismissing the dialog. More... | |
virtual const std::string & | get_control_type () const override |
Inherited from styled_widget, implemented by REGISTER_WIDGET. More... | |
void | redraw_windows_on_top () const |
Schedules windows on top of us (if any) to redraw. More... | |
void | finalize (const builder_grid &content_grid) |
Finishes the initialization of the grid. More... | |
void | generate_dot_file (const std::string &, const unsigned) |
void | signal_handler_sdl_video_resize (const event::ui_event event, bool &handled, const point &new_size) |
void | signal_handler_click_dismiss (const event::ui_event event, bool &handled, bool &halt, const int mouse_button_mask) |
The handler for the click dismiss mouse 'event'. More... | |
void | signal_handler_sdl_key_down (const event::ui_event event, bool &handled, const SDL_Keycode key, const SDL_Keymod mod, bool handle_tab) |
void | signal_handler_message_show_tooltip (const event::ui_event event, bool &handled, const event::message &message) |
void | signal_handler_message_show_helptip (const event::ui_event event, bool &handled, const event::message &message) |
void | signal_handler_request_placement (const event::ui_event event, bool &handled) |
void | signal_handler_close_window () |
Private Attributes | |
CVideo & | video_ |
Needed so we can change what's drawn on the screen. More... | |
status | status_ |
The status of the window. More... | |
show_mode | show_mode_ |
The mode in which the window is shown. More... | |
int | retval_ |
dialogs::modal_dialog * | owner_ |
The dialog that owns the window. More... | |
bool | need_layout_ |
When set the form needs a full layout redraw cycle. More... | |
wfl::map_formula_callable | variables_ |
The variables of the canvas. More... | |
bool | invalidate_layout_blocked_ |
Is invalidate_layout blocked, see invalidate_layout_blocker. More... | |
bool | suspend_drawing_ |
Avoid drawing the window. More... | |
bool | restore_ |
Whether the window should undraw the window using restorer_. More... | |
bool | is_toplevel_ |
Whether the window has other windows behind it. More... | |
surface | restorer_ |
When the window closes this surface is used to undraw the window. More... | |
const bool | automatic_placement_ |
Do we wish to place the widget automatically? More... | |
const unsigned | horizontal_placement_ |
Sets the horizontal placement. More... | |
const unsigned | vertical_placement_ |
Sets the vertical placement. More... | |
typed_formula< unsigned > | maximum_width_ |
The maximum width if automatic_placement_ is true. More... | |
typed_formula< unsigned > | maximum_height_ |
The maximum height if automatic_placement_ is true. More... | |
typed_formula< unsigned > | x_ |
The formula to calculate the x value of the dialog. More... | |
typed_formula< unsigned > | y_ |
The formula to calculate the y value of the dialog. More... | |
typed_formula< unsigned > | w_ |
The formula to calculate the width of the dialog. More... | |
typed_formula< unsigned > | h_ |
The formula to calculate the height of the dialog. More... | |
typed_formula< bool > | reevaluate_best_size_ |
The formula to determine whether the size is good. More... | |
wfl::function_symbol_table | functions_ |
The formula definitions available for the calculation formulas. More... | |
builder_window::window_resolution::tooltip_info | tooltip_ |
The settings for the tooltip. More... | |
builder_window::window_resolution::tooltip_info | helptip_ |
The settings for the helptip. More... | |
bool | click_dismiss_ |
Do we want to have easy close behavior? More... | |
bool | enter_disabled_ |
Disable the enter key see our setter for more info. More... | |
bool | escape_disabled_ |
Disable the escape key see our setter for more info. More... | |
std::map< std::string, linked_size > | linked_size_ |
List of the widgets, whose size are linked together. More... | |
std::vector< widget * > | tab_order |
List of widgets in the tabbing order. More... | |
int | mouse_button_state_ |
The state of the mouse button. More... | |
std::vector< std::vector< widget * > > | dirty_list_ |
The list with dirty items in the window. More... | |
unsigned int | consecutive_changed_frames_ = 0u |
In how many consecutive frames the window has changed. More... | |
std::unique_ptr< event::distributor > | event_distributor_ |
std::function< bool(window &)> | exit_hook_ |
std::function< void()> | callback_next_draw_ |
Friends | |
class | debug_layout_graph |
struct | window_implementation |
class | invalidate_layout_blocker |
class | pane |
std::unique_ptr< window > | build (const builder_window::window_resolution &) |
Builds a window. More... | |
Additional Inherited Members | |
![]() | |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
virtual void | layout_children () override |
See widget::layout_children. More... | |
virtual void | child_populate_dirty_list (window &caller, const std::vector< widget *> &call_stack) override |
See widget::child_populate_dirty_list. More... | |
![]() | |
resolution_definition_ptr | config () |
resolution_definition_const_ptr | config () const |
template<typename T > | |
std::shared_ptr< const typename T::resolution > | cast_config_to () const |
Casts the current resolution definition config to the respective type of a derived widget. More... | |
void | set_config (resolution_definition_ptr config) |
virtual void | update_canvas () |
Updates the canvas(ses). More... | |
unsigned int | get_text_font_size () const |
Resolves and returns the text_font_size. More... | |
int | get_text_maximum_width () const |
Returns the maximum width available for the text. More... | |
int | get_text_maximum_height () const |
Returns the maximum height available for the text. More... | |
std::string | get_label_token (const point &position, const char *delimiters=" \\) const |
Exposes font::pango_text::get_token, for the text label of this styled_widget. More... | |
std::string | get_label_link (const point &position) const |
![]() | |
void | set_layout_size (const point &size) |
const point & | layout_size () const |
void | clear_layout_size () |
Throws away layout_size_. More... | |
base class of top level items, the only item which needs to store the final canvases to draw on.
A window is a kind of panel see the panel for which fields exist.
Definition at line 65 of file window.hpp.
|
strong |
Enumerator | |
---|---|
none | |
modal | |
modeless | |
tooltip |
Definition at line 433 of file window.hpp.
|
strong |
The status of the window.
Definition at line 169 of file window.hpp.
|
explicit |
< Needs to be initialized in show.
Definition at line 276 of file window.cpp.
References automatic_placement_, gui2::event::dispatcher::back_post_child, gui2::event::dispatcher::back_pre_child, callback_next_draw_, click_dismiss_, gui2::event::dispatcher::connect(), debug_layout_graph, gui2::builder_window::window_resolution::definition, dirty_list_, draw(), enter_disabled_, escape_disabled_, event_distributor_, exit_hook_, CVideo::faked(), gui2::event::dispatcher::front_child, functions_, CVideo::get_singleton(), hotkey::GLOBAL__HELPTIP, h_, helptip_, horizontal_placement_, hotkey::HOTKEY_FULLSCREEN, gui2::event::distributor::initialize_state(), invalidate_layout_blocked_, gui2::is_in_dialog(), is_toplevel_, linked_size_, maximum_height_, maximum_width_, mouse_button_state_, need_layout_, NEW, gui2::NONE, none, owner_, reevaluate_best_size_, gui2::event::dispatcher::register_hotkey(), restore_, restorer_, retval_, show_mode_, signal_handler_click_dismiss(), signal_handler_close_window(), signal_handler_message_show_helptip(), signal_handler_message_show_tooltip(), signal_handler_request_placement(), signal_handler_sdl_key_down(), signal_handler_sdl_video_resize(), status_, suspend_drawing_, CVideo::toggle_fullscreen(), tooltip_, type(), variables_, vertical_placement_, video_, w_, x_, and y_.
gui2::window::~window | ( | ) |
Definition at line 393 of file window.cpp.
References gui2::grid::get_cols(), gui2::container_base::get_grid(), gui2::grid::get_rows(), modal, gui2::dialogs::tip::remove(), gui2::grid::remove_child(), and show_mode_.
void gui2::window::add_linked_widget | ( | const std::string & | id, |
widget * | widget | ||
) |
Adds a widget to a linked size group.
The group needs to exist, which is done by calling init_linked_size_group. A widget may only be member of one group.
id | The id of the group. |
widget | The widget to add to the group. |
Definition at line 842 of file window.cpp.
References ERR_GUI, has_linked_size_group(), gui2::widget::id(), and linked_size_.
Referenced by gui2::widget::layout_initialize().
|
inline |
Adds an item to the dirty_list_.
call_stack | The list of widgets traversed to get to the dirty widget. |
Definition at line 163 of file window.hpp.
Referenced by gui2::widget::populate_dirty_list().
void gui2::window::add_to_keyboard_chain | ( | widget * | widget | ) |
Adds the widget to the keyboard chain.
widget | The widget to add to the chain. The widget should be valid widget, which hasn't been added to the chain yet. |
Definition at line 1259 of file window.cpp.
References event_distributor_.
Referenced by gui2::addon_list::add_list_to_keyboard_chain().
void gui2::window::add_to_tab_order | ( | widget * | widget, |
int | at = -1 |
||
) |
Add the widget to the tabbing order.
widget | The widget to be added to the tabbing order |
at | A hint for where to place the widget in the tabbing order |
Definition at line 1271 of file window.cpp.
References schema_validation::at(), event_distributor_, keyboard_capture(), tab_order, and gui2::widget::widget().
Referenced by gui2::dialogs::editor_edit_side::pre_show(), gui2::dialogs::editor_edit_scenario::pre_show(), gui2::dialogs::custom_tod::pre_show(), and gui2::dialogs::editor_edit_label::pre_show().
|
private |
Handles a mouse click event for dismissing the dialog.
mouse_button_mask | The SDL_BUTTON mask for the button used to dismiss the click. If the caller is from the keyboard code the value should be 0. |
Definition at line 1119 of file window.cpp.
References does_click_dismiss(), mouse_button_state_, gui2::OK, and set_retval().
Referenced by signal_handler_click_dismiss(), and signal_handler_sdl_key_down().
|
inline |
Requests to close the window.
At the moment the request is always honored but that might change in the future.
Definition at line 182 of file window.hpp.
Referenced by gui2::dialogs::lobby_player_info::check_status_button_callback(), gui2::dialogs::outro::draw_callback(), gui2::dialogs::addon_manager::fetch_addons_list(), gui2::dialogs::synched_choice_wait::handle_generic_event(), gui2::dialogs::lobby_player_info::kick_ban_button_callback(), gui2::dialogs::lobby_player_info::kick_button_callback(), gui2::dialogs::story_viewer::nav_button_callback(), gui2::dialogs::loading_screen::process(), gui2::dialogs::lobby_player_info::start_whisper_button_callback(), and gui2::dialogs::lobby_player_info::stopgame_button_callback().
|
inline |
Inherited from widget.
Definition at line 231 of file window.hpp.
|
inline |
Does the window close easily?
The behavior can change at run-time, but that might cause oddities with the easy close button (when one is needed).
Definition at line 273 of file window.hpp.
Referenced by click_dismiss().
void gui2::window::draw | ( | ) |
Draws the window.
This routine draws the window if needed, it's called from the event handler. This is done by a drawing event. When a window is shown it manages an SDL timer which fires a drawing event every X milliseconds, that event calls this routine. Don't call it manually.
Definition at line 604 of file window.cpp.
References wfl::call_stack, callback_next_draw_, consecutive_changed_frames_, dirty_list_, CVideo::draw_area(), font::draw_floating_labels(), gui2::widget::get_rectangle(), get_surface_portion(), CVideo::getDrawingSurface(), gui2::widget::id_, is_toplevel_, layout(), gui2::container_base::layout_children(), need_layout_, gui2::new_widgets, gui2::widget::none, gui2::widget::populate_dirty_list(), redraw_windows_on_top(), restore_, restorer_, sdl_blit(), suspend_drawing_, video_, and gui2::widget::visible.
Referenced by show(), gui2::dialogs::unit_test_window(), and window().
|
private |
Finishes the initialization of the grid.
content_grid | The new contents for the content grid. |
Definition at line 1143 of file window.cpp.
References gui2::builder_grid::build(), c, generate_dot_file(), gui2::container_base::get_grid(), gui2::widget::id(), and gui2::widget::set_id().
|
overridevirtual |
See widget::find.
Reimplemented from gui2::container_base.
Definition at line 816 of file window.cpp.
References gui2::container_base::find().
Referenced by gui2::dialogs::modal_dialog::init_fields().
|
overridevirtual |
See widget::find.
Reimplemented from gui2::container_base.
Definition at line 821 of file window.cpp.
References gui2::container_base::find().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::container_base.
Definition at line 805 of file window.cpp.
References gui2::container_base::find_at().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::container_base.
Definition at line 810 of file window.cpp.
References gui2::container_base::find_at().
|
inlineprivate |
Definition at line 679 of file window.hpp.
Referenced by finalize(), layout(), show(), show_non_modal(), and show_tooltip().
|
overrideprivatevirtual |
Inherited from styled_widget, implemented by REGISTER_WIDGET.
Reimplemented from gui2::panel.
|
inline |
Gets a reference to the window's distributor to allow some state peeking.
Definition at line 688 of file window.hpp.
|
inline |
Definition at line 390 of file window.hpp.
Referenced by gui2::widget::get_best_size().
|
inline |
Definition at line 380 of file window.hpp.
Referenced by gui2::scrollbar_container::content_resize_request().
|
inline |
Definition at line 365 of file window.hpp.
Referenced by gui2::dialogs::mp_lobby::exit_hook(), gui2::dialogs::addon_manager::exit_hook(), gui2::dialogs::file_dialog::on_exit(), gui2::dialogs::mp_join_game::post_show(), gui2::dialogs::mp_change_control::post_show(), gui2::dialogs::mp_staging::post_show(), and gui2::dialogs::sp_options_configure::post_show().
|
static |
Gets the retval for the default buttons.
Definition at line 433 of file window.cpp.
References gui2::CANCEL, gui2::NONE, and gui2::OK.
Referenced by gui2::implementation::get_retval().
bool gui2::window::has_linked_size_group | ( | const std::string & | id | ) |
Is the linked size group defined for this window?
id | The id of the group. |
Definition at line 837 of file window.cpp.
References linked_size_.
Referenced by add_linked_widget(), init_linked_size_group(), and remove_linked_widget().
void gui2::window::init_linked_size_group | ( | const std::string & | id, |
const bool | fixed_width, | ||
const bool | fixed_height | ||
) |
Initializes a linked size group.
Note at least one of fixed_width or fixed_height must be true.
id | The id of the group. |
fixed_width | Does the group have a fixed width? |
fixed_height | Does the group have a fixed height? |
Definition at line 827 of file window.cpp.
References has_linked_size_group(), gui2::widget::id(), and linked_size_.
Referenced by gui2::container_base::inject_linked_groups().
void gui2::window::invalidate_layout | ( | ) |
Updates the size of the window.
If the window has automatic placement set this function recalculates the window. To be used after creation and after modification or items which can have different sizes eg listboxes.
Definition at line 799 of file window.cpp.
References invalidate_layout_blocked_, and need_layout_.
Referenced by gui2::scrollbar_container::content_resize_height(), gui2::scrollbar_container::content_resize_width(), gui2::dialogs::game_load::display_savegame_internal(), gui2::scrollbar_base::recalculate(), gui2::dialogs::unit_recall::rename_unit(), gui2::listbox::set_row_shown(), gui2::widget::set_visible(), show(), show_non_modal(), gui2::dialogs::mp_lobby::show_preferences_button_callback(), show_tooltip(), signal_handler_request_placement(), signal_handler_sdl_video_resize(), and WIDGET_SETTER().
|
inline |
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition at line 208 of file window.hpp.
void gui2::window::keyboard_capture | ( | widget * | widget | ) |
Definition at line 1253 of file window.cpp.
References event_distributor_.
Referenced by add_to_tab_order(), gui2::dialogs::modal_dialog::init_fields(), gui2::listbox::list_item_clicked(), gui2::dialogs::file_dialog::on_bookmark_selected(), gui2::dialogs::file_dialog::on_row_selected(), gui2::scroll_label::signal_handler_left_button_down(), gui2::tree_view::signal_handler_left_button_down(), gui2::text_box::signal_handler_left_button_down(), gui2::slider::signal_handler_left_button_up(), gui2::chatbox::signal_handler_receive_keyboard_focus(), signal_handler_sdl_key_down(), and gui2::chatbox::switch_to_window().
|
private |
Layouts the window.
This part does the pre and post processing for the actual layout algorithm.
See Layout algorithm for more information.
Definition at line 876 of file window.cpp.
References _(), wfl::map_formula_callable::add(), automatic_placement_, click_dismiss_, gui2::event::connect_signal_mouse_left_click(), gui2::container_base::disable_click_dismiss(), functions_, generate_dot_file(), gui2::widget::get_best_size(), gui2::get_mouse_position(), gui2::get_screen_size_variables(), h_, gui2::grid::HORIZONTAL_ALIGN_CENTER, gui2::grid::HORIZONTAL_ALIGN_LEFT, gui2::grid::HORIZONTAL_ALIGN_RIGHT, horizontal_placement_, gui2::event::init_mouse_location(), gui2::widget::invisible, gui2::window_implementation::layout(), gui2::container_base::layout_initialize(), layout_linked_widgets(), gui2::log_gui_layout, log_scope2, LOG_SCOPE_HEADER, maximum_height_, maximum_width_, need_layout_, gui2::OK, gui2::container_base::place(), reevaluate_best_size_, gui2::settings::screen_height, gui2::settings::screen_width, set_retval(), gui2::widget::set_visible(), utf8::size(), VALIDATE, variables_, gui2::grid::VERTICAL_ALIGN_BOTTOM, gui2::grid::VERTICAL_ALIGN_CENTER, gui2::grid::VERTICAL_ALIGN_TOP, vertical_placement_, gui2::widget::visible, w_, point::x, x_, point::y, and y_.
Referenced by draw(), and gui2::window_implementation::layout().
|
private |
Layouts the linked widgets.
See Layout algorithm for more information.
Definition at line 1073 of file window.cpp.
References gui2::widget::get_best_size(), gui2::window::linked_size::height, linked_size_, gui2::widget::set_layout_size(), utf8::size(), gui2::window::linked_size::widgets, gui2::window::linked_size::width, point::x, and point::y.
Referenced by gui2::window_implementation::layout(), layout(), and gui2::pane::signal_handler_request_placement().
|
inline |
Returns the dialog mode for this window.
Definition at line 694 of file window.hpp.
References schema_validation::at().
void gui2::window::mouse_capture | ( | const bool | capture = true | ) |
Definition at line 1247 of file window.cpp.
References event_distributor_.
Referenced by gui2::button::signal_handler_left_button_down(), gui2::repeating_button::signal_handler_left_button_down(), gui2::menu_button::signal_handler_left_button_down(), gui2::multimenu_button::signal_handler_left_button_down(), gui2::text_box::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_up(), and gui2::scrollbar_base::signal_handler_left_button_up().
|
private |
Schedules windows on top of us (if any) to redraw.
Definition at line 1132 of file window.cpp.
References gui2::event::get_all_dispatchers(), and gui2::widget::set_is_dirty().
Referenced by draw().
void gui2::window::remove_from_keyboard_chain | ( | widget * | widget | ) |
Remove the widget from the keyboard chain.
widget | The widget to be removed from the chain. |
Definition at line 1265 of file window.cpp.
References event_distributor_.
void gui2::window::remove_linked_widget | ( | const std::string & | id, |
const widget * | widget | ||
) |
Removes a widget from a linked size group.
The group needs to exist, which is done by calling init_linked_size_group. If the widget is no member of the group the function does nothing.
id | The id of the group. |
widget | The widget to remove from the group. |
Definition at line 856 of file window.cpp.
References has_linked_size_group(), gui2::widget::id(), and linked_size_.
Referenced by gui2::widget::~widget().
|
inline |
Sets a callback that will be called after the window is drawn next time.
The callback is automatically removed after calling it once. Useful if you need to do something after the window is drawn for the first time and it's timing-sensitive (i.e. pre_show is too early).
Definition at line 423 of file window.hpp.
Referenced by gui2::dialogs::end_credits::pre_show(), and gui2::dialogs::lua_interpreter::view::update_contents().
|
inline |
Definition at line 375 of file window.hpp.
Referenced by gui2::dialogs::title_screen::pre_show().
|
inline |
Disable the enter key.
This is added to block dialogs from being closed automatically.
Definition at line 286 of file window.hpp.
Referenced by gui2::dialogs::game_load::display_savegame(), gui2::dialogs::outro::pre_show(), gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::story_viewer::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::loading_screen::pre_show(), and gui2::dialogs::title_screen::pre_show().
|
inline |
Disable the escape key.
This is added to block dialogs from being closed automatically.
Definition at line 299 of file window.hpp.
Referenced by gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::loading_screen::pre_show(), and gui2::dialogs::title_screen::pre_show().
|
inline |
Sets the window's exit hook.
A window will only close if this function returns true.
func | A function taking a window reference and returning a boolean result. |
Definition at line 407 of file window.hpp.
|
inline |
Definition at line 412 of file window.hpp.
|
inline |
Definition at line 370 of file window.hpp.
|
inline |
Sets there return value of the window.
retval | The return value for the window. |
close_window | Close the window after setting the value. |
Definition at line 358 of file window.hpp.
Referenced by gui2::dialogs::title_screen::button_callback_cores(), gui2::dialogs::title_screen::button_callback_multiplayer(), click_dismiss(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::drop_down_menu::entry_data::entry_data(), layout(), gui2::dialogs::file_dialog::on_exit(), gui2::dialogs::title_screen::pre_show(), signal_handler_close_window(), gui2::button::signal_handler_left_button_click(), gui2::toggle_button::signal_handler_left_button_double_click(), gui2::toggle_panel::signal_handler_left_button_double_click(), and signal_handler_sdl_key_down().
|
inline |
Definition at line 428 of file window.hpp.
References s.
|
inline |
Definition at line 385 of file window.hpp.
Referenced by gui2::dialogs::drop_down_menu::pre_show().
int gui2::window::show | ( | const bool | restore = true , |
const unsigned | auto_close_timeout = 0 |
||
) |
Shows the window.
the show functions are a bit messy and can use a proper cleanup.
restore | Restore the screenarea the window was on after closing it? |
auto_close_timeout | The time in ms after which the window will automatically close, if 0 it doesn't close. |
In the future the restoring shouldn't be needed so the duplication doesn't hurt too much but keep this todo as a reminder.
Definition at line 493 of file window.cpp.
References CLOSE_WINDOW_EVENT, CLOSED, draw(), event_distributor_, exit_hook_, generate_dot_file(), hotkey::get_id(), sdl::get_mouse_button_mask(), gui2::widget::get_rectangle(), CVideo::getDrawingSurface(), invalidate_layout(), gui2::log_gui_draw, log_scope2, LOG_SCOPE_HEADER, modal, mouse_button_state_, NEW, events::pump(), gui2::dialogs::tip::remove(), REQUEST_CLOSE, restore_, restorer_, retval_, sdl_blit(), show_mode_, SHOWING, status_, suspend_drawing_, font::undraw_floating_labels(), and video_.
Referenced by intf_show_dialog().
void gui2::window::show_non_modal | ( | ) |
Shows the window non modal.
A tooltip can be interacted with unlike the tooltip.
auto_close_timeout
.auto_close_timeout
The time in ms after which the window will automatically close, if 0 it doesn't close.
Definition at line 468 of file window.cpp.
References generate_dot_file(), gui2::event::dispatcher::hit, invalidate_layout(), gui2::log_gui_draw, log_scope2, modeless, NEW, events::pump(), gui2::event::dispatcher::set_mouse_behavior(), show_mode_, status_, and suspend_drawing_.
void gui2::window::show_tooltip | ( | ) |
Shows the window as a tooltip.
A tooltip can't be interacted with and is just shown.
auto_close_timeout
.auto_close_timeout
The time in ms after which the window will automatically close, if 0 it doesn't close.
Definition at line 446 of file window.cpp.
References generate_dot_file(), invalidate_layout(), gui2::log_gui_draw, log_scope2, NEW, gui2::event::dispatcher::none, gui2::event::dispatcher::set_mouse_behavior(), gui2::event::dispatcher::set_want_keyboard_input(), show_mode_, status_, suspend_drawing_, and tooltip.
|
private |
The handler for the click dismiss mouse 'event'.
event | See event::dispatcher::fire. |
handled | See event::dispatcher::fire. |
halt | See event::dispatcher::fire. |
mouse_button_mask | Forwared to click_dismiss. |
Definition at line 1302 of file window.cpp.
References click_dismiss(), DBG_GUI_E, and LOG_HEADER.
Referenced by window().
|
private |
Definition at line 1416 of file window.cpp.
References gui2::AUTO_CLOSE, and set_retval().
Referenced by window().
|
private |
Definition at line 1392 of file window.cpp.
References DBG_GUI_E, helptip_, gui2::builder_window::window_resolution::tooltip_info::id, gui2::event::message_show_helptip::location, LOG_HEADER, gui2::event::message_show_helptip::message, gui2::dialogs::tip::show(), and gui2::event::message_show_helptip::source_rect.
Referenced by window().
|
private |
Definition at line 1378 of file window.cpp.
References DBG_GUI_E, gui2::builder_window::window_resolution::tooltip_info::id, gui2::event::message_show_tooltip::location, LOG_HEADER, gui2::event::message_show_tooltip::message, gui2::dialogs::tip::show(), gui2::event::message_show_tooltip::source_rect, and tooltip_.
Referenced by window().
|
private |
Definition at line 1406 of file window.cpp.
References DBG_GUI_E, invalidate_layout(), and LOG_HEADER.
Referenced by window().
|
private |
Definition at line 1321 of file window.cpp.
References gui2::CANCEL, click_dismiss(), DBG_GUI_E, enter_disabled_, escape_disabled_, event_distributor_, gui2::is_active(), keyboard_capture(), LOG_HEADER, gui2::OK, set_retval(), and tab_order.
Referenced by window().
|
private |
Definition at line 1287 of file window.cpp.
References DBG_GUI_E, gui2::settings::gamemap_height, gui2::settings::gamemap_width, invalidate_layout(), LOG_HEADER, gui2::settings::screen_height, gui2::settings::screen_width, point::x, and point::y.
Referenced by window().
|
static |
Static type getter that does not rely on the widget being constructed.
Referenced by window().
void gui2::window::undraw | ( | ) |
Undraws the window.
Definition at line 777 of file window.cpp.
References gui2::widget::get_rectangle(), CVideo::getDrawingSurface(), restore_, restorer_, sdl_blit(), and video_.
Referenced by gui2::dialogs::custom_tod::update_tod_display().
|
static |
Returns the instance of a window.
handle | The instance id of the window. |
Definition at line 428 of file window.cpp.
References gui2::widget::get_window().
Referenced by gui2::event::sdl_event_handler::close_window().
|
friend |
Builds a window.
Definition at line 38 of file window_builder.cpp.
|
friend |
Definition at line 67 of file window.hpp.
Referenced by window().
|
friend |
Definition at line 70 of file window.hpp.
|
friend |
Definition at line 71 of file window.hpp.
|
friend |
Definition at line 69 of file window.hpp.
|
private |
Do we wish to place the widget automatically?
Definition at line 487 of file window.hpp.
|
private |
Definition at line 770 of file window.hpp.
|
private |
Do we want to have easy close behavior?
Easy closing means that whenever a mouse click is done the dialog will be closed. The widgets in the window may override this behavior by registering themselves as blockers. This is tested by the function disable_click_dismiss().
The handling of easy close is done in the window, in order to do so a window either needs a click_dismiss or an ok button. Both will be hidden when not needed and when needed first the ok is tried and then the click_dismiss button. this allows adding a click_dismiss button to the window definition and use the ok from the window instance.
Definition at line 552 of file window.hpp.
|
private |
In how many consecutive frames the window has changed.
This is used to detect the situation where the title screen changes in every frame, forcing all other windows to redraw everything all the time.
Definition at line 658 of file window.hpp.
Referenced by draw().
|
private |
The list with dirty items in the window.
When drawing only the widgets that are dirty are updated. The draw() function has more information about the dirty_list_.
Definition at line 651 of file window.hpp.
|
private |
Disable the enter key see our setter for more info.
Definition at line 555 of file window.hpp.
Referenced by signal_handler_sdl_key_down(), and window().
|
private |
Disable the escape key see our setter for more info.
Definition at line 558 of file window.hpp.
Referenced by signal_handler_sdl_key_down(), and window().
|
private |
Definition at line 684 of file window.hpp.
Referenced by add_to_keyboard_chain(), add_to_tab_order(), keyboard_capture(), mouse_capture(), remove_from_keyboard_chain(), show(), signal_handler_sdl_key_down(), and window().
|
private |
Definition at line 769 of file window.hpp.
|
private |
The formula definitions available for the calculation formulas.
Definition at line 527 of file window.hpp.
|
private |
The formula to calculate the height of the dialog.
Definition at line 521 of file window.hpp.
|
private |
The settings for the helptip.
Definition at line 533 of file window.hpp.
Referenced by signal_handler_message_show_helptip(), and window().
|
private |
Sets the horizontal placement.
Only used if automatic_placement_ is true. The value should be a grid placement flag.
Definition at line 495 of file window.hpp.
|
private |
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition at line 472 of file window.hpp.
Referenced by invalidate_layout(), gui2::window::invalidate_layout_blocker::invalidate_layout_blocker(), window(), and gui2::window::invalidate_layout_blocker::~invalidate_layout_blocker().
|
private |
Whether the window has other windows behind it.
Definition at line 481 of file window.hpp.
|
private |
List of the widgets, whose size are linked together.
Definition at line 585 of file window.hpp.
Referenced by add_linked_widget(), has_linked_size_group(), init_linked_size_group(), layout_linked_widgets(), remove_linked_widget(), and window().
|
private |
The maximum height if automatic_placement_ is true.
Definition at line 509 of file window.hpp.
|
private |
The maximum width if automatic_placement_ is true.
Definition at line 506 of file window.hpp.
|
private |
The state of the mouse button.
When click dismissing a dialog in the past the DOWN event was used. This lead to a bug [1]. The obvious change was to switch to the UP event, this lead to another bug; the dialog was directly dismissed. Since the game map code uses the UP and DOWN event to select a unit there is no simple solution.
Upon entry this value stores the mouse button state at entry. When a button is DOWN and goes UP that button does not trigger a dismissal of the dialog, instead that button's down state is removed from this variable. Therefore the next UP event does dismiss the dialog.
[1] https://gna.org/bugs/index.php?18970
Definition at line 635 of file window.hpp.
Referenced by click_dismiss(), show(), and window().
|
private |
When set the form needs a full layout redraw cycle.
This happens when either a widget changes it's size or visibility or the window is resized.
Definition at line 466 of file window.hpp.
Referenced by draw(), invalidate_layout(), layout(), and window().
|
private |
|
private |
The formula to determine whether the size is good.
Definition at line 524 of file window.hpp.
|
private |
|
private |
|
private |
Definition at line 455 of file window.hpp.
|
private |
The mode in which the window is shown.
This is used to determine whether or not to remove the tip.
Definition at line 452 of file window.hpp.
Referenced by show(), show_non_modal(), show_tooltip(), window(), and ~window().
|
private |
The status of the window.
Definition at line 445 of file window.hpp.
Referenced by show(), show_non_modal(), show_tooltip(), and window().
|
private |
Avoid drawing the window.
Definition at line 475 of file window.hpp.
Referenced by draw(), show(), show_non_modal(), show_tooltip(), and window().
|
private |
List of widgets in the tabbing order.
Definition at line 588 of file window.hpp.
Referenced by add_to_tab_order(), and signal_handler_sdl_key_down().
|
private |
The settings for the tooltip.
Definition at line 530 of file window.hpp.
Referenced by signal_handler_message_show_tooltip(), and window().
|
private |
The variables of the canvas.
Definition at line 469 of file window.hpp.
|
private |
Sets the vertical placement.
Only used if automatic_placement_ is true. The value should be a grid placement flag.
Definition at line 503 of file window.hpp.
|
private |
|
private |
The formula to calculate the width of the dialog.
Definition at line 518 of file window.hpp.
|
private |
The formula to calculate the x value of the dialog.
Definition at line 512 of file window.hpp.
|
private |
The formula to calculate the y value of the dialog.
Definition at line 515 of file window.hpp.