From: Adam Skobodzinski Date: Tue, 27 Oct 2015 08:08:14 +0000 (+0100) Subject: Displaying UrlHistoryList refactoring (moving class, focus chain). X-Git-Tag: accepted/tizen/tv/20151029.090044~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36cb30d49a9f9b8e13ec5a45ee7fa17ef6055814;p=profile%2Ftv%2Fapps%2Fweb%2Fbrowser.git Displaying UrlHistoryList refactoring (moving class, focus chain). [Issue] https://bugs.tizen.org/jira/browse/TT-161 [Problem] UrlHistoryList was not included in focus chain and was not always visible in a WebPage view. [Solution] UrlHistoryList is moved to WebPageUI. UrlHistoryList is added to focus chain in 'WebPageUI::refreshFocusChain'. Inserting focused item's content to uri entry. [Verify] Displayed UrlHistoryList (QuickAccess view and WebPage view) should be included in focus chain. Focusing out from list and from UriEntry should cause list's scroll out. Focusing on item should change uri entry content. What is not solved yet: 1) list's width is not adapting to QuickAccess url width. 2) 'web_view' content in WebPage view is sometimes colliding with list's focus chain 3) If list is displaying small number of elements, it's partially covering web page view (blocks cursor focus events). Change-Id: Iab263e4e0421adab9e61ac6a6a16f926ace66f67 Signed-off-by: Adam Skobodzinski --- diff --git a/services/QuickAccess/CMakeLists.txt b/services/QuickAccess/CMakeLists.txt index 2b76470..bacd28d 100644 --- a/services/QuickAccess/CMakeLists.txt +++ b/services/QuickAccess/CMakeLists.txt @@ -3,19 +3,11 @@ project(QuickAccess) set(QuickAccess_SRCS QuickAccess.cpp DetailPopup.cpp - UrlHistoryList/UrlHistoryList.cpp - UrlHistoryList/GenlistManager.cpp - UrlHistoryList/GenlistManagerCallbacks.cpp - UrlHistoryList/UrlMatchesStyler.cpp ) set(QuickAccess_HEADERS QuickAccess.h DetailPopup.h - UrlHistoryList/UrlHistoryList.h - UrlHistoryList/GenlistManager.h - UrlHistoryList/GenlistManagerCallbacks.h - UrlHistoryList/UrlMatchesStyler.h ) include(Coreheaders) @@ -37,7 +29,6 @@ install(TARGETS ${PROJECT_NAME} set(edcFiles QuickAccess.edc DetailPopup.edc - UrlHistoryList.edc ) foreach(edec ${edcFiles}) diff --git a/services/QuickAccess/QuickAccess.cpp b/services/QuickAccess/QuickAccess.cpp index 9e34730..4dee510 100644 --- a/services/QuickAccess/QuickAccess.cpp +++ b/services/QuickAccess/QuickAccess.cpp @@ -25,7 +25,6 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" #include "Tools/GeneralTools.h" -#include "UrlHistoryList/UrlHistoryList.h" #define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) @@ -76,14 +75,10 @@ QuickAccess::QuickAccess() , m_detailPopup(this) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - edjFilePath = edjFilePathUrlHistoryList = EDJE_DIR; + edjFilePath = EDJE_DIR; edjFilePath.append("QuickAccess/QuickAccess.edj"); - edjFilePathUrlHistoryList.append("QuickAccess/UrlHistoryList.edj"); elm_theme_extension_add(nullptr, edjFilePath.c_str()); - elm_theme_extension_add(nullptr, edjFilePathUrlHistoryList.c_str()); QuickAccess::createItemClasses(); - - m_urlHistoryList = std::make_shared(this); } QuickAccess::~QuickAccess() @@ -105,7 +100,6 @@ Evas_Object* QuickAccess::getContent() M_ASSERT(m_parent); if (!m_layout) { m_layout = createQuickAccessLayout(m_parent); - m_urlHistoryListLayout = createUrlHistoryListLayout(m_layout); } return m_layout; } @@ -255,20 +249,6 @@ Evas_Object* QuickAccess::createBottomButton(Evas_Object *parent) return layoutBottom; } -Evas_Object* QuickAccess::createUrlHistoryListLayout(Evas_Object* parent) -{ - Evas_Object* urlHistoryListLayout = elm_layout_add(parent); - elm_layout_file_set(urlHistoryListLayout, edjFilePath.c_str(), "url_history_list_layout"); - evas_object_size_hint_weight_set(urlHistoryListLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set (urlHistoryListLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_urlHistoryList->createLayout(urlHistoryListLayout); - if(m_urlHistoryList->getLayout()) - { - elm_object_part_content_set(urlHistoryListLayout, "url_history_list_swallow", m_urlHistoryList->getLayout()); - } - return urlHistoryListLayout; -} void QuickAccess::_mostVisited_clicked(void * data, Evas_Object *, void *) { @@ -461,7 +441,6 @@ void QuickAccess::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); evas_object_show(m_layout); - evas_object_show(m_urlHistoryListLayout); if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_bookmarksView) { evas_object_show(m_bookmarksView); } else { @@ -515,11 +494,6 @@ DetailPopup& QuickAccess::getDetailPopup() return m_detailPopup; } -UrlHistoryPtr QuickAccess::getUrlHistoryList() -{ - return m_urlHistoryList; -} - void QuickAccess::backButtonClicked() { if (m_detailPopup.isVisible()) { diff --git a/services/QuickAccess/QuickAccess.h b/services/QuickAccess/QuickAccess.h index 9dd5155..5418b38 100644 --- a/services/QuickAccess/QuickAccess.h +++ b/services/QuickAccess/QuickAccess.h @@ -31,9 +31,6 @@ namespace tizen_browser{ namespace base_ui{ -class UrlHistoryList; -typedef std::shared_ptr UrlHistoryPtr; - //TODO: This class name is not revelant to what this class actually does. //Rename this class and file to "QuickAccessUI". class BROWSER_EXPORT QuickAccess @@ -53,7 +50,6 @@ public: bool isDesktopMode() const; void setDesktopMode(bool mode); DetailPopup & getDetailPopup(); - UrlHistoryPtr getUrlHistoryList(); void backButtonClicked(); inline bool isMostVisitedActive() const; void refreshFocusChain(); @@ -84,7 +80,6 @@ private: Evas_Object* createBookmarksView(Evas_Object *parent); Evas_Object* createBottomButton(Evas_Object *parent); Evas_Object* createTopButtons(Evas_Object *parent); - Evas_Object* createUrlHistoryListLayout(Evas_Object *parent); 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); @@ -109,15 +104,11 @@ private: std::vector m_tiles; Eina_List* m_parentFocusChain; - UrlHistoryPtr m_urlHistoryList; - Evas_Object* m_urlHistoryListLayout; - Elm_Gengrid_Item_Class * m_bookmark_item_class; DetailPopup m_detailPopup; services::HistoryItemVector m_historyItems; bool m_gengridSetup; std::string edjFilePath; - std::string edjFilePathUrlHistoryList; bool m_desktopMode; static const int MAX_TILES_NUMBER; diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp deleted file mode 100644 index 4e18d6b..0000000 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "UrlHistoryList.h" -#include "GenlistManager.h" -#include "BrowserLogger.h" -#include "../QuickAccess.h" - -namespace tizen_browser { -namespace base_ui { - -UrlHistoryList::UrlHistoryList(QuickAccess* quickAccess) : - m_layout(nullptr), m_quickAccess(quickAccess) -{ - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("QuickAccess/UrlHistoryList.edj"); - m_genlistListManager = make_shared(); - m_genlistListManager->signalItemSelected.connect( - boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); - m_genlistListManager->signalWidgetFocused.connect( - boost::bind(&UrlHistoryList::onListWidgetFocused, this)); - m_genlistListManager->signalWidgetUnfocused.connect( - boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); -} - -UrlHistoryList::~UrlHistoryList() -{ -} - -Evas_Object* UrlHistoryList::getLayout() -{ - return m_layout; -} - -void UrlHistoryList::createLayout(Evas_Object* parentLayout) -{ - m_layout = elm_layout_add(parentLayout); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); - - m_genlistListManager->createWidget(m_layout); -} - -void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, - shared_ptr matchedEntries) -{ - editedUrlStatesHelper.changeState(true); - - if (matchedEntries->size() == 0) { - m_genlistListManager->hideWidgetPretty(); - } else { - Evas_Object* widgetList = m_genlistListManager->getWidget(); - elm_object_part_content_set(m_layout, "list_swallow", widgetList); - m_genlistListManager->showWidget(editedUrl, matchedEntries); - evas_object_show(widgetList); - } -} - -void UrlHistoryList::onURLEntryEdited() -{ - editedUrlStatesHelper.changeState(false); - if (editedUrlStatesHelper.getCurrentState() - == EditedUrlState::EDITED_OTHER_FIRST) { - m_genlistListManager->hideWidgetPretty(); - } else { - // in this situation scroll will not work, it has to be hidden instantly - m_genlistListManager->hideWidgetInstant(); - } -} - -void UrlHistoryList::onMouseClick() -{ - m_genlistListManager->onMouseClick(); -} - -void UrlHistoryList::onListItemSelect(std::string content) -{ - openURLInNewTab(make_shared < services::HistoryItem > (content), - m_quickAccess->isDesktopMode()); -} - -void UrlHistoryList::onListWidgetFocused() -{ - // will be used soon: in a proper focus-chain solution -} - -void UrlHistoryList::onListWidgetUnfocused() -{ - // will be used soon: in a proper focus-chain solution -} - -}/* namespace base_ui */ -} /* namespace tizen_browser */ diff --git a/services/QuickAccess/edc/QuickAccess.edc b/services/QuickAccess/edc/QuickAccess.edc index ef1881b..c87299b 100644 --- a/services/QuickAccess/edc/QuickAccess.edc +++ b/services/QuickAccess/edc/QuickAccess.edc @@ -20,11 +20,6 @@ collections { #define ITEM_WIDTH 374 #define PARENT_ITEM_HEIGHT 36 -#define URI_INPUTBOX_LENGTH 1720 -#define URL_HISTORY_ITEM_H 82 -#define URL_HISTORY_ITEMS_VISIBLE_MAX 5 -#define URL_HISTORY_LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX - group{ name: "elm/button/base/invisible_button"; parts{ @@ -1388,33 +1383,6 @@ group { name: "top_button_item"; } } -group { - name: "url_history_list_layout"; - parts - { - part - { - name: "url_history_list_swallow"; - type: SWALLOW; - description { - state: "default" 0.0; - min: URI_INPUTBOX_LENGTH URL_HISTORY_LIST_MAX_H; - max: -1 -1; - align: 0.0 0.0; - fixed: 1 1; - visible: 1; - rel1 { - relative: 0 0; - offset: 10 106; - } - rel2 { - relative: 1.0 1.0; - } - } - } - } -} - group { name: "bottom_button_item"; min: 1920 181; max: 1920 181; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 0ab02e6..fc73d3a 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -238,7 +238,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_webPageUI.get()); m_webPageUI->getURIEntry().uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1)); m_webPageUI->getURIEntry().uriEntryEditingChangedByUser.connect(boost::bind(&SimpleUI::onURLEntryEditedByUser, this, _1)); - m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this)); + m_webPageUI->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1)); m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::back, m_webEngine.get())); m_webPageUI->backPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); @@ -257,7 +257,6 @@ void SimpleUI::connectUISignals() M_ASSERT(m_quickAccess.get()); m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); - m_quickAccess->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_quickAccess->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this)); @@ -559,6 +558,11 @@ void SimpleUI::onOpenURLInNewTab(std::shared_ptr historyItem) +{ + onOpenURLInNewTab(historyItem, m_quickAccess->isDesktopMode()); +} + void SimpleUI::onMostVisitedTileClicked(std::shared_ptr< services::HistoryItem > historyItem, int itemsNumber) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); @@ -728,23 +732,18 @@ void SimpleUI::onURLEntryEditedByUser(const std::shared_ptr editedU { string editedUrl(*editedUrlPtr); int historyItemsVisibleMax = - m_quickAccess->getUrlHistoryList()->getVisibleItemsMax(); + m_webPageUI->getUrlHistoryList()->getVisibleItemsMax(); int minKeywordLength = - m_quickAccess->getUrlHistoryList()->getMinKeywordLength(); + m_webPageUI->getUrlHistoryList()->getMinKeywordLength(); std::shared_ptr result = m_historyService->getHistoryItemsByKeywordsString(editedUrl, historyItemsVisibleMax, minKeywordLength); - m_quickAccess->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); -} - -void SimpleUI::onURLEntryEdited() -{ - m_quickAccess->getUrlHistoryList()->onURLEntryEdited(); + m_webPageUI->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); } void SimpleUI::onMouseClick() { - m_quickAccess->getUrlHistoryList()->onMouseClick(); + m_webPageUI->getUrlHistoryList()->onMouseClick(); } void SimpleUI::webEngineURLChanged(const std::string url) diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index a4f8486..f50db74 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -132,6 +132,10 @@ private: void onHistoryRemoved(const std::string& uri); void onOpenURLInNewTab(std::shared_ptr historyItem, bool desktopMode); + /** + * @brief Handles 'openUrlInNewTab' signals. Uses QuickAccess to indicate desktop/mobile mode. + */ + void onOpenURLInNewTab(std::shared_ptr historyItem); void onMostVisitedTileClicked(std::shared_ptr historyItem, int itemsNumber); void onClearHistoryClicked(); diff --git a/services/WebPageUI/CMakeLists.txt b/services/WebPageUI/CMakeLists.txt index ddcb2e9..6171eae 100644 --- a/services/WebPageUI/CMakeLists.txt +++ b/services/WebPageUI/CMakeLists.txt @@ -4,12 +4,22 @@ set(WebPageUI_SRCS WebPageUI.cpp ButtonBar.cpp URIEntry.cpp + UrlHistoryList/UrlHistoryList.cpp + UrlHistoryList/GenlistManager.cpp + UrlHistoryList/GenlistManagerCallbacks.cpp + UrlHistoryList/UrlMatchesStyler.cpp + UrlHistoryList/GenlistItemsManager.cpp ) set(WebPageUI_HEADERS WebPageUI.h ButtonBar.h URIEntry.h + UrlHistoryList/UrlHistoryList.h + UrlHistoryList/GenlistManager.h + UrlHistoryList/GenlistManagerCallbacks.h + UrlHistoryList/UrlMatchesStyler.h + UrlHistoryList/GenlistItemsManager.h ) include(Coreheaders) @@ -59,6 +69,7 @@ set(edcFiles RightButtonBar.edc URIEntry.edc PrivateMode.edc + UrlHistoryList.edc ) foreach(edec ${edcFiles}) diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 7be0408..0376a6a 100644 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -80,7 +80,6 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entry, "activated", URIEntry::activated, this); evas_object_smart_callback_add(m_entry, "aborted", URIEntry::aborted, this); evas_object_smart_callback_add(m_entry, "preedit,changed", URIEntry::preeditChange, this); - evas_object_smart_callback_add(m_entry, "changed", URIEntry::_uri_entry_editing_changed, this); evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::_uri_entry_editing_changed_user, this); evas_object_smart_callback_add(m_entry, "focused", URIEntry::focused, this); evas_object_smart_callback_add(m_entry, "unfocused", URIEntry::unfocused, this); @@ -102,6 +101,11 @@ Evas_Object* URIEntry::getContent() return m_entry_layout; } +Evas_Object* URIEntry::getEntryWidget() +{ + return m_entry; +} + void URIEntry::changeUri(const std::string& newUri) { BROWSER_LOGD("%s: newUri=%s", __func__, newUri.c_str()); @@ -237,12 +241,6 @@ void URIEntry::_uri_entry_editing_changed_user(void* data, Evas_Object* /* obj * self->uriEntryEditingChangedByUser(std::make_shared(entry)); } -void URIEntry::_uri_entry_editing_changed(void* data, Evas_Object* /* obj */, void* /* event_info */) -{ - URIEntry* self = static_cast(data); - self->uriEntryEditingChanged(); -} - void URIEntry::setUrlGuideText(const char* txt) const { #if PLATFORM(TIZEN) @@ -254,7 +252,6 @@ void URIEntry::setUrlGuideText(const char* txt) const void URIEntry::unfocused(void* data, Evas_Object*, void*) { - BROWSER_LOGD("%s", __func__); URIEntry* self = static_cast(data); self->m_entrySelectedAllFirst = false; self->setUrlGuideText(GUIDE_TEXT_UNFOCUSED); diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index 01a20ab..478bc5e 100644 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -40,13 +40,12 @@ public: ~URIEntry(); void init(Evas_Object* parent); Evas_Object* getContent(); + Evas_Object* getEntryWidget(); void changeUri(const std::string&); boost::signals2::signal uriChanged; - // uri edition change - boost::signals2::signal uriEntryEditingChanged; // uri edition change (by a user) boost::signals2::signal)> uriEntryEditingChangedByUser; @@ -108,7 +107,6 @@ private: static void _fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); static void _uri_entry_btn_clicked(void* data, Evas_Object* obj, void* event_info); static void _uri_entry_clicked(void* data, Evas_Object* obj, void* event_info); - static void _uri_entry_editing_changed(void* data, Evas_Object* obj, void* event_info); static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); static void focusedBtn(void* data, Evas_Object* obj, void* event_info); diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp new file mode 100644 index 0000000..b868747 --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp @@ -0,0 +1,85 @@ +/* + * GenlistItemsManager.cpp + * + * Created on: Oct 23, 2015 + * Author: a.skobodzins + */ + +#include "GenlistItemsManager.h" +#include "BrowserLogger.h" + +namespace tizen_browser { +namespace base_ui { + +GenlistItemsManager::GenlistItemsManager() +{ + ptrMap.insert( { GenlistItemType::ITEM_CURRENT, + make_shared() }); + ptrMap.insert( { GenlistItemType::ITEM_FIRST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_LAST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_SPACE_FIRST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_SPACE_LAST, + make_shared() }); +} + +GenlistItemsManager::~GenlistItemsManager() +{ +} + +Elm_Object_Item* GenlistItemsManager::getItem(GenlistItemType type) +{ + return *ptrMap.at(type); +} + +void GenlistItemsManager::setItems(std::initializer_list types, + Elm_Object_Item* item) +{ + for (auto i : types) { + *ptrMap.at(i) = item; + } +} + +void GenlistItemsManager::setItemsIfNullptr( + std::initializer_list types, Elm_Object_Item* item) +{ + for (auto i : types) { + if (!getItem(i)) { + setItems( { i }, item); + } + } +} + +void GenlistItemsManager::assignItem(GenlistItemType dst, GenlistItemType src) +{ + setItems( { dst }, getItem(src)); +} + +bool GenlistItemsManager::shiftItemDown(GenlistItemType item) +{ + if (!getItem(item)) + return false; + Elm_Object_Item* item_next = elm_genlist_item_next_get(getItem(item)); + if (item_next) { + setItems( { item }, item_next); + return true; + } + return false; +} + +bool GenlistItemsManager::shiftItemUp(GenlistItemType item) +{ + if (!getItem(item)) + return false; + Elm_Object_Item* item_prev = elm_genlist_item_prev_get(getItem(item)); + if (item_prev) { + setItems( { item }, item_prev); + return true; + } + return false; +} + +} /* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h new file mode 100644 index 0000000..b8901d3 --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h @@ -0,0 +1,62 @@ +/* + * GenlistItemsManager.h + * + * Created on: Oct 23, 2015 + * Author: a.skobodzins + */ + +#ifndef GENLISTITEMSMANAGER_H_ +#define GENLISTITEMSMANAGER_H_ + +#include +#include + +#include + +using namespace std; + +namespace tizen_browser { +namespace base_ui { + +enum class GenlistItemType +{ + ITEM_CURRENT, ITEM_FIRST, ITEM_LAST, ITEM_SPACE_FIRST, ITEM_SPACE_LAST +}; + +/** + * Stores and manipulated pointers on Elm_Object_Item for GenlistManager + */ +class GenlistItemsManager +{ +public: + GenlistItemsManager(); + virtual ~GenlistItemsManager(); + + Elm_Object_Item* getItem(GenlistItemType type); + void setItems(std::initializer_list types, + Elm_Object_Item* item); + /** + * Same as #setItems, except only nullptr value pointers are set + */ + void setItemsIfNullptr(std::initializer_list types, + Elm_Object_Item* item); + /** + * Assign src pointer value to dst. + */ + void assignItem(GenlistItemType dst, GenlistItemType src); + /** + * Assign item of a given type to a elm_genlist_item_next_get item, if + * there is one. Return false, if value has not changed. + */ + bool shiftItemDown(GenlistItemType item); + bool shiftItemUp(GenlistItemType item); + +private: + map> ptrMap; + +}; + +} /* namespace base_ui */ +} /* namespace tizen_browser */ + +#endif /* GENLISTITEMSMANAGER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp similarity index 61% rename from services/QuickAccess/UrlHistoryList/GenlistManager.cpp rename to services/WebPageUI/UrlHistoryList/GenlistManager.cpp index 7977861..2b17152 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp @@ -14,9 +14,11 @@ * limitations under the License. */ +#include "BrowserLogger.h" #include "GenlistManager.h" #include "GenlistManagerCallbacks.h" #include "UrlMatchesStyler.h" +#include "GenlistItemsManager.h" namespace tizen_browser { namespace base_ui { @@ -24,11 +26,12 @@ namespace base_ui { GenlistManager::GenlistManager() { m_urlMatchesStyler = make_shared(); + m_itemsManager = make_shared(); m_historyItemClass = elm_genlist_item_class_new(); m_historyItemClass->item_style = "url_historylist_grid_item"; m_historyItemClass->func.text_get = nullptr; - m_historyItemClass->func.content_get = m_contentGet; + m_historyItemClass->func.content_get = m_itemClassContentGet; m_historyItemClass->func.state_get = nullptr; m_historyItemClass->func.del = nullptr; @@ -49,7 +52,7 @@ GenlistManager::~GenlistManager() void GenlistManager::clearWidget() { - if(m_genlist && elm_genlist_items_count(m_genlist)) + if (m_genlist && elm_genlist_items_count(m_genlist)) elm_genlist_clear(m_genlist); } @@ -58,6 +61,16 @@ void GenlistManager::onMouseFocusChange(bool mouseInsideWidget) this->mouseInsideWidget = mouseInsideWidget; } +void GenlistManager::setSingleBlockHide(bool block) +{ + m_singleHideBlock = block; +} + +bool GenlistManager::getSingleBlockHide() +{ + return m_singleHideBlock; +} + Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) { if (!widgetExists()) { @@ -67,11 +80,12 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (!genlistShowScrollbar) { + if (!GENLIST_SHOW_SCROLLBAR) { elm_scroller_policy_set(m_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); } - + elm_object_event_callback_add(m_genlist, + GenlistManagerCallbacks::_object_event, this); evas_object_smart_callback_add(m_genlist, "edge,top", GenlistManagerCallbacks::_genlist_edge_top, this); evas_object_smart_callback_add(m_genlist, "edge,bottom", @@ -86,8 +100,6 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) GenlistManagerCallbacks::_genlist_focused, this); evas_object_smart_callback_add(m_genlist, "unfocused", GenlistManagerCallbacks::_genlist_unfocused, this); - - } return m_genlist; } @@ -99,47 +111,79 @@ Evas_Object* GenlistManager::getWidget() return m_genlist; } +GenlistItemsManagerPtr GenlistManager::getItemsManager() +{ + return m_itemsManager; +} + void GenlistManager::showWidget(const string& editedUrl, shared_ptr matchedEntries) { clearWidget(); prepareUrlsVector(editedUrl, matchedEntries); - m_itemUrlFirst = m_itemUrlLast = nullptr; + m_itemsManager->setItems( { GenlistItemType::ITEM_FIRST, + GenlistItemType::ITEM_LAST }, nullptr); Elm_Object_Item* itemAppended = nullptr; - for(auto it : m_readyUrlPairs) { + for (auto it : m_readyUrlPairs) { itemAppended = elm_genlist_item_append(m_genlist, m_historyItemClass, - it.get(), nullptr, ELM_GENLIST_ITEM_NONE, GenlistManagerCallbacks::_item_selected, it.get()); - if (!m_itemUrlFirst) - m_itemUrlFirst = itemAppended; + it.get(), nullptr, ELM_GENLIST_ITEM_NONE, + GenlistManagerCallbacks::_item_selected, it.get()); + m_itemsManager->setItemsIfNullptr( { GenlistItemType::ITEM_FIRST }, + itemAppended); } - m_itemUrlLast = itemAppended; + m_itemsManager->setItems( { GenlistItemType::ITEM_LAST }, itemAppended); - if (widgetPreviouslyHidden) { - widgetPreviouslyHidden = false; + if (getWidgetPreviouslyHidden()) { + setWidgetPreviouslyHidden(false); startScrollIn(); } } +const char* GenlistManager::getItemUrl(GenlistItemType type) +{ + if (!m_itemsManager->getItem( { type })) + return ""; + void* data = elm_object_item_data_get(m_itemsManager->getItem( { type })); + if (!data) + return ""; + const UrlPair* const urlPair = reinterpret_cast(data); + if (!urlPair) + return ""; + return urlPair->urlOriginal.c_str(); +} + void GenlistManager::hideWidgetPretty() { - if (widgetPreviouslyHidden) { + if (getSingleBlockHide()) { + setSingleBlockHide(false); + return; + } + + m_itemsManager->setItems( { GenlistItemType::ITEM_CURRENT }, nullptr); + + if (getWidgetPreviouslyHidden()) { hideWidgetInstant(); return; } startScrollOut(); - widgetPreviouslyHidden = true; + setWidgetPreviouslyHidden(true); } void GenlistManager::hideWidgetInstant() { - if(m_genlist) + if (m_genlist) evas_object_hide(m_genlist); } -bool GenlistManager::isWidgetHidden() +bool GenlistManager::getWidgetPreviouslyHidden() { - return widgetPreviouslyHidden; + return m_widgetPreviouslyHidden; +} + +void GenlistManager::setWidgetPreviouslyHidden(bool previouslyHidden) +{ + this->m_widgetPreviouslyHidden = previouslyHidden; } void GenlistManager::onMouseClick() @@ -151,10 +195,13 @@ void GenlistManager::onMouseClick() void GenlistManager::startScrollIn() { - if (m_itemUrlFirst) { + if (m_itemsManager->getItem(GenlistItemType::ITEM_FIRST)) { addSpaces(); - elm_genlist_item_show(m_itemSpaceLast, ELM_GENLIST_ITEM_SCROLLTO_TOP); - elm_genlist_item_bring_in(m_itemUrlFirst, + elm_genlist_item_show( + m_itemsManager->getItem(GenlistItemType::ITEM_SPACE_LAST), + ELM_GENLIST_ITEM_SCROLLTO_TOP); + elm_genlist_item_bring_in( + m_itemsManager->getItem(GenlistItemType::ITEM_FIRST), ELM_GENLIST_ITEM_SCROLLTO_TOP); } } @@ -162,48 +209,45 @@ void GenlistManager::startScrollIn() void GenlistManager::startScrollOut() { addSpaces(); - if (m_itemSpaceFirst) { - elm_genlist_item_bring_in(m_itemSpaceFirst, - ELM_GENLIST_ITEM_SCROLLTO_TOP); + Elm_Object_Item* first = m_itemsManager->getItem( + GenlistItemType::ITEM_SPACE_FIRST); + if (first) { + elm_genlist_item_bring_in(first, ELM_GENLIST_ITEM_SCROLLTO_TOP); } } -void GenlistManager::setLastEdgeTop(bool edgeTop) -{ - lastEdgeTop = edgeTop; -} - -bool GenlistManager::getLastEdgeTop() -{ - return lastEdgeTop; -} - void GenlistManager::addSpaces() { - if (m_itemUrlLast) { - m_itemSpaceFirst = m_itemSpaceLast = nullptr; + if (m_itemsManager->getItem(GenlistItemType::ITEM_LAST)) { + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_FIRST, + GenlistItemType::ITEM_SPACE_LAST }, nullptr); Elm_Object_Item* itemAppended = nullptr; for (auto i = 0; i < HISTORY_ITEMS_VISIBLE_MAX; ++i) { // append spaces to the last url item, so they can be easily cleared itemAppended = elm_genlist_item_append(m_genlist, - m_historyItemSpaceClass, nullptr, m_itemUrlLast, - ELM_GENLIST_ITEM_NONE, nullptr, this); - if (!m_itemSpaceFirst) - m_itemSpaceFirst = itemAppended; + m_historyItemSpaceClass, nullptr, + m_itemsManager->getItem(GenlistItemType::ITEM_LAST), + ELM_GENLIST_ITEM_NONE, nullptr, nullptr); + elm_object_focus_allow_set(itemAppended, EINA_FALSE); + m_itemsManager->setItemsIfNullptr( { + GenlistItemType::ITEM_SPACE_FIRST }, itemAppended); } - m_itemSpaceLast = itemAppended; + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_LAST }, + itemAppended); } } void GenlistManager::removeSpaces() { - if (m_itemUrlLast) { - elm_genlist_item_subitems_clear(m_itemUrlLast); + if (m_itemsManager->getItem(GenlistItemType::ITEM_LAST)) { + elm_genlist_item_subitems_clear( + m_itemsManager->getItem(GenlistItemType::ITEM_LAST)); } - m_itemSpaceFirst = m_itemSpaceLast = nullptr; + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_FIRST, + GenlistItemType::ITEM_SPACE_LAST }, nullptr); } -Evas_Object* GenlistManager::m_contentGet(void* data, Evas_Object* obj, +Evas_Object* GenlistManager::m_itemClassContentGet(void* data, Evas_Object* obj, const char* part) { Evas_Object* label = elm_label_add(obj); @@ -225,7 +269,6 @@ void GenlistManager::prepareUrlsVector(const string& editedUrl, { // free previously used urls. IMPORTANT: it has to be assured that previous // genlist items are not using these pointers. - m_readyUrls.clear(); m_readyUrlPairs.clear(); for (auto it : *matchedEntries) { UrlPair newUrlPair(it->getUrl(), diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.h b/services/WebPageUI/UrlHistoryList/GenlistManager.h similarity index 74% rename from services/QuickAccess/UrlHistoryList/GenlistManager.h rename to services/WebPageUI/UrlHistoryList/GenlistManager.h index b1e91e1..bec4f4c 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.h @@ -20,7 +20,6 @@ #include #include "services/HistoryService/HistoryItem.h" #include -#include "BrowserLogger.h" using namespace std; @@ -28,12 +27,23 @@ namespace tizen_browser { namespace base_ui { class GenlistManagerCallbacks; +class GenlistItemsManager; +enum class GenlistItemType +; +typedef shared_ptr GenlistItemsManagerPtr; class UrlMatchesStyler; typedef shared_ptr UrlMatchesStylerPtr; -typedef struct UrlPair_s { - UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {} +typedef struct UrlPair_s +{ + UrlPair_s(string a, string b) : + urlOriginal(a), urlHighlighted(b) + { + } string urlOriginal; + /** + * Url plus styling tags. + */ string urlHighlighted; } UrlPair; @@ -46,12 +56,20 @@ public: Evas_Object* createWidget(Evas_Object* parentLayout); Evas_Object* getWidget(); + GenlistItemsManagerPtr getItemsManager(); void showWidget(const string& editedUrl, shared_ptr matchedEntries); + /** + * Hide widget by scrolling out. + */ void hideWidgetPretty(); + /** + * Hide widget by evas_object_hide. + */ void hideWidgetInstant(); - bool isWidgetHidden(); + void setWidgetPreviouslyHidden(bool previouslyHidden); + bool getWidgetPreviouslyHidden(); void onMouseClick(); /** @@ -59,24 +77,32 @@ public: */ void addSpaces(); void removeSpaces(); + /** + * Clear all elements from a genlist. + */ void clearWidget(); + /** + * When set to true, the next hide attempt will be blocked. + */ + void setSingleBlockHide(bool block); + bool getSingleBlockHide(); boost::signals2::signal signalItemSelected; boost::signals2::signal signalWidgetFocused; boost::signals2::signal signalWidgetUnfocused; + boost::signals2::signal signalItemFocusChange; + + const char* getItemUrl(GenlistItemType type); private: - static Evas_Object* m_contentGet(void *data, Evas_Object *obj, + static Evas_Object* m_itemClassContentGet(void *data, Evas_Object *obj, const char *part); - bool widgetExists() - { - return m_genlist != nullptr; - } + + bool widgetExists() {return m_genlist != nullptr;} + void prepareUrlsVector(const string& editedUrl, shared_ptr matchedEntries); - void setLastEdgeTop(bool edgeTop); - bool getLastEdgeTop(); void onMouseFocusChange(bool mouseInsideWidget); void startScrollIn(); @@ -84,8 +110,8 @@ private: Evas_Object* m_parentLayout = nullptr; Evas_Object* m_genlist = nullptr; - const bool genlistShowScrollbar = false; + const bool GENLIST_SHOW_SCROLLBAR = false; // don't know how to get from edc: const int HISTORY_ITEM_H = 82; const int HISTORY_ITEMS_VISIBLE_MAX = 5; @@ -96,22 +122,17 @@ private: * Set to true, whenever hide request occurs. Set to false, whenever show * request occurs. Needed to indicate when genlist should slide in. */ - bool widgetPreviouslyHidden = true; + bool m_widgetPreviouslyHidden = true; + bool m_singleHideBlock = false; /* * If mouse click received and mouse is outside widget, hide it. */ bool mouseInsideWidget = true; - /* - * needed to indicate direction of the scroll in 'anim,stop' callback - */ - bool lastEdgeTop = true; Elm_Gengrid_Item_Class* m_historyItemClass; Elm_Gengrid_Item_Class* m_historyItemSpaceClass; - Elm_Object_Item* m_itemUrlFirst = nullptr; - Elm_Object_Item* m_itemUrlLast = nullptr; - Elm_Object_Item* m_itemSpaceFirst = nullptr; - Elm_Object_Item* m_itemSpaceLast = nullptr; + + GenlistItemsManagerPtr m_itemsManager; /* * keeps shared pointers to strings, that are ready to be displayed, so they can be @@ -120,7 +141,6 @@ private: * labels from these pointers in m_contentGet(). in case of segfaults, delete copy of pointers * manually in m_contentGet(). */ - vector> m_readyUrls; vector> m_readyUrlPairs; UrlMatchesStylerPtr m_urlMatchesStyler; diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp similarity index 52% rename from services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp rename to services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp index 17d1cf3..757d356 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp @@ -15,7 +15,9 @@ */ #include "BrowserLogger.h" -#include +#include "GenlistManagerCallbacks.h" +#include "GenlistItemsManager.h" +#include namespace tizen_browser { namespace base_ui { @@ -30,21 +32,19 @@ GenlistManagerCallbacks::~GenlistManagerCallbacks() { } -void GenlistManagerCallbacks::_genlist_edge_top(void *data, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_edge_top(void* data, + Evas_Object* /*obj*/, void* /*event_info*/) { auto manager = static_cast(data); - manager->setLastEdgeTop(false); // spaces added for 'slide in' effect are not longer needed manager->removeSpaces(); } -void GenlistManagerCallbacks::_genlist_edge_bottom(void *data, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_edge_bottom(void* data, + Evas_Object* /*obj*/, void* /*event_info*/) { auto manager = static_cast(data); - manager->setLastEdgeTop(true); - if (manager->isWidgetHidden()) { + if (manager->getWidgetPreviouslyHidden()) { manager->clearWidget(); evas_object_hide(manager->getWidget()); } @@ -56,6 +56,7 @@ void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/, auto manager = static_cast(data); manager->onMouseFocusChange(true); } + void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* /*event_info*/) { @@ -63,20 +64,18 @@ void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, manager->onMouseFocusChange(false); } -void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, + Evas_Object* /*obj*/, void* /*event_info*/) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalWidgetFocused(); } } -void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, + Evas_Object* /*obj*/, void* /*event_info*/) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalWidgetUnfocused(); } } @@ -86,13 +85,45 @@ void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/, { const UrlPair* const item = reinterpret_cast(data); if (item) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalItemSelected(item->urlOriginal); genlistManager->hideWidgetPretty(); } } } +Eina_Bool GenlistManagerCallbacks::_object_event(void* /*data*/, + Evas_Object* /*obj*/, Evas_Object* /*src*/, Evas_Callback_Type /*type*/, + void* event_info) +{ + genlistManager->removeSpaces(); + genlistManager->setWidgetPreviouslyHidden(false); + + if (genlistManager) { + Ecore_Event_Key *ev = static_cast(event_info); + const std::string keyName = ev->keyname; + if (!keyName.compare("Down") || !keyName.compare("Up")) { + GenlistItemsManagerPtr itemsManager = + genlistManager->getItemsManager(); + if (!itemsManager->getItem(GenlistItemType::ITEM_CURRENT)) { + itemsManager->assignItem(GenlistItemType::ITEM_CURRENT, + GenlistItemType::ITEM_FIRST); + } else { + if (!keyName.compare("Down")) { + itemsManager->shiftItemDown(GenlistItemType::ITEM_CURRENT); + } else { + if (!itemsManager->shiftItemUp( + GenlistItemType::ITEM_CURRENT)) { + // 'up' pressed on a first item. don't hide widget + genlistManager->setSingleBlockHide(true); + } + } + } + genlistManager->signalItemFocusChange(); + } + } + return EINA_FALSE; +} + } /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h similarity index 91% rename from services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h rename to services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h index 228108d..d87b590 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h @@ -17,7 +17,7 @@ #ifndef GENLISTMANAGERCALLBACKS_H_ #define GENLISTMANAGERCALLBACKS_H_ -#include +#include "GenlistManager.h" #include #include @@ -45,6 +45,9 @@ public: static void _genlist_unfocused(void* data, Evas_Object* obj, void* event_info); + static Eina_Bool _object_event(void* data, Evas_Object* obj, + Evas_Object* src, Evas_Callback_Type type, void* event_info); + static void _item_selected(void* data, Evas_Object* obj, void* event_info); static void setGenlistManager(GenlistManager* genlistManager) diff --git a/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp new file mode 100644 index 0000000..45e6d2a --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "UrlHistoryList.h" +#include "GenlistManager.h" +#include "BrowserLogger.h" +#include "GenlistItemsManager.h" + +namespace tizen_browser { +namespace base_ui { + +UrlHistoryList::UrlHistoryList() : + m_layout(nullptr) +{ + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("WebPageUI/UrlHistoryList.edj"); + m_genlistListManager = make_shared(); + m_genlistListManager->signalItemSelected.connect( + boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); + m_genlistListManager->signalWidgetFocused.connect( + boost::bind(&UrlHistoryList::onListWidgetFocused, this)); + m_genlistListManager->signalWidgetUnfocused.connect( + boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); + m_genlistListManager->signalItemFocusChange.connect( + boost::bind(&UrlHistoryList::onItemFocusChange, this)); +} + +UrlHistoryList::~UrlHistoryList() +{ +} + +void UrlHistoryList::setMembers(Evas_Object* parent, Evas_Object* editedEntry) +{ + m_parent = parent; + m_entry = editedEntry; + + evas_object_smart_callback_add(m_entry, "changed,user", + UrlHistoryList::_uri_entry_editing_changed_user, this); + evas_object_smart_callback_add(m_entry, "unfocused", + UrlHistoryList::_uri_entry_unfocused, this); +} + +void UrlHistoryList::createLayout(Evas_Object* parentLayout) +{ + if (m_layout) + return; + + m_layout = elm_layout_add(parentLayout); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + Evas_Object* widgetList = m_genlistListManager->createWidget(m_layout); + m_genlistListManager->hideWidgetPretty(); + elm_object_part_content_set(m_layout, "list_swallow", widgetList); + evas_object_show(widgetList); + evas_object_show(m_layout); +} + +Evas_Object* UrlHistoryList::getContent() +{ + if (!m_layout) + createLayout(m_parent); + + return m_layout; +} + +Evas_Object* UrlHistoryList::getEditedEntry() +{ + return m_entry; +} + +void UrlHistoryList::saveEntryEditedContent() +{ + m_entryEditedContent = elm_entry_entry_get(m_entry); +} + +void UrlHistoryList::restoreEntryEditedContent() +{ + elm_entry_entry_set(m_entry, m_entryEditedContent.c_str()); +} + +void UrlHistoryList::saveEntryURLContent() +{ + m_entryURLContent = elm_entry_entry_get(m_entry); +} + +void UrlHistoryList::restoreEntryURLContent() +{ + elm_entry_entry_set(m_entry, m_entryURLContent.c_str()); +} + +Evas_Object* UrlHistoryList::getGenlist() +{ + return m_genlistListManager->getWidget(); +} + +void UrlHistoryList::hideWidgetPretty() +{ + m_genlistListManager->hideWidgetPretty(); +} + +void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries) +{ + if (matchedEntries->size() == 0) { + m_genlistListManager->hideWidgetPretty(); + } else { + Evas_Object* widgetList = m_genlistListManager->getWidget(); + m_genlistListManager->showWidget(editedUrl, matchedEntries); + evas_object_show(m_parent); + evas_object_show(widgetList); + evas_object_show(m_layout); + } +} + +void UrlHistoryList::onItemFocusChange() +{ + elm_entry_entry_set(m_entry, + m_genlistListManager->getItemUrl(GenlistItemType::ITEM_CURRENT)); +} + +void UrlHistoryList::onMouseClick() +{ + m_genlistListManager->onMouseClick(); +} + +void UrlHistoryList::onListItemSelect(std::string content) +{ + openURLInNewTab (make_shared(content));hideWidgetPretty(); +} + +void UrlHistoryList::onListWidgetFocused() +{ + saveEntryURLContent(); +} + +void UrlHistoryList::onListWidgetUnfocused() +{ + m_genlistListManager->hideWidgetPretty(); + restoreEntryURLContent(); +} + +void UrlHistoryList::_uri_entry_editing_changed_user(void* data, + Evas_Object* /* obj */, void* /* event_info */) +{ + UrlHistoryList* self = reinterpret_cast(data); + self->saveEntryEditedContent(); +} + +void UrlHistoryList::_uri_entry_unfocused(void* data, Evas_Object* /* obj */, + void* /* event_info */) +{ + + UrlHistoryList* self = reinterpret_cast(data); + self->hideWidgetPretty(); +} + +}/* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h similarity index 68% rename from services/QuickAccess/UrlHistoryList/UrlHistoryList.h rename to services/WebPageUI/UrlHistoryList/UrlHistoryList.h index f42a425..02636d7 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h @@ -28,7 +28,6 @@ using namespace std; namespace tizen_browser { namespace base_ui { -class QuickAccess; class GenlistManager; typedef shared_ptr GenlistManagerPtr; @@ -43,56 +42,35 @@ enum class EditedUrlState }; /** - * Needed to indicate who did the last url entry edition (user/other/other many times). Used - * to indicate when widget can be hidden in a pretty way or an instant way. - */ -class EditedUrlStatesHelper -{ -public: - EditedUrlStatesHelper() - { - } - void changeState(bool editedByUser) - { - if (editedByUser) { - currentState = EditedUrlState::EDITED_BY_USER; - } else { - if (currentState == EditedUrlState::EDITED_BY_USER) { - currentState = EditedUrlState::EDITED_OTHER_FIRST; - } else { - currentState = EditedUrlState::EDITED_OTHER_MANY_TIMES; - } - } - } - EditedUrlState getCurrentState() - { - return currentState; - } -private: - EditedUrlState currentState = EditedUrlState::EDITED_BY_USER; -}; - -/** * Manages list of url matches (URL from history). Manages top layout, creates * widget displaying url items. */ class UrlHistoryList { public: - UrlHistoryList(QuickAccess* quickAccess); + UrlHistoryList(); virtual ~UrlHistoryList(); - void createLayout(Evas_Object* parentLayout); - Evas_Object* getLayout(); + Evas_Object* getContent(); + Evas_Object* getEditedEntry(); + void saveEntryEditedContent(); + void restoreEntryEditedContent(); + void saveEntryURLContent(); + void restoreEntryURLContent(); + Evas_Object* getGenlist(); + + // remove if unused + void hideWidgetPretty(); + + void setMembers(Evas_Object* parent, Evas_Object* chainObject); // // on uri entry widget "changed,user" signal void onURLEntryEditedByUser(const string& editedUrl, shared_ptr matchedEntries); - // on uri entry widget "changed" signal - void onURLEntryEdited(); + void onItemFocusChange(); void onMouseClick(); - boost::signals2::signal, bool)> openURLInNewTab; + boost::signals2::signal)> openURLInNewTab; int getVisibleItemsMax() const { @@ -105,21 +83,29 @@ public: } private: + void createLayout(Evas_Object* parentLayout); void onListItemSelect(std::string content); void onListWidgetFocused(); void onListWidgetUnfocused(); - EditedUrlStatesHelper editedUrlStatesHelper; + static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_unfocused(void* data, Evas_Object* obj, void* event_info); // the maximum items number on a list const int VISIBLE_ITEMS_MAX = 12; // the minimum length of the keyword used to search matches const int MIN_KEYWORD_LENGTH = 3; - Evas_Object* m_layout; + Evas_Object* m_parent = nullptr; + // entry widget from which change signals are received + Evas_Object* m_entry = nullptr; + // content of the entry, needed to restore edited value + string m_entryEditedContent; + // content of the entry before edition: needed to restore original URL value + string m_entryURLContent; + Evas_Object* m_layout = nullptr; string m_edjFilePath; GenlistManagerPtr m_genlistListManager = nullptr; - QuickAccess* m_quickAccess; }; diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp similarity index 100% rename from services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp rename to services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h similarity index 100% rename from services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h rename to services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index 439a59e..fef4f9d 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -21,6 +21,7 @@ #include "BrowserLogger.h" #include "ServiceManager.h" #include "BrowserAssert.h" +#include "UrlHistoryList/UrlHistoryList.h" namespace tizen_browser { namespace base_ui { @@ -35,6 +36,7 @@ WebPageUI::WebPageUI() , m_progressBar(nullptr) , m_bookmarkManagerButton(nullptr) , m_URIEntry(new URIEntry()) + , m_urlHistoryList(std::make_shared()) , m_homePageActive(false) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -62,6 +64,11 @@ Evas_Object* WebPageUI::getContent() return m_mainLayout; } +UrlHistoryPtr WebPageUI::getUrlHistoryList() +{ + return m_urlHistoryList; +} + void WebPageUI::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -286,6 +293,9 @@ void WebPageUI::createLayout() elm_layout_signal_callback_add(m_URIEntry->getContent(), "slide_websearch", "elm", faviconClicked, this); + elm_theme_extension_add(nullptr, edjePath("WebPageUI/UrlHistoryList.edj").c_str()); + m_urlHistoryList->setMembers(m_parent, m_URIEntry->getEntryWidget()); + connectActions(); } @@ -445,6 +455,7 @@ void WebPageUI::refreshFocusChain() m_reload->setEnabled(false); } elm_object_focus_custom_chain_append(m_mainLayout, m_URIEntry->getContent(), NULL); + elm_object_focus_custom_chain_append(m_mainLayout, m_urlHistoryList->getContent(), NULL); } } // namespace tizen_browser diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index f9c387a..712203a 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -29,6 +29,9 @@ namespace tizen_browser { namespace base_ui { +class UrlHistoryList; +typedef std::shared_ptr UrlHistoryPtr; + class BROWSER_EXPORT WebPageUI : public tizen_browser::core::AbstractService, public tizen_browser::interfaces::AbstractUIComponent { public: WebPageUI(); @@ -36,6 +39,7 @@ public: virtual std::string getName(); virtual void init(Evas_Object* parent); virtual Evas_Object* getContent(); + UrlHistoryPtr getUrlHistoryList(); virtual void showUI(); virtual void hideUI(); void loadStopped(); @@ -107,6 +111,7 @@ private: std::unique_ptr m_leftButtonBar; std::unique_ptr m_rightButtonBar; std::unique_ptr m_URIEntry; + UrlHistoryPtr m_urlHistoryList; bool m_homePageActive; sharedAction m_back; diff --git a/services/QuickAccess/edc/UrlHistoryList.edc b/services/WebPageUI/edc/UrlHistoryList.edc similarity index 78% rename from services/QuickAccess/edc/UrlHistoryList.edc rename to services/WebPageUI/edc/UrlHistoryList.edc index 9cc5fb3..156ad2e 100644 --- a/services/QuickAccess/edc/UrlHistoryList.edc +++ b/services/WebPageUI/edc/UrlHistoryList.edc @@ -1,10 +1,12 @@ +#define LIST_OFFSET_X 255 +#define LIST_OFFSET_Y 104 #define URI_INPUTBOX_LENGTH 1720 -#define URI_INPUTBOX_LENGTH_SMALL 1460 +#define URI_INPUTBOX_LENGTH_SHORT 1460 #define HISTORY_ITEM_W URI_INPUTBOX_LENGTH #define HISTORY_ITEM_H 82 #define HISTORY_ITEMS_VISIBLE_MAX 5 /* - Right now, has to be a multiple of item's height. + has to be a multiple of item's height. */ #define LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX @@ -14,41 +16,17 @@ collections { parts { part { - name: "bg"; - type: RECT; - mouse_events: 1; - description - { - color: 232 122 32 150; - state: "default" 0.0; - visible: 0; - min: URI_INPUTBOX_LENGTH LIST_MAX_H; - max: -1 -1; - align: 0.0 0.0; - fixed: 1 1; - rel1 - { - relative: 0 0; - } - rel2 - { - relative: 1.0 1.0; - } - } - } - - part { name: "list_swallow"; type: SWALLOW; description { color: 255 0 0 150; - min: URI_INPUTBOX_LENGTH LIST_MAX_H; + min: URI_INPUTBOX_LENGTH_SHORT LIST_MAX_H; max: -1 -1; visible: 1; align: 0.0 0.0; rel1 { relative: 0 0; - offset: 0 0; + offset: LIST_OFFSET_X LIST_OFFSET_Y; } rel2 { relative: 1.0 0.5;