../../lib/interface/ui_iface_controller.cpp
../../lib/interface/ui_iface_view.cpp
../../lib/interface/ui_iface_viewmgr.cpp
- ../../lib/efl/ui_controller.cpp
- ../../lib/efl/ui_view.cpp
- ../../lib/efl/ui_viewmgr.cpp
- ../../lib/efl/ui_key_listener.cpp
- ../../lib/efl/mobile/ui_basic_controller.cpp
- ../../lib/efl/mobile/ui_basic_view.cpp
- ../../lib/efl/mobile/ui_basic_key_listener.cpp
- ../../lib/efl/mobile/ui_basic_viewmgr.cpp
+ ../../lib/efl/ui_base_controller.cpp
+ ../../lib/efl/ui_base_view.cpp
+ ../../lib/efl/ui_base_viewmgr.cpp
+ ../../lib/efl/ui_base_key_listener.cpp
+ ../../lib/efl/mobile/ui_controller.cpp
+ ../../lib/efl/mobile/ui_view.cpp
+ ../../lib/efl/mobile/ui_key_listener.cpp
+ ../../lib/efl/mobile/ui_viewmgr.cpp
main.cpp
)
static void create_base_gui(appdata_s *ad)
{
//FIXME: Hide this creation.
- ad->viewmgr = new ui_basic_viewmgr(PACKAGE);
+ ad->viewmgr = new ui_viewmgr(PACKAGE);
create_page1(ad);
*/
static void ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
{
- ui_basic_view *view = static_cast<ui_basic_view *>(data);
+ ui_view *view = static_cast<ui_view *>(data);
Elm_Object_Item *it = static_cast<Elm_Object_Item *>(event_info);
elm_ctxpopup_dismiss(obj);
LOGE("Item (%s) is selected", elm_object_item_text_get(it));
}
-class page1: public ui_basic_controller
+class page1: public ui_controller
{
private:
appdata_s *ad;
page1(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name).
+ /* ui_view(controller, identity name).
Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_basic_view(this, "page1"));
+ ad->viewmgr->push_view(new ui_view(this, "page1"));
}
~page1()
{
{
//Initialize contents.
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Check the current rotation for set portrait or landscape content if any.
LOGE("view 1 load rotation = %d\n", view->get_degree());
bool on_menu()
{
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
Elm_Ctxpopup *ctxpopup = elm_ctxpopup_add(view->get_base());
elm_ctxpopup_item_append(ctxpopup, "Phone calls", NULL, ctxpopup_item_select_cb, this);
* limitations under the License.
*
*/
-class page2: public ui_basic_controller
+class page2: public ui_controller
{
private:
appdata_s *ad;
page2(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name).
+ /* ui_view(controller, identity name).
Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_basic_view(this, "page2"));
+ ad->viewmgr->push_view(new ui_view(this, "page2"));
}
~page2()
void on_load()
{
//Initialize contents.
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 2",
* limitations under the License.
*
*/
-class page3: public ui_basic_controller
+class page3: public ui_controller
{
private:
appdata_s *ad;
page3(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name).
+ /* ui_view(controller, identity name).
Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_basic_view(this, "page3"));
+ ad->viewmgr->push_view(new ui_view(this, "page3"));
}
~page3()
{
//Initialize contents.
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 3",
* limitations under the License.
*
*/
-class page4: public ui_basic_controller
+class page4: public ui_controller
{
private:
appdata_s *ad;
page4(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name).
+ /* ui_view(controller, identity name).
Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_basic_view(this, "page4"));
+ ad->viewmgr->push_view(new ui_view(this, "page4"));
}
~page4()
{
//Initialize contents.
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 4",
* limitations under the License.
*
*/
-class page5: public ui_basic_controller
+class page5: public ui_controller
{
private:
appdata_s *ad;
//No basic form.
/* ui_view(controller, identity name).
Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page5"));
+ ad->viewmgr->push_view(new ui_base_view(this, "page5"));
}
~page5()
{
//Initialize contents.
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
+ ui_base_view *view = dynamic_cast<ui_base_view *>(this->get_view());
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 5<br>(Full View)",
* limitations under the License.
*
*/
-class page6: public ui_basic_controller
+class page6: public ui_controller
{
private:
appdata_s *ad;
page6(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name).
+ /* ui_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"));
+ ad->viewmgr->push_view(new ui_view(this, "page6"));
}
~page6()
//Initialize contents.
- ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ ui_view *view = dynamic_cast<ui_view *>(this->get_view());
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 6",
* limitations under the License.
*
*/
-class page7: public ui_basic_controller
+class page7: public ui_controller
{
private:
appdata_s *ad;
page7(appdata_s *ad)
: ad(ad)
{
- /* ui_basic_view(controller, identity name, style name of view).
+ /* ui_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");
+ ui_view *view = new ui_view(this, "page7");
//FIXME: It will be deleted or change to other way :(
// We don't have any way to support it now.
*
*/
-class page8: public ui_basic_view
+class page8: public ui_view
{
private:
appdata_s *ad;
public:
page8(const char *name, appdata_s *ad)
- : ui_basic_view(name), ad(ad)
+ : ui_view(name), ad(ad)
{
ad->viewmgr->push_view(this);
}
* limitations under the License.
*
*/
-class page9: public ui_basic_view
+class page9: public ui_view
{
private:
appdata_s *ad;
public:
page9(const char *name, appdata_s *ad)
- : ui_basic_view(name), ad(ad)
+ : ui_view(name), ad(ad)
{
//FIXME: It will be deleted or change to other way :(
// We don't have any way to support it now.
+++ /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_BASIC_CONTROLLER_H
-#define UI_BASIC_CONTROLLER_H
-
-#include "../ui_viewmanager_efl.h"
-
-namespace efl_viewmgr
-{
-class ui_basic_controller: public ui_controller
-{
-public:
- virtual ~ui_basic_controller();
- virtual bool on_menu();
-};
-}
-
-#endif /* UI_BASIC_CONTROLLER_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.
- *
- */
-#ifndef UI_BASIC_KEY_HANDLER_H
-#define UI_BASIC_KEY_HANDLER_H
-
-#include "../ui_viewmanager_efl.h"
-
-namespace efl_viewmgr
-{
-class ui_viewmgr;
-
-class ui_basic_key_listener : public ui_key_listener
-{
-public:
- ui_basic_key_listener(ui_viewmgr *viewmgr);
-
- virtual bool init();
- virtual void extend_event_proc(ui_view *view, Evas_Event_Key_Down *ev);
-};
-
-}
-
-#endif /* UI_BASIC_KEY_HANDLER_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.
- *
- */
-#ifndef UI_BASIC_VIEW
-#define UI_BASIC_VIEW
-
-#include "../ui_viewmanager_efl.h"
-
-namespace efl_viewmgr
-{
-
-class ui_basic_view: public ui_view
-{
-private:
- Elm_Layout *layout; //Base layout for view
- Elm_Ctxpopup *ctxpopup; //Menu Widget
-
- bool create_layout();
- bool destroy_layout();
-
-protected:
- virtual void on_load();
- virtual void on_unload();
- virtual void unload_content();
- virtual void set_event_block(bool block);
-
-public:
- ui_basic_view(ui_controller *controller, const char *name = NULL);
- ui_basic_view(const char *name = NULL);
- virtual ~ui_basic_view();
-
- Evas_Object *set_content(Evas_Object *content, const char *title = NULL);
- Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn, Elm_Button *title_right_btn);
- bool set_title_badge(const char *text);
- bool set_subtitle(const char *text);
- bool set_title_left_btn(Elm_Button *title_left_btn);
- bool set_title_right_btn(Elm_Button *title_right_btn);
- bool set_title(const char *text);
- bool set_toolbar(Elm_Toolbar *toolbar);
- bool set_menu(Elm_Ctxpopup *menu);
- Elm_Ctxpopup *unset_menu();
- Evas_Object *unset_content();
- Elm_Button *unset_title_left_btn();
- Elm_Button *unset_title_right_btn();
- Elm_Toolbar *unset_toolbar();
-
- virtual void on_menu();
-
- virtual Evas_Object *get_base()
- {
- if (!this->layout)this->create_layout();
- return this->layout;
- }
-
- Elm_Ctxpopup *get_menu()
- {
- return this->ctxpopup;
- }
-
-};
-
-}
-
-#endif /* UI_BASIC_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_BASIC_VIEWMGR_H
-#define UI_BASIC_VIEWMGR_H
-
-#include <Elementary.h>
-#include "../ui_viewmanager_efl.h"
-
-namespace efl_viewmgr
-{
-
-class ui_basic_view;
-
-class ui_basic_viewmgr: public ui_viewmgr
-{
- friend class ui_basic_view;
-
-public:
- ui_basic_viewmgr(const char *pkg);
-
- virtual ~ui_basic_viewmgr();
-
-};
-}
-
-#endif /* UI_BASIC_VIEWMGR_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.
+ *
+ */
+#ifndef UI_CONTROLLER_H
+#define UI_CONTROLLER_H
+
+#include "../ui_viewmanager_base.h"
+
+namespace efl_viewmgr
+{
+class ui_controller: public ui_base_controller
+{
+public:
+ virtual ~ui_controller();
+ virtual bool on_menu();
+};
+}
+
+#endif /* UI_CONTROLLER_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.
+ *
+ */
+#ifndef UI_KEY_HANDLER_H
+#define UI_KEY_HANDLER_H
+
+#include "../ui_viewmanager_base.h"
+
+namespace efl_viewmgr
+{
+class ui_viewmgr;
+
+class ui_key_listener : public ui_base_key_listener
+{
+public:
+ ui_key_listener(ui_viewmgr *viewmgr);
+
+ virtual bool init();
+ virtual void extend_event_proc(ui_base_view *view, Evas_Event_Key_Down *ev);
+};
+
+}
+
+#endif /* UI_BASIC_KEY_HANDLER_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.
+ *
+ */
+#ifndef UI_VIEW
+#define UI_VIEW
+
+#include "../ui_viewmanager_base.h"
+
+namespace efl_viewmgr
+{
+
+class ui_view: public ui_base_view
+{
+private:
+ Elm_Layout *layout; //Base layout for view
+ Elm_Ctxpopup *ctxpopup; //Menu Widget
+
+ bool create_layout();
+ bool destroy_layout();
+
+protected:
+ virtual void on_load();
+ virtual void on_unload();
+ virtual void unload_content();
+ virtual void set_event_block(bool block);
+
+public:
+ ui_view(ui_controller *controller, const char *name = NULL);
+ ui_view(const char *name = NULL);
+ virtual ~ui_view();
+
+ Evas_Object *set_content(Evas_Object *content, const char *title = NULL);
+ Evas_Object *set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn, Elm_Button *title_right_btn);
+ bool set_title_badge(const char *text);
+ bool set_subtitle(const char *text);
+ bool set_title_left_btn(Elm_Button *title_left_btn);
+ bool set_title_right_btn(Elm_Button *title_right_btn);
+ bool set_title(const char *text);
+ bool set_toolbar(Elm_Toolbar *toolbar);
+ bool set_menu(Elm_Ctxpopup *menu);
+ Elm_Ctxpopup *unset_menu();
+ Evas_Object *unset_content();
+ Elm_Button *unset_title_left_btn();
+ Elm_Button *unset_title_right_btn();
+ Elm_Toolbar *unset_toolbar();
+
+ virtual void on_menu();
+
+ virtual Evas_Object *get_base()
+ {
+ if (!this->layout)this->create_layout();
+ return this->layout;
+ }
+
+ Elm_Ctxpopup *get_menu()
+ {
+ return this->ctxpopup;
+ }
+
+};
+
+}
+
+#endif /* 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 <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "UI_VIEWMGR"
+
+#include "ui_controller.h"
+#include "ui_view.h"
+#include "ui_key_listener.h"
+#include "ui_viewmgr.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 <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "UI_VIEWMGR"
-
-#include "ui_basic_controller.h"
-#include "ui_basic_view.h"
-#include "ui_basic_key_listener.h"
-#include "ui_basic_viewmgr.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.
+ *
+ */
+#ifndef UI_BASIC_VIEWMGR_H
+#define UI_BASIC_VIEWMGR_H
+
+#include <Elementary.h>
+#include "../ui_viewmanager_base.h"
+
+namespace efl_viewmgr
+{
+
+class ui_view;
+
+class ui_viewmgr: public ui_base_viewmgr
+{
+ friend class ui_view;
+
+public:
+ ui_viewmgr(const char *pkg);
+
+ virtual ~ui_viewmgr();
+
+};
+}
+
+#endif /* UI_VIEWMGR_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.
+ *
+ */
+#ifndef UI_BASE_CONTROLLER_H
+#define UI_BASE_CONTROLLER_H
+
+#include "../interface/ui_viewmanager_interface.h"
+
+namespace efl_viewmgr
+{
+
+/**
+ * @class ui_base_controller
+ *
+ * @ingroup viewmgr
+ *
+ * @brief UI Controller. This is a class for handling of life-cycle events from user side.
+ */
+class ui_base_controller: public viewmgr::ui_iface_controller
+{
+public:
+ ///Destructor.
+ virtual ~ui_base_controller();
+
+ /**
+ * @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_base_view *get_view();
+
+ /** @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 on_load() {}
+
+ /** @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 on_unload() {}
+
+ /** @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 on_active() {}
+
+ /** @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 on_inactive() {}
+
+ /** @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_base_viewmgr_base :: deactivate()).
+ * If the view were inactive or unload state, the pause won't be called.
+ */
+ virtual void on_pause() {}
+
+ /** @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_base_viewmgr :: activate())
+ */
+ virtual void on_resume() {}
+
+ /** @brief destroy callback.
+ *
+ * @note When this view is on destroying by popping or deleting.
+ */
+ virtual void on_destroy() {}
+
+ /** @brief Back key callback.
+ *
+ * @note In default. current view will be popped by viewmgr in those scenarios
+ * that viewmgr is requested to poo the current view.
+ * If you return false in the overriding, then popping will be stopped.
+ */
+ virtual bool on_back() { return true; }
+
+ /** @brief View rotate callback.
+ *
+ * @param degree Current rotation degree.
+ *
+ * @note This method will be called when view rotation occurred.
+ */
+ virtual void on_rotate(int degree) {}
+
+ /** @brief Portrait callback.
+ *
+ * @note When current view is on portrait mode.
+ */
+ virtual void on_portrait() {}
+
+ /** @brief Landscape callback.
+ *
+ * @note When current view is on landscape mode.
+ */
+ virtual void on_landscape() {}
+};
+}
+
+#endif /* UI_BASE_CONTROLLER_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.
+ *
+ */
+#ifndef UI_BASE_KEY_LISTENER_H
+#define UI_BASE_KEY_LISTENER_H
+
+#include <Elementary.h>
+#include "../interface/ui_viewmanager_interface.h"
+
+namespace efl_viewmgr
+{
+class ui_base_viewmgr;
+class ui_base_view;
+
+class ui_base_key_listener
+{
+protected:
+ ui_base_viewmgr *viewmgr;
+ Evas_Object *key_grabber;
+
+public:
+ ui_base_key_listener(ui_base_viewmgr *viewmgr);
+ virtual ~ui_base_key_listener() {}
+
+ virtual bool init();
+ virtual bool term();
+ virtual void extend_event_proc(ui_base_view *view, Evas_Event_Key_Down *ev) {}
+
+ ui_base_viewmgr *get_viewmgr() { return this->viewmgr; }
+};
+
+}
+
+#endif /* UI_BASE_KEY_LISTENER_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.
+ *
+ */
+#ifndef UI_BASE_VIEW_H
+#define UI_BASE_VIEW_H
+
+#include <Elementary.h>
+#include "../interface/ui_viewmanager_interface.h"
+
+#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
+#define CONVERT_TO_T(EO) static_cast<T>((EO))
+
+namespace efl_viewmgr
+{
+class ui_base_controller;
+
+/**
+ * @class ui_base_view
+ *
+ * @ingroup viewmgr
+ *
+ * @brief UI View Class. This is the 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_base_view: public viewmgr::ui_iface_view
+{
+ friend class ui_base_viewmgr;
+
+protected:
+ /** @brief Unload current view's content
+ *
+ * @note Make this view's content as NULL, then destroy content.
+ */
+ virtual void unload_content();
+
+ /** @brief Get a parent object of view.
+ *
+ * @note This is calling viewmgr get_base() method internally.
+ *
+ * @return base layout of viewmgr.
+ */
+ Evas_Object *get_parent();
+
+ /** @brief toggle event block.
+ *
+ * @note It makes internal conformant event freeze during effect showing.
+ *
+ * @param block @c true, when blocking is enabled, otherwise @c false.
+ */
+ virtual void set_event_block(bool block);
+
+public:
+ ///Constructor.
+ ui_base_view(ui_base_controller *controller, const char *name = NULL);
+ ///Constructor.
+ ui_base_view(const char *name = NULL);
+
+ ///Destructor.
+ virtual ~ui_base_view();
+
+ /** @brief This is for replacing or setting a content of the view.
+ *
+ * @param content a new content. It allows @c NULL for canceling the previous content.
+ *
+ * @return A previous content. If it wasn't, return value will be @c NULL.
+ */
+ virtual Evas_Object *set_content(Evas_Object *content);
+
+ /** @brief This is for unsetting a content of the view.
+ *
+ * @return A previous content. If it wasn't, return value will be @c NULL.
+ */
+ virtual Evas_Object *unset_content();
+
+ /** @brief Get a base layout of viewmgr.
+ */
+ virtual Evas_Object *get_base();
+
+ /** @brief This is for calling controller's back method.
+ */
+ virtual void on_back();
+
+ /** @brief This is for calling controller's rotate method.
+ */
+ virtual void on_rotate(int degree);
+
+ /** @brief This is for calling controller's portrait method.
+ */
+ virtual void on_portrait();
+
+ /** @brief This is for calling controller's landscape method.
+ */
+ virtual void on_landscape();
+ /** @brief Set the indicator mode.
+ *
+ * @param indicator The mode to set, one of #ui_base_view_indicator.
+ */
+ void set_indicator(ui_view_indicator indicator);
+
+ /** @brief Get current view's degree.
+ *
+ * @return Current rotation degree, -1 if failed to get viewmgr degree.
+ */
+ int get_degree();
+};
+
+}
+
+#endif /* UI_BASE_VIEW_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.
+ *
+ */
+#ifndef UI_BASE_VIEWMGR_H
+#define UI_BASE_VIEWMGR_H
+
+#include <Elementary.h>
+#include "../interface/ui_viewmanager_interface.h"
+#include "ui_base_key_listener.h"
+#include <map>
+
+
+//FIXME: ??
+#ifndef Elm_Conformant
+#define Elm_Conformant Evas_Object
+#endif
+
+namespace efl_viewmgr
+{
+
+class ui_base_view;
+
+/**
+ * @class ui_base_viewmgr
+ *
+ * @ingroup viewmgr
+ *
+ * @brief This is a 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_base_viewmgr: public viewmgr::ui_iface_viewmgr
+{
+ friend class ui_base_view;
+
+private:
+ Elm_Win *win; //This is acting like a base object of viewmgr.
+ Elm_Conformant *conform; //Conformant for viewmgr.
+ Elm_Layout *layout; //Viewmgr's base layout.
+ ui_base_key_listener *key_listener; //HW Key Handler such as "BACK" key...
+ ui_view_indicator indicator; //Mode of indicator.
+ string transition_style; //Current transiton effect style name
+ map<string, Elm_Layout *> effect_map; //Map for effect layouts.
+
+ Elm_Layout *set_transition_layout(string transition_style);
+
+ /**
+ * @brief Create a conformant.
+ *
+ * @param win viewmgr's window object. this will be parent of conformant object.
+ *
+ * @return @c true success or @c false not.
+ */
+ bool create_conformant(Elm_Win *win);
+
+ /**
+ * @brief Create a base layout.
+ *
+ * @param conform viewmgr's conformant object. this will be parent of layout object.
+ * @param style view's transition effect style.
+ *
+ * @return @c true success or @c false not.
+ */
+ bool create_base_layout(Elm_Conformant *conform, const char *style);
+
+ /** @brief Set the indicator mode.
+ *
+ * @param indicator The mode to set, one of #ui_view_indicator.
+ */
+ bool set_indicator(ui_view_indicator indicator);
+
+ void active_top_view();
+
+protected:
+ ui_base_viewmgr(const char *pkg, ui_base_key_listener *key_listener);
+
+ /** @brief Get a base layout of viewmgr.
+ */
+ Evas_Object *get_base()
+ {
+ return this->layout;
+ }
+
+public:
+ ///Constructor.
+ ui_base_viewmgr(const char *pkg);
+ ///Destructor.
+ virtual ~ui_base_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()
+ */
+ virtual 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()
+ */
+ virtual bool deactivate();
+
+ /**
+ * @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 in the 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()
+ */
+ virtual ui_base_view *push_view(ui_base_view *view);
+
+ /**
+ * @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 in the 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()
+ */
+ virtual bool pop_view();
+
+ /** @brief Get a window object of viewmgr.
+ */
+ Elm_Win *get_window()
+ {
+ return this->win;
+ }
+
+ /** @brief Get a conformant object of viewmgr.
+ */
+ Elm_Conformant *get_conformant()
+ {
+ return this->conform;
+ }
+
+ /** @brief Get a last view of current view stack.
+ */
+ ui_base_view *get_last_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_base_view *get_view(unsigned int idx);
+};
+}
+
+#endif /* UI_BASE_VIEWMGR_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.
- *
- */
-#ifndef UI_CONTROLLER_H
-#define UI_CONTROLLER_H
-
-#include "../interface/ui_viewmanager_interface.h"
-
-namespace efl_viewmgr
-{
-
-/**
- * @class ui_controller
- *
- * @ingroup viewmgr
- *
- * @brief UI Controller. This is a class for handling of life-cycle events from user side.
- */
-class ui_controller: public viewmgr::ui_iface_controller
-{
-public:
- ///Destructor.
- virtual ~ui_controller();
-
- /**
- * @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 *get_view();
-
- /** @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 on_load() {}
-
- /** @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 on_unload() {}
-
- /** @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 on_active() {}
-
- /** @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 on_inactive() {}
-
- /** @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 on_pause() {}
-
- /** @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 on_resume() {}
-
- /** @brief destroy callback.
- *
- * @note When this view is on destroying by popping or deleting.
- */
- virtual void on_destroy() {}
-
- /** @brief Back key callback.
- *
- * @note In default. current view will be popped by viewmgr in those scenarios
- * that viewmgr is requested to poo the current view.
- * If you return false in the overriding, then popping will be stopped.
- */
- virtual bool on_back() { return true; }
-
- /** @brief View rotate callback.
- *
- * @param degree Current rotation degree.
- *
- * @note This method will be called when view rotation occurred.
- */
- virtual void on_rotate(int degree) {}
-
- /** @brief Portrait callback.
- *
- * @note When current view is on portrait mode.
- */
- virtual void on_portrait() {}
-
- /** @brief Landscape callback.
- *
- * @note When current view is on landscape mode.
- */
- virtual void on_landscape() {}
-};
-}
-
-#endif /* UI_CONTROLLER_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.
- *
- */
-#ifndef UI_KEY_LISTENER_H
-#define UI_KEY_LISTENER_H
-
-#include <Elementary.h>
-#include "../interface/ui_viewmanager_interface.h"
-
-namespace efl_viewmgr
-{
-class ui_viewmgr;
-class ui_view;
-
-class ui_key_listener
-{
-protected:
- ui_viewmgr *viewmgr;
- Evas_Object *key_grabber;
-
-public:
- ui_key_listener(ui_viewmgr *viewmgr);
- virtual ~ui_key_listener() {}
-
- virtual bool init();
- virtual bool term();
- virtual void extend_event_proc(ui_view *view, Evas_Event_Key_Down *ev) {}
-
- ui_viewmgr *get_viewmgr() { return this->viewmgr; }
-};
-
-}
-
-#endif /* UI_KEY_LISTENER_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.
- *
- */
-#ifndef UI_VIEW_H
-#define UI_VIEW_H
-
-#include <Elementary.h>
-#include "../interface/ui_viewmanager_interface.h"
-
-#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
-#define CONVERT_TO_T(EO) static_cast<T>((EO))
-
-namespace efl_viewmgr
-{
-class ui_controller;
-
-/**
- * @class ui_view
- *
- * @ingroup viewmgr
- *
- * @brief UI View Class. This is the 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_view: public viewmgr::ui_iface_view
-{
- friend class ui_viewmgr;
-
-protected:
- /** @brief Unload current view's content
- *
- * @note Make this view's content as NULL, then destroy content.
- */
- virtual void unload_content();
-
- /** @brief Get a parent object of view.
- *
- * @note This is calling viewmgr get_base() method internally.
- *
- * @return base layout of viewmgr.
- */
- Evas_Object *get_parent();
-
- /** @brief toggle event block.
- *
- * @note It makes internal conformant event freeze during effect showing.
- *
- * @param block @c true, when blocking is enabled, otherwise @c false.
- */
- virtual void set_event_block(bool block);
-
-public:
- ///Constructor.
- ui_view(ui_controller *controller, const char *name = NULL);
- ///Constructor.
- ui_view(const char *name = NULL);
-
- ///Destructor.
- virtual ~ui_view();
-
- /** @brief This is for replacing or setting a content of the view.
- *
- * @param content a new content. It allows @c NULL for canceling the previous content.
- *
- * @return A previous content. If it wasn't, return value will be @c NULL.
- */
- virtual Evas_Object *set_content(Evas_Object *content);
-
- /** @brief This is for unsetting a content of the view.
- *
- * @return A previous content. If it wasn't, return value will be @c NULL.
- */
- virtual Evas_Object *unset_content();
-
- /** @brief Get a base layout of viewmgr.
- */
- virtual Evas_Object *get_base();
-
- /** @brief This is for calling controller's back method.
- */
- virtual void on_back();
-
- /** @brief This is for calling controller's rotate method.
- */
- virtual void on_rotate(int degree);
-
- /** @brief This is for calling controller's portrait method.
- */
- virtual void on_portrait();
-
- /** @brief This is for calling controller's landscape method.
- */
- virtual void on_landscape();
- /** @brief Set the indicator mode.
- *
- * @param indicator The mode to set, one of #ui_view_indicator.
- */
- void set_indicator(ui_view_indicator indicator);
-
- /** @brief Get current view's degree.
- *
- * @return Current rotation degree, -1 if failed to get viewmgr degree.
- */
- int get_degree();
-};
-
-}
-
-#endif /* UI_VIEW_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 <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "UI_VIEWMGR"
+
+#include "ui_base_viewmgr.h"
+#include "ui_base_controller.h"
+#include "ui_base_view.h"
+#include "ui_base_key_listener.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 <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "UI_VIEWMGR"
-
-#include "ui_viewmgr.h"
-#include "ui_controller.h"
-#include "ui_view.h"
-#include "ui_key_listener.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.
- *
- */
-#ifndef UI_VIEWMGR_H
-#define UI_VIEWMGR_H
-
-#include <Elementary.h>
-#include "../interface/ui_viewmanager_interface.h"
-#include "ui_key_listener.h"
-#include <map>
-
-
-//FIXME: ??
-#ifndef Elm_Conformant
-#define Elm_Conformant Evas_Object
-#endif
-
-namespace efl_viewmgr
-{
-
-class ui_view;
-
-/**
- * @class ui_viewmgr
- *
- * @ingroup viewmgr
- *
- * @brief This is a 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: public viewmgr::ui_iface_viewmgr
-{
- friend class ui_view;
-
-private:
- Elm_Win *win; //This is acting like a base object of viewmgr.
- Elm_Conformant *conform; //Conformant for viewmgr.
- Elm_Layout *layout; //Viewmgr's base layout.
- ui_key_listener *key_listener; //HW Key Handler such as "BACK" key...
- ui_view_indicator indicator; //Mode of indicator.
- string transition_style; //Current transiton effect style name
- map<string, Elm_Layout *> effect_map; //Map for effect layouts.
-
- Elm_Layout *set_transition_layout(string transition_style);
-
- /**
- * @brief Create a conformant.
- *
- * @param win viewmgr's window object. this will be parent of conformant object.
- *
- * @return @c true success or @c false not.
- */
- bool create_conformant(Elm_Win *win);
-
- /**
- * @brief Create a base layout.
- *
- * @param conform viewmgr's conformant object. this will be parent of layout object.
- * @param style view's transition effect style.
- *
- * @return @c true success or @c false not.
- */
- bool create_base_layout(Elm_Conformant *conform, const char *style);
-
- /** @brief Set the indicator mode.
- *
- * @param indicator The mode to set, one of #ui_view_indicator.
- */
- bool set_indicator(ui_view_indicator indicator);
-
- void active_top_view();
-
-protected:
- ui_viewmgr(const char *pkg, ui_key_listener *key_listener);
-
- /** @brief Get a base layout of viewmgr.
- */
- Evas_Object *get_base()
- {
- return this->layout;
- }
-
-public:
- ///Constructor.
- ui_viewmgr(const char *pkg);
- ///Destructor.
- virtual ~ui_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()
- */
- virtual 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()
- */
- virtual bool deactivate();
-
- /**
- * @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 in the 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()
- */
- virtual ui_view *push_view(ui_view *view);
-
- /**
- * @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 in the 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()
- */
- virtual bool pop_view();
-
- /** @brief Get a window object of viewmgr.
- */
- Elm_Win *get_window()
- {
- return this->win;
- }
-
- /** @brief Get a conformant object of viewmgr.
- */
- Elm_Conformant *get_conformant()
- {
- return this->conform;
- }
-
- /** @brief Get a last view of current view stack.
- */
- ui_view *get_last_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 *get_view(unsigned int idx);
-};
-}
-
-#endif /* UI_VIEWMGR_H */
-#include "efl/mobile/ui_viewmanager_mobile.h"
+#include "efl/mobile/ui_viewmanager.h"
interface/ui_iface_controller.cpp
interface/ui_iface_view.cpp
interface/ui_iface_viewmgr.cpp
- efl/ui_controller.cpp
- efl/ui_view.cpp
- efl/ui_viewmgr.cpp
- efl/ui_key_listener.cpp
- efl/mobile/ui_basic_controller.cpp
- efl/mobile/ui_basic_view.cpp
- efl/mobile/ui_basic_key_listener.cpp
- efl/mobile/ui_basic_viewmgr.cpp
+ efl/ui_base_controller.cpp
+ efl/ui_base_view.cpp
+ efl/ui_base_viewmgr.cpp
+ efl/ui_base_key_listener.cpp
+ efl/mobile/ui_controller.cpp
+ efl/mobile/ui_view.cpp
+ efl/mobile/ui_key_listener.cpp
+ efl/mobile/ui_viewmgr.cpp
)
ADD_LIBRARY(${LIB_NAME} SHARED ${LIB_SRCS})
+++ /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 "../../../include/efl/mobile/ui_viewmanager_mobile.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-ui_basic_controller::~ui_basic_controller()
-{
-}
-
-bool ui_basic_controller::on_menu()
-{
- return true;
-}
+++ /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 "../../../include/efl/mobile/ui_viewmanager_mobile.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-static const char *KEY_MENU = "XF86Menu";
-static const char *KEY_MENU2 = "XF86Send";
-
-ui_basic_key_listener::ui_basic_key_listener(ui_viewmgr *viewmgr)
- : ui_key_listener(viewmgr)
-{
-}
-
-void ui_basic_key_listener::extend_event_proc(ui_view *view, Evas_Event_Key_Down *ev)
-{
- if (strcmp(ev->keyname, KEY_MENU) && strcmp(ev->keyname, KEY_MENU2)) return;
- dynamic_cast<ui_basic_view *>(view)->on_menu();
-}
-
-bool ui_basic_key_listener::init()
-{
- if (!ui_key_listener::init()) return false;
-
- if (!evas_object_key_grab(this->key_grabber, KEY_MENU, 0, 0, EINA_FALSE))
- {
- LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU);
- return false;
- }
-
- if (!evas_object_key_grab(this->key_grabber, KEY_MENU2, 0, 0, EINA_FALSE))
- {
- LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU2);
- return false;
- }
- return true;
-}
+++ /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 "../../../include/efl/mobile/ui_viewmanager_mobile.h"
-
-//FIXME: is it correct to define here?
-#define EDJ_PATH "/usr/share/edje/ui-viewmgr/ui-viewmgr.edj"
-#define GROUP "tizen_view/default"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-#define MY_VIEWMGR dynamic_cast<ui_viewmgr *>(this->get_viewmgr())
-#define MY_CONTROLLER dynamic_cast<ui_basic_controller *>(this->get_controller()))
-
-static void update_menu(Elm_Win *win, Elm_Ctxpopup *ctxpopup)
-{
- /* We convince the top widget is a window */
- Evas_Coord w, h;
- elm_win_screen_size_get(win, NULL, NULL, &w, &h);
- int rot = elm_win_rotation_get(win);
-
- switch (rot)
- {
- case 0:
- case 180:
- evas_object_move(ctxpopup, (w / 2), h);
- break;
- case 90:
- case 270:
- evas_object_move(ctxpopup, (h / 2), w);
- break;
- }
- evas_object_show(ctxpopup);
-}
-
-bool ui_basic_view::destroy_layout()
-{
- if (!this->layout) return false;
- evas_object_del(this->layout);
- this->layout = NULL;
-
- return true;
-}
-
-bool ui_basic_view::create_layout()
-{
- if (this->layout) return false;
-
- Elm_Layout *layout = elm_layout_add(this->get_parent());
-
- if (!layout)
- {
- LOGE("Failed to create a layout = ui_basic_view(%p)", this);
- return false;
- }
-
- if (!elm_layout_file_set(layout, EDJ_PATH, GROUP))
- {
- LOGE("Failed to set file = ui_basic_view(%p), path(%s), group(%s)", this, EDJ_PATH, GROUP);
- evas_object_del(layout);
- return false;
- }
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- if (this->get_content())
- {
- elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content()));
- }
-
- //Set software back key, if it's needed
- ui_viewmgr *viewmgr = MY_VIEWMGR;
- if (viewmgr->need_soft_key())
- {
- Elm_Button *prev_btn = elm_button_add(layout);
-
- if (!prev_btn)
- {
- LOGE("Failed to create a button = ui_basic_view(%p)", this);
- }
- else
- {
- evas_object_smart_callback_add(prev_btn, "clicked", [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
- viewmgr->pop_view();
- }, viewmgr);
-
- elm_object_style_set(prev_btn, "tizen_view/prev_btn");
- elm_object_part_content_set(layout, "elm.swallow.prev_btn", prev_btn);
- elm_object_signal_emit(layout, "elm,state,prev_btn,show", "elm");
- }
- }
-
- //FIXME: .... ?
- evas_object_event_callback_add(layout, EVAS_CALLBACK_RESIZE,
- [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
- {
- ui_basic_view *view = static_cast<ui_basic_view *>(data);
- Elm_Ctxpopup *ctxpopup = view->get_menu();
- if (ctxpopup && evas_object_visible_get(ctxpopup))
- {
- update_menu(dynamic_cast<ui_viewmgr *>(view->get_viewmgr())->get_window(), ctxpopup);
- }
- },
- this);
-
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOVE,
- [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
- {
- ui_basic_view *view = static_cast<ui_basic_view *>(data);
- Elm_Ctxpopup *ctxpopup = view->get_menu();
- if (ctxpopup && evas_object_visible_get(ctxpopup))
- {
- elm_ctxpopup_dismiss(ctxpopup);
- }
- },
- this);
-
- this->layout = layout;
-
- return true;
-}
-
-ui_basic_view::ui_basic_view(ui_controller *controller, const char *name)
- : ui_view(controller, name), layout(NULL), ctxpopup(NULL)
-{
-}
-
-ui_basic_view::ui_basic_view(const char *name)
- : ui_basic_view(NULL, name)
-{
-}
-
-ui_basic_view::~ui_basic_view()
-{
- evas_object_del(this->ctxpopup);
- destroy_layout();
-}
-
-void ui_basic_view::on_load()
-{
- if (!this->layout) this->create_layout();
- ui_view::on_load();
-}
-
-void ui_basic_view::on_unload()
-{
- ui_view::on_unload();
-}
-
-Evas_Object *
-ui_basic_view::set_content(Evas_Object *content, const char *title)
-{
- Evas_Object *pcontent = ui_view::set_content(content);
-
- if (this->layout)
- {
- elm_object_part_content_unset(this->layout, "elm.swallow.content");
- elm_object_part_content_set(this->layout, "elm.swallow.content", content);
- elm_object_part_text_set(this->layout, "elm.text.title", title);
- }
- else
- {
- LOGE("Layout is not exist!");
- }
-
- return pcontent;
-}
-
-bool ui_basic_view::set_subtitle(const char *text)
-{
- if (this->layout)
- {
- elm_object_part_text_set(this->layout, "elm.text.subtitle", text);
- if (text) elm_object_signal_emit(this->layout, "elm,state,subtitle,show", "elm");
- else elm_object_signal_emit(this->layout, "elm,state,subtitle,hide", "elm");
- return true;
- }
- LOGE("Layout is not exist!");
- return false;
-}
-
-bool ui_basic_view::set_title_left_btn(Elm_Button *title_left_btn)
-{
- if (this->layout)
- {
- if (title_left_btn)
- {
- elm_object_style_set(title_left_btn, "tizen_view/title_left");
- }
- elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn);
- if (title_left_btn) elm_object_signal_emit(this->layout, "elm,state,title_left_btn,show", "elm");
- else elm_object_signal_emit(this->layout, "elm,state,title_left_btn,hide", "elm");
- return true;
- }
- LOGE("Layout is not exist!");
- return false;
-}
-
-bool ui_basic_view::set_title_right_btn(Elm_Button *title_right_btn)
-{
- if (this->layout)
- {
- if (title_right_btn)
- {
- elm_object_style_set(title_right_btn, "tizen_view/title_right");
- }
- elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn);
- if (title_right_btn) elm_object_signal_emit(this->layout, "elm,state,title_right_btn,show", "elm");
- else elm_object_signal_emit(this->layout, "elm,state,title_right_btn,hide", "elm");
- return true;
- }
- LOGE("Layout is not exist!");
- return false;
-}
-
-bool ui_basic_view::set_title_badge(const char *text)
-{
- if (this->layout)
- {
- elm_object_part_text_set(this->layout, "title_badge", text);
- if (text) elm_object_signal_emit(this->layout, "elm,state,title_badge,show", "elm");
- else elm_object_signal_emit(this->layout, "elm,state,title_badge,hide", "elm");
- return true;
- }
- LOGE("Layout is not exist!");
- return false;
-}
-
-bool ui_basic_view::set_title(const char *text)
-{
- if (this->layout)
- {
- elm_object_part_text_set(this->layout, "elm.text.title", text);
- if (text) elm_object_signal_emit(this->layout, "elm,state,title,show", "elm");
- else elm_object_signal_emit(this->layout, "elm,state,title,hide", "elm");
- return true;
- }
- LOGE("Layout is not exist!");
- return false;
-}
-
-Evas_Object *ui_basic_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn,
- Elm_Button *title_right_btn)
-{
- Evas_Object *pcontent = this->set_content(content);
-
- if (this->layout)
- {
- this->set_title(title);
- this->set_subtitle(subtitle);
- this->set_title_left_btn(title_left_btn);
- this->set_title_right_btn(title_right_btn);
- }
- else
- {
- LOGE("Layout is not exist!");
- }
-
- return pcontent;
-}
-
-bool ui_basic_view::set_menu(Elm_Ctxpopup *menu)
-{
- if (this->ctxpopup) evas_object_del(this->ctxpopup);
-
- //validation!
- if (strcmp(evas_object_type_get(menu), "elm_ctxpopup"))
- {
- LOGE("Menu widget is not a ctxpopup!");
- return false;
- }
-
- //FIXME: rename style.
- elm_object_style_set(menu, "more/default");
- elm_ctxpopup_auto_hide_disabled_set(menu, EINA_TRUE);
- evas_object_smart_callback_add(menu, "dismissed",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- evas_object_hide(obj);
- },
- NULL);
- evas_object_event_callback_add(menu, EVAS_CALLBACK_DEL,
- [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
- {
- ui_basic_view *view = static_cast<ui_basic_view *>(data);
- view->unset_menu();
- },
- this);
-
- this->ctxpopup = menu;
-
- return true;
-}
-
-bool ui_basic_view::set_toolbar(Elm_Toolbar *toolbar)
-{
- Elm_Layout *layout = this->get_base();
-
- //FIXME: Keep this toolbar inside of this view then set up when layout is created after.
- if (!layout)
- {
- LOGE("Layout is not exist!");
- return false;
- }
-
- 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);
- }
- else
- {
- elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
- }
- 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");
-
- return true;
-}
-
-void ui_basic_view::unload_content()
-{
- ui_view::set_content(NULL);
- this->destroy_layout();
-}
-
-void ui_basic_view::on_menu()
-{
- if (this->ctxpopup && evas_object_visible_get(this->ctxpopup))
- {
- elm_ctxpopup_dismiss(this->ctxpopup);
- return;
- }
-
- if (this->get_controller())
- {
- (MY_CONTROLLER->on_menu();
- }
-
- if (this->ctxpopup)
- {
- update_menu(MY_VIEWMGR->get_window(), this->ctxpopup);
- }
-}
-
-void ui_basic_view::set_event_block(bool block)
-{
- ui_iface_view::set_event_block(block);
- evas_object_freeze_events_set(this->get_base(), block);
-}
-
-Elm_Ctxpopup* ui_basic_view::unset_menu()
-{
- Elm_Ctxpopup *menu = this->ctxpopup;
- //FIXME: cancel callbacks
- this->ctxpopup = NULL;
- return menu;
-}
-
-Evas_Object *ui_basic_view::unset_content()
-{
- Evas_Object *pcontent = ui_view::unset_content();
-
- if (!this->get_base()) return pcontent;
-
- elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
- evas_object_hide(pcontent);
-
- return pcontent;
-}
-
-Elm_Button *ui_basic_view::unset_title_left_btn()
-{
- Elm_Button *title_left_btn;
-
- if (!this->get_base()) return NULL;
-
- title_left_btn = elm_object_part_content_unset(this->get_base(), "title_left_btn");
- if (title_left_btn)
- elm_object_signal_emit(this->get_base(), "elm,state,title_left_btn,hide", "elm");
- evas_object_hide(title_left_btn);
-
- return title_left_btn;
-}
-
-Elm_Button *ui_basic_view::unset_title_right_btn()
-{
- Elm_Button *title_right_btn;
-
- if (!this->get_base()) return NULL;
-
- title_right_btn = elm_object_part_content_unset(this->get_base(), "title_right_btn");
- if (title_right_btn)
- elm_object_signal_emit(this->get_base(), "elm,state,title_right_btn,hide", "elm");
- evas_object_hide(title_right_btn);
-
- return title_right_btn;
-}
-
-Elm_Toolbar *ui_basic_view::unset_toolbar()
-{
- Elm_Toolbar *toolbar;
-
- if (!this->get_base()) return NULL;
-
- toolbar = elm_object_part_content_unset(this->get_base(), "toolbar");
- if (toolbar)
- elm_object_signal_emit(this->get_base(), "elm,state,toolbar,hide", "elm");
- evas_object_hide(toolbar);
-
- return 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.
- *
- */
-#include "../../../include/efl/mobile/ui_viewmanager_mobile.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-ui_basic_viewmgr::ui_basic_viewmgr(const char *pkg)
- : ui_viewmgr(pkg, new ui_basic_key_listener(this))
-{
-}
-
-ui_basic_viewmgr::~ui_basic_viewmgr()
-{
-}
--- /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 "../../../include/efl/mobile/ui_viewmanager.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+ui_controller::~ui_controller()
+{
+}
+
+bool ui_controller::on_menu()
+{
+ return true;
+}
--- /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 "../../../include/efl/mobile/ui_viewmanager.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+static const char *KEY_MENU = "XF86Menu";
+static const char *KEY_MENU2 = "XF86Send";
+
+ui_key_listener::ui_key_listener(ui_viewmgr *viewmgr)
+ : ui_base_key_listener(viewmgr)
+{
+}
+
+void ui_key_listener::extend_event_proc(ui_base_view *view, Evas_Event_Key_Down *ev)
+{
+ if (strcmp(ev->keyname, KEY_MENU) && strcmp(ev->keyname, KEY_MENU2)) return;
+ dynamic_cast<ui_view *>(view)->on_menu();
+}
+
+bool ui_key_listener::init()
+{
+ if (!ui_base_key_listener::init()) return false;
+
+ if (!evas_object_key_grab(this->key_grabber, KEY_MENU, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU);
+ return false;
+ }
+
+ if (!evas_object_key_grab(this->key_grabber, KEY_MENU2, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab MENU KEY(%s)\n", KEY_MENU2);
+ return false;
+ }
+ return true;
+}
--- /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 "../../../include/efl/mobile/ui_viewmanager.h"
+
+//FIXME: is it correct to define here?
+#define EDJ_PATH "/usr/share/edje/ui-viewmgr/ui-viewmgr.edj"
+#define GROUP "tizen_view/default"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+#define MY_VIEWMGR dynamic_cast<ui_viewmgr *>(this->get_viewmgr())
+#define MY_CONTROLLER dynamic_cast<ui_controller *>(this->get_controller()))
+
+static void update_menu(Elm_Win *win, Elm_Ctxpopup *ctxpopup)
+{
+ /* We convince the top widget is a window */
+ Evas_Coord w, h;
+ elm_win_screen_size_get(win, NULL, NULL, &w, &h);
+ int rot = elm_win_rotation_get(win);
+
+ switch (rot)
+ {
+ case 0:
+ case 180:
+ evas_object_move(ctxpopup, (w / 2), h);
+ break;
+ case 90:
+ case 270:
+ evas_object_move(ctxpopup, (h / 2), w);
+ break;
+ }
+ evas_object_show(ctxpopup);
+}
+
+bool ui_view::destroy_layout()
+{
+ if (!this->layout) return false;
+ evas_object_del(this->layout);
+ this->layout = NULL;
+
+ return true;
+}
+
+bool ui_view::create_layout()
+{
+ if (this->layout) return false;
+
+ Elm_Layout *layout = elm_layout_add(this->get_parent());
+
+ if (!layout)
+ {
+ LOGE("Failed to create a layout = ui_view(%p)", this);
+ return false;
+ }
+
+ if (!elm_layout_file_set(layout, EDJ_PATH, GROUP))
+ {
+ LOGE("Failed to set file = ui_view(%p), path(%s), group(%s)", this, EDJ_PATH, GROUP);
+ evas_object_del(layout);
+ return false;
+ }
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ if (this->get_content())
+ {
+ elm_object_part_content_set(layout, "elm.swallow.content", CONVERT_TO_EO(this->get_content()));
+ }
+
+ //Set software back key, if it's needed
+ ui_viewmgr *viewmgr = MY_VIEWMGR;
+ if (viewmgr->need_soft_key())
+ {
+ Elm_Button *prev_btn = elm_button_add(layout);
+
+ if (!prev_btn)
+ {
+ LOGE("Failed to create a button = ui_view(%p)", this);
+ }
+ else
+ {
+ evas_object_smart_callback_add(prev_btn, "clicked", [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
+ viewmgr->pop_view();
+ }, viewmgr);
+
+ elm_object_style_set(prev_btn, "tizen_view/prev_btn");
+ elm_object_part_content_set(layout, "elm.swallow.prev_btn", prev_btn);
+ elm_object_signal_emit(layout, "elm,state,prev_btn,show", "elm");
+ }
+ }
+
+ //FIXME: .... ?
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_RESIZE,
+ [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_view *view = static_cast<ui_view *>(data);
+ Elm_Ctxpopup *ctxpopup = view->get_menu();
+ if (ctxpopup && evas_object_visible_get(ctxpopup))
+ {
+ update_menu(dynamic_cast<ui_viewmgr *>(view->get_viewmgr())->get_window(), ctxpopup);
+ }
+ },
+ this);
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOVE,
+ [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_view *view = static_cast<ui_view *>(data);
+ Elm_Ctxpopup *ctxpopup = view->get_menu();
+ if (ctxpopup && evas_object_visible_get(ctxpopup))
+ {
+ elm_ctxpopup_dismiss(ctxpopup);
+ }
+ },
+ this);
+
+ this->layout = layout;
+
+ return true;
+}
+
+ui_view::ui_view(ui_controller *controller, const char *name)
+ : ui_base_view(controller, name), layout(NULL), ctxpopup(NULL)
+{
+}
+
+ui_view::ui_view(const char *name)
+ : ui_view(NULL, name)
+{
+}
+
+ui_view::~ui_view()
+{
+ evas_object_del(this->ctxpopup);
+ destroy_layout();
+}
+
+void ui_view::on_load()
+{
+ if (!this->layout) this->create_layout();
+ ui_base_view::on_load();
+}
+
+void ui_view::on_unload()
+{
+ ui_base_view::on_unload();
+}
+
+Evas_Object *
+ui_view::set_content(Evas_Object *content, const char *title)
+{
+ Evas_Object *pcontent = ui_base_view::set_content(content);
+
+ if (this->layout)
+ {
+ elm_object_part_content_unset(this->layout, "elm.swallow.content");
+ elm_object_part_content_set(this->layout, "elm.swallow.content", content);
+ elm_object_part_text_set(this->layout, "elm.text.title", title);
+ }
+ else
+ {
+ LOGE("Layout is not exist!");
+ }
+
+ return pcontent;
+}
+
+bool ui_view::set_subtitle(const char *text)
+{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "elm.text.subtitle", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,subtitle,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,subtitle,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool ui_view::set_title_left_btn(Elm_Button *title_left_btn)
+{
+ if (this->layout)
+ {
+ if (title_left_btn)
+ {
+ elm_object_style_set(title_left_btn, "tizen_view/title_left");
+ }
+ elm_object_part_content_set(this->layout, "title_left_btn", title_left_btn);
+ if (title_left_btn) elm_object_signal_emit(this->layout, "elm,state,title_left_btn,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_left_btn,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool ui_view::set_title_right_btn(Elm_Button *title_right_btn)
+{
+ if (this->layout)
+ {
+ if (title_right_btn)
+ {
+ elm_object_style_set(title_right_btn, "tizen_view/title_right");
+ }
+ elm_object_part_content_set(this->layout, "title_right_btn", title_right_btn);
+ if (title_right_btn) elm_object_signal_emit(this->layout, "elm,state,title_right_btn,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_right_btn,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool ui_view::set_title_badge(const char *text)
+{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "title_badge", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,title_badge,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title_badge,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+bool ui_view::set_title(const char *text)
+{
+ if (this->layout)
+ {
+ elm_object_part_text_set(this->layout, "elm.text.title", text);
+ if (text) elm_object_signal_emit(this->layout, "elm,state,title,show", "elm");
+ else elm_object_signal_emit(this->layout, "elm,state,title,hide", "elm");
+ return true;
+ }
+ LOGE("Layout is not exist!");
+ return false;
+}
+
+Evas_Object *ui_view::set_content(Evas_Object *content, const char *title, const char *subtitle, Elm_Button *title_left_btn,
+ Elm_Button *title_right_btn)
+{
+ Evas_Object *pcontent = this->set_content(content);
+
+ if (this->layout)
+ {
+ this->set_title(title);
+ this->set_subtitle(subtitle);
+ this->set_title_left_btn(title_left_btn);
+ this->set_title_right_btn(title_right_btn);
+ }
+ else
+ {
+ LOGE("Layout is not exist!");
+ }
+
+ return pcontent;
+}
+
+bool ui_view::set_menu(Elm_Ctxpopup *menu)
+{
+ if (this->ctxpopup) evas_object_del(this->ctxpopup);
+
+ //validation!
+ if (strcmp(evas_object_type_get(menu), "elm_ctxpopup"))
+ {
+ LOGE("Menu widget is not a ctxpopup!");
+ return false;
+ }
+
+ //FIXME: rename style.
+ elm_object_style_set(menu, "more/default");
+ elm_ctxpopup_auto_hide_disabled_set(menu, EINA_TRUE);
+ evas_object_smart_callback_add(menu, "dismissed",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ evas_object_hide(obj);
+ },
+ NULL);
+ evas_object_event_callback_add(menu, EVAS_CALLBACK_DEL,
+ [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_view *view = static_cast<ui_view *>(data);
+ view->unset_menu();
+ },
+ this);
+
+ this->ctxpopup = menu;
+
+ return true;
+}
+
+bool ui_view::set_toolbar(Elm_Toolbar *toolbar)
+{
+ Elm_Layout *layout = this->get_base();
+
+ //FIXME: Keep this toolbar inside of this view then set up when layout is created after.
+ if (!layout)
+ {
+ LOGE("Layout is not exist!");
+ return false;
+ }
+
+ 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);
+ }
+ else
+ {
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ }
+ 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");
+
+ return true;
+}
+
+void ui_view::unload_content()
+{
+ ui_base_view::set_content(NULL);
+ this->destroy_layout();
+}
+
+void ui_view::on_menu()
+{
+ if (this->ctxpopup && evas_object_visible_get(this->ctxpopup))
+ {
+ elm_ctxpopup_dismiss(this->ctxpopup);
+ return;
+ }
+
+ if (this->get_controller())
+ {
+ (MY_CONTROLLER->on_menu();
+ }
+
+ if (this->ctxpopup)
+ {
+ update_menu(MY_VIEWMGR->get_window(), this->ctxpopup);
+ }
+}
+
+void ui_view::set_event_block(bool block)
+{
+ ui_iface_view::set_event_block(block);
+ evas_object_freeze_events_set(this->get_base(), block);
+}
+
+Elm_Ctxpopup* ui_view::unset_menu()
+{
+ Elm_Ctxpopup *menu = this->ctxpopup;
+ //FIXME: cancel callbacks
+ this->ctxpopup = NULL;
+ return menu;
+}
+
+Evas_Object *ui_view::unset_content()
+{
+ Evas_Object *pcontent = ui_base_view::unset_content();
+
+ if (!this->get_base()) return pcontent;
+
+ elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
+ evas_object_hide(pcontent);
+
+ return pcontent;
+}
+
+Elm_Button *ui_view::unset_title_left_btn()
+{
+ Elm_Button *title_left_btn;
+
+ if (!this->get_base()) return NULL;
+
+ title_left_btn = elm_object_part_content_unset(this->get_base(), "title_left_btn");
+ if (title_left_btn)
+ elm_object_signal_emit(this->get_base(), "elm,state,title_left_btn,hide", "elm");
+ evas_object_hide(title_left_btn);
+
+ return title_left_btn;
+}
+
+Elm_Button *ui_view::unset_title_right_btn()
+{
+ Elm_Button *title_right_btn;
+
+ if (!this->get_base()) return NULL;
+
+ title_right_btn = elm_object_part_content_unset(this->get_base(), "title_right_btn");
+ if (title_right_btn)
+ elm_object_signal_emit(this->get_base(), "elm,state,title_right_btn,hide", "elm");
+ evas_object_hide(title_right_btn);
+
+ return title_right_btn;
+}
+
+Elm_Toolbar *ui_view::unset_toolbar()
+{
+ Elm_Toolbar *toolbar;
+
+ if (!this->get_base()) return NULL;
+
+ toolbar = elm_object_part_content_unset(this->get_base(), "toolbar");
+ if (toolbar)
+ elm_object_signal_emit(this->get_base(), "elm,state,toolbar,hide", "elm");
+ evas_object_hide(toolbar);
+
+ return 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.
+ *
+ */
+#include "../../../include/efl/mobile/ui_viewmanager.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+ui_viewmgr::ui_viewmgr(const char *pkg)
+ : ui_base_viewmgr(pkg, new ui_key_listener(this))
+{
+}
+
+ui_viewmgr::~ui_viewmgr()
+{
+}
--- /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 "../../include/efl/ui_viewmanager_base.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+ui_base_view * ui_base_controller::get_view()
+{
+ ui_iface_view *view = ui_iface_controller::get_view();
+ if (!view) return NULL;
+ return dynamic_cast<ui_base_view *>(view);
+}
+
+ui_base_controller::~ui_base_controller()
+{
+
+}
--- /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 "../../include/efl/ui_viewmanager_base.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+static const char *KEY_BACK = "XF86Back";
+static const char *KEY_BACK2 = "XF86Stop";
+
+ui_base_key_listener::ui_base_key_listener(ui_base_viewmgr *viewmgr)
+ : viewmgr(viewmgr), key_grabber(NULL)
+{
+
+}
+
+static void event_proc(ui_base_key_listener *key_listener, Evas_Event_Key_Down *ev)
+{
+ //Only if view manager is activated
+ ui_base_viewmgr *viewmgr = key_listener->get_viewmgr();
+ if (!viewmgr->is_activated()) return;
+
+ //Get Top View
+ ui_base_view *view = dynamic_cast<ui_base_view *>(viewmgr->get_last_view());
+ if (!view) return;
+
+ key_listener->extend_event_proc(view, ev);
+
+ if (strcmp(ev->keyname, KEY_BACK) && strcmp(ev->keyname, KEY_BACK2)) return;
+
+ view->on_back();
+}
+
+bool ui_base_key_listener::term()
+{
+ evas_object_del(this->key_grabber);
+ return true;
+}
+
+bool ui_base_key_listener::init()
+{
+ if (!this->viewmgr)
+ {
+ LOGE("No view manager??");
+ return false;
+ }
+
+ Evas *e = evas_object_evas_get(this->viewmgr->get_window());
+ if (!e)
+ {
+ LOGE("Failed to get Evas from window");
+ return false;
+ }
+
+ Evas_Object *key_grab_rect = evas_object_rectangle_add(e);
+ if (!key_grab_rect)
+ {
+ LOGE("Failed to create a key grabber rectangle");
+ return false;
+ }
+
+ evas_object_event_callback_add(key_grab_rect, EVAS_CALLBACK_KEY_UP, [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
+ {
+ Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(event_info);
+ ui_base_key_listener *key_listener = static_cast<ui_base_key_listener *>(data);
+ event_proc(key_listener, ev);
+ }, this);
+
+ if (!evas_object_key_grab(key_grab_rect, KEY_BACK, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK);
+ evas_object_del(key_grab_rect);
+ return false;
+ }
+
+ if (!evas_object_key_grab(key_grab_rect, KEY_BACK2, 0, 0, EINA_FALSE))
+ {
+ LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK2);
+ evas_object_del(key_grab_rect);
+ return false;
+ }
+
+ this->key_grabber = key_grab_rect;
+
+ return true;
+}
--- /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 "../../include/efl/ui_viewmanager_base.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+#define MY_CONTROLLER dynamic_cast<ui_base_controller *>(this->get_controller())
+#define MY_VIEWMGR dynamic_cast<ui_base_viewmgr *>(this->get_viewmgr())
+
+ui_base_view::ui_base_view(ui_base_controller *controller, const char *name)
+ : ui_iface_view(controller, name)
+{
+}
+
+ui_base_view::ui_base_view(const char *name)
+ : ui_base_view(NULL, name)
+{
+}
+
+ui_base_view::~ui_base_view()
+{
+}
+
+Evas_Object *ui_base_view::set_content(Evas_Object *content)
+{
+ T pcontent = ui_iface_view::set_content(CONVERT_TO_T(content));
+ return CONVERT_TO_EO(pcontent);
+}
+
+Evas_Object *ui_base_view::unset_content()
+{
+ T pcontent = ui_iface_view::unset_content();
+ return static_cast<Evas_Object *>(pcontent);
+}
+
+Evas_Object *ui_base_view::get_base()
+{
+ ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ if (!viewmgr)
+ {
+ return NULL;
+ }
+ return viewmgr->get_base();
+}
+
+void ui_base_view::unload_content()
+{
+ Evas_Object *pcontent = this->set_content(NULL);
+ if (pcontent) evas_object_del(pcontent);
+}
+
+Evas_Object *ui_base_view ::get_parent()
+{
+ ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return NULL;
+ }
+ return viewmgr->get_base();
+}
+
+void ui_base_view::set_indicator(ui_view_indicator indicator)
+{
+ if (this->get_indicator() == indicator) return;
+
+ ui_iface_view::set_indicator(indicator);
+
+ ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+
+ if (!viewmgr->is_activated()) return;
+
+ if (dynamic_cast<ui_base_view *>(viewmgr->get_last_view()) != this) return;
+
+ viewmgr->set_indicator(indicator);
+}
+
+void ui_base_view::on_back()
+{
+ if (this->get_controller())
+ {
+ if (!MY_CONTROLLER->on_back())
+ {
+ return;
+ }
+ }
+ MY_VIEWMGR->pop_view();
+}
+
+void ui_base_view::on_rotate(int degree)
+{
+ if (this->get_controller())
+ {
+ MY_CONTROLLER->on_rotate(degree);
+ }
+}
+
+void ui_base_view::on_portrait()
+{
+ if (this->get_controller())
+ {
+ MY_CONTROLLER->on_portrait();
+ }
+}
+
+void ui_base_view::on_landscape()
+{
+ if (this->get_controller())
+ {
+ MY_CONTROLLER->on_landscape();
+ }
+}
+void ui_base_view::set_event_block(bool block)
+{
+ ui_iface_view::set_event_block(block);
+ evas_object_freeze_events_set(CONVERT_TO_EO(this->get_content()), block);
+}
+
+int ui_base_view::get_degree()
+{
+ ui_base_viewmgr *viewmgr = MY_VIEWMGR;
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return -1;
+ }
+ return elm_win_rotation_get(viewmgr->get_window());
+}
--- /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 "../../include/efl/ui_viewmanager_base.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+//FIXME: is it correct to define here?
+#define EDJ_PATH "/usr/share/edje/ui-viewmgr/ui-viewmgr.edj"
+
+bool ui_base_viewmgr::create_base_layout(Elm_Conformant *conform, const char *style)
+{
+ char buf[128];
+ Elm_Layout *layout = elm_layout_add(conform);
+ if (!layout) return false;
+
+ //FIXME: Is it C programming style? need to change?
+ snprintf(buf, sizeof(buf), "transition/%s", style);
+ //default transition layout
+ elm_layout_file_set(layout, EDJ_PATH, buf);
+ elm_object_content_set(conform, layout);
+
+ //Push Finished Event
+ elm_layout_signal_callback_add(layout, "push,finished", "viewmgr",
+ [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
+ {
+ ui_base_viewmgr *viewmgr = static_cast<ui_base_viewmgr *>(data);
+ ui_base_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2);
+ ui_base_view *view = viewmgr->get_last_view();
+ if (pview) viewmgr->push_view_finished(pview);
+ if (view) viewmgr->push_view_finished(view);
+ },
+ this);
+
+ //Pop Finished Event
+ elm_layout_signal_callback_add(layout, "pop,finished", "viewmgr",
+ [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
+ {
+ ui_base_viewmgr *viewmgr = static_cast<ui_base_viewmgr *>(data);
+ ui_base_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2);
+ ui_base_view *view = viewmgr->get_last_view();
+ if (pview) viewmgr->pop_view_finished(pview);
+ if (view) viewmgr->pop_view_finished(view);
+ },
+ this);
+
+ this->layout = layout;
+
+ return true;
+}
+
+Elm_Layout *ui_base_viewmgr::set_transition_layout(string transition_style)
+{
+ Elm_Layout *effect_layout = NULL;
+
+ elm_object_part_content_unset(this->get_base(), "pcontent");
+ elm_object_part_content_unset(this->get_base(), "content");
+
+ if (transition_style.compare(this->transition_style) == 0) return this->layout;
+
+ if (effect_map.size()) effect_layout = effect_map.find(transition_style)->second;
+
+ //Conformant content change to current effect layout and change to hide prev layout.
+ Elm_Layout *playout = elm_object_part_content_unset(this->conform, "elm.swallow.content");
+ evas_object_hide(playout);
+
+ if (!effect_layout)
+ {
+ //Create and add effect_layouts in map here.
+ //FIXME: If we have to support many effects, this logic should be changed.
+ effect_map.insert(pair<string, Elm_Layout *>("default", this->layout));
+ this->create_base_layout(this->get_conformant(), transition_style.c_str());
+ effect_map.insert(pair<string, Elm_Layout *>(transition_style, this->layout));
+ }
+ else
+ {
+ elm_object_part_content_set(this->conform, "elm.swallow.content", effect_layout);
+
+ this->layout = effect_layout;
+ }
+
+ this->transition_style = transition_style;
+
+ return this->layout;
+}
+
+void ui_base_viewmgr::active_top_view()
+{
+ elm_object_part_content_unset(this->get_base(), "content");
+
+ ui_base_view *view = this->get_last_view();
+
+ //In case of ui_base_view, it doesn't have any base form. It uses viewmgr base instead.
+ Evas_Object *content;
+ if (view->get_base() == this->get_base())
+ {
+ content = CONVERT_TO_EO(view->get_content());
+ }
+ else
+ {
+ content = CONVERT_TO_EO(view->get_base());
+ }
+
+ elm_object_part_content_set(this->get_base(), "content", content);
+
+ this->set_indicator(view->get_indicator());
+}
+
+//FIXME: How to deal with indicator in other UI framework? Dali? Volt?
+//Is it possible make this interface common?
+bool ui_base_viewmgr::set_indicator(ui_view_indicator indicator)
+{
+ if (this->indicator == indicator) return false;
+ this->indicator = indicator;
+
+ Elm_Win *window = this->get_window();
+ Elm_Conformant *conform = this->get_conformant();
+
+ switch (indicator)
+ {
+ case UI_VIEW_INDICATOR_DEFAULT:
+ elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_OPAQUE);
+ elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+ /* Unset if you set the Indicator BG */
+ evas_object_del(elm_object_part_content_get(conform, "elm.swallow.indicator_bg"));
+ elm_object_signal_emit(conform, "elm,state,indicator,nooverlap", "elm");
+ break;
+ case UI_VIEW_INDICATOR_OPTIMAL:
+ elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+ elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_TRANSPARENT);
+ break;
+ case UI_VIEW_INDICATOR_OVERLAP:
+ elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+ elm_object_signal_emit(conform, "elm,state,indicator,overlap", "elm");
+ break;
+ default:
+ elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_HIDE);
+ break;
+ }
+ return true;
+}
+
+bool ui_base_viewmgr::create_conformant(Elm_Win *win)
+{
+ Elm_Conformant *conform = elm_conformant_add(win);
+ 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);
+
+ this->conform = conform;
+
+ return true;
+}
+
+ui_base_viewmgr::ui_base_viewmgr(const char *pkg, ui_base_key_listener *key_listener)
+ : ui_iface_viewmgr(), key_listener(key_listener), transition_style("default")
+{
+ if (!pkg)
+ {
+ LOGE("Invalid package name");
+ return;
+ }
+ //Window
+ this->win = elm_win_util_standard_add(pkg, pkg);
+
+ if (!this->win)
+ {
+ LOGE("Failed to create a window (%s)", pkg);
+ return;
+ }
+
+ //FIXME: Make a method? to set available rotation degree.
+ //Set window rotation
+ if (elm_win_wm_rotation_supported_get(this->win))
+ {
+ int rots[4] =
+ { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4);
+ }
+ evas_object_smart_callback_add(this->win, "wm,rotation,changed",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ int rot = elm_win_rotation_get(obj);
+
+ ui_base_viewmgr *viewmgr = static_cast<ui_base_viewmgr *>(data);
+ ui_base_view *view = viewmgr->get_last_view();
+ view->on_rotate(rot);
+
+ //FIXME: Change this configurable?
+ if (rot == 0 || rot == 180) view->on_portrait();
+ else view->on_landscape();
+ }
+ , this);
+
+ //Window is requested to delete.
+ evas_object_smart_callback_add(this->win, "delete,request",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ ui_base_viewmgr *viewmgr = static_cast<ui_base_viewmgr*>(data);
+ delete(viewmgr);
+ //FIXME: Window is destroyed. Terminate Application!
+ //ui_app_exit();
+ },
+ this);
+
+ //FIXME: Make conformant configurable?
+ if (!this->create_conformant(this->win))
+ {
+ LOGE("Failed to create a conformant (%s)", pkg);
+ return;
+ }
+
+ if (!this->create_base_layout(this->conform, "default"))
+ {
+ LOGE("Failed to create a base layout (%s)", pkg);
+ return;
+ }
+
+ //Set Indicator properties
+ elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW);
+ elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_OPAQUE);
+
+ elm_win_autodel_set(this->win, EINA_TRUE);
+
+ key_listener->init();
+}
+
+ui_base_viewmgr::ui_base_viewmgr(const char *pkg)
+ : ui_base_viewmgr(pkg, new ui_base_key_listener(this))
+{
+}
+
+ui_base_viewmgr::~ui_base_viewmgr()
+{
+ this->key_listener->term();
+ delete(this->key_listener);
+}
+
+bool ui_base_viewmgr::activate()
+{
+ if (!ui_iface_viewmgr::activate()) return false;
+
+ this->active_top_view();
+
+ //FIXME: Necessary??
+ ui_base_view *view = this->get_last_view();
+ view->on_active();
+
+ evas_object_show(this->win);
+
+ return true;
+}
+
+bool ui_base_viewmgr::deactivate()
+{
+ if (!ui_iface_viewmgr::deactivate()) return false;
+
+ //FIXME: based on the profile, we should app to go behind or terminate.
+ if (true)
+ {
+ ui_base_view *view = this->get_last_view();
+ if (view) view->on_inactive();
+ evas_object_lower(this->win);
+ }
+ else
+ {
+ //FIXME: exit app
+ //ui_app_exit();
+ }
+
+ return true;
+}
+
+bool ui_base_viewmgr::pop_view()
+{
+ if (this->get_view_count() == 1)
+ {
+ this->deactivate();
+ return true;
+ }
+
+ if(!ui_iface_viewmgr::pop_view())
+ {
+ return false;
+ }
+
+ ui_base_view *pview = this->get_view(this->get_view_count() - 2);
+ ui_base_view *view = this->get_last_view();
+
+ //In case, if view doesn't have transition effect
+ if (!strcmp(view->get_transition_style(), "none"))
+ {
+ this->pop_view_finished(pview);
+ this->pop_view_finished(view);
+ this->active_top_view();
+ return true;
+ }
+
+ //Choose an effect layout.
+ Elm_Layout *effect = this->set_transition_layout(view->get_transition_style());
+ if (!effect) {
+ LOGE("invalid effect transition style?! = %s", view->get_transition_style());
+ this->pop_view_finished(pview);
+ this->pop_view_finished(view);
+ this->active_top_view();
+ return true;
+ }
+
+ //Trigger Effects.
+ Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
+ elm_layout_content_set(effect, "content", prv);
+
+ Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
+ elm_layout_content_set(effect, "pcontent", cur);
+
+ elm_layout_signal_emit(effect, "view,pop", "viewmgr");
+
+ this->set_indicator(pview->get_indicator());
+
+ return true;
+}
+
+ui_base_view * ui_base_viewmgr::push_view(ui_base_view *view)
+{
+ ui_iface_viewmgr::push_view(view);
+
+ if (!this->is_activated()) return view;
+
+ //In case, if viewmgr has one view, we skip effect.
+ if (this->get_view_count() == 1) {
+ this->active_top_view();
+ this->push_view_finished(view);
+ return view;
+ }
+
+ ui_base_view *pview = this->get_view(this->get_view_count() - 2);
+
+ //In case, if view doesn't have transition effect
+ if (!strcmp(view->get_transition_style(), "none")) {
+ this->active_top_view();
+ this->push_view_finished(pview);
+ this->push_view_finished(view);
+ return view;
+ }
+
+ //Choose an effect layout.
+ Elm_Layout *effect = this->set_transition_layout(view->get_transition_style());
+ if (!effect) {
+ LOGE("invalid effect transition style?! = %s", view->get_transition_style());
+ this->active_top_view();
+ this->push_view_finished(pview);
+ this->push_view_finished(view);
+ return view;
+ }
+
+ //Trigger Effects.
+ Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
+ elm_layout_content_set(effect, "pcontent", prv);
+
+ Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
+ elm_layout_content_set(effect, "content", cur);
+
+ elm_layout_signal_emit(effect, "view,push", "viewmgr");
+
+ this->set_indicator(view->get_indicator());
+
+ return view;
+}
+
+ui_base_view *ui_base_viewmgr::get_view(unsigned int idx)
+{
+ return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_view(idx));
+}
+
+ui_base_view *ui_base_viewmgr::get_last_view()
+{
+ return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_last_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 "../../include/efl/ui_viewmanager_efl.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-ui_view * ui_controller::get_view()
-{
- ui_iface_view *view = ui_iface_controller::get_view();
- if (!view) return NULL;
- return dynamic_cast<ui_view *>(view);
-}
-
-ui_controller::~ui_controller()
-{
-
-}
+++ /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 "../../include/efl/ui_viewmanager_efl.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-static const char *KEY_BACK = "XF86Back";
-static const char *KEY_BACK2 = "XF86Stop";
-
-ui_key_listener::ui_key_listener(ui_viewmgr *viewmgr)
- : viewmgr(viewmgr), key_grabber(NULL)
-{
-
-}
-
-static void event_proc(ui_key_listener *key_listener, Evas_Event_Key_Down *ev)
-{
- //Only if view manager is activated
- ui_viewmgr *viewmgr = key_listener->get_viewmgr();
- if (!viewmgr->is_activated()) return;
-
- //Get Top View
- ui_view *view = dynamic_cast<ui_view *>(viewmgr->get_last_view());
- if (!view) return;
-
- key_listener->extend_event_proc(view, ev);
-
- if (strcmp(ev->keyname, KEY_BACK) && strcmp(ev->keyname, KEY_BACK2)) return;
-
- view->on_back();
-}
-
-bool ui_key_listener::term()
-{
- evas_object_del(this->key_grabber);
- return true;
-}
-
-bool ui_key_listener::init()
-{
- if (!this->viewmgr)
- {
- LOGE("No view manager??");
- return false;
- }
-
- Evas *e = evas_object_evas_get(this->viewmgr->get_window());
- if (!e)
- {
- LOGE("Failed to get Evas from window");
- return false;
- }
-
- Evas_Object *key_grab_rect = evas_object_rectangle_add(e);
- if (!key_grab_rect)
- {
- LOGE("Failed to create a key grabber rectangle");
- return false;
- }
-
- evas_object_event_callback_add(key_grab_rect, EVAS_CALLBACK_KEY_UP, [](void *data, Evas *e, Evas_Object *obj, void *event_info) -> void
- {
- Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(event_info);
- ui_key_listener *key_listener = static_cast<ui_key_listener *>(data);
- event_proc(key_listener, ev);
- }, this);
-
- if (!evas_object_key_grab(key_grab_rect, KEY_BACK, 0, 0, EINA_FALSE))
- {
- LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK);
- evas_object_del(key_grab_rect);
- return false;
- }
-
- if (!evas_object_key_grab(key_grab_rect, KEY_BACK2, 0, 0, EINA_FALSE))
- {
- LOGE("Failed to grab BACK KEY(%s)\n", KEY_BACK2);
- evas_object_del(key_grab_rect);
- return false;
- }
-
- this->key_grabber = key_grab_rect;
-
- return true;
-}
+++ /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 "../../include/efl/ui_viewmanager_efl.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-#define MY_CONTROLLER dynamic_cast<ui_controller *>(this->get_controller())
-#define MY_VIEWMGR dynamic_cast<ui_viewmgr *>(this->get_viewmgr())
-
-ui_view::ui_view(ui_controller *controller, const char *name)
- : ui_iface_view(controller, name)
-{
-}
-
-ui_view::ui_view(const char *name)
- : ui_view(NULL, name)
-{
-}
-
-ui_view::~ui_view()
-{
-}
-
-Evas_Object *ui_view::set_content(Evas_Object *content)
-{
- T pcontent = ui_iface_view::set_content(CONVERT_TO_T(content));
- return CONVERT_TO_EO(pcontent);
-}
-
-Evas_Object *ui_view::unset_content()
-{
- T pcontent = ui_iface_view::unset_content();
- return static_cast<Evas_Object *>(pcontent);
-}
-
-Evas_Object *ui_view::get_base()
-{
- ui_viewmgr *viewmgr = MY_VIEWMGR;
- if (!viewmgr)
- {
- return NULL;
- }
- return viewmgr->get_base();
-}
-
-void ui_view::unload_content()
-{
- Evas_Object *pcontent = this->set_content(NULL);
- if (pcontent) evas_object_del(pcontent);
-}
-
-Evas_Object *ui_view ::get_parent()
-{
- ui_viewmgr *viewmgr = MY_VIEWMGR;
- if (!viewmgr)
- {
- LOGE("Failed to get a viewmgr");
- return NULL;
- }
- return viewmgr->get_base();
-}
-
-void ui_view::set_indicator(ui_view_indicator indicator)
-{
- if (this->get_indicator() == indicator) return;
-
- ui_iface_view::set_indicator(indicator);
-
- ui_viewmgr *viewmgr = MY_VIEWMGR;
-
- if (!viewmgr->is_activated()) return;
-
- if (dynamic_cast<ui_view *>(viewmgr->get_last_view()) != this) return;
-
- viewmgr->set_indicator(indicator);
-}
-
-void ui_view::on_back()
-{
- if (this->get_controller())
- {
- if (!MY_CONTROLLER->on_back())
- {
- return;
- }
- }
- MY_VIEWMGR->pop_view();
-}
-
-void ui_view::on_rotate(int degree)
-{
- if (this->get_controller())
- {
- MY_CONTROLLER->on_rotate(degree);
- }
-}
-
-void ui_view::on_portrait()
-{
- if (this->get_controller())
- {
- MY_CONTROLLER->on_portrait();
- }
-}
-
-void ui_view::on_landscape()
-{
- if (this->get_controller())
- {
- MY_CONTROLLER->on_landscape();
- }
-}
-void ui_view::set_event_block(bool block)
-{
- ui_iface_view::set_event_block(block);
- evas_object_freeze_events_set(CONVERT_TO_EO(this->get_content()), block);
-}
-
-int ui_view::get_degree()
-{
- ui_viewmgr *viewmgr = MY_VIEWMGR;
- if (!viewmgr)
- {
- LOGE("Failed to get a viewmgr");
- return -1;
- }
- return elm_win_rotation_get(viewmgr->get_window());
-}
+++ /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 "../../include/efl/ui_viewmanager_efl.h"
-
-using namespace efl_viewmgr;
-using namespace viewmgr;
-
-//FIXME: is it correct to define here?
-#define EDJ_PATH "/usr/share/edje/ui-viewmgr/ui-viewmgr.edj"
-
-bool ui_viewmgr::create_base_layout(Elm_Conformant *conform, const char *style)
-{
- char buf[128];
- Elm_Layout *layout = elm_layout_add(conform);
- if (!layout) return false;
-
- //FIXME: Is it C programming style? need to change?
- snprintf(buf, sizeof(buf), "transition/%s", style);
- //default transition layout
- elm_layout_file_set(layout, EDJ_PATH, buf);
- elm_object_content_set(conform, layout);
-
- //Push Finished Event
- elm_layout_signal_callback_add(layout, "push,finished", "viewmgr",
- [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
- {
- ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
- ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2);
- ui_view *view = viewmgr->get_last_view();
- if (pview) viewmgr->push_view_finished(pview);
- if (view) viewmgr->push_view_finished(view);
- },
- this);
-
- //Pop Finished Event
- elm_layout_signal_callback_add(layout, "pop,finished", "viewmgr",
- [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
- {
- ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
- ui_view *pview = viewmgr->get_view(viewmgr->get_view_count() - 2);
- ui_view *view = viewmgr->get_last_view();
- if (pview) viewmgr->pop_view_finished(pview);
- if (view) viewmgr->pop_view_finished(view);
- },
- this);
-
- this->layout = layout;
-
- return true;
-}
-
-Elm_Layout *ui_viewmgr::set_transition_layout(string transition_style)
-{
- Elm_Layout *effect_layout = NULL;
-
- elm_object_part_content_unset(this->get_base(), "pcontent");
- elm_object_part_content_unset(this->get_base(), "content");
-
- if (transition_style.compare(this->transition_style) == 0) return this->layout;
-
- if (effect_map.size()) effect_layout = effect_map.find(transition_style)->second;
-
- //Conformant content change to current effect layout and change to hide prev layout.
- Elm_Layout *playout = elm_object_part_content_unset(this->conform, "elm.swallow.content");
- evas_object_hide(playout);
-
- if (!effect_layout)
- {
- //Create and add effect_layouts in map here.
- //FIXME: If we have to support many effects, this logic should be changed.
- effect_map.insert(pair<string, Elm_Layout *>("default", this->layout));
- this->create_base_layout(this->get_conformant(), transition_style.c_str());
- effect_map.insert(pair<string, Elm_Layout *>(transition_style, this->layout));
- }
- else
- {
- elm_object_part_content_set(this->conform, "elm.swallow.content", effect_layout);
-
- this->layout = effect_layout;
- }
-
- this->transition_style = transition_style;
-
- return this->layout;
-}
-
-void ui_viewmgr::active_top_view()
-{
- elm_object_part_content_unset(this->get_base(), "content");
-
- ui_view *view = this->get_last_view();
-
- //In case of ui_view, it doesn't have any base form. It uses viewmgr base instead.
- Evas_Object *content;
- if (view->get_base() == this->get_base())
- {
- content = CONVERT_TO_EO(view->get_content());
- }
- else
- {
- content = CONVERT_TO_EO(view->get_base());
- }
-
- elm_object_part_content_set(this->get_base(), "content", content);
-
- this->set_indicator(view->get_indicator());
-}
-
-//FIXME: How to deal with indicator in other UI framework? Dali? Volt?
-//Is it possible make this interface common?
-bool ui_viewmgr::set_indicator(ui_view_indicator indicator)
-{
- if (this->indicator == indicator) return false;
- this->indicator = indicator;
-
- Elm_Win *window = this->get_window();
- Elm_Conformant *conform = this->get_conformant();
-
- switch (indicator)
- {
- case UI_VIEW_INDICATOR_DEFAULT:
- elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_OPAQUE);
- elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
- /* Unset if you set the Indicator BG */
- evas_object_del(elm_object_part_content_get(conform, "elm.swallow.indicator_bg"));
- elm_object_signal_emit(conform, "elm,state,indicator,nooverlap", "elm");
- break;
- case UI_VIEW_INDICATOR_OPTIMAL:
- elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(window, ELM_WIN_INDICATOR_TRANSPARENT);
- break;
- case UI_VIEW_INDICATOR_OVERLAP:
- elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
- elm_object_signal_emit(conform, "elm,state,indicator,overlap", "elm");
- break;
- default:
- elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_HIDE);
- break;
- }
- return true;
-}
-
-bool ui_viewmgr::create_conformant(Elm_Win *win)
-{
- Elm_Conformant *conform = elm_conformant_add(win);
- 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);
-
- this->conform = conform;
-
- return true;
-}
-
-ui_viewmgr::ui_viewmgr(const char *pkg, ui_key_listener *key_listener)
- : ui_iface_viewmgr(), key_listener(key_listener), transition_style("default")
-{
- if (!pkg)
- {
- LOGE("Invalid package name");
- return;
- }
- //Window
- this->win = elm_win_util_standard_add(pkg, pkg);
-
- if (!this->win)
- {
- LOGE("Failed to create a window (%s)", pkg);
- return;
- }
-
- //FIXME: Make a method? to set available rotation degree.
- //Set window rotation
- if (elm_win_wm_rotation_supported_get(this->win))
- {
- int rots[4] =
- { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4);
- }
- evas_object_smart_callback_add(this->win, "wm,rotation,changed",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- int rot = elm_win_rotation_get(obj);
-
- ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
- ui_view *view = viewmgr->get_last_view();
- view->on_rotate(rot);
-
- //FIXME: Change this configurable?
- if (rot == 0 || rot == 180) view->on_portrait();
- else view->on_landscape();
- }
- , this);
-
- //Window is requested to delete.
- evas_object_smart_callback_add(this->win, "delete,request",
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- ui_viewmgr *viewmgr = static_cast<ui_viewmgr*>(data);
- delete(viewmgr);
- //FIXME: Window is destroyed. Terminate Application!
- //ui_app_exit();
- },
- this);
-
- //FIXME: Make conformant configurable?
- if (!this->create_conformant(this->win))
- {
- LOGE("Failed to create a conformant (%s)", pkg);
- return;
- }
-
- if (!this->create_base_layout(this->conform, "default"))
- {
- LOGE("Failed to create a base layout (%s)", pkg);
- return;
- }
-
- //Set Indicator properties
- elm_win_indicator_mode_set(this->win, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(this->win, ELM_WIN_INDICATOR_OPAQUE);
-
- elm_win_autodel_set(this->win, EINA_TRUE);
-
- key_listener->init();
-}
-
-ui_viewmgr::ui_viewmgr(const char *pkg)
- : ui_viewmgr(pkg, new ui_key_listener(this))
-{
-}
-
-ui_viewmgr::~ui_viewmgr()
-{
- this->key_listener->term();
- delete(this->key_listener);
-}
-
-bool ui_viewmgr::activate()
-{
- if (!ui_iface_viewmgr::activate()) return false;
-
- this->active_top_view();
-
- //FIXME: Necessary??
- ui_view *view = this->get_last_view();
- view->on_active();
-
- evas_object_show(this->win);
-
- return true;
-}
-
-bool ui_viewmgr::deactivate()
-{
- if (!ui_iface_viewmgr::deactivate()) return false;
-
- //FIXME: based on the profile, we should app to go behind or terminate.
- if (true)
- {
- ui_view *view = this->get_last_view();
- if (view) view->on_inactive();
- evas_object_lower(this->win);
- }
- else
- {
- //FIXME: exit app
- //ui_app_exit();
- }
-
- return true;
-}
-
-bool ui_viewmgr::pop_view()
-{
- if (this->get_view_count() == 1)
- {
- this->deactivate();
- return true;
- }
-
- if(!ui_iface_viewmgr::pop_view())
- {
- return false;
- }
-
- ui_view *pview = this->get_view(this->get_view_count() - 2);
- ui_view *view = this->get_last_view();
-
- //In case, if view doesn't have transition effect
- if (!strcmp(view->get_transition_style(), "none"))
- {
- this->pop_view_finished(pview);
- this->pop_view_finished(view);
- this->active_top_view();
- return true;
- }
-
- //Choose an effect layout.
- Elm_Layout *effect = this->set_transition_layout(view->get_transition_style());
- if (!effect) {
- LOGE("invalid effect transition style?! = %s", view->get_transition_style());
- this->pop_view_finished(pview);
- this->pop_view_finished(view);
- this->active_top_view();
- return true;
- }
-
- //Trigger Effects.
- Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
- elm_layout_content_set(effect, "content", prv);
-
- Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
- elm_layout_content_set(effect, "pcontent", cur);
-
- elm_layout_signal_emit(effect, "view,pop", "viewmgr");
-
- this->set_indicator(pview->get_indicator());
-
- return true;
-}
-
-ui_view * ui_viewmgr::push_view(ui_view *view)
-{
- ui_iface_viewmgr::push_view(view);
-
- if (!this->is_activated()) return view;
-
- //In case, if viewmgr has one view, we skip effect.
- if (this->get_view_count() == 1) {
- this->active_top_view();
- this->push_view_finished(view);
- return view;
- }
-
- ui_view *pview = this->get_view(this->get_view_count() - 2);
-
- //In case, if view doesn't have transition effect
- if (!strcmp(view->get_transition_style(), "none")) {
- this->active_top_view();
- this->push_view_finished(pview);
- this->push_view_finished(view);
- return view;
- }
-
- //Choose an effect layout.
- Elm_Layout *effect = this->set_transition_layout(view->get_transition_style());
- if (!effect) {
- LOGE("invalid effect transition style?! = %s", view->get_transition_style());
- this->active_top_view();
- this->push_view_finished(pview);
- this->push_view_finished(view);
- return view;
- }
-
- //Trigger Effects.
- Evas_Object *prv = CONVERT_TO_EO(this->get_base() == pview->get_base() ? pview->get_content() : pview->get_base());
- elm_layout_content_set(effect, "pcontent", prv);
-
- Evas_Object *cur = CONVERT_TO_EO(this->get_base() == view->get_base() ? view->get_content() : view->get_base());
- elm_layout_content_set(effect, "content", cur);
-
- elm_layout_signal_emit(effect, "view,push", "viewmgr");
-
- this->set_indicator(view->get_indicator());
-
- return view;
-}
-
-ui_view *ui_viewmgr::get_view(unsigned int idx)
-{
- return dynamic_cast<ui_view *>(ui_iface_viewmgr::get_view(idx));
-}
-
-ui_view *ui_viewmgr::get_last_view()
-{
- return dynamic_cast<ui_view *>(ui_iface_viewmgr::get_last_view());
-}