#include "ui_controller.h"
-
static Evas_Object*
create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, appdata_s *ad)
{
}
-
-
-
class app_controller4: public ui_controller
{
private:
appdata_s *ad;
- Evas_Object *content;
-
- static void page_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
-
- appdata_s *ad = static_cast<appdata_s *>(data);
-
- }
public:
- app_controller4(appdata_s *ad) :
- ad(ad), content(NULL)
+ app_controller4(appdata_s *ad)
+ : ad(ad)
{
}
~app_controller4()
{
- LOGE("controller 4");
}
void load()
{
- LOGE("view 4 button create");
- ui_view *view = this->get_view();
- Evas_Object *btn = elm_button_add(view->get_base());
- elm_object_text_set(btn, "Page 4");
- view->set_content(btn);
+ //Initialize contents.
+
+ ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
- evas_object_smart_callback_add(btn, "clicked", page_clicked_cb, this->ad);
+ //Create a main content.
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 4",
+ //Prev Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->pop_view();
+ },
+ //Next Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->deactivate();
+ }, this->ad);
- this->content = btn;
+ //Arguments: content, title
+ view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
+ view->set_title_badge("999+");
}
void unload()
{
- LOGE("controller4");
- evas_object_del(this->content);
+ //You could destroy the content here for save memory.
ui_view *view = this->get_view();
- view->set_content(NULL);
- }
-
- void active()
- {
- LOGE("controller4");
+ Evas_Object *content = view->set_content(NULL);
+ evas_object_del(content);
}
- void inactive()
- {
- LOGE("controller4");
- }
-
- void destroy()
- {
- LOGE("controller4");
- }
};
+
class app_controller3: public ui_controller
{
private:
appdata_s *ad;
- Evas_Object *content;
-
- static void page_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
-
- appdata_s *ad = static_cast<appdata_s *>(data);
-
- //View 4
-
- app_controller4 *controller = new app_controller4(ad);
- ad->viewmgr->push_view(new ui_basic_view(controller));
-
- }
public:
- app_controller3(appdata_s *ad) :
- ad(ad), content(NULL)
+ app_controller3(appdata_s *ad)
+ : ad(ad)
{
}
~app_controller3()
{
- LOGE("controller 3");
}
void load()
{
- ui_view *view = this->get_view();
- Evas_Object *btn = elm_button_add(view->get_base());
- elm_object_text_set(btn, "Page 3");
- view->set_content(btn);
+ //Initialize contents.
- evas_object_smart_callback_add(btn, "clicked", page_clicked_cb, this->ad);
+ ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
- this->content = btn;
+ //Create a main content.
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 3",
+ //Prev Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->pop_view();
+ },
+ //Next Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ app_controller4 *controller = new app_controller4(ad);
+ ad->viewmgr->push_view(new ui_basic_view(controller));
+ }, this->ad);
+
+ //Arguments: content, title, subtitle, icon, title left button, title right button
+ view->set_content(content, "Title", "Subtitle", NULL, NULL, NULL);
}
void unload()
{
- LOGE("controller3");
- evas_object_del(this->content);
+ //You could destroy the content here for save memory.
ui_view *view = this->get_view();
- view->set_content(NULL);
- }
-
- void active()
- {
- LOGE("controller3");
- }
-
- void inactive()
- {
- LOGE("controller3");
- }
-
- void destroy()
- {
- LOGE("controller3");
+ Evas_Object *content = view->set_content(NULL);
+ evas_object_del(content);
}
};
+
class app_controller2: public ui_controller
{
private:
appdata_s *ad;
- Evas_Object *content;
-
- static void next_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- //View 2
- app_controller2 *controller = new app_controller2(ad);
- ad->viewmgr->push_view(new ui_basic_view(controller));
- }
- static void prev_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
- }
public:
- app_controller2(appdata_s *ad) :
- ad(ad), content(NULL)
+ app_controller2(appdata_s *ad)
+ : ad(ad)
{
}
-
~app_controller2()
{
}
void load()
{
+ //Initialize contents.
+
ui_basic_view *view = dynamic_cast<ui_basic_view *>(ui_controller::get_view());
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 2", prev_clicked_cb, next_clicked_cb, this->ad);
+ //Create a main content.
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 2",
+ //Prev Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->pop_view();
+ },
+ //Next Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ app_controller3 *controller = new app_controller3(ad);
+ ad->viewmgr->push_view(new ui_basic_view(controller));
+ }, this->ad);
+
+ //Title left button
Evas_Object *left_title_btn = elm_button_add(view->get_base());
elm_object_text_set(left_title_btn, "Cancel");
+ //Title right button
Evas_Object *right_title_btn = elm_button_add(view->get_base());
elm_object_text_set(right_title_btn, "Done");
- view->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
- this->content = content;
+ //Arguments: content, title, subtitle, icon, title left button, title right button
+ view->set_content(content, "Title Buttons", NULL, NULL, left_title_btn, right_title_btn);
}
void unload()
{
- evas_object_del(this->content);
+ //You could destroy the content here for save memory.
ui_view *view = this->get_view();
- view->set_content(NULL);
+ Evas_Object *content = view->set_content(NULL);
+ evas_object_del(content);
}
};
private:
appdata_s *ad;
- static void next_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- //View 2
- app_controller2 *controller = new app_controller2(ad);
- ad->viewmgr->push_view(new ui_basic_view(controller));
- }
- static void prev_clicked_cb(void *data, Evas_Object *obj, void *event_info)
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
- }
-
public:
- app_controller1(appdata_s *ad) :
- ad(ad)
+ app_controller1(appdata_s *ad)
+ : ad(ad)
{
}
-
~app_controller1()
{
}
void load()
{
+ //Initialize contents.
+
ui_basic_view *view = dynamic_cast<ui_basic_view *>(ui_controller::get_view());
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1", prev_clicked_cb, next_clicked_cb, this->ad);
+
+ //Create a main content.
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1",
+ //Prev Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->deactivate();
+ },
+ //Next Button
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ app_controller2 *controller = new app_controller2(ad);
+ ui_basic_view *view = new ui_basic_view(controller, "page2");
+ ad->viewmgr->push_view(view);
+ }, this->ad);
+
view->set_content(content, "Title");
}
void unload()
{
- ui_view *view = ui_controller::get_view();
- Evas_Object *btn = view->set_content(NULL);
- evas_object_del(btn);
+ //You could destroy the content here for save memory.
+ ui_view *view = this->get_view();
+ Evas_Object *content = view->set_content(NULL);
+ evas_object_del(content);
}
};
//View 1
{
app_controller1 *controller = new app_controller1(ad);
- ad->viewmgr->push_view(new ui_basic_view(controller));
+ ad->viewmgr->push_view(new ui_basic_view(controller, "page1"));
}
/*
//View 2
{
app_controller2 *controller = new app_controller2(ad);
- ad->viewmgr->push_view(new ui_basic_view(controller));
+ ad->viewmgr->push_view(new ui_basic_view(controller, "page2"));
}
-
//View 3
{
app_controller3 *controller = new app_controller3(ad);
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
elm_language_set(locale);
free(locale);
+
return;
}
return true;
}
-ui_basic_view::ui_basic_view(ui_controller *controller) :
- ui_view(controller), layout(NULL)
+ui_basic_view::ui_basic_view(ui_controller *controller, const char *name)
+ : ui_view(controller, name), layout(NULL)
{
}
ui_view::load();
}
-void ui_basic_view ::unload()
+void ui_basic_view::unload()
{
this->destroy_layout();
ui_view::unload();
}
Evas_Object *
-ui_basic_view::set_content(Evas_Object *content)
+ui_basic_view::set_content(Evas_Object *content, const char *title)
{
Evas_Object *pcontent = ui_view::set_content(content);
{
elm_object_part_content_unset(this->layout, "elm.swallow.content");
elm_object_part_content_set(this->layout, "elm.swallow.content", content);
+ elm_object_part_text_set(this->layout, "elm.text.title", title);
}
else
{
return pcontent;
}
-
-Evas_Object *
-ui_basic_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *title_left_btn, Evas_Object *title_right_btn)
+bool ui_basic_view::set_subtitle(const char *text)
{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "elm.text.subtitle", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,subtitle,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,subtitle,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
- Evas_Object *pcontent = this->set_content(content);
+bool ui_basic_view::set_icon(Evas_Object *icon)
+{
+ if (this->layout)
+ {
+ elm_object_part_content_set(this->layout, "elm.swallow.icon", icon);
+ if (icon) elm_object_signal_emit(this->layout, "elm,state,icon,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,icon,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+bool ui_basic_view::set_title_left_btn(Evas_Object *title_left_btn)
+{
if (this->layout)
{
- if (title) elm_object_part_text_set(this->layout, "elm.text.title", title);
- if (subtitle) elm_object_part_text_set(this->layout, "elm.text.subtitle", subtitle);
if (title_left_btn)
{
elm_object_style_set(title_left_btn, "naviframe/title_left");
- //FIXME:
+ //FIXME: naviframe/title_left -> tizen_view/title_left
//elm_object_style_set(title_left_btn, "tizen_view/title_left");
- elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn);
}
+ elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn);
+ if (title_left_btn) elm_object_signal_emit(this->layout, "elm,state,title_left_btn,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_left_btn,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool
+ui_basic_view::set_title_right_btn(Evas_Object *title_right_btn)
+{
+ if (this->layout)
+ {
if (title_right_btn)
{
- LOGE("AHHHHHHHHHHHHH");
elm_object_style_set(title_right_btn, "naviframe/title_right");
- //FIXME:
+ //FIXME: naviframe/title_right -> tizen_view/title_right
//elm_object_style_set(title_left_btn, "tizen_view/title_right");
- elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn);
}
+ elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn);
+ if (title_right_btn) elm_object_signal_emit(this->layout, "elm,state,title_right_btn,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_right_btn,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool ui_basic_view::set_title_badge(const char *text)
+{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "title_badge", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,title_badge,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_badge,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool
+ui_basic_view::set_title(const char *text)
+{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "elm.text.title", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,title,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+Evas_Object *
+ui_basic_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn,
+ Evas_Object *title_right_btn)
+{
+ Evas_Object *pcontent = this->set_content(content);
+
+ if (this->layout)
+ {
+ this->set_title(title);
+ this->set_subtitle(subtitle);
+ this->set_icon(icon);
+ this->set_title_left_btn(title_left_btn);
+ this->set_title_right_btn(title_right_btn);
}
else
{
return pcontent;
}
-
void unload();
public:
- ui_basic_view(ui_controller *controller);
+ ui_basic_view(ui_controller *controller, const char *name = NULL);
virtual ~ui_basic_view();
Evas_Object *get_base()
return this->layout;
}
- Evas_Object *set_content(Evas_Object *content);
- Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle = NULL, Evas_Object *title_left_btn = NULL, Evas_Object *title_right_btn = NULL);
+ Evas_Object *set_content(Evas_Object *content, const char *title = NULL);
+ Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, Evas_Object *title_right_btn);
+ bool set_title_badge(const char *text);
+ bool set_subtitle(const char *text);
+ bool set_icon(Evas_Object *icon);
+ bool set_title_left_btn(Evas_Object *title_left_btn);
+ bool set_title_right_btn(Evas_Object *title_right_btn);
+ bool set_title(const char *text);
};
}
ui_controller::get_view()
{
ui_view_base *view = ui_controller_base::get_view();
- if (!view)
- {
- LOGI("view ahhhhh =%p", view);
- return NULL;
- }
- LOGI("view =%p", view);
+ if (!view) return NULL;
return dynamic_cast<ui_view *>(view);
}
{
//TODO: ?
}
- LOGI("view =%p", view);
this->view = view;
}
using namespace efl;
-ui_view::ui_view(ui_controller *controller) :
- ui_view_base(controller)
+ui_view::ui_view(ui_controller *controller, const char *name) :
+ ui_view_base(controller, name)
{
}
class ui_view: public ui_view_base
{
public:
- ui_view(ui_controller *controller);
+ ui_view(ui_controller *controller, const char *name = NULL);
virtual ~ui_view();
virtual Evas_Object *set_content(Evas_Object *content);
- //virtual Evas_Object *set_content(Evas_Object *content, const char *title);
virtual Evas_Object *get_base();
protected:
virtual void load();
-
- /* protected:
-
- virtual void set_event_block(bool block)
- {
- //TO DO: Implement below to proper way.
- //if (block)
- // evas_object_freeze_events_set(elm_object_part_content_get(this->content, "swallow.view.this"), EINA_FALSE);
- //else
- // evas_object_freeze_events_set(ui_view_content_get(view_mgr->anim.view_this), EINA_TRUE);
- } */
};
+
}
#endif /* UI_VIEW */
void ui_view_base::load()
{
this->state = UI_VIEW_STATE_LOAD;
- if (this->content)
- return;
- if (!this->controller)
- return;
+ if (this->content) return;
+ if (!this->controller) return;
this->controller->load();
}
void ui_view_base::unload()
{
this->state = UI_VIEW_STATE_UNLOAD;
- if (!this->content)
- return;
- if (!this->controller)
- return;
+ if (!this->content) return;
+ if (!this->controller) return;
this->controller->unload();
}
void ui_view_base::active()
{
this->state = UI_VIEW_STATE_ACTIVE;
- if (!this->controller)
- return;
+ if (!this->controller) return;
this->controller->active();
}
void ui_view_base::inactive()
{
this->state = UI_VIEW_STATE_INACTIVE;
- if (!this->controller)
- return;
+ if (!this->controller) return;
this->controller->inactive();
}
void ui_view_base::pause()
{
this->state = UI_VIEW_STATE_PAUSE;
- if (!this->content)
- return;
- if (state != UI_VIEW_STATE_ACTIVE)
- return;
- if (!this->controller)
- return;
+ if (!this->content) return;
+ if (state != UI_VIEW_STATE_ACTIVE) return;
+ if (!this->controller) return;
this->controller->pause();
}
void ui_view_base::resume()
{
this->state = UI_VIEW_STATE_ACTIVE;
- if (state != UI_VIEW_STATE_PAUSE)
- return;
- if (!this->content)
- return;
- if (!this->controller)
- return;
+ if (state != UI_VIEW_STATE_PAUSE) return;
+ if (!this->content) return;
+ if (!this->controller) return;
this->controller->resume();
}
void ui_view_base::destroy()
{
- if (!this->controller)
- return;
+ if (!this->controller) return;
this->controller->destroy();
}
-ui_view_base::ui_view_base(T content, ui_controller_base *controller) :
- content(content), controller(controller), name(string()), style(string()), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), event_block(
- false)
+ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name)
+ : content(content), controller(controller), name(string(name ? name : "")), style(string()), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), event_block(
+ false)
{
- if (!content)
- this->state = UI_VIEW_STATE_UNLOAD;
- else
- this->state = UI_VIEW_STATE_LOAD;
+ if (!content) this->state = UI_VIEW_STATE_UNLOAD;
+ else this->state = UI_VIEW_STATE_LOAD;
controller->set_view(this);
}
-ui_view_base::ui_view_base(ui_controller_base *controller = NULL) :
- ui_view_base(NULL, controller)
+ui_view_base::ui_view_base(ui_controller_base *controller, const char *name)
+ : ui_view_base(NULL, controller, name)
{
this->state = UI_VIEW_STATE_UNLOAD;
}
+ui_view_base::ui_view_base(const char *name)
+ : ui_view_base(NULL, name)
+{
+
+}
+
ui_view_base::~ui_view_base()
{
this->viewmgr->remove_view(this);
- if (this->controller)
- delete (this->controller);
+ if (this->controller) delete (this->controller);
}
ui_controller_base*
*/
//Constructor
- ui_view_base(T content, ui_controller_base *controller);
+ ui_view_base(T content, ui_controller_base *controller, const char *name);
///Constructor for initializing with controller.
- ui_view_base(ui_controller_base *controller);
+ ui_view_base(ui_controller_base *controller, const char *name = NULL);
+ ///Constructor for initializing with name.
+ ui_view_base(const char *name = NULL);
///Destructor for terminating view.
virtual ~ui_view_base();
{
ui_viewmgr *viewmgr = static_cast<ui_viewmgr*>(data);
delete(viewmgr);
+
+ //FIXME: Window is destroyed. Terminate Application!
+ //ui_app_exit();
}
Evas_Object *
ui_viewmgr::create_conformant(Evas_Object *win)
{
Evas_Object *conform = elm_conformant_add(win);
- if (!conform)
- return NULL;
+ if (!conform) return NULL;
evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, conform);
ui_viewmgr::create_base_layout(Evas_Object *conform)
{
Evas_Object *layout = elm_layout_add(conform);
- if (!layout)
- {
- return NULL;
- }
+ if (!layout) return NULL;
elm_layout_theme_set(layout, "layout", "application", "default");
elm_object_content_set(conform, layout);
return layout;
}
-ui_viewmgr::ui_viewmgr(const char *pkg) :
- ui_viewmgr_base()
+ui_viewmgr::ui_viewmgr(const char *pkg)
+ : ui_viewmgr_base()
{
if (!pkg)
{
//Set window rotation
if (elm_win_wm_rotation_supported_get(this->win))
{
- int rots[4] = { 0, 90, 180, 270 };
+ int rots[4] =
+ { 0, 90, 180, 270 };
elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4);
}
- evas_object_smart_callback_add(this->win, "delete,request", win_delete_request_cb, this);
+ //Window is requested to delete.
+ evas_object_smart_callback_add(this->win, "delete,request",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_viewmgr *viewmgr = static_cast<ui_viewmgr*>(data);
+ delete(viewmgr);
+
+ //FIXME: Window is destroyed. Terminate Application!
+ //ui_app_exit();
+ },
+ this);
//Conformant: Make this configurable.
this->conform = this->create_conformant(this->win);
//Set Indicator properties
elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW);
elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_TRANSPARENT);
-
elm_win_autodel_set(this->win, EINA_TRUE);
}
bool ui_viewmgr::activate()
{
+ ui_viewmgr_base :: activate();
+
elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
ui_view *view = dynamic_cast<ui_view *>(this->get_last_view());
if (content == this->base_layout)
{
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
- } else
+ }
+ else
{
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
}
bool ui_viewmgr::deactivate()
{
- //TODO: based on the profile, we could hide window or destroy window.
- evas_object_lower(this->win);
+ ui_viewmgr_base ::deactivate();
+
+ //FIXME: based on the profile, we should app to go behind or terminate.
+ if (true)
+ {
+ evas_object_lower(this->win);
+ }
+ else
+ {
+ //FIXME: exit app
+ //ui_app_exit();
+ }
+
return true;
}
if (content == this->base_layout)
{
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
- } else
+ }
+ else
{
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
}
{
ui_viewmgr_base::push_view(view);
- if (this->get_view_count() == 1) return view;
+ //Don't prepare yet if viewmgr is not activated.
+ if (!this->is_activated()) return view;
elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
if (content == this->base_layout)
{
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
- } else
+ }
+ else
{
LOGE("view->base = %p", view->get_base());
elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
Evas_Object * create_conformant(Evas_Object *win);
Evas_Object * create_base_layout(Evas_Object *conform);
- /*
- static void
- _appear_finished_cb(void *data, Evas_Object *obj, const char *emision, const char *source)
- {
- LOGI("CALLED");
- ui_viewmgr *viewmgr = (ui_viewmgr *)data;
-
- viewmgr->_push_view_finished(viewmgr->anim.view_this);
-
- //TODO: Appear finish callback call?
-
- elm_object_part_content_set(viewmgr->base_layout, "swallow.back", obj);
-
- //TODO: Thaw event?
-
- viewmgr->anim.view_this = NULL;
- viewmgr->anim.view_other = NULL;
- viewmgr->animation_ongoing = false;
- viewmgr->to_show = false;
- }
-
- static void
- _appear_effect(ui_viewmgr *viewmgr)
- {
- LOGI("CALLED");
- Evas_Object *layout;
-
- //TODO: send a style intead of NULL value below.
- layout = _create_layout(viewmgr->base_layout, NULL);
- elm_object_part_content_set(viewmgr->base_layout, "swallow.front", layout);
- evas_object_show(layout);
-
- if (!viewmgr->anim.view_this->get_content())
- {
- //TODO: Content load here?
- }
-
- if (viewmgr->anim.view_this->get_content())
- {
- //TODO: Freeze event?
- elm_object_part_content_set(layout,"swallow.view.this",
- viewmgr->anim.view_this->get_content());
- //View appear start.
- }
-
- if (viewmgr->anim.view_other)
- {
- if (viewmgr->anim.view_other->get_content())
- {
- //TODO: Freeze event?
- elm_object_part_content_set(layout,"swallow.view.other",
- viewmgr->anim.view_other->get_content());
- //View disappear start.
- }
- }
- //ui_view_base<Evas_Object *> *appear_view = viewmgr->view_list.back();
-
- // delete old layout if any
- _delete_layout(elm_object_part_content_get(viewmgr->base_layout, "swallow.back"));
-
- // start the animation
- elm_object_signal_emit(layout, "appear,effect", "elm");
- elm_object_signal_callback_add(layout, "appear,effect,finished", "*", _appear_finished_cb, viewmgr);
- }
-
- static void
- _disappear_finished_cb(void *data, Evas_Object *obj, const char *emision, const char *source)
- {
- LOGI("CALLED");
- ui_viewmgr *viewmgr = (ui_viewmgr *)data;
-
- ui_view_base<Evas_Object *> *appear_view = viewmgr->view_list.back();
- //appear_view->active();
-
- //viewmgr->_pop_view_finished(appear_view);
-
- elm_object_part_content_set(viewmgr->base_layout, "swallow.back", obj);
- //evas_object_freeze_events_set(elm_object_part_content_get(obj, "swallow.view.this"), EINA_FALSE);
- //evas_object_freeze_events_set(elm_object_part_content_get(obj, "swallow.view.other"), EINA_FALSE);
-
- //destroy the view
- // remove it from the view stack
- //viewmgr->view_list.pop_back();
- elm_object_part_content_unset(obj,"swallow.view.this");
- viewmgr-> _pop_view_finished(viewmgr->anim.view_this);
- //delete(viewmgr->anim.view_this);
- //Do it in unload method?
- evas_object_del(viewmgr->anim.view_this->get_content());
-
- viewmgr->anim.view_this = NULL;
- viewmgr->anim.view_other = NULL;
- viewmgr->animation_ongoing = false;
- }
-
- static void
- _disappear_effect(ui_viewmgr* viewmgr)
- {
- LOGI("CALLED");
- Evas_Object *layout;
-
- //TODO: send a style intead of NULL value below.
- layout = _create_layout(viewmgr->base_layout, NULL);
- elm_object_part_content_set(viewmgr->base_layout, "swallow.front", layout);
- evas_object_show(layout);
-
- //TODO: check the content is?
- //TODO: event freeze?
-
- elm_object_part_content_set(layout,"swallow.view.this",
- viewmgr->anim.view_this->get_content());
- elm_object_part_content_set(layout,"swallow.view.other",
- viewmgr->anim.view_other->get_content());
-
- //TODO: check is it right?
- //ui_view_base<Evas_Object *> *appear_view = viewmgr->view_list.back();
-
- //view appear start
- //elm_object_part_content_set(layout,"swallow.view.this", appear_view->get_content());
-
- //evas_object_freeze_events_set(ui_view_content_get(view_mgr->anim.view_this), EINA_TRUE);
- //evas_object_freeze_events_set(ui_view_content_get(view_mgr->anim.view_other), EINA_TRUE);
-
- // delete old layout if any
- _delete_layout(elm_object_part_content_get(viewmgr->base_layout, "swallow.back"));
-
- elm_object_signal_emit(layout, "disappear,effect", "elm");
- elm_object_signal_callback_add(layout, "disappear,effect,finished", "*", _disappear_finished_cb, viewmgr);
- }
-
- static void _animation_cb(void *data)
- {
- ui_viewmgr *viewmgr = (ui_viewmgr *)data;
- viewmgr->animation_job = NULL;
-
- if (viewmgr->animation_ongoing) {
- viewmgr->animation_job = ecore_job_add(_animation_cb, viewmgr);
- return;
- } else {
- viewmgr->animation_ongoing = true;
- }
-
- viewmgr->anim.view_this = viewmgr->view_list.back();
-
- //TODO: fix below hard coding :(
-
- //if (viewmgr->anim.view_this->get_state() == 3)
- if (viewmgr->to_show)
- {
- std::list<ui_view_base<Evas_Object *>*>::iterator li;
-
- for (li = viewmgr->view_list.begin(); li!= viewmgr->view_list.end(); li++)
- {
- ui_view *view = (ui_view *)*li;
- if (view->get_state() == 2)
- {
- printf("Find active view %p\n", view);
- viewmgr->anim.view_other = view;
- break;
- }
- }
-
- _appear_effect(viewmgr);
- }
- else
- {
- std::list<ui_view_base<Evas_Object *>*>::reverse_iterator li;
-
- int i = 0;
- for (li = viewmgr->view_list.rbegin(); li!= viewmgr->view_list.rend(); li++)
- {
- i++;
- ui_view *view = (ui_view *)*li;
- //if (view->get_state() == 2)
- if (i == 2)
- {
- printf("Find view %p\n", view);
- viewmgr->anim.view_other = view;
- break;
- }
- }
-
- if (viewmgr->anim.view_other)
- _disappear_effect(viewmgr);
- }
- }
- */
public:
ui_viewmgr(const char *pkg);
~ui_viewmgr();
bool ui_viewmgr_base::_connect_view(ui_view_base *view)
{
- LOGE("Conneted view with viewmgr");
if (view->viewmgr)
{
LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
bool ui_viewmgr_base::_disconnect_view(ui_view_base *view)
{
- if (!view->viewmgr)
- return false;
+ if (!view->viewmgr) return false;
view->viewmgr = NULL;
return true;
}
void ui_viewmgr_base::_set_event_block(ui_view_base *view, bool block)
{
- if (!this->event_block)
- return;
+ if (!this->event_block) return;
view->set_event_block(block);
}
return true;
}
-ui_viewmgr_base::ui_viewmgr_base() :
- event_block(true)
+ui_viewmgr_base::ui_viewmgr_base()
+ : event_block(true), activated(false)
{
//TODO: Initialize ?
}
//previous page to be current active.
auto nx = std::prev(this->view_list.end(), 2);
ui_view_base *pview = *nx;
- LOGE("pview = %p", pview);
pview->load();
pview->inactive();
this->_set_event_block(pview, true);
for (typename std::list<ui_view_base*>::iterator it = this->view_list.begin(); it != this->view_list.end(); it++)
{
- if (view == *it)
- return idx;
+ if (view == *it) return idx;
++idx;
}
ui_viewmgr_base::get_last_view()
{
int cnt = this->get_view_count();
- LOGE("cnt = %d", cnt);
return this->get_view(cnt - 1);
}
+
+bool ui_viewmgr_base::activate()
+{
+ if (this->activated) return false;
+ this->activated = true;
+ return true;
+}
+
+bool ui_viewmgr_base::deactivate()
+{
+ if (!this->activated) return false;
+ this->activated = false;
+ return true;
+}
//TODO: change name to view_stack
std::list<ui_view_base*> view_list; //view list.
bool event_block; //event block on view transition. This value should be configurable by system.
+ bool activated; //activated status of this viewmgr.
/**
* @brief link a given view to this viewmgr.
///Destructor. Delete all contained views.
virtual ~ui_viewmgr_base();
- //Activate a viewmgr. Implement this body to activate a viewmgr.
- virtual bool activate() = 0;
+ //Activate a viewmgr.
+ virtual bool activate();
- //Deactivate a viewmgr. Implement this body to deactivate a viewmgr.
- virtual bool deactivate() = 0;
+ //Deactivate a viewmgr.
+ virtual bool deactivate();
/**
* @brief Push a new view into the viewmgr stack.
return this->view_list.size();
}
+ /**
+ * @brief Return the active status of viewmgr.
+ *
+ * @return active status
+ *
+ */
+ bool is_activated()
+ {
+ return this->activated;
+ }
+
/**
* @brief Return a list of views which this viewmgr has.
*