bool ui_basic_view::destroy_layout()
{
if (!this->layout) return false;
- if (this->get_content())
- {
- elm_object_part_content_unset(this->layout, "elm.swallow.content");
- }
evas_object_del(this->layout);
+ this->layout = NULL;
return true;
}
bool ui_basic_view::create_layout()
{
+ if (this->layout) return false;
+
ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_base::get_viewmgr());
- Evas_Object *parent = viewmgr->get_window();
- Evas_Object *layout = elm_layout_add(parent);
+ Evas_Object *layout = elm_layout_add(viewmgr->get_base());
+
if (!layout)
{
LOGE("Failed to create a layout = ui_basic_view(%p)", this);
void ui_basic_view::unload()
{
- this->destroy_layout();
ui_view::unload();
}
return pcontent;
}
+void ui_basic_view::unload_content()
+{
+ ui_view::set_content(NULL);
+ this->destroy_layout();
+}
bool destroy_layout();
protected:
- void load();
- void unload();
+ virtual void load();
+ virtual void unload();
+ virtual void unload_content();
public:
ui_basic_view(ui_controller *controller, const char *name = NULL);
using namespace efl;
-ui_view::ui_view(ui_controller *controller, const char *name) :
- ui_view_base(controller, name)
+ui_view::ui_view(ui_controller *controller, const char *name)
+ : ui_view_base(controller, name)
{
}
{
}
-Evas_Object *
-ui_view::set_content(Evas_Object *content)
+Evas_Object *ui_view::set_content(Evas_Object *content)
{
T pcontent = ui_view_base::set_content(CONVERT_TO_T(content));
return static_cast<Evas_Object *>(pcontent);
}
-Evas_Object *
-ui_view::get_base()
+Evas_Object *ui_view::get_base()
{
ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_base::get_viewmgr());
if (!viewmgr)
{
return NULL;
}
- return viewmgr->get_base_layout();
+ return viewmgr->get_base();
}
void ui_view::load()
{
ui_view_base::load();
}
+
+void ui_view::unload()
+{
+ ui_view_base::unload();
+}
+
+void ui_view::unload_content()
+{
+ Evas_Object *pcontent = this->set_content(NULL);
+ if (pcontent) evas_object_del(pcontent);
+}
protected:
virtual void load();
+ virtual void unload();
+ virtual void unload_content();
};
}
delete(viewmgr);
}
-Evas_Object *
+bool
ui_viewmgr::create_conformant(Evas_Object *win)
{
Evas_Object *conform = elm_conformant_add(win);
- if (!conform) return NULL;
+ if (!conform) return false;
evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, conform);
elm_win_conformant_set(win, EINA_TRUE);
evas_object_show(conform);
- return conform;
+ this->conform = conform;
+
+ return true;
}
-Evas_Object *
+bool
ui_viewmgr::create_base_layout(Evas_Object *conform)
{
Evas_Object *layout = elm_layout_add(conform);
- if (!layout) return NULL;
+ if (!layout) return false;
elm_layout_theme_set(layout, "layout", "application", "default");
elm_object_content_set(conform, layout);
- return layout;
+ this->layout = layout;
+
+ return true;
}
ui_viewmgr::ui_viewmgr(const char *pkg)
this);
//Conformant: Make this configurable.
- this->conform = this->create_conformant(this->win);
-
- if (!this->conform)
+ if (!this->create_conformant(this->win))
{
LOGE("Failed to create a conformant (%s)", pkg);
return;
}
- this->base_layout = this->create_base_layout(this->conform);
-
- if (!this->base_layout)
+ if (!this->create_base_layout(this->conform))
{
LOGE("Failed to create a base layout (%s)", pkg);
return;
{
ui_viewmgr_base :: activate();
- elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
+ elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
ui_view *view = dynamic_cast<ui_view *>(this->get_last_view());
//TODO: get parent?
Evas_Object *content = view->get_base();
- if (content == this->base_layout)
+ if (content == this->get_base())
{
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
}
else
{
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
}
evas_object_show(this->win);
//TODO: get parent?
Evas_Object *content = view->get_base();
- if (content == this->base_layout)
+ if (content == this->get_base())
{
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
}
else
{
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
}
return true;
//Don't prepare yet if viewmgr is not activated.
if (!this->is_activated()) return view;
- elm_object_part_content_unset(this->base_layout, "elm.swallow.content");
+ elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
Evas_Object *content = view->get_base();
- if (content == this->base_layout)
+ if (content == this->get_base())
{
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_content()));
}
else
{
LOGE("view->base = %p", view->get_base());
- elm_object_part_content_set(this->base_layout, "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
+ elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
}
return view;
private:
Evas_Object *win;
Evas_Object *conform;
- Evas_Object *base_layout;
+ Evas_Object *layout;
- Evas_Object *create_conformant(Evas_Object *win);
- Evas_Object *create_base_layout(Evas_Object *conform);
+ bool create_conformant(Evas_Object *win);
+ bool create_base_layout(Evas_Object *conform);
public:
ui_viewmgr(const char *pkg);
bool pop_view();
//FIXME: Make this private
- Evas_Object *get_base_layout()
+ Evas_Object *get_base()
{
- return this->base_layout;
+ return this->layout;
}
Evas_Object *get_window()
void ui_view_base::unload()
{
this->state = UI_VIEW_STATE_UNLOAD;
+ if (this->get_removable_content())
+ {
+ this->unload_content();
+ return;
+ }
if (!this->content) return;
if (!this->controller) return;
this->controller->unload();
}
ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name)
- : content(content), controller(controller), name(string(name ? name : "")), style(string()), viewmgr(NULL), state(UI_VIEW_STATE_LOAD), event_block(
- false)
+ : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
+ event_block(false), removable_content(true)
{
if (!content) this->state = UI_VIEW_STATE_UNLOAD;
else this->state = UI_VIEW_STATE_LOAD;
if (this->controller) delete (this->controller);
}
-ui_controller_base*
-ui_view_base::set_controller(ui_controller_base *controller)
+ui_controller_base* ui_view_base::set_controller(ui_controller_base *controller)
{
ui_controller_base *prev_controller = this->controller;
this->controller = controller;
this->style.assign(style);
return true;
}
+
+void ui_view_base::set_removable_content(bool removable)
+{
+ this->removable_content = removable;
+
+ //FIXME: If this api is called on unload state? should we remove content right now?
+}
};
T content; ///< A content instance for a screen as a view.
- ui_controller_base *controller; ///< view life-cycle controller interface.
- std::string name; ///< view name
- std::string style; ///< view style name.
- ui_viewmgr_base *viewmgr; ///< viewmgr which this view belongs to.
- ui_view_state state; ///< view state
- bool event_block; ///< state of event block.
-
- //Need to check.
+ ui_controller_base *controller; ///< View life-cycle controller interface.
+ std::string name; ///< View name
+ std::string style; ///< View style name.
+ ui_viewmgr_base *viewmgr; ///< Viewmgr which this view belongs to.
+ ui_view_state state; ///< 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;
- //friend bool ui_viewmgr_base ::_connect_view(ui_view_base *view);
- //friend bool ui_viewmgr_base ::_disconnect_view(ui_view_base<T> *view);
- //friend void ui_viewmgr_base ::_set_event_block(ui_view_base<T> *view);
- //friend bool ui_viewmgr_base ::_push_view_finished(ui_view_base<T> *view);
- //friend bool ui_viewmgr_base ::_pop_view_finished(ui_view_base<T> *view);
protected:
*/
virtual void destroy();
+
+ virtual void unload_content() = 0;
+
/// Return the state of event block.
bool get_event_block()
{
* @warning Be aware the deletion of controller passed here will be covered by ui_view_base.
* If you want to keep it for any reasons, please unset it using set_controller() before ui_view_base is deleted.
*/
-
- //Constructor
ui_view_base(T content, ui_controller_base *controller, const char *name);
///Constructor for initializing with controller.
ui_view_base(ui_controller_base *controller, const char *name = NULL);
/** @brief This is for replacing or setting a content of the view.
*
- * @note @c 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.
+ * @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.
* For instance, the type could be Evas_Object * in EFL and Layer * in Dali.
*
* @param content a new content. It allows @c NULL for canceling the previous content.
*/
virtual bool set_style(const char *style);
+ /** @brief set content removable
+ *
+ * @param removable if @p removable is @c true, content of this view will be removed on unload state. @c false otherwise.
+ *
+ * @warning You should not remove a view content manually on unload status if removable content is set.
+ *
+ */
+ void set_removable_content(bool removable);
+
/// Return a controller of this view.
const ui_controller_base* get_controller()
{
{
return this->state;
}
+ /// Return a state of removeable content.
+ bool get_removable_content()
+ {
+ return this->removable_content;
+ }
};
#endif /* UI_VIEW_BASE_H_ */
*/
ui_view_base *get_view(const char *name)
{
- //TODO: ...
+ //FIXME: ...
return NULL;
}
- //TODO: Doc.
+ //FIXME: Doc.
ui_view_base *get_last_view();
/**
view->set_content(content, "Title");
}
-
- void unload()
- {
- //You could destroy the content here for save memory.
- ui_view *view = this->get_view();
- Evas_Object *content = view->set_content(NULL);
- evas_object_del(content);
- }
};
//Arguments: content, title, subtitle, icon, title left button, title right button
view->set_content(content, "Title Buttons", NULL, NULL, left_title_btn, right_title_btn);
}
-
- void unload()
- {
- //You could destroy the content here for save memory.
- ui_view *view = this->get_view();
- Evas_Object *content = view->set_content(NULL);
- evas_object_del(content);
- }
};
//Arguments: content, title, subtitle, icon, title left button, title right button
view->set_content(content, "Title", "Subtitle", NULL, NULL, NULL);
}
-
- void unload()
- {
- //You could destroy the content here for save memory.
- ui_view *view = this->get_view();
- Evas_Object *content = view->set_content(NULL);
- evas_object_del(content);
- }
};
view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
view->set_title_badge("999+");
}
-
- void unload()
- {
- //You could destroy the content here for save memory.
- ui_view *view = this->get_view();
- Evas_Object *content = view->set_content(NULL);
- evas_object_del(content);
- }
-
};