Add method to get orientation of view. 30/78030/12
authorWoochan Lee <wc0917.lee@samsung.com>
Mon, 4 Jul 2016 04:35:45 +0000 (13:35 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Wed, 6 Jul 2016 08:15:56 +0000 (17:15 +0900)
Change-Id: I44d4ad4b132f7897ad5ae0a923edf668c867e573

src/examples/efl/c/page10.cpp
src/examples/efl/c/page9.cpp
src/examples/efl/cpp/page10.h
src/examples/efl/cpp/page9.h
src/include/efl/mobile/UiView.h
src/include/efl/mobile/c/ui_view.h
src/include/interface/UiIfaceRotatable.h
src/include/interface/UiIfaceTypes.h
src/lib/efl/mobile/UiView.cpp
src/lib/efl/mobile/c/ui_view.cpp

index 110d3f60ab96293ec252147a02db6ffaacc94cbf..61221743ba4627444b95e618979c8cdaefc95200 100644 (file)
@@ -44,8 +44,7 @@ view10_rotate_cb(ui_standard_view *view, int degree, void *data)
        }
 
        //Check orientation manually to create a content.
-
-       if (degree == 0 || degree == 180)
+       if (ui_view_get_orientation_mode(view) == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
        {
                //Portrait
                content = create_content(base, "ViewMgr Demo<br>Rotation", prev_btn_clicked_cb, next_btn_clicked_cb);
index 34386f1bfb9636df9ad452a44285d9e0138141cc..4f865e0d33f1974cccdaec35a62ee09d3cad2da4 100644 (file)
@@ -88,12 +88,11 @@ view9_landscape_cb(ui_standard_view *view, void *data)
 static bool
 view9_load_cb(ui_standard_view *view, void *data)
 {
-       //FIXME: Change below code to more convenient and clear way.
-       if (ui_view_get_degree(view) == 90 || ui_view_get_degree(view) == 270)
+       if (ui_view_get_orientation_mode(view) == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
        {
-               return view9_landscape_cb(view, data);
-       } else {
                return view9_portrait_cb(view, data);
+       } else {
+               return view9_landscape_cb(view, data);
        }
 }
 
index dc06da254a4c7ef4048dc47c73904cad0ff04d01..99e4cbb842180d68869e665d2d36d852658619ee 100644 (file)
@@ -31,7 +31,7 @@ protected:
        {
                UiStandardView::onRotate(degree);
 
-               if (this->getDegree() == 0 || this->getDegree() == 180)
+               if (this->getOrientationMode() == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
                {
                        //Portrait
                        Evas_Object *content = createContent(this->getBase(), "ViewMgr++ Demo<br>Rotation",
index 345043e41331ed448b0165843a2b478a6c7946b9..26eefd75f852d925899d9cf6bdb139d841168106 100644 (file)
@@ -26,11 +26,10 @@ protected:
        {
                UiStandardView::onLoad();
 
-               //FIXME: Change below code to more convenient and clear way.
-               if (this->getDegree() == 90 || this->getDegree() == 270)
-                       this->onLandscape();
-               else
+               if (this->getOrientationMode() == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
                        this->onPortrait();
+               else
+                       this->onLandscape();
        }
 
        void onPortrait()
index 4a01421b7e4bcf676b1662e30064d68fdb800bbf..882e435d3dc849bf03e9b0cfc42385640ecaf05c 100644 (file)
@@ -55,6 +55,13 @@ public:
         */
        const UiMenu *getMenu();
 
+       /**
+        *  @brief Get current view's orientation mode.
+        *
+        *  @return Current orientation mode, one of #UiViewOrientationMode.
+        */
+       virtual UiViewOrientationMode getOrientationMode() override;
+
 protected:
        /**
         *  @brief This is making UiMenu instance.
index d26e7224a7e47cde2e54412a9d29e5252a8bd3fb..809b0b6e78062227792d0a889db15d54c9643328 100644 (file)
@@ -187,6 +187,15 @@ EAPI bool ui_view_get_removable_content(ui_view *view);
  */
 EAPI int ui_view_get_degree(ui_view *view);
 
+/**
+ *  @brief Get current view's orientation mode.
+ *
+ *  @param view An ui_view instance
+ *
+ *  @return Current orientation mode, one of #ui_view_orientation_mode.
+ */
+EAPI ui_view_orientation_mode ui_view_get_orientation_mode(ui_view *view);
+
 /**
  *  @brief Set transition style of a view.
  *
index f3688c31489319e2779c2d8becea46dfec7c6b3e..eefc5cb1c3d1f8da4041463d6f25c6471f2afc0c 100644 (file)
@@ -39,6 +39,13 @@ public:
         */
        virtual int getDegree() { return 0; }
 
+       /**
+        *  @brief Get current view's orientation mode.
+        *
+        *  @return Current orientation mode, one of #UiViewOrientationMode.
+        */
+       virtual UiViewOrientationMode getOrientationMode() { return UI_VIEW_ORIENTATION_MODE_UNKOWN; }
+
 protected:
        /**
         *  @brief View portrait state.
index 65d29b78b6ebf4517c3ee81730dea7a428c59170..619ae20302753991c01e9e785d5b10a86ab88f5e 100644 (file)
@@ -47,4 +47,16 @@ enum UiViewState
 };
 typedef enum UiViewState ui_view_state;
 
+/**
+ * Possible values for view orientation mode.
+ */
+enum UiViewOrientationMode
+{
+       UI_VIEW_ORIENTATION_MODE_UNKOWN = 0,  ///< Unknown state (Exceptional case)
+       UI_VIEW_ORIENTATION_MODE_PORTRAIT,    ///< Portrait state
+       UI_VIEW_ORIENTATION_MODE_LANDSCAPE,   ///< Landscape state
+       UI_VIEW_ORIENTATION_MODE_LAST,
+};
+typedef enum UiViewOrientationMode ui_view_orientation_mode;
+
 #endif /* _UI_IFACE_TYPES_H_ */
index ba37119bf78eb90e62525898a30eccdbd314ac5d..38769e2f217b64989c0b2ab4a4f6c45ae1d7fa24 100644 (file)
@@ -58,6 +58,8 @@ public:
        {
                return this->_menu;
        }
+
+       UiViewOrientationMode getOrientationMode();
 };
 
 }
@@ -160,6 +162,23 @@ void UiViewImpl::onLandscape()
        this->_menu->onLandscape();
 }
 
+UiViewOrientationMode UiViewImpl::getOrientationMode()
+{
+       switch (this->_view->getDegree()) {
+               case 0:
+               case 180:
+                       return UI_VIEW_ORIENTATION_MODE_PORTRAIT;
+                       break;
+               case 90:
+               case 270:
+                       return UI_VIEW_ORIENTATION_MODE_LANDSCAPE;
+                       break;
+               }
+
+       return UI_VIEW_ORIENTATION_MODE_UNKOWN;
+}
+
+
 /***********************************************************************************************/
 /* External class Implementation                                                               */
 /***********************************************************************************************/
@@ -237,6 +256,11 @@ void UiView::onLandscape()
        this->_impl->onLandscape();
 }
 
+UiViewOrientationMode UiView::getOrientationMode()
+{
+       return this->_impl->getOrientationMode();
+}
+
 const UiMenu *UiView::getMenu()
 {
        return this->_impl->getMenu();
index 965d26fba1fa030b3b717b112cc55089f8c44f63..d35c6bab2b4ea2c72d5e86fc03868eebef91f9c7 100644 (file)
@@ -229,6 +229,12 @@ EAPI int ui_view_get_degree(ui_view *view)
        return view->getDegree();
 }
 
+EAPI ui_view_orientation_mode ui_view_get_orientation_mode(ui_view *view)
+{
+       if (!validate_view(view)) return UI_VIEW_ORIENTATION_MODE_UNKOWN;
+       return view->getOrientationMode();
+}
+
 EAPI bool ui_view_set_transition_style(ui_view *view, const char *style)
 {
        if (!validate_view(view)) return false;