Add view inheritance example. 12/62612/7
authorWoochan Lee <wc0917.lee@samsung.com>
Thu, 17 Mar 2016 05:04:10 +0000 (14:04 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Fri, 18 Mar 2016 07:34:36 +0000 (16:34 +0900)
Change-Id: If1bd0daf9de88c754bb267b4f32b1ee341333eb4

src/examples/efl/main.cpp
src/examples/efl/page7.h
src/examples/efl/page8.h [new file with mode: 0644]
src/examples/efl/page9.h [new file with mode: 0644]
src/include/efl/mobile/ui_basic_view.h
src/include/efl/ui_view.h
src/lib/efl/mobile/ui_basic_view.cpp
src/lib/efl/ui_view.cpp
src/lib/interface/ui_iface_view.cpp

index 459d25db5399e5428f3d7970431577f6049ec15f..5daf1204d935f8c7b5bf3d8e6c2ae2f7ab02c2d1 100644 (file)
@@ -15,6 +15,8 @@
  *
  */
 #include "main.h"
+#include "page9.h"
+#include "page8.h"
 #include "page7.h"
 #include "page6.h"
 #include "page5.h"
index 1d7520453c3d4f728bc0f0b33d4f22d49966a10d..a50ae14d3998fe1c6d4d9d663a7e06bd8e61f7d7 100644 (file)
@@ -44,10 +44,12 @@ public:
                                [](void *data, Evas_Object *obj, void *event_info) -> void
                                {
                                        appdata_s *ad = static_cast<appdata_s *>(data);
-                                       ad->viewmgr->deactivate();
+                                       create_page8(ad);
                                },
                                this->ad);
 
+               //Don't delete view's content when this view poped.
+               view->set_removable_content(false);
                view->set_content(content, "Title with toolbar");
                Evas_Object *toolbar = create_toolbar(view->get_base(), "navigationbar");
                view->set_toolbar(toolbar);
diff --git a/src/examples/efl/page8.h b/src/examples/efl/page8.h
new file mode 100644 (file)
index 0000000..61bdafc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 page8: public ui_basic_view
+{
+private:
+       appdata_s *ad;
+
+protected:
+       virtual void load()
+       {
+               //Create a main content.
+               Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 8<br>(View inheritance lazy 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();
+                               },
+                               //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);
+
+               this->set_content(content, "Title");
+       }
+
+public:
+       page8(const char *name, appdata_s *ad)
+               : ui_basic_view(name), ad(ad)
+       {
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page8()
+       {
+       }
+};
+
+void create_page8(appdata_s *ad)
+{
+       /* A example for view class extension instead of using controller class. */
+       new page8("page8", ad);
+}
diff --git a/src/examples/efl/page9.h b/src/examples/efl/page9.h
new file mode 100644 (file)
index 0000000..1c35d6d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 page9: public ui_basic_view
+{
+private:
+       appdata_s *ad;
+
+public:
+       page9(const char *name, appdata_s *ad)
+               : ui_basic_view(name), ad(ad)
+       {
+               //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 9<br>(View 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();
+                       },
+                       //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);
+
+               //Don't delete view's content when this view poped.
+               this->set_removable_content(false);
+               this->set_content(content, "Title");
+               ad->viewmgr->push_view(this);
+       }
+
+       ~page9()
+       {
+       }
+};
+
+void create_page9(appdata_s *ad)
+{
+       /* A example for view class extension instead of using controller class. */
+       new page9("page9", ad);
+}
index 8b944bd4294c7d9eabb65ca434746f1c6a5a9ced..3835639caba432345e3c71b8dde3271ca9c90447 100644 (file)
@@ -38,6 +38,7 @@ protected:
 
 public:
        ui_basic_view(ui_controller *controller, const char *name = NULL);
+       ui_basic_view(const char *name = NULL);
        virtual ~ui_basic_view();
 
        Evas_Object *set_content(Evas_Object *content, const char *title = NULL);
index f9349e74bc67f900e5feb6ecb1a69a283be48368..2bcc2869bea084da1378eccf63af3dc64db144b4 100644 (file)
@@ -46,6 +46,8 @@ class ui_view: public viewmgr::ui_iface_view
 public:
        ///Constructor.
        ui_view(ui_controller *controller, const char *name = NULL);
+       ///Constructor.
+       ui_view(const char *name = NULL);
 
        ///Destructor.
        virtual ~ui_view();
index 04c55fd29965a169ece923e0675fd1396bdf0594..99de673fc84ff4d27987db1434d3a19b86047791 100644 (file)
@@ -92,6 +92,11 @@ ui_basic_view::ui_basic_view(ui_controller *controller, const char *name)
 {
 }
 
+ui_basic_view::ui_basic_view(const char *name)
+               : ui_basic_view(NULL, name)
+{
+}
+
 ui_basic_view::~ui_basic_view()
 {
        destroy_layout();
index a50329bdac27b3f66cfec6fd5c6c32a4513aaad4..adfbae9218f407050425eb483078ed18826a63b4 100644 (file)
@@ -24,6 +24,11 @@ ui_view::ui_view(ui_controller *controller, const char *name)
 {
 }
 
+ui_view::ui_view(const char *name)
+               : ui_view(NULL, name)
+{
+}
+
 ui_view::~ui_view()
 {
 }
index 39a3dadadb3bef630a161e1cdc5a7cdd448bedc2..750ee0bd6d71a51d5b705ebd07976af19aa0329b 100644 (file)
@@ -87,7 +87,9 @@ ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name)
                  indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
 {
        this->state = UI_VIEW_STATE_UNLOAD;
-       controller->set_view(this);
+
+       if (controller)
+               controller->set_view(this);
 }
 
 ui_iface_view::ui_iface_view(const char *name)