From 1a584f05b00770a1c0d7335bb6145b6cde528a7f Mon Sep 17 00:00:00 2001 From: Woochan Lee Date: Tue, 12 Jul 2016 13:46:14 +0900 Subject: [PATCH] Add available rotations set/get methods. Change-Id: Ia8116c8ad5ecb24519d568cf14d2ac72283ee523 --- src/examples/efl/c/page2.cpp | 4 +++ src/examples/efl/cpp/page2.h | 4 +++ src/include/efl/UiBaseView.h | 11 ++++++ src/include/efl/mobile/c/ui_view.h | 24 +++++++++++++ src/include/interface/UiIfaceView.h | 24 +++++++++++++ src/lib/efl/UiBaseView.cpp | 19 ++++++++++ src/lib/efl/UiBaseViewmgr.cpp | 14 ++++++++ src/lib/efl/mobile/c/ui_view.cpp | 12 +++++++ src/lib/interface/UiIfaceView.cpp | 72 ++++++++++++++++++++++++++++++++----- 9 files changed, 175 insertions(+), 9 deletions(-) diff --git a/src/examples/efl/c/page2.cpp b/src/examples/efl/c/page2.cpp index 1dbc0d2..ad85b4c 100644 --- a/src/examples/efl/c/page2.cpp +++ b/src/examples/efl/c/page2.cpp @@ -55,6 +55,10 @@ view2_load_cb(ui_standard_view *view, void *data) Elm_Button *right_title_btn = elm_button_add(base); elm_object_text_set(right_title_btn, "Done"); + //Set available rotation only "0, 90" of this view + const int rots[2] = { 0, 90 }; + ui_view_set_available_rotations(view, rots, 2); + if (!ui_standard_view_set_content(view, content, "Page2", NULL, left_title_btn, right_title_btn)) { dlog_print(DLOG_ERROR, LOG_TAG, "failed to set view content"); diff --git a/src/examples/efl/cpp/page2.h b/src/examples/efl/cpp/page2.h index 0da400c..e1c1c31 100644 --- a/src/examples/efl/cpp/page2.h +++ b/src/examples/efl/cpp/page2.h @@ -46,6 +46,10 @@ protected: Elm_Button *rightTitleBtn = elm_button_add(this->getBase()); elm_object_text_set(rightTitleBtn, "Done"); + //Set available rotation only "0, 90" of this view + const int rots[2] = { 0, 90 }; + this->setAvailableRotations(rots, 2); + //Arguments: content, title, subtitle, title left button, title right button this->setContent(content, "Page2", NULL, leftTitleBtn, rightTitleBtn); } diff --git a/src/include/efl/UiBaseView.h b/src/include/efl/UiBaseView.h index 1894443..a024443 100644 --- a/src/include/efl/UiBaseView.h +++ b/src/include/efl/UiBaseView.h @@ -74,6 +74,17 @@ public: virtual void setIndicator(UiViewIndicator indicator) override; /** + * @breif Set the array of view's available rotations. + * + * @note Set an array of rotation values. + * For instance, {0, 90, 180, 270}. These rotation values depends on the system support. + * + * @param rotations The array of rotation values. + * @param count The number of arrays of rotatons. + */ + virtual bool setAvailableRotations(const int *rotations, unsigned int count) override; + + /** * @brief Get current view's degree. * * @return Current rotation degree, -1 if it fails to get degree information. diff --git a/src/include/efl/mobile/c/ui_view.h b/src/include/efl/mobile/c/ui_view.h index 809b0b6..b813110 100644 --- a/src/include/efl/mobile/c/ui_view.h +++ b/src/include/efl/mobile/c/ui_view.h @@ -156,6 +156,30 @@ EAPI void ui_view_set_indicator(ui_view *view, ui_view_indicator indicator); EAPI ui_view_indicator ui_view_get_indicator(ui_view *view); /** + * @breif Set the array of view's available rotations. + * + * @note Set an array of rotation values. + * For instance, {0, 90, 180, 270}. These rotation values depends on the system support. + * + * @param rotations The array of rotation values. + * @param count The number of arrays of rotatons. + * + * @see ui_view_get_available_rotations + */ +EAPI bool ui_view_set_available_rotations(ui_view *view, const int *rotations, unsigned int count); + +/** + * @brief Get the array of view's available rotations. + * + * @param count The number of arrays of rotations. + * + * @return The array of rotation values. + * + * @see ui_view_set_available_rotations + */ +EAPI const int *ui_view_get_available_rotations(ui_view *view, unsigned int *count); + +/** * @brief Set content removable. * * @param view An ui_view instance. diff --git a/src/include/interface/UiIfaceView.h b/src/include/interface/UiIfaceView.h index 5e21699..fd22773 100644 --- a/src/include/interface/UiIfaceView.h +++ b/src/include/interface/UiIfaceView.h @@ -85,6 +85,30 @@ public: virtual void setIndicator(UiViewIndicator indicator); /** + * @breif Set the array of view's available rotations. + * + * @note Set an array of rotation values. + * For instance, {0, 90, 180, 270}. These rotation values depends on the system support. + * + * @param rotations The array of rotation values. + * @param count The number of arrays of rotations. + * + * @see getAvailableRotations() + */ + virtual bool setAvailableRotations(const int *rotations, unsigned int count); + + /** + * @brief Get the array of view's available rotations. + * + * @param count The number of arrays of rotations. + * + * @return The array of rotation values. + * + * @see setAvailableRotations() + */ + const int *getAvailableRotations(unsigned int *count); + + /** * @brief Return a style name of this view. * * @return style name of view. diff --git a/src/lib/efl/UiBaseView.cpp b/src/lib/efl/UiBaseView.cpp index c661bd0..20be99a 100644 --- a/src/lib/efl/UiBaseView.cpp +++ b/src/lib/efl/UiBaseView.cpp @@ -117,6 +117,25 @@ void UiBaseView::setIndicator(UiViewIndicator indicator) viewmgr->setIndicator(indicator); } +bool UiBaseView::setAvailableRotations(const int *rotations, unsigned int count) +{ + if (!UiIfaceView::setAvailableRotations(rotations, count)) { + return false; + } + + UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR; + + if (!viewmgr) { + LOGE("Failed to get a viewmgr"); + return false; + } + + if (this == viewmgr->getLastView()) + elm_win_wm_rotation_available_rotations_set(viewmgr->getWindow(), rotations, count); + + return true; +} + void UiBaseView::onRotate(int degree) { } diff --git a/src/lib/efl/UiBaseViewmgr.cpp b/src/lib/efl/UiBaseViewmgr.cpp index b822edb..d3b1e02 100644 --- a/src/lib/efl/UiBaseViewmgr.cpp +++ b/src/lib/efl/UiBaseViewmgr.cpp @@ -49,6 +49,7 @@ private: bool _createScroller(Elm_Conformant *conform); bool _createBaseLayout(Elm_Scroller *scroller, const char *style); bool _setIndicator(UiViewIndicator indicator); + void _setAvailableRotations(UiBaseView *view); void _activateTopView(); bool _init(); bool _term(); @@ -174,6 +175,7 @@ void UiBaseViewmgrImpl::_activateTopView() elm_object_part_content_set(this->getBase(), "content", content); + this->_setAvailableRotations(view); this->_setIndicator(view->getIndicator()); } @@ -210,6 +212,16 @@ bool UiBaseViewmgrImpl::_setIndicator(UiViewIndicator indicator) return true; } +void UiBaseViewmgrImpl::_setAvailableRotations(UiBaseView *view) +{ + const int *rotations = NULL; + unsigned int count = 0; + + rotations = view->getAvailableRotations(&count); + + elm_win_wm_rotation_available_rotations_set(this->getWindow(), rotations, count); +} + bool UiBaseViewmgrImpl::_createConformant(Elm_Win *win) { Elm_Conformant *conform = elm_conformant_add(win); @@ -377,6 +389,7 @@ bool UiBaseViewmgrImpl::popView() elm_layout_signal_emit(effect, "view,pop", "viewmgr"); + this->_setAvailableRotations(pview); this->_setIndicator(pview->getIndicator()); return true; @@ -422,6 +435,7 @@ UiBaseView * UiBaseViewmgrImpl::pushView(UiBaseView *view) elm_layout_signal_emit(effect, "view,push", "viewmgr"); + this->_setAvailableRotations(view); this->_setIndicator(view->getIndicator()); return view; diff --git a/src/lib/efl/mobile/c/ui_view.cpp b/src/lib/efl/mobile/c/ui_view.cpp index 151ec94..9ec890e 100644 --- a/src/lib/efl/mobile/c/ui_view.cpp +++ b/src/lib/efl/mobile/c/ui_view.cpp @@ -233,6 +233,18 @@ EAPI ui_view_orientation_mode ui_view_get_orientation_mode(ui_view *view) return view->getOrientationMode(); } +EAPI bool ui_view_set_available_rotations(ui_view *view, const int *rotations, unsigned int count) +{ + if (!validate_view(view)) return false; + return view->setAvailableRotations(rotations, count); +} + +EAPI const int *ui_view_get_available_rotations(ui_view *view, unsigned int *count) +{ + if (!validate_view(view)) return false; + return view->getAvailableRotations(count); +} + EAPI bool ui_view_set_transition_style(ui_view *view, const char *style) { if (!validate_view(view)) return false; diff --git a/src/lib/interface/UiIfaceView.cpp b/src/lib/interface/UiIfaceView.cpp index 87c6411..a62a54f 100644 --- a/src/lib/interface/UiIfaceView.cpp +++ b/src/lib/interface/UiIfaceView.cpp @@ -37,12 +37,14 @@ private: UiIfaceView *_view = NULL; T _content = NULL; ///< A content instance for a screen as a view. string _name; ///< View name. - string _transition_style = "default"; ///< View transition style name. + string _transitionStyle = "default"; ///< View transition style name. UiIfaceViewmgr *_viewmgr = NULL; ///< Viewmgr which this view belongs to. UiViewState _state = UI_VIEW_STATE_UNLOAD; ///< View state. UiViewIndicator _indicator = UI_VIEW_INDICATOR_DEFAULT; ///< View indicator mode. - bool _event_block = false; ///< State of event block. - bool _removable_content = true; ///< When this value is true, view removes it's content internally on unload state. + int *_rotations = NULL; ///< The pointer of rotation values. + unsigned int _rotationCount = 0; ///< The number of available rotations. + bool _eventBlock = false; ///< State of event block. + bool _removableContent = true; ///< When this value is true, view removes it's content internally on unload state. public: void setEventBlock(bool block); @@ -63,6 +65,8 @@ public: bool setTransitionStyle(const char *style); void setRemovableContent(bool removable); void setIndicator(UiViewIndicator indicator); + bool setAvailableRotations(const int *rotations, unsigned int count); + const int *getAvailableRotations(unsigned int *count); const char *getTransitionStyle(); const char *getName(); T getContent(); @@ -74,14 +78,16 @@ public: } +#define MAX_NUM_OF_AVAILABLE_ROTATIONS 4 + bool UiIfaceViewImpl::getEventBlock() { - return this->_event_block; + return this->_eventBlock; } void UiIfaceViewImpl::setEventBlock(bool block) { - this->_event_block = block; + this->_eventBlock = block; } void UiIfaceViewImpl::onLoad() @@ -130,6 +136,8 @@ UiIfaceViewImpl::UiIfaceViewImpl(UiIfaceView *view, const char *name) UiIfaceViewImpl::~UiIfaceViewImpl() { this->_viewmgr->removeView(this->_view); + + if (this->_rotations) delete[](this->_rotations); } bool UiIfaceViewImpl::setContent(T content) @@ -147,13 +155,13 @@ T UiIfaceViewImpl::unsetContent() bool UiIfaceViewImpl::setTransitionStyle(const char *style) { - this->_transition_style.assign(style); + this->_transitionStyle.assign(style); return true; } void UiIfaceViewImpl::setRemovableContent(bool removable) { - this->_removable_content = removable; + this->_removableContent = removable; //FIXME: If this api is called on unload state? should we remove content right now? } @@ -163,9 +171,45 @@ void UiIfaceViewImpl::setIndicator(UiViewIndicator indicator) this->_indicator = indicator; } +bool UiIfaceViewImpl::setAvailableRotations(const int *rotations, unsigned int count) +{ + if (count <= 0) { + LOGE("Invalid count value %d count must bigger than 0", count); + return false; + } + + this->_rotations = new int[count]; + if (!this->_rotations) { + LOGE("Allocation failed"); + return false; + } + + for (unsigned int i = 0; i < count; i++) { + this->_rotations[i] = rotations[i]; + } + + this->_rotationCount = count; + + return true; +} + +const int *UiIfaceViewImpl::getAvailableRotations(unsigned int *count) +{ + static int rots[MAX_NUM_OF_AVAILABLE_ROTATIONS] = {0, 90, 180, 270}; + + if (this->_rotationCount > 0) { + *count = this->_rotationCount; + return this->_rotations; + } + else { + *count = MAX_NUM_OF_AVAILABLE_ROTATIONS; + return rots; + } +} + const char *UiIfaceViewImpl::getTransitionStyle() { - return this->_transition_style.c_str(); + return this->_transitionStyle.c_str(); } const char *UiIfaceViewImpl::getName() @@ -185,7 +229,7 @@ UiViewState UiIfaceViewImpl::getState() bool UiIfaceViewImpl::getRemovableContent() { - return this->_removable_content; + return this->_removableContent; } UiViewIndicator UiIfaceViewImpl::getIndicator() @@ -287,6 +331,16 @@ void UiIfaceView::setIndicator(UiViewIndicator indicator) this->_impl->setIndicator(indicator); } +bool UiIfaceView::setAvailableRotations(const int *rotations, unsigned int count) +{ + return this->_impl->setAvailableRotations(rotations, count); +} + +const int *UiIfaceView::getAvailableRotations(unsigned int *count) +{ + return this->_impl->getAvailableRotations(count); +} + const char *UiIfaceView::getTransitionStyle() { return this->_impl->getTransitionStyle(); -- 2.7.4