From 43075620683a12df9580d2446e11684c875f48b2 Mon Sep 17 00:00:00 2001 From: "k.lis2" Date: Thu, 6 Aug 2015 18:10:28 +0200 Subject: [PATCH 01/16] Remove ewk_context_favicon_database_directory_set internal API call [Issue#] https://bugs.tizen.org/jira/browse/TT-70 [Problem] ewk_context_favicon_database_directory_set needs to be removed [Cause] Internal API shouldn't be used in this project [Solution] Remove the call to this function [Verify] Perform basic sanity check. Change-Id: I67bd61e1c92704c43d833f2f9a1ecc862d03130a --- services/BookmarkService/BookmarkService.cpp | 4 +++- services/SimpleUI/SimpleUI.cpp | 2 ++ services/SimpleUI/SimpleUI.h | 4 ++++ services/WebKitEngineService/WebView.cpp | 6 ++++-- services/WebKitEngineService/WebView.h | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/services/BookmarkService/BookmarkService.cpp b/services/BookmarkService/BookmarkService.cpp index 99b14e2..fd67099 100644 --- a/services/BookmarkService/BookmarkService.cpp +++ b/services/BookmarkService/BookmarkService.cpp @@ -177,8 +177,10 @@ std::vector > BookmarkService::getBookmarks() { bp_bookmark_info_fmt bookmark_info; bp_bookmark_adaptor_get_easy_all(ids[i], &bookmark_info); + std::string url = bookmark_info.url ? bookmark_info.url : ""; + std::string title = bookmark_info.title ? bookmark_info.title : ""; - std::shared_ptr bookmark = std::make_shared(std::string(bookmark_info.url),std::string(bookmark_info.title), std::string(""), 0); + std::shared_ptr bookmark = std::make_shared(url,title, std::string(""), 0); std::shared_ptr bi = std::make_shared(); bi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 590bf6f..6798e9c 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -69,6 +69,7 @@ SimpleUI::SimpleUI(/*Evas_Object *window*/) , items_vector() , m_networkErrorPopup(0) , m_wvIMEStatus(false) + , m_ewkContext(ewk_context_new()) { elm_init(static_cast(NULL), static_cast(NULL)); Evas_Object *main_window = elm_win_util_standard_add("browserApp", "browserApp"); @@ -83,6 +84,7 @@ SimpleUI::~SimpleUI() { m_sessionService->getStorage()->deleteSession(m_currentSession); /// \todo Auto-generated destructor stub evas_object_del(m_window.get()); + ewk_context_delete(m_ewkContext); } void SimpleUI::destroyUI() diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 5c5f736..676c881 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -266,6 +266,10 @@ private: int m_tabLimit; int m_favoritesLimit; bool m_wvIMEStatus; + // This context object is used to implicitly init internal ewk data used by opengl to create the first and + // consecutive webviews in the application, otherwise we would encounter a crash after creating + // the first web view + Ewk_Context *m_ewkContext; std::vector> items_vector; std::unique_ptr m_netErrorHandler; diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 5f9aa82..acf79a3 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -57,6 +57,7 @@ WebView::WebView(Evas_Object * obj, TabId tabId) : m_parent(obj) , m_tabId(tabId) , m_ewkView(NULL) + , m_ewkContext(ewk_context_new()) , m_isLoading(false) , m_loadError(false) { @@ -70,12 +71,14 @@ WebView::~WebView() if (m_ewkView) { unregisterCallbacks(); } + + ewk_context_delete(m_ewkContext); } void WebView::init(Evas_Object * opener) { #if defined(USE_EWEBKIT) - m_ewkView = ewk_view_add(evas_object_evas_get(m_parent)); + m_ewkView = ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext); evas_object_data_set(m_ewkView, "_container", this); BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, this); @@ -99,7 +102,6 @@ void WebView::init(Evas_Object * opener) if (context) { ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); - ewk_context_favicon_database_directory_set(context, (webkit_path + std::string("/favicon")).c_str()); } } diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index a4e40c5..9dd26dc 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -178,6 +178,8 @@ private: Evas_Object * m_parent; TabId m_tabId; Evas_Object * m_ewkView; + // ewk context of this web view + Ewk_Context * m_ewkContext; std::string m_title; std::shared_ptr faviconImage; bool m_isLoading; -- 2.7.4 From 4d76a2e6a9a867287c6a3ec5cadb0a7879417b68 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Fri, 7 Aug 2015 11:28:57 +0200 Subject: [PATCH 02/16] Minor style fixes and cleanup in BookmarkManagerUI [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] Wrong indenting, wrong casting method, unused variable [Cause] n/a [Solution] Reformat code, fix casting and remove unused variable [Verify] Check that there are no build problems caused by this change Change-Id: Ic5d8b7b3d24322aa93111d2ab195ccceb5cca6e0 --- services/BookmarkManagerUI/AddNewFolderPopup.cpp | 9 ++++++--- services/BookmarkManagerUI/AddNewFolderPopup.h | 8 ++++++-- services/BookmarkManagerUI/BookmarkManagerUI.cpp | 21 +++++++++------------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/services/BookmarkManagerUI/AddNewFolderPopup.cpp b/services/BookmarkManagerUI/AddNewFolderPopup.cpp index 10b6114..941e16a 100644 --- a/services/BookmarkManagerUI/AddNewFolderPopup.cpp +++ b/services/BookmarkManagerUI/AddNewFolderPopup.cpp @@ -25,9 +25,12 @@ AddNewFolderPopup::AddNewFolderPopup(Evas_Object* main_layout) : { } -AddNewFolderPopup::AddNewFolderPopup(Evas_Object *main_layout, Evas_Object *content, const std::string& message, - const std::string& title, const std::string& okButtonText, - const std::string& cancelButtonText) : +AddNewFolderPopup::AddNewFolderPopup(Evas_Object *main_layout + , Evas_Object *content + , const std::string& message + , const std::string& title + , const std::string& okButtonText + , const std::string& cancelButtonText) : m_popup(nullptr), m_cancel_button(nullptr), m_editfield_entry(nullptr), diff --git a/services/BookmarkManagerUI/AddNewFolderPopup.h b/services/BookmarkManagerUI/AddNewFolderPopup.h index 4f2d6a5..5923be4 100644 --- a/services/BookmarkManagerUI/AddNewFolderPopup.h +++ b/services/BookmarkManagerUI/AddNewFolderPopup.h @@ -19,8 +19,12 @@ class AddNewFolderPopup{ public: AddNewFolderPopup(Evas_Object *main_layout); - AddNewFolderPopup(Evas_Object *main_layout, Evas_Object *content, const std::string& message, - const std::string& title, const std::string& okButtonText, const std::string& cancelButtonText); + AddNewFolderPopup(Evas_Object *main_layout + , Evas_Object *content + , const std::string& message + , const std::string& title + , const std::string& okButtonText + , const std::string& cancelButtonText); /* * These setters should be called before showing popup. diff --git a/services/BookmarkManagerUI/BookmarkManagerUI.cpp b/services/BookmarkManagerUI/BookmarkManagerUI.cpp index a44f7bd..9a0be45 100644 --- a/services/BookmarkManagerUI/BookmarkManagerUI.cpp +++ b/services/BookmarkManagerUI/BookmarkManagerUI.cpp @@ -127,9 +127,6 @@ void BookmarkManagerUI::showTopContent() elm_genlist_decorate_mode_set(m_genList, EINA_TRUE); evas_object_size_hint_weight_set(m_genList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - /*evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, nullptr);*/ - m_itemClass = elm_genlist_item_class_new(); m_itemClass->item_style = "topContent"; m_itemClass->func.text_get = &listItemTextGet; @@ -140,12 +137,12 @@ void BookmarkManagerUI::showTopContent() ItemData * id = new ItemData; id->m_bookmarkManager = this; Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist - m_itemClass, //item Class + m_itemClass, //item Class id, - nullptr, //parent item - ELM_GENLIST_ITEM_NONE, //item type + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type nullptr, - nullptr //data passed to above function + nullptr //data passed to above function ); id->e_item = elmItem; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -352,7 +349,7 @@ char* BookmarkManagerUI::_grid_text_get(void *data, Evas_Object *, const char *p const char *part_name2 = "page_url"; static const int part_name1_len = strlen(part_name1); static const int part_name2_len = strlen(part_name2); - ItemData * id = static_cast(data); + if (!strncmp(part_name1, part, part_name1_len) && !itemData->item->getTittle().empty()) { return strdup(itemData->item->getTittle().c_str()); @@ -479,7 +476,7 @@ void BookmarkManagerUI::_thumbSelected(void * data, Evas_Object *, void *) { if (data != nullptr) { - BookmarkFolderItemData * itemData = reinterpret_cast(data); + BookmarkFolderItemData * itemData = static_cast(data); BROWSER_LOGD("Folder ID: %d" , itemData->item->getId()); itemData->bookmarkManagerUI->set_folder(itemData->item->getTittle().c_str()); itemData->bookmarkManagerUI->bookmarkFolderClicked(itemData->item->getId()); @@ -493,7 +490,7 @@ void BookmarkManagerUI::_bookmark_thumbSelected(void * data, Evas_Object *, void #if 0 if (data != nullptr) { - HistoryItemData * itemData = reinterpret_cast(data); + HistoryItemData * itemData = static_cast(data); itemData->bookmarkManagerUI->bookmarkClicked(itemData->item); } #endif @@ -524,7 +521,7 @@ void BookmarkManagerUI::focusItem(void*, Evas_Object*, void* event_info) BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (event_info != nullptr) { - Elm_Object_Item *item = reinterpret_cast(event_info); + Elm_Object_Item *item = static_cast(event_info); elm_object_item_signal_emit( item, "mouse,in", "over2"); // selected manually @@ -537,7 +534,7 @@ void BookmarkManagerUI::unFocusItem(void*, Evas_Object*, void* event_info) BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (event_info != nullptr) { - Elm_Object_Item *item = reinterpret_cast(event_info); + Elm_Object_Item *item = static_cast(event_info); elm_object_item_signal_emit( item, "mouse,out", "over2"); // unselected manually -- 2.7.4 From cf77c87d050d6f9e22da1fa5f0c861f890b49a17 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Fri, 7 Aug 2015 12:01:38 +0200 Subject: [PATCH 03/16] Refactored MoreMenuUI service [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] Lots of style fixes, several fixes for build warnings [Cause] n/a [Solution] Reformat code, fix casting and remove unused variables [Verify] 1. Check that there are no build problems caused by this change 2. Run the browser and explore the More Menu to see if nothing's broken List of changes: * tabs -> spaces * proper indentation * other minor style fixes * removing unused variables' declarations * renaming a few class members to better express their use * replacing reinterpret_Cast with static_cast where appropriate * adding null-checks in callback functions * replacing shared_ptr copy-assignments with make_shared Change-Id: I6a65bbcf9efaef42db955c689ba81673cb12e1fa --- services/MoreMenuUI/AddBookmarkPopup.cpp | 114 +++---- services/MoreMenuUI/AddBookmarkPopup.h | 4 +- services/MoreMenuUI/MoreMenuUI.cpp | 520 +++++++++++++++++-------------- services/MoreMenuUI/MoreMenuUI.h | 15 +- services/MoreMenuUI/NewFolderPopup.cpp | 33 +- services/MoreMenuUI/NewFolderPopup.h | 7 +- 6 files changed, 384 insertions(+), 309 deletions(-) diff --git a/services/MoreMenuUI/AddBookmarkPopup.cpp b/services/MoreMenuUI/AddBookmarkPopup.cpp index fea26c4..a455589 100644 --- a/services/MoreMenuUI/AddBookmarkPopup.cpp +++ b/services/MoreMenuUI/AddBookmarkPopup.cpp @@ -34,9 +34,9 @@ typedef struct _BookmarkFolderItemData AddBookmarkPopup::AddBookmarkPopup(Evas_Object* main_layout): + m_mainLayout(main_layout), m_popup(nullptr), m_gengrid(nullptr), - m_mainLayout(main_layout), m_itemClass(nullptr) { } @@ -47,15 +47,15 @@ AddBookmarkPopup::~AddBookmarkPopup () void AddBookmarkPopup::show() { BROWSER_LOGD("[%s],", __func__); - bm_edjFilePath = EDJE_DIR; - bm_edjFilePath.append("MoreMenuUI/AddBookmarkPopup.edj"); - elm_theme_extension_add(0, bm_edjFilePath.c_str()); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("MoreMenuUI/AddBookmarkPopup.edj"); + elm_theme_extension_add(0, m_edjFilePath.c_str()); m_popup = elm_layout_add(m_mainLayout); if (m_popup != nullptr) { elm_object_signal_emit(m_mainLayout, "elm,state,show", "elm"); - elm_layout_file_set(m_popup, bm_edjFilePath.c_str(), "bookmark_popup"); - BROWSER_LOGI("PATH: %s", bm_edjFilePath.c_str()); + elm_layout_file_set(m_popup, m_edjFilePath.c_str(), "bookmark_popup"); + BROWSER_LOGI("PATH: %s", m_edjFilePath.c_str()); m_gengrid = elm_gengrid_add(m_popup); @@ -175,7 +175,7 @@ char* AddBookmarkPopup::_grid_text_get(void *data, Evas_Object *, const char *pa static const char* part_name = "page_title"; static const int part_len = strlen(part_name); - BookmarkFolderItemData *itemData = reinterpret_cast(data); + BookmarkFolderItemData *itemData = static_cast(data); if (!strncmp(part, part_name, part_len)) { if(itemData->item) return strdup(itemData->item->getTittle().c_str()); @@ -186,17 +186,9 @@ char* AddBookmarkPopup::_grid_text_get(void *data, Evas_Object *, const char *pa const char* AddBookmarkPopup::getImageFileNameForType(int index, bool focused) { - static char* file_name = ""; - if (index == 1) - { - if (focused) - { - file_name = "btn_bar_new_foc.png"; - } - else - { - file_name = "btn_bar_new_nor.png"; - } + static const char *file_name = ""; + if (index == 1) { + file_name = focused ? "btn_bar_new_foc.png" : "btn_bar_new_nor.png"; } return file_name; } @@ -206,7 +198,7 @@ Evas_Object * AddBookmarkPopup::_grid_content_get(void *data, Evas_Object *obj, BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); if ((data != nullptr) && (obj != nullptr) && (part != nullptr)) { - BookmarkFolderItemData *itemData = reinterpret_cast(data); + BookmarkFolderItemData *itemData = static_cast(data); static const char* part1_name = "elm.thumbnail"; static const char* part2_name = "elm.thumbButton"; @@ -220,7 +212,7 @@ Evas_Object * AddBookmarkPopup::_grid_content_get(void *data, Evas_Object *obj, BROWSER_LOGD("%s:%d %s file=%s", __FILE__, __LINE__, __func__, file_name); if (thumb_nail != nullptr) { - elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->bm_edjFilePath.c_str(), file_name); + elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->m_edjFilePath.c_str(), file_name); } return thumb_nail; } @@ -251,7 +243,7 @@ void AddBookmarkPopup::__cb_mouse_in(void * data, Evas *, Evas_Object *obj, void if ((data != nullptr) && (obj != nullptr)) { elm_object_focus_set(obj, EINA_TRUE); - BookmarkFolderItemData *itemData = reinterpret_cast(data); + BookmarkFolderItemData *itemData = static_cast(data); const char* file_name = getImageFileNameForType(itemData->index, true); Elm_Object_Item * selected = itemData->addBookmarkPopup->m_map_bookmark_folder_views["new_folder_button"]; @@ -260,46 +252,54 @@ void AddBookmarkPopup::__cb_mouse_in(void * data, Evas *, Evas_Object *obj, void Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "elm.thumbnail"); if (thumb_nail != nullptr) { - elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->bm_edjFilePath.c_str(), file_name); + elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->m_edjFilePath.c_str(), file_name); } } } } -void AddBookmarkPopup::__cb_mouse_out(void * data, Evas *e, Evas_Object *obj, void *event_info) +void AddBookmarkPopup::__cb_mouse_out(void * data, Evas *, Evas_Object *obj, void* ) { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - BookmarkFolderItemData *itemData = reinterpret_cast(data); - elm_object_focus_set(obj, EINA_FALSE); - const char* file_name = getImageFileNameForType(itemData->index, false); - Elm_Object_Item * selected = itemData->addBookmarkPopup->m_map_bookmark_folder_views["new_folder_button"]; - Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "elm.thumbnail"); - elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->bm_edjFilePath.c_str(), file_name); + if (data && obj){ + BookmarkFolderItemData *itemData = static_cast(data); + elm_object_focus_set(obj, EINA_FALSE); + const char* file_name = getImageFileNameForType(itemData->index, false); + Elm_Object_Item * selected = itemData->addBookmarkPopup->m_map_bookmark_folder_views["new_folder_button"]; + Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "elm.thumbnail"); + elm_image_file_set(thumb_nail, itemData->addBookmarkPopup->m_edjFilePath.c_str(), file_name); + } } -void AddBookmarkPopup::_itemSelected(void * data, Evas_Object * /* obj */, void * event_info) -{ - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - /*Elm_Object_Item * selected = reinterpret_cast(event_info); - HistoryItemData * itemData = reinterpret_cast(elm_object_item_data_get(selected)); - AddBookmarkPopup * self = reinterpret_cast(data); - - self->bookmarkClicked(itemData->item);*/ -} +//void AddBookmarkPopup::_itemSelected(void* , Evas_Object* , void*) +//{ +// BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); +// if (data && event_info) { +// Elm_Object_Item * selected = static_cast(event_info); +// HistoryItemData * itemData = static_cast(elm_object_item_data_get(selected)); +// AddBookmarkPopup * self = static_cast(data); +// +// self->bookmarkClicked(itemData->item); +// } +//} -void AddBookmarkPopup::_newFolderButton(void * data, Evas_Object * /* obj */, void * /* event_info */) +void AddBookmarkPopup::_newFolderButton(void* data, Evas_Object*, void*) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - BookmarkFolderItemData * itemData = reinterpret_cast(data); - itemData->addBookmarkPopup->addNewFolderClicked(std::string()); + if (data) { + BookmarkFolderItemData * itemData = static_cast(data); + itemData->addBookmarkPopup->addNewFolderClicked(std::string()); + } } -void AddBookmarkPopup::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */) +void AddBookmarkPopup::_thumbSelected(void* data, Evas_Object*, void*) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - BookmarkFolderItemData * itemData = reinterpret_cast(data); - itemData->addBookmarkPopup->folderSelected(itemData->item->getId()); + if (data) { + BookmarkFolderItemData * itemData = static_cast(data); + itemData->addBookmarkPopup->folderSelected(itemData->item->getId()); + } } void AddBookmarkPopup::clearItems() @@ -307,7 +307,7 @@ void AddBookmarkPopup::clearItems() BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); elm_gengrid_clear(m_gengrid); m_map_bookmark_folder_views.clear(); - elm_theme_extension_del(nullptr, bm_edjFilePath.c_str()); + elm_theme_extension_del(nullptr, m_edjFilePath.c_str()); elm_theme_full_flush(); elm_cache_all_flush(); } @@ -320,24 +320,28 @@ void AddBookmarkPopup::updateGengrid() m_map_bookmark_folder_views.clear(); } -void AddBookmarkPopup::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) +void AddBookmarkPopup::focusItem(void*, Evas_Object*, void* event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); + if (event_info) { + Elm_Object_Item *item = static_cast(event_info); + elm_object_item_signal_emit(item, "mouse,in", "over2"); - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); + // selected manually + elm_gengrid_item_selected_set(item, EINA_TRUE); + } } -void AddBookmarkPopup::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) +void AddBookmarkPopup::unFocusItem(void*, Evas_Object*, void* event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); + if (event_info) { + Elm_Object_Item *item = static_cast(event_info); + elm_object_item_signal_emit(item, "mouse,out", "over2"); - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); + // unselected manually + elm_gengrid_item_selected_set(item, EINA_FALSE); + } } } diff --git a/services/MoreMenuUI/AddBookmarkPopup.h b/services/MoreMenuUI/AddBookmarkPopup.h index 62d86e7..bce7ada 100644 --- a/services/MoreMenuUI/AddBookmarkPopup.h +++ b/services/MoreMenuUI/AddBookmarkPopup.h @@ -39,7 +39,7 @@ public: private: static char* _grid_text_get(void *data, Evas_Object *, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); - static void _itemSelected(void * data, Evas_Object * obj, void * event_info); + //static void _itemSelected(void * data, Evas_Object * obj, void * event_info); static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); static void _newFolderButton(void *data, Evas_Object *obj, void *event_info); static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part); @@ -56,7 +56,7 @@ private: Elm_Gengrid_Item_Class * m_itemClass; std::map m_map_bookmark_folder_views; - std::string bm_edjFilePath; + std::string m_edjFilePath; bool m_gengridSetup; static void __cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index 492f3ea..0a61323 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -40,8 +40,8 @@ struct ItemData{ typedef struct _MoreItemData { - ItemType item; - std::shared_ptr moreMenuUI; + ItemType item; + std::shared_ptr moreMenuUI; } MoreMenuItemData; MoreMenuUI::MoreMenuUI() @@ -50,8 +50,8 @@ MoreMenuUI::MoreMenuUI() , m_item_class(NULL) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - edjFilePath = EDJE_DIR; - edjFilePath.append("MoreMenuUI/MoreMenu.edj"); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("MoreMenuUI/MoreMenu.edj"); } MoreMenuUI::~MoreMenuUI() @@ -62,9 +62,9 @@ void MoreMenuUI::show(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_parent = parent; - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(NULL, m_edjFilePath.c_str()); m_mm_layout = elm_layout_add(parent); - elm_layout_file_set(m_mm_layout, edjFilePath.c_str(), "moremenu-layout"); + elm_layout_file_set(m_mm_layout, m_edjFilePath.c_str(), "moremenu-layout"); evas_object_size_hint_weight_set(m_mm_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_mm_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(m_mm_layout); @@ -101,7 +101,7 @@ void MoreMenuUI::show(Evas_Object* parent) void MoreMenuUI::showCurrentTab(const std::shared_ptr item) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(NULL, m_edjFilePath.c_str()); m_genList = elm_genlist_add(m_mm_layout); elm_object_part_content_set(m_mm_layout, "elm.swallow.genlist", m_genList); elm_genlist_homogeneous_set(m_genList, EINA_FALSE); @@ -125,12 +125,12 @@ void MoreMenuUI::showCurrentTab(const std::shared_ptrm_moreMenu = this; id->h_item = item ? item.get() : NULL; Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist - m_itemClass, //item Class + m_itemClass, //item Class id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE, //item type + NULL, //parent item + ELM_GENLIST_ITEM_NONE, //item type NULL, - NULL //data passed to above function + NULL //data passed to above function ); id->e_item = elmItem; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -139,114 +139,133 @@ void MoreMenuUI::showCurrentTab(const std::shared_ptr(data); - if(!strcmp(part, "favicon") && id->h_item && id->h_item->getFavIcon()) - { - // Currently favicon is not getting fetched from the engine, so we are showing Google's favicon by default. - Evas_Object* thumb_nail = elm_icon_add(obj); - const char* file_name = "favicon.png"; - elm_image_file_set(thumb_nail, id->m_moreMenu->edjFilePath.c_str(), file_name); - return thumb_nail; - //return tizen_browser::tools::EflTools::getEvasImage(id->h_item->getFavIcon(), obj); - } - else if(!strcmp(part, "star_click")) - { - Evas_Object *star_click = elm_button_add(obj); - elm_object_style_set(star_click, "hidden_button"); - evas_object_smart_callback_add(star_click, "clicked", MoreMenuUI::star_clicked_cb, id); - return star_click; - } - else if(!strcmp(part, "close_click")) - { - Evas_Object *close_click = elm_button_add(obj); - elm_object_style_set(close_click, "hidden_button"); - evas_object_smart_callback_add(close_click, "clicked", MoreMenuUI::close_clicked_cb, id); - return close_click; + if (data && obj && part) { + ItemData * id = static_cast(data); + const char *part_name1 = "favicon"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "star_click"; + static const int part_name2_len =strlen(part_name2); + const char *part_name3 = "close_click"; + static const int part_name3_len = strlen(part_name3); + + if (!strncmp(part_name1, part, part_name1_len) && id->h_item && id->h_item->getFavIcon()) { + // Currently favicon is not getting fetched from the engine, + // so we are showing Google's favicon by default. + Evas_Object *thumb_nail = elm_icon_add(obj); + const char *file_name = "favicon.png"; + elm_image_file_set(thumb_nail, id->m_moreMenu->m_edjFilePath.c_str(), file_name); + return thumb_nail; + //return tizen_browser::tools::EflTools::getEvasImage(id->h_item->getFavIcon(), obj); + } + + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *star_click = elm_button_add(obj); + elm_object_style_set(star_click, "hidden_button"); + evas_object_smart_callback_add(star_click, "clicked", MoreMenuUI::star_clicked_cb, id); + return star_click; + } + + if (!strncmp(part_name3, part, part_name3_len)) { + Evas_Object *close_click = elm_button_add(obj); + elm_object_style_set(close_click, "hidden_button"); + evas_object_smart_callback_add(close_click, "clicked", MoreMenuUI::close_clicked_cb, id); + return close_click; + } } return NULL; } -void MoreMenuUI::item_clicked_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -} - -void MoreMenuUI::star_clicked_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) +void MoreMenuUI::star_clicked_cb(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - id->m_moreMenu->AddBookmarkPopupCalled(); + if (data) { + ItemData * id = static_cast(data); + id->m_moreMenu->AddBookmarkPopupCalled(); + } } void MoreMenuUI::AddBookmarkPopupCalled() -{ //m_map_bookmark_folder_list.clear(); - popup = std::shared_ptr (new AddBookmarkPopup(m_mm_layout)); - popup->show(); - popup->addBookmarkFolderItems(m_map_bookmark_folder_list); - popup->folderSelected.disconnect_all_slots(); - popup->folderSelected.connect(boost::bind(&MoreMenuUI::addToBookmarks, this, _1)); - popup->addNewFolderClicked.disconnect_all_slots(); - popup->addNewFolderClicked.connect(boost::bind(&MoreMenuUI::newFolderPopup, this,_1)); +{ + m_add_bookmark_popup = std::make_shared(m_mm_layout); + m_add_bookmark_popup->show(); + m_add_bookmark_popup->addBookmarkFolderItems(m_map_bookmark_folder_list); + m_add_bookmark_popup->folderSelected.disconnect_all_slots(); + m_add_bookmark_popup->folderSelected.connect(boost::bind(&MoreMenuUI::addToBookmarks, this, _1)); + m_add_bookmark_popup->addNewFolderClicked.disconnect_all_slots(); + m_add_bookmark_popup->addNewFolderClicked.connect(boost::bind(&MoreMenuUI::newFolderPopup, this,_1)); } void MoreMenuUI::newFolderPopup(std::string) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_popup = std::shared_ptr (new NewFolderPopup(m_mm_layout, NULL,"Add New Folder for adding to Bookmark","New Folder","Add to bookmark","Cancel")); - m_popup->on_ok.disconnect_all_slots(); - m_popup->on_ok.connect(boost::bind(&MoreMenuUI::NewFolderCreate, this, _1)); - m_popup->on_cancel.disconnect_all_slots(); - m_popup->on_cancel.connect(boost::bind(&MoreMenuUI::CancelClicked, this, _1)); - popup->hide(); - m_popup->show(); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_new_folder_popup = + std::make_shared(m_mm_layout + , nullptr + , "Add New Folder for adding to Bookmark" + , "New Folder" + , "Add to bookmark" + , "Cancel"); + m_new_folder_popup->on_ok.disconnect_all_slots(); + m_new_folder_popup->on_ok.connect(boost::bind(&MoreMenuUI::NewFolderCreate, this, _1)); + m_new_folder_popup->on_cancel.disconnect_all_slots(); + m_new_folder_popup->on_cancel.connect(boost::bind(&MoreMenuUI::CancelClicked, this, _1)); + m_add_bookmark_popup->hide(); + m_new_folder_popup->show(); } -void MoreMenuUI::NewFolderCreate(Evas_Object * popup_content) +void MoreMenuUI::NewFolderCreate(Evas_Object* popup_content) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_folderName = elm_entry_entry_get(popup_content); - BookmarkFolderCreated(m_folderName.c_str(), 0,0); - m_popup->hide(); + if (popup_content) { + m_folderName = elm_entry_entry_get(popup_content); + BookmarkFolderCreated(m_folderName.c_str(), 0,0); + m_new_folder_popup->hide(); + } } -void MoreMenuUI::CancelClicked(Evas_Object * popup) +void MoreMenuUI::CancelClicked(Evas_Object*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_popup->hide(); + m_new_folder_popup->hide(); } void MoreMenuUI::addToBookmarks(int folder_id) { AddBookmarkInput(folder_id); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - popup->hide(); - popup.reset(); + m_add_bookmark_popup->hide(); + m_add_bookmark_popup.reset(); } -void MoreMenuUI::close_clicked_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) +void MoreMenuUI::close_clicked_cb(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - id->m_moreMenu->closeMoreMenuClicked(std::string()); - id->m_moreMenu->clearItems(); + if (data) { + ItemData * id = static_cast(data); + id->m_moreMenu->closeMoreMenuClicked(std::string()); + id->m_moreMenu->clearItems(); + } } -char* MoreMenuUI::listItemTextGet(void* data, Evas_Object* /* obj */, const char* part) +char* MoreMenuUI::listItemTextGet(void* data, Evas_Object*, const char* part) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - if(!strcmp(part, "webpage_title")) - { - if(!id->h_item) - return strdup("New Tab"); - if(!id->h_item->getTitle().empty()){ + if (data && part) { + ItemData *id = static_cast(data); + const char *part_name1 = "webpage_title"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "webpage_url"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name1, part, part_name1_len)) { + if (!id->h_item) { + return strdup("New Tab"); + } return strdup(id->h_item->getTitle().c_str()); } - } - else if(!strcmp(part, "webpage_url")) - { - if(!id->h_item) - return strdup(""); - if(!id->h_item->getUrl().empty()){ + + if (!strncmp(part_name2, part, part_name2_len)) { + if(!id->h_item) + return strdup(""); return strdup(id->h_item->getUrl().c_str()); } } @@ -255,166 +274,194 @@ char* MoreMenuUI::listItemTextGet(void* data, Evas_Object* /* obj */, const char void MoreMenuUI::hide() { - evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.grid")); - evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.genlist")); - evas_object_hide(m_mm_layout); + evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.grid")); + evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.genlist")); + evas_object_hide(m_mm_layout); } void MoreMenuUI::addItems() { - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - for (size_t i = 0; i < 10; i++) { - MoreMenuItemData *itemData = new MoreMenuItemData(); - itemData->item = static_cast(i);; - itemData->moreMenuUI = std::shared_ptr(this); - Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, NULL, this); - m_map_menu_views.insert(std::pair(itemData->item, bookmarkView)); - elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); - } - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + for (size_t i = 0; i < 10; i++) { + MoreMenuItemData *itemData = new MoreMenuItemData(); + itemData->item = static_cast(i);; + itemData->moreMenuUI = std::shared_ptr(this); + Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, NULL, this); + m_map_menu_views.insert(std::pair(itemData->item, bookmarkView)); + elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); + } + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); } -char* MoreMenuUI::_grid_text_get(void *data, Evas_Object *obj, const char *part) +char* MoreMenuUI::_grid_text_get(void* data, Evas_Object*, const char* part) { - MoreMenuItemData *itemData = reinterpret_cast(data); - - BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); - if (!strcmp(part, "menu_label")) { - const char* item_name = NULL; - switch(itemData->item) { - case READER_MODE: - item_name = "Reader mode"; break; - case BOOKMARK_MANAGER: - item_name = "Bookmark manager"; break; - case HISTORY: - item_name = "History"; break; - case SCREEN_ZOOM: - item_name = "Screen zoom"; break; - case START_MINIBROWSER: - item_name = "Start minibrowser"; break; - case FOCUS_MODE: - item_name = "Focus mode"; break; - case VIEW_MOBILE_WEB: - item_name = "View mobile web"; break; - case SHARE: - item_name = "Share"; break; - case SETTINGS: - item_name = "Settings"; break; - case EXIT_BROWSER: - item_name = "Exit browser"; break; - default: - item_name = ""; - } - return strdup(item_name); - } - return NULL; + BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); + if (data && part) { + MoreMenuItemData *itemData = static_cast(data); + const char *part_name = "menu_label"; + static const int part_name_len = strlen(part_name); + + if (!strncmp(part_name, part, part_name_len)) { + const char* item_name = NULL; + switch (itemData->item) { + case READER_MODE: + item_name = "Reader mode"; + break; + case BOOKMARK_MANAGER: + item_name = "Bookmark manager"; + break; + case HISTORY: + item_name = "History"; + break; + case SCREEN_ZOOM: + item_name = "Screen zoom"; + break; + case START_MINIBROWSER: + item_name = "Start minibrowser"; + break; + case FOCUS_MODE: + item_name = "Focus mode"; + break; + case VIEW_MOBILE_WEB: + item_name = "View mobile web"; + break; + case SHARE: + item_name = "Share"; + break; + case SETTINGS: + item_name = "Settings"; + break; + case EXIT_BROWSER: + item_name = "Exit browser"; + break; + default: + item_name = ""; + } + return strdup(item_name); + } + } + return NULL; } static const char* getImageFileNameForType(ItemType type, bool focused) { - const char* file_name = NULL; - switch(type) { - case READER_MODE: - file_name = focused ? "ic_more_readermode_foc.png" : "ic_more_readermode_nor.png"; break; - case BOOKMARK_MANAGER: - file_name = focused ? "ic_more_bookmark_foc.png" : "ic_more_bookmark_nor.png"; break; - case HISTORY: - file_name = focused ? "ic_more_history_foc.png" : "ic_more_history_nor.png"; break; - case SCREEN_ZOOM: - file_name = focused ? "ic_more_zoom_foc.png" : "ic_more_zoom_nor.png"; break; - case START_MINIBROWSER: - file_name = focused ? "ic_more_minibrowser_foc.png" : "ic_more_minibrowser_nor.png"; break; - case FOCUS_MODE: - file_name = focused ? "ic_more_focusmode_foc.png" : "ic_more_focusmode_nor.png"; break; - case VIEW_MOBILE_WEB: - file_name = focused ? "ic_more_mobileview_foc.png" : "ic_more_mobileview_nor.png"; break; - case SHARE: - file_name = focused ? "ic_more_share_foc.png" : "ic_more_share_nor.png"; break; - case SETTINGS: - file_name = focused ? "ic_more_setting_foc.png" : "ic_more_setting_nor.png"; break; - case EXIT_BROWSER: - file_name = focused ? "ic_more_exit_foc.png" : "ic_more_exit_nor.png"; break; - default: - file_name = ""; - } - return file_name; + const char* file_name = NULL; + switch (type) { + case READER_MODE: + file_name = focused ? "ic_more_readermode_foc.png" : "ic_more_readermode_nor.png"; + break; + case BOOKMARK_MANAGER: + file_name = focused ? "ic_more_bookmark_foc.png" : "ic_more_bookmark_nor.png"; + break; + case HISTORY: + file_name = focused ? "ic_more_history_foc.png" : "ic_more_history_nor.png"; + break; + case SCREEN_ZOOM: + file_name = focused ? "ic_more_zoom_foc.png" : "ic_more_zoom_nor.png"; + break; + case START_MINIBROWSER: + file_name = focused ? "ic_more_minibrowser_foc.png" : "ic_more_minibrowser_nor.png"; + break; + case FOCUS_MODE: + file_name = focused ? "ic_more_focusmode_foc.png" : "ic_more_focusmode_nor.png"; + break; + case VIEW_MOBILE_WEB: + file_name = focused ? "ic_more_mobileview_foc.png" : "ic_more_mobileview_nor.png"; + break; + case SHARE: + file_name = focused ? "ic_more_share_foc.png" : "ic_more_share_nor.png"; + break; + case SETTINGS: + file_name = focused ? "ic_more_setting_foc.png" : "ic_more_setting_nor.png"; + break; + case EXIT_BROWSER: + file_name = focused ? "ic_more_exit_foc.png" : "ic_more_exit_nor.png"; + break; + default: + file_name = ""; + } + return file_name; } Evas_Object * MoreMenuUI::_grid_content_get(void *data, Evas_Object *obj, const char *part) { BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); - MoreMenuItemData *itemData = reinterpret_cast(data); + if (data && obj && part) { + MoreMenuItemData *itemData = static_cast(data); + const char *part_name1 = "thumbnail_item"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "thumbbutton_item"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name1, part, part_name1_len)) { + Evas_Object* thumb_nail = elm_icon_add(obj); + const char* file_name = getImageFileNameForType(itemData->item, false); + elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); + return thumb_nail; + } - if (!strcmp(part, "thumbnail_item")) { - Evas_Object* thumb_nail = elm_icon_add(obj); - const char* file_name = getImageFileNameForType(itemData->item, false); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->edjFilePath.c_str(), file_name); - return thumb_nail; - } - else if (!strcmp(part, "thumbbutton_item")) { - Evas_Object *thumbButton = elm_button_add(obj); - elm_object_style_set(thumbButton, "clickButton"); - evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::MoreMenuUI::_thumbSelected, data); - evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_IN, __cb_mouse_in, data); - evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_OUT, __cb_mouse_out, data); - return thumbButton; + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *thumbButton = elm_button_add(obj); + elm_object_style_set(thumbButton, "clickButton"); + evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::MoreMenuUI::_thumbSelected, data); + evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_IN, __cb_mouse_in, data); + evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_OUT, __cb_mouse_out, data); + return thumbButton; + } } return NULL; } -void MoreMenuUI::__cb_mouse_in(void * data, Evas *e, Evas_Object *obj, void *event_info) +void MoreMenuUI::__cb_mouse_in(void * data, Evas *, Evas_Object *obj, void *) { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - elm_object_focus_set(obj, EINA_TRUE); - MoreMenuItemData *itemData = reinterpret_cast(data); - - const char* file_name = getImageFileNameForType(itemData->item, true); - Elm_Object_Item * selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; - Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->edjFilePath.c_str(), file_name); -} - -void MoreMenuUI::__cb_mouse_out(void * data, Evas *e, Evas_Object *obj, void *event_info) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - MoreMenuItemData *itemData = reinterpret_cast(data); - elm_object_focus_set(obj, EINA_FALSE); - const char* file_name = getImageFileNameForType(itemData->item, false); - Elm_Object_Item * selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; - Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->edjFilePath.c_str(), file_name); + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + + MoreMenuItemData *itemData = static_cast(data); + const char *file_name = getImageFileNameForType(itemData->item, true); + Elm_Object_Item *selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; + Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); + elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); + } } -void MoreMenuUI::_itemSelected(void * data, Evas_Object * /* obj */, void * event_info) +void MoreMenuUI::__cb_mouse_out(void * data, Evas *, Evas_Object *obj, void *) { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + + MoreMenuItemData *itemData = static_cast(data); + const char *file_name = getImageFileNameForType(itemData->item, false); + Elm_Object_Item *selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; + Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); + elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); + } } -void MoreMenuUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */) +void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - MoreMenuItemData *itemData = reinterpret_cast(data); - switch(itemData->item) { - case READER_MODE: - break; - case BOOKMARK_MANAGER: - break; - case HISTORY: - itemData->moreMenuUI->historyUIClicked(std::string()); break; - case SCREEN_ZOOM: - break; - case START_MINIBROWSER: - break; - case FOCUS_MODE: - break; - case VIEW_MOBILE_WEB: - break; - case SHARE: - break; - case SETTINGS: - itemData->moreMenuUI->settingsClicked(std::string()); break; - case EXIT_BROWSER: - break; + if (data) { + MoreMenuItemData *itemData = static_cast(data); + switch (itemData->item) { + case HISTORY: + itemData->moreMenuUI->historyUIClicked(std::string()); + break; + case SETTINGS: + itemData->moreMenuUI->settingsClicked(std::string()); + break; + case READER_MODE: + case BOOKMARK_MANAGER: + case SCREEN_ZOOM: + case START_MINIBROWSER: + case FOCUS_MODE: + case VIEW_MOBILE_WEB: + case SHARE: + case EXIT_BROWSER: + break; + } } } @@ -431,30 +478,39 @@ void MoreMenuUI::clearItems() elm_genlist_clear(m_genList); m_map_menu_views.clear(); m_map_bookmark_folder_list.clear(); - elm_theme_extension_del(NULL, edjFilePath.c_str()); + elm_theme_extension_del(NULL, m_edjFilePath.c_str()); elm_theme_full_flush(); elm_cache_all_flush(); } -void MoreMenuUI::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); - - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); -} - -void MoreMenuUI::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); - - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); -} +//void MoreMenuUI::focusItem(void*, Evas_Object*, void* event_info) +//{ +// BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); +// if (event_info) { +// Elm_Object_Item *item = static_cast(event_info); +// elm_object_item_signal_emit(item, "mouse,in", "over2"); +// +// // selected manually +// elm_gengrid_item_selected_set(item, EINA_TRUE); +// } +//} +// +//void MoreMenuUI::unFocusItem(void*, Evas_Object*, void* event_info) +//{ +// BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); +// if (event_info) { +// Elm_Object_Item *item = static_cast(event_info); +// elm_object_item_signal_emit( item, "mouse,out", "over2"); +// +// // unselected manually +// elm_gengrid_item_selected_set(item, EINA_FALSE); +// } +//} +// +//void MoreMenuUI::_itemSelected(void*, Evas_Object*, void *) +//{ +// BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); +//} } } diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 7bff048..7f0812b 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -18,6 +18,7 @@ #define MOREMENUUI_H #include +#include #include #include "AbstractUIComponent.h" @@ -73,7 +74,6 @@ public: private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); - static void _itemSelected(void * data, Evas_Object * obj, void * event_info); static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part); @@ -85,7 +85,7 @@ private: void AddBookmarkPopupCalled(); void addToBookmarks(int folder_id); - static void item_clicked_cb(void *data, Evas_Object *obj, void *event_info); + static void star_clicked_cb(void *data, Evas_Object *obj, void *event_info); static void close_clicked_cb(void *data, Evas_Object *obj, void *event_info); @@ -94,21 +94,22 @@ private: private: Evas_Object *m_genList; - std::shared_ptr m_popup; + std::shared_ptr m_new_folder_popup; Evas_Object *m_mm_layout; - std::shared_ptr popup; + std::shared_ptr m_add_bookmark_popup; Elm_Genlist_Item_Class *m_itemClass; Evas_Object *m_gengrid; Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_item_class; std::map m_map_menu_views; std::vector > m_map_bookmark_folder_list; - std::string edjFilePath; + std::string m_edjFilePath; std::string m_folderName; bool m_gengridSetup; - static void focusItem(void* data, Evas_Object* obj, void* event_info); - static void unFocusItem(void* data, Evas_Object* obj, void* event_info); + //static void focusItem(void* data, Evas_Object* obj, void* event_info); + //static void unFocusItem(void* data, Evas_Object* obj, void* event_info); + //static void _itemSelected(void * data, Evas_Object * obj, void * event_info); }; } diff --git a/services/MoreMenuUI/NewFolderPopup.cpp b/services/MoreMenuUI/NewFolderPopup.cpp index 32b8f69..ca5ef0f 100644 --- a/services/MoreMenuUI/NewFolderPopup.cpp +++ b/services/MoreMenuUI/NewFolderPopup.cpp @@ -28,21 +28,26 @@ namespace tizen_browser{ namespace base_ui{ NewFolderPopup::NewFolderPopup(Evas_Object* main_layout) : - m_popup(NULL), - m_content(NULL), + m_popup(nullptr), + m_content(nullptr), m_mainLayout(main_layout) { } -NewFolderPopup::NewFolderPopup(Evas_Object *main_layout, Evas_Object *content, const char *message, char* title, char* okButtonText, char* cancelButtonText) : - m_popup(NULL), - m_mainLayout(main_layout), +NewFolderPopup::NewFolderPopup(Evas_Object *main_layout + , Evas_Object *content + , const char *message + , const char *title + , const char *okButtonText + , const char *cancelButtonText) : + m_popup(nullptr), m_content(content), m_message(message), m_title(title), m_okButtonText(okButtonText), - m_cancelButtonText(cancelButtonText) + m_cancelButtonText(cancelButtonText), + m_mainLayout(main_layout) { } @@ -153,17 +158,21 @@ void NewFolderPopup::hide() elm_object_signal_emit(m_mainLayout, "elm,state,hide", "elm"); } -void NewFolderPopup::popup_ok_cb(void *data, Evas_Object *btn, void*) +void NewFolderPopup::popup_ok_cb(void *data, Evas_Object*, void*) { BROWSER_LOGD("[%s],", __func__); - NewFolderPopup *ownPopup = static_cast(data); - ownPopup->on_ok(ownPopup->m_editfield_entry); + if (data) { + NewFolderPopup *ownPopup = static_cast(data); + ownPopup->on_ok(ownPopup->m_editfield_entry); + } } -void NewFolderPopup::popup_cancel_cb(void *data, Evas_Object *btn, void*) +void NewFolderPopup::popup_cancel_cb(void *data, Evas_Object*, void*) { BROWSER_LOGD("[%s],", __func__); - NewFolderPopup *ownPopup = static_cast(data); - ownPopup->on_cancel(ownPopup->m_editfield_entry); + if (data) { + NewFolderPopup *ownPopup = static_cast(data); + ownPopup->on_cancel(ownPopup->m_editfield_entry); + } } } diff --git a/services/MoreMenuUI/NewFolderPopup.h b/services/MoreMenuUI/NewFolderPopup.h index 18edd11..e0fd051 100644 --- a/services/MoreMenuUI/NewFolderPopup.h +++ b/services/MoreMenuUI/NewFolderPopup.h @@ -17,7 +17,12 @@ class NewFolderPopup{ public: NewFolderPopup(Evas_Object *main_layout); - NewFolderPopup(Evas_Object *main_layout, Evas_Object *content, const char *message, char *title, char* okButtonText, char* cancelButtonText); + NewFolderPopup(Evas_Object *main_layout + , Evas_Object *content + , const char *message + , const char *title + , const char *okButtonText + , const char *cancelButtonText); /** * Theese setters should be called before showing popup. -- 2.7.4 From bcf6cf4832f214b8f5327618ab967a0fc2176f51 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Fri, 7 Aug 2015 19:01:24 +0200 Subject: [PATCH 04/16] Refactored TabUI service [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] Lots of style fixes, several fixes for build warnings [Cause] n/a [Solution] Reformat code, fix casting and remove unused variables [Verify] 1. Check that there are no build problems caused by this change 2. Run the browser and explore the tab functionality to see if nothing's broken List of changes: * tabs -> spaces * proper indentation * other minor style fixes * removing unused variables' declarations * renaming a few class members to better express their use * replacing reinterpret_cast with static_cast where appropriate * adding null-checks in callback functions Change-Id: Ib2a5731683c99aa5b89acf9f00417a41d207c579 --- services/TabUI/TabUI.cpp | 522 +++++++++++++++++++++++------------------------ services/TabUI/TabUI.h | 5 +- 2 files changed, 257 insertions(+), 270 deletions(-) diff --git a/services/TabUI/TabUI.cpp b/services/TabUI/TabUI.cpp index 5646f26..d004b0b 100644 --- a/services/TabUI/TabUI.cpp +++ b/services/TabUI/TabUI.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include "TabUI.h" @@ -25,7 +27,6 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" -#define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) namespace tizen_browser{ namespace base_ui{ @@ -34,28 +35,29 @@ EXPORT_SERVICE(TabUI, "org.tizen.browser.tabui") typedef struct _TabItemData { - std::shared_ptr item; - std::shared_ptr tabUI; + std::shared_ptr item; + std::shared_ptr tabUI; } TabItemData; -struct ItemData{ - tizen_browser::base_ui::TabUI* tabUI; - Elm_Object_Item * e_item; +struct ItemData +{ + tizen_browser::base_ui::TabUI* tabUI; + Elm_Object_Item * e_item; }; TabUI::TabUI() - : m_gengrid(NULL) - , m_tab_layout(NULL) - , m_genListTop(NULL) - , m_genListActionBar(NULL) - , m_parent(NULL) - , m_itemClassActionBar(NULL) - , m_itemClassTop(NULL) - , m_item_class(NULL) + : m_tab_layout(nullptr) + , m_genListActionBar(nullptr) + , m_itemClassActionBar(nullptr) + , m_genListTop(nullptr) + , m_itemClassTop(nullptr) + , m_gengrid(nullptr) + , m_parent(nullptr) + , m_item_class(nullptr) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - edjFilePath = EDJE_DIR; - edjFilePath.append("TabUI/TabUI.edj"); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("TabUI/TabUI.edj"); } TabUI::~TabUI() @@ -67,9 +69,9 @@ void TabUI::show(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); //m_parent = p; - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_tab_layout = elm_layout_add(parent); - elm_layout_file_set(m_tab_layout, edjFilePath.c_str(), "tab-layout"); + elm_layout_file_set(m_tab_layout, m_edjFilePath.c_str(), "tab-layout"); evas_object_size_hint_weight_set(m_tab_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_tab_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(m_tab_layout); @@ -80,31 +82,32 @@ void TabUI::show(Evas_Object* parent) m_gengrid = elm_gengrid_add(m_tab_layout); elm_object_part_content_set(m_tab_layout, "tab_gengird", m_gengrid); - evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, NULL); - evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, NULL); + evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, nullptr); + evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, nullptr); evas_object_smart_callback_add(m_gengrid, "activated", _itemSelected, this); - if (!m_item_class) { - m_item_class = elm_gengrid_item_class_new(); - m_item_class->item_style = "tab_item"; - m_item_class->func.text_get = _grid_text_get; - m_item_class->func.content_get = _tab_grid_content_get; - m_item_class->func.state_get = NULL; - m_item_class->func.del = NULL; - } - - M_ASSERT(m_parent); - elm_gengrid_align_set(m_gengrid, 0, 0); - elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); - elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); - elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scroller_page_size_set(m_gengrid, 0, 327); - - evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); + if (!m_item_class) { + m_item_class = elm_gengrid_item_class_new(); + m_item_class->item_style = "tab_item"; + m_item_class->func.text_get = _grid_text_get; + m_item_class->func.content_get = _tab_grid_content_get; + m_item_class->func.state_get = nullptr; + m_item_class->func.del = nullptr; + } + M_ASSERT(m_parent); + elm_gengrid_align_set(m_gengrid, 0, 0); + elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); + elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); + elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); + elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_scroller_page_size_set(m_gengrid, 0, 327); + + evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); + + double efl_scale = elm_config_scale_get() / elm_app_base_scale_get(); elm_gengrid_item_size_set(m_gengrid, 364 * efl_scale, 320 * efl_scale); } @@ -112,7 +115,7 @@ void TabUI::show(Evas_Object* parent) void TabUI::showActionBar() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_genListActionBar = elm_genlist_add(m_tab_layout); elm_object_part_content_set(m_tab_layout, "action_bar_genlist", m_genListActionBar); elm_genlist_homogeneous_set(m_genListActionBar, EINA_FALSE); @@ -122,124 +125,118 @@ void TabUI::showActionBar() elm_genlist_decorate_mode_set(m_genListActionBar, EINA_TRUE); evas_object_size_hint_weight_set(m_genListActionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - // evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - // evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, NULL);*/ +// evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); +// evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, nullptr);*/ m_itemClassActionBar = elm_genlist_item_class_new(); m_itemClassActionBar->item_style = "action_bar_items"; - m_itemClassActionBar->func.text_get = NULL; // &listTopItemTextGet; + m_itemClassActionBar->func.text_get = nullptr; // &listTopItemTextGet; m_itemClassActionBar->func.content_get = &listActionBarContentGet; - m_itemClassActionBar->func.state_get = 0; - m_itemClassActionBar->func.del = 0; + m_itemClassActionBar->func.state_get = nullptr; + m_itemClassActionBar->func.del = nullptr; - ItemData * id = new ItemData; + ItemData *id = new ItemData; id->tabUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListActionBar, //genlist + m_itemClassActionBar, //item Class + id, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id->e_item = elmItem; - ItemData * id2 = new ItemData; + + ItemData *id2 = new ItemData; id2->tabUI = this; - Elm_Object_Item* elmItem2 = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id2, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item* elmItem2 = elm_genlist_item_append(m_genListActionBar, //genlist + m_itemClassActionBar, //item Class + id2, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id2->e_item = elmItem2; - ItemData * id3 = new ItemData; + ItemData *id3 = new ItemData; id3->tabUI = this; - Elm_Object_Item* elmItem3 = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id3, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item* elmItem3 = elm_genlist_item_append(m_genListActionBar , //genlist + m_itemClassActionBar, //item Class + id3, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id3->e_item = elmItem3; - /*ItemData * id4 = new ItemData; - id4->tabUI = this; - Elm_Object_Item* elmItem4 = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - //id.get(), //item data - id4, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); - id4->e_item = elmItem4;*/ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - } Evas_Object* TabUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) { - //ItemData *itemData = reinterpret_cast(data); - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!strcmp(part, "newtab_click")) - { - BROWSER_LOGD("############in new tab button part##################"); - Evas_Object *newtabButton = elm_button_add(obj); - elm_object_style_set(newtabButton, "tab_button"); - evas_object_smart_callback_add(newtabButton, "clicked", tizen_browser::base_ui::TabUI::_newtab_clicked, data); - return newtabButton; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (obj && part) { + const char *part_name1 = "newtab_click"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "newincognitotab_clic"; + static const int part_name2_len = strlen(part_name2); + const char *part_name3 = "closetabs_click"; + static const int part_name3_len = strlen(part_name3); + const char *part_name4 = "close_click"; + static const int part_name4_len = strlen(part_name4); + + if (!strncmp(part_name1, part, part_name1_len)) { + Evas_Object *newtabButton = elm_button_add(obj); + elm_object_style_set(newtabButton, "tab_button"); + evas_object_smart_callback_add(newtabButton, "clicked", tizen_browser::base_ui::TabUI::_newtab_clicked, data); + return newtabButton; } - else if(!strcmp(part, "newincognitotab_click")) - { - Evas_Object *newincognitotabButton = elm_button_add(obj); - elm_object_style_set(newincognitotabButton, "tab_button"); - evas_object_smart_callback_add(newincognitotabButton, "clicked", tizen_browser::base_ui::TabUI::_newincognitotab_clicked, data); - return newincognitotabButton; + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *newincognitotabButton = elm_button_add(obj); + elm_object_style_set(newincognitotabButton, "tab_button"); + evas_object_smart_callback_add(newincognitotabButton, "clicked", tizen_browser::base_ui::TabUI::_newincognitotab_clicked, data); + return newincognitotabButton; } - else if(!strcmp(part, "closetabs_click")) - { - Evas_Object *closetabsButton = elm_button_add(obj); - elm_object_style_set(closetabsButton, "tab_button"); - evas_object_smart_callback_add(closetabsButton, "clicked", tizen_browser::base_ui::TabUI::_closetabs_clicked, data); - return closetabsButton; + if (!strncmp(part_name3, part, part_name3_len)) { + Evas_Object *closetabsButton = elm_button_add(obj); + elm_object_style_set(closetabsButton, "tab_button"); + evas_object_smart_callback_add(closetabsButton, "clicked", tizen_browser::base_ui::TabUI::_closetabs_clicked, data); + return closetabsButton; } - else if(!strcmp(part, "close_click")) - { - Evas_Object *close_click = elm_button_add(obj); - elm_object_style_set(close_click, "tab_button"); - evas_object_smart_callback_add(close_click, "clicked", TabUI::close_clicked_cb, data); - return close_click; - } - return NULL; + if (!strncmp(part_name4, part, part_name4_len)) { + Evas_Object *close_click = elm_button_add(obj); + elm_object_style_set(close_click, "tab_button"); + evas_object_smart_callback_add(close_click, "clicked", TabUI::close_clicked_cb, data); + return close_click; + } + } + return nullptr; } -void TabUI::close_clicked_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) +void TabUI::close_clicked_cb(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - id->tabUI->closeTabUIClicked(std::string()); - id->tabUI->clearItems(); + if (data) { + ItemData * id = static_cast(data); + id->tabUI->closeTabUIClicked(std::string()); + id->tabUI->clearItems(); + } } void TabUI::hide() { - evas_object_hide(elm_layout_content_get(m_tab_layout, "action_bar_genlist")); - evas_object_hide(elm_layout_content_get(m_tab_layout, "top_bar_genlist")); - evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengird")); - evas_object_hide(m_tab_layout); + evas_object_hide(elm_layout_content_get(m_tab_layout, "action_bar_genlist")); + evas_object_hide(elm_layout_content_get(m_tab_layout, "top_bar_genlist")); + evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengird")); + evas_object_hide(m_tab_layout); } void TabUI::showTopButtons() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_genListTop = elm_genlist_add(m_tab_layout); elm_object_part_content_set(m_tab_layout, "top_bar_genlist", m_genListTop); elm_genlist_homogeneous_set(m_genListTop, EINA_FALSE); @@ -249,37 +246,37 @@ void TabUI::showTopButtons() elm_genlist_decorate_mode_set(m_genListTop, EINA_TRUE); evas_object_size_hint_weight_set(m_genListTop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - /*evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, NULL);*/ +// evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); +// evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, nullptr); m_itemClassTop = elm_genlist_item_class_new(); m_itemClassTop->item_style = "top_buttons"; - m_itemClassTop->func.text_get = NULL;// &listTapTopItemTextGet; + m_itemClassTop->func.text_get = nullptr; m_itemClassTop->func.content_get = &listTopButtonItemsContentGet; - m_itemClassTop->func.state_get = 0; - m_itemClassTop->func.del = 0; + m_itemClassTop->func.state_get = nullptr; + m_itemClassTop->func.del = nullptr; - ItemData * id = new ItemData; + ItemData *id = new ItemData; id->tabUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListTop, //genlist - m_itemClassTop, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item *elmItem = elm_genlist_item_append(m_genListTop, //genlist + m_itemClassTop, //item Class + id, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id->e_item = elmItem; - ItemData * id2 = new ItemData; + ItemData *id2 = new ItemData; id2->tabUI = this; - Elm_Object_Item* elmItem2 = elm_genlist_item_append(m_genListTop, //genlist - m_itemClassTop, //item Class - id2, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item *elmItem2 = elm_genlist_item_append(m_genListTop, //genlist + m_itemClassTop, //item Class + id2, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id2->e_item = elmItem2; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -287,92 +284,77 @@ void TabUI::showTopButtons() Evas_Object* TabUI::listTopButtonItemsContentGet(void* data, Evas_Object* obj , const char* part) { - //ItemData *itemData = reinterpret_cast(data); - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!strcmp(part, "openedtabs_button")) - { - Evas_Object *openedtabsButton = elm_button_add(obj); - elm_object_style_set(openedtabsButton, "tab_button"); - evas_object_smart_callback_add(openedtabsButton, "clicked", tizen_browser::base_ui::TabUI::_openedtabs_clicked, data); - return openedtabsButton; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj && part) { + const char *part_name1 = "openedtabs_button"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "onotherdevices_button"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name1, part, part_name1_len)) { + Evas_Object *openedtabsButton = elm_button_add(obj); + elm_object_style_set(openedtabsButton, "tab_button"); + evas_object_smart_callback_add(openedtabsButton, "clicked", tizen_browser::base_ui::TabUI::_openedtabs_clicked, data); + return openedtabsButton; } - else if(!strcmp(part, "onotherdevices_button")) - { - Evas_Object *onotherdevicesButton = elm_button_add(obj); - elm_object_style_set(onotherdevicesButton, "tab_button"); - evas_object_smart_callback_add(onotherdevicesButton, "clicked", tizen_browser::base_ui::TabUI::_onotherdevices_clicked, data); - return onotherdevicesButton; - } - return NULL; + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *onotherdevicesButton = elm_button_add(obj); + elm_object_style_set(onotherdevicesButton, "tab_button"); + evas_object_smart_callback_add(onotherdevicesButton, "clicked", tizen_browser::base_ui::TabUI::_onotherdevices_clicked, data); + return onotherdevicesButton; + } + } + return nullptr; } -void TabUI::_newtab_clicked(void * data, Evas_Object * /* obj */, void * event_info) +void TabUI::_newtab_clicked(void * data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->clearItems(); - itemData->tabUI->newTabClicked(std::string()); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData* itemData = static_cast(data); + itemData->tabUI->clearItems(); + itemData->tabUI->newTabClicked(std::string()); + } } -void TabUI::_openedtabs_clicked(void * data, Evas_Object * /* obj */, void * event_info) +void TabUI::_openedtabs_clicked(void*, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - /*ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->newTabClicked(std::string());*/ } -void TabUI::_onotherdevices_clicked(void * data, Evas_Object * /* obj */, void * event_info) +void TabUI::_onotherdevices_clicked(void*, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - /*ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->newTabClicked(std::string());*/ } -void TabUI::_newincognitotab_clicked(void * data, Evas_Object * /* obj */, void * event_info) +void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->clearItems(); - itemData->tabUI->newIncognitoTabClicked(std::string()); -} - -void TabUI::_closetabs_clicked(void * data, Evas_Object * /* obj */, void * event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->closeTabsClicked(std::string()); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData* itemData = static_cast(data); + itemData->tabUI->clearItems(); + itemData->tabUI->newIncognitoTabClicked(std::string()); + } } -/* -char* TabUI::listItemTopTextGet(void* data, Evas_Object* obj , const char* part) +void TabUI::_closetabs_clicked(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - if(!strcmp(part, "Tabmanager")) - { - if(!id->h_item->getTitle().empty()){ - return strdup(id->h_item->getTitle().c_str()); - } - } - else if(!strcmp(part, "tab_url")) - { - if(!id->h_item->getUrl().empty()){ - return strdup(id->h_item->getUrl().c_str()); - } + if (data) { + ItemData* itemData = static_cast(data); + itemData->tabUI->closeTabsClicked(std::string()); } - return strdup(""); } -*/ void TabUI::addTabItem(std::shared_ptr hi) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); if (m_map_tab_views.size() >= 10) - return; + return; TabItemData *itemData = new TabItemData(); itemData->item = hi; - itemData->tabUI = std::shared_ptr(this); - Elm_Object_Item* tabView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, NULL, this); + itemData->tabUI = std::shared_ptr(this); + Elm_Object_Item* tabView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, nullptr, this); m_map_tab_views.insert(std::pair(hi->getTitle(),tabView)); // unselect by default @@ -382,70 +364,74 @@ void TabUI::addTabItem(std::shared_ptr>items) { - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - int i = 0; - for (auto it = items.begin(); it != items.end(); ++it) { - i++; - if (i > 10) break; - addTabItem(*it); - } + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + //limiting number of added items to 10 + auto eit = std::min(items.end(), items.begin() + 10); + for (auto it = items.begin(); it != eit; ++it) { + addTabItem(*it); + } } - -char* TabUI::_grid_text_get(void *data, Evas_Object *obj, const char *part) +char* TabUI::_grid_text_get(void *data, Evas_Object*, const char *part) { - TabItemData *itemData = reinterpret_cast(data); - if (!strcmp(part, "tab_title")) { - return strdup(itemData->item->getTitle().c_str()); - } - if (!strcmp(part, "tab_url")) { - //return strdup(itemData->item->getUrl().c_str()); - return strdup(""); - } - - return strdup(""); -} + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + if (data && part) { + TabItemData *itemData = static_cast(data); + const char *part_name1 = "tab_title"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "tab_url"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name1, part, part_name1_len)) { + return strdup(itemData->item->getTitle().c_str()); + } + if (!strncmp(part_name2, part, part_name2_len)) { + //return strdup(itemData->item->getUrl().c_str()); + return strdup(""); + } + } + return strdup(""); +} Evas_Object * TabUI::_tab_grid_content_get(void *data, Evas_Object *obj, const char *part) { - BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); - TabItemData *itemData = reinterpret_cast(data); - - if (!strcmp(part, "tab_thumbnail")) { - if (itemData->item->getThumbnail()) { - Evas_Object * thumb = tizen_browser::tools::EflTools::getEvasImage(itemData->item->getThumbnail(), itemData->tabUI->m_parent); - return thumb; + if (data && obj && part) { + TabItemData *itemData = static_cast(data); + const char *part_name1 = "tab_thumbnail"; + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "tab_thumbButton"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *thumbButton = elm_button_add(obj); + elm_object_style_set(thumbButton, "tab_thumbButton"); + evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::TabUI::_thumbSelected, data); + return thumbButton; } - else { - return NULL; + if (!strncmp(part_name1, part, part_name1_len)) { + if (itemData->item->getThumbnail()) { + return tizen_browser::tools::EflTools::getEvasImage(itemData->item->getThumbnail(), itemData->tabUI->m_parent); + } } } - else if (!strcmp(part, "tab_thumbButton")) { - Evas_Object *thumbButton = elm_button_add(obj); - elm_object_style_set(thumbButton, "tab_thumbButton"); - evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::TabUI::_thumbSelected, data); - return thumbButton; - } - return NULL; - + return nullptr; } -void TabUI::_itemSelected(void * data, Evas_Object * /* obj */, void * event_info) +void TabUI::_itemSelected(void*, Evas_Object*, void*) { - Elm_Object_Item * selected = reinterpret_cast(event_info); - TabItemData * itemData = reinterpret_cast(elm_object_item_data_get(selected)); - TabUI * self = reinterpret_cast(data); - -// self->historyClicked(itemData->item); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); +// self->historyClicked(itemData->item); } -void TabUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */ ) +void TabUI::_thumbSelected(void *data, Evas_Object*, void*) { - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - TabItemData * itemData = reinterpret_cast(data); - itemData->tabUI->clearItems(); - itemData->tabUI->tabClicked(itemData->item->getId()); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + if (data) { + TabItemData *itemData = static_cast(data); + itemData->tabUI->clearItems(); + itemData->tabUI->tabClicked(itemData->item->getId()); + } } void TabUI::clearItems() @@ -469,31 +455,35 @@ Evas_Object* TabUI::createNoHistoryLabel() void TabUI::setEmptyGengrid(bool setEmpty) { - if(setEmpty) { + if (setEmpty) { elm_object_part_content_set(m_gengrid, "elm.swallow.empty", createNoHistoryLabel()); } else { - elm_object_part_content_set(m_gengrid, "elm.swallow.empty", NULL); + elm_object_part_content_set(m_gengrid, "elm.swallow.empty", nullptr); } } -void TabUI::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) +void TabUI::focusItem(void*, Evas_Object*, void* event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); + if (event_info) { + Elm_Object_Item *item = static_cast(event_info); + elm_object_item_signal_emit( item, "mouse,in", "over2"); - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); + // selected manually + elm_gengrid_item_selected_set(item, EINA_TRUE); + } } -void TabUI::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) +void TabUI::unFocusItem(void*, Evas_Object*, void* event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); + if (event_info) { + Elm_Object_Item *item = static_cast(event_info); + elm_object_item_signal_emit( item, "mouse,out", "over2"); - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); + // unselected manually + elm_gengrid_item_selected_set(item, EINA_FALSE); + } } } diff --git a/services/TabUI/TabUI.h b/services/TabUI/TabUI.h index 505ca5a..9694132 100644 --- a/services/TabUI/TabUI.h +++ b/services/TabUI/TabUI.h @@ -45,8 +45,6 @@ public: void addTabItem(std::shared_ptr); void addTabItems(std::vector > items); -// void addBookmarkItem(std::shared_ptr); -// void addbookmarkItems(std::vector >); boost::signals2::signal tabClicked; boost::signals2::signal newTabClicked; @@ -58,7 +56,6 @@ public: private: static Evas_Object* listActionBarContentGet(void *data, Evas_Object *obj, const char *part); static Evas_Object* listTopButtonItemsContentGet(void *data, Evas_Object *obj, const char *part); - //static char* listItemTextGet(void *data, Evas_Object *obj, const char *part); static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _tab_grid_content_get(void *data, Evas_Object *obj, const char *part); @@ -86,7 +83,7 @@ private: Elm_Gengrid_Item_Class * m_item_class; std::map m_map_tab_views; bool m_gengridSetup; - std::string edjFilePath; + std::string m_edjFilePath; Evas_Object *createNoHistoryLabel(); static void focusItem(void* data, Evas_Object* obj, void* event_info); -- 2.7.4 From 03aa306dc5760f924cb4345cbdb9d111ef1b4d51 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Mon, 10 Aug 2015 16:41:33 +0200 Subject: [PATCH 05/16] Refactored SettingsUI service [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] Lots of style fixes, several fixes for build warnings [Cause] n/a [Solution] Reformat code, fix casting and remove unused variables [Verify] 1. Check that there are no build problems caused by this change 2. Run the browser and explore the settings to see if nothing's broken List of changes: * tabs -> spaces * proper indentation * other minor style fixes * removing unused variables' declarations * renaming a few class members to better express their use * replacing reinterpret_cast with static_cast where appropriate * adding null-checks in callback functions * replacing deprecated Elementary API call with its successor Change-Id: Ic9e00dd20b93f9392af61bede11868df18448478 --- services/SettingsUI/SettingsUI.cpp | 281 ++++++++++++++++++++----------------- services/SettingsUI/SettingsUI.h | 8 +- 2 files changed, 153 insertions(+), 136 deletions(-) diff --git a/services/SettingsUI/SettingsUI.cpp b/services/SettingsUI/SettingsUI.cpp index 9fe988b..9b897a2 100644 --- a/services/SettingsUI/SettingsUI.cpp +++ b/services/SettingsUI/SettingsUI.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -31,21 +32,21 @@ namespace base_ui{ EXPORT_SERVICE(SettingsUI, "org.tizen.browser.settingsui") -struct ItemData{ - tizen_browser::base_ui::SettingsUI* settingsUI; - Elm_Object_Item * e_item; +struct ItemData { + tizen_browser::base_ui::SettingsUI* settingsUI; + Elm_Object_Item * e_item; }; SettingsUI::SettingsUI() - : m_settings_layout(NULL) - , m_genListActionBar(NULL) - , m_parent(NULL) - , m_itemClassActionBar(NULL) - , m_item_class(NULL) + : m_settings_layout(nullptr) + , m_genListActionBar(nullptr) + , m_itemClassActionBar(nullptr) + , m_parent(nullptr) + , m_item_class(nullptr) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - edjFilePath = EDJE_DIR; - edjFilePath.append("SettingsUI/SettingsUI.edj"); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SettingsUI/SettingsUI.edj"); } SettingsUI::~SettingsUI() @@ -56,10 +57,9 @@ SettingsUI::~SettingsUI() void SettingsUI::show(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - //m_parent = p; - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_settings_layout = elm_layout_add(parent); - elm_layout_file_set(m_settings_layout, edjFilePath.c_str(), "settings-layout"); + elm_layout_file_set(m_settings_layout, m_edjFilePath.c_str(), "settings-layout"); evas_object_size_hint_weight_set(m_settings_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_settings_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(m_settings_layout); @@ -68,11 +68,10 @@ void SettingsUI::show(Evas_Object* parent) showSettingsGenlist(); } - void SettingsUI::showActionBar() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_genListActionBar = elm_genlist_add(m_settings_layout); elm_object_part_content_set(m_settings_layout, "actionbar_swallow", m_genListActionBar); elm_genlist_homogeneous_set(m_genListActionBar, EINA_FALSE); @@ -84,31 +83,30 @@ void SettingsUI::showActionBar() m_itemClassActionBar = elm_genlist_item_class_new(); m_itemClassActionBar->item_style = "settings_action_bar_items"; - m_itemClassActionBar->func.text_get = NULL; + m_itemClassActionBar->func.text_get = nullptr; m_itemClassActionBar->func.content_get = &listActionBarContentGet; - m_itemClassActionBar->func.state_get = 0; - m_itemClassActionBar->func.del = 0; + m_itemClassActionBar->func.state_get = nullptr; + m_itemClassActionBar->func.del = nullptr; - ItemData * id = new ItemData; + ItemData *id = new ItemData; id->settingsUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item *elmItem = elm_genlist_item_append(m_genListActionBar, //genlist + m_itemClassActionBar, //item Class + id, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id->e_item = elmItem; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - } void SettingsUI::showSettingsGenlist() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_genList = elm_genlist_add(m_settings_layout); elm_object_part_content_set(m_settings_layout, "settings_genlist_swallow", m_genList); elm_genlist_homogeneous_set(m_genList, EINA_FALSE); @@ -117,134 +115,179 @@ void SettingsUI::showSettingsGenlist() elm_genlist_mode_set(m_genList, ELM_LIST_SCROLL); elm_genlist_decorate_mode_set(m_genList, EINA_TRUE); evas_object_size_hint_weight_set(m_genList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_genlist_scroller_policy_set(m_genList, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO); + elm_scroller_policy_set(m_genList, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO); m_item_class = elm_genlist_item_class_new(); m_item_class->item_style = "settings_items"; - m_item_class->func.text_get = NULL; + m_item_class->func.text_get = nullptr; m_item_class->func.content_get = &listSettingsGenlistContentGet; - m_item_class->func.state_get = 0; - m_item_class->func.del = 0; + m_item_class->func.state_get = nullptr; + m_item_class->func.del = nullptr; - ItemData * id = new ItemData; + ItemData *id = new ItemData; id->settingsUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist + Elm_Object_Item *elmItem = elm_genlist_item_append(m_genList, //genlist m_item_class, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + id, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id->e_item = elmItem; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - } Evas_Object* SettingsUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!strcmp(part, "close_click")) - { - Evas_Object *close_click = elm_button_add(obj); - elm_object_style_set(close_click, "basic_button"); - evas_object_smart_callback_add(close_click, "clicked", SettingsUI::close_clicked_cb, data); - return close_click; - } - return NULL; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (obj && part) { + const char *part_name = "close_click"; + static const int part_name_len = strlen(part_name); + if (!strncmp(part_name, part, part_name_len)) { + Evas_Object *close_click = elm_button_add(obj); + elm_object_style_set(close_click, "basic_button"); + evas_object_smart_callback_add(close_click, "clicked", SettingsUI::close_clicked_cb, data); + return close_click; + } + } + return nullptr; } Evas_Object* SettingsUI::listSettingsGenlistContentGet(void* data, Evas_Object* obj , const char* part) { - BROWSER_LOGD("[%s:%d] Part %s", __PRETTY_FUNCTION__, __LINE__, part); - if(!strcmp(part, "del_selected_data_click")) - { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_del_selected_data_clicked_cb, data); - return button; + BROWSER_LOGD("[%s:%d] Part %s", __PRETTY_FUNCTION__, __LINE__, part); + if (obj && part) { + const char * part_name1 = "del_selected_data_click"; + static const int part_name1_len = strlen(part_name1); + if (!strncmp(part_name1, part, part_name1_len)) { + Evas_Object *button = elm_button_add(obj); + elm_object_style_set(button, "basic_button"); + evas_object_smart_callback_add(button, "clicked", SettingsUI::_del_selected_data_clicked_cb, data); + return button; } - else if(!strcmp(part, "reset_mv_click")) - { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_mv_clicked_cb, data); - return button; + + const char * part_name2 = "reset_mv_click"; + static const int part_name2_len = strlen(part_name2); + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *button = elm_button_add(obj); + elm_object_style_set(button, "basic_button"); + evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_mv_clicked_cb, data); + return button; } - else if(!strcmp(part, "reset_browser_click")) - { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_browser_clicked_cb, data); - return button; + + const char * part_name3 = "reset_browser_click"; + static const int part_name3_len = strlen(part_name3); + if (!strncmp(part_name3, part, part_name3_len)) { + Evas_Object *button = elm_button_add(obj); + elm_object_style_set(button, "basic_button"); + evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_browser_clicked_cb, data); + return button; } - else if(!strcmp(part, "cache_cb") || !strcmp(part, "cookies_cb") || !strcmp(part, "history_cb")) + + const char * part_name4 = "cache_cb"; + static const int part_name4_len = strlen(part_name4); + const char * part_name5 = "cookies_cb"; + static const int part_name5_len = strlen(part_name5); + const char * part_name6 = "history_cb"; + static const int part_name6_len = strlen(part_name6); + if (!strncmp(part_name4, part, part_name4_len) || + !strncmp(part_name5, part, part_name5_len) || + !strncmp(part_name6, part, part_name6_len)) { - Evas_Object *checkbox = elm_check_add(obj); - elm_object_style_set(checkbox, "on&off"); - evas_object_smart_callback_add(checkbox, "changed", __check_changed_cb, data); - elm_check_state_set(checkbox, EINA_TRUE); - return checkbox; - } - else if(!strcmp(part, "accept_all_rb") || !strcmp(part, "ask_rb") || !strcmp(part, "sr_disable_rb") || !strcmp(part, "bs_enable_rb") - || !strcmp(part, "bs_disable_rb") || !strcmp(part, "ts_enable_rb") || !strcmp(part, "ts_disable_rb")) + Evas_Object *checkbox = elm_check_add(obj); + elm_object_style_set(checkbox, "on&off"); + evas_object_smart_callback_add(checkbox, "changed", __check_changed_cb, data); + elm_check_state_set(checkbox, EINA_TRUE); + return checkbox; + } + + const char * part_name7 = "accept_all_rb"; + static const int part_name7_len = strlen(part_name7); + const char * part_name8 = "ask_rb"; + static const int part_name8_len = strlen(part_name8); + const char * part_name9 = "sr_disable_rb"; + static const int part_name9_len = strlen(part_name9); + const char * part_name10 = "bs_enable_rb"; + static const int part_name10_len = strlen(part_name10); + const char * part_name11 = "bs_disable_rb"; + static const int part_name11_len = strlen(part_name11); + const char * part_name12 = "ts_enable_rb"; + static const int part_name12_len = strlen(part_name12); + const char * part_name13 = "ts_disable_rb"; + static const int part_name13_len = strlen(part_name13); + if (!strncmp(part_name7, part, part_name7_len) || + !strncmp(part_name8, part, part_name8_len) || + !strncmp(part_name9, part, part_name9_len) || + !strncmp(part_name10, part, part_name10_len) || + !strncmp(part_name11, part, part_name11_len) || + !strncmp(part_name12, part, part_name12_len) || + !strncmp(part_name13, part, part_name13_len)) { - Evas_Object *rb = elm_radio_add(obj); - elm_object_style_set(rb, "on&off"); - //evas_object_smart_callback_add(rb, "changed", __radio_changed_cb, data); - return rb; + Evas_Object *rb = elm_radio_add(obj); + elm_object_style_set(rb, "on&off"); + //evas_object_smart_callback_add(rb, "changed", __radio_changed_cb, data); + return rb; } - return NULL; + } + return nullptr; } -void SettingsUI::__check_changed_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) +void SettingsUI::__check_changed_cb(void*, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - //ItemData * id = static_cast(data); } -void SettingsUI::close_clicked_cb(void* data, Evas_Object* /* obj */, void* /* event_info */) +void SettingsUI::close_clicked_cb(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - id->settingsUI->closeSettingsUIClicked(std::string()); - id->settingsUI->clearItems(); + if (data) { + ItemData * id = static_cast(data); + id->settingsUI->closeSettingsUIClicked(std::string()); + id->settingsUI->clearItems(); + } } void SettingsUI::hide() { - evas_object_hide(elm_layout_content_get(m_settings_layout, "action_bar_swallow")); - evas_object_hide(elm_layout_content_get(m_settings_layout, "settings_genlist_swallow")); - evas_object_hide(m_settings_layout); + evas_object_hide(elm_layout_content_get(m_settings_layout, "action_bar_swallow")); + evas_object_hide(elm_layout_content_get(m_settings_layout, "settings_genlist_swallow")); + evas_object_hide(m_settings_layout); } -void SettingsUI::_del_selected_data_clicked_cb(void * data, Evas_Object * /* obj */, void * event_info) +void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - Evas_Object *cb1 = elm_object_item_part_content_get(itemData->e_item, "cache_cb"); - Evas_Object *cb2 = elm_object_item_part_content_get(itemData->e_item, "cookies_cb"); - Evas_Object *cb3 = elm_object_item_part_content_get(itemData->e_item, "history_cb"); - std::string type; - elm_check_state_get(cb1) ? type += "_CACHE" : ""; - elm_check_state_get(cb2) ? type += "_COOKIES" : ""; - elm_check_state_get(cb3) ? type += "_HISTORY" : ""; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *itemData = static_cast(data); + Evas_Object *cb1 = elm_object_item_part_content_get(itemData->e_item, "cache_cb"); + Evas_Object *cb2 = elm_object_item_part_content_get(itemData->e_item, "cookies_cb"); + Evas_Object *cb3 = elm_object_item_part_content_get(itemData->e_item, "history_cb"); + std::string type; + elm_check_state_get(cb1) ? type += "_CACHE" : ""; + elm_check_state_get(cb2) ? type += "_COOKIES" : ""; + elm_check_state_get(cb3) ? type += "_HISTORY" : ""; itemData->settingsUI->deleteSelectedDataClicked(type); + } } -void SettingsUI::_reset_mv_clicked_cb(void * data, Evas_Object * /* obj */, void * event_info) +void SettingsUI::_reset_mv_clicked_cb(void *data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData* itemData = static_cast(data); itemData->settingsUI->resetMostVisitedClicked(std::string()); + } } -void SettingsUI::_reset_browser_clicked_cb(void * data, Evas_Object * /* obj */, void * event_info) +void SettingsUI::_reset_browser_clicked_cb(void *data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData* itemData = static_cast(data); itemData->settingsUI->resetBrowserClicked(std::string()); + } } void SettingsUI::clearItems() @@ -255,25 +298,5 @@ void SettingsUI::clearItems() elm_genlist_clear(m_genList); } -void SettingsUI::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); - - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); -} - -void SettingsUI::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); - - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); -} - } } diff --git a/services/SettingsUI/SettingsUI.h b/services/SettingsUI/SettingsUI.h index 43bf8d2..c7e8e9f 100644 --- a/services/SettingsUI/SettingsUI.h +++ b/services/SettingsUI/SettingsUI.h @@ -42,9 +42,6 @@ public: void clearItems(); void hide(); - /*boost::signals2::signal tabClicked; - boost::signals2::signal newTabClicked; - boost::signals2::signal newIncognitoTabClicked;*/ boost::signals2::signal resetBrowserClicked; boost::signals2::signal resetMostVisitedClicked; boost::signals2::signal deleteSelectedDataClicked; @@ -74,10 +71,7 @@ private: Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_item_class; - std::string edjFilePath; - - static void focusItem(void* data, Evas_Object* obj, void* event_info); - static void unFocusItem(void* data, Evas_Object* obj, void* event_info); + std::string m_edjFilePath; }; } -- 2.7.4 From 5db881e53c12d44a57d2d5e29c888a1965b70083 Mon Sep 17 00:00:00 2001 From: "t.dakowicz" Date: Tue, 11 Aug 2015 14:46:23 +0200 Subject: [PATCH 06/16] Bug TT-96 Fixed 'Bookmark Manager' button in the More Menu [Issue#] https://bugs.tizen.org/jira/browse/TT-96 [Problem] Bookmark Manager couldn't be accessed from More Menu [Cause] Proper signal wasn't created [Solution] Added signal to MoreMenu class [Verify] Check if Bookmark Manager button does anything Change-Id: Idad6aaa774ad30fb9ff9b0207d4ef2a2004bf751 --- services/MoreMenuUI/MoreMenuUI.cpp | 4 +++- services/MoreMenuUI/MoreMenuUI.h | 1 + services/SimpleUI/SimpleUI.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index 0a61323..2670648 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -452,8 +452,10 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) case SETTINGS: itemData->moreMenuUI->settingsClicked(std::string()); break; - case READER_MODE: case BOOKMARK_MANAGER: + itemData->moreMenuUI->bookmarkManagerClicked(std::string()); + break; + case READER_MODE: case SCREEN_ZOOM: case START_MINIBROWSER: case FOCUS_MODE: diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 7f0812b..a837fad 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -65,6 +65,7 @@ public: void clearItems(); void getBookmarkFolderList(std::vector > ); + boost::signals2::signal bookmarkManagerClicked; boost::signals2::signal historyUIClicked; boost::signals2::signal BookmarkFolderCreated; boost::signals2::signal closeMoreMenuClicked; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 1a2ad29..0ccc4d0 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -1046,7 +1046,7 @@ void SimpleUI::showMainUI() m_mainUI->historyClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); - m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); + m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); m_isHomePageActive = true; } @@ -1107,6 +1107,7 @@ void SimpleUI::showMoreMenu() (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui")); M_ASSERT(m_moreMenuUI); + m_moreMenuUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this, _1)); m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1)); m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1)); m_moreMenuUI->closeMoreMenuClicked.disconnect_all_slots(); -- 2.7.4 From 676726a7652bc9b28a29456e83020f18d156ed11 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Tue, 11 Aug 2015 10:44:06 +0200 Subject: [PATCH 07/16] Refactored HistoryUI service [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] Lots of style fixes, several fixes for build warnings [Cause] n/a [Solution] Reformat code, fix casting and remove unused variables [Verify] 1. Check that there are no build problems caused by this change 2. Run the browser and explore the history ui to see if nothing got broken List of changes: * tabs -> spaces * proper indentation * other minor style fixes * removing unused variables' declarations * renaming a few class members to better express their use * replacing reinterpret_cast with static_cast where appropriate * adding null-checks in callback functions * replacing deprecated Elementary API call with its successor Change-Id: Id2c4c020573138d641a8e6a676942830a6505ab5 --- services/HistoryUI/HistoryUI.cpp | 367 +++++++++++++++++---------------------- services/HistoryUI/HistoryUI.h | 28 +-- 2 files changed, 171 insertions(+), 224 deletions(-) diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index be63ad0..c2724da 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include "HistoryUI.h" @@ -33,43 +35,41 @@ EXPORT_SERVICE(HistoryUI, "org.tizen.browser.historyui") typedef struct _HistoryItemData { - std::shared_ptr item; - std::shared_ptr historyUI; + std::shared_ptr item; + std::shared_ptr historyUI; } HistoryItemData; struct ItemData{ - tizen_browser::base_ui::HistoryUI* historyUI; - Elm_Object_Item * e_item; + tizen_browser::base_ui::HistoryUI* historyUI; + Elm_Object_Item * e_item; }; -static std::vector m_history_item_data; +static std::vector _history_item_data; -#define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) HistoryUI::HistoryUI() - : m_gengrid(NULL) - , m_parent(NULL) - , m_item_class(NULL) - , m_gengridSetup(false) - , m_history_layout(NULL) - , m_historyitem_layout(NULL) - , m_genListActionBar(NULL) - , m_genListToday(NULL) - , m_itemClassToday(NULL) + : m_history_layout(nullptr) + , m_genListActionBar(nullptr) + , m_genListToday(nullptr) + , m_itemClassToday(nullptr) + , m_gengrid(nullptr) + , m_parent(nullptr) + , m_item_class(nullptr) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - edjFilePath = EDJE_DIR; - edjFilePath.append("HistoryUI/History.edj"); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("HistoryUI/History.edj"); } HistoryUI::~HistoryUI() { + } void HistoryUI::show(Evas_Object* parent) { - elm_theme_extension_add(NULL, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); m_history_layout = elm_layout_add(parent); - elm_layout_file_set(m_history_layout, edjFilePath.c_str(), "history-layout"); + elm_layout_file_set(m_history_layout, m_edjFilePath.c_str(), "history-layout"); evas_object_size_hint_weight_set(m_history_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_history_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(m_history_layout); @@ -79,41 +79,36 @@ void HistoryUI::show(Evas_Object* parent) m_gengrid = elm_gengrid_add(m_history_layout); elm_object_part_content_set(m_history_layout, "history_gengird", m_gengrid); - /*evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, NULL); - evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, NULL); - evas_object_smart_callback_add(m_gengrid, "activated", _itemSelected, this);*/ - - if (!m_item_class) { - m_item_class = elm_gengrid_item_class_new(); - m_item_class->item_style = "history_item"; - m_item_class->func.text_get = _grid_text_get; - m_item_class->func.content_get = _history_grid_content_get; - m_item_class->func.state_get = NULL; - m_item_class->func.del = NULL; - } + if (!m_item_class) { + m_item_class = elm_gengrid_item_class_new(); + m_item_class->item_style = "history_item"; + m_item_class->func.text_get = _grid_text_get; + m_item_class->func.content_get = _history_grid_content_get; + m_item_class->func.state_get = nullptr; + m_item_class->func.del = nullptr; + } - M_ASSERT(m_parent); - elm_gengrid_align_set(m_gengrid, 0, 0); - elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); - elm_gengrid_horizontal_set(m_gengrid, EINA_TRUE); - elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON); - elm_scroller_page_size_set(m_gengrid, 0, 580); + elm_gengrid_align_set(m_gengrid, 0, 0); + elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); + elm_gengrid_horizontal_set(m_gengrid, EINA_TRUE); + elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); + elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON); + elm_scroller_page_size_set(m_gengrid, 0, 580); - evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); + double efl_scale = elm_config_scale_get() / elm_app_base_scale_get(); elm_gengrid_item_size_set(m_gengrid, 580 * efl_scale, 580 * efl_scale); addItems(); - } void HistoryUI::showActionBar() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, edjFilePath.c_str()); + 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); @@ -125,98 +120,106 @@ void HistoryUI::showActionBar() m_itemClassActionBar = elm_genlist_item_class_new(); m_itemClassActionBar->item_style = "action_bar_history_items"; - m_itemClassActionBar->func.text_get = NULL; // &listTopItemTextGet; - m_itemClassActionBar->func.content_get = &listActionBarContentGet; - m_itemClassActionBar->func.state_get = 0; - m_itemClassActionBar->func.del = 0; + m_itemClassActionBar->func.text_get = nullptr; // &listTopItemTextGet; + m_itemClassActionBar->func.content_get = &_listActionBarContentGet; + m_itemClassActionBar->func.state_get = nullptr; + m_itemClassActionBar->func.del = nullptr; - ItemData * id = new ItemData; + ItemData *id = new ItemData; id->historyUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item *elmItem = elm_genlist_item_append(m_genListActionBar, //genlist + m_itemClassActionBar, //item Class + id, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id->e_item = elmItem; - ItemData * id2 = new ItemData; + ItemData *id2 = new ItemData; id2->historyUI = this; - Elm_Object_Item* elmItem2 = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id2, - NULL, //parent item - ELM_GENLIST_ITEM_NONE,//item type - NULL, - NULL //data passed to above function - ); + Elm_Object_Item *elmItem2 = elm_genlist_item_append(m_genListActionBar, //genlist + m_itemClassActionBar, //item Class + id2, + nullptr, //parent item + ELM_GENLIST_ITEM_NONE, //item type + nullptr, + nullptr //data passed to above function + ); id2->e_item = elmItem2; } -Evas_Object* HistoryUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) +Evas_Object* HistoryUI::_listActionBarContentGet(void* data, Evas_Object* obj , const char* part) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!strcmp(part, "clearhistory_click")) - { - Evas_Object *clearHistoryButton = elm_button_add(obj); - elm_object_style_set(clearHistoryButton, "history_button"); - evas_object_smart_callback_add(clearHistoryButton, "clicked", tizen_browser::base_ui::HistoryUI::_clearhistory_clicked, data); - return clearHistoryButton; + 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", tizen_browser::base_ui::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; } - else if(!strcmp(part, "close_click")) - { - 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 NULL; + } + return nullptr; } -void HistoryUI::close_clicked_cb(void * data, Evas_Object * /* obj */, void * event_info) +void HistoryUI::_close_clicked_cb(void * data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData * id = static_cast(data); - id->historyUI->closeHistoryUIClicked(std::string()); - id->historyUI->clearItems(); -} + if (data) { + ItemData *id = static_cast(data); + id->historyUI->closeHistoryUIClicked(std::string()); + id->historyUI->clearItems(); + } +} -char* HistoryUI::listTodayTextGet(void* data, Evas_Object* obj , const char* part) +char* HistoryUI::_listTodayTextGet(void* data, Evas_Object*, const char* part) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - HistoryItemData * id = static_cast(data); - if(!strcmp(part, "history_url_text")) - { - if(!id->item->getUrl().empty()){ - std::string str = id->item->getTitle() + " - " + id->item->getUrl(); - return strdup(str.c_str()); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + HistoryItemData *id = static_cast(data); + const char *part_name = "history_url_text"; + static const int part_name_len = strlen(part_name); + + if (!strncmp(part_name, part, part_name_len)) { + if (!id->item->getUrl().empty()) { + std::string str = id->item->getTitle() + " - " + id->item->getUrl(); + return strdup(str.c_str()); + } } } - return NULL; + return nullptr; } -void HistoryUI::_clearhistory_clicked(void * data, Evas_Object * /* obj */, void * event_info) +void HistoryUI::_clearhistory_clicked(void*, Evas_Object*, void*) { - /* - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->tabUI->clearItems(); - itemData->tabUI->newTabClicked(std::string()); - */ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); +// ItemData *itemData = static_cast(data); +// itemData->tabUI->clearItems(); +// itemData->tabUI->newTabClicked(std::string()); } void HistoryUI::addItems() { - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - for (size_t i = 0; i < 1; i++) { - HistoryItemData *itemData = new HistoryItemData(); - itemData->historyUI = std::shared_ptr(this); - Elm_Object_Item* historyView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, NULL, this); - elm_gengrid_item_selected_set(historyView, EINA_FALSE); - } - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + for (size_t i = 0; i < 1; i++) { + HistoryItemData *itemData = new HistoryItemData(); + itemData->historyUI = std::shared_ptr(this); + Elm_Object_Item* historyView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, nullptr, this); + elm_gengrid_item_selected_set(historyView, EINA_FALSE); + } + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); } void HistoryUI::addHistoryItem(std::shared_ptr hi) @@ -225,68 +228,71 @@ void HistoryUI::addHistoryItem(std::shared_ptritem = hi; itemData->historyUI = std::shared_ptr(this); - m_history_item_data.push_back(itemData); + _history_item_data.push_back(itemData); setEmptyGengrid(false); } void HistoryUI::addHistoryItems(std::vector > items) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - m_history_item_data.clear(); + _history_item_data.clear(); for (auto it = items.begin(); it != items.end(); ++it) - addHistoryItem(*it); + addHistoryItem(*it); } -char* HistoryUI::_grid_text_get(void *data, Evas_Object *obj, const char *part) +char* HistoryUI::_grid_text_get(void*, Evas_Object*, const char *part) { BROWSER_LOGD("%s:%d %s part=%s", __FILE__, __LINE__, __func__, part); - HistoryItemData *itemData = reinterpret_cast(data); - const char* item_name = NULL; - if (!strcmp(part, "menu_label")) { - item_name = "Today"; - return strdup(item_name); + const char* part_name = "menu_label"; + static const int part_name_len = strlen(part_name); + + if (!strncmp(part_name, part, part_name_len)) { + return strdup("Today"); } - return NULL; + return nullptr; } -Evas_Object * HistoryUI::_history_grid_content_get(void *data, Evas_Object *obj, const char *part) +Evas_Object * HistoryUI::_history_grid_content_get(void *data, Evas_Object*, const char *part) { BROWSER_LOGD("[%s:%d] part : %s", __PRETTY_FUNCTION__, __LINE__, part); - HistoryItemData * id = static_cast(data); - if(!strcmp(part, "history_genlist")) - { - id->historyUI->m_genListToday = elm_genlist_add(id->historyUI->m_history_layout); - - elm_genlist_homogeneous_set(id->historyUI->m_genListToday, EINA_FALSE); - elm_genlist_multi_select_set(id->historyUI->m_genListToday, EINA_FALSE); - elm_genlist_select_mode_set(id->historyUI->m_genListToday, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(id->historyUI->m_genListToday, ELM_LIST_LIMIT); - elm_genlist_decorate_mode_set(id->historyUI->m_genListToday, EINA_TRUE); - evas_object_size_hint_weight_set(id->historyUI->m_genListToday, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - id->historyUI->m_itemClassToday = elm_genlist_item_class_new(); - id->historyUI->m_itemClassToday->item_style = "history_url_items"; - id->historyUI->m_itemClassToday->func.text_get = &listTodayTextGet; - id->historyUI->m_itemClassToday->func.content_get = NULL; - id->historyUI->m_itemClassToday->func.state_get = 0; - id->historyUI->m_itemClassToday->func.del = 0; - - for(auto it = m_history_item_data.begin(); it != m_history_item_data.end(); it++) { - Elm_Object_Item* historyView = elm_genlist_item_append(id->historyUI->m_genListToday, id->historyUI->m_itemClassToday, *it, NULL, ELM_GENLIST_ITEM_NONE, NULL, id->historyUI.get()); - id->historyUI->m_map_history_views.insert(std::pair((*it)->item->getUrl(), historyView)); - } - - return id->historyUI->m_genListToday; + if (data && part) { + HistoryItemData *id = static_cast(data); + const char *part_name = "history_genlist"; + static const int part_name_len = strlen(part_name); + + if(!strncmp(part_name, part, part_name_len)) { + id->historyUI->m_genListToday = elm_genlist_add(id->historyUI->m_history_layout); + + elm_genlist_homogeneous_set(id->historyUI->m_genListToday, EINA_FALSE); + elm_genlist_multi_select_set(id->historyUI->m_genListToday, EINA_FALSE); + elm_genlist_select_mode_set(id->historyUI->m_genListToday, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(id->historyUI->m_genListToday, ELM_LIST_LIMIT); + elm_genlist_decorate_mode_set(id->historyUI->m_genListToday, EINA_TRUE); + evas_object_size_hint_weight_set(id->historyUI->m_genListToday, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + id->historyUI->m_itemClassToday = elm_genlist_item_class_new(); + id->historyUI->m_itemClassToday->item_style = "history_url_items"; + id->historyUI->m_itemClassToday->func.text_get = &_listTodayTextGet; + id->historyUI->m_itemClassToday->func.content_get = nullptr; + id->historyUI->m_itemClassToday->func.state_get = nullptr; + id->historyUI->m_itemClassToday->func.del = nullptr; + + for(auto it = _history_item_data.begin(); it != _history_item_data.end(); it++) { + Elm_Object_Item* historyView = elm_genlist_item_append(id->historyUI->m_genListToday, id->historyUI->m_itemClassToday, *it, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, id->historyUI.get()); + id->historyUI->m_map_history_views.insert(std::pair((*it)->item->getUrl(), historyView)); + } + + return id->historyUI->m_genListToday; + } } - return NULL; + return nullptr; } void HistoryUI::removeHistoryItem(const std::string& uri) { BROWSER_LOGD("[%s] uri=%s", __func__, uri.c_str()); - if(m_map_history_views.find(uri) == m_map_history_views.end()) { + if(m_map_history_views.find(uri) == m_map_history_views.end()) return; - } Elm_Object_Item* historyView = m_map_history_views.at(uri); elm_object_item_del(historyView); @@ -295,34 +301,9 @@ void HistoryUI::removeHistoryItem(const std::string& uri) setEmptyGengrid(0 == m_map_history_views.size()); } -void HistoryUI::_item_deleted(void * /* data */, Evas_Object * /* obj */) -{ - -} - -void HistoryUI::_itemSelected(void * data, Evas_Object * /* obj */, void * event_info) -{ - Elm_Object_Item * selected = reinterpret_cast(event_info); - HistoryItemData * itemData = reinterpret_cast(elm_object_item_data_get(selected)); - HistoryUI * self = reinterpret_cast(data); - - self->historyItemClicked(itemData->item); -} - -void HistoryUI::_deleteHistory(void *data, Evas_Object * /* obj */, void * /* event_info */) -{ - HistoryItemData * itemData = reinterpret_cast(data); - //itemData->historysUI->historyDeleteClicked(itemData->item); -} - -void HistoryUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - HistoryItemData * itemData = reinterpret_cast(data); - // itemData->historysUI->historyClicked(itemData->item); -} - -Evas_Object* HistoryUI::createNoHistorysLabel() +Evas_Object* HistoryUI::createNoHistoryLabel() { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); Evas_Object *label = elm_label_add(m_parent); elm_object_text_set(label, "No favorite websites."); evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -332,11 +313,9 @@ Evas_Object* HistoryUI::createNoHistorysLabel() void HistoryUI::setEmptyGengrid(bool setEmpty) { - if(setEmpty) { - elm_object_part_content_set(m_gengrid, "elm.swallow.empty", createNoHistorysLabel()); - } else { - elm_object_part_content_set(m_gengrid, "elm.swallow.empty", NULL); - } + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *obj = (setEmpty ? createNoHistoryLabel() : nullptr); + elm_object_part_content_set(m_gengrid, "elm.swallow.empty", obj); } void HistoryUI::hide() @@ -350,35 +329,15 @@ void HistoryUI::hide() void HistoryUI::clearItems() { - hide(); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + hide(); elm_genlist_clear(m_genListToday); elm_gengrid_clear(m_gengrid); elm_genlist_clear(m_genListActionBar); m_map_history_views.clear(); - m_history_item_data.clear(); + _history_item_data.clear(); setEmptyGengrid(true); } -void HistoryUI::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); - - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); -} - -void HistoryUI::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); - - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); -} - } } diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 89c26a3..20bcc53 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -30,8 +30,8 @@ namespace tizen_browser{ namespace base_ui{ class BROWSER_EXPORT HistoryUI - : public tizen_browser::interfaces::AbstractUIComponent - , public tizen_browser::core::AbstractService + : public tizen_browser::interfaces::AbstractUIComponent + , public tizen_browser::core::AbstractService { public: HistoryUI(); @@ -53,21 +53,14 @@ private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _history_grid_content_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); - static Evas_Object* listActionBarContentGet(void *data, Evas_Object *obj, const char *part); - static Evas_Object* listTodayContentGet(void *data, Evas_Object *obj, const char *part); - static void _itemSelected(void * data, Evas_Object * obj, void * event_info); - static void _item_deleted(void *data, Evas_Object *obj); - static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); - static void _deleteHistory(void *data, Evas_Object *obj, void *event_info); + static Evas_Object* _listActionBarContentGet(void *data, Evas_Object *obj, const char *part); static void _clearhistory_clicked(void *data, Evas_Object *obj, void *event_info); + static char* _listTodayTextGet(void* data, Evas_Object* obj , const char* part); + static void _close_clicked_cb(void *data, Evas_Object *obj, void *event_info); + void setEmptyGengrid(bool setEmpty); - static char* listTodayTextGet(void* data, Evas_Object* obj , const char* part); - static void close_clicked_cb(void *data, Evas_Object *obj, void *event_info); -private: - Evas_Object *m_history_layout; - Evas_Object *m_historyitem_layout; Evas_Object *m_genListActionBar; Evas_Object *m_genListToday; Elm_Genlist_Item_Class *m_itemClassActionBar; @@ -76,15 +69,10 @@ private: Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_item_class; std::map m_map_history_views; - bool m_gengridSetup; - std::string edjFilePath; - Evas_Object *createNoHistorysLabel(); - - static void focusItem(void* data, Evas_Object* obj, void* event_info); - static void unFocusItem(void* data, Evas_Object* obj, void* event_info); + std::string m_edjFilePath; + Evas_Object *createNoHistoryLabel(); }; - } } -- 2.7.4 From 146f90a4a967dab0c4c5ffaa1e2cca48568b5328 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Wed, 12 Aug 2015 14:03:09 +0200 Subject: [PATCH 08/16] Improve sizes of tiles, remove unneeded medium style, small refactoring of white spaces. [Issue#] https://bugs.tizen.org/jira/browse/TT-73 [Problem] Sizes of most visited tiles were wrong. [Cause] N/A [Solution] Fixed style for small tiles, removed style for medium tiles. [Verify] Check if Most visited view has proper tiles sizes. Change-Id: I4d884e3d099056e553c99b492469b8abb03d8b16 Signed-off-by: Maciej Skrzypkowski --- services/MainUI/MainUI.cpp | 122 ++++++------- services/MainUI/MainUI.h | 7 +- services/MainUI/edc/MainUI.edc | 388 ++++++++++++----------------------------- 3 files changed, 170 insertions(+), 347 deletions(-) diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index d45d22c..173e306 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -30,6 +30,8 @@ namespace tizen_browser{ namespace base_ui{ +const int SMALL_TILES_ROWS = 2; + EXPORT_SERVICE(MainUI, "org.tizen.browser.mainui") typedef struct _HistoryItemData @@ -56,7 +58,6 @@ MainUI::MainUI() , m_genListBottom(nullptr) , m_parent(nullptr) , m_big_item_class(nullptr) - , m_medium_item_class(nullptr) , m_small_item_class(nullptr) , m_bookmark_item_class(nullptr) { @@ -80,29 +81,29 @@ void MainUI::show(Evas_Object* parent) evas_object_show(m_layout); m_parent = m_layout; - m_genListMVBig = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.mvBig", m_genListMVBig); - elm_genlist_homogeneous_set(m_genListMVBig, EINA_FALSE); - elm_genlist_multi_select_set(m_genListMVBig, EINA_FALSE); - elm_genlist_select_mode_set(m_genListMVBig, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListMVBig, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListMVBig, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - m_genListMVMedium = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.mvMedium", m_genListMVMedium); - elm_genlist_homogeneous_set(m_genListMVMedium, EINA_FALSE); - elm_genlist_multi_select_set(m_genListMVMedium, EINA_FALSE); - elm_genlist_select_mode_set(m_genListMVMedium, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListMVMedium, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListMVMedium, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - m_genListMVSmall = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.mvSmall", m_genListMVSmall); - elm_genlist_homogeneous_set(m_genListMVSmall, EINA_FALSE); - elm_genlist_multi_select_set(m_genListMVSmall, EINA_FALSE); - elm_genlist_select_mode_set(m_genListMVSmall, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListMVSmall, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListMVSmall, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + m_genListLeft = elm_genlist_add(m_layout); + elm_object_part_content_set(m_layout, "elm.swallow.left", m_genListLeft); + elm_genlist_homogeneous_set(m_genListLeft, EINA_FALSE); + elm_genlist_multi_select_set(m_genListLeft, EINA_FALSE); + elm_genlist_select_mode_set(m_genListLeft, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(m_genListLeft, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(m_genListLeft, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + m_genListCenter = elm_genlist_add(m_layout); + elm_object_part_content_set(m_layout, "elm.swallow.center", m_genListCenter); + elm_genlist_homogeneous_set(m_genListCenter, EINA_FALSE); + elm_genlist_multi_select_set(m_genListCenter, EINA_FALSE); + elm_genlist_select_mode_set(m_genListCenter, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(m_genListCenter, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(m_genListCenter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + m_genListRight = elm_genlist_add(m_layout); + elm_object_part_content_set(m_layout, "elm.swallow.right", m_genListRight); + elm_genlist_homogeneous_set(m_genListRight, EINA_FALSE); + elm_genlist_multi_select_set(m_genListRight, EINA_FALSE); + elm_genlist_select_mode_set(m_genListRight, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(m_genListRight, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(m_genListRight, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); if (!m_big_item_class) { m_big_item_class = elm_genlist_item_class_new(); @@ -113,15 +114,6 @@ void MainUI::show(Evas_Object* parent) m_big_item_class->func.del = nullptr; } - if (!m_medium_item_class) { - m_medium_item_class = elm_genlist_item_class_new(); - m_medium_item_class->item_style = "medium_grid_item"; - m_medium_item_class->func.text_get = _grid_text_get; - m_medium_item_class->func.content_get = _grid_content_get; - m_medium_item_class->func.state_get = nullptr; - m_medium_item_class->func.del = nullptr; - } - if (!m_small_item_class) { m_small_item_class = elm_genlist_item_class_new(); m_small_item_class->item_style = "small_grid_item"; @@ -222,7 +214,6 @@ void MainUI::showBottomButton() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); elm_theme_extension_add(nullptr, edjFilePath.c_str()); m_genListBottom = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.genlistBottom", m_genListBottom); elm_genlist_homogeneous_set(m_genListBottom, EINA_FALSE); elm_genlist_multi_select_set(m_genListBottom, EINA_FALSE); elm_genlist_select_mode_set(m_genListBottom, ELM_OBJECT_SELECT_MODE_ALWAYS); @@ -318,22 +309,16 @@ void MainUI::addHistoryItem(std::shared_ptrmainUI = std::shared_ptr(this); Elm_Object_Item* historyView = nullptr; - switch(m_map_history_views.size()) + if (m_map_history_views.empty()) { - case 0: - BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); - historyView = elm_genlist_item_append(m_genListMVBig, m_big_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); - break; - case 1: - case 2: - BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); - historyView = elm_genlist_item_append(m_genListMVMedium, m_medium_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); - break; - case 3: - case 4: - BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); - historyView = elm_genlist_item_append(m_genListMVSmall, m_small_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); - break; + BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); + historyView = elm_genlist_item_append(m_genListLeft, m_big_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); + } else if (m_map_history_views.size() <= SMALL_TILES_ROWS) { + BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); + historyView = elm_genlist_item_append(m_genListCenter, m_small_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); + } else { + BROWSER_LOGD("%s:%d %s m_map_history_views.size %d", __FILE__, __LINE__, __func__, m_map_history_views.size()); + historyView = elm_genlist_item_append(m_genListRight, m_small_item_class, itemData, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); } m_map_history_views.insert(std::pair(hi->getUrl(),historyView)); @@ -463,22 +448,24 @@ void MainUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* even void MainUI::clearHistoryGenlist() { - elm_genlist_clear(m_genListMVSmall); - elm_genlist_clear(m_genListMVBig); - elm_genlist_clear(m_genListMVMedium); + elm_genlist_clear(m_genListRight); + elm_genlist_clear(m_genListLeft); + elm_genlist_clear(m_genListCenter); m_map_history_views.clear(); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvBig")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvSmall")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvMedium")); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.left")); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.right")); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.center")); } void MainUI::showHistoryGenlist() { - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.grid")); - elm_object_part_content_unset(m_layout, "elm.swallow.grid"); - elm_object_part_content_set(m_layout, "elm.swallow.mvBig", m_genListMVBig); - elm_object_part_content_set(m_layout, "elm.swallow.mvSmall", m_genListMVSmall); - elm_object_part_content_set(m_layout, "elm.swallow.mvMedium", m_genListMVMedium); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.grid")); + elm_object_part_content_unset(m_layout, "elm.swallow.grid"); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.genlistBottom")); + elm_object_part_content_unset(m_layout, "elm.swallow.genlistBottom"); + elm_object_part_content_set(m_layout, "elm.swallow.left", m_genListLeft); + elm_object_part_content_set(m_layout, "elm.swallow.right", m_genListRight); + elm_object_part_content_set(m_layout, "elm.swallow.center", m_genListCenter); } void MainUI::clearBookmarkGengrid() @@ -490,13 +477,14 @@ void MainUI::clearBookmarkGengrid() void MainUI::showBookmarkGengrid() { - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvBig")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvSmall")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.mvMedium")); - elm_object_part_content_unset(m_layout, "elm.swallow.mvBig"); - elm_object_part_content_unset(m_layout, "elm.swallow.mvSmall"); - elm_object_part_content_unset(m_layout, "elm.swallow.mvMedium"); - elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.left")); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.right")); + evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.center")); + elm_object_part_content_unset(m_layout, "elm.swallow.left"); + elm_object_part_content_unset(m_layout, "elm.swallow.right"); + elm_object_part_content_unset(m_layout, "elm.swallow.center"); + elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); + elm_object_part_content_set(m_layout, "elm.swallow.genlistBottom", m_genListBottom); } void MainUI::hide() diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index c0beb25..bd77d53 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -77,9 +77,9 @@ private: static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info); private: Evas_Object *m_genListTop; - Evas_Object *m_genListMVBig; - Evas_Object *m_genListMVMedium; - Evas_Object *m_genListMVSmall; + Evas_Object *m_genListLeft; + Evas_Object *m_genListCenter; + Evas_Object *m_genListRight; Elm_Genlist_Item_Class *m_itemClassTop; Evas_Object *m_genListBottom; Elm_Genlist_Item_Class *m_itemClassBottom; @@ -87,7 +87,6 @@ private: Evas_Object *m_layout; Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_big_item_class; - Elm_Gengrid_Item_Class * m_medium_item_class; Elm_Gengrid_Item_Class * m_small_item_class; Elm_Gengrid_Item_Class * m_bookmark_item_class; std::multimap m_map_history_views; diff --git a/services/MainUI/edc/MainUI.edc b/services/MainUI/edc/MainUI.edc index 8357ec7..f094d4e 100644 --- a/services/MainUI/edc/MainUI.edc +++ b/services/MainUI/edc/MainUI.edc @@ -141,37 +141,38 @@ group { name: "mv_bookmarks"; type: RECT; mouse_events: 0; description { state: "default" 0.0; - color: 255 255 255 255; - min: 1920 181; - max: 1920 181; - align: 0.0 0.0; + color: 255 255 255 255; + min: 0 181; + max: -1 181; + align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 0; offset: 0 104; + relative: 0 0; offset: 0 104; } rel2{ - relative: 1 1; + relative: 1 1; } } } - part { name: "gengrid_bg"; + part { name: "gengrid_bg"; type: RECT; mouse_events: 0; description { state: "default" 0.0; - color: 255 255 255 255; - min: 1920 626; - max: 1920 626; - align: 0.0 0.0; + color: 255 255 255 255; + min: 1920 626; + max: -1 626; + align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 1; to: "genlistTop_bg"; + to: "genlistTop_bg"; + relative: 0 1; } rel2{ - relative: 1 1; + relative: 1 1; } } } - part { name: "genlistBottom_bg"; + part { name: "genlistBottom_bg"; type: RECT; mouse_events: 0; description { state: "default" 0.0; @@ -205,15 +206,33 @@ group { name: "mv_bookmarks"; } } } - part { name: "elm.swallow.mvBig"; + + part { name: "most_visited"; + type: RECT; + description { state: "default" 0.0; + min: 1592 614; + max: 1592 614; + visible: 0; + align: 0.5 0.0; + rel1 { + to: "gengrid_bg"; + relative: 0 0; + } + rel2 { + to: "gengrid_bg"; + relative: 1 1; + } + } + } + part { name: "elm.swallow.left"; type: SWALLOW; description { state: "default" 0.0; - min: 800 626; - max: 800 626; + min: 784 614; + max: 784 614; align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 0; to: "gengrid_bg"; offset: 63 0; + relative: 0 0; to: "most_visited"; } rel2 { relative: 1 1; @@ -221,38 +240,44 @@ group { name: "mv_bookmarks"; } } } - part { name: "elm.swallow.mvMedium"; + part { name: "elm.swallow.center"; type: SWALLOW; description { state: "default" 0.0; - min: 600 626; - max: 600 626; + min: 378 614; + max: 378 614; align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 0; to: "gengrid_bg"; offset: 889 0; + to: "most_visited"; + relative: 0 0; + offset: 810 0; } rel2{ + to: "most_visited"; relative: 1 1; offset: 0 0; } - } - } - part { name: "elm.swallow.mvSmall"; + } + } + part { name: "elm.swallow.right"; type: SWALLOW; description { state: "default" 0.0; - min: 342 626; - max: 342 626; + min: 378 614; + max: 378 614; align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 0; to: "gengrid_bg"; offset: 1515 0; + to: "most_visited"; + relative: 0 0; + offset: 1214 0; } rel2 { + to: "most_visited"; relative: 1 1; offset: 0 0; } } - } + } part { name: "elm.swallow.genlistTop"; type: SWALLOW; @@ -331,11 +356,10 @@ group { name: "elm/genlist/item/big_grid_item/default"; type: RECT; mouse_events: 0; description { state: "default" 0.0; - min: 800 613; - max: 800 613; + min: 784 614; + max: 784 614; visible: 1; color: 231 231 231 255; - rel1.offset: 0 13; } description { state: "selected"; inherit: "default" 0.0; @@ -349,8 +373,8 @@ group { name: "elm/genlist/item/big_grid_item/default"; fixed: 1 0; align: 0.0 0.0; color : 231 231 231 255; - min: 800 526; - max: 800 526; + min: 784 526; + max: 784 526; rel1 { relative: 0.0 0.0; to: "bg"; } @@ -389,8 +413,8 @@ group { name: "elm/genlist/item/big_grid_item/default"; part { name: "background"; type: RECT; description { state: "default" 0.0; - min: 800 87; - max: 800 87; + min: 784 87; + max: 784 87; align: 0.0 0.0; color: 231 231 231 255; rel1 { @@ -522,7 +546,7 @@ group { name: "elm/genlist/item/big_grid_item/default"; } } -group { name: "elm/genlist/item/medium_grid_item/default"; +group { name: "elm/genlist/item/small_grid_item/default"; data.item: "texts" "page_title page_url"; data.item: "contents" "elm.thumbnail elm.thumbButton"; images { @@ -530,218 +554,30 @@ group { name: "elm/genlist/item/medium_grid_item/default"; image: "ico_bg_round_shape_37x37.png" COMP; } parts { + part { name: "border"; + type: RECT; + description { state: "default" 0.0; + min: 378 320; + max: 378 320; + visible: 0; + } + } + part { name: "bg"; type: RECT; mouse_events: 0; description { state: "default" 0.0; - min: 600 300; - max: 600 300; + min: 378 294; + max: 378 294; visible: 1; color: 231 231 231 255; - rel1.offset: 0 13; - } - description { state: "selected"; - inherit: "default" 0.0; - color: 70 143 254 255; - } - } - - part { name: "elm.thumbnail"; - type: SWALLOW; - description { state: "default" 0.0; - fixed: 1 0; - align: 0.0 0.0; - color : 231 231 231 255; - min: 600 203; - max: 600 203; - rel1 { - relative: 0.0 0.0; to: "bg"; - } - rel2 { - relative: 1.0 1.0; to: "bg"; - } - } - description { state: "selected"; - inherit: "default" 0.0; - } - } - - part { name: "focus_highlight"; - type: IMAGE; - description { state: "default" 0.0; - rel1 { - to: "elm.thumbnail"; - relative: 0.0 0.0; - } - rel2 { - to: "elm.thumbnail"; - relative: 1.0 1.0; - } - image.normal: "web_frame_selected.png"; - image.border: 8 8 8 0; - image.border_scale: 1; - image.middle: NONE; - visible: 0; - } - description { state: "selected"; - inherit: "default" 0.0; - visible: 1; - } - } - - part { name: "background"; - type: RECT; - description { state: "default" 0.0; - min: 600 87; - max: 600 87; - align: 0.0 0.0; - color: 231 231 231 255; - rel1 { - to: "elm.thumbnail"; - relative: 0.0 1.0; - } - rel2 { - relative: 1.0 1.0; - } - } - description { state: "selected" 0.0; - inherit: "default" 0.0; - color: 70 143 254 255; - } - } - - part { name: "page_title"; - type: TEXT; - description { state: "default" 0.0; - min: 500 48; - max: 500 48; - align: 0.0 0.5; - rel1 { - to: "background"; - relative: 0.0 0.0; - offset: 17 0; - } - rel2 { - to: "background"; - relative: 1.0 1.0; - } - color: 51 51 51 255; - text { - text: "Web page title"; - font: "Sans"; - size: 27; - align: 0 0.5; - } + align: 0.0 0.0; + rel1 { + relative: 0.0 0.0; to: "border"; } - description { state: "focus" 0.0; - inherit: "default" 0.0; - //color: focusTextColor; + rel2 { + relative: 1.0 1.0; to: "border"; } - description { state: "highlight" 0.0; - inherit: "default" 0.0; - //color: highlightTextColor; - } - } - - part { name: "page_url"; - type: TEXT; - description { state: "default" 0.0; - min: 500 48; - max: 500 48; - align: 0 0.5; - rel1 { - to: "page_title"; - relative: 0.0 1.0; - } - rel2 { - to: "page_title"; - relative: 1.0 1.0; - } - color: 153 153 153 255; - text { - text: "Web page url"; - font: "Sans"; - size: 24; - align: 0 0.5; - } - } - description { state: "focus" 0.0; - inherit: "default" 0.0; - //color: focusTextColor; - } - description { state: "highlight" 0.0; - inherit: "default" 0.0; - //color: highlightTextColor; - } - } - - part { name: "elm.thumbButton"; - type: SWALLOW; - description { state: "default" 0.0; - rel1.to: "elm.thumbnail"; - rel2.to: "elm.thumbnail"; - } - } - - part { name: "over2"; - type: RECT; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - color: 0 0 0 0; - rel1.to: "bg"; - rel2.to: "background"; - } - } - part { name: "over3"; - type: RECT; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - color: 0 0 0 0; - rel1.to: "background"; - rel2.to: "background"; - } - } - } - - programs{ - program { name: "mouse_in"; - signal: "mouse,in"; - source: "over2"; - action: STATE_SET "selected" 0.0; - target: "background"; - target: "focus_highlight"; - target: "bg"; - } - program { name: "mouse_out"; - signal: "mouse,out"; - source: "over2"; - action: STATE_SET "default" 0.0; - target: "background"; - target: "focus_highlight"; - target: "bg"; - } - } -} - -group { name: "elm/genlist/item/small_grid_item/default"; - data.item: "texts" "page_title page_url"; - data.item: "contents" "elm.thumbnail elm.thumbButton"; - images { - image: "web_frame_selected.png" COMP; - image: "ico_bg_round_shape_37x37.png" COMP; - } - parts { - part { name: "bg"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - min: 342 300; - max: 342 300; - visible: 1; - color: 231 231 231 255; - rel1.offset: 0 13; } description { state: "selected"; inherit: "default" 0.0; @@ -1137,7 +973,7 @@ group { name: "elm/genlist/item/top_button_item/default"; data.item: "texts" "mostvisited_text bookmark_text"; data.item: "contents" "mostvisited_click bookmark_click"; parts{ - part { + part { name: "bg_clipper"; scale:1; mouse_events: 1; @@ -1152,7 +988,7 @@ group { name: "elm/genlist/item/top_button_item/default"; rel2 { relative: 1.0 1.0;} } } - part { + part { name: "mostvisited_button"; scale:1; mouse_events: 1; @@ -1163,8 +999,8 @@ group { name: "elm/genlist/item/top_button_item/default"; fixed: 1 1; color: 192 192 192 255; align: 0 0; - min: 348 65; - max: 348 65; + min: 348 64; + max: 348 64; rel1 { relative: 0.0 0.0; to: "bg_clipper"; offset: 611 58;} rel2 { relative: 1.0 1.0; to: "bg_clipper"; } } @@ -1174,14 +1010,14 @@ group { name: "elm/genlist/item/top_button_item/default"; color_class: focusBgColor; visible: 1; } - description { + description { state: "focus" 0.0; inherit: "default" 0.0; color_class: focusbtBgColor; visible: 1; } } - part{ + part{ name: "mostvisited_text"; type: TEXT; scale: 1; @@ -1191,7 +1027,7 @@ group { name: "elm/genlist/item/top_button_item/default"; rel1 { relative: 0.0 0.0;to: "mostvisited_button";} rel2 { relative: 1.0 1.0;to: "mostvisited_button";} color: 0 0 0 255; - text { + text { text: "Most visited"; font: "Sans"; size: 27; @@ -1199,7 +1035,7 @@ group { name: "elm/genlist/item/top_button_item/default"; } } } - part { + part { name: "mostvisited_over"; scale:1; type: RECT; @@ -1209,14 +1045,14 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; + min: 348 64; + max: 348 64; rel1 { relative: 0.0 0.0; to: "mostvisited_button";} rel2 { relative: 1.0 1.0; to: "mostvisited_button";} color_class: transparent; } } - part { + part { name: "mostvisited_click"; scale:1; type: SWALLOW; @@ -1226,13 +1062,13 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; - rel1 { relative: 0.0 0.0; to: "mostvisited_over";} - rel2 { relative: 1.0 1.0; to: "mostvisited_over";} + min: 348 64; + max: 348 64; + rel1 { relative: 0.0 0.0; to: "mostvisited_button";} + rel2 { relative: 1.0 1.0; to: "mostvisited_button";} } } - part { + part { name: "bookmark_button"; scale:1; mouse_events: 1; @@ -1243,8 +1079,8 @@ group { name: "elm/genlist/item/top_button_item/default"; fixed: 1 1; color: 192 192 192 255; align: 0 0; - min: 348 65; - max: 348 65; + min: 348 64; + max: 348 64; rel1 { relative: 0.0 0.0; to: "bg_clipper"; offset: 961 58;} rel2 { relative: 1.0 1.0; to: "bg_clipper"; } } @@ -1261,7 +1097,7 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; } } - part{ + part{ name: "bookmark_text"; type: TEXT; scale: 1; @@ -1271,7 +1107,7 @@ group { name: "elm/genlist/item/top_button_item/default"; rel1 { relative: 0.0 0.0;to: "bookmark_button";} rel2 { relative: 1.0 1.0;to: "bookmark_button";} color: 0 0 0 255; - text { + text { text: "Bookmark"; font: "Sans"; size: 27; @@ -1279,7 +1115,7 @@ group { name: "elm/genlist/item/top_button_item/default"; } } } - part { + part { name: "bookmark_over"; scale:1; type: RECT; @@ -1289,8 +1125,8 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; + min: 348 64; + max: 348 64; rel1 { relative: 0.0 0.0; to: "bookmark_button";} rel2 { relative: 1.0 1.0; to: "bookmark_button";} color_class: transparent; @@ -1306,8 +1142,8 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; + min: 348 64; + max: 348 64; rel1 { relative: 0.0 0.0; to: "bookmark_over";} rel2 { relative: 1.0 1.0; to: "bookmark_over";} color_class: transparent; @@ -1323,7 +1159,7 @@ group { name: "elm/genlist/item/top_button_item/default"; emit("elm,action,click", ""); } } - program { + program { name: "mouse_in_mostvisited_click"; signal: "mouse,in"; source: "mostvisited_*"; @@ -1349,7 +1185,7 @@ group { name: "elm/genlist/item/top_button_item/default"; emit("elm,action,click", ""); } } - program { + program { name: "mouse_in_bookmark_click"; signal: "mouse,in"; source: "bookmark_*"; @@ -1367,7 +1203,7 @@ group { name: "elm/genlist/item/top_button_item/default"; target: "bookmark_over"; target: "mostvisited_text"; } - } + } } } @@ -1377,7 +1213,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; data.item: "texts" "bookmarkmanager_text"; data.item: "contents" "bookmarkmanager_click"; parts{ - part { + part { name: "bg_clipper"; scale:1; mouse_events: 1; @@ -1392,7 +1228,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; rel2 { relative: 1.0 1.0;} } } - part { + part { name: "bookmarkmanager_button"; scale:1; mouse_events: 1; @@ -1421,7 +1257,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; visible: 1; } } - part{ + part{ name: "bookmarkmanager_text"; type: TEXT; scale: 1; @@ -1431,7 +1267,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; rel1 { relative: 0.0 0.0;to: "bookmarkmanager_button";} rel2 { relative: 1.0 1.0;to: "bookmarkmanager_button";} color: 0 0 0 255; - text { + text { text: "Bookmark Manager"; font: "Sans"; size: 27; @@ -1439,7 +1275,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; } } } - part { + part { name: "bookmarkmanager_over"; scale:1; type: RECT; @@ -1456,7 +1292,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; color_class: transparent; } } - part { + part { name: "bookmarkmanager_click"; scale:1; type: SWALLOW; @@ -1482,7 +1318,7 @@ group { name: "elm/genlist/item/bottom_button_item/default"; emit("elm,action,click", ""); } } - program { + program { name: "mouse_in_bookmarkmanager_click"; signal: "mouse,in"; source: "bookmarkmanager_*"; -- 2.7.4 From 2e79d3bfb763dd55387dbb0df445c28c2bad8f15 Mon Sep 17 00:00:00 2001 From: Marcin Lapinski Date: Wed, 12 Aug 2015 15:31:53 +0200 Subject: [PATCH 09/16] Added action on clear history button clicked. [Issue#] https://bugs.tizen.org/jira/browse/TT-99 [Problem] 'Clear History' button does not work. [Cause] Buttons callback was empty. [Solution] Trigger history clear on button click. [Verify] 1. (History is not empty) 2. Open More menu -> history. 3. Click 'Clear History' button. 4. History should be deleted. Change-Id: I7d9b5d40451398d21ef88359f37660261ce1e6e6 --- services/HistoryUI/HistoryUI.cpp | 33 ++++++++++----------------------- services/HistoryUI/HistoryUI.h | 7 ++++--- services/SimpleUI/SimpleUI.cpp | 7 +++++++ services/SimpleUI/SimpleUI.h | 4 +++- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index c2724da..c562a18 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -125,28 +125,14 @@ void HistoryUI::showActionBar() m_itemClassActionBar->func.state_get = nullptr; m_itemClassActionBar->func.del = nullptr; - ItemData *id = new ItemData; - id->historyUI = this; Elm_Object_Item *elmItem = elm_genlist_item_append(m_genListActionBar, //genlist m_itemClassActionBar, //item Class - id, + this, nullptr, //parent item ELM_GENLIST_ITEM_NONE, //item type nullptr, nullptr //data passed to above function ); - id->e_item = elmItem; - ItemData *id2 = new ItemData; - id2->historyUI = this; - Elm_Object_Item *elmItem2 = elm_genlist_item_append(m_genListActionBar, //genlist - m_itemClassActionBar, //item Class - id2, - nullptr, //parent item - ELM_GENLIST_ITEM_NONE, //item type - nullptr, - nullptr //data passed to above function - ); - id2->e_item = elmItem2; } Evas_Object* HistoryUI::_listActionBarContentGet(void* data, Evas_Object* obj , const char* part) @@ -161,7 +147,7 @@ Evas_Object* HistoryUI::_listActionBarContentGet(void* data, Evas_Object* obj , 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", tizen_browser::base_ui::HistoryUI::_clearhistory_clicked, data); + evas_object_smart_callback_add(clearHistoryButton, "clicked", HistoryUI::_clearHistory_clicked, data); return clearHistoryButton; } if (!strncmp(part_name2, part, part_name2_len)) { @@ -178,9 +164,9 @@ void HistoryUI::_close_clicked_cb(void * data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (data) { - ItemData *id = static_cast(data); - id->historyUI->closeHistoryUIClicked(std::string()); - id->historyUI->clearItems(); + HistoryUI *historyUI = static_cast(data); + historyUI->closeHistoryUIClicked(std::string()); + historyUI->clearItems(); } } @@ -202,12 +188,13 @@ char* HistoryUI::_listTodayTextGet(void* data, Evas_Object*, const char* part) return nullptr; } -void HistoryUI::_clearhistory_clicked(void*, Evas_Object*, void*) +void HistoryUI::_clearHistory_clicked(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -// ItemData *itemData = static_cast(data); -// itemData->tabUI->clearItems(); -// itemData->tabUI->newTabClicked(std::string()); + + HistoryUI *historyUI = static_cast(data); + historyUI->clearHistoryClicked(std::string()); + historyUI->clearItems(); } void HistoryUI::addItems() diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 20bcc53..4556327 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -43,18 +43,19 @@ public: void removeHistoryItem(const std::string& uri); void clearItems(); void hide(); - void showActionBar(); + void showActionBar(); void show(Evas_Object *main_layout); void addItems(); boost::signals2::signal closeHistoryUIClicked; + boost::signals2::signal clearHistoryClicked; boost::signals2::signal)> historyItemClicked; boost::signals2::signal)> historyDeleteClicked; private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); - static Evas_Object * _history_grid_content_get(void *data, Evas_Object *obj, const char *part); + static Evas_Object * _history_grid_content_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); static Evas_Object* _listActionBarContentGet(void *data, Evas_Object *obj, const char *part); - static void _clearhistory_clicked(void *data, Evas_Object *obj, void *event_info); + static void _clearHistory_clicked(void *data, Evas_Object *obj, void *event_info); static char* _listTodayTextGet(void* data, Evas_Object* obj , const char* part); static void _close_clicked_cb(void *data, Evas_Object *obj, void *event_info); diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 0ccc4d0..4aa6931 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -588,6 +588,12 @@ void SimpleUI::onHistoryClicked(std::shared_ptrclearAllHistory(); +} + void SimpleUI::onMostVisitedClicked(const std::string&) { BROWSER_LOGD("[%s]", __func__); @@ -1057,6 +1063,7 @@ void SimpleUI::showHistoryUI(const std::string& str) std::dynamic_pointer_cast (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui")); M_ASSERT(m_historyUI); + m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1)); m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1)); m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); m_historyUI->addHistoryItems(getHistory()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 31bd390..482fcde 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -132,6 +132,8 @@ private: void onHistoryAdded(std::shared_ptr historyItem); void onHistoryRemoved(const std::string& uri); void onHistoryClicked(std::shared_ptr historyItem); + void onClearHistoryClicked(const std::string&); + void onMostVisitedClicked(const std::string&); void onBookmarkButtonClicked(const std::string&); void onBookmarkManagerButtonClicked(const std::string&); @@ -225,7 +227,7 @@ private: void showMoreMenu(); void closeMoreMenu(const std::string& str); void showHistoryUI(const std::string& str); - void closeHistoryUI(const std::string& str); + void closeHistoryUI(const std::string&); void showMainUI(); void hideMainUI(); void showURIBar(); -- 2.7.4 From 0fd97134fc1fb5a49e44279c777eae023833d0ae Mon Sep 17 00:00:00 2001 From: Marcin Lapinski Date: Thu, 13 Aug 2015 11:58:37 +0200 Subject: [PATCH 10/16] Refactor of HistoryUI::showActionBar function. [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 | 72 +++++++++++--------------------------- services/HistoryUI/HistoryUI.h | 3 +- services/HistoryUI/edc/History.edc | 12 +++---- 3 files changed, 26 insertions(+), 61 deletions(-) diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index c562a18..11ab3ed 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -48,7 +48,7 @@ static std::vector _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); diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 4556327..7070ff8 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -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; diff --git a/services/HistoryUI/edc/History.edc b/services/HistoryUI/edc/History.edc index 4f36aef..cda9200 100644 --- a/services/HistoryUI/edc/History.edc +++ b/services/HistoryUI/edc/History.edc @@ -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 { -- 2.7.4 From ce14505e000b735ff8fcb63dc7ba124447e865e9 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Wed, 12 Aug 2015 12:32:04 +0200 Subject: [PATCH 11/16] Fixed tabs addition [Issue#] https://bugs.tizen.org/jira/browse/TT-92 [Problem] Multiple tabs are added when navigating a page from Most Visited or Bookmarks. [Cause] Slots were added to signals every time the ShowMainUI function was called. [Solution] Changed time of adding slots. Now they are added in function exec only once (if m_initialised is false). [Verify] Launch Browser > Create new tabs > Obs Number of open tabs should be correct. Change-Id: I0401061a1cc75984c739a582be6bb83465849556 --- services/SimpleUI/SimpleUI.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 4aa6931..7c821c8 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -298,6 +298,16 @@ int SimpleUI::exec(const std::string& _url) } m_initialised = true; + m_mainUI = std::dynamic_pointer_cast + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.mainui")); + M_ASSERT(m_mainUI.get()); + + m_historyService->historyAllDeleted.connect(boost::bind(&tizen_browser::base_ui::MainUI::clearHistoryGenlist, m_mainUI.get())); + m_mainUI->historyClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); + m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); + m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); + m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); + // only when first run if (url.empty()) { BROWSER_LOGD("[%s]: changing to homeUrl", __func__); @@ -1043,16 +1053,11 @@ void SimpleUI::showMainUI() std::dynamic_pointer_cast (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.mainui")); - M_ASSERT(m_mainUI); + M_ASSERT(m_mainUI); hideWebView(); - m_mainUI->show(m_window.get()); + m_mainUI->show(m_window.get()); m_mainUI->addHistoryItems(getHistory()); - m_historyService->historyAllDeleted.connect(boost::bind(&tizen_browser::base_ui::MainUI::clearHistoryGenlist, m_mainUI.get())); - m_mainUI->historyClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); - m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); - m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); - m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); m_isHomePageActive = true; } -- 2.7.4 From e1880e27029ccdbf44ef15de4707e8c08e219635 Mon Sep 17 00:00:00 2001 From: Marcin Lapinski Date: Mon, 17 Aug 2015 14:28:24 +0200 Subject: [PATCH 12/16] Disabled START_MINIBROWSER and READ_MODE features [Issue#] https://bugs.tizen.org/jira/browse/TT-129 [Problem] N/A [Cause] N/A [Solution] N/A [Verify] 1. Change builds. 2. Feature buttons in More Menu should be not visible. Change-Id: I9aec51faabafb9503a31e30955cd92d0ed31b10b --- services/MoreMenuUI/MoreMenuUI.cpp | 16 +++++++++++++++- services/MoreMenuUI/MoreMenuUI.h | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index 2670648..ff31301 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -282,7 +282,7 @@ void MoreMenuUI::hide() void MoreMenuUI::addItems() { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - for (size_t i = 0; i < 10; i++) { + for (size_t i = 0; i < static_cast(END_OF_RANGE); i++) { MoreMenuItemData *itemData = new MoreMenuItemData(); itemData->item = static_cast(i);; itemData->moreMenuUI = std::shared_ptr(this); @@ -304,9 +304,11 @@ char* MoreMenuUI::_grid_text_get(void* data, Evas_Object*, const char* part) if (!strncmp(part_name, part, part_name_len)) { const char* item_name = NULL; switch (itemData->item) { +#ifdef READER_MODE_ENABLED case READER_MODE: item_name = "Reader mode"; break; +#endif case BOOKMARK_MANAGER: item_name = "Bookmark manager"; break; @@ -316,9 +318,11 @@ char* MoreMenuUI::_grid_text_get(void* data, Evas_Object*, const char* part) case SCREEN_ZOOM: item_name = "Screen zoom"; break; +#ifdef START_MINIBROWSER_ENABLED case START_MINIBROWSER: item_name = "Start minibrowser"; break; +#endif case FOCUS_MODE: item_name = "Focus mode"; break; @@ -347,9 +351,11 @@ static const char* getImageFileNameForType(ItemType type, bool focused) { const char* file_name = NULL; switch (type) { +#ifdef READER_MODE_ENABLED case READER_MODE: file_name = focused ? "ic_more_readermode_foc.png" : "ic_more_readermode_nor.png"; break; +#endif case BOOKMARK_MANAGER: file_name = focused ? "ic_more_bookmark_foc.png" : "ic_more_bookmark_nor.png"; break; @@ -359,9 +365,11 @@ static const char* getImageFileNameForType(ItemType type, bool focused) case SCREEN_ZOOM: file_name = focused ? "ic_more_zoom_foc.png" : "ic_more_zoom_nor.png"; break; +#ifdef START_MINIBROWSER_ENABLED case START_MINIBROWSER: file_name = focused ? "ic_more_minibrowser_foc.png" : "ic_more_minibrowser_nor.png"; break; +#endif case FOCUS_MODE: file_name = focused ? "ic_more_focusmode_foc.png" : "ic_more_focusmode_nor.png"; break; @@ -455,9 +463,15 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) case BOOKMARK_MANAGER: itemData->moreMenuUI->bookmarkManagerClicked(std::string()); break; +#ifdef READER_MODE_ENABLED case READER_MODE: + //TODO: Implement reader mode +#endif case SCREEN_ZOOM: +#ifdef START_MINIBROWSER_ENABLED case START_MINIBROWSER: + //TODO: Implement minibrowser launching +#endif case FOCUS_MODE: case VIEW_MOBILE_WEB: case SHARE: diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index a837fad..1d87456 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -38,16 +38,21 @@ namespace base_ui{ class SimpleUI; enum ItemType { +#ifdef READER_MODE_ENABLED READER_MODE, +#endif BOOKMARK_MANAGER, HISTORY, SCREEN_ZOOM, +#ifdef START_MINIBROWSER_ENABLED START_MINIBROWSER, +#endif FOCUS_MODE, VIEW_MOBILE_WEB, SHARE, SETTINGS, - EXIT_BROWSER + EXIT_BROWSER, + END_OF_RANGE } item; class BROWSER_EXPORT MoreMenuUI -- 2.7.4 From e28d4d5ec1bf1123a34612b1b90776c3d520d12f Mon Sep 17 00:00:00 2001 From: "t.dakowicz" Date: Thu, 13 Aug 2015 15:05:35 +0200 Subject: [PATCH 13/16] Bug TT-94 Fixed bookmarks folder creation bug [Issue#] https://bugs.tizen.org/jira/browse/TT-94 [Problem] User couldn't create new folder for bookmarks. [Cause] Wrong initialization of variable [Solution] The variable initialized with zeros [Verify] MoreMenu -> Add bookmark -> '+' -> type new folder's name. Check if the folder is visible in Bookmark Manager. Change-Id: I630787ae4251cbe6ab4ad53ce23b756996173e3d --- services/BookmarkService/BookmarkService.cpp | 3 +++ services/SimpleUI/SimpleUI.cpp | 26 ++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/services/BookmarkService/BookmarkService.cpp b/services/BookmarkService/BookmarkService.cpp index 2489359..ac5cce3 100644 --- a/services/BookmarkService/BookmarkService.cpp +++ b/services/BookmarkService/BookmarkService.cpp @@ -330,12 +330,15 @@ int BookmarkService::save_folder(const char *title, int *saved_folder_id, int pa } bp_bookmark_info_fmt info; + std::memset(&info, 0, sizeof(bp_bookmark_info_fmt)); + info.type = 1; info.parent = parent_id; info.sequence = -1; info.is_operator = by_operator; info.access_count = -1; info.editable = 1; + if (title != nullptr && strlen(title) > 0) { info.title = (char *)title; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 7c821c8..94d6a80 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -1376,7 +1376,8 @@ void SimpleUI::favicon_clicked(void *data, Evas_Object */*obj*/, const char */*e } void SimpleUI::addToBookmarks(int folder_id) -{ BROWSER_LOGD("[%s,%d],", __func__, __LINE__); +{ + BROWSER_LOGD("[%s,%d],", __func__, __LINE__); if (m_favoriteService) { if( m_webEngine && !m_webEngine->getURI().empty()) { m_favoriteService->addToBookmarks(m_webEngine->getURI(), m_webEngine->getTitle(), std::string(), @@ -1387,8 +1388,9 @@ void SimpleUI::addToBookmarks(int folder_id) } void SimpleUI::saveFolder(const char* title,int folder_id, int by_operator) -{ BROWSER_LOGD("[%s,%d],", __func__, __LINE__); - int id = -1; +{ + BROWSER_LOGD("[%s,%d],", __func__, __LINE__); + int id = -1; if (m_favoriteService) m_favoriteService->save_folder(title, &id, folder_id, by_operator); if (id >= 0 ) @@ -1403,20 +1405,16 @@ void SimpleUI::saveFolder(const char* title,int folder_id, int by_operator) void SimpleUI::NewFolder(const char* title,int folder_id, int by_operator) -{ BROWSER_LOGD("[%s,%d],", __func__, __LINE__); +{ int id = -1; if (m_favoriteService) m_favoriteService->save_folder(title, &id, folder_id, by_operator); - if (id >= 0 ) - { BROWSER_LOGD("[%s], Added New Folder", __func__); - } - if (m_favoriteService) - { if( m_webEngine && !m_webEngine->getURI().empty()) - { m_favoriteService->addToBookmarks(m_webEngine->getURI(), m_webEngine->getTitle(), std::string(), - m_webEngine->getSnapshotData(373, 240), - m_webEngine->getFavicon(),(unsigned int)id); - } - } + if (id >= 0) + { + BROWSER_LOGD("[%s], Added New Folder", __func__); + addToBookmarks(id); + m_moreMenuUI->getBookmarkFolderList(getBookmarkFolders()); + } } void SimpleUI::deleteBookmark(void) -- 2.7.4 From f408581c995f49eee8574b284d992ebbc878fb48 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Mon, 17 Aug 2015 15:03:27 +0200 Subject: [PATCH 14/16] Remove unneeded genlist from top buttons. [Issue#] https://bugs.tizen.org/jira/browse/TT-73 [Problem] Uneeded genlist caused scrolling of top buttons. [Cause] N/A [Solution] Removed genlist. [Verify] Check if buttons "Most visited" and "Bookmarks" work. Change-Id: I044d8502be38d55fe7ce9b44c1674f3cf155922c Signed-off-by: Maciej Skrzypkowski --- services/MainUI/MainUI.cpp | 96 ++++++++++++------------------------------ services/MainUI/MainUI.h | 9 ++-- services/MainUI/edc/MainUI.edc | 14 ++---- 3 files changed, 35 insertions(+), 84 deletions(-) diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index 173e306..c6feff8 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -53,10 +53,15 @@ struct ItemData{ }; MainUI::MainUI() - : m_gengrid(nullptr) - , m_genListTop(nullptr) + : m_parent(nullptr) + , m_layout(nullptr) + , m_layoutTop(nullptr) + , m_gengrid(nullptr) + , m_genListLeft(nullptr) + , m_genListCenter(nullptr) + , m_genListRight(nullptr) , m_genListBottom(nullptr) - , m_parent(nullptr) + , m_itemClassBottom(nullptr) , m_big_item_class(nullptr) , m_small_item_class(nullptr) , m_bookmark_item_class(nullptr) @@ -164,49 +169,25 @@ void MainUI::show(Evas_Object* parent) void MainUI::showTopButtons() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(nullptr, edjFilePath.c_str()); - m_genListTop = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.genlistTop", m_genListTop); - elm_genlist_homogeneous_set(m_genListTop, EINA_FALSE); - elm_genlist_multi_select_set(m_genListTop, EINA_FALSE); - elm_genlist_select_mode_set(m_genListTop, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListTop, ELM_LIST_LIMIT); - //elm_genlist_decorate_mode_set(m_genListTop, EINA_TRUE); - evas_object_size_hint_weight_set(m_genListTop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - /*evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, nullptr);*/ + m_layoutTop = elm_layout_add(m_layout); - m_itemClassTop = elm_genlist_item_class_new(); - m_itemClassTop->item_style = "top_button_item"; - m_itemClassTop->func.text_get = nullptr; // &listTopItemTextGet; - m_itemClassTop->func.content_get = &listTopItemContentGet; - m_itemClassTop->func.state_get = 0; - m_itemClassTop->func.del = 0; + elm_layout_file_set(m_layoutTop, edjFilePath.c_str(), "top_button_item"); + evas_object_size_hint_weight_set(m_layoutTop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_layoutTop, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(m_layoutTop); - ItemData * id = new ItemData; - id->mainUI = this; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genListTop, //genlist - m_itemClassTop, //item Class - id, - nullptr, //parent item - ELM_GENLIST_ITEM_NONE,//item type - nullptr, - nullptr //data passed to above function - ); - id->e_item = elmItem; - ItemData * id2 = new ItemData; - id2->mainUI = this; - Elm_Object_Item* elmItem2 = elm_genlist_item_append(m_genListTop, //genlist - m_itemClassTop, //item Class - id2, - nullptr, //parent item - ELM_GENLIST_ITEM_NONE,//item type - nullptr, - nullptr //data passed to above function - ); - id2->e_item = elmItem2; - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *mvButton = elm_button_add(m_layoutTop); + elm_object_style_set(mvButton, "invisible_button"); + evas_object_smart_callback_add(mvButton, "clicked", tizen_browser::base_ui::MainUI::_mostVisited_clicked, this); + elm_layout_content_set(m_layoutTop, "mostvisited_click", mvButton); + + Evas_Object *bmButton = elm_button_add(m_layoutTop); + elm_object_style_set(bmButton, "invisible_button"); + evas_object_smart_callback_add(bmButton, "clicked", tizen_browser::base_ui::MainUI::_bookmark_clicked, this); + elm_layout_content_set(m_layoutTop, "bookmark_click", bmButton); + + elm_object_part_content_set(m_layout, "elm.swallow.genlistTop", m_layoutTop); } void MainUI::showBottomButton() @@ -244,38 +225,18 @@ void MainUI::showBottomButton() id->e_item = elmItem; } -Evas_Object* MainUI::listTopItemContentGet(void* data, Evas_Object* obj, const char* part) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!strcmp(part, "mostvisited_click")) - { - Evas_Object *mvButton = elm_button_add(obj); - elm_object_style_set(mvButton, "invisible_button"); - evas_object_smart_callback_add(mvButton, "clicked", tizen_browser::base_ui::MainUI::_mostVisited_clicked, data); - return mvButton; - } - else if(!strcmp(part, "bookmark_click")) - { - Evas_Object *bmButton = elm_button_add(obj); - elm_object_style_set(bmButton, "invisible_button"); - evas_object_smart_callback_add(bmButton, "clicked", tizen_browser::base_ui::MainUI::_bookmark_clicked, data); - return bmButton; - } - return nullptr; -} - void MainUI::_mostVisited_clicked(void * data, Evas_Object * /* obj */, void * event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->mainUI->mostVisitedClicked(std::string()); + MainUI* mainUI = reinterpret_cast(data); + mainUI->mostVisitedClicked(std::string()); } void MainUI::_bookmark_clicked(void * data, Evas_Object * /* obj */, void * event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ItemData* itemData = reinterpret_cast(data); - itemData->mainUI->bookmarkClicked(std::string()); + MainUI* mainUI = reinterpret_cast(data); + mainUI->bookmarkClicked(std::string()); } void MainUI::_bookmark_manager_clicked(void * data, Evas_Object * /* obj */, void * event_info) @@ -501,7 +462,6 @@ void MainUI::clearItems() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); clearHistoryGenlist(); clearBookmarkGengrid(); - elm_genlist_clear(m_genListTop); elm_genlist_clear(m_genListBottom); } diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index bd77d53..c62a301 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -76,16 +76,15 @@ private: static void _bookmark_clicked(void * data, Evas_Object * obj, void * event_info); static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info); private: - Evas_Object *m_genListTop; + Evas_Object *m_parent; + Evas_Object *m_layout; + Evas_Object *m_layoutTop; + Evas_Object *m_gengrid; Evas_Object *m_genListLeft; Evas_Object *m_genListCenter; Evas_Object *m_genListRight; - Elm_Genlist_Item_Class *m_itemClassTop; Evas_Object *m_genListBottom; Elm_Genlist_Item_Class *m_itemClassBottom; - Evas_Object *m_gengrid; - Evas_Object *m_layout; - Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_big_item_class; Elm_Gengrid_Item_Class * m_small_item_class; Elm_Gengrid_Item_Class * m_bookmark_item_class; diff --git a/services/MainUI/edc/MainUI.edc b/services/MainUI/edc/MainUI.edc index f094d4e..a81e52a 100644 --- a/services/MainUI/edc/MainUI.edc +++ b/services/MainUI/edc/MainUI.edc @@ -967,7 +967,7 @@ group { name: "elm/gengrid/item/grid_item/default"; } } -group { name: "elm/genlist/item/top_button_item/default"; +group { name: "top_button_item"; min: 1920 181; max: 1920 181; data.item: "texts" "mostvisited_text bookmark_text"; @@ -1045,8 +1045,6 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 64; - max: 348 64; rel1 { relative: 0.0 0.0; to: "mostvisited_button";} rel2 { relative: 1.0 1.0; to: "mostvisited_button";} color_class: transparent; @@ -1062,8 +1060,6 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 64; - max: 348 64; rel1 { relative: 0.0 0.0; to: "mostvisited_button";} rel2 { relative: 1.0 1.0; to: "mostvisited_button";} } @@ -1125,8 +1121,6 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 64; - max: 348 64; rel1 { relative: 0.0 0.0; to: "bookmark_button";} rel2 { relative: 1.0 1.0; to: "bookmark_button";} color_class: transparent; @@ -1142,10 +1136,8 @@ group { name: "elm/genlist/item/top_button_item/default"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 64; - max: 348 64; - rel1 { relative: 0.0 0.0; to: "bookmark_over";} - rel2 { relative: 1.0 1.0; to: "bookmark_over";} + rel1 { relative: 0.0 0.0; to: "bookmark_button";} + rel2 { relative: 1.0 1.0; to: "bookmark_button";} color_class: transparent; } } -- 2.7.4 From a76afd26f9fdd471633a68f0e383ac3bc286ae80 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Mon, 17 Aug 2015 14:22:02 +0200 Subject: [PATCH 15/16] Added action on "Exit browser" button [Issue#] https://bugs.tizen.org/jira/browse/TT-131 [Problem] "Exit browser" in More Menu is not working. [Cause] There was no action connected to "exit browser" button. [Solution] Added function _exitClicked that calls elm_exit(). [Verify] Browser -> MoreMenu -> Exit browser -> Obs Browser should be closed. Change-Id: I14473625d1b8ba9d60e9049005193b63e3a66208 --- services/MoreMenuUI/MoreMenuUI.cpp | 17 +++++++++++++++-- services/MoreMenuUI/MoreMenuUI.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index ff31301..3edef9d 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -465,17 +465,24 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) break; #ifdef READER_MODE_ENABLED case READER_MODE: - //TODO: Implement reader mode + //TODO: Implement reader mode + break; #endif case SCREEN_ZOOM: + break; #ifdef START_MINIBROWSER_ENABLED case START_MINIBROWSER: - //TODO: Implement minibrowser launching + //TODO: Implement minibrowser launching + break; #endif case FOCUS_MODE: + break; case VIEW_MOBILE_WEB: + break; case SHARE: + break; case EXIT_BROWSER: + _exitClicked(); break; } } @@ -499,6 +506,12 @@ void MoreMenuUI::clearItems() elm_cache_all_flush(); } +void MoreMenuUI::_exitClicked() +{ + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + elm_exit(); +} + //void MoreMenuUI::focusItem(void*, Evas_Object*, void* event_info) //{ // BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 1d87456..0bb5b1e 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -81,6 +81,7 @@ private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); + static void _exitClicked(); static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part); static char* listItemTextGet(void *data, Evas_Object *obj, const char *part); -- 2.7.4 From 7ef0447eb77b0dbd6c66c2c2827f8b1e988e9e53 Mon Sep 17 00:00:00 2001 From: Marcin Lapinski Date: Tue, 18 Aug 2015 11:46:41 +0200 Subject: [PATCH 16/16] Set callback for bookmark gengrid item instead of items thumbnail. [Issue#] https://bugs.tizen.org/jira/browse/TT-135 [Problem] Clicking on bookmark folder text doesn't work. [Cause] Callback was set on thumbnail instead of on whole item. [Sollution] Move callback to bookmark gengrid item click. [Verify] 1. Run browser 2. Create some bookmark folders 3. Open More Menu -> Bookmark manager 4. Click on some bookmark folder description 5. Bookmark folder shold be opened. Additional changes: - Changed some function names to make code more self-explaining. - Removed redundant focus managment callbacks causing problems in the current approach. Change-Id: Ibddc457a7cfdc19f7b68ce4163f4b2ae04d793db --- services/BookmarkManagerUI/BookmarkManagerUI.cpp | 59 ++++++------------------ services/BookmarkManagerUI/BookmarkManagerUI.h | 11 ++--- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/services/BookmarkManagerUI/BookmarkManagerUI.cpp b/services/BookmarkManagerUI/BookmarkManagerUI.cpp index 9a0be45..2ae1617 100644 --- a/services/BookmarkManagerUI/BookmarkManagerUI.cpp +++ b/services/BookmarkManagerUI/BookmarkManagerUI.cpp @@ -80,15 +80,12 @@ void BookmarkManagerUI::show(Evas_Object* parent) elm_object_part_content_set(b_mm_layout, "elm.swallow.grid", m_gengrid); elm_object_style_set(m_gengrid, "back_ground"); - evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, nullptr); - evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, nullptr); - evas_object_smart_callback_add(m_gengrid, "activated", _itemSelected, this); if (!m_item_class) { m_item_class = elm_gengrid_item_class_new(); m_item_class->item_style = "grid_bm_item"; - m_item_class->func.text_get = _grid_text_get; - m_item_class->func.content_get = _grid_content_get; + m_item_class->func.text_get = _grid_folder_text_get; + m_item_class->func.content_get = _grid_folder_content_get; m_item_class->func.state_get = nullptr; m_item_class->func.del = nullptr; } @@ -298,7 +295,7 @@ void BookmarkManagerUI::addBookmarkFolderItem(std::shared_ptritem = hi; itemData->bookmarkManagerUI.reset(this); - Elm_Object_Item* BookmarkFolderView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, nullptr, this); + Elm_Object_Item* BookmarkFolderView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, _folderItemClicked, itemData); m_map_bookmark_folder_views.insert(std::pair(hi->getAddress(),BookmarkFolderView)); elm_gengrid_item_selected_set(BookmarkFolderView, EINA_FALSE); setEmptyGengrid(false); @@ -322,7 +319,7 @@ void BookmarkManagerUI::addBookmarkItem(std::shared_ptritem = hi; itemData->bookmarkManagerUI.reset(this); - Elm_Object_Item* BookmarkView = elm_gengrid_item_append(m_gengrid, m_detail_item_class, itemData, nullptr, this); + Elm_Object_Item* BookmarkView = elm_gengrid_item_append(m_gengrid, m_detail_item_class, itemData, _bookmarkItemClicked, itemData); m_map_bookmark_folder_views.insert(std::pair(hi->getAddress(),BookmarkView)); elm_gengrid_item_selected_set(BookmarkView, EINA_FALSE); setEmptyGengrid(false); @@ -339,7 +336,7 @@ void BookmarkManagerUI::addBookmarkItems(std::vector image = itemData->item->getThumbnail(); + std::shared_ptr image = itemData->item->getThumbnail(); if (image) { - thumb = tizen_browser::tools::EflTools::getEvasImage(image, itemData->bookmarkManagerUI->m_parent); + thumb = tools::EflTools::getEvasImage(image, itemData->bookmarkManagerUI->m_parent); } return thumb; } @@ -388,7 +385,6 @@ Evas_Object * BookmarkManagerUI::_grid_content_get(void *data, Evas_Object *obj, if (thumbButton != nullptr) { elm_object_style_set(thumbButton, "thumbButton"); - evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::BookmarkManagerUI::_thumbSelected, data); } return thumbButton; } @@ -446,7 +442,6 @@ Evas_Object * BookmarkManagerUI::_grid_bookmark_content_get(void *data, Evas_Obj if (thumbButton != nullptr) { elm_object_style_set(thumbButton, "thumbButton"); - evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::BookmarkManagerUI::_bookmark_thumbSelected, data); } return thumbButton; } @@ -454,11 +449,12 @@ Evas_Object * BookmarkManagerUI::_grid_bookmark_content_get(void *data, Evas_Obj return nullptr; } -void BookmarkManagerUI::_itemSelected(void * data, Evas_Object *, void * event_info) +void BookmarkManagerUI::_bookmarkItemClicked(void * data, Evas_Object *, void * event_info) { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); (void)data; (void)event_info; -#if 0 +/* if ((data != nullptr) && (event_info != nullptr)) { Elm_Object_Item * selected = static_cast(event_info); @@ -469,11 +465,12 @@ void BookmarkManagerUI::_itemSelected(void * data, Evas_Object *, void * event_i self->bookmarkClicked(itemData->item); } } -#endif +*/ } -void BookmarkManagerUI::_thumbSelected(void * data, Evas_Object *, void *) +void BookmarkManagerUI::_folderItemClicked(void * data, Evas_Object *, void *) { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); if (data != nullptr) { BookmarkFolderItemData * itemData = static_cast(data); @@ -483,7 +480,6 @@ void BookmarkManagerUI::_thumbSelected(void * data, Evas_Object *, void *) } } - void BookmarkManagerUI::_bookmark_thumbSelected(void * data, Evas_Object *, void *) { (void)data; @@ -508,7 +504,6 @@ void BookmarkManagerUI::clearItems() elm_cache_all_flush(); } - void BookmarkManagerUI::updateGengrid() { elm_genlist_clear(m_genList); @@ -516,31 +511,5 @@ void BookmarkManagerUI::updateGengrid() m_map_bookmark_folder_views.clear(); } -void BookmarkManagerUI::focusItem(void*, Evas_Object*, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (event_info != nullptr) - { - Elm_Object_Item *item = static_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); - - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); - } -} - -void BookmarkManagerUI::unFocusItem(void*, Evas_Object*, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (event_info != nullptr) - { - Elm_Object_Item *item = static_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); - - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); - } -} - } } diff --git a/services/BookmarkManagerUI/BookmarkManagerUI.h b/services/BookmarkManagerUI/BookmarkManagerUI.h index 419f508..eeb2a57 100644 --- a/services/BookmarkManagerUI/BookmarkManagerUI.h +++ b/services/BookmarkManagerUI/BookmarkManagerUI.h @@ -61,13 +61,13 @@ public: boost::signals2::signal bookmarkFolderClicked; private: - static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); - static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); + static char* _grid_folder_text_get(void *data, Evas_Object *obj, const char *part); + static Evas_Object * _grid_folder_content_get(void *data, Evas_Object *obj, const char *part); static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part); - static void _itemSelected(void * data, Evas_Object * obj, void * event_info); - static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); + static void _bookmarkItemClicked(void * data, Evas_Object * obj, void * event_info); + static void _folderItemClicked(void * data, Evas_Object * obj, void * event_info); static void _bookmark_thumbSelected(void * data, Evas_Object *, void *); void NewFolderCreate(Evas_Object * popup_content); @@ -95,9 +95,6 @@ private: std::string edjFilePath; std::string m_folder; bool m_gengridSetup; - - static void focusItem(void*, Evas_Object*, void* event_info); - static void unFocusItem(void*, Evas_Object*, void* event_info); }; } -- 2.7.4