We've considered supporting controller interface.
But it turned out it's unnecesary here.
It just made ui_viewmgr complex and we couldn't find out the actual usuability.
If, it's usage is figured out, then we could revert this interface again.
Change-Id: Ie58ce01aaee8708371e2ed7e187a7910624cb6ea
SET(EXAM_NAME viewmgr_demo)
SET(EXAM_SRCS
- ../../lib/interface/ui_iface_controller.cpp
../../lib/interface/ui_iface_view.cpp
../../lib/interface/ui_iface_viewmgr.cpp
../../lib/efl/ui_base_popup.cpp
- ../../lib/efl/ui_base_controller.cpp
../../lib/efl/ui_base_view.cpp
../../lib/efl/ui_base_viewmgr.cpp
../../lib/efl/ui_base_key_listener.cpp
- ../../lib/efl/mobile/ui_controller.cpp
../../lib/efl/mobile/ui_menu.cpp
../../lib/efl/mobile/ui_view.cpp
../../lib/efl/mobile/ui_key_listener.cpp
*
*/
#include "main.h"
-#include "page15.h"
#include "page14.h"
#include "page13.h"
#include "page12.h"
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 1",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Basic View",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
{
create_page2();
});
- this->set_content(content, "Title");
+ this->set_content(content, "Page1");
}
public:
*
*/
-/** This page inherit ui_view.
- * And implement on_portait(), on_landscape() method to create portarit, landscape content.
- * This page will be created suitable content in on_portrait(), on_landscape() method.
+/** This page implements on_rotate() method to create portarit, landscape content.
+ * This page will be created suitable content in on_rotate() method.
*/
class page10: public ui_view
{
protected:
void on_load()
{
- //FIXME: Change below code to more convenient and clear way.
- if (this->get_degree() == 90 || this->get_degree() == 270)
- this->on_landscape();
- else
- this->on_portrait();
- }
-
- void on_portrait()
- {
- 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
- {
- 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);
+ this->on_rotate(this->get_degree());
}
- void on_landscape()
+ void on_rotate(int degree)
{
- 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
- {
- 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);
+ //Portrait
+ if (this->get_degree() == 0 || this->get_degree() == 180)
+ {
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Rotation",
+ //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_page11();
+ });
+ this->set_content(content, "Page 10");
+ this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
+ }
+ //Landscape
+ else
+ {
+ Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Rotation",
+ //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_page11();
+ });
+ this->set_content(content, "Page 10");
+ this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
+ }
}
-
public:
page10() : ui_view("page10") {}
~page10() {}
*
*/
-/** This page inherit ui_controller
- * And implement on_rotate() method to create portarit, landscape content.
- * This page will be created suitable content in on_rotate() method.
+
+/** This page implement on_menu() method to create ctxpopup when menu HW key clicked.
+ * This page will be created menu(ctxpopup)items in on_menu() method.
*/
-class page11: public ui_controller
+static void ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ui_view *view = static_cast<ui_view *>(data);
+ Elm_Object_Item *it = static_cast<Elm_Object_Item *>(event_info);
+ elm_ctxpopup_dismiss(obj);
+ LOGE("Item (%s) is selected", elm_object_item_text_get(it));
+}
+
+class page11: public ui_view
{
protected:
void on_load()
{
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
- this->on_rotate(view->get_degree());
+ //Create a main content.
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Menu Popup",
+ //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_page12();
+ });
+
+ this->set_content(content, "Page11");
}
- void on_rotate(int degree)
+ void on_menu(ui_menu *menu)
{
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
+ Elm_Ctxpopup *ctxpopup = elm_ctxpopup_add(menu->get_base());
+ elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Favorites", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Search", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Dialer", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Add contact", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Favorites", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Search", NULL, ctxpopup_item_select_cb, this);
+ elm_ctxpopup_item_append(ctxpopup, "Dialer", NULL, ctxpopup_item_select_cb, this);
- //Portrait
- if (view->get_degree() == 0 || view->get_degree() == 180)
- {
- 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
- {
- 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);
- }
- //Landscape
- else
- {
- 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
- {
- 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);
- }
+ menu->set_content(ctxpopup);
}
+
public:
- page11()
- {
- UI_VIEWMGR->push_view(new ui_view(this, "page11"));
- }
+ page11() {}
~page11() {}
};
void create_page11()
{
- //page 11 controller
- page11 *controller = new page11();
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page11());
}
*
*/
-
-/** This page inherit ui_controller
- * And implement on_menu() method to create ctxpopup when menu HW key clicked.
- * This page will be created menu(ctxpopup)items in on_menu() method.
+/** This page inherit ui_ui_view
+ * And make a button on right top side of title area to activate popup.
+ * The created popup has view and it will be managed by viewmgr.
*/
-static void ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
+
+static void popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
{
- ui_view *view = static_cast<ui_view *>(data);
- Elm_Object_Item *it = static_cast<Elm_Object_Item *>(event_info);
- elm_ctxpopup_dismiss(obj);
- LOGE("Item (%s) is selected", elm_object_item_text_get(it));
+ //FIXME: remove dismissed callback because this callback is called twice.
+ //It seems this is an efl or popup error, not this ui_popup nor example.
+ evas_object_smart_callback_del(obj, "dismissed", popup_dismissed_cb);
+ ui_base_popup *overlay = static_cast<ui_base_popup *>(data);
+ delete (overlay);
}
class page12: public ui_view
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 12<br>(Menu Popup)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Popup",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
create_page13();
});
- this->set_content(content, "Title");
- }
-
- void on_menu(ui_menu *menu)
- {
- Elm_Ctxpopup *ctxpopup = elm_ctxpopup_add(menu->get_base());
- elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Favorites", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Search", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Dialer", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Add contact", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Favorites", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Search", NULL, ctxpopup_item_select_cb, this);
- elm_ctxpopup_item_append(ctxpopup, "Dialer", NULL, ctxpopup_item_select_cb, this);
+ this->set_content(content, "Page12");
- menu->set_content(ctxpopup);
+ //Title Right button
+ Elm_Button *right_btn = elm_button_add(this->get_base());
+ elm_object_text_set(right_btn, "popup");
+ evas_object_smart_callback_add(right_btn, "clicked",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ page12 *view = static_cast<page12 *>(data);
+ view->create_popup();
+ },
+ this);
+ this->set_title_right_btn(right_btn);
}
public:
- page12() {}
+ page12() : ui_view("page12") {}
~page12() {}
+
+ void create_popup()
+ {
+ //FIXME: is overlay a proper name?
+ ui_base_popup *overlay = new ui_base_popup(this);
+
+ Elm_Popup *popup = elm_popup_add(overlay->get_base());
+ elm_object_text_set(popup, "This popup has only text which is set via desc set function, (This popup gets hidden when user clicks outside) here timeout of 3 sec is set.");
+ elm_popup_timeout_set(popup, 3.0);
+ evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, overlay);
+ evas_object_smart_callback_add(popup, "block,clicked",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ elm_popup_dismiss(obj);
+ },
+ NULL);
+ evas_object_smart_callback_add(popup, "timeout",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ elm_popup_dismiss(obj);
+ },
+ NULL);
+ overlay->set_content(popup);
+ overlay->activate();
+ }
};
void create_page12()
*
*/
-/** This page inherit ui_ui_view
- * And make a button on right top side of title area to activate popup.
- * The created popup has view and it will be managed by viewmgr.
+/** This example create a simple view which is inheritance ui_view.
+ * Then push in viewmgr.
*/
-
-static void popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- //FIXME: remove dismissed callback because this callback is called twice.
- //It seems this is an efl or popup error, not this ui_popup nor example.
- evas_object_smart_callback_del(obj, "dismissed", popup_dismissed_cb);
- ui_base_popup *overlay = static_cast<ui_base_popup *>(data);
- delete (overlay);
-}
-
class page13: public ui_view
{
protected:
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 13<br>(Popup)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Fade Transition",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
create_page14();
});
- this->set_content(content, "Title");
-
- //Title Right button
- Elm_Button *right_btn = elm_button_add(this->get_base());
- elm_object_text_set(right_btn, "popup");
- evas_object_smart_callback_add(right_btn, "clicked",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- page13 *view = static_cast<page13 *>(data);
- view->create_popup();
- },
- this);
- this->set_title_right_btn(right_btn);
+ this->set_content(content, "Page13");
}
public:
- page13() : ui_view("page13") {}
- ~page13() {}
-
- void create_popup()
+ page13() : ui_view("page13")
{
- //FIXME: is overlay a proper name?
- ui_base_popup *overlay = new ui_base_popup(this);
-
- Elm_Popup *popup = elm_popup_add(overlay->get_base());
- elm_object_text_set(popup, "This popup has only text which is set via desc set function, (This popup gets hidden when user clicks outside) here timeout of 3 sec is set.");
- elm_popup_timeout_set(popup, 3.0);
- evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, overlay);
- evas_object_smart_callback_add(popup, "block,clicked",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- elm_popup_dismiss(obj);
- },
- NULL);
- evas_object_smart_callback_add(popup, "timeout",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- elm_popup_dismiss(obj);
- },
- NULL);
- overlay->set_content(popup);
- overlay->activate();
+ this->set_transition_style("fade");
}
+ ~page13() {}
};
void create_page13()
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 14<br>(Fade Transition)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>None Transition",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
//Next Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
- create_page15();
+ UI_VIEWMGR->deactivate();
});
- this->set_content(content, "Title");
+ this->set_content(content, "Page14");
}
public:
page14() : ui_view("page14")
{
- this->set_transition_style("fade");
+ this->set_transition_style("none");
}
- ~page14() {}
+ ~page14(){}
};
void create_page14()
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/** This example create a simple view which is inheritance ui_view.
- * Then push in viewmgr.
- */
-class page15: public ui_view
-{
-protected:
- void on_load()
- {
- //Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 15<br>(None Transition)",
- //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
- {
- UI_VIEWMGR->deactivate();
- });
-
- this->set_content(content, "Title");
- }
-
-public:
- page15() : ui_view("page15")
- {
- this->set_transition_style("none");
- }
- ~page15(){}
-};
-
-void create_page15()
-{
- //Push this view in viewmgr.
- UI_VIEWMGR->push_view(new page15());
-}
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 2",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Title Buttons",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
elm_object_text_set(right_title_btn, "Done");
//Arguments: content, title, subtitle, title left button, title right button
- this->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
+ this->set_content(content, "Page2", NULL, left_title_btn, right_title_btn);
}
public:
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 3",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Subtitle",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
});
//Arguments: content, title, subtitle, title left button, title right button
- this->set_content(content, "Title", "Subtitle", NULL, NULL);
+ this->set_content(content, "Page3", "Subtitle", NULL, NULL);
}
public:
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 4",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Title Badge",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
});
//Arguments: content, title
- this->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
+ this->set_content(content, "Page4. We put a long title here intentionally");
this->set_title_badge("999+");
}
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 5<br>(Full View)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Full View",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 6",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Toolbar",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
});
//Arguments: content, title
- this->set_content(content, "Title with toolbar");
+ this->set_content(content, "Page6");
Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "toolbar_with_title");
this->set_toolbar(toolbar);
}
page7() : ui_view("page7")
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 7<br>(Navigationbar style)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Navigationbar",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
//FIXME: Don't delete view's content when this view poped.
this->set_removable_content(false);
- this->set_content(content, "Title with toolbar");
+ this->set_content(content, "Page7");
Elm_Toolbar *toolbar = create_toolbar(this->get_base(), "navigationbar");
this->set_toolbar(toolbar);
}
*
*/
-/** This page inherit ui_controller to show view create in controller side.
+/** This page shows how to create a view content in advance.
*/
-class page8: public ui_controller
+class page8: public ui_view
{
-protected:
- void on_load()
+public:
+ page8() : ui_view("page8")
{
- //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<br>(Controller Inheritance)",
- //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_page9();
- });
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Content Preloading",
+ //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_page9();
+ });
- view->set_content(content, "Title");
- }
-public:
- page8()
- {
- UI_VIEWMGR->push_view(new ui_view(this, "page8"));
+ //Don't delete view's content when this view poped.
+ this->set_removable_content(false);
+ this->set_content(content, "Page 8");
}
~page8() {}
};
void create_page8()
{
- page8 *controller = new page8();
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page8());
}
*
*/
-/** This page inherit ui_controller to show view create in controller side.
- * And this page create content in controller constructor time.
+/** This page inherit ui_view.
+ * And implement on_portait(), on_landscape() method to create portarit, landscape content.
+ * This page will be created suitable content in on_portrait(), on_landscape() method.
*/
-class page9: public ui_controller
+class page9: public ui_view
{
-public:
- page9()
+protected:
+ void on_load()
{
- ui_view *view = new ui_view(this, "page9");
+ //FIXME: Change below code to more convenient and clear way.
+ if (this->get_degree() == 90 || this->get_degree() == 270)
+ this->on_landscape();
+ else
+ this->on_portrait();
+ }
- //Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 9<br>(Controller Inheritance + Content Preloading)",
+ void on_portrait()
+ {
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Portrait/Landscape",
//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_page10();
- });
-
- //Don't delete view's content when this view poped.
- view->set_removable_content(false);
- view->set_content(content, "Title");
+ [](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_page10();
+ });
+ this->set_content(content, "Page 9");
+ this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
+ }
- UI_VIEWMGR->push_view(view);
+ void on_landscape()
+ {
+ Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Portrait/Landscape",
+ //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_page10();
+ });
+ this->set_content(content, "Page 9");
+ this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
}
+
+public:
+ page9() : ui_view("page9") {}
~page9() {}
};
void create_page9()
{
- page9 *controller = new page9();
+ //Push this view in viewmgr.
+ UI_VIEWMGR->push_view(new page9());
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef UI_CONTROLLER_H
-#define UI_CONTROLLER_H
-
-#include "../ui_viewmanager_base.h"
-
-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();
-};
-}
-
-#endif /* UI_CONTROLLER_H */
namespace efl_viewmgr
{
+class ui_menu;
+class ui_key_listener;
+
class ui_view: public ui_base_view
{
friend class ui_menu;
friend class ui_key_listener;
- friend class ui_controller;
private:
Elm_Layout *layout; //Base layout for view
virtual void unload_content();
virtual void set_event_block(bool block);
virtual void on_back();
-
- /** @brief This is for calling controller's rotate method.
- */
virtual void on_rotate(int degree);
-
- /** @brief This is for calling controller's portrait method.
- */
virtual void on_portrait();
-
- /** @brief This is for calling controller's landscape method.
- */
virtual void on_landscape();
public:
- ui_view(ui_controller *controller, const char *name = NULL);
ui_view(const char *name = NULL);
virtual ~ui_view();
#endif
#define LOG_TAG "UI_VIEWMGR"
-#include "ui_controller.h"
#include "ui_view.h"
#include "ui_key_listener.h"
#include "ui_viewmgr.h"
class ui_viewmgr: public ui_base_viewmgr
{
friend class ui_view;
- friend class ui_controller;
public:
ui_viewmgr(const char *pkg);
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef UI_BASE_CONTROLLER_H
-#define UI_BASE_CONTROLLER_H
-
-#include "../interface/ui_viewmanager_interface.h"
-
-namespace efl_viewmgr
-{
-
-/**
- * @class ui_base_controller
- *
- * @ingroup viewmgr
- *
- * @brief UI Controller. This is a class for handling of life-cycle events from user side.
- */
-class ui_base_controller: public viewmgr::ui_iface_controller
-{
- 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.
- * In the most cases, this callback will be triggered with this step load -> deactivate -> activate.
- */
- virtual void on_load() {}
-
- /** @brief unload callback.
- *
- * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario.
- * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view.
- * If the view content is not alive, the unload won't be called.
- * In the most cases, this callback will be triggered with this step. deactivate -> unload -> destroy
- */
- virtual void on_unload() {}
-
- /** @brief activate callback.
- *
- * @note View is on activate state after show transition is finished.
- * From whatever the state, if the view is on the screen, the activate callback will be called.
- * In the most cases, this callback will be triggered with this step. load -> deactivate -> activate
- */
- virtual void on_activate() {}
-
- /** @brief deactivate callback.
- *
- * @note View is on deactivate state. Get ready for unload. Hide transition may be triggered at this point.
- * Deactivate state is triggered on this scenario that the view is still visible but it's not interactivate with users.
- * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the deactivate state will be triggered.
- * Some UI controls such as a center popup or a menu popup blocks the view, this view may be deactivate but still visible in someway (with transparency)
- */
- virtual void on_deactivate() {}
-
- /** @brief pause callback.
- *
- * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ...
- * When Window turns to deactivate. (@see ui_base_viewmgr_base :: deactivate()).
- * If the view were deactivate or unload state, the pause won't be called.
- */
- virtual void on_pause() {}
-
- /** @brief resume callback.
- *
- * @note View is turning back to the activate state again from pause.
- * When the system allows the application turns to activate.
- * When the Window turns to activate. (@see ui_base_viewmgr :: activate())
- */
- virtual void on_resume() {}
-
- /** @brief destroy callback.
- *
- * @note When this view is on destroying by popping or deleting.
- */
- virtual void on_destroy() {}
-
- /** @brief View rotate callback.
- *
- * @param degree Current rotation degree.
- *
- * @note This method will be called when view rotation occurred.
- */
- virtual void on_rotate(int degree) {}
-
- /** @brief Portrait callback.
- *
- * @note When current view is on portrait mode.
- */
- virtual void on_portrait() {}
-
- /** @brief Landscape callback.
- *
- * @note When current view is on landscape mode.
- */
- virtual void on_landscape() {}
-
- /** @brief Back key callback.
- *
- * @note In default. current view will be popped by viewmgr in those scenarios
- * that viewmgr is requested to poo the current view.
- * If you return false in the overriding, then popping will be stopped.
- */
- 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();
-};
-}
-
-#endif /* UI_BASE_CONTROLLER_H */
namespace efl_viewmgr
{
-class ui_base_controller;
class ui_base_popup;
/**
*/
virtual void set_event_block(bool block);
- /** @brief This is for calling controller's rotate method.
- */
virtual void on_rotate(int degree);
-
- /** @brief This is for calling controller's portrait method.
- */
virtual void on_portrait();
-
- /** @brief This is for calling controller's landscape method.
- */
virtual void on_landscape();
/** @brief view deactivate state.
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_deactivate();
public:
///Constructor.
- ui_base_view(ui_base_controller *controller, const char *name = NULL);
- ///Constructor.
ui_base_view(const char *name = NULL);
///Destructor.
*/
virtual Evas_Object *get_base();
- /** @brief This is for calling controller's back method.
- */
//FIXME: public?
virtual void on_back();
#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"
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef UI_CONTROLLER_INTERFACE_H_
-#define UI_CONTROLLER_INTERFACE_H_
-
-namespace viewmgr {
-
-class ui_iface_view;
-
-/**
- * @class ui_iface_controller.
- *
- * @internal
- * @ingroup viewmgr
- *
- * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side.
- */
-class ui_iface_controller
-{
- friend class ui_iface_view;
-
-private:
- ui_iface_view *view;
-
- void set_view(ui_iface_view *view);
-
-protected:
- /**
- * @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_iface_view *get_view()
- {
- return this->view;
- }
-
- /** @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.
- * In the most cases, this callback will be triggered with this step load -> deactivate -> activate.
- */
- virtual void on_load() = 0;
-
- /** @brief unload callback.
- *
- * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario.
- * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view.
- * If the view content is not alive, the unload won't be called.
- * In the most cases, this callback will be triggered with this step. deactivate -> unload -> destroy
- */
- virtual void on_unload() = 0;
-
- /** @brief activate callback.
- *
- * @note View is on activate state after show transition is finished.
- * From whatever the state, if the view is on the screen, the activate callback will be called.
- * In the most cases, this callback will be triggered with this step. load -> deactivate -> activate
- */
- virtual void on_activate() = 0;
-
- /** @brief deactivate callback.
- *
- * @note View is on deactivate state. Get ready for unload. Hide transition may be triggered at this point.
- * Deactivate state is triggered on this scenario that the view is still visible but it's not interactivate with users.
- * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the deactivate state will be triggered.
- * Some UI controls such as a center popup or a menu popup blocks the view, this view may be deactivate but still visible in someway (with transparency)
- */
- virtual void on_deactivate() = 0;
-
- /** @brief pause callback.
- *
- * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ...
- * When Window turns to deactivate. (@see ui_viewmgr_base :: deactivate()).
- * If the view were deactivate or unload state, the pause won't be called.
- */
- virtual void on_pause() = 0;
-
- /** @brief resume callback.
- *
- * @note View is turning back to the activate state again from pause.
- * When the system allows the application turns to activate.
- * When the Window turns to activate. (@see ui_viewmgr_base :: activate())
- */
- virtual void on_resume() = 0;
-
- /** @brief destroy callback.
- *
- * @note When this view is on destroying by popping or deleting.
- */
- virtual void on_destroy() = 0;
-
- /** @brief View rotate callback.
- *
- * @param degree Current rotation degree.
- *
- * @note This method will be called when view rotation occurred.
- */
- virtual void on_rotate(int degree) = 0;
-
- /** @brief Portrait callback.
- *
- * @note When current view is on portrait mode.
- */
- virtual void on_portrait() = 0;
-
- /** @brief Landscape callback.
- *
- * @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()
- {
- }
-};
-
-}
-
-#endif /* UI_CONTROLLER_INTERFACE_H_ */
class ui_iface_rotatable
{
protected:
- /** @brief This is for calling controller's portrait method.
- */
virtual void on_portrait() {}
-
- /** @brief This is for calling controller's landscape method.
- */
virtual void on_landscape() {}
-
- /** @brief This is for calling controller's rotate method.
- */
virtual void on_rotate(int degree) {}
public:
namespace viewmgr {
class ui_iface_viewmgr;
-class ui_iface_controller;
/**
* @class ui_iface_view
class ui_iface_view
{
friend class ui_iface_viewmgr;
- friend class ui_iface_controller;
private:
/// View state definition
};
T content; ///< A content instance for a screen as a view.
- ui_iface_controller *controller; ///< View life-cycle controller interface.
string name; ///< View name.
string transition_style; ///< View transition style name.
ui_iface_viewmgr *viewmgr; ///< Viewmgr which this view belongs to.
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_load();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_unload();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_activate();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_deactivate();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_pause();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_resume();
*
* @note this state will be triggered by ui_iface_viewmgr.
*
- * @see ui_iface_controller for this state in detail.
*/
virtual void on_destroy();
return this->event_block;
}
- /// Return a controller of this view.
- ui_iface_controller* get_controller()
- {
- return this->controller;
- }
-
/** @brief Return a viewmgr which this view is belonging to.
*/
ui_iface_viewmgr *get_viewmgr()
return this->viewmgr;
}
- /** @brief This is for replacing or setting a controller of the view.
- *
- * @return A previous controller. If it wasn't, the return value will be @c NULL.
- * @note this state will be triggered by ui_iface_viewmgr.
- * @param controller a new controller. It allows @c NULL for canceling the previous controller.
- *
- * @warning Be aware deletion of controller passed here will be taken cover by ui_iface_view.
- * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_iface_view is deleted.
- */
- ui_iface_controller* set_controller(ui_iface_controller *controller);
-
public:
/** @brief This is a constructor for initializing this view resources.
*
- * @param controller view life-cycle controller interface.
* @param name view name.
- *
- * @warning Be aware the deletion of controller passed here will be covered by ui_iface_view.
- * If you want to keep it for any reasons, please unset it using set_controller() before ui_iface_view is deleted.
*/
- ///Constructor for initializing with controller.
- ui_iface_view(ui_iface_controller *controller, const char *name = NULL);
- ///Constructor for initializing with name.
ui_iface_view(const char *name = NULL);
///Destructor for terminating view.
#include "ui_iface_rotatable.h"
#include "ui_iface_viewmgr.h"
#include "ui_iface_view.h"
-#include "ui_iface_controller.h"
#endif /* UI_VIEWMANAGER_INTERFACE_H */
SET(LIB_SRCS
- interface/ui_iface_controller.cpp
interface/ui_iface_view.cpp
interface/ui_iface_viewmgr.cpp
efl/ui_base_popup.cpp
- efl/ui_base_controller.cpp
efl/ui_base_view.cpp
efl/ui_base_viewmgr.cpp
efl/ui_base_key_listener.cpp
- efl/mobile/ui_controller.cpp
efl/mobile/ui_menu.cpp
efl/mobile/ui_view.cpp
efl/mobile/ui_key_listener.cpp
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include "../../../include/efl/mobile/ui_viewmanager.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-ui_controller::~ui_controller()
-{
-}
-
-void ui_controller::on_menu(ui_menu *menu)
-{
-}
using namespace efl_viewmgr;
using namespace 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)
{
ui_view *view = static_cast<ui_view *>(data);
ui_base_view ::on_back();
}
-ui_view::ui_view(ui_controller *controller, const char *name)
- : ui_base_view(controller, name), layout(NULL), menu(NULL)
-{
-}
-
ui_view::ui_view(const char *name)
- : ui_view(NULL, name)
+ : ui_base_view(name), layout(NULL), menu(NULL)
{
}
{
this->menu = new ui_menu(this);
}
-
- if (this->get_controller())
- {
- MY_CONTROLLER->on_menu(this->menu);
- return false;
- }
return true;
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include "../../include/efl/ui_viewmanager_base.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-ui_base_view * ui_base_controller::get_view()
-{
- ui_iface_view *view = ui_iface_controller::get_view();
- if (!view) return NULL;
- return dynamic_cast<ui_base_view *>(view);
-}
-
-ui_base_controller::~ui_base_controller()
-{
-
-}
using namespace efl_viewmgr;
using namespace viewmgr;
-#define MY_CONTROLLER dynamic_cast<ui_base_controller *>(this->get_controller())
typedef list<ui_base_popup*>::reverse_iterator popup_ritr;
void ui_base_view::connect_popup(ui_base_popup *popup)
this->popup_list.remove(popup);
}
-ui_base_view::ui_base_view(ui_base_controller *controller, const char *name)
- : ui_iface_view(controller, name)
-{
-}
-
ui_base_view::ui_base_view(const char *name)
- : ui_base_view(NULL, name)
+ : ui_iface_view(name)
{
}
//If any popup is activated, deactivate the popup first.
if (this->deactivate_popup(true)) return;
- if (this->get_controller())
- {
- if (!MY_CONTROLLER->on_back())
- {
- return;
- }
- }
ui_base_viewmgr *viewmgr = UI_BASE_VIEWMGR;
if (!viewmgr)
{
void ui_base_view::on_rotate(int degree)
{
- if (!this->get_controller()) return;
- MY_CONTROLLER->on_rotate(degree);
}
void ui_base_view::on_portrait()
{
- if (!this->get_controller()) return;
- MY_CONTROLLER->on_portrait();
}
void ui_base_view::on_landscape()
{
- if (!this->get_controller()) return;
- MY_CONTROLLER->on_landscape();
}
+
void ui_base_view::set_event_block(bool block)
{
ui_iface_view::set_event_block(block);
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include "../../include/interface/ui_viewmanager_interface.h"
-
-using namespace viewmgr;
-
-void ui_iface_controller::set_view(ui_iface_view *view)
-{
- if (this->view)
- {
- this->view->set_controller(NULL);
- }
- this->view = view;
-}
void ui_iface_view::on_load()
{
this->state = UI_VIEW_STATE_LOAD;
- if (this->content) return;
- if (!this->controller) return;
- this->controller->on_load();
}
void ui_iface_view::on_unload()
this->unload_content();
return;
}
- if (!this->content) return;
- if (!this->controller) return;
- this->controller->on_unload();
}
void ui_iface_view::on_activate()
{
this->state = UI_VIEW_STATE_ACTIVATE;
- if (!this->controller) return;
- this->controller->on_activate();
}
void ui_iface_view::on_deactivate()
{
this->state = UI_VIEW_STATE_DEACTIVATE;
- if (!this->controller) return;
- this->controller->on_deactivate();
}
void ui_iface_view::on_pause()
{
this->state = UI_VIEW_STATE_PAUSE;
- if (!this->content) return;
- if (state != UI_VIEW_STATE_ACTIVATE) return;
- if (!this->controller) return;
- this->controller->on_pause();
}
void ui_iface_view::on_resume()
{
this->state = UI_VIEW_STATE_ACTIVATE;
- if (state != UI_VIEW_STATE_PAUSE) return;
- if (!this->content) return;
- if (!this->controller) return;
- this->controller->on_resume();
}
void ui_iface_view::on_destroy()
{
- if (!this->controller) return;
- this->controller->on_destroy();
}
-ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name)
- : content(NULL), controller(controller), name(string(name ? name : "")), transition_style(string("default")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
+ui_iface_view::ui_iface_view(const char *name)
+ : content(NULL), name(string(name ? name : "")), transition_style(string("default")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
{
this->state = UI_VIEW_STATE_UNLOAD;
-
- if (controller)
- controller->set_view(this);
-}
-
-ui_iface_view::ui_iface_view(const char *name)
- : ui_iface_view(NULL, name)
-{
-
}
ui_iface_view::~ui_iface_view()
{
this->viewmgr->remove_view(this);
- if (this->controller) delete (this->controller);
-}
-
-ui_iface_controller* ui_iface_view::set_controller(ui_iface_controller *controller)
-{
- ui_iface_controller *prev_controller = this->controller;
- this->controller = controller;
- if (controller) controller->set_view(this);
- if (prev_controller) prev_controller->set_view(NULL);
- return prev_controller;
}
T ui_iface_view::set_content(T content)