test & implement ui_view life-cycle behaviors.
Change-Id: Id6847f6dc8f24dd721360c5c4c6c08ffe81398e6
this->set_content(content, "Page1");
}
+ //on_unload() will be called when this page1 is requested to be hidden.
+ void on_unload()
+ {
+ ui_standard_view::on_unload();
+ }
+
+ //on_destroy() will be called when this page1 is requested to be destroyed.
+ void on_destroy()
+ {
+ ui_standard_view::on_destroy();
+ }
+
+ //on_deactivate() will be called when this page1 is requested to be deactivated.
+ void on_deactivate()
+ {
+ ui_standard_view::on_deactivate();
+ }
+
+ //on_activate() will be called when this page1 is requested to be activated.
+ void on_activate()
+ {
+ ui_standard_view::on_activate();
+ }
+
public:
page1() : ui_standard_view("page1") {}
~page1() {}
*/
class page2: public ui_standard_view
{
+private:
+ Evas_Object *content;
+ Elm_Button *left_title_btn;
+ Elm_Button *right_title_btn;
+
protected:
void on_load()
{
//Arguments: content, title, subtitle, title left button, title right button
this->set_content(content, "Page2", NULL, left_title_btn, right_title_btn);
+
+ this->content = content;
+ this->left_title_btn = left_title_btn;
+ this->right_title_btn = right_title_btn;
+ }
+ void on_unload()
+ {
+ ui_standard_view::on_unload();
+
+ evas_object_del(this->content);
+ evas_object_del(this->left_title_btn);
+ evas_object_del(this->right_title_btn);
}
public:
- page2() : ui_standard_view("page2") {}
+ page2() : ui_standard_view("page2")
+ {
+ }
~page2() {}
};
#ifndef _UI_MOBILE_VIEWMANAGER_H_
#define _UI_MOBILE_VIEWMANAGER_H_
-#include <app.h>
#include "../ui_base_viewmanager.h"
#include "ui_view.h"
#include "ui_standard_view.h"
#define Elm_Conformant Evas_Object
#endif
+#include <app.h>
#include "../interface/ui_iface_viewmanager.h"
#include "ui_base_overlay.h"
#include "ui_base_key_listener.h"
* @brief View destroy state.
*
* @note When this view is on destroyed by popping or by somehow, destroy will be triggered. Most of the cases, you can free your personal resources for
- * the view because this view instance will be totally freed at the end of destroy. Be awre that you must not request any view functions on this
+ * the view because this view instance will be totally freed at the end of destroy. Be aware that you must not request any view functions on this
* state.
*/
virtual void on_destroy();
void ui_app::on_resume()
{
- this->impl->get_viewmgr()->activate();
+// this->impl->get_viewmgr()->activate();
}
void ui_app::on_control(app_control_h app_control)
void ui_app::on_terminate()
{
+ delete(this);
}
ui_app::ui_app(const char *pkg, const char *locale_dir)
{
ui_base_viewmgr *viewmgr = static_cast<ui_base_viewmgr*>(data);
delete(viewmgr);
- //FIXME: Window is destroyed. Terminate Application!
- //ui_app_exit();
},
this->viewmgr);
bool ui_base_viewmgr_impl::activate()
{
this->activate_top_view();
-
- //FIXME: Necessary??
- ui_base_view *view = this->viewmgr->get_last_view();
- view->on_activate();
-
evas_object_show(this->win);
return true;
//FIXME: based on the profile, we should app to go behind or terminate.
if (true)
{
- ui_base_view *view = this->viewmgr->get_last_view();
- if (view) view->on_deactivate();
evas_object_lower(this->win);
}
else
{
- //FIXME: exit app
- //ui_app_exit();
+ delete(this->viewmgr);
}
return true;
ui_base_view *pview = this->viewmgr->get_view(this->viewmgr->get_view_count() - 2);
ui_base_view *view = this->viewmgr->get_last_view();
- //In case, if view doesn't have transition effect
+ //In case, if view doesn't have any transition effects.
if (!strcmp(view->get_transition_style(), "none"))
{
this->viewmgr->pop_view_finished(pview);
{
this->impl->term();
delete(this->impl);
+ ui_app_exit();
}
bool ui_base_viewmgr::activate()
{
if (!ui_iface_viewmgr::activate()) return false;
-
this->impl->activate();
return true;
bool ui_base_viewmgr::deactivate()
{
if (!ui_iface_viewmgr::deactivate()) return false;
-
this->impl->deactivate();
return true;
void ui_iface_view_impl::on_destroy()
{
+
}
ui_iface_view_impl::ui_iface_view_impl(ui_iface_view *view, const char *name)
static bool event_block; //Event block on view transition. This value should be configurable by system.
list<ui_iface_view *> view_list; //View list.
bool activated; //Activated status of this viewmgr.
+ bool destroying; //True, if viewmgr is on destroying.
public:
bool connect_view(ui_iface_view *view);
}
ui_iface_viewmgr_impl::ui_iface_viewmgr_impl(ui_iface_viewmgr* viewmgr)
- : activated(false)
+ : activated(false), destroying(false)
{
ui_iface_viewmgr_impl::inst = viewmgr;
}
ui_iface_viewmgr_impl::~ui_iface_viewmgr_impl()
{
//Terminate views
- for (VIEW_RITR it = this->view_list.rbegin(); it != this->view_list.rend(); it++)
+ this->destroying = EINA_TRUE;
+ for (VIEW_RITR ritr = this->view_list.rbegin(); ritr != this->view_list.rend(); ritr++)
{
- ui_iface_view *view = *it;
- view->on_deactivate();
- view->on_unload();
+ ui_iface_view *view = *ritr;
+ if ((view->get_state() != UI_VIEW_STATE_DEACTIVATE) &&
+ (view->get_state() != UI_VIEW_STATE_UNLOAD))
+ {
+ view->on_deactivate();
+ }
+ if (view->get_state() != UI_VIEW_STATE_UNLOAD)
+ {
+ view->on_unload();
+ }
view->on_destroy();
delete (view);
}
+ this->destroying = EINA_FALSE;
//FIXME: Window is destroyed. Terminate Application!
ui_app_exit();
this->view_list.push_back(view);
- if (!view->get_content())
- {
- view->on_load();
- }
+ //If view manager is not activated yet, don't load view.
+ if (!this->is_activated()) return view;
+ view->on_load();
view->on_deactivate();
if (this->view_list.size() != 1)
bool ui_iface_viewmgr_impl::remove_view(ui_iface_view *view)
{
+ if (this->destroying) return false;
+
this->view_list.remove(view);
this->disconnect_view(view);
if (this->activated) return false;
if (this->get_view_count() == 0) return false;
this->activated = true;
+ ui_iface_view *view = this->get_last_view();
+ view->on_load();
+ view->on_deactivate();
+ view->on_activate();
return true;
}
{
if (!this->activated) return false;
this->activated = false;
+ ui_iface_view *view = this->get_last_view();
+
+ if ((view->get_state() != UI_VIEW_STATE_DEACTIVATE) &&
+ (view->get_state() != UI_VIEW_STATE_UNLOAD))
+ {
+ view->on_deactivate();
+ }
+ if (view->get_state() != UI_VIEW_STATE_UNLOAD)
+ {
+ view->on_unload();
+ }
+
return true;
}