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"
15#include "../text/gstring.hpp"
16#include "../geometry/axis_aligned_rectangle.hpp"
17#include "../hires_utc_clock.hpp"
18#include "../label.hpp"
19#include "../widgets/window_widget.hpp"
20#include "../widgets/grid_widget.hpp"
21#include "../widgets/toolbar_widget.hpp"
22#include <unordered_set>
126 tt_axiom(is_gui_thread());
135 return dpi / (window_scale() * 72.0f);
153 tt_axiom(is_gui_thread());
164 tt_axiom(is_gui_thread());
173 void set_resize_border_priority(
bool left,
bool right,
bool bottom,
bool top)
noexcept;
203 void update_mouse_target(tt::
widget const *new_target_widget,
point2 position = {})
noexcept;
239 [[nodiscard]]
translate2 window_to_screen() const noexcept
241 return translate2{_screen_rectangle.left(), _screen_rectangle.bottom()};
244 [[nodiscard]]
translate2 screen_to_window() const noexcept
246 return ~window_to_screen();
263 aarectangle _screen_rectangle;
276 hires_utc_clock::time_point last_forced_redraw = {};
281 virtual void create_window() = 0;
287 [[nodiscard]]
float window_scale() const noexcept;
292 [[nodiscard]] virtual
bool handle_event(tt::command command) noexcept;
294 [[nodiscard]] virtual
bool handle_event(
std::vector<tt::command> const &commands) noexcept
296 for (ttlet command : commands) {
297 if (handle_event(command)) {
307 [[nodiscard]]
virtual bool handle_event(mouse_event
const &event)
noexcept
315 [[nodiscard]]
virtual bool handle_event(keyboard_event
const &event)
noexcept
325 bool send_event(mouse_event
const &event)
noexcept;
331 bool send_event(keyboard_event
const &event)
noexcept;
333 bool send_event(KeyboardState _state, keyboard_modifiers modifiers, keyboard_virtual_key key)
noexcept;
335 bool send_event(grapheme grapheme,
bool full =
true) noexcept;
337 bool send_event(
char32_t c,
bool full = true) noexcept;
340 std::shared_ptr<
std::function<
void()>> _setting_change_callback;
346 tt::
widget const *_mouse_target_widget =
nullptr;
351 tt::
widget const *_keyboard_target_widget =
nullptr;
357 void widget_is_destructing(tt::
widget const *sender) noexcept
359 if (_mouse_target_widget == sender) {
360 _mouse_target_widget =
nullptr;
362 if (_keyboard_target_widget == sender) {
363 _keyboard_target_widget =
nullptr;
375 template<
typename Event>
376 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
Class which represents an rectangle.
Definition rectangle.hpp:16
Definition gfx_device.hpp:22
Definition gui_window.hpp:36
mouse_cursor currentmouse_cursor
The current cursor.
Definition gui_window.hpp:49
gui_window_size size_state
Definition gui_window.hpp:72
virtual void set_text_on_clipboard(std::string str) noexcept=0
Place a text string on the operating system's clip-board.
extent2 size
The size from the surface, clamped to combined widget's size.
Definition gui_window.hpp:76
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.
bool resizing
Definition gui_window.hpp:63
virtual void init()
2 phase constructor.
toolbar_widget & toolbar() noexcept
Get a reference to window's toolbar widget.
Definition gui_window.hpp:162
std::atomic< bool > requestResize
When set to true the window will resize to the size of the contained widget.
Definition gui_window.hpp:57
virtual void maximize_window()=0
Ask the operating system to maximize this window.
std::atomic< bool > requestLayout
When set to true the widgets will be laid out.
Definition gui_window.hpp:53
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:87
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:68
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:151
bool is_closed() const noexcept
Check if the window was closed by the operating system.
void request_redraw() noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:124
virtual void normalize_window()=0
Ask the operating system to normalize this window.
virtual void render(hires_utc_clock::time_point displayTimePoint)
Update window.
float fontScale() const noexcept
By how much the font needs to be scaled compared to current windowScale.
Definition gui_window.hpp:133
void request_redraw(aarectangle rectangle) noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:117
float dpi
Definition gui_window.hpp:84
Definition gui_window_delegate.hpp:12
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:39