{
if (this->layout) return false;
- ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(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)
{
{
private:
Evas_Object *layout; //Base layout for view
+
bool create_layout();
bool destroy_layout();
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);
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;
+ }
};
}
if (!view) return NULL;
return dynamic_cast<ui_view *>(view);
}
+
+ui_controller::~ui_controller()
+{
+
+}
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() {}
Evas_Object *pcontent = this->set_content(NULL);
if (pcontent) evas_object_del(pcontent);
}
+
+Evas_Object *ui_view ::get_parent()
+{
+ ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->get_viewmgr());
+ return viewmgr->get_base();
+}
virtual void load();
virtual void unload();
virtual void unload_content();
+ Evas_Object *get_parent();
};
}
class ui_viewmgr: public ui_viewmgr_base
{
+ friend class ui_view;
+
private:
Evas_Object *win;
Evas_Object *conform;
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;
+ }
};
}
{
if (this->view)
{
- //TODO: ?
+ this->view->set_controller(NULL);
}
this->view = view;
}
*/
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)
* @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_ */
{
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;
}
*/
class ui_view_base
{
+ friend class ui_viewmgr_base;
+ friend class ui_controller_base;
+
private:
/// View state definition
enum ui_view_state
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
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.
*
///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.
* @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.
*
* 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
*
*/
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()
{
*/
#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)
{
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();
//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();
//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;
}
return NULL;
}
- if (!this->_connect_view(view))
+ if (!this->connect_view(view))
{
LOGE("connect view failed");
return NULL;
{
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();
}
view->inactive();
- this->_set_event_block(view, true);
+ this->set_event_block(view, true);
return 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?
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();
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;
*/
class ui_viewmgr_base
{
+ friend class ui_view_base;
+
private:
- //TODO: change name to view_stack
- std::list<ui_view_base*> view_list; //view list.
+ list<ui_view_base*> 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
* @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<ui_view_base*>* const get_view_list()
+ {
+ return &this->view_list;
+ }
/**
* @brief Push a new view into the viewmgr stack.
* @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.
* 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
* 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.
* @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.
*/
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.
*
return this->activated;
}
- /**
- * @brief Return a list of views which this viewmgr has.
- *
- * @return a pointer of list of views.
- *
- */
- const list<ui_view_base*>* const get_view_list()
- {
- return &this->view_list;
- }
};
#endif /* UI_WINDOW_BASE_H_ */