CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIWindow.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
13
14#include "UILayout.hpp"
15#include "UIResponder.hpp"
16#include "UIView.hpp"
17#include "UIViewController.hpp"
18
20
24
25namespace CeresEngine {
26 class UIView;
27
28 enum class UIWindowState {
29 NeedsDisplay = 1 << 0
30 };
31
34
42 class UIWindow : public UIResponder, public RefCounted<UIWindow> {
43 private:
46
50
62
65
74
77
80
84
87
90
91 public:
92 explicit UIWindow();
93 explicit UIWindow(UIWindowDevice& device);
94
95 ~UIWindow() override;
96
97 public:
99 [[nodiscard]] const String& getTitle() const;
100
102 virtual void setTitle(const String& title);
103
117 [[nodiscard]] virtual UIView* CE_NULLABLE getContentView() const { return mContentView.get(); }
118
121
124
127
130
131 public: // Sizing Windows
135
137 virtual void setFrame(const UIRect& frame);
138
139 public: // Layout
143
144 public: // Drawing Windows
152 void display();
153
161 void display(UIDrawCommandBuffer& commandBuffer);
162
175
188
190 void flush();
191
200
203
206
228
229 public: // Devices & Backing Store
232
235
238
241
242 private:
245
246 public: // UIResponder
250
264
298
299 // TODO: Write docs
301
303
304 public: // Appearance
307
310
313
314 public: // Converting Coordinates
317 [[nodiscard]] AffineTransform getTransformToScreen() const;
318
322 [[nodiscard]] AffineTransform getTransformToBacking() const;
323
327
332
339
346
352
358
365
372
379
386
387 public: // Handling Events
394 void sendEvent(const UIEvent& event);
395
396 private:
400 };
401
402} // namespace CeresEngine
#define CE_FLAGS_OPERATORS(Enum)
Defines global operators for a Flags<Enum, Storage> implementation.
Definition Flags.hpp:216
#define CE_NULLABLE
The CE_NULLABLE nullability qualifier indicates that a value of the pointer type can be null.
Definition Macros.hpp:300
#define CE_NON_NULL
The CE_NON_NULL nullability qualifier indicates that null is not a meaningful value for a value of th...
Definition Macros.hpp:299
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
Pointer get() const noexcept
Definition SmartPtr.hpp:244
An object that encapsulates rendering context for a view.
Definition GraphicsCommandBuffer.hpp:284
A simple reference counter base class.
Definition SmartPtr.hpp:438
An object that describes the appearance of a UI view.
Definition UIAppearance.hpp:93
The BackingStore represents store for a window or view.
Definition UIBackingStore.hpp:29
An abstract class that forms the basis of event and command processing in the UI framework.
Definition UIResponder.hpp:33
virtual bool resignFirstResponder()
Notifies the receiver that it's been asked to relinquish its status as first responder in its window.
Definition UIResponder.hpp:71
A controller that manages a view.
Definition UIViewController.hpp:24
The infrastructure for drawing and handling events in a UI.
Definition UIView.hpp:153
The UIWindow::Device is the backing device for one or multiple windows.
Definition UIWindowDevice.hpp:41
A window that an app displays on the screen.
Definition UIWindow.hpp:42
void setContentViewController(const UIViewControllerPtr &contentViewController)
The root view controller for the window.
Definition UIWindow.hpp:129
AffineTransform getTransformFromScreen() const
void notifyFrameChanged(const UIRect &newFrame)
double getBackingScaleFactor() const
The backing scale factor.
UIWindowDevice * getDevice() const noexcept
Gets the backing store for the window, if any is set.
Definition UIWindow.hpp:231
void setViewsNeedDisplay()
A Boolean value that indicates whether any of the window's views need to be displayed.
void setDevice(UIWindowDevice &device)
Gets the backing store for the window, if any is set.
bool resignFirstResponder(const UIResponder *responder)
UIWindow(UIWindowDevice &device)
UIViewPtr mContentView
The window's content view, the highest accessible UIView object in the window's view hierarchy.
Definition UIWindow.hpp:49
UIBackingStorePtr createBackingStore() const
Creates a new backing store for a view or a layer.
virtual UIView * getContentView() const
The window's content view, the highest accessible UIView object in the window's view hierarchy.
Definition UIWindow.hpp:117
UIRect mFrame
The window size and position.
Definition UIWindow.hpp:64
UIBackingStore * getBackingStore() const noexcept
Gets the backing store for the window, if any is set.
Definition UIWindow.hpp:237
void layoutIfNeeded()
Updates the layout of views in the window based on the current views and constraints.
void flush()
Flushes the contents of the window without drawing it.
UIRect convertFromScreen(const UIRect &rect) const
Converts the rectangle from the screen coordinate system to the window's coordinate system.
UIViewController * getContentViewController() const
The root view controller for the window.
Definition UIWindow.hpp:123
UIViewControllerPtr mContentViewController
The root view controller for the window.
Definition UIWindow.hpp:61
UIBackingStorePtr mBackingStore
The underlying backing store of the window.
Definition UIWindow.hpp:86
void sendEvent(const UIEvent &event)
This action method dispatches mouse and keyboard events sent to the window by the engine.
UIRect getFrame() const
The window's frame rectangle in screen coordinates, including the title bar.
UIView * getInitialFirstResponder() const
The view that's made first responder (also called the key view) the first time the window is placed o...
void displayIfNeeded(UIDrawCommandBuffer &commandBuffer)
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need ...
const UIAppearance & getAppearance() const noexcept
The UI appearance to be used by the window.
UIWindowDevicePtr mDevice
The underlying backing store of the window.
Definition UIWindow.hpp:89
void setAppearance(UIAppearance *appearance)
The UI appearance to be used by the window.
void display()
Calls display() down the window's view hierarchy, thus redrawing all views within the window,...
UIResponder * getFirstResponder() const
The window's first responder.
UIViewPtr mMouseDownView
The view the last mouseDown event occurred on.
Definition UIWindow.hpp:79
UIResponder * mFirstResponder
The window's first responder.
Definition UIWindow.hpp:45
void setBackingStore(UIBackingStorePtr &&backingStore)
Gets the backing store for the window, if any is set.
UIAppearancePtr mAppearance
The UI appearance to be used by the window.
Definition UIWindow.hpp:73
void displayIfNeeded()
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need ...
virtual void setTitle(const String &title)
The string that appears in the title bar of the window.
static const UIAppearancePtr kDefaultAppearance
The default appearance to be used by new windows.
Definition UIWindow.hpp:312
void setViewsNeedDisplay(bool state)
A Boolean value that indicates whether any of the window's views need to be displayed.
UIWindowStateFlags mFlags
The view flags.
Definition UIWindow.hpp:76
UIRect convertFromBacking(const UIRect &rect) const
Converts a rectangle from its pixel-aligned backing store coordinate system to the window’s coordinat...
bool getViewsNeedDisplay() const
A Boolean value that indicates whether any of the window's views need to be displayed.
void notifyBackingScaleFactorChange(double newBackingScalingFactor)
UIViewPtr mPreviousHitView
The view to dispatch events that can occur outside of the views bounds, like drag events.
Definition UIWindow.hpp:83
AffineTransform getTransformFromBacking() const
UIRect convertToBacking(const UIRect &rect) const
Converts a rectangle from the window’s coordinate system to its pixel-aligned backing store coordinat...
AffineTransform getTransformToScreen() const
virtual void setFrame(const UIRect &frame)
The window's frame rectangle in screen coordinates, including the title bar.
void setContentViewController(UIViewController *contentViewController)
The root view controller for the window.
bool makeFirstResponder(UIResponder *responder)
Attempts to make a given responder the first responder for the window.
void display(UIDrawCommandBuffer &commandBuffer)
Calls display() down the window's view hierarchy, thus redrawing all views within the window,...
const String & getTitle() const
The string that appears in the title bar of the window.
UIRect convertToScreen(const UIRect &rect) const
Converts the rectangle to the screen coordinate system from the window's coordinate system.
virtual void setContentView(UIView *contentView)
The window's content view, the highest accessible UIView object in the window's view hierarchy.
AffineTransform getTransformToBacking() const
Definition Application.hpp:19
UIWindowState
Definition UIWindow.hpp:28
struct CeresEngine::GLState state
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
Point2 UIPoint
A type that contains a point in a two-dimensional coordinate system.
Definition UIUtility.hpp:27
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
An object that contains information about an input action such as a mouse click or a key press.
Definition UIEvent.hpp:115