From 34e34286925720a144e8b1c5ef90fe4e51339308 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 18 Feb 2016 21:44:42 +0900 Subject: [PATCH] clarify class visibility. Change-Id: I0a2556521d711ab239e7d684c39dda900584b9df --- src/efl/mobile/ui_basic_view.cpp | 4 +-- src/efl/mobile/ui_basic_view.h | 11 +++--- src/efl/ui_controller.cpp | 5 +++ src/efl/ui_controller.h | 6 ++-- src/efl/ui_view.cpp | 6 ++++ src/efl/ui_view.h | 1 + src/efl/ui_viewmgr.h | 27 ++++++++------ src/interface/ui_controller_base.cpp | 2 +- src/interface/ui_controller_base.h | 17 +++++---- src/interface/ui_view_base.cpp | 4 +-- src/interface/ui_view_base.h | 53 ++++++++++++++------------- src/interface/ui_viewmgr_base.cpp | 26 +++++++------- src/interface/ui_viewmgr_base.h | 69 ++++++++++++++++++------------------ 13 files changed, 128 insertions(+), 103 deletions(-) diff --git a/src/efl/mobile/ui_basic_view.cpp b/src/efl/mobile/ui_basic_view.cpp index 20e62bd..d399efa 100644 --- a/src/efl/mobile/ui_basic_view.cpp +++ b/src/efl/mobile/ui_basic_view.cpp @@ -31,9 +31,7 @@ bool ui_basic_view::create_layout() { if (this->layout) return false; - ui_viewmgr *viewmgr = dynamic_cast(ui_view_base::get_viewmgr()); - - Evas_Object *layout = elm_layout_add(viewmgr->get_base()); + Evas_Object *layout = elm_layout_add(this->get_parent()); if (!layout) { diff --git a/src/efl/mobile/ui_basic_view.h b/src/efl/mobile/ui_basic_view.h index cbefb47..d9a1add 100644 --- a/src/efl/mobile/ui_basic_view.h +++ b/src/efl/mobile/ui_basic_view.h @@ -30,6 +30,7 @@ class ui_basic_view: public ui_view { private: Evas_Object *layout; //Base layout for view + bool create_layout(); bool destroy_layout(); @@ -42,11 +43,6 @@ public: ui_basic_view(ui_controller *controller, const char *name = NULL); virtual ~ui_basic_view(); - Evas_Object *get_base() - { - return this->layout; - } - Evas_Object *set_content(Evas_Object *content, const char *title = NULL); Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Evas_Object *icon, Evas_Object *title_left_btn, Evas_Object *title_right_btn); bool set_title_badge(const char *text); @@ -55,6 +51,11 @@ public: bool set_title_left_btn(Evas_Object *title_left_btn); bool set_title_right_btn(Evas_Object *title_right_btn); bool set_title(const char *text); + + virtual Evas_Object *get_base() + { + return this->layout; + } }; } diff --git a/src/efl/ui_controller.cpp b/src/efl/ui_controller.cpp index 58e56f1..68369f5 100644 --- a/src/efl/ui_controller.cpp +++ b/src/efl/ui_controller.cpp @@ -24,3 +24,8 @@ ui_view * ui_controller::get_view() if (!view) return NULL; return dynamic_cast(view); } + +ui_controller::~ui_controller() +{ + +} diff --git a/src/efl/ui_controller.h b/src/efl/ui_controller.h index 9f032ae..3414930 100644 --- a/src/efl/ui_controller.h +++ b/src/efl/ui_controller.h @@ -25,11 +25,9 @@ namespace efl class ui_controller: public ui_controller_base { public: - virtual ~ui_controller() - { - } - ui_view *get_view(); + virtual ~ui_controller(); + ui_view *get_view(); virtual void load() {} virtual void unload() {} virtual void active() {} diff --git a/src/efl/ui_view.cpp b/src/efl/ui_view.cpp index 6ae7399..635e9fd 100644 --- a/src/efl/ui_view.cpp +++ b/src/efl/ui_view.cpp @@ -58,3 +58,9 @@ void ui_view::unload_content() Evas_Object *pcontent = this->set_content(NULL); if (pcontent) evas_object_del(pcontent); } + +Evas_Object *ui_view ::get_parent() +{ + ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); + return viewmgr->get_base(); +} diff --git a/src/efl/ui_view.h b/src/efl/ui_view.h index 3ec530d..3a7c6ee 100644 --- a/src/efl/ui_view.h +++ b/src/efl/ui_view.h @@ -40,6 +40,7 @@ protected: virtual void load(); virtual void unload(); virtual void unload_content(); + Evas_Object *get_parent(); }; } diff --git a/src/efl/ui_viewmgr.h b/src/efl/ui_viewmgr.h index 4bb9273..06aa65b 100644 --- a/src/efl/ui_viewmgr.h +++ b/src/efl/ui_viewmgr.h @@ -27,6 +27,8 @@ class ui_view; class ui_viewmgr: public ui_viewmgr_base { + friend class ui_view; + private: Evas_Object *win; Evas_Object *conform; @@ -35,25 +37,30 @@ private: bool create_conformant(Evas_Object *win); bool create_base_layout(Evas_Object *conform); -public: - ui_viewmgr(const char *pkg); - ~ui_viewmgr(); - - bool activate(); - bool deactivate(); - ui_view *push_view(ui_view *view); - bool pop_view(); - - //FIXME: Make this private +protected: Evas_Object *get_base() { return this->layout; } +public: + ui_viewmgr(const char *pkg); + virtual ~ui_viewmgr(); + + virtual bool activate(); + virtual bool deactivate(); + virtual ui_view *push_view(ui_view *view); + virtual bool pop_view(); + Evas_Object *get_window() { return this->win; } + + Evas_Object *get_conformant() + { + return this->conform; + } }; } diff --git a/src/interface/ui_controller_base.cpp b/src/interface/ui_controller_base.cpp index 1fa7901..84aa2b9 100644 --- a/src/interface/ui_controller_base.cpp +++ b/src/interface/ui_controller_base.cpp @@ -20,7 +20,7 @@ void ui_controller_base::set_view(ui_view_base *view) { if (this->view) { - //TODO: ? + this->view->set_controller(NULL); } this->view = view; } diff --git a/src/interface/ui_controller_base.h b/src/interface/ui_controller_base.h index b4902c2..907ff2f 100644 --- a/src/interface/ui_controller_base.h +++ b/src/interface/ui_controller_base.h @@ -32,9 +32,19 @@ class ui_view_base; */ class ui_controller_base { + friend class ui_view_base; + private: ui_view_base *view; + void set_view(ui_view_base *view); + +protected: + ui_view_base *get_view() + { + return this->view; + } + public: ui_controller_base() : view(NULL) @@ -98,13 +108,6 @@ public: * @note When this view is on destroying by popping or deleting. */ virtual void destroy() = 0; - - void set_view(ui_view_base *view); - - ui_view_base *get_view() - { - return this->view; - } }; #endif /* UI_CONTROLLER_BASE_H_ */ diff --git a/src/interface/ui_view_base.cpp b/src/interface/ui_view_base.cpp index 1d0ed03..c5a8df4 100644 --- a/src/interface/ui_view_base.cpp +++ b/src/interface/ui_view_base.cpp @@ -111,8 +111,8 @@ ui_controller_base* ui_view_base::set_controller(ui_controller_base *controller) { ui_controller_base *prev_controller = this->controller; this->controller = controller; - controller->set_view(this); - prev_controller->set_view(NULL); + if (controller) controller->set_view(this); + if (prev_controller) prev_controller->set_view(NULL); return prev_controller; } diff --git a/src/interface/ui_view_base.h b/src/interface/ui_view_base.h index d7b5cd2..8dd7b83 100644 --- a/src/interface/ui_view_base.h +++ b/src/interface/ui_view_base.h @@ -41,6 +41,9 @@ class ui_controller_base; */ class ui_view_base { + friend class ui_viewmgr_base; + friend class ui_controller_base; + private: /// View state definition enum ui_view_state @@ -62,8 +65,6 @@ private: bool event_block; ///< State of event block. bool removable_content; ///< When this value is true, view removes it's content internally on unload state. - friend class ui_viewmgr_base; - protected: /** @brief toggle event block @@ -141,6 +142,28 @@ protected: return this->event_block; } + /// Return a controller of this view. + const ui_controller_base* get_controller() + { + return this->controller; + } + + /// Return a viewmgr which this view is belonging to + ui_viewmgr_base *get_viewmgr() + { + return this->viewmgr; + } + + /** @brief This is for replacing or setting a controller of the view. + * + * @param controller a new controller. It allows @c NULL for canceling the previous controller. + * @return A previous controller. If it wasn't, the return value will be @c NULL + * + * @warning Be aware deletion of controller passed here will be taken cover by ui_view_base. + * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_view_base is deleted. + */ + ui_controller_base* set_controller(ui_controller_base *controller); + public: /** @brief This is a constructor for initializing this view resources. * @@ -160,16 +183,6 @@ public: ///Destructor for terminating view. virtual ~ui_view_base(); - /** @brief This is for replacing or setting a controller of the view. - * - * @param controller a new controller. It allows @c NULL for canceling the previous controller. - * @return A previous controller. If it wasn't, the return value will be @c NULL - * - * @warning Be aware deletion of controller passed here will be taken cover by ui_view_base. - * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_view_base is deleted. - */ - ui_controller_base* set_controller(ui_controller_base *controller); - /** @brief This is for replacing or setting a content of the view. * * @note @p content is a logical object that represents a view in your framework. The actual type of the content could be translated to any certain types. @@ -178,7 +191,7 @@ public: * @param content a new content. It allows @c NULL for canceling the previous content. * @return A previous content. If it wasn't, return value will be @c NULL */ - virtual T set_content(T content); + T set_content(T content); /** @brief set style of the view. * @@ -192,7 +205,7 @@ public: * If your framework doesn't support any styles then just allow a @c NULL argument and return true. Otherwise return false. * */ - virtual bool set_style(const char *style); + bool set_style(const char *style); /** @brief set content removable * @@ -203,26 +216,18 @@ public: */ void set_removable_content(bool removable); - /// Return a controller of this view. - const ui_controller_base* get_controller() - { - return this->controller; - } /// Return a style name of this view. const char *get_style() { return this->style.c_str(); } + /// Return a content instance of this view. T get_content() { return this->content; } - /// Return a viewmgr which this view is belonging to - ui_viewmgr_base *get_viewmgr() - { - return this->viewmgr; - } + /// Return a state of this view. ui_view_state get_state() { diff --git a/src/interface/ui_viewmgr_base.cpp b/src/interface/ui_viewmgr_base.cpp index a72906e..614c594 100644 --- a/src/interface/ui_viewmgr_base.cpp +++ b/src/interface/ui_viewmgr_base.cpp @@ -16,7 +16,7 @@ */ #include "ui_viewmgr.h" -bool ui_viewmgr_base::_connect_view(ui_view_base *view) +bool ui_viewmgr_base::connect_view(ui_view_base *view) { if (view->viewmgr) { @@ -28,21 +28,21 @@ bool ui_viewmgr_base::_connect_view(ui_view_base *view) return true; } -bool ui_viewmgr_base::_disconnect_view(ui_view_base *view) +bool ui_viewmgr_base::disconnect_view(ui_view_base *view) { if (!view->viewmgr) return false; view->viewmgr = NULL; return true; } -void ui_viewmgr_base::_set_event_block(ui_view_base *view, bool block) +void ui_viewmgr_base::set_event_block(ui_view_base *view, bool block) { if (!this->event_block) return; view->set_event_block(block); } -bool ui_viewmgr_base::_push_view_finished(ui_view_base *view) +bool ui_viewmgr_base::push_view_finished(ui_view_base *view) { ui_view_base *last = this->view_list.back(); @@ -55,12 +55,12 @@ bool ui_viewmgr_base::_push_view_finished(ui_view_base *view) //A new view has been pushed. This should be active. view->active(); - this->_set_event_block(view, true); + this->set_event_block(view, true); return true; } -bool ui_viewmgr_base::_pop_view_finished(ui_view_base *view) +bool ui_viewmgr_base::pop_view_finished(ui_view_base *view) { ui_view_base *last = this->view_list.back(); @@ -75,7 +75,7 @@ bool ui_viewmgr_base::_pop_view_finished(ui_view_base *view) //The previous view has been popped. It should become active. view->active(); - this->_set_event_block(view, true); + this->set_event_block(view, true); return true; } @@ -111,7 +111,7 @@ ui_viewmgr_base::push_view(ui_view_base *view) return NULL; } - if (!this->_connect_view(view)) + if (!this->connect_view(view)) { LOGE("connect view failed"); return NULL; @@ -124,7 +124,7 @@ ui_viewmgr_base::push_view(ui_view_base *view) { pview = this->view_list.back(); pview->inactive(); - this->_set_event_block(pview, true); + this->set_event_block(pview, true); //FIXME: Since we have no transition pview->unload(); @@ -138,7 +138,7 @@ ui_viewmgr_base::push_view(ui_view_base *view) } view->inactive(); - this->_set_event_block(view, true); + this->set_event_block(view, true); return view; } @@ -165,7 +165,7 @@ bool ui_viewmgr_base::pop_view() //last page to be popped. ui_view_base *view = this->view_list.back(); view->inactive(); - this->_set_event_block(view, true); + this->set_event_block(view, true); //Below object has to be used in child class... //Make this getter method? or define instance? @@ -174,7 +174,7 @@ bool ui_viewmgr_base::pop_view() ui_view_base *pview = *nx; pview->load(); pview->inactive(); - this->_set_event_block(pview, true); + this->set_event_block(pview, true); //FIXME: since we have no transition effect pview->active(); @@ -201,7 +201,7 @@ bool ui_viewmgr_base::insert_view_after(ui_view_base *view, ui_view_base *after) bool ui_viewmgr_base::remove_view(ui_view_base *view) { this->view_list.remove(view); - this->_disconnect_view(view); + this->disconnect_view(view); //TODO: If this view is the top on the stack ? return true; diff --git a/src/interface/ui_viewmgr_base.h b/src/interface/ui_viewmgr_base.h index 772e7ea..4fdf9eb 100644 --- a/src/interface/ui_viewmgr_base.h +++ b/src/interface/ui_viewmgr_base.h @@ -37,9 +37,10 @@ class ui_view_base; */ class ui_viewmgr_base { + friend class ui_view_base; + private: - //TODO: change name to view_stack - std::list view_list; //view list. + list view_list; //view list. bool event_block; //event block on view transition. This value should be configurable by system. bool activated; //activated status of this viewmgr. @@ -51,7 +52,7 @@ private: * * @note This is s a friend function of ui_view_base */ - bool _connect_view(ui_view_base *view); + bool connect_view(ui_view_base *view); /** * @brief unlink a given view from this viewmgr. @@ -61,7 +62,7 @@ private: * * @note This is s a friend function of ui_view_base */ - bool _disconnect_view(ui_view_base *view); + bool disconnect_view(ui_view_base *view); /** * @brief toggle event blocking to the given view. @@ -71,10 +72,9 @@ private: * * @note This is s a friend function of ui_view_base */ - void _set_event_block(ui_view_base *view, bool block); + void set_event_block(ui_view_base *view, bool block); protected: - /** * @brief This function is designed for end of push transition. * @@ -84,7 +84,7 @@ protected: * @warning This function must be called definitely when push transition is finished. * @note This is s a friend function of ui_view_base */ - virtual bool _push_view_finished(ui_view_base *view); + bool push_view_finished(ui_view_base *view); /** * @brief This function is designed for end of pop transition. @@ -95,20 +95,18 @@ protected: * @warning This function must be called definitely when push transition is finished. * @note This is s a friend function of ui_view_base */ - virtual bool _pop_view_finished(ui_view_base *view); - -public: - ///Constructor. - ui_viewmgr_base(); - - ///Destructor. Delete all contained views. - virtual ~ui_viewmgr_base(); - - //Activate a viewmgr. - virtual bool activate(); + bool pop_view_finished(ui_view_base *view); - //Deactivate a viewmgr. - virtual bool deactivate(); + /** + * @brief Return a list of views which this viewmgr has. + * + * @return a pointer of list of views. + * + */ + const list* const get_view_list() + { + return &this->view_list; + } /** * @brief Push a new view into the viewmgr stack. @@ -117,7 +115,7 @@ public: * @note Normally, the current view will be hidden by a new view. * @return @c true on success, @c false otherwise. */ - virtual ui_view_base *push_view(ui_view_base *view); + ui_view_base *push_view(ui_view_base *view); /** * @brief Pop the top view from the viewmgr stack. @@ -139,7 +137,7 @@ public: * If you pass @c NULL, @c view will be inserted at the front of the view stack. * @return @c true success or @c false not. */ - virtual bool insert_view_before(ui_view_base *view, ui_view_base *before); + bool insert_view_before(ui_view_base *view, ui_view_base *before); /** * @brief Insert a view into this viewmgr stack. Specially, right after of the given view, @after @@ -149,7 +147,7 @@ public: * If you pass @c NULL, @c view will be inserted at the end of the view stack. * @return @c true success or @c false not. */ - virtual bool insert_view_after(ui_view_base *view, ui_view_base *after); + bool insert_view_after(ui_view_base *view, ui_view_base *after); /** * @brief Remove the given view from this viewmgr stack. @@ -157,7 +155,7 @@ public: * @return @c true on success or @c false if not. * */ - virtual bool remove_view(ui_view_base *view); + bool remove_view(ui_view_base *view); /** * @brief Return a stack index number of the given view. @@ -199,6 +197,19 @@ public: */ int get_view_index(const ui_view_base *view); + //Activate a viewmgr. + bool activate(); + + //Deactivate a viewmgr. + bool deactivate(); + +public: + ///Constructor. + ui_viewmgr_base(); + + ///Destructor. Delete all contained views. + virtual ~ui_viewmgr_base(); + /** * @brief Return the number of views which this viewmgr has. * @@ -221,16 +232,6 @@ public: return this->activated; } - /** - * @brief Return a list of views which this viewmgr has. - * - * @return a pointer of list of views. - * - */ - const list* const get_view_list() - { - return &this->view_list; - } }; #endif /* UI_WINDOW_BASE_H_ */ -- 2.7.4