support view indicator mode. 02/59802/3
authorHermet Park <hermet@hermet.pe.kr>
Thu, 18 Feb 2016 16:48:01 +0000 (01:48 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Thu, 18 Feb 2016 17:12:37 +0000 (02:12 +0900)
Change-Id: Ic64dd80103f9b3ca2d19b86a435251b46749f3e2

12 files changed:
src/efl/ui_view.cpp
src/efl/ui_view.h
src/efl/ui_viewmgr.cpp
src/efl/ui_viewmgr.h
src/interface/ui_view_base.cpp
src/interface/ui_view_base.h
src/interface/ui_viewmgr.h
src/page1_controller.h
src/page2_controller.h
src/page3_controller.h
src/page4_controller.h
src/page5_controller.h

index 635e9fd..11b64fd 100644 (file)
@@ -64,3 +64,18 @@ Evas_Object *ui_view ::get_parent()
        ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->get_viewmgr());
        return viewmgr->get_base();
 }
+
+void ui_view::set_indicator(ui_view_indicator indicator)
+{
+       if (this->get_indicator() == indicator) return;
+
+       ui_view_base::set_indicator(indicator);
+
+       ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(this->get_viewmgr());
+
+       if (!viewmgr->is_activated()) return;
+
+       if (dynamic_cast<ui_view *>(viewmgr->get_last_view()) != this) return;
+
+       viewmgr->set_indicator(indicator);
+}
index 3a7c6ee..b3d87b4 100644 (file)
@@ -36,6 +36,8 @@ public:
        virtual Evas_Object *set_content(Evas_Object *content);
        virtual Evas_Object *get_base();
 
+       void set_indicator(ui_view_indicator indicator);
+
 protected:
        virtual void load();
        virtual void unload();
index e85f4fb..16598d9 100644 (file)
 
 using namespace efl;
 
-void
-win_delete_request_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+bool ui_viewmgr::set_indicator(ui_view_indicator indicator)
 {
-       ui_viewmgr *viewmgr = static_cast<ui_viewmgr*>(data);
-       delete(viewmgr);
+       if (this->indicator == indicator) return false;
+       this->indicator = indicator;
+
+       Evas_Object *window = this->get_window();
+       Evas_Object *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(Evas_Object *win)
+bool ui_viewmgr::create_conformant(Evas_Object *win)
 {
        Evas_Object *conform = elm_conformant_add(win);
        if (!conform) return false;
@@ -41,8 +65,7 @@ ui_viewmgr::create_conformant(Evas_Object *win)
        return true;
 }
 
-bool
-ui_viewmgr::create_base_layout(Evas_Object *conform)
+bool ui_viewmgr::create_base_layout(Evas_Object *conform)
 {
        Evas_Object *layout = elm_layout_add(conform);
        if (!layout) return false;
@@ -86,7 +109,6 @@ ui_viewmgr::ui_viewmgr(const char *pkg)
                        {
                                ui_viewmgr *viewmgr = static_cast<ui_viewmgr*>(data);
                                delete(viewmgr);
-
                                //FIXME: Window is destroyed. Terminate Application!
                                //ui_app_exit();
                        },
@@ -108,6 +130,7 @@ ui_viewmgr::ui_viewmgr(const char *pkg)
        //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);
 }
 
@@ -117,7 +140,7 @@ ui_viewmgr::~ui_viewmgr()
 
 bool ui_viewmgr::activate()
 {
-       ui_viewmgr_base :: activate();
+       ui_viewmgr_base::activate();
 
        elm_object_part_content_unset(this->get_base(), "elm.swallow.content");
 
@@ -134,6 +157,8 @@ bool ui_viewmgr::activate()
                elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
+       this->set_indicator(view->get_indicator());
+
        evas_object_show(this->win);
 
        return true;
@@ -141,7 +166,7 @@ bool ui_viewmgr::activate()
 
 bool ui_viewmgr::deactivate()
 {
-       ui_viewmgr_base ::deactivate();
+       ui_viewmgr_base::deactivate();
 
        //FIXME: based on the profile, we should app to go behind or terminate.
        if (true)
@@ -177,6 +202,8 @@ bool ui_viewmgr::pop_view()
                elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
+       this->set_indicator(view->get_indicator());
+
        return true;
 }
 
@@ -198,9 +225,10 @@ ui_viewmgr::push_view(ui_view *view)
        }
        else
        {
-               LOGE("view->base = %p", view->get_base());
                elm_object_part_content_set(this->get_base(), "elm.swallow.content", CONVERT_TO_EO(view->get_base()));
        }
 
+       this->set_indicator(view->get_indicator());
+
        return view;
 }
index 06aa65b..5da92e8 100644 (file)
@@ -33,9 +33,11 @@ private:
        Evas_Object *win;
        Evas_Object *conform;
        Evas_Object *layout;
+       ui_view_indicator indicator;
 
        bool create_conformant(Evas_Object *win);
        bool create_base_layout(Evas_Object *conform);
+       bool set_indicator(ui_view_indicator indicator);
 
 protected:
        Evas_Object *get_base()
index c5a8df4..f708ec9 100644 (file)
@@ -82,7 +82,7 @@ void ui_view_base::destroy()
 
 ui_view_base::ui_view_base(T content, ui_controller_base *controller, const char *name)
                : content(content), controller(controller), name(string(name ? name : "")), style(string("")), viewmgr(NULL), state(UI_VIEW_STATE_LOAD),
-                 event_block(false), removable_content(true)
+                 indicator(UI_VIEW_INDICATOR_DEFAULT), event_block(false), removable_content(true)
 {
        if (!content) this->state = UI_VIEW_STATE_UNLOAD;
        else this->state = UI_VIEW_STATE_LOAD;
@@ -135,3 +135,8 @@ void ui_view_base::set_removable_content(bool removable)
 
        //FIXME: If this api is called on unload state? should we remove content right now?
 }
+
+void ui_view_base::set_indicator(ui_view_indicator indicator)
+{
+       this->indicator = indicator;
+}
index 8c9abfd..08caea0 100644 (file)
@@ -62,6 +62,7 @@ private:
        std::string style;                      ///< View style name.
        ui_viewmgr_base *viewmgr;               ///< Viewmgr which this view belongs to.
        ui_view_state state;                    ///< View state
+       ui_view_indicator indicator;            ///< View indicator mode
        bool event_block;                       ///< State of event block.
        bool removable_content;                 ///< When this value is true, view removes it's content internally on unload state.
 
@@ -215,28 +216,41 @@ public:
         */
        void set_removable_content(bool removable);
 
+       void set_indicator(ui_view_indicator indicator);
+
        /// Return a style name of this view.
        const char *get_style()
        {
                return this->style.c_str();
        }
 
-       /// Return a content instance of this view.
+       const char *get_name()
+       {
+               return this->name.c_str();
+       }
+
+       /// Return the content instance of this view.
        T get_content()
        {
                return this->content;
        }
 
-       /// Return a state of this view.
+       /// Return the state of this view.
        ui_view_state get_state()
        {
                return this->state;
        }
-       /// Return a state of removeable content.
+       /// Return the state of removeable content.
        bool get_removable_content()
        {
                return this->removable_content;
        }
+
+       /// Return the indicator mode of this view.
+       ui_view_indicator get_indicator()
+       {
+               return this->indicator;
+       }
 };
 
 #endif /* UI_VIEW_BASE_H_ */
index 512525f..cc56ba2 100644 (file)
@@ -14,6 +14,9 @@
  *  limitations under the License.
  *
  */
+#ifndef UI_VIEWMGR_H_
+#define UI_VIEWMGR_H_
+
 #include <app.h>
 #include <dlog.h>
 
 #endif
 #define LOG_TAG "VIEWMGR"
 
+enum ui_view_indicator
+{
+       UI_VIEW_INDICATOR_DEFAULT = 0,
+       UI_VIEW_INDICATOR_OPTIMAL,
+       UI_VIEW_INDICATOR_OVERLAP,
+       UI_VIEW_INDICATOR_HIDE,
+       UI_VIEW_INDICATOR_LAST
+};
+
 #include "ui_viewmgr_base.h"
 #include "ui_view_base.h"
 #include "ui_controller_base.h"
+
+
+#endif /* UI_VIEWMGR_H */
index 031eed6..b34d122 100644 (file)
@@ -23,6 +23,8 @@ public:
        page1_controller(appdata_s *ad)
                        : ad(ad)
        {
+               /* ui_basic_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
                ad->viewmgr->push_view(new ui_basic_view(this, "page1"));
        }
        ~page1_controller()
@@ -33,23 +35,23 @@ public:
        {
                //Initialize contents.
 
-               ui_basic_view *view = dynamic_cast<ui_basic_view *>(ui_controller::get_view());
+               ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
 
                //Create a main content.
                Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1",
-                               //Prev Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               ad->viewmgr->deactivate();
-                       },
-                       //Next Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               page2(ad);
-                       },
-                       this->ad);
+                               //Prev Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       ad->viewmgr->deactivate();
+                               },
+                               //Next Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       page2(ad);
+                               },
+                               this->ad);
 
                view->set_content(content, "Title");
        }
index 06e3f94..5e71b8d 100644 (file)
@@ -23,8 +23,11 @@ public:
        page2_controller(appdata_s *ad)
                        : ad(ad)
        {
+               /* ui_basic_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
                ad->viewmgr->push_view(new ui_basic_view(this, "page2"));
        }
+
        ~page2_controller()
        {
        }
@@ -32,18 +35,17 @@ public:
        void load()
        {
                //Initialize contents.
-
-               ui_basic_view *view = dynamic_cast<ui_basic_view *>(ui_controller::get_view());
+               ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
 
                //Create a main content.
                Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 2",
-                               //Prev Button
+                               //Prev Button Callback
                        [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
                                appdata_s *ad = static_cast<appdata_s *>(data);
                                ad->viewmgr->pop_view();
                        },
-                       //Next Button
+                       //Next Button Callback
                        [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
                                appdata_s *ad = static_cast<appdata_s *>(data);
index 2d1dd0f..67a6070 100644 (file)
@@ -23,6 +23,8 @@ public:
        page3_controller(appdata_s *ad)
                        : ad(ad)
        {
+               /* ui_basic_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
                ad->viewmgr->push_view(new ui_basic_view(this, "page3"));
        }
 
@@ -38,19 +40,19 @@ public:
 
                //Create a main content.
                Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 3",
-                               //Prev Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               ad->viewmgr->pop_view();
-                       },
-                       //Next Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               page4(ad);
-                       },
-                       this->ad);
+                               //Prev Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       ad->viewmgr->pop_view();
+                               },
+                               //Next Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       page4(ad);
+                               },
+                               this->ad);
 
                //Arguments: content, title, subtitle, title left button, title right button
                view->set_content(content, "Title", "Subtitle", NULL, NULL);
index 434b394..6e97a38 100644 (file)
@@ -23,6 +23,8 @@ public:
        page4_controller(appdata_s *ad)
                        : ad(ad)
        {
+               /* ui_basic_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
                ad->viewmgr->push_view(new ui_basic_view(this, "page4"));
        }
 
@@ -38,18 +40,19 @@ public:
 
                //Create a main content.
                Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 4",
-                               //Prev Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               ad->viewmgr->pop_view();
-                       },
-                       //Next Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               page5(ad);
-                       }, this->ad);
+                               //Prev Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       ad->viewmgr->pop_view();
+                               },
+                               //Next Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       page5(ad);
+                               },
+                               this->ad);
 
                //Arguments: content, title
                view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
index a12ec14..744de44 100644 (file)
@@ -24,7 +24,9 @@ public:
                        : ad(ad)
        {
                //No basic form.
-               ad->viewmgr->push_view(new ui_view(this, "page5"));
+               /* ui_view(controller, identity name).
+                  Later, you could get the identity name using view->get_name(); */
+               ui_view *view = ad->viewmgr->push_view(new ui_view(this, "page5"));
        }
 
        ~page5_controller()
@@ -38,21 +40,23 @@ public:
                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 5<br>(No Title View)",
-                               //Prev Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               ad->viewmgr->pop_view();
-                       },
-                       //Next Button
-                       [](void *data, Evas_Object *obj, void *event_info) -> void
-                       {
-                               appdata_s *ad = static_cast<appdata_s *>(data);
-                               ad->viewmgr->deactivate();
-                       }, this->ad);
+               Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 5<br>(Full View)",
+                               //Prev Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       ad->viewmgr->pop_view();
+                               },
+                               //Next Button Callback
+                               [](void *data, Evas_Object *obj, void *event_info) -> void
+                               {
+                                       appdata_s *ad = static_cast<appdata_s *>(data);
+                                       ad->viewmgr->deactivate();
+                               },
+                               this->ad);
 
                view->set_content(content);
+               view->set_indicator(UI_VIEW_INDICATOR_HIDE);
        }
 };