45 namespace event {
struct message; }
49 namespace dialogs {
class modal_dialog; }
97 int show(
unsigned auto_close_timeout = 0);
152 virtual void layout()
override;
159 virtual void render()
override;
179 virtual bool expose(
const rect& region)
override;
261 const bool must_be_active)
override;
265 const bool must_be_active)
const override;
274 widget*
find(
const std::string_view
id,
const bool must_be_active)
override;
277 const widget*
find(
const std::string_view
id,
const bool must_be_active)
const override;
288 void add_click_dismiss_blocker(
const std::string&
id);
298 void remove_click_dismiss_blocker(
const std::string&
id);
350 const bool fixed_width,
351 const bool fixed_height);
428 std::map<std::string, linked_size>::const_iterator it =
linked_size_.find(linked_group_id);
430 return point(it->second.width, it->second.height);
433 return point(-1, -1);
455 return w.get_retval() !=
OK || func(
w);
646 static const std::string&
type();
669 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
670 std::unique_ptr<debug_layout_graph> debug_layout_;
734 const point& new_size);
747 const int mouse_button_mask);
751 const SDL_Keycode key,
752 const SDL_Keymod mod,
A config object defines a single node in a WML file, with access to child nodes.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Main class to show messages to the user.
Abstract base class for all modal dialogs.
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.
A top-level drawable item (TLD), such as a window.
Helper class to block invalidate_layout.
invalidate_layout_blocker(window &window)
~invalidate_layout_blocker()
base class of top level items, the only item which needs to store the final canvases to draw on.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
bool need_layout_
When set the form needs a full layout redraw cycle.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
std::function< bool(window &)> exit_hook_
show_mode mode() const
Returns the dialog mode for this window.
const unsigned vertical_placement_
Sets the vertical placement.
bool invalidate_layout_blocked_
Is invalidate_layout blocked, see invalidate_layout_blocker.
typed_formula< bool > reevaluate_best_size_
The formula to determine whether the size is good.
typed_formula< unsigned > maximum_width_
The maximum width if automatic_placement_ is true.
void remove_from_keyboard_chain(widget *widget)
Remove the widget from the keyboard chain.
void keyboard_capture(widget *widget)
void invalidate_layout()
Updates the size of the window.
void add_to_keyboard_chain(widget *widget)
Adds the widget to the keyboard chain.
void signal_handler_message_show_tooltip(const event::ui_event event, bool &handled, const event::message &message)
void mouse_capture(const bool capture=true)
typed_formula< unsigned > maximum_height_
The maximum height if automatic_placement_ is true.
virtual rect screen_location() override
The current draw location of the window, on the screen.
void update_render_textures()
Ensure render textures are valid and correct.
void show_tooltip()
Shows the window as a tooltip.
int mouse_button_state_
The state of the mouse button.
void hide()
Hides the window.
void show_non_modal()
Shows the window non modal.
std::unique_ptr< event::distributor > event_distributor_
void signal_handler_sdl_video_resize(const event::ui_event event, bool &handled, const point &new_size)
void set_exit_hook(exit_hook mode, std::function< bool(window &)> func)
Sets the window's exit hook.
unsigned int consecutive_changed_frames_
In how many consecutive frames the window has changed.
static window * window_instance(const unsigned handle)
Returns the instance of a window.
void close()
Requests to close the window.
status
The status of the window.
@ 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.
bool invalidate_layout_blocked() const
Is invalidate_layout blocked, see invalidate_layout_blocker.
void signal_handler_sdl_key_down(const event::ui_event event, bool &handled, const SDL_Keycode key, const SDL_Keymod mod, bool handle_tab)
virtual void layout() override
Lays out the window.
void signal_handler_message_show_helptip(const event::ui_event event, bool &handled, const event::message &message)
dialogs::modal_dialog * dialog()
Inherited from widget.
void layout_linked_widgets()
Layouts the linked widgets.
show_mode show_mode_
The mode in which the window is shown.
std::vector< widget * > tab_order
List of widgets in the tabbing order.
typed_formula< unsigned > h_
The formula to calculate the height of the dialog.
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
int show(unsigned auto_close_timeout=0)
Shows the window, running an event loop until it should close.
rect awaiting_rerender_
The part of the window (if any) currently marked for rerender.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void signal_handler_request_placement(const event::ui_event event, bool &handled)
friend class debug_layout_graph
bool escape_disabled_
Disable the escape key see our setter for more info.
bool does_click_dismiss() const
Does the window close easily?
void signal_handler_close_window()
bool click_dismiss_
Do we want to have easy close behavior?
void redraw_windows_on_top() const
Schedules windows on top of us (if any) to redraw.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
void add_linked_widget(const std::string &id, widget *widget)
Adds a widget to a linked size group.
void defer_region(const rect ®ion)
Defer rendering of a particular region to next frame.
const unsigned horizontal_placement_
Sets the horizontal placement.
static retval get_retval_by_id(const std::string &id)
Gets the retval for the default buttons.
bool get_need_layout() const
void set_click_dismiss(const bool click_dismiss)
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
const bool automatic_placement_
Do we wish to place the widget automatically?
void finalize(const builder_grid &content_grid)
Finishes the initialization of the grid.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
builder_window::window_resolution::tooltip_info helptip_
The settings for the helptip.
std::vector< rect > deferred_regions_
Parts of the window (if any) with rendering deferred to next frame.
bool hidden_
Avoid drawing the window.
bool click_dismiss(const int mouse_button_mask)
Handles a mouse click event for dismissing the dialog.
typed_formula< unsigned > x_
The formula to calculate the x value of the dialog.
typed_formula< unsigned > y_
The formula to calculate the y value of the dialog.
void set_variable(const std::string &key, const wfl::variant &value)
point get_linked_size(const std::string &linked_group_id) const
void generate_dot_file(const std::string &, const unsigned)
virtual bool expose(const rect ®ion) override
Called by draw_manager when it believes a redraw is necessary.
wfl::map_formula_callable variables_
The variables of the canvas.
void remove_linked_widget(const std::string &id, const widget *widget)
Removes a widget from a linked size group.
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'.
const event::distributor & get_distributor() const
Gets a reference to the window's distributor to allow some state peeking.
bool enter_disabled_
Disable the enter key see our setter for more info.
virtual void render() override
Ensure the window's internal render buffer is up-to-date.
@ on_ok
Run hook only if result is OK.
dialogs::modal_dialog * owner_
The dialog that owns the window.
void init_linked_size_group(const std::string &id, const bool fixed_width, const bool fixed_height)
Initializes a linked size group.
void draw()
Draws the window.
typed_formula< unsigned > w_
The formula to calculate the width of the dialog.
wfl::function_symbol_table functions_
The formula definitions available for the calculation formulas.
void set_owner(dialogs::modal_dialog *owner)
status status_
The status of the window.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
std::map< std::string, linked_size > linked_size_
List of the widgets, whose size are linked together.
texture render_buffer_
The internal render buffer used by render() and expose().
bool has_linked_size_group(const std::string &id)
Is the linked size group defined for this window?
friend std::unique_ptr< window > build(const builder_window::window_resolution &)
Wrapper class to encapsulate creation and management of an SDL_Texture.
Various uncategorised dialogs.
void point(int x, int y)
Draw a single point.
ui_event
The event sent to the dispatcher.
std::shared_ptr< builder_grid > builder_grid_ptr
retval
Default window/dialog return values.
@ OK
Dialog was closed with the OK button.
std::shared_ptr< halo_record > handle
static std::string at(const std::string &file, int line)
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
The message callbacks hold a reference to a message.
Helper struct to force widgets the have the same size.
int height
The current height of all widgets in the group, -1 if the height is not linked.
linked_size(const bool width=false, const bool height=false)
int width
The current width of all widgets in the group, -1 if the width is not linked.
std::vector< widget * > widgets
The widgets linked.
resolution(const config &cfg)
window_definition(const config &cfg)
Helper to implement private functions without modifying the header.
An abstract description of a rectangle with integer coordinates.