From: Woochan Lee Date: Mon, 4 Jul 2016 04:35:45 +0000 (+0900) Subject: Add method to get orientation of view. X-Git-Tag: submit/tizen/20160707.233627~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ffaee938564c36a5e6e6ed018096e158e146457;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git Add method to get orientation of view. Change-Id: I44d4ad4b132f7897ad5ae0a923edf668c867e573 --- diff --git a/src/examples/efl/c/page10.cpp b/src/examples/efl/c/page10.cpp index 110d3f6..6122174 100644 --- a/src/examples/efl/c/page10.cpp +++ b/src/examples/efl/c/page10.cpp @@ -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
Rotation", prev_btn_clicked_cb, next_btn_clicked_cb); diff --git a/src/examples/efl/c/page9.cpp b/src/examples/efl/c/page9.cpp index 34386f1..4f865e0 100644 --- a/src/examples/efl/c/page9.cpp +++ b/src/examples/efl/c/page9.cpp @@ -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); } } diff --git a/src/examples/efl/cpp/page10.h b/src/examples/efl/cpp/page10.h index dc06da2..99e4cbb 100644 --- a/src/examples/efl/cpp/page10.h +++ b/src/examples/efl/cpp/page10.h @@ -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
Rotation", diff --git a/src/examples/efl/cpp/page9.h b/src/examples/efl/cpp/page9.h index 345043e..26eefd7 100644 --- a/src/examples/efl/cpp/page9.h +++ b/src/examples/efl/cpp/page9.h @@ -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() diff --git a/src/include/efl/mobile/UiView.h b/src/include/efl/mobile/UiView.h index 4a01421..882e435 100644 --- a/src/include/efl/mobile/UiView.h +++ b/src/include/efl/mobile/UiView.h @@ -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. diff --git a/src/include/efl/mobile/c/ui_view.h b/src/include/efl/mobile/c/ui_view.h index d26e722..809b0b6 100644 --- a/src/include/efl/mobile/c/ui_view.h +++ b/src/include/efl/mobile/c/ui_view.h @@ -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. * diff --git a/src/include/interface/UiIfaceRotatable.h b/src/include/interface/UiIfaceRotatable.h index f3688c3..eefc5cb 100644 --- a/src/include/interface/UiIfaceRotatable.h +++ b/src/include/interface/UiIfaceRotatable.h @@ -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. diff --git a/src/include/interface/UiIfaceTypes.h b/src/include/interface/UiIfaceTypes.h index 65d29b7..619ae20 100644 --- a/src/include/interface/UiIfaceTypes.h +++ b/src/include/interface/UiIfaceTypes.h @@ -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_ */ diff --git a/src/lib/efl/mobile/UiView.cpp b/src/lib/efl/mobile/UiView.cpp index ba37119..38769e2 100644 --- a/src/lib/efl/mobile/UiView.cpp +++ b/src/lib/efl/mobile/UiView.cpp @@ -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(); diff --git a/src/lib/efl/mobile/c/ui_view.cpp b/src/lib/efl/mobile/c/ui_view.cpp index 965d26f..d35c6ba 100644 --- a/src/lib/efl/mobile/c/ui_view.cpp +++ b/src/lib/efl/mobile/c/ui_view.cpp @@ -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;