Files
Upsilon/apps/apps_container.cpp
Émilie Feral 30f37213d1 [escher][apps] add pointer to the container from the app and a method to
access the toolbox from the container

Change-Id: I89eb598b4a7d317d70d5a1f13b79422d35438d68
2016-11-10 10:55:15 +01:00

43 lines
865 B
C++

#include "apps_container.h"
extern "C" {
#include <assert.h>
}
AppsContainer::AppsContainer() :
Container(),
m_homeApp(this),
m_graphApp(this, &m_context),
m_probabilityApp(this),
m_calculationApp(this, &m_context),
m_context(Context())
{
}
int AppsContainer::numberOfApps() {
return k_numberOfApps;
}
App * AppsContainer::appAtIndex(int index) {
static App * apps[] = {
&m_homeApp,
&m_graphApp,
&m_probabilityApp,
&m_calculationApp,
};
assert(sizeof(apps)/sizeof(apps[0]) == k_numberOfApps);
assert(index >= 0 && index < k_numberOfApps);
return apps[index];
}
ToolBoxController * AppsContainer::toolBoxController() {
return &m_toolBoxController;
}
bool AppsContainer::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Event::F1) {
switchTo(appAtIndex(0));
return true;
}
return false;
}