Directly make a view and content in the same function.
Change-Id: Id470c7af4cbcc116b0ad304424c0119de85518ae
*
*/
#include "main.h"
+#include "page7.h"
#include "page6.h"
#include "page5.h"
#include "page4.h"
#include "page1.h"
Evas_Object*
-create_toolbar(Evas_Object *parent)
+create_toolbar(Evas_Object *parent, const char *style)
{
Evas_Object *toolbar;
toolbar = elm_toolbar_add(parent);
//FIXME: :( UI_View can set this style instead.
- elm_object_style_set(toolbar, "toolbar_with_title");
+ elm_object_style_set(toolbar, style);
+
+ //FIXME: If not call below API, toolbar items create with min size.
+ // It looks toolbar bug.
elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
- elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
elm_toolbar_item_append(toolbar, NULL, "Tab1", NULL, NULL);
elm_toolbar_item_append(toolbar, NULL, "Tab2", NULL, NULL);
-
- elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
+ elm_toolbar_item_append(toolbar, NULL, "Tab3", NULL, NULL);
+ elm_toolbar_item_append(toolbar, NULL, "Tab4", NULL, NULL);
return toolbar;
}
} appdata_s;
Evas_Object *create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb, appdata_s *ad);
-Evas_Object *create_toolbar(Evas_Object *parent);
+Evas_Object *create_toolbar(Evas_Object *parent, const char *style);
page6(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name, style name of view).
- Later, you could get the identity name using view->get_name();
- you could get the style name of view as well */
+ /* ui_basic_view(controller, identity name).
+ Later, you could get the identity name using view->get_name(); */
ad->viewmgr->push_view(new ui_basic_view(this, "page6"));
}
ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 6<br>With Tabar",
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 6<br>With Toolbar<br>(tabbar style)",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
[](void *data, Evas_Object *obj, void *event_info) -> void
{
appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->deactivate();
+ create_page7(ad);
},
this->ad);
//Arguments: content, title
view->set_content(content, "Title with toolbar");
- Evas_Object *toolbar = create_toolbar(view->get_base());
+ Evas_Object *toolbar = create_toolbar(view->get_base(), "toolbar_with_title");
view->set_toolbar(toolbar);
}
};
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+class page7: public ui_basic_controller
+{
+private:
+ appdata_s *ad;
+
+public:
+ page7(appdata_s *ad)
+ : ad(ad)
+ {
+ /* ui_basic_view(controller, identity name, style name of view).
+ Later, you could get the identity name using view->get_name();
+ you could get the style name of view as well */
+ ui_basic_view *view = new ui_basic_view(this, "page7");
+
+ //FIXME: It will be deleted or change to other way :(
+ // We don't have any way to support it now.
+ view->set_viewmgr(ad->viewmgr);
+
+ //Create a main content.
+ Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 7<br>With Toolbar<br>(Navigationbar style)",
+ //Prev Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->deactivate();
+ },
+ this->ad);
+
+ view->set_content(content, "Title with toolbar");
+ Evas_Object *toolbar = create_toolbar(view->get_base(), "navigationbar");
+ view->set_toolbar(toolbar);
+ ad->viewmgr->push_view(view);
+ }
+
+ ~page7()
+ {
+ }
+};
+
+void create_page7(appdata_s *ad)
+{
+ new page7(ad);
+}
virtual Evas_Object *get_base()
{
+ if (!this->layout)this->create_layout();
return this->layout;
}
};
ui_iface_controller* set_controller(ui_iface_controller *controller);
public:
+ //FIXME: This method for support a use case that user make content, view same time.
+ void set_viewmgr(ui_iface_viewmgr *viewmgr)
+ {
+ this->viewmgr = viewmgr;
+ }
+
/** @brief This is a constructor for initializing this view resources.
*
- * @param content A content instance for a screen as a view.
* @param controller view life-cycle controller interface.
* @param name view name.
*
* @warning Be aware the deletion of controller passed here will be covered by ui_iface_view.
* If you want to keep it for any reasons, please unset it using set_controller() before ui_iface_view is deleted.
*/
- ui_iface_view(T content, ui_iface_controller *controller, const char *name);
///Constructor for initializing with controller.
ui_iface_view(ui_iface_controller *controller, const char *name = NULL);
///Constructor for initializing with name.
void ui_basic_view::load()
{
- this->create_layout();
+ if (!this->layout) this->create_layout();
ui_view::load();
}
if (layout)
{
+
+ if ((!strcmp(elm_object_style_get(toolbar), "toolbar_with_title")) &&
+ ((elm_toolbar_shrink_mode_get(toolbar) != ELM_TOOLBAR_SHRINK_EXPAND)))
+ {
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ }
+ else if (!strcmp(elm_object_style_get(toolbar), "navigationbar"))
+ {
+ if (elm_toolbar_shrink_mode_get(toolbar) != ELM_TOOLBAR_SHRINK_SCROLL)
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL);
+ elm_toolbar_align_set(toolbar, 0.0);
+ }
+ elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
+
+ //FIXME: It can be deleted when the application want to handle this property.
+ // Some of application may want to select one of toolbar item when view activated.
+ elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
+
elm_object_part_content_set(layout, "toolbar", toolbar);
if (toolbar) elm_object_signal_emit(layout, "elm,state,toolbar,show", "elm");
else elm_object_signal_emit(layout, "elm,state,toolbar,hide", "elm");
Evas_Object *ui_view ::get_parent()
{
ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->get_viewmgr());
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return NULL;
+ }
return viewmgr->get_base();
}
this->controller->destroy();
}
-ui_iface_view::ui_iface_view(T content, ui_iface_controller *controller, const char *name)
- : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
- indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
-{
- if (!content) this->state = UI_VIEW_STATE_UNLOAD;
- else this->state = UI_VIEW_STATE_LOAD;
- controller->set_view(this);
-}
-
ui_iface_view::ui_iface_view(ui_iface_controller *controller, const char *name)
- : ui_iface_view(NULL, controller, name)
+ : content(NULL), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
+ indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
{
this->state = UI_VIEW_STATE_UNLOAD;
+ controller->set_view(this);
}
ui_iface_view::ui_iface_view(const char *name)
bool ui_iface_viewmgr::connect_view(ui_iface_view *view)
{
+ //FIXME: If user call a set_viewmgr() before, It should not return false.
+ /*
if (view->viewmgr)
{
LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
return false;
}
+ */
view->viewmgr = this;
return true;