7#include "gui_window_state.hpp"
8#include "gui_window_size.hpp"
9#include "gui_window_delegate.hpp"
10#include "gui_system_globals.hpp"
11#include "mouse_cursor.hpp"
13#include "mouse_event.hpp"
14#include "keyboard_event.hpp"
15#include "subpixel_orientation.hpp"
16#include "keyboard_focus_direction.hpp"
17#include "keyboard_focus_group.hpp"
18#include "../text/gstring.hpp"
19#include "../logger.hpp"
20#include "../geometry/axis_aligned_rectangle.hpp"
21#include "../cpu_utc_clock.hpp"
22#include "../label.hpp"
23#include <unordered_set>
41 gui_window_state state = gui_window_state::no_device;
84 subpixel_orientation subpixel_orientation = subpixel_orientation::BlueRight;
132 return dpi / (window_scale() * 72.0f);
165 template<
typename T,
typename... Args>
171 template<
typename T,
typename... Args>
177 template<
typename T, horizontal_alignment Alignment = horizontal_alignment::left,
typename... Args>
184 void set_resize_border_priority(
bool left,
bool right,
bool bottom,
bool top)
noexcept;
214 void update_mouse_target(
std::shared_ptr<tt::
widget> new_target_widget,
point2 position = {})
noexcept;
224 keyboard_focus_group group = keyboard_focus_group::normal)
noexcept;
236 keyboard_focus_group group,
237 keyboard_focus_direction direction)
noexcept;
245 [[nodiscard]]
translate2 window_to_screen() const noexcept
247 return translate2{_screen_rectangle.left(), _screen_rectangle.bottom()};
250 [[nodiscard]]
translate2 screen_to_window() const noexcept
252 return ~window_to_screen();
260 gui_device *_device =
nullptr;
273 aarectangle _screen_rectangle;
275 bool _request_setting_change =
true;
277 aarectangle _request_redraw_rectangle = aarectangle{};
283 virtual void create_window(
const std::u8string &title, extent2
extent) = 0;
289 [[nodiscard]]
float window_scale() const noexcept;
293 virtual
void window_changed_size(extent2 new_extent);
297 virtual
void teardown() = 0;
301 virtual
void build() = 0;
306 [[nodiscard]] virtual
bool handle_event(tt::command command) noexcept;
308 [[nodiscard]] virtual
bool handle_event(
std::vector<tt::command> const &commands) noexcept
310 for (ttlet command : commands) {
311 if (handle_event(command)) {
321 [[nodiscard]]
virtual bool handle_event(mouse_event
const &event)
noexcept
329 [[nodiscard]]
virtual bool handle_event(keyboard_event
const &event)
noexcept
339 bool send_event(mouse_event
const &event)
noexcept;
345 bool send_event(keyboard_event
const &event)
noexcept;
347 bool send_event(KeyboardState _state, keyboard_modifiers modifiers, keyboard_virtual_key key)
noexcept;
349 bool send_event(grapheme grapheme,
bool full =
true) noexcept;
351 bool send_event(
char32_t c,
bool full = true) noexcept;
358 std::weak_ptr<tt::
widget> _mouse_target_widget = {};
373 template<
typename Event>
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:18
Class which represents an rectangle.
Definition rectangle.hpp:16
Definition gui_device.hpp:22
Vulkan gui_device controller.
Definition gui_system.hpp:24
Definition gui_window.hpp:37
std::atomic< bool > active
Definition gui_window.hpp:69
mouse_cursor currentmouse_cursor
The current cursor.
Definition gui_window.hpp:50
gui_window_size size_state
Definition gui_window.hpp:73
virtual void set_text_on_clipboard(std::string str) noexcept=0
Place a text string on the operating system's clip-board.
virtual void set_window_size(extent2 extent)=0
Ask the operating system to set the size of this window.
virtual void close_window()=0
Ask the operating system to close this window.
std::shared_ptr< T > make_toolbar_widget(Args &&...args)
Add a widget to main widget of the window.
Definition widgets.hpp:56
void set_device(gui_device *device)
virtual void init()
2 phase constructor.
std::atomic< bool > requestResize
When set to true the window will resize to the size of the contained widget.
Definition gui_window.hpp:58
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 layed out.
Definition gui_window.hpp:54
extent2 extent
The current window extent as set by the GPU library.
Definition gui_window.hpp:76
bool is_closed()
Check if the window was closed by the operating system.
void update_keyboard_target(std::shared_ptr< tt::widget > const &widget, keyboard_focus_group group, keyboard_focus_direction direction) noexcept
Change the keyboard focus to the given, previous or next widget.
std::atomic< bool > resizing
Definition gui_window.hpp:64
void unset_device()
Definition gui_window.hpp:142
std::shared_ptr< window_widget > widget
The widget covering the complete window.
Definition gui_window.hpp:93
virtual void set_cursor(mouse_cursor cursor)=0
Set the mouse cursor icon.
virtual void minimize_window()=0
Ask the operating system to minimize this window.
void update_keyboard_target(std::shared_ptr< tt::widget > widget, keyboard_focus_group group=keyboard_focus_group::normal) noexcept
Change the keyboard focus to the given widget.
virtual std::string get_text_from_clipboard() const noexcept=0
Retrieve a text string from the operating system's clip-board.
std::shared_ptr< T > make_widget(size_t column_nr, size_t row_nr, Args &&...args)
Add a widget to main widget of the window.
Definition widgets.hpp:35
virtual void render(hires_utc_clock::time_point displayTimePoint)=0
Update window.
virtual extent2 virtual_screen_size() const noexcept=0
Get the size of the virtual-screen.
void request_redraw() noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:121
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:130
void request_redraw(aarectangle rectangle) noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:113
float dpi
Definition gui_window.hpp:90
A localized text + icon label.
Definition label.hpp:76
int recurse_lock_count() const noexcept
This function should be used in tt_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60