SceneController¶
- class
A logical grouping of views, that together comprise a scene.
A Scene is a group of views that together represent a UI. The scene enables you to hide, show and repaint all the views at once.
You should use the scene to represent a complete UI that takes up a full screen. Your application can have multiple scenes, that you can switch between to navigate in your app.
Adding views to a scene
When you create a scene (constructing the object instance), you need to add the views to it. You do this assigning the relevant view by calling the addView method, for every view.
When a view is added to a scene, the scene are now in charge of controlling the views state. It is the scene that handles repaints and visibility states.
Like views, scenes are constructed in
hidden
state.Changing scenes
A scene is shown on the display by calling it show method. This triggers the callback set be setShowCallback, and enables you to provide your scene’s views with the data to be displayed.
When you wish to hide or navigate to another view, you must call requestDismiss. This will trigger the callback set by setDimissCallback, that must do the actual hide call. Also, this method must call show on the new scene to display.
Scene background color
Scenes have a background color, that is painted before any of the views in the scene. By default the background color is View::StandardBackgroundColor , but you can change that with the setBackground method.
Scene dimensions
A scene has display bounaries, just like views. However, these are not enforced by the scene itself. They exist to allow you to enforce restrictions on dimensions.
Public Functions
-
SceneController::
SceneController
()¶ Construct a scene that takes up the entire display.
-
SceneController::
SceneController
(const geo::Rect &rect)¶ Construct a scene with specific position and dimensions.
- Parameters
rect
-The scenes visible Rect
-
virtual void
SceneController::
addView
(const IViewALike &child)¶ Add a view to the scene.
- Parameters
child
-THe view to add to the scene
-
virtual void
SceneController::
removeView
(const IViewALike &child)¶ Remove a view from the scene.
- Parameters
child
-The view to remove from the scene
-
void
SceneController::
requestDismiss
()¶ Call the scene dismiss callback handler.
-
void
SceneController::
setBackground
(display::Color color)¶ Set the scenes background color.
-
virtual bool
SceneController::
Visible
()¶
const Get the scene’s visibility state.
-
virtual void
SceneController::
show
()¶ Show the scene.
This will trigger the setShowCallback and call
show
on all the scene’s views.
-
virtual void
SceneController::
hide
()¶ Hide the scene.
This will call the scene’s hide handler as set by setHideCallback and then call
hide
on all the scene’s views.Note: When you need to change between scenes, you should use requestDismiss - not
hide
-
virtual void
SceneController::
scheduleRepaint
()¶ Schedule repaint of the scene’s views.
-
virtual void
SceneController::
setRect
(geo::Rect rct)¶ Sets a new Rect for the scene’s.
-
virtual const mono::geo::Rect &
SceneController::
ViewRect
()¶
const Get the scene’s view rect area and offset.
- template <typename Context>
-
void mono::ui::SceneController::setShowCallback(Context * cnxt, void(Context::*)(const SceneController &) memptr)
Sets the callback handler for the
show
event.You can provide a callback to be called when the scene is about to be shown. Use this callback function to do any pre-setup of the scenes internal views.
- Parameters
cnxt
-The callback context, normally the
this
pointermemptr
-The callback method on the context class.
- template <typename Context>
-
void mono::ui::SceneController::setHideCallback(Context * cnxt, void(Context::*)(const SceneController &) memptr)
Sets the callback handler for the
hide
event.You can provide a callback to be called when the scene is about to be hidden. Use this callback function to do any post-teardown of the scenes internal views.
- Parameters
cnxt
-The callback context, normally the
this
pointermemptr
-The callback method on the context class
- template <typename Context>
-
void mono::ui::SceneController::setDismissCallback(Context * cnxt, void(Context::*)(void) memptr)
Sets the callback handler for the
dismiss
event.You can provide a callback to be called when the scene is about to be dismissed. You can use this callback to hide this scene and setup the new view to be displayed.
- Parameters
cnxt
-The callback context, normally the
this
pointermemptr
-The callback method on the context class
-