introduce ui_iface_rotatable. 77/63777/2
authorHermet Park <hermet@hermet.pe.kr>
Sat, 26 Mar 2016 08:14:45 +0000 (17:14 +0900)
committerHermet Park <chuneon.park@samsung.com>
Sat, 26 Mar 2016 08:17:34 +0000 (01:17 -0700)
This interface is designed for rotataion events.
All kinds of views which is rotatable could inherit this.

Change-Id: Ifac8e14cf62631c62554201ddfe88abfab412097

src/include/efl/mobile/ui_menu.h
src/include/efl/mobile/ui_view.h
src/include/efl/ui_base_view.h
src/include/interface/ui_iface_rotatable.h [new file with mode: 0644]
src/include/interface/ui_viewmanager_interface.h
src/lib/efl/mobile/ui_menu.cpp
src/lib/efl/mobile/ui_view.cpp
src/lib/efl/ui_base_view.cpp

index 6c1dc18..de0d942 100644 (file)
 #define UI_MENU_H
 
 #include "../ui_viewmanager_base.h"
+#include "../../interface/ui_viewmanager_interface.h"
 
 namespace efl_viewmgr
 {
 class ui_view;
 
-class ui_menu
+class ui_menu: public viewmgr::ui_iface_rotatable
 {
        friend class ui_view;
 private:
@@ -42,8 +43,9 @@ public:
        virtual Elm_Ctxpopup *unset_content();
        virtual void on_back();
        virtual bool is_activated();
-       virtual Evas_Object *get_base();
 
+       virtual Evas_Object *get_base();
+       virtual int get_degree();
        virtual Elm_Ctxpopup *get_content()
        {
                return this->ctxpopup;
index b77bec1..1dacd1f 100644 (file)
@@ -45,6 +45,18 @@ protected:
        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);
index 6f23264..b0e95a1 100644 (file)
@@ -39,7 +39,7 @@ class ui_base_controller;
  *  @warning When the transitions are finished, the view must to call ui_iface_viewmgr :: _push_finished(), ui_iface_viewmgr :: _pop_finished() in order that
  *           The ui_iface_viewmgr keeps the view states exactly.
  */
-class ui_base_view: public viewmgr::ui_iface_view
+class ui_base_view: public viewmgr::ui_iface_view, public viewmgr::ui_iface_rotatable
 {
        friend class ui_base_viewmgr;
 
@@ -114,13 +114,13 @@ public:
         *
         *  @param indicator The mode to set, one of #ui_base_view_indicator.
         */
-       void set_indicator(ui_view_indicator indicator);
+       virtual void set_indicator(ui_view_indicator indicator);
 
        /** @brief Get current view's degree.
         *
-        *  @return Current rotation degree, -1 if failed to get viewmgr degree.
+        *  @return Current rotation degree, -1 if it fails to get degree information.
         */
-       int get_degree();
+       virtual int get_degree();
 };
 
 }
diff --git a/src/include/interface/ui_iface_rotatable.h b/src/include/interface/ui_iface_rotatable.h
new file mode 100644 (file)
index 0000000..6d46c2a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_ROTATABLE_INTERFACE_H_
+#define UI_ROTATABLE_INTERFACE_H_
+
+namespace viewmgr
+{
+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:
+       /** @brief Get current view's degree.
+        *
+        *  @return Current rotation degree, -1 if it fails to get degree information.
+        */
+       virtual int get_degree() { return 0; }
+};
+
+}
+
+#endif /* UI_ROTATABLE_INTERFACE_H_ */
index d5e10b0..baae5e4 100644 (file)
@@ -35,6 +35,7 @@ enum ui_view_indicator
        UI_VIEW_INDICATOR_LAST
 };
 
+#include "ui_iface_rotatable.h"
 #include "ui_iface_viewmgr.h"
 #include "ui_iface_view.h"
 #include "ui_iface_controller.h"
index 847f684..2c01297 100644 (file)
@@ -18,8 +18,6 @@
 
 using namespace efl_viewmgr;
 
-#define MY_VIEWMGR
-
 static void ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
 {
        evas_object_hide(obj);
@@ -175,3 +173,8 @@ void ui_menu::on_back()
 {
        this->deactivate();
 }
+
+int ui_menu::get_degree()
+{
+       return this->view->get_degree();
+}
index 45d969b..42ed2d6 100644 (file)
@@ -409,3 +409,30 @@ Elm_Toolbar *ui_view::unset_toolbar()
 
        return toolbar;
 }
+
+void ui_view::on_rotate(int degree)
+{
+       ui_base_view::on_rotate(degree);
+       if (this->menu && this->menu->is_activated())
+       {
+               this->menu->on_rotate(degree);
+       }
+}
+
+void ui_view::on_portrait()
+{
+       ui_base_view::on_portrait();
+       if (this->menu && this->menu->is_activated())
+       {
+               this->menu->on_portrait();
+       }
+}
+
+void ui_view::on_landscape()
+{
+       ui_base_view::on_landscape();
+       if (this->menu && this->menu->is_activated())
+       {
+               this->menu->on_landscape();
+       }
+}
index aff4d8c..e28abcd 100644 (file)
@@ -109,26 +109,20 @@ void ui_base_view::on_back()
 
 void ui_base_view::on_rotate(int degree)
 {
-       if (this->get_controller())
-       {
-               MY_CONTROLLER->on_rotate(degree);
-       }
+       if (!this->get_controller()) return;
+       MY_CONTROLLER->on_rotate(degree);
 }
 
 void ui_base_view::on_portrait()
 {
-       if (this->get_controller())
-       {
-               MY_CONTROLLER->on_portrait();
-       }
+       if (!this->get_controller()) return;
+       MY_CONTROLLER->on_portrait();
 }
 
 void ui_base_view::on_landscape()
 {
-       if (this->get_controller())
-       {
-               MY_CONTROLLER->on_landscape();
-       }
+       if (!this->get_controller()) return;
+       MY_CONTROLLER->on_landscape();
 }
 void ui_base_view::set_event_block(bool block)
 {