From: Hermet Park Date: Sat, 26 Mar 2016 08:14:45 +0000 (+0900) Subject: introduce ui_iface_rotatable. X-Git-Tag: submit/tizen/20160617.075742~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8de3af4d00158b197f68c2feb267a1901f3a6593;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git introduce ui_iface_rotatable. This interface is designed for rotataion events. All kinds of views which is rotatable could inherit this. Change-Id: Ifac8e14cf62631c62554201ddfe88abfab412097 --- diff --git a/src/include/efl/mobile/ui_menu.h b/src/include/efl/mobile/ui_menu.h index 6c1dc18..de0d942 100644 --- a/src/include/efl/mobile/ui_menu.h +++ b/src/include/efl/mobile/ui_menu.h @@ -18,12 +18,13 @@ #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; diff --git a/src/include/efl/mobile/ui_view.h b/src/include/efl/mobile/ui_view.h index b77bec1..1dacd1f 100644 --- a/src/include/efl/mobile/ui_view.h +++ b/src/include/efl/mobile/ui_view.h @@ -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); diff --git a/src/include/efl/ui_base_view.h b/src/include/efl/ui_base_view.h index 6f23264..b0e95a1 100644 --- a/src/include/efl/ui_base_view.h +++ b/src/include/efl/ui_base_view.h @@ -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 index 0000000..6d46c2a --- /dev/null +++ b/src/include/interface/ui_iface_rotatable.h @@ -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_ */ diff --git a/src/include/interface/ui_viewmanager_interface.h b/src/include/interface/ui_viewmanager_interface.h index d5e10b0..baae5e4 100644 --- a/src/include/interface/ui_viewmanager_interface.h +++ b/src/include/interface/ui_viewmanager_interface.h @@ -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" diff --git a/src/lib/efl/mobile/ui_menu.cpp b/src/lib/efl/mobile/ui_menu.cpp index 847f684..2c01297 100644 --- a/src/lib/efl/mobile/ui_menu.cpp +++ b/src/lib/efl/mobile/ui_menu.cpp @@ -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(); +} diff --git a/src/lib/efl/mobile/ui_view.cpp b/src/lib/efl/mobile/ui_view.cpp index 45d969b..42ed2d6 100644 --- a/src/lib/efl/mobile/ui_view.cpp +++ b/src/lib/efl/mobile/ui_view.cpp @@ -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(); + } +} diff --git a/src/lib/efl/ui_base_view.cpp b/src/lib/efl/ui_base_view.cpp index aff4d8c..e28abcd 100644 --- a/src/lib/efl/ui_base_view.cpp +++ b/src/lib/efl/ui_base_view.cpp @@ -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) {