refactoring code. 74/63774/2
authorHermet Park <hermet@hermet.pe.kr>
Sat, 26 Mar 2016 06:31:05 +0000 (15:31 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Sat, 26 Mar 2016 06:39:48 +0000 (15:39 +0900)
Still, viewmgr implementation has a lot of missings.
we are gradually improving the bodies.

Change-Id: I1628bc0e58f1ac72b7366963b4115e8bd6c6d76f

src/examples/efl/main.cpp
src/examples/efl/page10.h
src/examples/efl/page11.h
src/examples/efl/page12.h
src/examples/efl/page13.h [new file with mode: 0644]
src/include/efl/mobile/ui_menu.h
src/include/efl/mobile/ui_view.h
src/lib/efl/mobile/ui_menu.cpp
src/lib/efl/mobile/ui_view.cpp
src/lib/efl/ui_base_key_listener.cpp

index 37c74aa..5a42973 100644 (file)
@@ -15,6 +15,7 @@
  *
  */
 #include "main.h"
+#include "page13.h"
 #include "page12.h"
 #include "page11.h"
 #include "page10.h"
index a3fca1c..edcef26 100644 (file)
@@ -62,6 +62,7 @@ public:
                                                        },
                                                        this->ad);
                view->set_content(content, "Title");
+               view->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
        }
 
        void on_landscape()
@@ -82,6 +83,7 @@ public:
                        },
                        this->ad);
                view->set_content(content, "Title");
+               view->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
        }
 
 };
index 4bb95ca..ff0dd57 100644 (file)
@@ -45,7 +45,8 @@ protected:
                                        create_page12(ad);
                                },
                                this->ad);
-                       this->set_content(content, "Title Portrait");
+                       this->set_content(content, "Title");
+                       this->set_indicator(UI_VIEW_INDICATOR_DEFAULT);
                }
                //Landscape
                else
@@ -64,7 +65,8 @@ protected:
                                        create_page12(ad);
                                },
                                this->ad);
-                       this->set_content(content, "Title Landscape");
+                       this->set_content(content, "Title");
+                       this->set_indicator(UI_VIEW_INDICATOR_OPTIMAL);
                }
        }
 
index 548fa8b..676cf17 100644 (file)
@@ -46,7 +46,7 @@ protected:
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
                                        appdata_s *ad = static_cast<appdata_s *>(data);
-                                       ad->viewmgr->deactivate();
+                                       create_page13(ad);
                                },
                                this->ad);
 
diff --git a/src/examples/efl/page13.h b/src/examples/efl/page13.h
new file mode 100644 (file)
index 0000000..e61abc6
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ *
+ */
+
+class page13: 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 13<br>(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();
+                               },
+                               //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);
+               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);
+       }
+
+public:
+       page13(const char *name, appdata_s *ad)
+                       : ui_view(name), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page13()
+       {
+       }
+
+       void create_popup()
+       {
+#if 0
+               ui_popup_view *view = new ui_popup_view(this);
+
+               Evas_Object *popup = elm_popup_add(view->get_base());
+
+               elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+               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, "block,clicked",
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       evas_object_del(obj);
+                               },
+                               NULL);
+               evas_object_smart_callback_add(popup, "timeout",
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       evas_object_del(obj);
+                               },
+                               NULL);
+               evas_object_show(popup);
+
+               view->set_content(popup);
+               view->activate();
+#endif
+       }
+};
+
+void create_page13(appdata_s *ad)
+{
+       /* A example for view class extension instead of using controller class. */
+       new page13("page13", ad);
+}
index 0982280..6c1dc18 100644 (file)
@@ -40,14 +40,14 @@ public:
        virtual bool deactivate();
        virtual bool set_content(Elm_Ctxpopup* ctxpopup);
        virtual Elm_Ctxpopup *unset_content();
+       virtual void on_back();
+       virtual bool is_activated();
+       virtual Evas_Object *get_base();
 
        virtual Elm_Ctxpopup *get_content()
        {
                return this->ctxpopup;
        }
-
-       virtual bool is_activated();
-       virtual Evas_Object *get_base();
 };
 
 }
index e3a1ccf..b77bec1 100644 (file)
@@ -69,17 +69,17 @@ public:
                return this->layout;
        }
 
-       const Elm_Button *get_title_left_btn()
+       Elm_Button *get_title_left_btn()
        {
                return this->title_left_btn;
        }
 
-       const Elm_Button *get_title_right_btn()
+       Elm_Button *get_title_right_btn()
        {
                return this->title_right_btn;
        }
 
-       const Elm_Toolbar *get_toolbar()
+       Elm_Toolbar *get_toolbar()
        {
                return this->toolbar;
        }
@@ -88,7 +88,6 @@ public:
        {
                return this->menu;
        }
-
 };
 
 }
index 996348c..847f684 100644 (file)
@@ -170,3 +170,8 @@ Evas_Object *ui_menu::get_base()
 
        return this->get_window();
 }
+
+void ui_menu::on_back()
+{
+       this->deactivate();
+}
index 5788c1e..45d969b 100644 (file)
@@ -120,7 +120,7 @@ void ui_view::on_back()
        {
                if (this->menu->is_activated())
                {
-                       this->menu->deactivate();
+                       this->menu->on_back();
                        return;
                }
        }
index 8abefd8..3a2bd92 100644 (file)
@@ -42,7 +42,6 @@ static void event_proc(ui_base_key_listener *key_listener, Evas_Event_Key_Down *
 
        if (strcmp(ev->keyname, KEY_BACK) && strcmp(ev->keyname, KEY_BACK2)) return;
 
-       //FIXME: cancel menu??
        view->on_back();
 }