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"
17#include "../geometry/axis_aligned_rectangle.hpp"
18#include "../widgets/window_widget.hpp"
19#include "../widgets/grid_widget.hpp"
20#include "../widgets/toolbar_widget.hpp"
21#include "../chrono.hpp"
22#include "../label.hpp"
23#include "../animator.hpp"
24#include <unordered_set>
28namespace hi::inline v1 {
33class keyboard_bindings;
66 mouse_cursor current_mouse_cursor = mouse_cursor::None;
72 bool resizing =
false;
136 _redraw_rectangle |= redraw_rectangle;
143 hi_axiom(is_gui_thread());
147 void request_relayout() noexcept
149 _relayout.store(
true, std::memory_order::relaxed);
152 void request_reconstrain() noexcept
154 _reconstrain.store(
true, std::memory_order::relaxed);
157 void request_resize() noexcept
159 _resize.store(
true, std::memory_order::relaxed);
165 virtual void render(utc_nanoseconds displayTimePoint);
173 hi_axiom(is_gui_thread());
184 hi_axiom(is_gui_thread());
193 void set_resize_border_priority(
bool left,
bool right,
bool bottom,
bool top)
noexcept;
218 gui_window_size size_state() const noexcept
239 virtual
void set_text_on_clipboard(
std::
string str) noexcept = 0;
241 void update_mouse_target(hi::
widget const *new_target_widget,
point2 position = {})
noexcept;
271 [[nodiscard]]
translate2 window_to_screen() const noexcept
276 [[nodiscard]]
translate2 screen_to_window() const noexcept
278 return ~window_to_screen();
293 gui_window_size _size_state = gui_window_size::normal;
297 aarectangle _restore_rectangle;
306 utc_nanoseconds last_forced_redraw = {};
310 animator<float> _animated_active = _animation_duration;
315 virtual void create_window(extent2 new_size) = 0;
320 [[nodiscard]]
virtual bool handle_event(hi::command command)
noexcept;
324 for (
hilet command : commands) {
325 if (handle_event(command)) {
335 [[nodiscard]]
virtual bool handle_event(mouse_event
const &event)
noexcept
343 [[nodiscard]]
virtual bool handle_event(keyboard_event
const &event)
noexcept
353 bool send_event(mouse_event
const &event)
noexcept;
359 bool send_event(keyboard_event
const &event)
noexcept;
361 bool send_event(KeyboardState _state, keyboard_modifiers modifiers, keyboard_virtual_key key)
noexcept;
363 bool send_event(grapheme grapheme,
bool full =
true) noexcept;
366 notifier<>::token_type _setting_change_token;
367 observable<
std::
string>::token_type _selected_theme_token;
373 hi::widget const *_mouse_target_widget =
nullptr;
378 hi::widget const *_keyboard_target_widget =
nullptr;
384 void widget_is_destructing(hi::widget const *sender) noexcept
386 if (_mouse_target_widget == sender) {
387 _mouse_target_widget =
nullptr;
389 if (_keyboard_target_widget == sender) {
390 _keyboard_target_widget =
nullptr;
402 template<
typename Event>
403 bool send_event_to_widget(hi::widget
const *target_widget, Event
const &event)
noexcept;
subpixel_orientation
The orientation of the RGB sub-pixels of and LCD/LED panel.
Definition subpixel_orientation.hpp:18
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
A rectangle / parallelogram in 3D space.
Definition rectangle.hpp:20
constexpr extent2 size() const noexcept
The size, or length of the right and up vectors.
Definition rectangle.hpp:154
Definition translate.hpp:15
Definition gfx_device.hpp:22
Graphics system.
Definition gui_system.hpp:30
Definition gui_window.hpp:40
void update_keyboard_target(hi::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.
virtual void open_system_menu()=0
Open the system menu of the 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.
void update_keyboard_target(hi::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.
toolbar_widget & toolbar() noexcept
Get a reference to window's toolbar widget.
Definition gui_window.hpp:182
grid_widget & content() noexcept
Get a reference to the window's content widget.
Definition gui_window.hpp:171
virtual void set_size_state(gui_window_size state) noexcept=0
Set the size-state of the window.
aarectangle rectangle
The current rectangle of the window relative to the screen.
Definition gui_window.hpp:57
extent2 widget_size
The size of the widget.
Definition gui_window.hpp:94
bool is_gui_thread() const noexcept
Check if the current thread is the same as the gui_system loop.
virtual void render(utc_nanoseconds displayTimePoint)
Update window.
std::unique_ptr< window_widget > widget
The widget covering the complete window.
Definition gui_window.hpp:98
virtual void init()
2 phase constructor.
notifier< void()> closing
Notifier used when the window is closing.
Definition gui_window.hpp:103
virtual void close_window()=0
Ask the operating system to close this window.
void request_redraw() noexcept
Request a rectangle on the window to be redrawn.
Definition gui_window.hpp:141
virtual void set_window_size(extent2 extent)=0
Ask the operating system to set the size of this window.
virtual std::string get_text_from_clipboard() const noexcept=0
Retrieve a text string from the operating system's clip-board.
virtual aarectangle workspace_rectangle() const noexcept=0
The rectangle of the workspace of the screen where the window is currently located.
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 notifier which can be used to call a set of registered callbacks.
Definition notifier.hpp:23
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:40