|
CeresEngine 0.2.0
A game development framework
|
A window that an app displays on the screen. More...
#include <CeresEngine/UI/UIWindow.hpp>
Public Member Functions | |
| UIWindow () | |
| UIWindow (UIWindowDevice &device) | |
| ~UIWindow () override | |
| const String & | getTitle () const |
| The string that appears in the title bar of the window. | |
| virtual void | setTitle (const String &title) |
| The string that appears in the title bar of the window. | |
| virtual UIView * | getContentView () const |
The window's content view, the highest accessible UIView object in the window's view hierarchy. | |
| virtual void | setContentView (UIView *contentView) |
The window's content view, the highest accessible UIView object in the window's view hierarchy. | |
| UIViewController * | getContentViewController () const |
| The root view controller for the window. | |
| void | setContentViewController (UIViewController *contentViewController) |
| The root view controller for the window. | |
| void | setContentViewController (const UIViewControllerPtr &contentViewController) |
| The root view controller for the window. | |
| UIRect | getFrame () const |
| The window's frame rectangle in screen coordinates, including the title bar. | |
| virtual void | setFrame (const UIRect &frame) |
| The window's frame rectangle in screen coordinates, including the title bar. | |
| void | layoutIfNeeded () |
| Updates the layout of views in the window based on the current views and constraints. | |
| void | display () |
Calls display() down the window's view hierarchy, thus redrawing all views within the window, including the frame view that draws the border, title bar, and other peripheral elements. | |
| void | display (UIDrawCommandBuffer &commandBuffer) |
Calls display() down the window's view hierarchy, thus redrawing all views within the window, including the frame view that draws the border, title bar, and other peripheral elements. | |
| void | displayIfNeeded () |
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements. | |
| void | displayIfNeeded (UIDrawCommandBuffer &commandBuffer) |
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements. | |
| void | flush () |
| Flushes the contents of the window without drawing it. | |
| bool | getViewsNeedDisplay () const |
| A Boolean value that indicates whether any of the window's views need to be displayed. | |
| void | setViewsNeedDisplay () |
| A Boolean value that indicates whether any of the window's views need to be displayed. | |
| void | setViewsNeedDisplay (bool state) |
| A Boolean value that indicates whether any of the window's views need to be displayed. | |
| double | getBackingScaleFactor () const |
| The backing scale factor. | |
| UIWindowDevice * | getDevice () const noexcept |
| Gets the backing store for the window, if any is set. | |
| void | setDevice (UIWindowDevice &device) |
| Gets the backing store for the window, if any is set. | |
| UIBackingStore * | getBackingStore () const noexcept |
| Gets the backing store for the window, if any is set. | |
| UIBackingStorePtr | createBackingStore () const |
| Creates a new backing store for a view or a layer. | |
| UIView * | getInitialFirstResponder () const |
| The view that's made first responder (also called the key view) the first time the window is placed onscreen. | |
| UIResponder * | getFirstResponder () const |
| The window's first responder. | |
| bool | makeFirstResponder (UIResponder *responder) |
| Attempts to make a given responder the first responder for the window. | |
| bool | resignFirstResponder (const UIResponder *responder) |
| const UIAppearance & | getAppearance () const noexcept |
| The UI appearance to be used by the window. | |
| void | setAppearance (UIAppearance *appearance) |
| The UI appearance to be used by the window. | |
| AffineTransform | getTransformToScreen () const |
| AffineTransform | getTransformToBacking () const |
| AffineTransform | getTransformFromScreen () const |
| AffineTransform | getTransformFromBacking () const |
| UIRect | convertToScreen (const UIRect &rect) const |
| Converts the rectangle to the screen coordinate system from the window's coordinate system. | |
| UIPoint | convertToScreen (const UIPoint &point) const |
| Converts the point to the screen coordinate system from the window's coordinate system. | |
| UIRect | convertToBacking (const UIRect &rect) const |
| Converts a rectangle from the window’s coordinate system to its pixel-aligned backing store coordinate system. | |
| UIPoint | convertToBacking (const UIPoint &point) const |
| Converts a point to the screen coordinate system from the window’s coordinate system. | |
| UIRect | convertFromScreen (const UIRect &rect) const |
| Converts the rectangle from the screen coordinate system to the window's coordinate system. | |
| UIPoint | convertFromScreen (const UIPoint &point) const |
| Converts the point from the screen coordinate system to the window's coordinate system. | |
| UIRect | convertFromBacking (const UIRect &rect) const |
| Converts a rectangle from its pixel-aligned backing store coordinate system to the window’s coordinate system. | |
| UIPoint | convertFromBacking (const UIPoint &point) const |
| Converts a point from its pixel-aligned backing store coordinate system to the window’s coordinate system. | |
| void | sendEvent (const UIEvent &event) |
| This action method dispatches mouse and keyboard events sent to the window by the engine. | |
| virtual bool | resignFirstResponder () |
| Notifies the receiver that it's been asked to relinquish its status as first responder in its window. | |
Public Member Functions inherited from CeresEngine::UIResponder | |
| virtual | ~UIResponder ()=default |
| virtual bool | acceptsFirstResponder () const |
| A Boolean value that indicates whether the responder accepts first responder status. | |
| virtual bool | becomeFirstResponder () |
| Notifies the receiver that it's about to become first responder in its window. | |
| virtual UIResponder * | getNextResponder () const |
| The next responder after this one, or nil if it has none. | |
| virtual void | mouseDown (const UIMouseEvent &event) |
| Informs the receiver that the user has pressed the left mouse button. | |
| virtual void | mouseDragged (const UIMouseEvent &event) |
| Informs the receiver that the user has moved the mouse with the left button pressed. | |
| virtual void | mouseUp (const UIMouseEvent &event) |
| Informs the receiver that the user has released the left mouse button. | |
| virtual void | mouseMoved (const UIMouseEvent &event) |
| Informs the receiver that the mouse has moved. | |
| virtual void | mouseEntered (const UIMouseEvent &event) |
| Informs the receiver that the cursor has entered a tracking rectangle. | |
| virtual void | mouseExited (const UIMouseEvent &event) |
| Informs the receiver that the cursor has exited a tracking rectangle. | |
| virtual void | rightMouseDown (const UIMouseEvent &event) |
| Informs the receiver that the user has pressed the right mouse button. | |
| virtual void | rightMouseDragged (const UIMouseEvent &event) |
| Informs the receiver that the user has moved the mouse with the right button pressed. | |
| virtual void | rightMouseUp (const UIMouseEvent &event) |
| Informs the receiver that the user has released the right mouse button. | |
| virtual void | otherMouseDown (const UIMouseEvent &event) |
| Informs the receiver that the user has pressed a mouse button other than the left or right one. | |
| virtual void | otherMouseDragged (const UIMouseEvent &event) |
| Informs the receiver that the user has moved the mouse with a button other than the left or right button pressed. | |
| virtual void | otherMouseUp (const UIMouseEvent &event) |
| Informs the receiver that the user has released a mouse button other than the left or right button. | |
| virtual void | scrollWheel (const UIMouseEvent &event) |
| Informs the receiver that the mouse's scroll wheel has moved. | |
| virtual void | keyDown (const UIKeyEvent &event) |
| Informs the receiver that the user has pressed a key. | |
| virtual void | keyUp (const UIKeyEvent &event) |
| Informs the receiver that the user has released a key. | |
| virtual void | interpretKeyEvents (const Vector< UIKeyEvent > &events) |
| Handles a series of key events. | |
| virtual bool | performKeyEquivalent (const UIKeyEvent &event) |
| Handle a key equivalent. | |
| virtual void | flushBufferedKeyEvents () |
| Clears any unprocessed key events when overridden by subclasses. | |
| virtual void | cursorUpdate (const UIEvent &event) |
| Informs the receiver that the mouse cursor has moved into a cursor rectangle. | |
| virtual void | flagsChanged (const UIEvent &event) |
| Informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on). | |
Public Member Functions inherited from CeresEngine::RefCounted< UIWindow > | |
| RefCounted (Args &&... args) | |
Creates a new RefCounted object and constructs a new Deleter by forwarding Args to it. | |
| void | retain () noexcept |
| Retains the object by increment it's reference count by one. | |
| bool | release () noexcept |
| Relases the object by decrementing it's reference count by one. | |
Static Public Attributes | |
| static const UIAppearancePtr | kDefaultAppearance |
| The default appearance to be used by new windows. | |
Private Member Functions | |
| void | setBackingStore (UIBackingStorePtr &&backingStore) |
| Gets the backing store for the window, if any is set. | |
| void | notifyFrameChanged (const UIRect &newFrame) |
| void | notifyBackingScaleFactorChange (double newBackingScalingFactor) |
Private Attributes | |
| UIResponder * | mFirstResponder = this |
| The window's first responder. | |
| UIViewPtr | mContentView = nullptr |
The window's content view, the highest accessible UIView object in the window's view hierarchy. | |
| UIViewControllerPtr | mContentViewController = nullptr |
| The root view controller for the window. | |
| UIRect | mFrame |
| The window size and position. | |
| UIAppearancePtr | mAppearance = nullptr |
| The UI appearance to be used by the window. | |
| UIWindowStateFlags | mFlags = UIWindowState::NeedsDisplay |
| The view flags. | |
| UIViewPtr | mMouseDownView |
| The view the last mouseDown event occurred on. | |
| UIViewPtr | mPreviousHitView = nullptr |
| The view to dispatch events that can occur outside of the views bounds, like drag events. | |
| UIBackingStorePtr | mBackingStore |
| The underlying backing store of the window. | |
| UIWindowDevicePtr | mDevice |
| The underlying backing store of the window. | |
Friends | |
| class | UIWindowDevice |
Additional Inherited Members | |
Static Public Member Functions inherited from CeresEngine::UIResponder | |
| static void | dispatch (UIResponder *const firstResponder, const UIEvent &event) |
Dispatches a UIEvent to the given first responder. | |
A window that an app displays on the screen.
A single UIWindow object corresponds to at most one onscreen window. The two principal functions of a window are to provide an area in which views can be placed and to accept and distribute, to the appropriate views, events the user instigates through actions with the mouse and keyboard.
|
explicit |
|
explicit |
|
override |
Converts a point from its pixel-aligned backing store coordinate system to the window’s coordinate system.
| point | The point in the pixel-aligned backing store coordinate system. |
Converts a rectangle from its pixel-aligned backing store coordinate system to the window’s coordinate system.
| rect | The rectangle aligned to the pixel backing store coordinate system. |
Converts the point from the screen coordinate system to the window's coordinate system.
| point | A point in the screen's coordinate system. |
Converts the rectangle from the screen coordinate system to the window's coordinate system.
| rect | A rectangle in the screen's coordinate system. |
Converts a point to the screen coordinate system from the window’s coordinate system.
| point | A point in the window’s coordinate system. |
Converts a rectangle from the window’s coordinate system to its pixel-aligned backing store coordinate system.
| point | A rectangle in the window’s coordinate system. |
Converts the point to the screen coordinate system from the window's coordinate system.
| point | A point in the window's coordinate system. |
Converts the rectangle to the screen coordinate system from the window's coordinate system.
| rect | A rectangle in the window's coordinate system. |
| UIBackingStorePtr CeresEngine::UIWindow::createBackingStore | ( | ) | const |
Creates a new backing store for a view or a layer.
| void CeresEngine::UIWindow::display | ( | ) |
Calls display() down the window's view hierarchy, thus redrawing all views within the window, including the frame view that draws the border, title bar, and other peripheral elements.
You rarely need to invoke this method. UIWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.
| void CeresEngine::UIWindow::display | ( | UIDrawCommandBuffer & | commandBuffer | ) |
Calls display() down the window's view hierarchy, thus redrawing all views within the window, including the frame view that draws the border, title bar, and other peripheral elements.
You rarely need to invoke this method. UIWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.
| void CeresEngine::UIWindow::displayIfNeeded | ( | ) |
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements.
This method is useful when you want to modify some number of views and then display only the ones that were modified.
You rarely need to invoke this method. UIWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.
| void CeresEngine::UIWindow::displayIfNeeded | ( | UIDrawCommandBuffer & | commandBuffer | ) |
Calls displayIfNeeded() message down the window's view hierarchy, thus redrawing all views that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements.
This method is useful when you want to modify some number of views and then display only the ones that were modified.
You rarely need to invoke this method. UIWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.
| void CeresEngine::UIWindow::flush | ( | ) |
Flushes the contents of the window without drawing it.
|
noexcept |
The UI appearance to be used by the window.
The default value for this property is nulltpr, which means that the view uses the appearance it inherits from the nearest ancestor that has set an appearance. When you set appearance to a non-null value, the view and the views it contains use the specified appearance.
| double CeresEngine::UIWindow::getBackingScaleFactor | ( | ) | const |
The backing scale factor.
The value of this property is 2.0 for high-resolution scaled display modes, and 1.0 for all other cases.
There are some scenarios where an application that is resolution-aware may want to reason on its own about the display environment it is running in. It is important to note that the value of this property does not represent anything concrete, such as pixel density or physical size, because it can vary based on the configured display mode. For example, the display may be in a mirrored configuration that is still high-resolution scaled, resulting in pixel geometry that may not match the native resolution of the display device.
getBackingScaleFactor() as an input to layout or drawing calculations. Developers should instead use the backing coordinate space conversion methods, because the resulting code will more likely work consistently and correctly under both standard and high-resolution operation.
|
inlinenoexcept |
Gets the backing store for the window, if any is set.
The window's content view, the highest accessible UIView object in the window's view hierarchy.
The window retains the new content view and owns it thereafter. The view object is resized to fit precisely within the content area of the window. You can modify the content view's coordinate system through its bounds rectangle, but can't alter its frame rectangle (that is, its size or location) directly.
Setting this property causes the old content view to be released; if you plan to reuse it, be sure to retain it before changing the property value and to release it as appropriate when adding it to another UIWindow or UIWindow object.
|
inline |
The root view controller for the window.
The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller's view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nullptr.
|
inlinenoexcept |
Gets the backing store for the window, if any is set.
| UIResponder * CeresEngine::UIWindow::getFirstResponder | ( | ) | const |
The window's first responder.
The first responder is usually the first object in a responder chain to receive an event or action message. In most cases, the first responder is a view object that the user selects or activates with the mouse or keyboard.
You can use the firstResponder property in custom subclasses of responder classes (UIWindow or UIView, and subclasses) to determine if an instance of the subclass is currently the first responder. You can also use it to help locate a text field that currently has first-responder status.
| UIRect CeresEngine::UIWindow::getFrame | ( | ) | const |
The window's frame rectangle in screen coordinates, including the title bar.
| UIView * CeresEngine::UIWindow::getInitialFirstResponder | ( | ) | const |
The view that's made first responder (also called the key view) the first time the window is placed onscreen.
The string that appears in the title bar of the window.
| AffineTransform CeresEngine::UIWindow::getTransformFromBacking | ( | ) | const |
| AffineTransform CeresEngine::UIWindow::getTransformFromScreen | ( | ) | const |
| AffineTransform CeresEngine::UIWindow::getTransformToBacking | ( | ) | const |
| AffineTransform CeresEngine::UIWindow::getTransformToScreen | ( | ) | const |
| bool CeresEngine::UIWindow::getViewsNeedDisplay | ( | ) | const |
A Boolean value that indicates whether any of the window's views need to be displayed.
The value of this property is true when any of the window's views need to be displayed; otherwise, NO. You should rarely need to set this property; the method UIView::setNeedsDisplay() and similar methods set it automatically.
| void CeresEngine::UIWindow::layoutIfNeeded | ( | ) |
Updates the layout of views in the window based on the current views and constraints.
| bool CeresEngine::UIWindow::makeFirstResponder | ( | UIResponder * | responder | ) |
Attempts to make a given responder the first responder for the window.
If responder isn't already the first responder, this method first calls resignFirstResponder() on the object that is the first responder. If that object refuses to resign, it remains the first responder, and this method immediately returns false. If the current first responder resigns, this method calls becomeFirstResponder() on responder. If responder does not accept first responder status, the UIWindow object becomes first responder; in this case, the method returns true even if responder refuses first responder status.
If responder is nullptr, this method still calls resignFirstResponder() on the current first responder. If the current first responder refuses to resign, it remains the first responder and this method immediately returns false. If the current first responder returns true from resignFirstResponder(), the window is made its own first responder and this method returns true.
The UI framework uses this method to alter the first responder in response to mouse-down events; you can also use it to explicitly set the first responder from within your program. The responder object is typically an UIView object in the window's view hierarchy. If this method is called explicitly, first call acceptsFirstResponder to responder, and do not call makeFirstResponder() if acceptsFirstResponder returns false.
Use initialFirstResponder to the set the first responder to be used when the window is brought onscreen for the first time.
true when the operation is successful; otherwise, false.
|
private |
Notifies the receiver that it's been asked to relinquish its status as first responder in its window.
The default implementation returns true, resigning first responder status. Subclasses can override this method to update state or perform some action such as unhighlighting the selection, or to return false, refusing to relinquish first responder status.
Use the UIWindow::makeFirstResponder() method, not this method, to make an object the first responder. Never invoke this method directly.
Reimplemented from CeresEngine::UIResponder.
| bool CeresEngine::UIWindow::resignFirstResponder | ( | const UIResponder * | responder | ) |
This action method dispatches mouse and keyboard events sent to the window by the engine.
Never invoke this method directly.
| event | The mouse or keyboard event to process. |
| void CeresEngine::UIWindow::setAppearance | ( | UIAppearance * | appearance | ) |
The UI appearance to be used by the window.
The default value for this property is nulltpr, which means that the view uses the appearance it inherits from the nearest ancestor that has set an appearance. When you set appearance to a non-null value, the view and the views it contains use the specified appearance.
|
private |
Gets the backing store for the window, if any is set.
The window's content view, the highest accessible UIView object in the window's view hierarchy.
The window retains the new content view and owns it thereafter. The view object is resized to fit precisely within the content area of the window. You can modify the content view's coordinate system through its bounds rectangle, but can't alter its frame rectangle (that is, its size or location) directly.
Setting this property causes the old content view to be released; if you plan to reuse it, be sure to retain it before changing the property value and to release it as appropriate when adding it to another UIWindow or UIWindow object.
|
inline |
The root view controller for the window.
The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller's view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nullptr.
| void CeresEngine::UIWindow::setContentViewController | ( | UIViewController * | contentViewController | ) |
The root view controller for the window.
The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller's view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nullptr.
| void CeresEngine::UIWindow::setDevice | ( | UIWindowDevice & | device | ) |
Gets the backing store for the window, if any is set.
The window's frame rectangle in screen coordinates, including the title bar.
The string that appears in the title bar of the window.
| void CeresEngine::UIWindow::setViewsNeedDisplay | ( | ) |
A Boolean value that indicates whether any of the window's views need to be displayed.
The value of this property is true when any of the window's views need to be displayed; otherwise, NO. You should rarely need to set this property; the method UIView::setNeedsDisplay() and similar methods set it automatically.
A Boolean value that indicates whether any of the window's views need to be displayed.
The value of this property is true when any of the window's views need to be displayed; otherwise, NO. You should rarely need to set this property; the method UIView::setNeedsDisplay() and similar methods set it automatically.
|
friend |
|
static |
The default appearance to be used by new windows.
|
private |
The UI appearance to be used by the window.
The default value for this property is nulltpr, which means that the view uses the appearance it inherits from the nearest ancestor that has set an appearance. When you set appearance to a non-null value, the view and the views it contains use the specified appearance.
|
private |
The underlying backing store of the window.
The window's content view, the highest accessible UIView object in the window's view hierarchy.
|
private |
The root view controller for the window.
The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller's view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nullptr.
|
private |
The underlying backing store of the window.
|
private |
The window's first responder.
|
private |
The view flags.
|
private |
The window size and position.
|
private |
The view the last mouseDown event occurred on.
The view to dispatch events that can occur outside of the views bounds, like drag events.