|
Aurore
A Switch-like interface for your app, on every screen
|
#include <aurore/core/activity.hpp>
Public Member Functions | |
| Activity () | |
| An activity whose content comes from createContentView() when it is pushed. | |
| Activity (View *view) | |
An activity showing view (it then owns it). | |
| virtual | ~Activity () |
| Frees the content view (at the end of the frame). | |
| void | setContentView (View *view) |
| View * | swapContentView (View *view) |
| virtual View * | createContentView () |
| virtual void | onContentAvailable () |
| View * | getContentView () |
| The root of the activity's views, nullptr before it is set. | |
| unsigned | getContentGeneration () const |
| View * | getView (std::string id) |
| void | registerModel (const std::string &name, DataModel *model) |
| void | unregisterModel (const std::string &name) |
| DataModel * | getModel (const std::string &name) |
| void | resizeToFitWindow () |
| virtual float | getShowAnimationDuration (TransitionAnimation animation) |
| virtual bool | isTranslucent () |
| virtual void | willAppear (bool resetState=false) |
| Passed on to the content view when the activity is shown. | |
| virtual void | willDisappear (bool resetState=false) |
| Passed on to the content view when the activity is hidden or popped. | |
| virtual void | onPause () |
| Another activity was pushed over this one. | |
| virtual void | onResume () |
| The activity over this one was popped: it is on top again. | |
| void | setInFadeAnimation (bool translucent) |
| void | show (std::function< void(void)> cb, bool animate, float animationDuration) |
| void | hide (std::function< void(void)> cb, bool animate, float animationDuration) |
| bool | isHidden () |
| Whether hide() hid the content view. | |
| ActionIdentifier | registerAction (const std::string &hintText, enum ControllerButton button, const ActionListener &actionListener, bool hidden=false, bool allowRepeating=false, enum Sound sound=SOUND_NONE) |
| ActionIdentifier | registerAction (AuroreKeyCombination key, const ActionListener &actionListener, bool allowRepeating=false) |
| The same on a keyboard key, on the content view. | |
| void | unregisterAction (ActionIdentifier identifier) |
| ActionIdentifier | registerExitAction (enum ControllerButton button=aurore::BUTTON_START) |
| void | onWindowSizeChanged () |
| Resizes the activity to the window (resizeToFitWindow()). | |
| View * | getDefaultFocus () |
| The view the focus goes to when the activity is shown: the content view's default. | |
| void | setAlpha (float alpha) |
| The content view's opacity. | |
An activity is a "screen" of your app in which the library adds the UI components. The app is made of a stack of activities, each activity containing a views tree.
Application::pushActivity() takes the activity and deletes it when it is popped; the activity owns its content view.
| aurore::Activity::Activity | ( | ) |
An activity whose content comes from createContentView() when it is pushed.
| aurore::Activity::Activity | ( | View * | view | ) |
An activity showing view (it then owns it).
|
virtual |
Frees the content view (at the end of the frame).
|
virtual |
Called when the activity is created. Should return the activity content view, if any.
Returning nullptr means the content is not known when the activity is created.
You can use View::createFromXMLFile(), View::createFromXMLResource() and View::createFromXMLString() to load a view from respectively an XML file path, an XML name in the resources/xml romfs directory and an XML string.
The CONTENT_FROM_XML_FILE, CONTENT_FROM_XML_RES, CONTENT_FROM_XML_STR macros are made to make this process simpler: just use them in the public block of your activity header and it will override createContentView() with the right code for you.
The onContentAvailable() method will be called once the content has been created, so that you can get the references to the activity views (by id).
|
inline |
Counts the content views set (setContentView): what views were bound to (AURORE_BIND) is looked up again in a content made anew.
| View * aurore::Activity::getContentView | ( | ) |
The root of the activity's views, nullptr before it is set.
| View * aurore::Activity::getDefaultFocus | ( | ) |
The view the focus goes to when the activity is shown: the content view's default.
| DataModel * aurore::Activity::getModel | ( | const std::string & | name | ) |
|
virtual |
Returns the duration of the activity show / hide animation.
| View * aurore::Activity::getView | ( | std::string | id | ) |
Returns the view with the corresponding id, or nullptr if it hasn't been found in the activity.
| void aurore::Activity::hide | ( | std::function< void(void)> | cb, |
| bool | animate, | ||
| float | animationDuration | ||
| ) |
Hides the activity with a fade in animation, or no animation at all.
| bool aurore::Activity::isHidden | ( | ) |
Whether hide() hid the content view.
|
virtual |
Is this activity translucent, aka can we see the activities under it in the stack?
|
inlinevirtual |
Called when the content view is created, so that you can get the references to the activity views (by id).
|
inlinevirtual |
Another activity was pushed over this one.
|
inlinevirtual |
The activity over this one was popped: it is on top again.
| void aurore::Activity::onWindowSizeChanged | ( | ) |
Resizes the activity to the window (resizeToFitWindow()).
| ActionIdentifier aurore::Activity::registerAction | ( | AuroreKeyCombination | key, |
| const ActionListener & | actionListener, | ||
| bool | allowRepeating = false |
||
| ) |
The same on a keyboard key, on the content view.
| ActionIdentifier aurore::Activity::registerAction | ( | const std::string & | hintText, |
| enum ControllerButton | button, | ||
| const ActionListener & | actionListener, | ||
| bool | hidden = false, |
||
| bool | allowRepeating = false, |
||
| enum Sound | sound = SOUND_NONE |
||
| ) |
Registers an action with the given parameters on the content view. The listener will be fired when the user presses the key.
The listener should return true if the action was consumed, false otherwise. The sound will only be played if the listener returned true.
A hidden action will not show up in the bottom-right hints.
Must be called after the content view is set.
Returns the identifier for the action, so it can be unregistered later on. Returns ACTION_NONE if the action was not registered.
| ActionIdentifier aurore::Activity::registerExitAction | ( | enum ControllerButton | button = aurore::BUTTON_START | ) |
Registers an action to exit the application with the default button BUTTON_START.
Must be called after the content view is set.
Returns the identifier for the action, so it can be unregistered later on. Returns ACTION_NONE if the action was not registered.
| void aurore::Activity::registerModel | ( | const std::string & | name, |
| DataModel * | model | ||
| ) |
A data model for the XML bindings of this activity's views (bind="text: name.key"), looked up before the application's (Application::registerModel). Register it before the content view is set (in the constructor); the model must outlive the activity.
| void aurore::Activity::resizeToFitWindow | ( | ) |
Resizes the activity to fit the window. Called when the activity is created and when the window is resized (Switch dock counts as window resize).
| void aurore::Activity::setAlpha | ( | float | alpha | ) |
The content view's opacity.
| void aurore::Activity::setContentView | ( | View * | view | ) |
Sets the content view of this activity, aka the root view of the tree.
When the activity is pushed, setContentView() is automatically called with the result of createContentView(). As such, you should override createContentView() if you want to use XML in your activity.
| void aurore::Activity::setInFadeAnimation | ( | bool | translucent | ) |
If set to true, will force the activity to be translucent.
| void aurore::Activity::show | ( | std::function< void(void)> | cb, |
| bool | animate, | ||
| float | animationDuration | ||
| ) |
Shows the activity with a fade in animation, or no animation at all.
Sets the content view as setContentView() does, but gives the previous one back instead of deleting it: detached from the activity, still "appeared" (no willDisappear), for the caller to put back or delete.
| void aurore::Activity::unregisterAction | ( | ActionIdentifier | identifier | ) |
Unregisters an action with the given identifier on the content view.
Must be called after the content view is set.
| void aurore::Activity::unregisterModel | ( | const std::string & | name | ) |
|
virtual |
Passed on to the content view when the activity is shown.
|
virtual |
Passed on to the content view when the activity is hidden or popped.