move menu popup example from page1 to page12.
remove unnecessary virtual keywords from member functions.
change content texts for consistency..
Change-Id: I3ed108db4c183631f3267e16e32f56df6d82e7b7
*
*/
#include "main.h"
+#include "page12.h"
#include "page11.h"
#include "page10.h"
#include "page9.h"
* limitations under the License.
*
*/
-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 page1: public ui_controller
{
private:
void on_load()
{
//Initialize contents.
-
ui_view *view = dynamic_cast<ui_view *>(this->get_view());
- //Check the current rotation for set portrait or landscape content if any.
- LOGE("view 1 load rotation = %d\n", view->get_degree());
-
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1",
//Prev Button Callback
view->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);
-
- menu->set_content(ctxpopup);
- }
-
- void on_rotate(int degree)
- {
- LOGE("Current view's degree is %d\n", degree);
- }
-
- void on_portrait()
- {
- LOGE("View is on portrait mode\n");
- }
-
- void on_landscape()
- {
- LOGE("View is on landscape mode\n");
- }
};
void create_page1(appdata_s *ad)
void on_portrait()
{
ui_view *view = dynamic_cast<ui_view *>(this->get_view());
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_landscape()",
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
create_page11(ad);
},
this->ad);
- view->set_content(content, "Title Portrait");
+ view->set_content(content, "Title");
}
void on_landscape()
{
ui_view *view = dynamic_cast<ui_view *>(this->get_view());
- Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 10 With<br>on_portrait(), on_landscape()",
+ Evas_Object *content = create_landscape_content(view->get_base(), "ViewMgr Demo<br>Page 10<br>(Portrait + Landscape)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
create_page11(ad);
},
this->ad);
- view->set_content(content, "Title Landscape");
+ view->set_content(content, "Title");
}
};
appdata_s *ad;
protected:
- virtual void on_load()
+ void on_load()
{
this->on_rotate(this->get_degree());
}
- virtual void on_rotate(int degree)
+ void on_rotate(int degree)
{
//Portrait
if (this->get_degree() == 0 || this->get_degree() == 180)
{
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
[](void *data, Evas_Object *obj, void *event_info) -> void
{
appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
+ create_page12(ad);
},
this->ad);
this->set_content(content, "Title Portrait");
//Landscape
else
{
- Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 11 (View inheritance)<br>With on_rotate()",
+ Evas_Object *content = create_landscape_content(this->get_base(), "ViewMgr Demo<br>Page 11<br>(Rotate)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
[](void *data, Evas_Object *obj, void *event_info) -> void
{
appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
+ create_page12(ad);
},
this->ad);
this->set_content(content, "Title Landscape");
--- /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.
+ *
+ */
+
+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 page12: public ui_controller
+{
+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)",
+ //Prev Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->deactivate();
+ },
+ //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);
+
+ view->set_content(content, "Title");
+ }
+
+public:
+ page12(appdata_s *ad)
+ : ad(ad)
+ {
+ ad->viewmgr->push_view(new ui_view(this, "page12"));
+ }
+
+ ~page12()
+ {
+ }
+
+ 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);
+
+ menu->set_content(ctxpopup);
+ }
+};
+
+void create_page12(appdata_s *ad)
+{
+ /* A example for view class extension instead of using controller class. */
+ new page12(ad);
+}
appdata_s *ad;
protected:
- virtual void on_load()
+ void on_load()
{
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 8<br>(View inheritance lazy load)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 8<br>(View inheritance)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
this->set_viewmgr(ad->viewmgr);
//Create a main content.
- Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 9<br>(View inheritance)",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 9<br>(Content Preloading)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
//Below object has to be used in child class...
//Make this getter method? or define instance?
- //previous page is to be active page.
+ //previous page is to be an active page.
auto nx = std::prev(this->view_list.end(), 2);
ui_iface_view *pview = *nx;
pview->on_load();