Implement inset_view_before/after(). 90/63790/2
authorWoochan Lee <wc0917.lee@samsung.com>
Sun, 27 Mar 2016 07:33:13 +0000 (16:33 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Sun, 27 Mar 2016 07:34:16 +0000 (16:34 +0900)
Change-Id: I3af88a93c32efcaf3d82bdf9bb52d68923abfe47

src/include/efl/ui_base_viewmgr.h
src/lib/efl/ui_base_viewmgr.cpp
src/lib/interface/ui_iface_viewmgr.cpp

index 30afc61..34eb042 100644 (file)
@@ -180,6 +180,26 @@ public:
         */
        virtual bool pop_view();
 
+       /**
+        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right before of the given view, @before.
+        *
+        *  @param view A view to insert in the viewmgr view list.
+        *  @param before A view that will be just inserted after @p view. If you pass @c NULL, @p view will be inserted at the front of the view list.
+        *
+        *  @return @c true on success or @c false otherwise.
+        */
+       virtual bool insert_view_before(ui_base_view *view, ui_base_view *before);
+
+       /**
+        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @p view right after of the given view, @after.
+        *
+        *  @param view A view to insert in the viewmgr view list.
+        *  @param after A view that will be just inserted before the @p view. If you pass @c NULL, @p view will be inserted at the end of the view list.
+        *
+        *  @return @c true on success or @c false otherwise.
+        */
+       virtual bool insert_view_after(ui_base_view *view, ui_base_view *after);
+
        /** @brief Get a window object of viewmgr.
         */
        Elm_Win *get_window()
index 530be66..17498d1 100644 (file)
@@ -408,6 +408,20 @@ ui_base_view * ui_base_viewmgr::push_view(ui_base_view *view)
        return view;
 }
 
+bool ui_base_viewmgr::insert_view_before(ui_base_view *view, ui_base_view *before)
+{
+       ui_iface_viewmgr::insert_view_before(view, before);
+
+       return true;
+}
+
+bool ui_base_viewmgr::insert_view_after(ui_base_view *view, ui_base_view *after)
+{
+       ui_iface_viewmgr::insert_view_after(view, after);
+
+       return true;
+}
+
 ui_base_view *ui_base_viewmgr::get_view(unsigned int idx)
 {
        return dynamic_cast<ui_base_view *>(ui_iface_viewmgr::get_view(idx));
index 4868849..e09976e 100644 (file)
@@ -196,13 +196,80 @@ bool ui_iface_viewmgr::pop_view()
 
 bool ui_iface_viewmgr::insert_view_before(ui_iface_view *view, ui_iface_view *before)
 {
-       //TODO: ...
+       typename std::list<ui_iface_view*>::iterator it;
+
+       if (!view)
+       {
+               LOGE("invalid view argument. view(NULL)");
+               return false;
+       }
+
+       if (!this->connect_view(view))
+       {
+               LOGE("connect view failed");
+               return false;
+       }
+
+       if (this->view_list.size() > 0)
+       {
+               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
+               {
+                       if (before == *it)
+                       {
+                               this->view_list.insert(it, view);
+
+                               return true;
+                       }
+               }
+       }
+
+       //If there is no matching before view with current list.
+       //also in case of before is NULL.
+       this->push_view(view);
+
        return true;
 }
 
 bool ui_iface_viewmgr::insert_view_after(ui_iface_view *view, ui_iface_view *after)
 {
-       //TODO: ...
+       typename std::list<ui_iface_view*>::iterator it;
+
+       if (!view)
+       {
+               LOGE("invalid view argument. view(NULL)");
+               return false;
+       }
+
+       if (!this->connect_view(view))
+       {
+               LOGE("connect view failed");
+               return false;
+       }
+
+       ui_iface_view *bview;
+
+       if (this->view_list.size() > 0)
+       {
+               for (it = this->view_list.begin(); it != this->view_list.end(); it++)
+               {
+                       if (after == *it)
+                       {
+                               //If the after is a last item of list.
+                               //view has to push now.
+                               if (it == this->view_list.end())
+                                       this->push_view(view);
+                               else
+                                       this->view_list.insert(++it, view);
+
+                               return true;
+                       }
+               }
+       }
+
+       //If there is no matching after view with current list.
+       //also in case of after is NULL.
+       this->push_view(view);
+
        return true;
 }