The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
window.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2007 - 2025
3 by Mark de Wever <koraq@xs4all.nl>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16/**
17 * @file
18 * This file contains the window object, this object is a top level container
19 * which has the event management as well.
20 */
21
22#pragma once
23
24#include "formula/callable.hpp"
25#include "formula/function.hpp"
29#include "gui/widgets/panel.hpp"
31
32#include "sdl/texture.hpp"
33
34#include <functional>
35#include <map>
36#include <memory>
37#include <string>
38#include <vector>
39
40
41namespace gui2
42{
43
44class widget;
45namespace event { struct message; }
46
47// ------------ WIDGET -----------{
48
49namespace event
50{
51class distributor;
52} // namespace event
53
54/**
55 * base class of top level items, the only item which needs to store the final canvases to draw on.
56 * A window is a kind of panel see the panel for which fields exist.
57 */
58class window : public panel, public top_level_drawable
59{
60 friend class debug_layout_graph;
61 friend struct window_implementation;
63 friend class pane;
64
65public:
66 explicit window(const builder_window::window_resolution& definition);
67
68 virtual ~window();
69
70 /**
71 * Returns the instance of a window.
72 *
73 * @param handle The instance id of the window.
74 *
75 * @returns The window or nullptr.
76 */
77 static window* window_instance(const unsigned handle);
78
79 /** Gets the retval for the default buttons. */
80 static retval get_retval_by_id(const std::string& id);
81
82 /**
83 * Shows the window, running an event loop until it should close.
84 *
85 * @param auto_close_timeout The time in ms after which the window will
86 * automatically close, if 0 it doesn't close.
87 * @note the timeout is a minimum time and
88 * there's no guarantee about how fast it closes
89 * after the minimum.
90 *
91 * @returns The close code of the window, predefined
92 * values are listed in retval.
93 */
94 int show(unsigned auto_close_timeout = 0);
95
96 /**
97 * Shows the window as a tooltip.
98 *
99 * A tooltip can't be interacted with and is just shown.
100 *
101 * @todo implement @p auto_close_timeout.
102 *
103 * @p auto_close_timeout The time in ms after which the window will
104 * automatically close, if 0 it doesn't close.
105 * @note the timeout is a minimum time and
106 * there's no guarantee about how fast it closes
107 * after the minimum.
108 */
109 void show_tooltip(/*const unsigned auto_close_timeout = 0*/);
110
111 /**
112 * Shows the window non modal.
113 *
114 * A tooltip can be interacted with unlike the tooltip.
115 *
116 * @todo implement @p auto_close_timeout.
117 *
118 * @p auto_close_timeout The time in ms after which the window will
119 * automatically close, if 0 it doesn't close.
120 * @note the timeout is a minimum time and
121 * there's no guarantee about how fast it closes
122 * after the minimum.
123 */
124 void show_non_modal(/*const unsigned auto_close_timeout = 0*/);
125
126 /**
127 * Draws the window.
128 *
129 * This routine draws the window if needed, it's called from the event
130 * handler. This is done by a drawing event. When a window is shown it
131 * manages an SDL timer which fires a drawing event every X milliseconds,
132 * that event calls this routine. Don't call it manually.
133 */
134 void draw();
135
136 /** Hides the window. It will not draw until it is shown again. */
137 void hide();
138
139 /**
140 * Lays out the window.
141 *
142 * This part does the pre and post processing for the actual layout
143 * algorithm.
144 *
145 * See @ref layout_algorithm for more information.
146 *
147 * This is also called by draw_manager to finalize screen layout.
148 */
149 virtual void layout() override;
150
151 /** Ensure the window's internal render buffer is up-to-date.
152 *
153 * This renders the window to an off-screen texture, which is then
154 * copied to the screen during expose().
155 */
156 virtual void render() override;
157
158private:
159 /** The internal render buffer used by render() and expose(). */
161
162 /** The part of the window (if any) currently marked for rerender. */
164
165 /** Parts of the window (if any) with rendering deferred to next frame */
166 std::vector<rect> deferred_regions_;
167
168 /** Ensure render textures are valid and correct. */
170
171public:
172 /**
173 * Called by draw_manager when it believes a redraw is necessary.
174 * Can be called multiple times per vsync.
175 */
176 virtual bool expose(const rect& region) override;
177
178 /** The current draw location of the window, on the screen. */
179 virtual rect screen_location() override;
180
181 /**
182 * Queue a rerender of the internal render buffer.
183 *
184 * This does not request a repaint. Ordinarily use queue_redraw()
185 * on a widget, which will call this automatically.
186 *
187 * @param region The region to rerender in screen coordinates.
188 */
189 void queue_rerender(const rect& region);
190 void queue_rerender();
191
192 /**
193 * Defer rendering of a particular region to next frame.
194 *
195 * This is used for blur, which must render the region underneath once
196 * before rendering the blur.
197 *
198 * @param region The region to defer in screen coordinates.
199 */
200 void defer_region(const rect& region);
201
202 /** The status of the window. */
203 enum class status {
204 NEW, /**< The window is new and not yet shown. */
205 SHOWING, /**< The window is being shown. */
206 REQUEST_CLOSE, /**< The window has been requested to be closed but still needs to evaluate the request. */
207 CLOSED /**< The window has been closed. */
208 };
209
210 /**
211 * Requests to close the window.
212 *
213 * This request is not always honored immediately, and so callers must account for the window remaining open.
214 * For example, when overriding draw_manager's update() method.
215 */
216 void close()
217 {
219 }
220
221 /**
222 * Helper class to block invalidate_layout.
223 *
224 * Some widgets can handling certain layout aspects without help. For
225 * example a listbox can handle hiding and showing rows without help but
226 * setting the visibility calls invalidate_layout(). When this blocker is
227 * Instantiated the call to invalidate_layout() becomes a nop.
228 *
229 * @note The class can't be used recursively.
230 */
240
241 /** Is invalidate_layout blocked, see invalidate_layout_blocker. */
243 {
245 }
246
247 /**
248 * Updates the size of the window.
249 *
250 * If the window has automatic placement set this function recalculates the
251 * window. To be used after creation and after modification or items which
252 * can have different sizes eg listboxes.
253 */
254 void invalidate_layout();
255
256 /** See @ref widget::find_at. */
257 virtual widget* find_at(const point& coordinate,
258 const bool must_be_active) override;
259
260 /** See @ref widget::find_at. */
261 virtual const widget* find_at(const point& coordinate,
262 const bool must_be_active) const override;
263
264 /** See @ref widget::find. */
265 widget* find(const std::string_view id, const bool must_be_active) override;
266
267 /** See @ref widget::find. */
268 const widget* find(const std::string_view id, const bool must_be_active) const override;
269
270#if 0
271 /** @todo Implement these functions. */
272 /**
273 * Register a widget that prevents easy closing.
274 *
275 * Duplicate registration are ignored. See click_dismiss_ for more info.
276 *
277 * @param id The id of the widget to register.
278 */
279 void add_click_dismiss_blocker(const std::string& id);
280
281 /**
282 * Unregister a widget the prevents easy closing.
283 *
284 * Removing a non registered id is allowed but will do nothing. See
285 * click_dismiss_ for more info.
286 *
287 * @param id The id of the widget to register.
288 */
289 void remove_click_dismiss_blocker(const std::string& id);
290#endif
291
292 /**
293 * Does the window close easily?
294 *
295 * The behavior can change at run-time, but that might cause oddities
296 * with the easy close button (when one is needed).
297 *
298 * @returns Whether or not the window closes easily.
299 */
301 {
303 }
304
305 /**
306 * Disable the enter key.
307 *
308 * This is added to block dialogs from being closed automatically.
309 *
310 * @todo this function should be merged with the hotkey support once
311 * that has been added.
312 */
313 void set_enter_disabled(const bool enter_disabled)
314 {
315 enter_disabled_ = enter_disabled;
316 }
317
318 /**
319 * Disable the escape key.
320 *
321 * This is added to block dialogs from being closed automatically.
322 *
323 * @todo this function should be merged with the hotkey support once
324 * that has been added.
325 */
326 void set_escape_disabled(const bool escape_disabled)
327 {
328 escape_disabled_ = escape_disabled;
329 }
330
331 /**
332 * Initializes a linked size group.
333 *
334 * Note at least one of fixed_width or fixed_height must be true.
335 *
336 * @param id The id of the group.
337 * @param fixed_width Does the group have a fixed width?
338 * @param fixed_height Does the group have a fixed height?
339 *
340 * @returns True if successful, false otherwise.
341 */
342 bool init_linked_size_group(const std::string& id,
343 const bool fixed_width,
344 const bool fixed_height);
345
346 /**
347 * Is the linked size group defined for this window?
348 *
349 * @param id The id of the group.
350 *
351 * @returns True if defined, false otherwise.
352 */
353 bool has_linked_size_group(const std::string& id);
354
355 /**
356 * Adds a widget to a linked size group.
357 *
358 * The group needs to exist, which is done by calling
359 * init_linked_size_group. A widget may only be member of one group.
360 * @todo Untested if a new widget is added after showing the widgets.
361 *
362 * @param id The id of the group.
363 * @param widget The widget to add to the group.
364 */
365 void add_linked_widget(const std::string& id, widget* widget);
366
367 /**
368 * Removes a widget from a linked size group.
369 *
370 * The group needs to exist, which is done by calling
371 * init_linked_size_group. If the widget is no member of the group the
372 * function does nothing.
373 *
374 * @param id The id of the group.
375 * @param widget The widget to remove from the group.
376 */
377 void remove_linked_widget(const std::string& id, const widget* widget);
378
379 /***** ***** ***** setters / getters for members ***** ****** *****/
380
381 /**
382 * Sets there return value of the window.
383 *
384 * @param retval The return value for the window.
385 * @param close_window Close the window after setting the value.
386 */
387 void set_retval(const int retval, const bool close_window = true)
388 {
389 retval_ = retval;
390 if(close_window)
391 close();
392 }
393
395 {
396 return retval_;
397 }
398
400 {
402 }
403
404 bool get_need_layout() const
405 {
406 return need_layout_;
407 }
408
409 void set_variable(const std::string& key, const wfl::variant& value)
410 {
411 variables_.add(key, value);
412 queue_redraw();
413 }
414
415 point get_linked_size(std::string_view group_id) const
416 {
417 if(auto it = linked_size_.find(group_id); it != linked_size_.end()) {
418 return { it->second.width, it->second.height };
419 } else {
420 return { -1, -1 };
421 }
422 }
423
424 enum class exit_hook {
425 always,
426 ok_only,
427 };
428
429 /**
430 * Sets the window's exit hook.
431 *
432 * A window will only close if the given function returns true under the specified mode.
433 */
434 template<typename Func>
435 void set_exit_hook(exit_hook mode, const Func& hook)
436 {
437 switch(mode) {
439 exit_hook_ = hook;
440 break;
441
443 exit_hook_ = [this, hook] { return get_retval() != OK || hook(); };
444 break;
445
446 default:
447 break;
448 }
449 }
450
451 enum class show_mode {
452 none,
453 modal,
454 modeless,
455 tooltip
456 };
457
458private:
459 /** The status of the window. */
461
462 /**
463 * The mode in which the window is shown.
464 *
465 * This is used to determine whether or not to remove the tip.
466 */
468
469 // return value of the window, 0 default.
471
472 /**
473 * When set the form needs a full layout redraw cycle.
474 *
475 * This happens when either a widget changes it's size or visibility or
476 * the window is resized.
477 */
479
480 /** The variables of the canvas. */
482
483 /** Is invalidate_layout blocked, see invalidate_layout_blocker. */
485
486 /** Avoid drawing the window. */
488
489 /** Do we wish to place the widget automatically? */
491
492 /**
493 * Sets the horizontal placement.
494 *
495 * Only used if automatic_placement_ is true.
496 * The value should be a grid placement flag.
497 */
498 const unsigned horizontal_placement_;
499
500 /**
501 * Sets the vertical placement.
502 *
503 * Only used if automatic_placement_ is true.
504 * The value should be a grid placement flag.
505 */
506 const unsigned vertical_placement_;
507
508 /** The maximum width if automatic_placement_ is true. */
510
511 /** The maximum height if automatic_placement_ is true. */
513
514 /** The formula to calculate the x value of the dialog. */
516
517 /** The formula to calculate the y value of the dialog. */
519
520 /** The formula to calculate the width of the dialog. */
522
523 /** The formula to calculate the height of the dialog. */
525
526 /** The formula to determine whether the size is good. */
528
529 /** The formula definitions available for the calculation formulas. */
531
532 /** The settings for the tooltip. */
534
535 /** The settings for the helptip. */
537
538 /**
539 * Do we want to have easy close behavior?
540 *
541 * Easy closing means that whenever a mouse click is done the dialog will
542 * be closed. The widgets in the window may override this behavior by
543 * registering themselves as blockers. This is tested by the function
544 * disable_click_dismiss().
545 *
546 * The handling of easy close is done in the window, in order to do so a
547 * window either needs a click_dismiss or an ok button. Both will be hidden
548 * when not needed and when needed first the ok is tried and then the
549 * click_dismiss button. this allows adding a click_dismiss button to the
550 * window definition and use the ok from the window instance.
551 *
552 * @todo After testing the click dismiss feature it should be documented in
553 * the wiki.
554 */
556
557 /** Disable the enter key see our setter for more info. */
559
560 /** Disable the escape key see our setter for more info. */
562
563 /**
564 * Helper struct to force widgets the have the same size.
565 *
566 * Widget which are linked will get the same width and/or height. This
567 * can especially be useful for listboxes, but can also be used for other
568 * applications.
569 */
571 {
572 linked_size(const bool width = false, const bool height = false)
573 : widgets(), width(width ? 0 : -1), height(height ? 0 : -1)
574 {
575 }
576
577 /** The widgets linked. */
578 std::vector<widget*> widgets;
579
580 /** The current width of all widgets in the group, -1 if the width is not linked. */
581 int width;
582
583 /** The current height of all widgets in the group, -1 if the height is not linked. */
585 };
586
587 /** List of the widgets, whose size are linked together. */
588 std::map<std::string, linked_size, std::less<>> linked_size_;
589
590 /** List of widgets in the tabbing order. */
591 std::vector<widget*> tab_order;
592
593 /**
594 * Layouts the linked widgets.
595 *
596 * See @ref layout_algorithm for more information.
597 */
599
600 /**
601 * Handles a mouse click event for dismissing the dialog.
602 *
603 * @param mouse_button_mask The SDL_BUTTON mask for the button used to
604 * dismiss the click. If the caller is from the
605 * keyboard code the value should be 0.
606 *
607 * @return Whether the event should be considered as
608 * handled.
609 */
610 bool click_dismiss(const int mouse_button_mask);
611
612 /**
613 * The state of the mouse button.
614 *
615 * When click dismissing a dialog in the past the DOWN event was used.
616 * This lead to a bug [1]. The obvious change was to switch to the UP
617 * event, this lead to another bug; the dialog was directly dismissed.
618 * Since the game map code uses the UP and DOWN event to select a unit
619 * there is no simple solution.
620 *
621 * Upon entry this value stores the mouse button state at entry. When a
622 * button is DOWN and goes UP that button does \em not trigger a dismissal
623 * of the dialog, instead that button's down state is removed from this
624 * variable. Therefore the next UP event does dismiss the dialog.
625 *
626 * [1] https://gna.org/bugs/index.php?18970
627 */
629
630public:
631 /** Static type getter that does not rely on the widget being constructed. */
632 static const std::string& type();
633
634private:
635 /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
636 virtual const std::string& get_control_type() const override;
637
638 /**
639 * Finishes the initialization of the grid.
640 *
641 * @param content_grid The new contents for the content grid.
642 */
643 void finalize(const builder_grid& content_grid);
644
645#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
646 std::unique_ptr<debug_layout_graph> debug_layout_;
647
648public:
649 /** wrapper for debug_layout_graph::generate_dot_file. */
650 void generate_dot_file(const std::string& generator, const unsigned domain);
651
652private:
653#else
654 void generate_dot_file(const std::string&, const unsigned)
655 {
656 }
657#endif
658
659 std::unique_ptr<event::distributor> event_distributor_;
660
661public:
662 /** Gets a reference to the window's distributor to allow some state peeking. */
664 {
665 return *event_distributor_;
666 }
667
668 /** Returns the dialog mode for this window. */
670 {
671 return show_mode_;
672 }
673
674 // mouse and keyboard_capture should be renamed and stored in the
675 // dispatcher. Chaining probably should remain exclusive to windows.
676 void mouse_capture(const bool capture = true);
679
680 /**
681 * Adds the widget to the keyboard chain.
682 *
683 * @todo rename to keyboard_add_to_chain.
684 * @param widget The widget to add to the chain. The widget
685 * should be valid widget, which hasn't been
686 * added to the chain yet.
687 */
689
690 /**
691 * Remove the widget from the keyboard chain.
692 *
693 * @todo rename to keyboard_remove_from_chain.
694 *
695 * @param widget The widget to be removed from the chain.
696 */
698
699 /**
700 * Add the widget to the tabbing order
701 * @param widget The widget to be added to the tabbing order
702 * @param at A hint for where to place the widget in the tabbing order
703 */
704 void add_to_tab_order(widget* widget, int at = -1);
705
706private:
707 /***** ***** ***** signal handlers ***** ****** *****/
708
710 bool& handled,
711 const point& new_size);
712
713 /**
714 * The handler for the click dismiss mouse 'event'.
715 *
716 * @param event See @ref event::dispatcher::fire.
717 * @param handled See @ref event::dispatcher::fire.
718 * @param halt See @ref event::dispatcher::fire.
719 * @param mouse_button_mask Forwared to @ref click_dismiss.
720 */
722 bool& handled,
723 bool& halt,
724 const int mouse_button_mask);
725
727 bool& handled,
728 const SDL_Keycode key,
729 const SDL_Keymod mod,
730 bool handle_tab);
731
733 bool& handled,
734 const event::message& message);
735
737 bool& handled,
738 const event::message& message);
739
741 bool& handled);
742
744
745 std::function<bool()> exit_hook_;
746};
747
748// }---------- DEFINITION ---------{
749
751{
752 explicit window_definition(const config& cfg);
753
755 {
756 explicit resolution(const config& cfg);
757
759 };
760};
761
762// }------------ END --------------
763
764} // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Main class to show messages to the user.
Definition message.hpp:36
At the moment two kinds of tips are known:
Definition tooltip.cpp:41
The event handler class for the widget library.
Basic template class to generate new items.
A pane is a container where new members can be added and removed during run-time.
Definition pane.hpp:41
A top-level drawable item (TLD), such as a window.
Template class can hold a value or a formula to calculate the value.
Base class for all widgets.
Definition widget.hpp:55
void queue_redraw()
Indicates that this widget should be redrawn.
Definition widget.cpp:464
Helper class to block invalidate_layout.
Definition window.hpp:232
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition window.hpp:59
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition window.hpp:313
bool need_layout_
When set the form needs a full layout redraw cycle.
Definition window.hpp:478
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition window.hpp:387
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
void capture_and_show_keyboard(widget *widget)
Definition window.cpp:1205
show_mode mode() const
Returns the dialog mode for this window.
Definition window.hpp:669
const unsigned vertical_placement_
Sets the vertical placement.
Definition window.hpp:506
bool invalidate_layout_blocked_
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition window.hpp:484
typed_formula< bool > reevaluate_best_size_
The formula to determine whether the size is good.
Definition window.hpp:527
typed_formula< unsigned > maximum_width_
The maximum width if automatic_placement_ is true.
Definition window.hpp:509
void remove_from_keyboard_chain(widget *widget)
Remove the widget from the keyboard chain.
Definition window.cpp:1217
void keyboard_capture(widget *widget)
Definition window.cpp:1197
void invalidate_layout()
Updates the size of the window.
Definition window.cpp:759
void add_to_keyboard_chain(widget *widget)
Adds the widget to the keyboard chain.
Definition window.cpp:1211
void signal_handler_message_show_tooltip(const event::ui_event event, bool &handled, const event::message &message)
Definition window.cpp:1339
void mouse_capture(const bool capture=true)
Definition window.cpp:1191
typed_formula< unsigned > maximum_height_
The maximum height if automatic_placement_ is true.
Definition window.hpp:512
virtual rect screen_location() override
The current draw location of the window, on the screen.
Definition window.cpp:738
void update_render_textures()
Ensure render textures are valid and correct.
Definition window.cpp:636
void show_tooltip()
Shows the window as a tooltip.
Definition window.cpp:425
int mouse_button_state_
The state of the mouse button.
Definition window.hpp:628
point get_linked_size(std::string_view group_id) const
Definition window.hpp:415
void hide()
Hides the window.
Definition window.cpp:620
void show_non_modal()
Shows the window non modal.
Definition window.cpp:457
std::unique_ptr< event::distributor > event_distributor_
Definition window.hpp:659
void signal_handler_sdl_video_resize(const event::ui_event event, bool &handled, const point &new_size)
Definition window.cpp:1239
virtual ~window()
Definition window.cpp:373
std::map< std::string, linked_size, std::less<> > linked_size_
List of the widgets, whose size are linked together.
Definition window.hpp:588
static window * window_instance(const unsigned handle)
Returns the instance of a window.
Definition window.cpp:407
void close()
Requests to close the window.
Definition window.hpp:216
status
The status of the window.
Definition window.hpp:203
@ CLOSED
The window has been closed.
@ NEW
The window is new and not yet shown.
@ SHOWING
The window is being shown.
@ REQUEST_CLOSE
The window has been requested to be closed but still needs to evaluate the request.
builder_window::window_resolution::tooltip_info tooltip_
The settings for the tooltip.
Definition window.hpp:533
bool invalidate_layout_blocked() const
Is invalidate_layout blocked, see invalidate_layout_blocker.
Definition window.hpp:242
void signal_handler_sdl_key_down(const event::ui_event event, bool &handled, const SDL_Keycode key, const SDL_Keymod mod, bool handle_tab)
Definition window.cpp:1273
virtual void layout() override
Lays out the window.
Definition window.cpp:829
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void signal_handler_message_show_helptip(const event::ui_event event, bool &handled, const event::message &message)
Definition window.cpp:1353
void layout_linked_widgets()
Layouts the linked widgets.
Definition window.cpp:1028
show_mode show_mode_
The mode in which the window is shown.
Definition window.hpp:467
std::vector< widget * > tab_order
List of widgets in the tabbing order.
Definition window.hpp:591
typed_formula< unsigned > h_
The formula to calculate the height of the dialog.
Definition window.hpp:524
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
Definition window.cpp:776
const event::distributor & get_distributor() const
Gets a reference to the window's distributor to allow some state peeking.
Definition window.hpp:663
int show(unsigned auto_close_timeout=0)
Shows the window, running an event loop until it should close.
Definition window.cpp:491
rect awaiting_rerender_
The part of the window (if any) currently marked for rerender.
Definition window.hpp:163
void signal_handler_request_placement(const event::ui_event event, bool &handled)
Definition window.cpp:1367
friend class debug_layout_graph
Definition window.hpp:60
bool escape_disabled_
Disable the escape key see our setter for more info.
Definition window.hpp:561
bool does_click_dismiss() const
Does the window close easily?
Definition window.hpp:300
void signal_handler_close_window()
Definition window.cpp:1377
bool click_dismiss_
Do we want to have easy close behavior?
Definition window.hpp:555
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition window.hpp:326
void add_linked_widget(const std::string &id, widget *widget)
Adds a widget to a linked size group.
Definition window.cpp:799
void defer_region(const rect &region)
Defer rendering of a particular region to next frame.
Definition window.cpp:684
const unsigned horizontal_placement_
Sets the horizontal placement.
Definition window.hpp:498
void queue_rerender()
Definition window.cpp:670
static retval get_retval_by_id(const std::string &id)
Gets the retval for the default buttons.
Definition window.cpp:412
bool get_need_layout() const
Definition window.hpp:404
void set_click_dismiss(const bool click_dismiss)
Definition window.hpp:399
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Definition window.cpp:1223
const bool automatic_placement_
Do we wish to place the widget automatically?
Definition window.hpp:490
void finalize(const builder_grid &content_grid)
Finishes the initialization of the grid.
Definition window.cpp:1087
void set_exit_hook(exit_hook mode, const Func &hook)
Sets the window's exit hook.
Definition window.hpp:435
int get_retval()
Definition window.hpp:394
builder_window::window_resolution::tooltip_info helptip_
The settings for the helptip.
Definition window.hpp:536
std::function< bool()> exit_hook_
Definition window.hpp:745
std::vector< rect > deferred_regions_
Parts of the window (if any) with rendering deferred to next frame.
Definition window.hpp:166
bool hidden_
Avoid drawing the window.
Definition window.hpp:487
bool click_dismiss(const int mouse_button_mask)
Handles a mouse click event for dismissing the dialog.
Definition window.cpp:1074
typed_formula< unsigned > x_
The formula to calculate the x value of the dialog.
Definition window.hpp:515
typed_formula< unsigned > y_
The formula to calculate the y value of the dialog.
Definition window.hpp:518
void set_variable(const std::string &key, const wfl::variant &value)
Definition window.hpp:409
void generate_dot_file(const std::string &, const unsigned)
Definition window.hpp:654
virtual bool expose(const rect &region) override
Called by draw_manager when it believes a redraw is necessary.
Definition window.cpp:717
wfl::map_formula_callable variables_
The variables of the canvas.
Definition window.hpp:481
void remove_linked_widget(const std::string &id, const widget *widget)
Removes a widget from a linked size group.
Definition window.cpp:813
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'.
Definition window.cpp:1254
bool enter_disabled_
Disable the enter key see our setter for more info.
Definition window.hpp:558
virtual void render() override
Ensure the window's internal render buffer is up-to-date.
Definition window.cpp:690
bool init_linked_size_group(const std::string &id, const bool fixed_width, const bool fixed_height)
Initializes a linked size group.
Definition window.cpp:787
void draw()
Draws the window.
Definition window.cpp:593
typed_formula< unsigned > w_
The formula to calculate the width of the dialog.
Definition window.hpp:521
wfl::function_symbol_table functions_
The formula definitions available for the calculation formulas.
Definition window.hpp:530
status status_
The status of the window.
Definition window.hpp:460
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
Definition window.cpp:765
texture render_buffer_
The internal render buffer used by render() and expose().
Definition window.hpp:160
bool has_linked_size_group(const std::string &id)
Is the linked size group defined for this window?
Definition window.cpp:794
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition texture.hpp:33
map_formula_callable & add(const std::string &key, const variant &value)
Definition callable.hpp:249
const config * cfg
ui_event
The event sent to the dispatcher.
Definition handler.hpp:115
Generic file dialog.
std::shared_ptr< builder_grid > builder_grid_ptr
retval
Default window/dialog return values.
Definition retval.hpp:30
@ OK
Dialog was closed with the OK button.
Definition retval.hpp:35
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
Definition sound.cpp:139
Helper struct to store information about the tips.
The message callbacks hold a reference to a message.
Definition message.hpp:46
Helper struct to force widgets the have the same size.
Definition window.hpp:571
int height
The current height of all widgets in the group, -1 if the height is not linked.
Definition window.hpp:584
linked_size(const bool width=false, const bool height=false)
Definition window.hpp:572
int width
The current width of all widgets in the group, -1 if the width is not linked.
Definition window.hpp:581
std::vector< widget * > widgets
The widgets linked.
Definition window.hpp:578
Helper to implement private functions without modifying the header.
Holds a 2D point.
Definition point.hpp:25
An abstract description of a rectangle with integer coordinates.
Definition rect.hpp:49