also renamed an API from ui_viewmgr_get_view() to ui_viewmgr_get_view_by_idx().
and removed ui_iface_view::set_name().
Allow renaming of view is ridiculous because we expect view name is unique.
So users should decide its name when they create the view instance.
Change-Id: I769ded274f82cbce251fefe426555e890670095d
* @brief A constructor for an ui_standard_view.
*
* @param name view name
- *
* @param view An ui_standard_view instance.
*
+ * @warning if you don't set a view name, you could not look up the view with its name. @see ui_viewmgr_view_get_by_name().
+ *
* @see ui_view_destroy()
*/
EAPI ui_standard_view *ui_standard_view_create(const char *name);
*
* @return The ui_view instance.
*
+ * @warning if you don't set a view name, you could not look up the view with its name. @see ui_viewmgr_view_get_by_name().
+ *
* @see ui_view_destroy()
*/
EAPI ui_view *ui_view_create(const char *name);
EAPI const ui_menu *ui_view_menu_get(ui_view *view);
/**
- * @brief Set name of ui_view.
- *
- * @note A ui_view can have a unique name. Default value of the name is NULL.
- *
- * @param view An ui_view instance.
- * @param name A new name of given @p view.
- *
- * @return @c true if the given @p name is available, otherwise @c false.
- *
- * @see ui_view_name_get()
- */
-EAPI bool ui_view_name_set(ui_view *view, const char *name);
-
-/**
* @brief Return a name of this view.
*
* @param view An ui_view instance.
* @see ui_viewmgr_view_index_get()
* @see ui_viewmgr_view_count_get()
*/
-EAPI ui_view *ui_viewmgr_view_get(ui_viewmgr *viewmgr, int idx);
+EAPI ui_view *ui_viewmgr_view_get_by_idx(ui_viewmgr *viewmgr, int idx);
+
+/**
+ * @brief Return a view which is matched with the @p name.
+ *
+ * @note Every view have their names as their own identifiers.
+ *
+ * @param name The name of the view which you are looking for.
+ *
+ * @return The view which name is matched with @p name.
+ * If there were no views name matched, @c NULL will be returned.
+ *
+ * @see ui_iface_view::set_name()
+ */
+EAPI ui_view *ui_viewmgr_view_get_by_name(ui_viewmgr *viewmgr, const char *name);
/**
* @brief Get a base object of a ui_viewmgr.
*/
EAPI int ui_viewmgr_view_index_get(ui_viewmgr *viewmgr, const ui_view *view);
-//FIXME:
-//ui_view *ui_viewmgr_view_get_by_id(ui_viewmgr *viewmgr, const char *id);
-
/**
* @brief Return the number of views which this @p given viewmgr has.
*
* @brief This is a constructor for initializing this view resources.
*
* @param name view name.
+ *
+ * @warning if you don't set a view name, you could not look up the view with its name. @see ui_viewmgr_view_get_by_name()
*/
ui_view(const char *name = NULL);
ui_base_view *get_view(unsigned int idx);
/**
+ * @brief Return a view which is matched with the @p name.
+ *
+ * @note Every view have their names as their own identifiers.
+ *
+ * @param name The name of the view which you are looking for.
+ *
+ * @return The view which name is matched with @p name.
+ * If there were no views name matched, @c NULL will be returned.
+ *
+ * @see ui_iface_view::set_name()
+ */
+ ui_base_view *get_view(const char *name);
+
+ /**
* @brief Get a base object of this viewmgr.
*
* @note Normally, a base object can be used for adding additional objects.
* @brief This is a constructor for initializing this view resources.
*
* @param name view name.
+ *
+ * @warning if you don't set a view name, you could not look up the view with its name. @see ui_viewmgr_view_get_by_name()
*/
ui_iface_view(const char *name = NULL);
bool set_transition_style(const char *style);
/**
- * @brief Set name of the view.
- *
- * @note A view can have a unique name. Default value of the name is NULL.
- *
- * @param name A new name of view.
- *
- * @return true if the given @c name is available, otherwise false.
- *
- * @warning When you override this member function, you should check the name duplicate with other view or not.
- */
- bool set_name(const char *name);
-
- /**
* @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.
* @return The view which name is matched with @p name.
* If there were no views name matched, @c NULL will be returned.
*
- * @see ui_iface_view::set_name()
+ * @see ui_iface_view::get_name().
*/
ui_iface_view *get_view(const char *name);
return view->get_menu();
}
-EAPI bool ui_view_name_set(ui_view *view, const char *name)
-{
- if (!validate_view(view)) return false;
- return view->set_name(name);
-}
-
EAPI const char *ui_view_name_get(ui_view *view)
{
if (!validate_view(view)) return NULL;
return true;
}
-
EAPI ui_view *ui_viewmgr_view_push(ui_viewmgr *viewmgr, ui_view *view)
{
if (!viewmgr || !view)
return dynamic_cast<ui_view *>(viewmgr->get_last_view());
}
-EAPI ui_view *ui_viewmgr_view_get(ui_viewmgr *viewmgr, int idx)
+EAPI ui_view *ui_viewmgr_view_get_by_idx(ui_viewmgr *viewmgr, int idx)
{
if (!validate_viewmgr(viewmgr)) return NULL;
return dynamic_cast<ui_view *>(viewmgr->get_view(idx));
}
+EAPI ui_view *ui_viewmgr_view_get_by_name(ui_viewmgr *viewmgr, const char *name)
+{
+ if (!validate_viewmgr(viewmgr)) return NULL;
+ return dynamic_cast<ui_view *>(viewmgr->get_view(name));
+}
+
EAPI Evas_Object *ui_viewmgr_base_get(ui_viewmgr *viewmgr)
{
if (!validate_viewmgr(viewmgr)) return NULL;
return viewmgr->get_view_index(view);
}
-
EAPI int ui_viewmgr_view_count_get(ui_viewmgr *viewmgr)
{
if (!validate_viewmgr(viewmgr)) return -1;
return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_view(idx));
}
+ui_base_view *ui_base_viewmgr::get_view(const char *name)
+{
+ return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_view(name));
+}
+
ui_base_view *ui_base_viewmgr::get_last_view()
{
return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_last_view());
~ui_iface_view_impl();
bool set_transition_style(const char *style);
- bool set_name(const char *name);
void set_removable_content(bool removable);
void set_indicator(ui_view_indicator indicator);
const char *get_transition_style();
return true;
}
-bool ui_iface_view_impl::set_name(const char *name)
-{
- this->name.assign(name);
- return true;
-}
-
void ui_iface_view_impl::set_removable_content(bool removable)
{
this->removable_content = removable;
return this->impl->set_transition_style(style);
}
-bool ui_iface_view::set_name(const char *name)
-{
- return this->impl->set_name(name);
-}
-
void ui_iface_view::set_removable_content(bool removable)
{
this->impl->set_removable_content(removable);
bool ui_iface_viewmgr_impl::connect_view(ui_iface_view *view)
{
+ //TODO: Perform this only in debug mode?
+ //Check whether the same name of this view is already existed in this viewmgr?
+ int name_len = strlen(view->get_name());
+ const char *name = view->get_name();
+
+ for (VIEW_ITR it = this->view_list.begin(); it != this->view_list.end(); it++)
+ {
+ ui_iface_view *view = *it;
+ const char *view_name = view->get_name();
+ if (!view_name) continue;
+ int view_name_len = strlen(view_name);
+
+ //Got you!
+ if ((view_name_len == name_len) && !strcmp(name, view_name))
+ {
+ LOGE("the same name of ui_iface_view(%p) is already in this ui_iface_viewmgr(%p)", view, this);
+ return false;
+ }
+ }
+
return view->set_viewmgr(this->get_instance());
}
ui_iface_view *ui_iface_viewmgr_impl::get_view(const char *name)
{
- //FIXME: ...
+ if (!name) return NULL;
+ int name_len = strlen(name);
+
+ for (VIEW_ITR it = this->view_list.begin(); it != this->view_list.end(); it++)
+ {
+ ui_iface_view *view = *it;
+ const char *view_name = view->get_name();
+ if (!view_name) continue;
+ int view_name_len = strlen(view_name);
+
+ //Got you!
+ if ((view_name_len == name_len) && !strcmp(name, view_name))
+ {
+ return view;
+ }
+ }
+
return NULL;
}