CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::UIViewController Class Reference

A controller that manages a view. More...

#include <CeresEngine/UI/UIViewController.hpp>

Inheritance diagram for CeresEngine::UIViewController:
CeresEngine::UIResponder CeresEngine::RefCounted< UIViewController > CeresEngine::TUIViewController< UISplitView > CeresEngine::TUIViewController< UIViewport > CeresEngine::TUIViewController< TViewType, TParentViewControllerType > CeresEngine::UIModelViewController< TModelType, TViewControllerType > CeresEngine::UISplitViewController CeresEngine::UIViewportViewController

Public Member Functions

 UIViewController ()=default
 
 UIViewController (UIView &view)
 
 UIViewController (UIView *view)
 
 ~UIViewController () override
 
UIViewgetView () const
 The view controller’s primary view.
 
bool isViewLoaded () const noexcept
 A Boolean value indicating whether the view controller’s view is loaded into memory.
 
virtual void didLoad ()
 Called after the view controller’s view has been loaded into memory.
 
virtual void willAppear ()
 Called after the view controller’s view has been loaded into memory is about to be added to the view hierarchy in the window.
 
virtual void didAppear ()
 Called when the view controller’s view is fully transitioned onto the screen.
 
virtual void willDisappear ()
 Called when the view controller’s view is about to be removed from the view hierarchy in the window.
 
virtual void didDisappear ()
 Called after the view controller’s view is removed from the view hierarchy in a window.
 
virtual void willLayout ()
 Called just before the layout method of the view controller's view is called.
 
virtual void didLayout ()
 Called immediately after the layout method of the view controller's view is called.
 
virtual void didAddChildViewController (UIViewController *const childViewController)
 Called immediately after a child UIViewController is added to the hierarchy.
 
virtual void didRemoveChildViewController (UIViewController *const childViewController)
 Called immediately after a child UIViewController is removed from the hierarchy.
 
UIViewControllergetParentViewController () const noexcept
 The immediate ancestor view controller of the view controller.
 
const Vector< UIViewControllerPtr > & getChildViewControllers () const noexcept
 An array of view controllers that are hierarchical children of the view controller.
 
void addChildViewController (UIViewController *childViewController)
 A convenience method for adding a child view controller at the end of the childViewControllers array.
 
void addChildViewController (const UIViewControllerPtr &childViewController)
 A convenience method for adding a child view controller at the end of the childViewControllers array.
 
void removeChildViewController (UIViewController *childViewController)
 A convenience method for removing a child view controller from the childViewControllers array.
 
void removeChildViewController (const UIViewControllerPtr &childViewController)
 A convenience method for removing a child view controller from the childViewControllers array.
 
void removeFromParentViewController ()
 Removes the called view controller from its parent view controller.
 
const AnygetRepresentedObject () const noexcept
 The object whose value is presented in the receiver’s primary view.
 
void setRepresentedObject (const Any &representedObject)
 The object whose value is presented in the receiver’s primary view.
 
UIRespondergetNextResponder () const final
 The next responder after this one, or nil if it has none.
 
- 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 bool resignFirstResponder ()
 Notifies the receiver that it's been asked to relinquish its status as first responder in its window.
 
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< UIViewController >
 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.
 

Protected Member Functions

virtual UIViewPtr createView ()
 Instantiates a view.
 
virtual void loadView (UIView &view)
 Instantiates a view.
 

Private Member Functions

void instantiateView ()
 

Private Attributes

UIViewPtr mView = nullptr
 The view controller’s primary view.
 
bool mViewLoaded = false
 A Boolean value indicating whether the view controller’s view is loaded into memory.
 
UIViewControllermParentViewController
 The immediate ancestor view controller of the view controller.
 
Vector< UIViewControllerPtrmChildViewControllers
 An array of view controllers that are hierarchical children of the view controller.
 
Any mRepresentedObject
 The object whose value is presented in the receiver’s primary view.
 

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.
 

Detailed Description

A controller that manages a view.

Constructor & Destructor Documentation

◆ UIViewController() [1/3]

CeresEngine::UIViewController::UIViewController ( )
default

◆ UIViewController() [2/3]

CeresEngine::UIViewController::UIViewController ( UIView view)
explicit

◆ UIViewController() [3/3]

CeresEngine::UIViewController::UIViewController ( UIView view)
explicit

◆ ~UIViewController()

CeresEngine::UIViewController::~UIViewController ( )
override

Member Function Documentation

◆ addChildViewController() [1/2]

void CeresEngine::UIViewController::addChildViewController ( const UIViewControllerPtr childViewController)
inline

A convenience method for adding a child view controller at the end of the childViewControllers array.

Parameters
childViewControllerThe view controller to be added to the end of the childViewControllers array.

◆ addChildViewController() [2/2]

void CeresEngine::UIViewController::addChildViewController ( UIViewController childViewController)

A convenience method for adding a child view controller at the end of the childViewControllers array.

Parameters
childViewControllerThe view controller to be added to the end of the childViewControllers array.

◆ createView()

virtual UIViewPtr CeresEngine::UIViewController::createView ( )
protectedvirtual

Instantiates a view.

This method is called by the system, and is exposed in this class so you can override it to add behavior or replace the created view.

Do not call this method. If you require this method to be called, access the view property.

Do not invoke this method from other objects unless you take care to avoid redundant invocations. The default implementation of the loadView method handles redundant invocations correctly, but a view controller subclass might not. To be safe, other objects should instead access a view controller’s view property.

Reimplemented in CeresEngine::TUIViewController< TViewType, TParentViewControllerType >, CeresEngine::TUIViewController< UISplitView >, and CeresEngine::TUIViewController< UIViewport >.

◆ didAddChildViewController()

virtual void CeresEngine::UIViewController::didAddChildViewController ( UIViewController *const  childViewController)
inlinevirtual

Called immediately after a child UIViewController is added to the hierarchy.

You can override this method to perform tasks to follow the addition of a new child view controller. If you override this method, call the parent implementation at some point in your implementation in case a superclass also overrides this method.

Parameters
childViewControllerA reference to the newly added child view controller.

Reimplemented in CeresEngine::UISplitViewController.

◆ didAppear()

virtual void CeresEngine::UIViewController::didAppear ( )
inlinevirtual

Called when the view controller’s view is fully transitioned onto the screen.

This method is called after the completion of any drawing and animations involved in the initial appearance of the view. You can override this method to perform tasks appropriate for that time, such as work that should not interfere with the presentation animation, or starting an animation that you want to begin after the view appears.

If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ didDisappear()

virtual void CeresEngine::UIViewController::didDisappear ( )
inlinevirtual

Called after the view controller’s view is removed from the view hierarchy in a window.

You can override this method to perform tasks associated with removing the view controller’s view from the window’s view hierarchy, such as releasing resources not needed when the view is not visible or no longer part of the window.

If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ didLayout()

virtual void CeresEngine::UIViewController::didLayout ( )
inlinevirtual

Called immediately after the layout method of the view controller's view is called.

You can override this method to perform tasks to follow the completion of layout of the view controller’s view. If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ didLoad()

virtual void CeresEngine::UIViewController::didLoad ( )
inlinevirtual

Called after the view controller’s view has been loaded into memory.

You can override this method to perform tasks to immediately follow the setting of the view property.

Typically, your override would perform one-time instantiation and initialization of the contents of the view controller’s view. If you override this method, call this method on the base-class at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ didRemoveChildViewController()

virtual void CeresEngine::UIViewController::didRemoveChildViewController ( UIViewController *const  childViewController)
inlinevirtual

Called immediately after a child UIViewController is removed from the hierarchy.

You can override this method to perform tasks to follow the removal of a child view controller. If you override this method, call the parent implementation at some point in your implementation in case a superclass also overrides this method.

Parameters
childViewControllerA reference to the removed child view controller.

Reimplemented in CeresEngine::UISplitViewController.

◆ getChildViewControllers()

const Vector< UIViewControllerPtr > & CeresEngine::UIViewController::getChildViewControllers ( ) const
inlinenoexcept

An array of view controllers that are hierarchical children of the view controller.

You can add or remove child view controllers by using this property. When you do, the addChildViewController() or removeFromParentViewController() method gets called accordingly.

◆ getNextResponder()

UIResponder * CeresEngine::UIViewController::getNextResponder ( ) const
finalvirtual

The next responder after this one, or nil if it has none.

The next responder must be an object that inherits, directly or indirectly, from UIResponder.

Reimplemented from CeresEngine::UIResponder.

◆ getParentViewController()

UIViewController * CeresEngine::UIViewController::getParentViewController ( ) const
inlinenoexcept

The immediate ancestor view controller of the view controller.

The value of this property is nullptr if the view controller has no parent view controller, such as if the view controller is a window's content view controller.

◆ getRepresentedObject()

const Any & CeresEngine::UIViewController::getRepresentedObject ( ) const
inlinenoexcept

The object whose value is presented in the receiver’s primary view.

◆ getView()

UIView * CeresEngine::UIViewController::getView ( ) const

The view controller’s primary view.

If this property’s value is not already set when you access it, the view controller invokes the loadView() method. That method, in turn, will create a new view for the controller.

If you want to set a view controller’s view directly, set this property’s value immediately after creating the view controller.

◆ instantiateView()

void CeresEngine::UIViewController::instantiateView ( )
private

◆ isViewLoaded()

bool CeresEngine::UIViewController::isViewLoaded ( ) const
inlinenoexcept

A Boolean value indicating whether the view controller’s view is loaded into memory.

◆ loadView()

virtual void CeresEngine::UIViewController::loadView ( UIView view)
protectedvirtual

Instantiates a view.

This method is called by the system, and is exposed in this class so you can override it to add behavior or replace the created view.

Do not call this method. If you require this method to be called, access the view property.

Do not invoke this method from other objects unless you take care to avoid redundant invocations. The default implementation of the loadView method handles redundant invocations correctly, but a view controller subclass might not. To be safe, other objects should instead access a view controller’s view property.

Reimplemented in CeresEngine::TUIViewController< TViewType, TParentViewControllerType >, CeresEngine::TUIViewController< UISplitView >, and CeresEngine::TUIViewController< UIViewport >.

◆ removeChildViewController() [1/2]

void CeresEngine::UIViewController::removeChildViewController ( const UIViewControllerPtr childViewController)
inline

A convenience method for removing a child view controller from the childViewControllers array.

Parameters
childViewControllerThe view controller to be removed from the childViewControllers array.

◆ removeChildViewController() [2/2]

void CeresEngine::UIViewController::removeChildViewController ( UIViewController childViewController)

A convenience method for removing a child view controller from the childViewControllers array.

Parameters
childViewControllerThe view controller to be removed from the childViewControllers array.

◆ removeFromParentViewController()

void CeresEngine::UIViewController::removeFromParentViewController ( )

Removes the called view controller from its parent view controller.

Use this method to remove a child view controller from its parent view controller.

◆ setRepresentedObject()

void CeresEngine::UIViewController::setRepresentedObject ( const Any representedObject)

The object whose value is presented in the receiver’s primary view.

◆ willAppear()

virtual void CeresEngine::UIViewController::willAppear ( )
inlinevirtual

Called after the view controller’s view has been loaded into memory is about to be added to the view hierarchy in the window.

You can override this method to perform tasks prior to a view controller’s view getting added to view hierarchy, such as setting the view’s highlight color. This method is called when:

  • The view is about to be added to the view hierarchy of the view controller
  • The view controller’s window is about to become visible, such as coming to the front or becoming unhidden

If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ willDisappear()

virtual void CeresEngine::UIViewController::willDisappear ( )
inlinevirtual

Called when the view controller’s view is about to be removed from the view hierarchy in the window.

You can override this method to perform tasks that are to precede the disappearance of the view controller’s view, such as stopping a continuous animation that you started in response to the viewDidAppear method call. This method is called when:

  • The view is about to be removed from the view hierarchy of the window.
  • The view is about to be hidden or obscured, such as in the case of a view controller whose parent is a tab view controller and the user switched to another tab.
  • The window is being closed.

If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

◆ willLayout()

virtual void CeresEngine::UIViewController::willLayout ( )
inlinevirtual

Called just before the layout method of the view controller's view is called.

You can override this method to perform tasks to precede the layout of the view controller’s view. If you override this method, call this method on super at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

Member Data Documentation

◆ mChildViewControllers

Vector<UIViewControllerPtr> CeresEngine::UIViewController::mChildViewControllers
private

An array of view controllers that are hierarchical children of the view controller.

You can add or remove child view controllers by using this property. When you do, the addChildViewController() or removeFromParentViewController() method gets called accordingly.

◆ mParentViewController

UIViewController* CeresEngine::UIViewController::mParentViewController
private

The immediate ancestor view controller of the view controller.

The value of this property is nullptr if the view controller has no parent view controller, such as if the view controller is a window's content view controller.

◆ mRepresentedObject

Any CeresEngine::UIViewController::mRepresentedObject
private

The object whose value is presented in the receiver’s primary view.

◆ mView

UIViewPtr CeresEngine::UIViewController::mView = nullptr
private

The view controller’s primary view.

If this property’s value is not already set when you access it, the view controller invokes the loadView() method. That method, in turn, will create a new view for the controller.

If you want to set a view controller’s view directly, set this property’s value immediately after creating the view controller.

◆ mViewLoaded

bool CeresEngine::UIViewController::mViewLoaded = false
private

A Boolean value indicating whether the view controller’s view is loaded into memory.


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