}
Evas_Object*
-create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, appdata_s *ad)
+create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb)
{
char buf[128];
Elm_Grid *grid;
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 1.0);
elm_object_text_set(btn, "Prev");
- evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, ad);
+ evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, NULL);
evas_object_show(btn);
elm_box_pack_end(box, btn);
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 1.0);
elm_object_text_set(btn, "Next");
- evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, ad);
+ evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, NULL);
evas_object_show(btn);
elm_box_pack_end(box, btn);
}
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)
+create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb)
{
Elm_Grid *grid;
Elm_Box *box;
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 1.0);
elm_object_text_set(btn, "Prev");
- evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, ad);
+ evas_object_smart_callback_add(btn, "clicked", prev_btn_clicked_cb, NULL);
evas_object_show(btn);
elm_box_pack_end(box, btn);
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 1.0);
elm_object_text_set(btn, "Next");
- evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, ad);
+ evas_object_smart_callback_add(btn, "clicked", next_btn_clicked_cb, NULL);
evas_object_show(btn);
elm_box_pack_end(box, btn);
static void create_base_gui(appdata_s *ad)
{
- //FIXME: Hide this creation.
- ad->viewmgr = new ui_viewmgr(PACKAGE);
-
- create_page1(ad);
-
- ad->viewmgr->activate();
+ create_page1();
+ UI_VIEWMGR->activate();
}
int
appdata_s *ad = {0,};
ad = static_cast<appdata_s *>(calloc(1, sizeof(appdata_s)));
+
+ //FIXME: Hide this creation.
+ ui_viewmgr *viewmgr = new ui_viewmgr(PACKAGE);
+
create_base_gui(ad);
elm_run();
ui_viewmgr *viewmgr;
} appdata_s;
-Evas_Object *create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, appdata_s *ad);
-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);
+Evas_Object *create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb);
+Evas_Object *create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb);
Elm_Toolbar *create_toolbar(Evas_Object *parent, const char *style);
*/
class page1: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
+ UI_VIEWMGR->deactivate();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page2(ad);
- },
- this->ad);
-
+ create_page2();
+ });
this->set_content(content, "Title");
}
public:
- page1(appdata_s *ad) : ui_view("page1"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page1()
- {
- }
+ page1() : ui_view("page1") {}
+ ~page1() {}
};
-void create_page1(appdata_s *ad)
+void create_page1()
{
- new page1(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page1());
}
*/
class page10: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
{
Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
//Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page11(ad);
- },
- this->ad);
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ UI_VIEWMGR->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ create_page11();
+ });
this->set_content(content, "Title");
this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
}
{
Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
//Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page11(ad);
- },
- this->ad);
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ UI_VIEWMGR->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ create_page11();
+ });
this->set_content(content, "Title");
this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
}
public:
- page10(appdata_s *ad) : ui_view("page10"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page10()
- {
- }
+ page10() : ui_view("page10") {}
+ ~page10() {}
};
-void create_page10(appdata_s *ad)
+void create_page10()
{
- new page10(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page10());
}
*/
class page11: public ui_controller
{
-private:
- appdata_s *ad;
-
-public:
- page11(appdata_s *ad)
- : ad(ad)
- {
- ad->viewmgr->push_view(new ui_view(this, "page11"));
- }
-
- ~page11()
- {
- }
-
+protected:
void on_load()
{
ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
this->on_rotate(view->get_degree());
}
{
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
//Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page12(ad);
- },
- this->ad);
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ UI_VIEWMGR->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ create_page12();
+ });
view->set_content(content, "Title");
view->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
}
{
Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
//Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page12(ad);
- },
- this->ad);
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ UI_VIEWMGR->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ create_page12();
+ });
view->set_content(content, "Title");
view->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
}
}
-
+public:
+ page11()
+ {
+ UI_VIEWMGR->push_view(new ui_view(this, "page11"));
+ }
+ ~page11() {}
};
-void create_page11(appdata_s *ad)
+void create_page11()
{
- new page11(ad);
+ //page 11 controller
+ page11 *controller = new page11();
}
LOGE("Item (%s) is selected", elm_object_item_text_get(it));
}
-class page12: public ui_controller
+class page12: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
- //Initialize contents.
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 12<br>(Menu Popup)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 12<br>(Menu Popup)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page13(ad);
- },
- this->ad);
-
- view->set_content(content, "Title");
- }
-
-public:
- page12(appdata_s *ad)
- : ad(ad)
- {
- ad->viewmgr->push_view(new ui_view(this, "page12"));
- }
+ create_page13();
+ });
- ~page12()
- {
+ this->set_content(content, "Title");
}
void on_menu(ui_menu *menu)
menu->set_content(ctxpopup);
}
+
+public:
+ page12() {}
+ ~page12() {}
};
-void create_page12(appdata_s *ad)
+void create_page12()
{
- new page12(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page12());
}
class page13: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page14(ad);
- },
- this->ad);
+ create_page14();
+ });
+
this->set_content(content, "Title");
//Title Right button
}
public:
- page13(const char *name, appdata_s *ad)
- : ui_view(name), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page13()
- {
- }
+ page13() : ui_view("page13") {}
+ ~page13() {}
void create_popup()
{
}
};
-void create_page13(appdata_s *ad)
+void create_page13()
{
- new page13("page13", ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page13());
}
*/
class page14: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page15(ad);
- },
- this->ad);
+ create_page15();
+ });
this->set_content(content, "Title");
}
public:
- page14(appdata_s *ad) : ui_view("page14"), ad(ad)
+ page14() : ui_view("page14")
{
this->set_transition_style("blend");
- ad->viewmgr->push_view(this);
- }
-
- ~page14()
- {
}
+ ~page14() {}
};
-void create_page14(appdata_s *ad)
+void create_page14()
{
- new page14(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page14());
}
*/
class page15: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
- },
- this->ad);
+ UI_VIEWMGR->deactivate();
+ });
this->set_content(content, "Title");
}
public:
- page15(appdata_s *ad) : ui_view("page15"), ad(ad)
+ page15() : ui_view("page15")
{
this->set_transition_style("none");
- ad->viewmgr->push_view(this);
- }
-
- ~page15()
- {
}
+ ~page15(){}
};
-void create_page15(appdata_s *ad)
+void create_page15()
{
- new page15(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page15());
}
*/
class page2: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Create a main content.
Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 2",
- //Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page3(ad);
- },
- this->ad);
+ //Prev Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ UI_VIEWMGR->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ create_page3();
+ });
//Title left button
Elm_Button *left_title_btn = elm_button_add(this->get_base());
}
public:
- page2(appdata_s *ad) : ui_view("page2"), ad(ad)
- {
- //Push this view in viewmgr.
- ad->viewmgr->push_view(this);
- }
-
- ~page2()
- {
- }
+ page2() : ui_view("page2") {}
+ ~page2() {}
};
-void create_page2(appdata_s *ad)
+void create_page2()
{
- new page2(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page2());
}
*/
class page3: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page4(ad);
- },
- this->ad);
+ create_page4();
+ });
//Arguments: content, title, subtitle, title left button, title right button
this->set_content(content, "Title", "Subtitle", NULL, NULL);
}
public:
- page3(appdata_s *ad) : ui_view("page3"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page3()
- {
- }
+ page3() : ui_view("page3") {}
+ ~page3() {}
};
-void create_page3(appdata_s *ad)
+void create_page3()
{
- new page3(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page3());
}
*/
class page4: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page5(ad);
- },
- this->ad);
+ create_page5();
+ });
//Arguments: content, title
this->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
}
public:
- page4(appdata_s *ad) : ui_view("page4"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page4()
- {
- }
+ page4() : ui_view("page4") {}
+ ~page4() {}
};
-void create_page4(appdata_s *ad)
+void create_page4()
{
- new page4(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page4());
}
*/
class page5: public ui_base_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page6(ad);
- },
- this->ad);
+ create_page6();
+ });
this->set_content(content);
this->set_indicator(UI_VIEW_INDICATOR_HIDE);
}
public:
- page5(appdata_s *ad) : ui_base_view("page5"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page5()
- {
- }
+ page5() : ui_base_view("page5") {}
+ ~page5() {}
};
-void create_page5(appdata_s *ad)
+void create_page5()
{
- new page5(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page5());
}
*/
class page6: public ui_view
{
-private:
- appdata_s *ad;
-
protected:
void on_load()
{
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page7(ad);
- },
- this->ad);
+ create_page7();
+ });
//Arguments: content, title
this->set_content(content, "Title with toolbar");
}
public:
- page6(appdata_s *ad) : ui_view("page6"), ad(ad)
- {
- ad->viewmgr->push_view(this);
- }
-
- ~page6()
- {
- }
+ page6() : ui_view("page6") {}
+ ~page6() {}
};
-void create_page6(appdata_s *ad)
+void create_page6()
{
- /* A example for view class extension instead of using controller class. */
- new page6(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page6());
}
*/
class page7: public ui_view
{
-private:
- appdata_s *ad;
-
public:
- page7(appdata_s *ad) : ui_view("page7"), ad(ad)
+ page7() : ui_view("page7")
{
- //FIXME: It will be deleted or change to other way :(
- // We don't have any way to support it now.
- this->set_viewmgr(ad->viewmgr);
-
//Create a main content.
Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 7<br>(Navigationbar style)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page8(ad);
- },
- this->ad);
+ create_page8();
+ });
- //Don't delete view's content when this view poped.
+ //FIXME: Don't delete view's content when this view poped.
this->set_removable_content(false);
this->set_content(content, "Title with toolbar");
Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "navigationbar");
this->set_toolbar(toolbar);
- ad->viewmgr->push_view(this);
- }
-
- ~page7()
- {
}
+ ~page7() {}
};
-void create_page7(appdata_s *ad)
+void create_page7()
{
- new page7(ad);
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page7());
}
*/
class page8: public ui_controller
{
-private:
- appdata_s *ad;
-
-public:
- page8(appdata_s *ad)
- : ad(ad)
- {
- /* ui_view(controller, identity name).
- Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page8"));
- }
- ~page8()
- {
- }
-
+protected:
void on_load()
{
//Initialize contents.
ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 8",
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 8<br>(Controller Inheritance)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page9(ad);
- },
- this->ad);
+ create_page9();
+ });
view->set_content(content, "Title");
}
+public:
+ page8()
+ {
+ UI_VIEWMGR->push_view(new ui_view(this, "page8"));
+ }
+ ~page8() {}
};
-void create_page8(appdata_s *ad)
+void create_page8()
{
- new page8(ad);
+ page8 *controller = new page8();
}
*/
class page9: public ui_controller
{
-private:
- appdata_s *ad;
-
public:
- page9(appdata_s *ad)
- : ad(ad)
+ page9()
{
ui_view *view = new ui_view(this, "page9");
- //FIXME: It will be deleted or change to other way :(
- // We don't have any way to support it now.
- view->set_viewmgr(ad->viewmgr);
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 9<br>(Content Preloading)",
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 9<br>(Controller Inheritance + Content Preloading)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
+ UI_VIEWMGR->pop_view();
},
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page10(ad);
- },
- this->ad);
+ create_page10();
+ });
//Don't delete view's content when this view poped.
view->set_removable_content(false);
view->set_content(content, "Title");
- ad->viewmgr->push_view(view);
- }
- ~page9()
- {
+
+ UI_VIEWMGR->push_view(view);
}
+ ~page9() {}
};
-void create_page9(appdata_s *ad)
+void create_page9()
{
- new page9(ad);
+ page9 *controller = new page9();
}
namespace efl_viewmgr
{
class ui_menu;
+class ui_viewmgr;
class ui_controller: public ui_base_controller
{
+ friend class ui_viewmgr;
+ friend class ui_view;
+
+protected:
+ virtual void on_menu(ui_menu *menu);
+
public:
virtual ~ui_controller();
- virtual void on_menu(ui_menu *menu);
};
}
{
friend class ui_menu;
friend class ui_key_listener;
+ friend class ui_controller;
private:
Elm_Layout *layout; //Base layout for view
protected:
virtual void on_load();
virtual void on_unload();
- virtual void on_menu();
+ bool on_menu_pre();
+ void on_menu_post();
+ virtual void on_menu(ui_menu *menu);
virtual void unload_content();
virtual void set_event_block(bool block);
virtual void on_back();
Elm_Button *unset_title_right_btn();
Elm_Toolbar *unset_toolbar();
- virtual Evas_Object *get_base()
- {
- if (!this->layout)this->create_layout();
- return this->layout;
- }
+ virtual Evas_Object *get_base();
Elm_Button *get_title_left_btn()
{
#include "ui_key_listener.h"
#include "ui_viewmgr.h"
#include "ui_menu.h"
+
+#define UI_VIEWMGR dynamic_cast<ui_viewmgr *>(efl_viewmgr::ui_base_viewmgr::get_instance())
* limitations under the License.
*
*/
-#ifndef UI_BASIC_VIEWMGR_H
-#define UI_BASIC_VIEWMGR_H
+#ifndef UI_VIEWMGR_H
+#define UI_VIEWMGR_H
#include <Elementary.h>
#include "../ui_viewmanager_base.h"
{
class ui_view;
+class ui_viewmgr;
class ui_viewmgr: public ui_base_viewmgr
{
friend class ui_view;
+ friend class ui_controller;
public:
ui_viewmgr(const char *pkg);
-
virtual ~ui_viewmgr();
};
*/
class ui_base_controller: public viewmgr::ui_iface_controller
{
-public:
- ///Destructor.
- virtual ~ui_base_controller();
-
- /**
- * @brief Return a view which is matched with controller
- *
- * @return The view which is matched with controller
- *
- * @note User can set a controller 2 ways, 1. send a controller instance when view created,
- * 2. call set_view() method with controller instance.
- *
- * @see set_view()
- */
-
- ui_base_view *get_view();
+ friend class ui_base_view;
+protected:
/** @brief load callback.
*
* @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called.
*/
virtual bool on_back() { return true; }
+public:
+ ///Destructor.
+ virtual ~ui_base_controller();
+
+ /**
+ * @brief Return a view which is matched with controller
+ *
+ * @return The view which is matched with controller
+ *
+ * @note User can set a controller 2 ways, 1. send a controller instance when view created,
+ * 2. call set_view() method with controller instance.
+ *
+ * @see set_view()
+ */
+
+ ui_base_view *get_view();
};
}
--- /dev/null
+#ifndef UI_SINGLETON_UTIL_H
+#define UI_SINGLETON_UTIL_H
+
+#include <cassert>
+
+using namespace std;
+
+namespace efl_viewmgr
+{
+
+template<typename T>
+class singleton
+{
+private:
+ static T* inst;
+
+public:
+ singleton();
+ virtual ~singleton();
+ inline static T* get_instance();
+};
+
+template<typename T> T* singleton<T>::inst = NULL;
+
+template<typename T>
+singleton<T>::singleton()
+{
+ assert(!singleton::inst);
+
+ T* pT = reinterpret_cast<T*>(1);
+
+ //Derived Class - Singleton class
+ int offset = reinterpret_cast<int>(pT) - reinterpret_cast<int>(reinterpret_cast<singleton<T>*>(pT));
+ singleton::inst = reinterpret_cast<T*>((reinterpret_cast<int>(this) + offset));
+}
+
+template<typename T>
+singleton<T>::~singleton()
+{
+ assert(singleton::inst);
+ singleton::inst = NULL;
+}
+
+template<typename T>
+T* singleton<T>::get_instance()
+{
+ assert(singleton::inst);
+ return singleton::inst;
+}
+
+}
+
+#endif /* UI_SINGLETON_UTIL_H_ */
*
* @warning viewmgr will remove all containing views when it's destroyed.
*/
-class ui_base_viewmgr: public viewmgr::ui_iface_viewmgr
+class ui_base_viewmgr: public singleton<ui_base_viewmgr>, public viewmgr::ui_iface_viewmgr
{
friend class ui_base_view;
#endif
#define LOG_TAG "UI_VIEWMGR"
+#include "ui_base_singleton.h"
#include "ui_base_viewmgr.h"
#include "ui_base_controller.h"
#include "ui_base_view.h"
#include "ui_base_key_listener.h"
#include "ui_base_popup.h"
+
+
+#define UI_BASE_VIEWMGR efl_viewmgr::ui_base_viewmgr::get_instance()
return this->view;
}
-public:
- ///Constructor.
- ui_iface_controller() :
- view(NULL)
- {
- }
-
- ///Destructor.
- virtual ~ui_iface_controller()
- {
- }
-
/** @brief load callback.
*
* @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called.
* @note When current view is on landscape mode.
*/
virtual void on_landscape() = 0;
+
+
+public:
+ ///Constructor.
+ ui_iface_controller() :
+ view(NULL)
+ {
+ }
+
+ ///Destructor.
+ virtual ~ui_iface_controller()
+ {
+ }
};
}
ui_iface_controller* set_controller(ui_iface_controller *controller);
public:
- //FIXME: This method for support a use case that user make content, view same time.
- void set_viewmgr(ui_iface_viewmgr *viewmgr)
- {
- this->viewmgr = viewmgr;
- }
-
/** @brief This is a constructor for initializing this view resources.
*
* @param controller view life-cycle controller interface.
void ui_key_listener::extend_event_proc(ui_base_view *view, Evas_Event_Key_Down *ev)
{
if (strcmp(ev->keyname, KEY_MENU) && strcmp(ev->keyname, KEY_MENU2)) return;
- dynamic_cast<ui_view *>(view)->on_menu();
+ ui_view *v = dynamic_cast<ui_view *>(view);
+ if (!v->on_menu_pre()) return;
+ v->on_menu((ui_menu*)(v->get_menu()));
+ v->on_menu_post();
}
bool ui_key_listener::init()
{
if (!ui_base_key_listener::init()) return false;
-
if (!evas_object_key_grab(this->key_grabber, KEY_MENU, 0, 0, EINA_FALSE))
{
LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU);
Elm_Win *ui_menu::get_window()
{
- ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->view->get_viewmgr());
+ ui_viewmgr *viewmgr = UI_VIEWMGR;
if (!viewmgr)
{
LOGE("Viewmgr is null?? menu(%p)", this);
using namespace efl_viewmgr;
using namespace viewmgr;
-#define MY_VIEWMGR dynamic_cast<ui_viewmgr *>(this->get_viewmgr())
#define MY_CONTROLLER dynamic_cast<ui_controller *>(this->get_controller())
static void content_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
}
//Set software back key, if it's needed
- ui_viewmgr *viewmgr = MY_VIEWMGR;
- if (viewmgr->need_soft_key())
+ ui_viewmgr *viewmgr = UI_VIEWMGR;
+ if (viewmgr && viewmgr->need_soft_key())
{
Elm_Button *prev_btn = elm_button_add(layout);
this->destroy_layout();
}
-void ui_view::on_menu()
+bool ui_view::on_menu_pre()
{
if (this->menu && this->menu->is_activated())
{
this->menu->deactivate();
- return;
+ return false;
+ }
+ if (!this->menu)
+ {
+ this->menu = new ui_menu(this);
}
if (this->get_controller())
{
- if (!this->menu)
- {
- this->menu = new ui_menu(this);
- }
MY_CONTROLLER->on_menu(this->menu);
+ return false;
}
+ return true;
+}
+void ui_view::on_menu(ui_menu *menu)
+{
+}
+
+void ui_view::on_menu_post()
+{
if (this->menu && this->menu->get_content())
{
this->menu->activate();
this->menu->on_landscape();
}
}
+
+Evas_Object *ui_view::get_base()
+{
+ if (!this->layout) this->create_layout();
+ return this->layout;
+}
Elm_Win *ui_base_popup::get_window()
{
- ui_base_viewmgr *viewmgr = dynamic_cast<ui_base_viewmgr *>(this->view->get_viewmgr());
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
if (!viewmgr)
{
LOGE("Viewmgr is null?? menu(%p)", this);
using namespace viewmgr;
#define MY_CONTROLLER dynamic_cast<ui_base_controller *>(this->get_controller())
-#define MY_VIEWMGR dynamic_cast<ui_base_viewmgr *>(this->get_viewmgr())
typedef list<ui_base_popup*>::reverse_iterator popup_ritr;
void ui_base_view::connect_popup(ui_base_popup *popup)
Evas_Object *ui_base_view::get_base()
{
- ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
if (!viewmgr)
{
return NULL;
Evas_Object *ui_base_view ::get_parent()
{
- ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
if (!viewmgr)
{
LOGE("Failed to get a viewmgr");
ui_iface_view::set_indicator(indicator);
- ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return;
+ }
if (!viewmgr->is_activated()) return;
return;
}
}
- MY_VIEWMGR->pop_view();
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return;
+ }
+ viewmgr->pop_view();
}
void ui_base_view::on_rotate(int degree)
int ui_base_view::get_degree()
{
- ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
if (!viewmgr)
{
LOGE("Failed to get a viewmgr");
}
ui_base_viewmgr::ui_base_viewmgr(const char *pkg, ui_base_key_listener *key_listener)
- : ui_iface_viewmgr(), key_listener(key_listener), transition_style("default")
+ : singleton(), ui_iface_viewmgr(), key_listener(key_listener), transition_style("default")
{
if (!pkg)
{