SET(PACKAGE org.tizen.ui-viewmgr)
SET(SRCS
- src/interface/ui_controller_interface.cpp
- src/interface/ui_view_interface.cpp
- src/interface/ui_viewmgr_interface.cpp
+ src/interface/ui_iface_controller.cpp
+ src/interface/ui_iface_view.cpp
+ src/interface/ui_iface_viewmgr.cpp
src/efl/ui_controller.cpp
src/efl/ui_view.cpp
src/efl/ui_viewmgr.cpp
}
//Set software back key, if it's needed
- ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_interface::get_viewmgr());
+ ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_iface_view::get_viewmgr());
if (viewmgr->need_soft_key())
{
Evas_Object *prev_btn = elm_button_add(layout);
ui_view * ui_controller::get_view()
{
- ui_view_interface *view = ui_controller_interface::get_view();
+ ui_iface_view *view = ui_iface_controller::get_view();
if (!view) return NULL;
return dynamic_cast<ui_view *>(view);
}
*
* @brief UI Controller. This is a class for handling of life-cycle events from user side.
*/
-class ui_controller: public viewmgr::ui_controller_interface
+class ui_controller: public viewmgr::ui_iface_controller
{
public:
///Destructor.
using namespace viewmgr;
ui_view::ui_view(ui_controller *controller, const char *name, const char *style)
- : ui_view_interface(controller, name, style)
+ : ui_iface_view(controller, name, style)
{
}
Evas_Object *ui_view::set_content(Evas_Object *content)
{
- T pcontent = ui_view_interface::set_content(CONVERT_TO_T(content));
+ T pcontent = ui_iface_view::set_content(CONVERT_TO_T(content));
return static_cast<Evas_Object *>(pcontent);
}
Evas_Object *ui_view::get_base()
{
- ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_view_interface::get_viewmgr());
+ ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_iface_view::get_viewmgr());
if (!viewmgr)
{
return NULL;
{
if (this->get_indicator() == indicator) return;
- ui_view_interface::set_indicator(indicator);
+ ui_iface_view::set_indicator(indicator);
ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->get_viewmgr());
* UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands.
* It's not mandatory but view should describe the transitions in this class.
*
- * @warning When the transitions are finished, the view must to call ui_viewmgr_interface :: _push_finished(), ui_viewmgr_interface :: _pop_finished() in order that
- * The ui_viewmgr_interface keeps the view states exactly.
+ * @warning When the transitions are finished, the view must to call ui_iface_viewmgr :: _push_finished(), ui_iface_viewmgr :: _pop_finished() in order that
+ * The ui_iface_viewmgr keeps the view states exactly.
*/
-class ui_view: public viewmgr::ui_view_interface
+class ui_view: public viewmgr::ui_iface_view
{
friend class ui_viewmgr;
}
ui_viewmgr::ui_viewmgr(const char *pkg, ui_key_listener *key_listener)
- : ui_viewmgr_interface(), key_listener(key_listener)
+ : ui_iface_viewmgr(), key_listener(key_listener)
{
if (!pkg)
{
bool ui_viewmgr::activate()
{
- ui_viewmgr_interface::activate();
+ ui_iface_viewmgr::activate();
elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
bool ui_viewmgr::deactivate()
{
- ui_viewmgr_interface::deactivate();
+ ui_iface_viewmgr::deactivate();
//FIXME: based on the profile, we should app to go behind or terminate.
if (true)
bool ui_viewmgr::pop_view()
{
if (this->get_view_count() == 1) this->deactivate();
- else if(!ui_viewmgr_interface::pop_view()) return false;
+ else if(!ui_iface_viewmgr::pop_view()) return false;
ui_view *view = dynamic_cast<ui_view *>(this->get_last_view());
ui_view * ui_viewmgr::push_view(ui_view *view)
{
- ui_viewmgr_interface::push_view(view);
+ ui_iface_viewmgr::push_view(view);
//Don't prepare yet if viewmgr is not activated.
if (!this->is_activated()) return view;
ui_view *ui_viewmgr::get_last_view()
{
- return dynamic_cast<ui_view *>(ui_viewmgr_interface::get_last_view());
+ return dynamic_cast<ui_view *>(ui_iface_viewmgr::get_last_view());
}
*
* @warning viewmgr will remove all containing views when it's destroyed.
*/
-class ui_viewmgr: public viewmgr::ui_viewmgr_interface
+class ui_viewmgr: public viewmgr::ui_iface_viewmgr
{
friend class ui_view;
+++ /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.
- *
- */
-#include "ui_viewmanager_interface.h"
-
-using namespace viewmgr;
-
-void ui_controller_interface::set_view(ui_view_interface *view)
-{
- if (this->view)
- {
- this->view->set_controller(NULL);
- }
- this->view = view;
-}
+++ /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.
- *
- */
-#ifndef UI_CONTROLLER_INTERFACE_H_
-#define UI_CONTROLLER_INTERFACE_H_
-
-namespace viewmgr {
-
-class ui_view_interface;
-
-/**
- * @class ui_controller_interface.
- *
- * @ingroup viewmgr
- *
- * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side.
- */
-class ui_controller_interface
-{
- friend class ui_view_interface;
-
-private:
- ui_view_interface *view;
-
- void set_view(ui_view_interface *view);
-
-protected:
- /**
- * @brief Return a view which is matched with controller
- *
- * @return The view which is matched with controller
- *
- * @note User can set a controller 2 ways, 1. send a controller instance when view created,
- * 2. call set_view() method with controller instance.
- *
- * @see set_view()
- */
- ui_view_interface *get_view()
- {
- return this->view;
- }
-
-public:
- ///Constructor.
- ui_controller_interface() :
- view(NULL)
- {
- }
-
- ///Destructor.
- virtual ~ui_controller_interface()
- {
- }
-
- /** @brief load callback.
- *
- * @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called.
- * In the most cases, this callback will be triggered with this step load -> inactive -> active.
- */
- virtual void load() = 0;
-
- /** @brief unload callback.
- *
- * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario.
- * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view.
- * If the view content is not alive, the unload won't be called.
- * In the most cases, this callback will be triggered with this step. inactive -> unload -> destroy
- */
- virtual void unload() = 0;
-
- /** @brief active callback.
- *
- * @note View is on active state after show transition is finished.
- * From whatever the state, if the view is on the screen, the active callback will be called.
- * In the most cases, this callback will be triggered with this step. load -> inactive -> active
- */
- virtual void active() = 0;
-
- /** @brief inactive callback.
- *
- * @note View is on inactive state. Get ready for unload. Hide transition may be triggered at this point.
- * Inactive state is triggered on this scenario that the view is still visible but it's not interactive with users.
- * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the inactive state will be triggered.
- * Some UI controls such as a center popup or a menu popup blocks the view, this view may be inactive but still visible in someway (with transparency)
- */
- virtual void inactive() = 0;
-
- /** @brief pause callback.
- *
- * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ...
- * When Window turns to deactivate. (@see ui_viewmgr_base :: deactivate()).
- * If the view were inactive or unload state, the pause won't be called.
- */
- virtual void pause() = 0;
-
- /** @brief resume callback.
- *
- * @note View is turning back to the active state again from pause.
- * When the system allows the application turns to activate.
- * When the Window turns to activate. (@see ui_viewmgr_base :: activate())
- */
- virtual void resume() = 0;
-
- /** @brief destroy callback.
- *
- * @note When this view is on destroying by popping or deleting.
- */
- virtual void destroy() = 0;
-};
-
-}
-
-#endif /* UI_CONTROLLER_INTERFACE_H_ */
--- /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.
+ *
+ */
+#include "ui_viewmanager_interface.h"
+
+using namespace viewmgr;
+
+void ui_iface_controller::set_view(ui_iface_view *view)
+{
+ if (this->view)
+ {
+ this->view->set_controller(NULL);
+ }
+ this->view = view;
+}
--- /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.
+ *
+ */
+#ifndef UI_CONTROLLER_INTERFACE_H_
+#define UI_CONTROLLER_INTERFACE_H_
+
+namespace viewmgr {
+
+class ui_iface_view;
+
+/**
+ * @class ui_iface_controller.
+ *
+ * @ingroup viewmgr
+ *
+ * @brief UI Controller Interface. This interface is designed for handling of life-cycle events from user side.
+ */
+class ui_iface_controller
+{
+ friend class ui_iface_view;
+
+private:
+ ui_iface_view *view;
+
+ void set_view(ui_iface_view *view);
+
+protected:
+ /**
+ * @brief Return a view which is matched with controller
+ *
+ * @return The view which is matched with controller
+ *
+ * @note User can set a controller 2 ways, 1. send a controller instance when view created,
+ * 2. call set_view() method with controller instance.
+ *
+ * @see set_view()
+ */
+ ui_iface_view *get_view()
+ {
+ return this->view;
+ }
+
+public:
+ ///Constructor.
+ ui_iface_controller() :
+ view(NULL)
+ {
+ }
+
+ ///Destructor.
+ virtual ~ui_iface_controller()
+ {
+ }
+
+ /** @brief load callback.
+ *
+ * @note Now, this view is moving onto the screen. Get ready for this view. If this view content is alive, load callback won't be called.
+ * In the most cases, this callback will be triggered with this step load -> inactive -> active.
+ */
+ virtual void load() = 0;
+
+ /** @brief unload callback.
+ *
+ * @note Remove resources with regards to this view for saving memory or keep the content for performance. It's up to your scenario.
+ * Unload will be called just right before when the view is going to be deleted by popping or it's piled under the more than one view.
+ * If the view content is not alive, the unload won't be called.
+ * In the most cases, this callback will be triggered with this step. inactive -> unload -> destroy
+ */
+ virtual void unload() = 0;
+
+ /** @brief active callback.
+ *
+ * @note View is on active state after show transition is finished.
+ * From whatever the state, if the view is on the screen, the active callback will be called.
+ * In the most cases, this callback will be triggered with this step. load -> inactive -> active
+ */
+ virtual void active() = 0;
+
+ /** @brief inactive callback.
+ *
+ * @note View is on inactive state. Get ready for unload. Hide transition may be triggered at this point.
+ * Inactive state is triggered on this scenario that the view is still visible but it's not interactive with users.
+ * In the most cases, when view is going to be popped or destroyed or pushed one more depth, the inactive state will be triggered.
+ * Some UI controls such as a center popup or a menu popup blocks the view, this view may be inactive but still visible in someway (with transparency)
+ */
+ virtual void inactive() = 0;
+
+ /** @brief pause callback.
+ *
+ * @note When the system blocks the application running in cases such as phone call, system notification, switching applications ...
+ * When Window turns to deactivate. (@see ui_viewmgr_base :: deactivate()).
+ * If the view were inactive or unload state, the pause won't be called.
+ */
+ virtual void pause() = 0;
+
+ /** @brief resume callback.
+ *
+ * @note View is turning back to the active state again from pause.
+ * When the system allows the application turns to activate.
+ * When the Window turns to activate. (@see ui_viewmgr_base :: activate())
+ */
+ virtual void resume() = 0;
+
+ /** @brief destroy callback.
+ *
+ * @note When this view is on destroying by popping or deleting.
+ */
+ virtual void destroy() = 0;
+};
+
+}
+
+#endif /* UI_CONTROLLER_INTERFACE_H_ */
--- /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.
+ *
+ */
+#include "ui_viewmanager_interface.h"
+
+using namespace viewmgr;
+
+void ui_iface_view::set_event_block(bool block)
+{
+ this->event_block = block;
+}
+
+void ui_iface_view::load()
+{
+ this->state = UI_VIEW_STATE_LOAD;
+ if (this->content) return;
+ if (!this->controller) return;
+ this->controller->load();
+}
+
+void ui_iface_view::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();
+}
+
+void ui_iface_view::active()
+{
+ this->state = UI_VIEW_STATE_ACTIVE;
+ if (!this->controller) return;
+ this->controller->active();
+}
+
+void ui_iface_view::inactive()
+{
+ this->state = UI_VIEW_STATE_INACTIVE;
+ if (!this->controller) return;
+ this->controller->inactive();
+}
+
+void ui_iface_view::pause()
+{
+ this->state = UI_VIEW_STATE_PAUSE;
+ if (!this->content) return;
+ if (state != UI_VIEW_STATE_ACTIVE) return;
+ if (!this->controller) return;
+ this->controller->pause();
+}
+
+void ui_iface_view::resume()
+{
+ this->state = UI_VIEW_STATE_ACTIVE;
+ if (state != UI_VIEW_STATE_PAUSE) return;
+ if (!this->content) return;
+ if (!this->controller) return;
+ this->controller->resume();
+}
+
+void ui_iface_view::destroy()
+{
+ if (!this->controller) return;
+ this->controller->destroy();
+}
+
+ui_iface_view::ui_iface_view(T content, ui_iface_controller *controller, const char *name, const char *style)
+ : content(content), controller(controller), name(string(name ? name : "")), style(string(style ? style : "")), 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, const char *style)
+ : ui_iface_view(NULL, controller, name, style)
+{
+ this->state = UI_VIEW_STATE_UNLOAD;
+}
+
+ui_iface_view::ui_iface_view(const char *name)
+ : ui_iface_view(NULL, name)
+{
+
+}
+
+ui_iface_view::~ui_iface_view()
+{
+ this->viewmgr->remove_view(this);
+ if (this->controller) delete (this->controller);
+}
+
+ui_iface_controller* ui_iface_view::set_controller(ui_iface_controller *controller)
+{
+ ui_iface_controller *prev_controller = this->controller;
+ this->controller = controller;
+ if (controller) controller->set_view(this);
+ if (prev_controller) prev_controller->set_view(NULL);
+ return prev_controller;
+}
+
+T ui_iface_view::set_content(T content)
+{
+ T prev = this->content;
+ this->content = content;
+ return prev;
+}
+
+bool ui_iface_view::set_style(const char *style)
+{
+ this->style.assign(style);
+ return true;
+}
+
+bool ui_iface_view::set_name(const char *name)
+{
+ this->name.assign(name);
+ return true;
+}
+
+void ui_iface_view::set_removable_content(bool removable)
+{
+ this->removable_content = removable;
+
+ //FIXME: If this api is called on unload state? should we remove content right now?
+}
+
+void ui_iface_view::set_indicator(ui_view_indicator indicator)
+{
+ this->indicator = indicator;
+}
--- /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.
+ *
+ */
+#ifndef UI_VIEW_INTERFACE_H_
+#define UI_VIEW_INTERFACE_H_
+
+#include <string>
+
+using namespace std;
+
+typedef void* T;
+
+namespace viewmgr {
+
+class ui_iface_viewmgr;
+class ui_iface_controller;
+
+/**
+ * @class ui_iface_view
+ *
+ * @ingroup viewmgr
+ *
+ * @brief UI View Base Class. This is the base class of view. A view must have one content instance which represents a view for a current screen.
+ * UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands.
+ * It's not mandatory but view should describe the transitions in this class.
+ *
+ * @warning When the transitions are finished, the view must to call ui_iface_viewmgr :: _push_finished(), ui_iface_viewmgr :: _pop_finished() in order that
+ * The ui_iface_viewmgr keeps the view states exactly.
+ */
+class ui_iface_view
+{
+ friend class ui_iface_viewmgr;
+ friend class ui_iface_controller;
+
+private:
+ /// View state definition
+ enum ui_view_state
+ {
+ UI_VIEW_STATE_LOAD = 0, ///< Load state
+ UI_VIEW_STATE_UNLOAD, ///< Unload state
+ UI_VIEW_STATE_ACTIVE, ///< Active state
+ UI_VIEW_STATE_INACTIVE, ///< Inactive state
+ UI_VIEW_STATE_PAUSE, ///< Pause state
+ UI_VIEW_STATE_LAST
+ };
+
+ T content; ///< A content instance for a screen as a view.
+ ui_iface_controller *controller; ///< View life-cycle controller interface.
+ string name; ///< View name.
+ string style; ///< View style name.
+ ui_iface_viewmgr *viewmgr; ///< Viewmgr which this view belongs to.
+ ui_view_state state; ///< View state.
+ ui_view_indicator indicator; ///< View indicator mode.
+ bool event_block; ///< State of event block.
+ bool removable_content; ///< When this value is true, view removes it's content internally on unload state.
+
+protected:
+
+ /** @brief toggle event block.
+ *
+ * @note This interface is designed for toggling touch event on view transition.
+ * ui_iface_viewmgr will call this interface for notifying event blocking toggling on transition time.
+ *
+ * @param block @c true, when blocking is enabled, otherwise @c false.
+ */
+ virtual void set_event_block(bool block);
+
+ /** @brief view load state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void load();
+
+ /** @brief view unload state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void unload();
+
+ /** @brief view active state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void active();
+
+ /** @brief view inactive state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void inactive();
+
+ /** @brief view pause state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void pause();
+
+ /** @brief view resume state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void resume();
+
+ /** @brief view destroy state.
+ *
+ * @note this state will be triggered by ui_iface_viewmgr.
+ *
+ * @see ui_iface_controller for this state in detail.
+ */
+ virtual void destroy();
+
+ //Make this view's content as NULL, then destroy content.
+ virtual void unload_content() = 0;
+
+ /** @brief Return the state of event block.
+ *
+ * @see set_event_block()
+ */
+ bool get_event_block()
+ {
+ return this->event_block;
+ }
+
+ /// Return a controller of this view.
+ ui_iface_controller* get_controller()
+ {
+ return this->controller;
+ }
+
+ /** @brief Return a viewmgr which this view is belonging to.
+ */
+ ui_iface_viewmgr *get_viewmgr()
+ {
+ return this->viewmgr;
+ }
+
+ /** @brief This is for replacing or setting a controller of the view.
+ *
+ * @return A previous controller. If it wasn't, the return value will be @c NULL.
+ * @note this state will be triggered by ui_iface_viewmgr.
+ * @param controller a new controller. It allows @c NULL for canceling the previous controller.
+ *
+ * @warning Be aware deletion of controller passed here will be taken cover by ui_iface_view.
+ * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_iface_view is deleted.
+ */
+ ui_iface_controller* set_controller(ui_iface_controller *controller);
+
+public:
+ /** @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, const char *style = NULL);
+ ///Constructor for initializing with controller.
+ ui_iface_view(ui_iface_controller *controller, const char *name = NULL, const char *style = NULL);
+ ///Constructor for initializing with name.
+ ui_iface_view(const char *name = NULL);
+
+ ///Destructor for terminating view.
+ virtual ~ui_iface_view();
+
+ /** @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.
+ * 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.
+ *
+ * @return A previous content. If it wasn't, return value will be @c NULL.
+ */
+ T set_content(T content);
+
+ /** @brief set style of the view.
+ *
+ * @note style is reserved for supporting various kinds of view as well as it's transition effects.
+ * The actual behaviors with this style is up to your frameworks. Default value of the style is NULL.
+ *
+ * @param style a new style name.
+ *
+ * @return true if the given @c style is available, otherwise false.
+ *
+ * @warning When you override this member function, you should implement the logic to check the given style name is available or not.
+ * If your framework doesn't support any styles then just allow a @c NULL argument and return true. Otherwise return false.
+ */
+ bool set_style(const char *style);
+
+ /** @brief set name of the view.
+ *
+ * @note A view can gets a specific 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.
+ *
+ * @warning You should not remove a view content manually on unload status if removable content is set.
+ */
+ void set_removable_content(bool removable);
+
+ /** @brief set the indicator of the view with mode.
+ *
+ * @param indicator The mode to set, one of #ui_view_indicator.
+ */
+ void set_indicator(ui_view_indicator indicator);
+
+ /** @brief Return a style name of this view.
+ *
+ * @return style name of view.
+ */
+ const char *get_style()
+ {
+ return this->style.c_str();
+ }
+
+ /** @brief Return a name of this view.
+ *
+ * @return name of view.
+ */
+ const char *get_name()
+ {
+ return this->name.c_str();
+ }
+
+ /** @brief Return a content instance of this view.
+ *
+ * @return content of view.
+ */
+ T get_content()
+ {
+ return this->content;
+ }
+
+ /** @brief Return a state of this view.
+ *
+ * #return current state of view.
+ */
+ ui_view_state get_state()
+ {
+ return this->state;
+ }
+
+
+ /** @brief Return a state of removeable content.
+ *
+ * @return true if the view's content is removable, otherwise false.
+ */
+ bool get_removable_content()
+ {
+ return this->removable_content;
+ }
+
+ /** @brief Return the indicator mode of this view.
+ *
+ * @return indicator state of view.
+ */
+ ui_view_indicator get_indicator()
+ {
+ return this->indicator;
+ }
+};
+
+}
+
+#endif /* UI_VIEW_INTERFACE_H_ */
--- /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.
+ *
+ */
+#include "ui_viewmanager_interface.h"
+
+using namespace viewmgr;
+
+//FIXME: Read system profile to decide whether support software key or not.
+bool ui_iface_viewmgr::soft_key = true;
+//FIXME: Read system profile to decide whether support event block or not.
+bool ui_iface_viewmgr::event_block = true;
+
+bool ui_iface_viewmgr::need_soft_key()
+{
+ return ui_iface_viewmgr::soft_key;
+}
+
+bool ui_iface_viewmgr::connect_view(ui_iface_view *view)
+{
+ if (view->viewmgr)
+ {
+ LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
+ return false;
+ }
+
+ view->viewmgr = this;
+ return true;
+}
+
+bool ui_iface_viewmgr::disconnect_view(ui_iface_view *view)
+{
+ if (!view->viewmgr) return false;
+ view->viewmgr = NULL;
+ return true;
+}
+
+void ui_iface_viewmgr::set_event_block(ui_iface_view *view, bool block)
+{
+
+ if (!ui_iface_viewmgr::event_block) return;
+ view->set_event_block(block);
+}
+
+bool ui_iface_viewmgr::push_view_finished(ui_iface_view *view)
+{
+ ui_iface_view *last = this->view_list.back();
+
+ //The previous view has been pushed. This should be unload.
+ if (last != view)
+ {
+ view->unload();
+ return true;
+ }
+
+ //A new view has been pushed. This should be active.
+ view->active();
+ this->set_event_block(view, true);
+
+ return true;
+}
+
+bool ui_iface_viewmgr::pop_view_finished(ui_iface_view *view)
+{
+ ui_iface_view *last = this->view_list.back();
+
+ //This view has been popped. It should be destroyed.
+ if (last == view)
+ {
+ view->unload();
+ view->destroy();
+ delete (view);
+ return true;
+ }
+
+ //The previous view has been popped. It should become active.
+ view->active();
+ this->set_event_block(view, true);
+
+ return true;
+}
+
+ui_iface_viewmgr::ui_iface_viewmgr()
+ : activated(false)
+{
+}
+
+ui_iface_viewmgr::~ui_iface_viewmgr()
+{
+ //Terminate views
+ for (typename std::list<ui_iface_view*>::reverse_iterator it = this->view_list.rbegin(); it != this->view_list.rend(); it++)
+ {
+ ui_iface_view *view = *it;
+ view->inactive();
+ view->unload();
+ view->destroy();
+ delete (view);
+ }
+
+ //FIXME: Window is destroyed. Terminate Application!
+ ui_app_exit();
+}
+
+ui_iface_view *
+ui_iface_viewmgr::push_view(ui_iface_view *view)
+{
+ if (!view)
+ {
+ LOGE("invalid view argument. view(NULL)");
+ return NULL;
+ }
+
+ if (!this->connect_view(view))
+ {
+ LOGE("connect view failed");
+ return NULL;
+ }
+
+ ui_iface_view *pview;
+
+ //Previous view
+ if (this->view_list.size())
+ {
+ pview = this->view_list.back();
+ pview->inactive();
+ this->set_event_block(pview, true);
+
+ //FIXME: Since we have no transition
+ pview->unload();
+ }
+
+ view_list.push_back(view);
+
+ if (!view->get_content())
+ {
+ view->load();
+ }
+
+ view->inactive();
+ this->set_event_block(view, true);
+
+ return view;
+}
+
+bool ui_iface_viewmgr::pop_view()
+{
+ //No more view? destroy viewmgr?
+ if (this->get_view_count() == 0)
+ {
+ return false;
+ }
+
+ //This is the last page. destroy viewmgr?
+ if (this->get_view_count() == 1)
+ {
+ //destroy viewmgr?
+ ui_iface_view *view = this->view_list.back();
+ view->inactive();
+ view->unload();
+ view->destroy();
+ delete(view);
+
+ return false;
+ }
+
+ //last page to be popped.
+ ui_iface_view *view = this->view_list.back();
+ view->inactive();
+ this->set_event_block(view, true);
+
+ //Below object has to be used in child class...
+ //Make this getter method? or define instance?
+ //previous page to be current active.
+ auto nx = std::prev(this->view_list.end(), 2);
+ ui_iface_view *pview = *nx;
+ pview->load();
+ pview->inactive();
+ this->set_event_block(pview, true);
+
+ //FIXME: since we have no transition effect
+ pview->active();
+ view->inactive();
+ view->unload();
+ view->destroy();
+ delete (view);
+
+ return true;
+}
+
+bool ui_iface_viewmgr::insert_view_before(ui_iface_view *view, ui_iface_view *before)
+{
+ //TODO: ...
+ return true;
+}
+
+bool ui_iface_viewmgr::insert_view_after(ui_iface_view *view, ui_iface_view *after)
+{
+ //TODO: ...
+ return true;
+}
+
+bool ui_iface_viewmgr::remove_view(ui_iface_view *view)
+{
+ this->view_list.remove(view);
+ this->disconnect_view(view);
+
+ //TODO: If this view is the top on the stack ?
+ return true;
+}
+
+ui_iface_view*
+ui_iface_viewmgr::get_view(unsigned int idx)
+{
+ if (idx < 0 || idx >= this->view_list.size())
+ {
+ LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1);
+ return NULL;
+ }
+ typename std::list<ui_iface_view*>::iterator it = this->view_list.begin();
+ std::advance(it, idx);
+ return *it;
+}
+
+int ui_iface_viewmgr::get_view_index(const ui_iface_view *view)
+{
+ int idx = 0;
+
+ for (typename std::list<ui_iface_view*>::iterator it = this->view_list.begin(); it != this->view_list.end(); it++)
+ {
+ if (view == *it) return idx;
+ ++idx;
+ }
+
+ return -1;
+}
+
+ui_iface_view *
+ui_iface_viewmgr::get_last_view()
+{
+ int cnt = this->get_view_count();
+ return this->get_view(cnt - 1);
+}
+
+bool ui_iface_viewmgr::activate()
+{
+ if (this->activated) return false;
+ this->activated = true;
+ return true;
+}
+
+bool ui_iface_viewmgr::deactivate()
+{
+ if (!this->activated) return false;
+ this->activated = false;
+ return true;
+}
+
+ui_iface_view *ui_iface_viewmgr::get_view(const char *name)
+{
+ //FIXME: ...
+ return NULL;
+}
+
+bool ui_iface_viewmgr::is_activated()
+{
+ return this->activated;
+}
+
+unsigned int ui_iface_viewmgr::get_view_count()
+{
+ return this->view_list.size();
+}
--- /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.
+ *
+ */
+#ifndef UI_VIEWMGR_INTERFACE_H_
+#define UI_VIEWMGR_INTERFACE_H_
+
+#include <list>
+
+using namespace std;
+
+namespace viewmgr {
+
+class ui_iface_view;
+
+/**
+ * @class ui_iface_viewmgr
+ *
+ * @ingroup viewmgr
+ *
+ * @brief This is a interface class of viewmgr. One viewmgr represents a window which contains multiple views.
+ * A viewmgr manages not only views life-cycle but constructs basic infrastructures such as key events handling, transition effects, transient views.
+ * This interface guide you a basic policy of a view manager.
+ *
+ * @warning viewmgr will remove all containing views when it's destroyed.
+ */
+class ui_iface_viewmgr
+{
+ friend class ui_iface_view;
+
+private:
+ static bool soft_key; //If system doesn't support HW back key, then this value is @c true.
+ static bool event_block; //Event block on view transition. This value should be configurable by system.
+ list<ui_iface_view*> view_list; //View list.
+ bool activated; //Activated status of this viewmgr.
+
+ /**
+ * @brief Connect a given view to this viewmgr.
+ *
+ * @param view A view to connect to this viewmgr which means the @p view is to belong to this viewmgr.
+ *
+ * @return @c true success or @c false not.
+ *
+ * @warning If the given view is already connected to a viewmgr, this call will be failed.
+ * @see disconnect_view()
+ */
+ bool connect_view(ui_iface_view *view);
+
+ /**
+ * @brief Disconnect a given view from this viewmgr.
+ *
+ * @param view A view to disconnect from this viewmgr.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @see connect_view()
+ */
+ bool disconnect_view(ui_iface_view *view);
+
+ /**
+ * @brief Toggle event blocking to the given view.
+ *
+ * @note If the event is blocked, product users won't be able to enter any inputs to this @p view. These inputs are mouse clicks, key press,
+ * screen touches, etc. Event if this function is called, @p view will be event-blocked only when system requires event blocking.
+ * Most of the times, This function should be used on transition. @see also push_view(), push_view_finished(), pop_view(), pop_view_finished().
+ *
+ * @param view A view to toggle event blocking.
+ * @param block @c true is blocking event, otherwise @c false.
+ */
+ void set_event_block(ui_iface_view *view, bool block);
+
+protected:
+ /**
+ * @brief This function is designed for finishing process of push transition.
+ *
+ * @param view A view which is finished pushing.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @warning This function must be called when push transition is finished.
+ */
+ bool push_view_finished(ui_iface_view *view);
+
+ /**
+ * @brief This function is designed for finishing process for pop transition.
+ *
+ * @note If a new view is pushed.
+ *
+ * @param view A view which is finished popping.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @warning This function must be called when push transition is finished.
+ */
+ bool pop_view_finished(ui_iface_view *view);
+
+#if 0
+ /**
+ * @brief Return a list of views which this viewmgr has.
+ *
+ * @return a pointer of list of views.
+ *
+ * @warning Don't modify this view list.
+ */
+ const list<ui_iface_view*>* const get_view_list()
+ {
+ return &this->view_list;
+ }
+#endif
+
+ /**
+ * @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one.
+ *
+ * @note Normally, the current view will be hidden by a new view. In default, when user calls this API, view will be switched to @p view instantly,
+ * only when viewmgr state is activated. Otherwise, the @p view will be shown later when viewmgr is activated. push_view() is designed for providing
+ * view transition effect. If you want push view instantly without any transition, you could use insert_view_before() or insert_view_after().
+ * If you want to pop the current view, the please use pop_view().
+ *
+ * @param view A view to insert at the end of viewmgr view list.
+ *
+ * @return @p view, @c NULL when it fails to push a @p view.
+ *
+ * @see activated()
+ * @see insert_view_before()
+ * @see insert_view_after()
+ * @see pop_view()
+ */
+ ui_iface_view *push_view(ui_iface_view *view);
+
+ /**
+ * @brief Pop the top(last) view from this viewmgr view list.
+ * This function is used for application switches the current view back to the previous view.
+ * The top view will be removed from the view stack and then it will be deleted by the viewmgr.
+ *
+ * @note If the view is just one left, then viewmgr would be deactivated since the ui application might be invalid anymore. Otherwise, the application will
+ * be terminated. It's up to system configuration.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @see deactivate()
+ * @see push_view()
+ */
+ bool pop_view();
+
+ /**
+ * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right before of the given view, @before.
+ *
+ * @param view A view to insert in the viewmgr view list.
+ * @param before A view that will be just inserted after @p view. If you pass @c NULL, @p view will be inserted at the front of the view list.
+ *
+ * @return @c true on success or @c false otherwise.
+ */
+ bool insert_view_before(ui_iface_view *view, ui_iface_view *before);
+
+ /**
+ * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after.
+ *
+ * @param view A view to insert in the viewmgr view list.
+ * @param after A view that will be just inserted before the @p view. If you pass @c NULL, @p view will be inserted at the end of the view list.
+ *
+ * @return @c true on success or @c false otherwise.
+ */
+ bool insert_view_after(ui_iface_view *view, ui_iface_view *after);
+
+ /**
+ * @brief Remove the given view from this viewmgr view list.
+ *
+ * @param view A view to remove from the viewmgr view list.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @see insert_view_before()
+ * @see insert_view_after()
+ * @see push_view()
+ */
+ bool remove_view(ui_iface_view *view);
+
+ /**
+ * @brief Return a view which is matched with the index @p idx.
+ *
+ * @param idx A index of the view which you are looking for.
+ *
+ * @return The view which index is matched with @p idx.
+ * If there were no views with index @p idx, @c NULL will be returned.
+ *
+ * @note You could use the index as the page numbers of the views.
+ * @warning the index number of views are variable since the view list is variable.
+ *
+ * @see get_view_index()
+ * @see get_view_count()
+ */
+ ui_iface_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_iface_view *get_view(const char *name);
+
+ /**
+ * @brief Return a last(top) view.
+ *
+ * @return The view which is last view of the viewmgr view list.
+ */
+ ui_iface_view *get_last_view();
+
+ /**
+ * @brief Return a view index(page) number of the given view.
+ * You could use this function to query the given @p view list order.
+ *
+ * @param view A view to query the index.
+ *
+ * @return An index of the give @p view on success, otherwise, -1.
+ *
+ * @warning The index number of views are variable since the view list is variable.
+ */
+ int get_view_index(const ui_iface_view *view);
+
+public:
+ ///Constructor.
+ ui_iface_viewmgr();
+
+ ///Destructor.
+ virtual ~ui_iface_viewmgr();
+
+ /**
+ * @brief Activate this view manager.
+ *
+ * @note viewmgr window and views will be shown once activate() is called. Usually this activate() should be called after applications set their all views
+ * on initialization time.
+ *
+ * @return @c true on success or @c false otherwise.
+ *
+ * @see deactivate()
+ */
+ bool activate();
+
+ /**
+ * @brief Deactivate this view manager.
+ *
+ * @note viewmgr window and views will be hidden once deactivate() is called. deactivate() behavior is up ui system, but usually it hides(unmap)
+ * current window in order that application go background.
+ *
+ * @return @c true success or @c false not.
+ *
+ * @see activate()
+ */
+ bool deactivate();
+
+ /**
+ * @brief Return the active status of viewmgr.
+ *
+ * @return @c true if viewmgr is active, @c false otherwise.
+ *
+ * @see activate()
+ * @see deactivate()
+ */
+ bool is_activated();
+
+ /**
+ * @brief Return the number of views which this viewmgr has.
+ *
+ * @return the number of view
+ */
+ unsigned int get_view_count();
+
+ /**
+ * @brief Return whether soft key is required or not.
+ *
+ * @note Soft key is kind of like the software back button. It's used for product users to change current view to a previous view (pop).
+ * If a device doesn't have any hardware back buttons, Soft back key is necessary which means this function will return @c true.
+ * Some devices may needs software back key as well as hardware back key at the same time. That decision is up to product design.
+ * And soft_key initial value should read from the system configuration.
+ *
+ * @return @c true if soft key is required, @c false otherwise.
+ */
+ static bool need_soft_key();
+};
+
+}
+
+#endif /* UI_VIEWMGR_INTERFACE_H_ */
+++ /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.
- *
- */
-#include "ui_viewmanager_interface.h"
-
-using namespace viewmgr;
-
-void ui_view_interface::set_event_block(bool block)
-{
- this->event_block = block;
-}
-
-void ui_view_interface::load()
-{
- this->state = UI_VIEW_STATE_LOAD;
- if (this->content) return;
- if (!this->controller) return;
- this->controller->load();
-}
-
-void ui_view_interface::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();
-}
-
-void ui_view_interface::active()
-{
- this->state = UI_VIEW_STATE_ACTIVE;
- if (!this->controller) return;
- this->controller->active();
-}
-
-void ui_view_interface::inactive()
-{
- this->state = UI_VIEW_STATE_INACTIVE;
- if (!this->controller) return;
- this->controller->inactive();
-}
-
-void ui_view_interface::pause()
-{
- this->state = UI_VIEW_STATE_PAUSE;
- if (!this->content) return;
- if (state != UI_VIEW_STATE_ACTIVE) return;
- if (!this->controller) return;
- this->controller->pause();
-}
-
-void ui_view_interface::resume()
-{
- this->state = UI_VIEW_STATE_ACTIVE;
- if (state != UI_VIEW_STATE_PAUSE) return;
- if (!this->content) return;
- if (!this->controller) return;
- this->controller->resume();
-}
-
-void ui_view_interface::destroy()
-{
- if (!this->controller) return;
- this->controller->destroy();
-}
-
-ui_view_interface::ui_view_interface(T content, ui_controller_interface *controller, const char *name, const char *style)
- : content(content), controller(controller), name(string(name ? name : "")), style(string(style ? style : "")), 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_view_interface::ui_view_interface(ui_controller_interface *controller, const char *name, const char *style)
- : ui_view_interface(NULL, controller, name, style)
-{
- this->state = UI_VIEW_STATE_UNLOAD;
-}
-
-ui_view_interface::ui_view_interface(const char *name)
- : ui_view_interface(NULL, name)
-{
-
-}
-
-ui_view_interface::~ui_view_interface()
-{
- this->viewmgr->remove_view(this);
- if (this->controller) delete (this->controller);
-}
-
-ui_controller_interface* ui_view_interface::set_controller(ui_controller_interface *controller)
-{
- ui_controller_interface *prev_controller = this->controller;
- this->controller = controller;
- if (controller) controller->set_view(this);
- if (prev_controller) prev_controller->set_view(NULL);
- return prev_controller;
-}
-
-T ui_view_interface::set_content(T content)
-{
- T prev = this->content;
- this->content = content;
- return prev;
-}
-
-bool ui_view_interface::set_style(const char *style)
-{
- this->style.assign(style);
- return true;
-}
-
-bool ui_view_interface::set_name(const char *name)
-{
- this->name.assign(name);
- return true;
-}
-
-void ui_view_interface::set_removable_content(bool removable)
-{
- this->removable_content = removable;
-
- //FIXME: If this api is called on unload state? should we remove content right now?
-}
-
-void ui_view_interface::set_indicator(ui_view_indicator indicator)
-{
- this->indicator = indicator;
-}
+++ /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.
- *
- */
-#ifndef UI_VIEW_INTERFACE_H_
-#define UI_VIEW_INTERFACE_H_
-
-#include <string>
-
-using namespace std;
-
-typedef void* T;
-
-namespace viewmgr {
-
-class ui_viewmgr_interface;
-class ui_controller_interface;
-
-/**
- * @class ui_view_interface
- *
- * @ingroup viewmgr
- *
- * @brief UI View Base Class. This is the base class of view. A view must have one content instance which represents a view for a current screen.
- * UI View may have it's own show/hide transition styles. That means, it's available that views have different show/hide effects on demands.
- * It's not mandatory but view should describe the transitions in this class.
- *
- * @warning When the transitions are finished, the view must to call ui_viewmgr_interface :: _push_finished(), ui_viewmgr_interface :: _pop_finished() in order that
- * The ui_viewmgr_interface keeps the view states exactly.
- */
-class ui_view_interface
-{
- friend class ui_viewmgr_interface;
- friend class ui_controller_interface;
-
-private:
- /// View state definition
- enum ui_view_state
- {
- UI_VIEW_STATE_LOAD = 0, ///< Load state
- UI_VIEW_STATE_UNLOAD, ///< Unload state
- UI_VIEW_STATE_ACTIVE, ///< Active state
- UI_VIEW_STATE_INACTIVE, ///< Inactive state
- UI_VIEW_STATE_PAUSE, ///< Pause state
- UI_VIEW_STATE_LAST
- };
-
- T content; ///< A content instance for a screen as a view.
- ui_controller_interface *controller; ///< View life-cycle controller interface.
- string name; ///< View name.
- string style; ///< View style name.
- ui_viewmgr_interface *viewmgr; ///< Viewmgr which this view belongs to.
- ui_view_state state; ///< View state.
- ui_view_indicator indicator; ///< View indicator mode.
- bool event_block; ///< State of event block.
- bool removable_content; ///< When this value is true, view removes it's content internally on unload state.
-
-protected:
-
- /** @brief toggle event block.
- *
- * @note This interface is designed for toggling touch event on view transition.
- * ui_viewmgr_interface will call this interface for notifying event blocking toggling on transition time.
- *
- * @param block @c true, when blocking is enabled, otherwise @c false.
- */
- virtual void set_event_block(bool block);
-
- /** @brief view load state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void load();
-
- /** @brief view unload state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void unload();
-
- /** @brief view active state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void active();
-
- /** @brief view inactive state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void inactive();
-
- /** @brief view pause state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void pause();
-
- /** @brief view resume state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void resume();
-
- /** @brief view destroy state.
- *
- * @note this state will be triggered by ui_viewmgr_interface.
- *
- * @see ui_controller_interface for this state in detail.
- */
- virtual void destroy();
-
- //Make this view's content as NULL, then destroy content.
- virtual void unload_content() = 0;
-
- /** @brief Return the state of event block.
- *
- * @see set_event_block()
- */
- bool get_event_block()
- {
- return this->event_block;
- }
-
- /// Return a controller of this view.
- ui_controller_interface* get_controller()
- {
- return this->controller;
- }
-
- /** @brief Return a viewmgr which this view is belonging to.
- */
- ui_viewmgr_interface *get_viewmgr()
- {
- return this->viewmgr;
- }
-
- /** @brief This is for replacing or setting a controller of the view.
- *
- * @return A previous controller. If it wasn't, the return value will be @c NULL.
- * @note this state will be triggered by ui_viewmgr_interface.
- * @param controller a new controller. It allows @c NULL for canceling the previous controller.
- *
- * @warning Be aware deletion of controller passed here will be taken cover by ui_view_interface.
- * If you want to keep the controller for any reasons, please unset it using set_controller() before ui_view_interface is deleted.
- */
- ui_controller_interface* set_controller(ui_controller_interface *controller);
-
-public:
- /** @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_view_interface.
- * If you want to keep it for any reasons, please unset it using set_controller() before ui_view_interface is deleted.
- */
- ui_view_interface(T content, ui_controller_interface *controller, const char *name, const char *style = NULL);
- ///Constructor for initializing with controller.
- ui_view_interface(ui_controller_interface *controller, const char *name = NULL, const char *style = NULL);
- ///Constructor for initializing with name.
- ui_view_interface(const char *name = NULL);
-
- ///Destructor for terminating view.
- virtual ~ui_view_interface();
-
- /** @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.
- * 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.
- *
- * @return A previous content. If it wasn't, return value will be @c NULL.
- */
- T set_content(T content);
-
- /** @brief set style of the view.
- *
- * @note style is reserved for supporting various kinds of view as well as it's transition effects.
- * The actual behaviors with this style is up to your frameworks. Default value of the style is NULL.
- *
- * @param style a new style name.
- *
- * @return true if the given @c style is available, otherwise false.
- *
- * @warning When you override this member function, you should implement the logic to check the given style name is available or not.
- * If your framework doesn't support any styles then just allow a @c NULL argument and return true. Otherwise return false.
- */
- bool set_style(const char *style);
-
- /** @brief set name of the view.
- *
- * @note A view can gets a specific 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.
- *
- * @warning You should not remove a view content manually on unload status if removable content is set.
- */
- void set_removable_content(bool removable);
-
- /** @brief set the indicator of the view with mode.
- *
- * @param indicator The mode to set, one of #ui_view_indicator.
- */
- void set_indicator(ui_view_indicator indicator);
-
- /** @brief Return a style name of this view.
- *
- * @return style name of view.
- */
- const char *get_style()
- {
- return this->style.c_str();
- }
-
- /** @brief Return a name of this view.
- *
- * @return name of view.
- */
- const char *get_name()
- {
- return this->name.c_str();
- }
-
- /** @brief Return a content instance of this view.
- *
- * @return content of view.
- */
- T get_content()
- {
- return this->content;
- }
-
- /** @brief Return a state of this view.
- *
- * #return current state of view.
- */
- ui_view_state get_state()
- {
- return this->state;
- }
-
-
- /** @brief Return a state of removeable content.
- *
- * @return true if the view's content is removable, otherwise false.
- */
- bool get_removable_content()
- {
- return this->removable_content;
- }
-
- /** @brief Return the indicator mode of this view.
- *
- * @return indicator state of view.
- */
- ui_view_indicator get_indicator()
- {
- return this->indicator;
- }
-};
-
-}
-
-#endif /* UI_VIEW_INTERFACE_H_ */
UI_VIEW_INDICATOR_LAST
};
-#include "ui_viewmgr_interface.h"
-#include "ui_view_interface.h"
-#include "ui_controller_interface.h"
+#include "ui_iface_viewmgr.h"
+#include "ui_iface_view.h"
+#include "ui_iface_controller.h"
#endif /* UI_VIEWMANAGER_INTERFACE_H */
+++ /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.
- *
- */
-#include "ui_viewmanager_interface.h"
-
-using namespace viewmgr;
-
-//FIXME: Read system profile to decide whether support software key or not.
-bool ui_viewmgr_interface::soft_key = true;
-//FIXME: Read system profile to decide whether support event block or not.
-bool ui_viewmgr_interface::event_block = true;
-
-bool ui_viewmgr_interface::need_soft_key()
-{
- return ui_viewmgr_interface::soft_key;
-}
-
-bool ui_viewmgr_interface::connect_view(ui_view_interface *view)
-{
- if (view->viewmgr)
- {
- LOGE("view(%p) has already connected to viewmgr(%p)", view, this);
- return false;
- }
-
- view->viewmgr = this;
- return true;
-}
-
-bool ui_viewmgr_interface::disconnect_view(ui_view_interface *view)
-{
- if (!view->viewmgr) return false;
- view->viewmgr = NULL;
- return true;
-}
-
-void ui_viewmgr_interface::set_event_block(ui_view_interface *view, bool block)
-{
-
- if (!ui_viewmgr_interface::event_block) return;
- view->set_event_block(block);
-}
-
-bool ui_viewmgr_interface::push_view_finished(ui_view_interface *view)
-{
- ui_view_interface *last = this->view_list.back();
-
- //The previous view has been pushed. This should be unload.
- if (last != view)
- {
- view->unload();
- return true;
- }
-
- //A new view has been pushed. This should be active.
- view->active();
- this->set_event_block(view, true);
-
- return true;
-}
-
-bool ui_viewmgr_interface::pop_view_finished(ui_view_interface *view)
-{
- ui_view_interface *last = this->view_list.back();
-
- //This view has been popped. It should be destroyed.
- if (last == view)
- {
- view->unload();
- view->destroy();
- delete (view);
- return true;
- }
-
- //The previous view has been popped. It should become active.
- view->active();
- this->set_event_block(view, true);
-
- return true;
-}
-
-ui_viewmgr_interface::ui_viewmgr_interface()
- : activated(false)
-{
-}
-
-ui_viewmgr_interface::~ui_viewmgr_interface()
-{
- //Terminate views
- for (typename std::list<ui_view_interface*>::reverse_iterator it = this->view_list.rbegin(); it != this->view_list.rend(); it++)
- {
- ui_view_interface *view = *it;
- view->inactive();
- view->unload();
- view->destroy();
- delete (view);
- }
-
- //FIXME: Window is destroyed. Terminate Application!
- ui_app_exit();
-}
-
-ui_view_interface *
-ui_viewmgr_interface::push_view(ui_view_interface *view)
-{
- if (!view)
- {
- LOGE("invalid view argument. view(NULL)");
- return NULL;
- }
-
- if (!this->connect_view(view))
- {
- LOGE("connect view failed");
- return NULL;
- }
-
- ui_view_interface *pview;
-
- //Previous view
- if (this->view_list.size())
- {
- pview = this->view_list.back();
- pview->inactive();
- this->set_event_block(pview, true);
-
- //FIXME: Since we have no transition
- pview->unload();
- }
-
- view_list.push_back(view);
-
- if (!view->get_content())
- {
- view->load();
- }
-
- view->inactive();
- this->set_event_block(view, true);
-
- return view;
-}
-
-bool ui_viewmgr_interface::pop_view()
-{
- //No more view? destroy viewmgr?
- if (this->get_view_count() == 0)
- {
- return false;
- }
-
- //This is the last page. destroy viewmgr?
- if (this->get_view_count() == 1)
- {
- //destroy viewmgr?
- ui_view_interface *view = this->view_list.back();
- view->inactive();
- view->unload();
- view->destroy();
- delete(view);
-
- return false;
- }
-
- //last page to be popped.
- ui_view_interface *view = this->view_list.back();
- view->inactive();
- this->set_event_block(view, true);
-
- //Below object has to be used in child class...
- //Make this getter method? or define instance?
- //previous page to be current active.
- auto nx = std::prev(this->view_list.end(), 2);
- ui_view_interface *pview = *nx;
- pview->load();
- pview->inactive();
- this->set_event_block(pview, true);
-
- //FIXME: since we have no transition effect
- pview->active();
- view->inactive();
- view->unload();
- view->destroy();
- delete (view);
-
- return true;
-}
-
-bool ui_viewmgr_interface::insert_view_before(ui_view_interface *view, ui_view_interface *before)
-{
- //TODO: ...
- return true;
-}
-
-bool ui_viewmgr_interface::insert_view_after(ui_view_interface *view, ui_view_interface *after)
-{
- //TODO: ...
- return true;
-}
-
-bool ui_viewmgr_interface::remove_view(ui_view_interface *view)
-{
- this->view_list.remove(view);
- this->disconnect_view(view);
-
- //TODO: If this view is the top on the stack ?
- return true;
-}
-
-ui_view_interface*
-ui_viewmgr_interface::get_view(unsigned int idx)
-{
- if (idx < 0 || idx >= this->view_list.size())
- {
- LOGE("Invalid idx(%d)! =? (idx range: %d ~ %d)", idx, 0, this->view_list.size() - 1);
- return NULL;
- }
- typename std::list<ui_view_interface*>::iterator it = this->view_list.begin();
- std::advance(it, idx);
- return *it;
-}
-
-int ui_viewmgr_interface::get_view_index(const ui_view_interface *view)
-{
- int idx = 0;
-
- for (typename std::list<ui_view_interface*>::iterator it = this->view_list.begin(); it != this->view_list.end(); it++)
- {
- if (view == *it) return idx;
- ++idx;
- }
-
- return -1;
-}
-
-ui_view_interface *
-ui_viewmgr_interface::get_last_view()
-{
- int cnt = this->get_view_count();
- return this->get_view(cnt - 1);
-}
-
-bool ui_viewmgr_interface::activate()
-{
- if (this->activated) return false;
- this->activated = true;
- return true;
-}
-
-bool ui_viewmgr_interface::deactivate()
-{
- if (!this->activated) return false;
- this->activated = false;
- return true;
-}
-
-ui_view_interface *ui_viewmgr_interface::get_view(const char *name)
-{
- //FIXME: ...
- return NULL;
-}
-
-bool ui_viewmgr_interface::is_activated()
-{
- return this->activated;
-}
-
-unsigned int ui_viewmgr_interface::get_view_count()
-{
- return this->view_list.size();
-}
+++ /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.
- *
- */
-#ifndef UI_VIEWMGR_INTERFACE_H_
-#define UI_VIEWMGR_INTERFACE_H_
-
-#include <list>
-
-using namespace std;
-
-namespace viewmgr {
-
-class ui_view_interface;
-
-/**
- * @class ui_viewmgr_interface
- *
- * @ingroup viewmgr
- *
- * @brief This is a interface class of viewmgr. One viewmgr represents a window which contains multiple views.
- * A viewmgr manages not only views life-cycle but constructs basic infrastructures such as key events handling, transition effects, transient views.
- * This interface guide you a basic policy of a view manager.
- *
- * @warning viewmgr will remove all containing views when it's destroyed.
- */
-class ui_viewmgr_interface
-{
- friend class ui_view_interface;
-
-private:
- static bool soft_key; //If system doesn't support HW back key, then this value is @c true.
- static bool event_block; //Event block on view transition. This value should be configurable by system.
- list<ui_view_interface*> view_list; //View list.
- bool activated; //Activated status of this viewmgr.
-
- /**
- * @brief Connect a given view to this viewmgr.
- *
- * @param view A view to connect to this viewmgr which means the @p view is to belong to this viewmgr.
- *
- * @return @c true success or @c false not.
- *
- * @warning If the given view is already connected to a viewmgr, this call will be failed.
- * @see disconnect_view()
- */
- bool connect_view(ui_view_interface *view);
-
- /**
- * @brief Disconnect a given view from this viewmgr.
- *
- * @param view A view to disconnect from this viewmgr.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @see connect_view()
- */
- bool disconnect_view(ui_view_interface *view);
-
- /**
- * @brief Toggle event blocking to the given view.
- *
- * @note If the event is blocked, product users won't be able to enter any inputs to this @p view. These inputs are mouse clicks, key press,
- * screen touches, etc. Event if this function is called, @p view will be event-blocked only when system requires event blocking.
- * Most of the times, This function should be used on transition. @see also push_view(), push_view_finished(), pop_view(), pop_view_finished().
- *
- * @param view A view to toggle event blocking.
- * @param block @c true is blocking event, otherwise @c false.
- */
- void set_event_block(ui_view_interface *view, bool block);
-
-protected:
- /**
- * @brief This function is designed for finishing process of push transition.
- *
- * @param view A view which is finished pushing.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @warning This function must be called when push transition is finished.
- */
- bool push_view_finished(ui_view_interface *view);
-
- /**
- * @brief This function is designed for finishing process for pop transition.
- *
- * @note If a new view is pushed.
- *
- * @param view A view which is finished popping.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @warning This function must be called when push transition is finished.
- */
- bool pop_view_finished(ui_view_interface *view);
-
-#if 0
- /**
- * @brief Return a list of views which this viewmgr has.
- *
- * @return a pointer of list of views.
- *
- * @warning Don't modify this view list.
- */
- const list<ui_view_interface*>* const get_view_list()
- {
- return &this->view_list;
- }
-#endif
-
- /**
- * @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one.
- *
- * @note Normally, the current view will be hidden by a new view. In default, when user calls this API, view will be switched to @p view instantly,
- * only when viewmgr state is activated. Otherwise, the @p view will be shown later when viewmgr is activated. push_view() is designed for providing
- * view transition effect. If you want push view instantly without any transition, you could use insert_view_before() or insert_view_after().
- * If you want to pop the current view, the please use pop_view().
- *
- * @param view A view to insert at the end of viewmgr view list.
- *
- * @return @p view, @c NULL when it fails to push a @p view.
- *
- * @see activated()
- * @see insert_view_before()
- * @see insert_view_after()
- * @see pop_view()
- */
- ui_view_interface *push_view(ui_view_interface *view);
-
- /**
- * @brief Pop the top(last) view from this viewmgr view list.
- * This function is used for application switches the current view back to the previous view.
- * The top view will be removed from the view stack and then it will be deleted by the viewmgr.
- *
- * @note If the view is just one left, then viewmgr would be deactivated since the ui application might be invalid anymore. Otherwise, the application will
- * be terminated. It's up to system configuration.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @see deactivate()
- * @see push_view()
- */
- bool pop_view();
-
- /**
- * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right before of the given view, @before.
- *
- * @param view A view to insert in the viewmgr view list.
- * @param before A view that will be just inserted after @p view. If you pass @c NULL, @p view will be inserted at the front of the view list.
- *
- * @return @c true on success or @c false otherwise.
- */
- bool insert_view_before(ui_view_interface *view, ui_view_interface *before);
-
- /**
- * @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after.
- *
- * @param view A view to insert in the viewmgr view list.
- * @param after A view that will be just inserted before the @p view. If you pass @c NULL, @p view will be inserted at the end of the view list.
- *
- * @return @c true on success or @c false otherwise.
- */
- bool insert_view_after(ui_view_interface *view, ui_view_interface *after);
-
- /**
- * @brief Remove the given view from this viewmgr view list.
- *
- * @param view A view to remove from the viewmgr view list.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @see insert_view_before()
- * @see insert_view_after()
- * @see push_view()
- */
- bool remove_view(ui_view_interface *view);
-
- /**
- * @brief Return a view which is matched with the index @p idx.
- *
- * @param idx A index of the view which you are looking for.
- *
- * @return The view which index is matched with @p idx.
- * If there were no views with index @p idx, @c NULL will be returned.
- *
- * @note You could use the index as the page numbers of the views.
- * @warning the index number of views are variable since the view list is variable.
- *
- * @see get_view_index()
- * @see get_view_count()
- */
- ui_view_interface* 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_view_interface::set_name()
- */
- ui_view_interface *get_view(const char *name);
-
- /**
- * @brief Return a last(top) view.
- *
- * @return The view which is last view of the viewmgr view list.
- */
- ui_view_interface *get_last_view();
-
- /**
- * @brief Return a view index(page) number of the given view.
- * You could use this function to query the given @p view list order.
- *
- * @param view A view to query the index.
- *
- * @return An index of the give @p view on success, otherwise, -1.
- *
- * @warning The index number of views are variable since the view list is variable.
- */
- int get_view_index(const ui_view_interface *view);
-
-public:
- ///Constructor.
- ui_viewmgr_interface();
-
- ///Destructor.
- virtual ~ui_viewmgr_interface();
-
- /**
- * @brief Activate this view manager.
- *
- * @note viewmgr window and views will be shown once activate() is called. Usually this activate() should be called after applications set their all views
- * on initialization time.
- *
- * @return @c true on success or @c false otherwise.
- *
- * @see deactivate()
- */
- bool activate();
-
- /**
- * @brief Deactivate this view manager.
- *
- * @note viewmgr window and views will be hidden once deactivate() is called. deactivate() behavior is up ui system, but usually it hides(unmap)
- * current window in order that application go background.
- *
- * @return @c true success or @c false not.
- *
- * @see activate()
- */
- bool deactivate();
-
- /**
- * @brief Return the active status of viewmgr.
- *
- * @return @c true if viewmgr is active, @c false otherwise.
- *
- * @see activate()
- * @see deactivate()
- */
- bool is_activated();
-
- /**
- * @brief Return the number of views which this viewmgr has.
- *
- * @return the number of view
- */
- unsigned int get_view_count();
-
- /**
- * @brief Return whether soft key is required or not.
- *
- * @note Soft key is kind of like the software back button. It's used for product users to change current view to a previous view (pop).
- * If a device doesn't have any hardware back buttons, Soft back key is necessary which means this function will return @c true.
- * Some devices may needs software back key as well as hardware back key at the same time. That decision is up to product design.
- * And soft_key initial value should read from the system configuration.
- *
- * @return @c true if soft key is required, @c false otherwise.
- */
- static bool need_soft_key();
-};
-
-}
-
-#endif /* UI_VIEWMGR_INTERFACE_H_ */