6#include "TTauri/GUI/globals.hpp"
7#include "TTauri/GUI/WindowDelegate.hpp"
8#include "TTauri/GUI/GUIDevice_forward.hpp"
9#include "TTauri/GUI/Cursor.hpp"
10#include "TTauri/GUI/HitBox.hpp"
11#include "TTauri/GUI/MouseEvent.hpp"
12#include "TTauri/GUI/KeyboardEvent.hpp"
13#include "TTauri/GUI/SubpixelOrientation.hpp"
14#include "TTauri/Cells/Label.hpp"
15#include "TTauri/Text/gstring.hpp"
16#include "TTauri/Foundation/logger.hpp"
17#include "TTauri/Foundation/vec.hpp"
18#include "TTauri/Foundation/aarect.hpp"
19#include "TTauri/Foundation/ivec.hpp"
20#include "TTauri/Foundation/iaarect.hpp"
21#include "TTauri/Foundation/Trigger.hpp"
22#include "TTauri/Foundation/cpu_utc_clock.hpp"
23#include "TTauri/Foundation/fast_mutex.hpp"
24#include <rhea/simplex_solver.hpp>
25#include <unordered_set>
126 return dpi / (windowScale() * 72.0f);
162 virtual void initialize();
190 template<
typename T,
typename... Args>
193 rhea::constraint addConstraint(rhea::constraint
const& constraint)
noexcept;
195 rhea::constraint addConstraint(
196 rhea::linear_equation
const& equation,
197 rhea::strength
const &strength = rhea::strength::required(),
201 rhea::constraint addConstraint(
202 rhea::linear_inequality const& equation,
203 rhea::strength const &strength = rhea::strength::required(),
207 void removeConstraint(rhea::constraint const& constraint) noexcept;
209 rhea::constraint replaceConstraint(
210 rhea::constraint const &oldConstraint,
211 rhea::constraint const &newConstraint
214 rhea::constraint replaceConstraint(
215 rhea::constraint const &oldConstraint,
216 rhea::linear_equation const &newEquation,
217 rhea::strength const &strength = rhea::strength::required(),
221 rhea::constraint replaceConstraint(
222 rhea::constraint const &oldConstraint,
223 rhea::linear_inequality const &newEquation,
224 rhea::strength const &strength = rhea::strength::required(),
228 virtual
void setCursor(Cursor cursor) = 0;
230 virtual
void closeWindow() = 0;
232 virtual
void minimizeWindow() = 0;
233 virtual
void maximizeWindow() = 0;
234 virtual
void normalizeWindow() = 0;
235 virtual
void setWindowSize(
ivec extent) = 0;
237 [[nodiscard]] virtual
std::
string getTextFromClipboard() const noexcept = 0;
238 virtual
void setTextOnClipboard(
std::
string str) noexcept = 0;
240 void updateToNextKeyboardTarget(
Widget *currentTargetWidget) noexcept;
242 void updateToPrevKeyboardTarget(
Widget *currentTargetWidget) noexcept;
258 [[nodiscard]]
float windowScale() const noexcept;
262 virtual
void windowChangedSize(
ivec extent);
266 virtual
void openingWindow();
270 virtual
void closingWindow();
274 virtual
void teardown() = 0;
278 virtual
void build() = 0;
280 void updateMouseTarget(
Widget const *newTargetWidget,
vec position=
vec{0.0f, 0.0f})
noexcept;
282 void updateKeyboardTarget(
Widget const *newTargetWidget)
noexcept;
289 void handleMouseEvent(
MouseEvent event)
noexcept;
295 void handleKeyboardEvent(
KeyboardEvent const &event)
noexcept;
297 void handleKeyboardEvent(KeyboardState _state, KeyboardModifiers modifiers, KeyboardVirtualKey key)
noexcept;
299 void handleKeyboardEvent(
Grapheme grapheme,
bool full=
true) noexcept;
301 void handleKeyboardEvent(
char32_t c,
bool full=true) noexcept;
305 HitBox hitBoxTest(
vec position) const noexcept;
309 rhea::simplex_solver widgetSolver;
314 bool constraintsUpdated = false;
317 rhea::constraint currentWindowExtentWidthConstraint;
320 rhea::constraint currentWindowExtentHeightConstraint;
329 vec suggestWidgetExtent(
vec extent) noexcept;
334 [[nodiscard]]
std::pair<
vec,
vec> getMinimumAndMaximumWidgetExtent() noexcept;
338 void layoutWindow() noexcept;
Definition fast_mutex.hpp:14
Class which represents an axis-aligned rectangle.
Definition iaarect.hpp:12
A 4D vector.
Definition ivec.hpp:37
A 4D vector.
Definition vec.hpp:37
Definition GUIDevice_vulkan.hpp:22
Definition KeyboardEvent.hpp:37
Definition MouseEvent.hpp:12
Definition Window_base.hpp:37
void setDevice(GUIDevice *device)
std::atomic< bool > forceLayout
When set to true the widgets will be layed out.
Definition Window_base.hpp:71
std::atomic< bool > resizing
Definition Window_base.hpp:81
Size size
Definition Window_base.hpp:90
State
Definition Window_base.hpp:39
@ NoDevice
No device is associated with the Window and can therefor not be rendered on.
@ Initializing
The window has not been initialized yet.
@ SwapchainLost
The window was resized, the swapchain needs to be rebuild and can not be rendered on.
@ ReadyToRender
Need to request a swapchain before rendering.
@ WindowLost
The window was destroyed, need to cleanup.
@ NoWindow
The window was destroyed, the device will drop the window on the next render cycle.
@ NoSurface
Need to request a new surface before building a swapchain.
@ SurfaceLost
The Vulkan surface on the window was destroyed.
@ DeviceLost
The device was lost, but the window could move to a new device, or the device can be recreated.
std::unique_ptr< Widget > widget
The widget covering the complete window.
Definition Window_base.hpp:130
virtual void render(hires_utc_clock::time_point displayTimePoint)=0
int layoutChildren(hires_utc_clock::time_point displayTimePoint, bool force)
Layout the widgets in the window.
void unsetDevice()
Definition Window_base.hpp:171
Cursor currentCursor
The current cursor.
Definition Window_base.hpp:67
SubpixelOrientation subpixelOrientation
Definition Window_base.hpp:114
ivec currentWindowExtent
The current window extent as set by the GPU library.
Definition Window_base.hpp:104
ivec maximumWindowExtent
The maximum window extent as calculated by laying out all the widgets.
Definition Window_base.hpp:101
Widget * firstKeyboardWidget
The first widget in the window that needs to be selected.
Definition Window_base.hpp:147
std::atomic< bool > active
Definition Window_base.hpp:86
ivec minimumWindowExtent
The minimum window extent as calculated by laying out all the widgets.
Definition Window_base.hpp:98
Widget * keyboardTargetWidget
Target of the keyboard widget where keyboard events are sent to.
Definition Window_base.hpp:141
Widget * lastKeyboardWidget
The first widget in the window that needs to be selected.
Definition Window_base.hpp:152
float dpi
Definition Window_base.hpp:120
float fontScale() const noexcept
By how much the font needs to be scaled compared to current windowScale.
Definition Window_base.hpp:125
Widget * mouseTargetWidget
Target of the mouse Since any mouse event will change the target this is used to check if the target ...
Definition Window_base.hpp:136
fast_mutex widgetSolverMutex
Mutex for access to rhea objects registered with the widgetSolver.
Definition Window_base.hpp:95
std::atomic< bool > forceRedraw
When set to true the widgets will be redrawn.
Definition Window_base.hpp:75
T & makeWidget(Args &&... args)
Add a widget to main widget of the window.
Definition widgets.hpp:23
Definition Grapheme.hpp:20