7#include "gui_window_size.hpp"
8#include "gui_window_delegate.hpp"
9#include "mouse_cursor.hpp"
11#include "mouse_event.hpp"
12#include "keyboard_event.hpp"
13#include "keyboard_focus_direction.hpp"
14#include "keyboard_focus_group.hpp"
16#include "../text/gstring.hpp"
17#include "../geometry/axis_aligned_rectangle.hpp"
18#include "../chrono.hpp"
19#include "../label.hpp"
20#include "../widgets/window_widget.hpp"
21#include "../widgets/grid_widget.hpp"
22#include "../widgets/toolbar_widget.hpp"
23#include <unordered_set>
32class keyboard_bindings;
159 return dpi / (window_scale() * 72.0f);
165 virtual void render(utc_nanoseconds displayTimePoint);
197 void set_resize_border_priority(
bool left,
bool right,
bool bottom,
bool top)
noexcept;
227 void update_mouse_target(tt::
widget const *new_target_widget,
point2 position = {})
noexcept;
263 [[nodiscard]]
translate2 window_to_screen() const noexcept
268 [[nodiscard]]
translate2 screen_to_window() const noexcept
270 return ~window_to_screen();
285 utc_nanoseconds last_forced_redraw = {};
290 virtual void create_window(extent2 new_size) = 0;
296 [[nodiscard]]
float window_scale() const noexcept;
301 [[nodiscard]] virtual
bool handle_event(tt::command command) noexcept;
303 [[nodiscard]] virtual
bool handle_event(
std::vector<tt::command> const &commands) noexcept
305 for (ttlet command : commands) {
306 if (handle_event(command)) {
316 [[nodiscard]]
virtual bool handle_event(mouse_event
const &event)
noexcept
324 [[nodiscard]]
virtual bool handle_event(keyboard_event
const &event)
noexcept
334 bool send_event(mouse_event
const &event)
noexcept;
340 bool send_event(keyboard_event
const &event)
noexcept;
342 bool send_event(KeyboardState _state, keyboard_modifiers modifiers, keyboard_virtual_key key)
noexcept;
344 bool send_event(grapheme grapheme,
bool full =
true) noexcept;
346 bool send_event(
char32_t c,
bool full = true) noexcept;
349 std::shared_ptr<
std::function<
void()>> _setting_change_callback;
355 tt::
widget const *_mouse_target_widget =
nullptr;
360 tt::
widget const *_keyboard_target_widget =
nullptr;
366 void widget_is_destructing(tt::
widget const *sender) noexcept
368 if (_mouse_target_widget == sender) {
369 _mouse_target_widget =
nullptr;
371 if (_keyboard_target_widget == sender) {
372 _keyboard_target_widget =
nullptr;
384 template<
typename Event>
385 bool send_event_to_widget(
tt::widget const *target_widget, Event
const &event)
noexcept;
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
extent2 size() const noexcept
Get size of the rectangle.
Definition axis_aligned_rectangle.hpp:159
Class which represents an rectangle.
Definition rectangle.hpp:16
Definition gfx_device.hpp:22
Graphics system.
Definition gui_system.hpp:29
Definition gui_window.hpp:39
mouse_cursor currentmouse_cursor
The current cursor.
Definition gui_window.hpp:65
gui_window_size size_state
Definition gui_window.hpp:92
virtual void set_text_on_clipboard(std::string str) noexcept=0
Place a text string on the operating system's clip-board.
std::atomic< bool > request_resize
When set to true the window will resize to the preferred size of the contained widget.
Definition gui_window.hpp:73
virtual void set_window_size(extent2 extent)=0
Ask the operating system to set the size of this window.
void update_keyboard_target(keyboard_focus_group group, keyboard_focus_direction direction) noexcept
Change the keyboard focus to the given, previous or next widget.
virtual void close_window()=0
Ask the operating system to close this window.
std::atomic< bool > request_constrain
When set to true the widget will calculate their constraints.
Definition gui_window.hpp:69
bool resizing
Definition gui_window.hpp:83
virtual void init()
2 phase constructor.
toolbar_widget & toolbar() noexcept
Get a reference to window's toolbar widget.
Definition gui_window.hpp:186
virtual void maximize_window()=0
Ask the operating system to maximize this window.
bool is_gui_thread() const noexcept
Check if the current thread is the same as the gui_system loop.
std::atomic< bool > request_layout
When set to true the widgets will be laid out.
Definition gui_window.hpp:77
void update_keyboard_target(tt::widget const *widget, keyboard_focus_group group=keyboard_focus_group::normal) noexcept
Change the keyboard focus to the given widget.
virtual void set_cursor(mouse_cursor cursor)=0
Set the mouse cursor icon.
std::unique_ptr< window_widget > widget
The widget covering the complete window.
Definition gui_window.hpp:103
virtual void minimize_window()=0
Ask the operating system to minimize this window.
void update_keyboard_target(tt::widget const *widget, keyboard_focus_group group, keyboard_focus_direction direction) noexcept
Change the keyboard focus to the previous or next widget from the given widget.
virtual std::string get_text_from_clipboard() const noexcept=0
Retrieve a text string from the operating system's clip-board.
virtual void deinit()
2 phase constructor.
bool active
Definition gui_window.hpp:88
virtual extent2 virtual_screen_size() const noexcept=0
Get the size of the virtual-screen.
grid_widget & content() noexcept
Get a reference to the window's content widget.
Definition gui_window.hpp:175
bool is_closed() const noexcept
Check if the window was closed by the operating system.
virtual void render(utc_nanoseconds displayTimePoint)
Update window.
void request_redraw() noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:148
aarectangle screen_rectangle
The current rectangle of the window relative to the screen.
Definition gui_window.hpp:56
virtual void normalize_window()=0
Ask the operating system to normalize this window.
float fontScale() const noexcept
By how much the font needs to be scaled compared to current windowScale.
Definition gui_window.hpp:157
float dpi
Definition gui_window.hpp:100
Definition gui_window_delegate.hpp:12
Definition keyboard_bindings.hpp:17
A label consisting of localizable text and an icon.
Definition label.hpp:27
A GUI widget that lays out child-widgets in a grid with variable sized cells.
Definition grid_widget.hpp:37
A toolbar widget is located at the top of a window and lays out its children horizontally.
Definition toolbar_widget.hpp:28
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37