Refactor of HistoryUI::showActionBar function. 39/46039/2
authorMarcin Lapinski <m.lapinski@samsung.com>
Thu, 13 Aug 2015 09:58:37 +0000 (11:58 +0200)
committerMarcin Lapinski <m.lapinski@samsung.com>
Thu, 13 Aug 2015 10:57:20 +0000 (12:57 +0200)
[Issue#]   https://bugs.tizen.org/jira/browse/TT-72
[Problem]  HistoryUI::showActionBar is too complicated. Uses unnecessary
           genlist, with only one item to create action bar. This makes
           code long and unclear as it is not the proper use of genlist.
[Cause]    N/A
[Solution] Use layout instead the genlist to make the code shorter and
           more self-explaining.
[Verify]   1. Browser builds.
           2. Run the browser and check history ui to see if the change
              is not introducing any new issues.

Change-Id: I9b1ad458d7497af9d85741978e844ebb4f918079

services/HistoryUI/HistoryUI.cpp
services/HistoryUI/HistoryUI.h
services/HistoryUI/edc/History.edc

index c562a18fac1c6db4eeef34ea917c93e9a0d0506a..11ab3edcd0a6713dec32d49ac666ddb6efea26d8 100644 (file)
@@ -48,7 +48,7 @@ static std::vector<HistoryItemData*> _history_item_data;
 
 HistoryUI::HistoryUI()
     : m_history_layout(nullptr)
-    , m_genListActionBar(nullptr)
+    , m_actionBar(nullptr)
     , m_genListToday(nullptr)
     , m_itemClassToday(nullptr)
     , m_gengrid(nullptr)
@@ -108,56 +108,25 @@ void HistoryUI::show(Evas_Object* parent)
 void HistoryUI::showActionBar()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    elm_theme_extension_add(nullptr, m_edjFilePath.c_str());
-    m_genListActionBar = elm_genlist_add(m_history_layout);
-    elm_object_part_content_set(m_history_layout, "action_bar_history_genlist", m_genListActionBar);
-    elm_genlist_homogeneous_set(m_genListActionBar, EINA_FALSE);
-    elm_genlist_multi_select_set(m_genListActionBar, EINA_FALSE);
-    elm_genlist_select_mode_set(m_genListActionBar, ELM_OBJECT_SELECT_MODE_ALWAYS);
-    elm_genlist_mode_set(m_genListActionBar, ELM_LIST_LIMIT);
-    elm_genlist_decorate_mode_set(m_genListActionBar, EINA_TRUE);
-    evas_object_size_hint_weight_set(m_genListActionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-    m_itemClassActionBar = elm_genlist_item_class_new();
-    m_itemClassActionBar->item_style = "action_bar_history_items";
-    m_itemClassActionBar->func.text_get = nullptr; // &listTopItemTextGet;
-    m_itemClassActionBar->func.content_get = &_listActionBarContentGet;
-    m_itemClassActionBar->func.state_get = nullptr;
-    m_itemClassActionBar->func.del = nullptr;
-
-    Elm_Object_Item *elmItem = elm_genlist_item_append(m_genListActionBar,    //genlist
-                                                       m_itemClassActionBar,  //item Class
-                                                       this,
-                                                       nullptr,               //parent item
-                                                       ELM_GENLIST_ITEM_NONE, //item type
-                                                       nullptr,
-                                                       nullptr                //data passed to above function
-                                                      );
-}
 
-Evas_Object* HistoryUI::_listActionBarContentGet(void* data, Evas_Object* obj , const char* part)
-{
-    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    if (obj && part) {
-        const char *part_name1 = "clearhistory_click";
-        static const int part_name1_len = strlen(part_name1);
-        const char *part_name2 = "close_click";
-        static const int part_name2_len = strlen(part_name2);
-
-        if (!strncmp(part_name1, part, part_name1_len)) {
-            Evas_Object *clearHistoryButton = elm_button_add(obj);
-            elm_object_style_set(clearHistoryButton, "history_button");
-            evas_object_smart_callback_add(clearHistoryButton, "clicked", HistoryUI::_clearHistory_clicked, data);
-            return clearHistoryButton;
-        }
-        if (!strncmp(part_name2, part, part_name2_len)) {
-            Evas_Object *close_click = elm_button_add(obj);
-            elm_object_style_set(close_click, "history_button");
-            evas_object_smart_callback_add(close_click, "clicked", HistoryUI::_close_clicked_cb, data);
-            return close_click;
-        }
-    }
-    return nullptr;
+    m_actionBar = elm_layout_add(m_history_layout);
+    elm_object_part_content_set(m_history_layout, "action_bar_history", m_actionBar);
+    evas_object_size_hint_weight_set(m_actionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(m_actionBar, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+    elm_layout_file_set(m_actionBar, m_edjFilePath.c_str(), "action_bar");
+
+    Evas_Object *button = elm_button_add(m_actionBar);
+    elm_object_style_set(button, "history_button");
+    evas_object_smart_callback_add(button, "clicked", HistoryUI::_clearHistory_clicked, this);
+    elm_object_part_content_set(m_actionBar, "clearhistory_click", button);
+
+    button = elm_button_add(m_actionBar);
+    elm_object_style_set(button, "history_button");
+    evas_object_smart_callback_add(button, "clicked", HistoryUI::_close_clicked_cb, this);
+    elm_object_part_content_set(m_actionBar, "close_click", button);
+
+    evas_object_show(m_actionBar);
 }
 
 void HistoryUI::_close_clicked_cb(void * data, Evas_Object*, void*)
@@ -310,7 +279,7 @@ void HistoryUI::hide()
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     evas_object_hide(elm_layout_content_get(m_history_layout, "m_genListToday"));
     evas_object_hide(elm_layout_content_get(m_history_layout, "m_gengrid"));
-    evas_object_hide(elm_layout_content_get(m_history_layout, "m_genListActionBar"));
+    evas_object_hide(elm_layout_content_get(m_history_layout, "m_ActionBar"));
     evas_object_hide(m_history_layout);
 }
 
@@ -320,7 +289,6 @@ void HistoryUI::clearItems()
     hide();
     elm_genlist_clear(m_genListToday);
     elm_gengrid_clear(m_gengrid);
-    elm_genlist_clear(m_genListActionBar);
     m_map_history_views.clear();
     _history_item_data.clear();
     setEmptyGengrid(true);
index 4556327dfbf5a4b4f1e84485178ee8c70686a98f..7070ff85b142583fffb8a2a38e52a30dc3f1edf0 100644 (file)
@@ -62,9 +62,8 @@ private:
     void setEmptyGengrid(bool setEmpty);
 
     Evas_Object *m_history_layout;
-    Evas_Object *m_genListActionBar;
+    Evas_Object *m_actionBar;
     Evas_Object *m_genListToday;
-    Elm_Genlist_Item_Class *m_itemClassActionBar;
     Elm_Genlist_Item_Class *m_itemClassToday;
     Evas_Object *m_gengrid;
     Evas_Object *m_parent;
index 4f36aefa3abf13d327e285f949387aa63e1d7a4e..cda9200dd55dbb5aea06f0cdcaa2a6700c4a54fc 100644 (file)
@@ -109,7 +109,7 @@ group {
             image: "web_shadow.png" COMP;
         }
         parts {
-            part { name: "action_bar_history_genlist_bg";
+            part { name: "action_bar_bg";
                 type: RECT;
                 mouse_events: 0;
                 description { state: "default" 0.0;
@@ -136,7 +136,7 @@ group {
                                 max: 1920 976;
                                         color: 231 231 231 255;
                     rel1 {
-                                                relative: 0 1; to: "action_bar_history_genlist_bg";
+                                                relative: 0 1; to: "action_bar_bg";
                     }
                       
                 rel2{
@@ -144,7 +144,7 @@ group {
                     }
                 }
             }
-            part { name: "action_bar_history_genlist";
+            part { name: "action_bar_history";
                 type : SWALLOW;
                 scale: 1;
                 description {
@@ -154,7 +154,7 @@ group {
                     max: 1920 104;
                     align: 0.0 0.0;
                     fixed: 0 0;
-                    rel1 { relative: 0.0 0.0; to: "action_bar_history_genlist_bg";}
+                    rel1 { relative: 0.0 0.0; to: "action_bar_bg";}
                     rel2 { relative: 1.0 1.0; }
                 }
                 description {
@@ -200,7 +200,6 @@ group {
         min: 500 600;
         max: 500 600;
         data.item: "texts" "history_url_text";
-        //data.item: "contents" "clearhistory_click";
         parts{
             part {
                 name: "bg_clipper";
@@ -254,10 +253,9 @@ group {
            }
 
 }
-  group { name: "elm/genlist/item/action_bar_history_items/default";
+  group { name: "action_bar";
         min: 1920 104;
         max: 1920 104;
-        data.item: "texts" "clearhistory_text";
         data.item: "contents" "clearhistory_click close_click";
         parts{
             part {