Class · aurore

aurore::Activity

On this page
aurore/core/activity.hpp
#include <aurore/core/activity.hpp>

class aurore::Activity

Description

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.

Constructors 3

Activity()

An activity whose content comes from createContentView() when it is pushed.

activity.hpp:48
Activity(View *view)

An activity showing view (it then owns it).

activity.hpp:50
virtual ~Activity()

Frees the content view (at the end of the frame).

activity.hpp:52

Functions 28

void 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.

activity.hpp:63
View * swapContentView(View *view)

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.

activity.hpp:68
virtual View * createContentView()

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).

activity.hpp:85
virtual void onContentAvailable()

Called when the content view is created, so that you can get the references to the activity views (by id).

activity.hpp:91
View * getContentView()

The root of the activity's views, nullptr before it is set.

activity.hpp:94
unsigned getContentGeneration() const

Counts the content views set (setContentView): what views were bound to (AURORE_BIND) is looked up again in a content made anew.

activity.hpp:100
View * getView(std::string id)

Returns the view with the corresponding id, or nullptr if it hasn't been found in the activity.

activity.hpp:106
void 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.

activity.hpp:114
void unregisterModel(const std::string &name)
DataModel * getModel(const std::string &name)
void 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).

activity.hpp:122
virtual float getShowAnimationDuration(TransitionAnimation animation)

Returns the duration of the activity show / hide animation.

activity.hpp:127
virtual bool isTranslucent()

Is this activity translucent, aka can we see the activities under it in the stack?

activity.hpp:133
virtual void willAppear(bool resetState = false)

Passed on to the content view when the activity is shown.

activity.hpp:136
virtual void willDisappear(bool resetState = false)

Passed on to the content view when the activity is hidden or popped.

activity.hpp:138
virtual void onPause()

Another activity was pushed over this one.

activity.hpp:140
virtual void onResume()

The activity over this one was popped: it is on top again.

activity.hpp:142
void setInFadeAnimation(bool translucent)

If set to true, will force the activity to be translucent.

activity.hpp:148
void show(std::function< void(void)> cb,bool animate,float animationDuration)

Shows the activity with a fade in animation, or no animation at all.

activity.hpp:153
void hide(std::function< void(void)> cb,bool animate,float animationDuration)

Hides the activity with a fade in animation, or no animation at all.

activity.hpp:158
bool isHidden()

Whether hide() hid the content view.

activity.hpp:161
ActionIdentifier 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.

activity.hpp:177
ActionIdentifier registerAction(AuroreKeyCombination key,const ActionListener &actionListener,bool allowRepeating = false)

The same on a keyboard key, on the content view.

activity.hpp:180
void unregisterAction(ActionIdentifier identifier)

Unregisters an action with the given identifier on the content view.

Must be called after the content view is set.

activity.hpp:187
ActionIdentifier 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.

activity.hpp:197
void onWindowSizeChanged()

Resizes the activity to the window (resizeToFitWindow()).

activity.hpp:200
View * getDefaultFocus()

The view the focus goes to when the activity is shown: the content view's default.

activity.hpp:203
void setAlpha(float alpha)

The content view's opacity.

activity.hpp:206

Read from Aurore's headers by Doxygen at each build · library/include