HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields
tt::Window_base Class Referenceabstract

#include <TTauri/GUI/Window_base.hpp>

Inheritance diagram for tt::Window_base:
tt::Window_vulkan tt::Window_vulkan_macos tt::Window_vulkan_win32

Public Types

enum class  State {
  Initializing , NoWindow , NoDevice , NoSurface ,
  NoSwapchain , ReadyToRender , SwapchainLost , SurfaceLost ,
  DeviceLost , WindowLost
}
 
enum class  Size { Normal , Minimized , Maximized }
 

Public Member Functions

float fontScale () const noexcept
 By how much the font needs to be scaled compared to current windowScale.
 
 Window_base (std::shared_ptr< WindowDelegate > const &delegate, Label &&title)
 
 Window_base (Window_base const &)=delete
 
Window_baseoperator= (Window_base const &)=delete
 
 Window_base (Window_base &&)=delete
 
Window_baseoperator= (Window_base &&)=delete
 
virtual void initialize ()
 
void setDevice (GUIDevice *device)
 
void unsetDevice ()
 
void layout (hires_utc_clock::time_point displayTimePoint)
 
int layoutChildren (hires_utc_clock::time_point displayTimePoint, bool force)
 Layout the widgets in the window.
 
virtual void render (hires_utc_clock::time_point displayTimePoint)=0
 
bool isClosed ()
 
template<typename T , typename... Args>
T & makeWidget (Args &&... args)
 Add a widget to main widget of the window.
 
rhea::constraint addConstraint (rhea::constraint const &constraint) noexcept
 
rhea::constraint addConstraint (rhea::linear_equation const &equation, rhea::strength const &strength=rhea::strength::required(), double weight=1.0) noexcept
 
rhea::constraint addConstraint (rhea::linear_inequality const &equation, rhea::strength const &strength=rhea::strength::required(), double weight=1.0) noexcept
 
void removeConstraint (rhea::constraint const &constraint) noexcept
 
rhea::constraint replaceConstraint (rhea::constraint const &oldConstraint, rhea::constraint const &newConstraint) noexcept
 
rhea::constraint replaceConstraint (rhea::constraint const &oldConstraint, rhea::linear_equation const &newEquation, rhea::strength const &strength=rhea::strength::required(), double weight=1.0) noexcept
 
rhea::constraint replaceConstraint (rhea::constraint const &oldConstraint, rhea::linear_inequality const &newEquation, rhea::strength const &strength=rhea::strength::required(), double weight=1.0) noexcept
 
virtual void setCursor (Cursor cursor)=0
 
virtual void closeWindow ()=0
 
virtual void minimizeWindow ()=0
 
virtual void maximizeWindow ()=0
 
virtual void normalizeWindow ()=0
 
virtual void setWindowSize (ivec extent)=0
 
virtual std::string getTextFromClipboard () const noexcept=0
 
virtual void setTextOnClipboard (std::string str) noexcept=0
 
void updateToNextKeyboardTarget (Widget *currentTargetWidget) noexcept
 
void updateToPrevKeyboardTarget (Widget *currentTargetWidget) noexcept
 

Data Fields

State state = State::NoDevice
 
Cursor currentCursor = Cursor::None
 The current cursor.
 
std::atomic< bool > forceLayout = true
 When set to true the widgets will be layed out.
 
std::atomic< bool > forceRedraw = true
 When set to true the widgets will be redrawn.
 
std::atomic< bool > resizing = false
 
std::atomic< bool > active = false
 
Size size = Size::Normal
 
fast_mutex widgetSolverMutex
 Mutex for access to rhea objects registered with the widgetSolver.
 
ivec minimumWindowExtent
 The minimum window extent as calculated by laying out all the widgets.
 
ivec maximumWindowExtent
 The maximum window extent as calculated by laying out all the widgets.
 
ivec currentWindowExtent
 The current window extent as set by the GPU library.
 
std::shared_ptr< WindowDelegatedelegate
 
Label title
 
GUIDevicedevice = nullptr
 
SubpixelOrientation subpixelOrientation = SubpixelOrientation::BlueRight
 
float dpi = 72.0
 
std::unique_ptr< Widgetwidget
 The widget covering the complete window.
 
WidgetmouseTargetWidget = nullptr
 Target of the mouse Since any mouse event will change the target this is used to check if the target has changed, to send exit events to the previous mouse target.
 
WidgetkeyboardTargetWidget = nullptr
 Target of the keyboard widget where keyboard events are sent to.
 
WidgetfirstKeyboardWidget = nullptr
 The first widget in the window that needs to be selected.
 
WidgetlastKeyboardWidget = nullptr
 The first widget in the window that needs to be selected.
 

Detailed Description

A Window. This Window is backed by a native operating system window with a Vulkan surface. The Window should not have any decorations, which are to be drawn by the GUI, because modern design requires drawing of user interface elements in the border.

Member Enumeration Documentation

◆ State

enum class tt::Window_base::State
strong
Enumerator
Initializing 

The window has not been initialized yet.

NoWindow 

The window was destroyed, the device will drop the window on the next render cycle.

NoDevice 

No device is associated with the Window and can therefor not be rendered on.

NoSurface 

Need to request a new surface before building a swapchain.

ReadyToRender 

Need to request a swapchain before rendering.

The swapchain is ready drawing is allowed.

SwapchainLost 

The window was resized, the swapchain needs to be rebuild and can not be rendered on.

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.

WindowLost 

The window was destroyed, need to cleanup.

Member Function Documentation

◆ fontScale()

float tt::Window_base::fontScale ( ) const
inlinenoexcept

By how much the font needs to be scaled compared to current windowScale.

Widgets should pass this value to the text-shaper.

◆ layoutChildren()

int tt::Window_base::layoutChildren ( hires_utc_clock::time_point displayTimePoint,
bool force )

Layout the widgets in the window.

Returns
bit 0: Request redraw, bit 1: Request layout.

◆ makeWidget()

template<typename T , typename... Args>
T & tt::Window_base::makeWidget ( Args &&... args)

Add a widget to main widget of the window.

Add a widget to the main widget of the window.

The implementation is in Widget.hpp

The implementation is located here so that widget is a concrete type.

◆ render()

virtual void tt::Window_base::render ( hires_utc_clock::time_point displayTimePoint)
pure virtual

Update window. This will update animations and redraw all widgets managed by this window.

Implemented in tt::Window_vulkan.

◆ setDevice()

void tt::Window_base::setDevice ( GUIDevice * device)

Set GPU device to manage this window. Change of the device may be done at runtime.

◆ unsetDevice()

void tt::Window_base::unsetDevice ( )
inline

Remove the GPU device from the window, making it an orphan.

Field Documentation

◆ active

std::atomic<bool> tt::Window_base::active = false

The window is currently active. Widgets may want to reduce redraws, or change colors.

◆ currentCursor

Cursor tt::Window_base::currentCursor = Cursor::None

The current cursor.

Used for optimizing when the operating system cursor is updated. Set to Cursor::None at the start (for the wait icon) and when the operating system is going to display another icon to make sure when it comes back in the application the cursor will be updated correctly.

◆ currentWindowExtent

ivec tt::Window_base::currentWindowExtent

The current window extent as set by the GPU library.

◆ dpi

float tt::Window_base::dpi = 72.0

Dots-per-inch of the screen where the window is located. If the window is located on multiple screens then one of the screens is used as the source for the DPI value.

◆ firstKeyboardWidget

Widget* tt::Window_base::firstKeyboardWidget = nullptr

The first widget in the window that needs to be selected.

This widget is selected when the window is opened and when pressing tab when no other widget is selected.

◆ forceLayout

std::atomic<bool> tt::Window_base::forceLayout = true

When set to true the widgets will be layed out.

◆ forceRedraw

std::atomic<bool> tt::Window_base::forceRedraw = true

When set to true the widgets will be redrawn.

◆ keyboardTargetWidget

Widget* tt::Window_base::keyboardTargetWidget = nullptr

Target of the keyboard widget where keyboard events are sent to.

◆ lastKeyboardWidget

Widget* tt::Window_base::lastKeyboardWidget = nullptr

The first widget in the window that needs to be selected.

This widget is selected when pressing shift-tab when no other widget is selected.

◆ maximumWindowExtent

ivec tt::Window_base::maximumWindowExtent

The maximum window extent as calculated by laying out all the widgets.

◆ minimumWindowExtent

ivec tt::Window_base::minimumWindowExtent

The minimum window extent as calculated by laying out all the widgets.

◆ mouseTargetWidget

Widget* tt::Window_base::mouseTargetWidget = nullptr

Target of the mouse Since any mouse event will change the target this is used to check if the target has changed, to send exit events to the previous mouse target.

◆ resizing

std::atomic<bool> tt::Window_base::resizing = false

The window is currently being resized by the user. We can disable expensive redraws during rendering until this is false again.

◆ size

Size tt::Window_base::size = Size::Normal

Current size state of the window.

◆ subpixelOrientation

SubpixelOrientation tt::Window_base::subpixelOrientation = SubpixelOrientation::BlueRight

Orientation of the RGB subpixels.

◆ widget

std::unique_ptr<Widget> tt::Window_base::widget

The widget covering the complete window.

◆ widgetSolverMutex

fast_mutex tt::Window_base::widgetSolverMutex

Mutex for access to rhea objects registered with the widgetSolver.

Widgets will need to lock this mutex when reading variables or equations.


The documentation for this class was generated from the following files: