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)
set(edcFiles
QuickAccess.edc
DetailPopup.edc
- UrlHistoryList.edc
)
foreach(edec ${edcFiles})
#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())
, 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<UrlHistoryList>(this);
}
QuickAccess::~QuickAccess()
M_ASSERT(m_parent);
if (!m_layout) {
m_layout = createQuickAccessLayout(m_parent);
- m_urlHistoryListLayout = createUrlHistoryListLayout(m_layout);
}
return m_layout;
}
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 *)
{
{
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 {
return m_detailPopup;
}
-UrlHistoryPtr QuickAccess::getUrlHistoryList()
-{
- return m_urlHistoryList;
-}
-
void QuickAccess::backButtonClicked()
{
if (m_detailPopup.isVisible()) {
namespace tizen_browser{
namespace base_ui{
-class UrlHistoryList;
-typedef std::shared_ptr<UrlHistoryList> 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
bool isDesktopMode() const;
void setDesktopMode(bool mode);
DetailPopup & getDetailPopup();
- UrlHistoryPtr getUrlHistoryList();
void backButtonClicked();
inline bool isMostVisitedActive() const;
void refreshFocusChain();
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);
std::vector<Evas_Object *> 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;
+++ /dev/null
-/*
- * 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 "GenlistManager.h"
-#include "GenlistManagerCallbacks.h"
-#include "UrlMatchesStyler.h"
-
-namespace tizen_browser {
-namespace base_ui {
-
-GenlistManager::GenlistManager()
-{
- m_urlMatchesStyler = make_shared<UrlMatchesStyler>();
-
- 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.state_get = nullptr;
- m_historyItemClass->func.del = nullptr;
-
- m_historyItemSpaceClass = elm_genlist_item_class_new();
- m_historyItemSpaceClass->item_style = "url_historylist_grid_item_space";
- m_historyItemSpaceClass->func.text_get = nullptr;
- m_historyItemSpaceClass->func.content_get = nullptr;
- m_historyItemSpaceClass->func.state_get = nullptr;
- m_historyItemSpaceClass->func.del = nullptr;
-
- GenlistManagerCallbacks::setGenlistManager(this);
-}
-
-GenlistManager::~GenlistManager()
-{
- elm_genlist_item_class_free(m_historyItemClass);
-}
-
-void GenlistManager::clearWidget()
-{
- if(m_genlist && elm_genlist_items_count(m_genlist))
- elm_genlist_clear(m_genlist);
-}
-
-void GenlistManager::onMouseFocusChange(bool mouseInsideWidget)
-{
- this->mouseInsideWidget = mouseInsideWidget;
-}
-
-Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout)
-{
- if (!widgetExists()) {
- m_parentLayout = parentLayout;
- m_genlist = elm_genlist_add(parentLayout);
- evas_object_size_hint_weight_set(m_genlist, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- if (!genlistShowScrollbar) {
- elm_scroller_policy_set(m_genlist, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_OFF);
- }
-
- evas_object_smart_callback_add(m_genlist, "edge,top",
- GenlistManagerCallbacks::_genlist_edge_top, this);
- evas_object_smart_callback_add(m_genlist, "edge,bottom",
- GenlistManagerCallbacks::_genlist_edge_bottom, this);
-
- evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_IN,
- GenlistManagerCallbacks::_genlist_mouse_in, this);
- evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_OUT,
- GenlistManagerCallbacks::_genlist_mouse_out, this);
-
- evas_object_smart_callback_add(m_genlist, "focused",
- GenlistManagerCallbacks::_genlist_focused, this);
- evas_object_smart_callback_add(m_genlist, "unfocused",
- GenlistManagerCallbacks::_genlist_unfocused, this);
-
-
- }
- return m_genlist;
-}
-
-Evas_Object* GenlistManager::getWidget()
-{
- if (!widgetExists())
- createWidget(m_parentLayout);
- return m_genlist;
-}
-
-void GenlistManager::showWidget(const string& editedUrl,
- shared_ptr<services::HistoryItemVector> matchedEntries)
-{
- clearWidget();
- prepareUrlsVector(editedUrl, matchedEntries);
-
- m_itemUrlFirst = m_itemUrlLast = nullptr;
- Elm_Object_Item* itemAppended = nullptr;
- 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;
- }
- m_itemUrlLast = itemAppended;
-
- if (widgetPreviouslyHidden) {
- widgetPreviouslyHidden = false;
- startScrollIn();
- }
-}
-
-void GenlistManager::hideWidgetPretty()
-{
- if (widgetPreviouslyHidden) {
- hideWidgetInstant();
- return;
- }
- startScrollOut();
- widgetPreviouslyHidden = true;
-}
-
-void GenlistManager::hideWidgetInstant()
-{
- if(m_genlist)
- evas_object_hide(m_genlist);
-}
-
-bool GenlistManager::isWidgetHidden()
-{
- return widgetPreviouslyHidden;
-}
-
-void GenlistManager::onMouseClick()
-{
- if (!mouseInsideWidget) {
- hideWidgetPretty();
- }
-}
-
-void GenlistManager::startScrollIn()
-{
- if (m_itemUrlFirst) {
- addSpaces();
- elm_genlist_item_show(m_itemSpaceLast, ELM_GENLIST_ITEM_SCROLLTO_TOP);
- elm_genlist_item_bring_in(m_itemUrlFirst,
- ELM_GENLIST_ITEM_SCROLLTO_TOP);
- }
-}
-
-void GenlistManager::startScrollOut()
-{
- addSpaces();
- if (m_itemSpaceFirst) {
- elm_genlist_item_bring_in(m_itemSpaceFirst,
- 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;
- 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_itemSpaceLast = itemAppended;
- }
-}
-
-void GenlistManager::removeSpaces()
-{
- if (m_itemUrlLast) {
- elm_genlist_item_subitems_clear(m_itemUrlLast);
- }
- m_itemSpaceFirst = m_itemSpaceLast = nullptr;
-}
-
-Evas_Object* GenlistManager::m_contentGet(void* data, Evas_Object* obj,
- const char* part)
-{
- Evas_Object* label = elm_label_add(obj);
- if (strcmp(part, "matched_url") == 0) {
- const UrlPair* const item = reinterpret_cast<UrlPair*>(data);
- if (item) {
- elm_object_text_set(label, item->urlHighlighted.c_str());
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- }
- }
- return label;
-}
-
-void GenlistManager::prepareUrlsVector(const string& editedUrl,
- shared_ptr<services::HistoryItemVector> matchedEntries)
-{
- // 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(),
- m_urlMatchesStyler->getUrlHighlightedMatches(it->getUrl(),
- editedUrl));
- m_readyUrlPairs.push_back(make_shared < UrlPair > (newUrlPair));
- }
-}
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef GENLISTMANAGER_H_
-#define GENLISTMANAGER_H_
-
-#include <Elementary.h>
-#include "services/HistoryService/HistoryItem.h"
-#include <boost/signals2/signal.hpp>
-#include "BrowserLogger.h"
-
-using namespace std;
-
-namespace tizen_browser {
-namespace base_ui {
-
-class GenlistManagerCallbacks;
-class UrlMatchesStyler;
-typedef shared_ptr<UrlMatchesStyler> UrlMatchesStylerPtr;
-
-typedef struct UrlPair_s {
- UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {}
- string urlOriginal;
- string urlHighlighted;
-} UrlPair;
-
-class GenlistManager
-{
- friend class GenlistManagerCallbacks;
-public:
- GenlistManager();
- ~GenlistManager();
-
- Evas_Object* createWidget(Evas_Object* parentLayout);
- Evas_Object* getWidget();
-
- void showWidget(const string& editedUrl,
- shared_ptr<services::HistoryItemVector> matchedEntries);
- void hideWidgetPretty();
- void hideWidgetInstant();
- bool isWidgetHidden();
- void onMouseClick();
-
- /**
- * Add empty list elements to allow scroll in effect.
- */
- void addSpaces();
- void removeSpaces();
- void clearWidget();
-
- boost::signals2::signal<void(string)> signalItemSelected;
- boost::signals2::signal<void()> signalWidgetFocused;
- boost::signals2::signal<void()> signalWidgetUnfocused;
-
-private:
- static Evas_Object* m_contentGet(void *data, Evas_Object *obj,
- const char *part);
- bool widgetExists()
- {
- return m_genlist != nullptr;
- }
- void prepareUrlsVector(const string& editedUrl,
- shared_ptr<services::HistoryItemVector> matchedEntries);
-
- void setLastEdgeTop(bool edgeTop);
- bool getLastEdgeTop();
- void onMouseFocusChange(bool mouseInsideWidget);
-
- void startScrollIn();
- void startScrollOut();
-
- Evas_Object* m_parentLayout = nullptr;
- Evas_Object* m_genlist = nullptr;
- const bool genlistShowScrollbar = false;
-
- // don't know how to get from edc:
- const int HISTORY_ITEM_H = 82;
- const int HISTORY_ITEMS_VISIBLE_MAX = 5;
- // don't know how to calculate:
- const int GENLIST_H = HISTORY_ITEM_H * HISTORY_ITEMS_VISIBLE_MAX;
-
- /*
- * 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;
- /*
- * 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;
-
- /*
- * keeps shared pointers to strings, that are ready to be displayed, so they can be
- * passed through EFL, until they're not needed. IMPORTANT: it has to be
- * assured, that list is not cleared until all EFL items has created their
- * labels from these pointers in m_contentGet(). in case of segfaults, delete copy of pointers
- * manually in m_contentGet().
- */
- vector<shared_ptr<string>> m_readyUrls;
- vector<shared_ptr<UrlPair>> m_readyUrlPairs;
- UrlMatchesStylerPtr m_urlMatchesStyler;
-
-};
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
-
-#endif /* GENLISTMANAGER_H_ */
+++ /dev/null
-/*
- * 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 "BrowserLogger.h"
-#include <services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h>
-
-namespace tizen_browser {
-namespace base_ui {
-
-GenlistManager* GenlistManagerCallbacks::genlistManager = nullptr;
-
-GenlistManagerCallbacks::GenlistManagerCallbacks()
-{
-}
-
-GenlistManagerCallbacks::~GenlistManagerCallbacks()
-{
-}
-
-void GenlistManagerCallbacks::_genlist_edge_top(void *data, Evas_Object* /*obj*/,
- void* /*event_info*/)
-{
- auto manager = static_cast<GenlistManager*>(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*/)
-{
- auto manager = static_cast<GenlistManager*>(data);
- manager->setLastEdgeTop(true);
- if (manager->isWidgetHidden()) {
- manager->clearWidget();
- evas_object_hide(manager->getWidget());
- }
-}
-
-void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/,
- Evas_Object* /*obj*/, void* /*event_info*/)
-{
- auto manager = static_cast<GenlistManager*>(data);
- manager->onMouseFocusChange(true);
-}
-void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/,
- Evas_Object* /*obj*/, void* /*event_info*/)
-{
- auto manager = static_cast<GenlistManager*>(data);
- manager->onMouseFocusChange(false);
-}
-
-void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, Evas_Object* /*obj*/,
- void* /*event_info*/)
-{
- if(genlistManager)
- {
- genlistManager->signalWidgetFocused();
- }
-}
-
-void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, Evas_Object* /*obj*/,
- void* /*event_info*/)
-{
- if(genlistManager)
- {
- genlistManager->signalWidgetUnfocused();
- }
-}
-
-void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/,
- void* /*event_info*/)
-{
- const UrlPair* const item = reinterpret_cast<UrlPair*>(data);
- if (item) {
- if(genlistManager)
- {
- genlistManager->signalItemSelected(item->urlOriginal);
- genlistManager->hideWidgetPretty();
- }
- }
-}
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef GENLISTMANAGERCALLBACKS_H_
-#define GENLISTMANAGERCALLBACKS_H_
-
-#include <services/QuickAccess/UrlHistoryList/GenlistManager.h>
-#include <Elementary.h>
-#include <Evas.h>
-
-namespace tizen_browser {
-namespace base_ui {
-
-class GenlistManagerCallbacks
-{
-public:
- GenlistManagerCallbacks();
- virtual ~GenlistManagerCallbacks();
-
- static void _genlist_edge_top(void* data, Evas_Object* obj,
- void* event_info);
- static void _genlist_edge_bottom(void* data, Evas_Object* obj,
- void* event_info);
-
- static void _genlist_mouse_in(void* data, Evas* e, Evas_Object* obj,
- void* event_info);
- static void _genlist_mouse_out(void* data, Evas* e, Evas_Object* obj,
- void* event_info);
-
- static void _genlist_focused(void* data, Evas_Object* obj,
- void* event_info);
- static void _genlist_unfocused(void* data, Evas_Object* obj,
- void* event_info);
-
- static void _item_selected(void* data, Evas_Object* obj, void* event_info);
-
- static void setGenlistManager(GenlistManager* genlistManager)
- {
- GenlistManagerCallbacks::genlistManager = genlistManager;
- }
-
-private:
- static GenlistManager* genlistManager;
-
-};
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
-
-#endif /* GENLISTMANAGERCALLBACKS_H_ */
+++ /dev/null
-/*
- * 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 <Elementary.h>
-#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<GenlistManager>();
- 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<services::HistoryItemVector> 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 */
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef URLHISTORYLIST_H_
-#define URLHISTORYLIST_H_
-
-#include <memory>
-#include <Evas.h>
-
-#include "services/HistoryService/HistoryItem.h"
-#include <boost/signals2/signal.hpp>
-
-using namespace std;
-
-namespace tizen_browser {
-namespace base_ui {
-
-class QuickAccess;
-class GenlistManager;
-typedef shared_ptr<GenlistManager> GenlistManagerPtr;
-
-enum class EditedUrlState
-{
- // url was edited by a user (by typing)
- EDITED_BY_USER,
- // url was edited in other way than typing (but for the first time after previous user edition)
- EDITED_OTHER_FIRST,
- // url was edited in other way than typing (and previously was not edited by the user)
- EDITED_OTHER_MANY_TIMES
-};
-
-/**
- * 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);
- virtual ~UrlHistoryList();
- void createLayout(Evas_Object* parentLayout);
- Evas_Object* getLayout();
-
- // // on uri entry widget "changed,user" signal
- void onURLEntryEditedByUser(const string& editedUrl,
- shared_ptr<services::HistoryItemVector> matchedEntries);
- // on uri entry widget "changed" signal
- void onURLEntryEdited();
-
- void onMouseClick();
-
- boost::signals2::signal<void(shared_ptr<services::HistoryItem>, bool)> openURLInNewTab;
-
- int getVisibleItemsMax() const
- {
- return VISIBLE_ITEMS_MAX;
- }
-
- int getMinKeywordLength() const
- {
- return MIN_KEYWORD_LENGTH;
- }
-
-private:
- void onListItemSelect(std::string content);
- void onListWidgetFocused();
- void onListWidgetUnfocused();
-
- EditedUrlStatesHelper editedUrlStatesHelper;
-
- // 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;
- string m_edjFilePath;
-
- GenlistManagerPtr m_genlistListManager = nullptr;
- QuickAccess* m_quickAccess;
-
-};
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
-
-#endif /* URLHISTORYLIST_H_ */
+++ /dev/null
-/*
- * 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 "UrlMatchesStyler.h"
-
-namespace tizen_browser {
-namespace base_ui {
-
-UrlMatchesStyler::UrlMatchesStyler() :
- TAG_WHOLE_URL("<align=left><color=" + FONT_COLOR_NORMAL + "><font_size="+FONT_SIZE+">"),
- TAG_WHOLE_URL_CLOSE("</color></font></align>"),
- TAG_HIGHLIGHT("<hilight>"),
- TAG_HIGHLIGHT_CLOSE(closeTag(TAG_HIGHLIGHT)),
- TAG_COLOR("<color=" + FONT_COLOR_HIGHLIGHT + ">"),
- TAG_COLOR_CLOSE(closeTag(TAG_COLOR)),
- TAG_COMPLETE(TAG_HIGHLIGHT + TAG_COLOR),
- TAG_COMPLETE_CLOSE(TAG_HIGHLIGHT_CLOSE + TAG_COLOR_CLOSE),
- TAGS_COMPLETE_LEN(TAG_COMPLETE.length() + TAG_COMPLETE_CLOSE.length()) {
-}
-
-UrlMatchesStyler::~UrlMatchesStyler() {
-}
-
-string UrlMatchesStyler::closeTag(const string& tag) const {
- string closedTag(tag);
- return string(closedTag.insert(1, "/"));
-}
-
-string UrlMatchesStyler::getUrlHighlightedMatches(const string& styledUrl,
- const string& highlightingKeywords) const {
- vector < string > keywords;
- splitKeywordsString(highlightingKeywords, keywords);
-
- int_pairs rangesHighlight;
- for (auto key : keywords) {
- fillOccuranceRanges(styledUrl, key, rangesHighlight);
- }
-
- int_pairs mergedRangesHighlight;
- mergeRanges(rangesHighlight, mergedRangesHighlight);
- return getTaggedString(styledUrl, mergedRangesHighlight);
-}
-
-void UrlMatchesStyler::splitKeywordsString(const string& keywordsString,
- vector<string>& resultKeywords) const {
- boost::algorithm::split(resultKeywords, keywordsString,
- boost::is_any_of("\t "), boost::token_compress_on);
- // remove empty elements
- for (auto it = resultKeywords.begin(); it != resultKeywords.end();) {
- if ((*it).empty()) {
- it = resultKeywords.erase(it);
- } else {
- ++it;
- }
- }
-}
-
-void UrlMatchesStyler::fillOccuranceRanges(const string& _checkedString,
- const string& _searchedMatch, int_pairs& resultRanges) const {
- if (_checkedString.empty() || _searchedMatch.empty())
- return;
-
- string checkedString(_checkedString);
- string searchedMatch(_searchedMatch);
- boost::algorithm::to_lower(checkedString);
- boost::algorithm::to_lower(searchedMatch);
-
- int len = searchedMatch.length();
- vector<int> positions;
- getMatchesPositions(checkedString, searchedMatch, positions);
- for (auto pos : positions) {
- resultRanges.push_back( { pos, pos + len - 1 });
- }
-}
-
-void UrlMatchesStyler::getMatchesPositions(const string& checkedString,
- const string& searchedMatch, vector<int>& resultPositions) const {
- boost::regex match_regex(searchedMatch);
- for (auto it = boost::sregex_iterator(checkedString.begin(),
- checkedString.end(), match_regex); it != boost::sregex_iterator();
- ++it) {
- resultPositions.push_back(it->position());
- }
-}
-
-void UrlMatchesStyler::mergeRanges(int_pairs& ranges, int_pairs& result) const {
- if (ranges.size() == 0)
- return;
- sort(ranges.begin(), ranges.end());
-
- auto current = *(ranges.begin());
- for (auto it = ranges.begin() + 1; it != ranges.end(); ++it) {
- if (current.second >= it->first) {
- current.second = max(current.second, it->second);
- } else {
- result.push_back(current);
- current = *it;
- }
- }
- result.push_back(current);
-}
-
-string UrlMatchesStyler::getTaggedString(const string& strToHighlight,
- const int_pairs& ranges) const {
- string strResult(strToHighlight);
- int insertOffset = 0;
- for (auto pair : ranges) {
- strResult.insert(pair.second + insertOffset + 1, TAG_COMPLETE_CLOSE);
- strResult.insert(pair.first + insertOffset, TAG_COMPLETE);
- insertOffset += TAGS_COMPLETE_LEN;
- }
- strResult.insert(strResult.length(), TAG_WHOLE_URL_CLOSE);
- strResult.insert(0, TAG_WHOLE_URL);
- return strResult;
-}
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef URLMATCHESSTYLER_H_
-#define URLMATCHESSTYLER_H_
-
-#include <string>
-#include <vector>
-#include <boost/algorithm/string.hpp>
-#include <boost/regex.hpp>
-#include "BrowserLogger.h"
-
-using namespace std;
-
-namespace tizen_browser {
-namespace base_ui {
-
-class UrlMatchesStyler {
-public:
- UrlMatchesStyler();
- virtual ~UrlMatchesStyler();
-
- /**
- * @brief Get string containing EFL tags, which are highlighting given keywords.
- * @param styledUrl url which will be styled
- * @param highlightingKeyword keywords (entered url) indicating which
- * fragments should be highlighted
- * @return styledUrl enriched with EFL tags
- */
- string getUrlHighlightedMatches(const string& styledUrl,
- const string& highlightingKeywords) const;
-
-private:
- typedef vector<pair<int, int>> int_pairs;
- const string FONT_COLOR_HIGHLIGHT = "#4088D3";
- const string FONT_COLOR_NORMAL = "#888888";
- const string FONT_SIZE = "35";
- const string TAG_WHOLE_URL;
- const string TAG_WHOLE_URL_CLOSE;
- const string TAG_HIGHLIGHT, TAG_HIGHLIGHT_CLOSE;
- const string TAG_COLOR, TAG_COLOR_CLOSE;
- const string TAG_COMPLETE, TAG_COMPLETE_CLOSE;
- const int TAGS_COMPLETE_LEN;
-
- /**
- * @brief adds '/' to a tag (<a> -> </a>)
- * @param tag tag to be closed
- * @return closed tag
- */
- string closeTag(const string& tag) const;
- /**
- * @brief splits given string by removing spaces
- * @param keywordsString string to split
- * @param resultKeywords vector to which result strings are stored
- */
- void splitKeywordsString(const string& keywordsString,
- vector<string>& resultKeywords) const;
- /**
- * @brief Fills vector with ranges describing beginnings end ends of occurrences of one string in another.
- * @param checkedString the subject of search
- * @param searchedMatch match to be searched for
- * @param resultRanges vector filled with found ranges
- */
- void fillOccuranceRanges(const string& checkedString,
- const string& searchedMatch, int_pairs& resultRanges) const;
- /**
- * @brief Searches the string for positions of occurrences of another string.
- * @param checkedString the subject of search
- * @param searchedMatch string to be searched for
- * @param resultPositions vector filled with result positions
- */
- void getMatchesPositions(const string& checkedString,
- const string& searchedMatch, vector<int>& resultPositions) const;
- /**
- * @brief merges ranges
- * @param ranges vector of ranges to merge
- * @param result vector filled with merged ranges
- */
- void mergeRanges(int_pairs& ranges, int_pairs& result) const;
- /**
- * @brief get string enriched with opening and closing tags on given positions
- * @param strToHighlight string to be enriched with tags
- * @param ranges positions of opening and closing tags
- * @param tag opening tag (for every pair.first)
- * @param tagClose closing tag (for every pair.second)
- * @return string with tags
- */
- string getTaggedString(const string& strToHighlight,
- const int_pairs& ranges) const;
-
-};
-
-} /* namespace base_ui */
-} /* namespace tizen_browser */
-
-#endif /* URLMATCHESSTYLER_H_ */
#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{
}
}
-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;
+++ /dev/null
-#define URI_INPUTBOX_LENGTH 1720
-#define URI_INPUTBOX_LENGTH_SMALL 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.
-*/
-#define LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX
-
-collections {
- group {
- name: "url_history_list";
- 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;
- max: -1 -1;
- visible: 1;
- align: 0.0 0.0;
- rel1 {
- relative: 0 0;
- offset: 0 0;
- }
- rel2 {
- relative: 1.0 0.5;
- }
- }
- }
- }
- }
-
- group {
- name: "elm/genlist/item/url_historylist_grid_item/default";
- data.item: "contents" "matched_url";
- parts {
- part {
- name: "bg";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- min: URI_INPUTBOX_LENGTH HISTORY_ITEM_H;
- max: -1 -1;
- visible: 1;
- color: 255 255 255 255;
- align: 0.0 0.0;
- }
- description {
- state: "focused" 0.0;
- inherit: "default" 0.0;
- color: 0 119 246 255;
- }
- }
- part {
- name: "matched_url";
- type: SWALLOW;
- scale: 1;
- description {
- state: "default" 0.0;
- fixed: 0 1;
- visible: 1;
- align: 0.0 0.0;
- rel1 {
- to: "bg";
- relative: 0.0 0.0;
- offset: 48 0;
- }
- rel2 {
- to: "bg";
- relative: 1.0 1.0;
- }
-
- }
- }
- }
- programs {
- program {
- name: "focused";
- signal: "mouse,in";
- source: "matched_url";
- action: STATE_SET "focused" 0.0;
- target: "bg";
- }
- program {
- name: "selected";
- signal: "mouse,out";
- source: "matched_url";
- action: STATE_SET "default" 0.0;
- target: "bg";
- }
- }
- }
-
- group {
- name: "elm/genlist/item/url_historylist_grid_item_space/default";
- parts {
- part {
- name: "bg";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- visible: 0;
- min: URI_INPUTBOX_LENGTH HISTORY_ITEM_H;
- max: -1 -1;
- visible: 1;
- color: 255 255 255 0;
- align: 0.0 0.0;
- }
- }
- }
- }
-}
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<Evas_Object>::back, m_webEngine.get()));
m_webPageUI->backPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
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));
openNewTab(historyAddress, desktopMode);
}
+void SimpleUI::onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> 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__);
{
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<services::HistoryItemVector> 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)
void onHistoryRemoved(const std::string& uri);
void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
+ /**
+ * @brief Handles 'openUrlInNewTab' signals. Uses QuickAccess to indicate desktop/mobile mode.
+ */
+ void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem);
void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
void onClearHistoryClicked();
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)
RightButtonBar.edc
URIEntry.edc
PrivateMode.edc
+ UrlHistoryList.edc
)
foreach(edec ${edcFiles})
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);
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());
self->uriEntryEditingChangedByUser(std::make_shared<std::string>(entry));
}
-void URIEntry::_uri_entry_editing_changed(void* data, Evas_Object* /* obj */, void* /* event_info */)
-{
- URIEntry* self = static_cast<URIEntry*>(data);
- self->uriEntryEditingChanged();
-}
-
void URIEntry::setUrlGuideText(const char* txt) const
{
#if PLATFORM(TIZEN)
void URIEntry::unfocused(void* data, Evas_Object*, void*)
{
- BROWSER_LOGD("%s", __func__);
URIEntry* self = static_cast<URIEntry*>(data);
self->m_entrySelectedAllFirst = false;
self->setUrlGuideText(GUIDE_TEXT_UNFOCUSED);
~URIEntry();
void init(Evas_Object* parent);
Evas_Object* getContent();
+ Evas_Object* getEntryWidget();
void changeUri(const std::string&);
boost::signals2::signal<void (const std::string&)> uriChanged;
- // uri edition change
- boost::signals2::signal<void ()> uriEntryEditingChanged;
// uri edition change (by a user)
boost::signals2::signal<void (const std::shared_ptr<std::string>)> uriEntryEditingChangedByUser;
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);
--- /dev/null
+/*
+ * 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<Elm_Object_Item*>() });
+ ptrMap.insert( { GenlistItemType::ITEM_FIRST,
+ make_shared<Elm_Object_Item*>() });
+ ptrMap.insert({ GenlistItemType::ITEM_LAST,
+ make_shared<Elm_Object_Item*>() });
+ ptrMap.insert({ GenlistItemType::ITEM_SPACE_FIRST,
+ make_shared<Elm_Object_Item*>() });
+ ptrMap.insert({ GenlistItemType::ITEM_SPACE_LAST,
+ make_shared<Elm_Object_Item*>() });
+}
+
+GenlistItemsManager::~GenlistItemsManager()
+{
+}
+
+Elm_Object_Item* GenlistItemsManager::getItem(GenlistItemType type)
+{
+ return *ptrMap.at(type);
+}
+
+void GenlistItemsManager::setItems(std::initializer_list<GenlistItemType> types,
+ Elm_Object_Item* item)
+{
+ for (auto i : types) {
+ *ptrMap.at(i) = item;
+ }
+}
+
+void GenlistItemsManager::setItemsIfNullptr(
+ std::initializer_list<GenlistItemType> 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 */
--- /dev/null
+/*
+ * GenlistItemsManager.h
+ *
+ * Created on: Oct 23, 2015
+ * Author: a.skobodzins
+ */
+
+#ifndef GENLISTITEMSMANAGER_H_
+#define GENLISTITEMSMANAGER_H_
+
+#include <memory>
+#include <map>
+
+#include <Elementary.h>
+
+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<GenlistItemType> types,
+ Elm_Object_Item* item);
+ /**
+ * Same as #setItems, except only nullptr value pointers are set
+ */
+ void setItemsIfNullptr(std::initializer_list<GenlistItemType> 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<GenlistItemType, shared_ptr<Elm_Object_Item*>> ptrMap;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* GENLISTITEMSMANAGER_H_ */
--- /dev/null
+/*
+ * 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 "BrowserLogger.h"
+#include "GenlistManager.h"
+#include "GenlistManagerCallbacks.h"
+#include "UrlMatchesStyler.h"
+#include "GenlistItemsManager.h"
+
+namespace tizen_browser {
+namespace base_ui {
+
+GenlistManager::GenlistManager()
+{
+ m_urlMatchesStyler = make_shared<UrlMatchesStyler>();
+ m_itemsManager = make_shared<GenlistItemsManager>();
+
+ 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_itemClassContentGet;
+ m_historyItemClass->func.state_get = nullptr;
+ m_historyItemClass->func.del = nullptr;
+
+ m_historyItemSpaceClass = elm_genlist_item_class_new();
+ m_historyItemSpaceClass->item_style = "url_historylist_grid_item_space";
+ m_historyItemSpaceClass->func.text_get = nullptr;
+ m_historyItemSpaceClass->func.content_get = nullptr;
+ m_historyItemSpaceClass->func.state_get = nullptr;
+ m_historyItemSpaceClass->func.del = nullptr;
+
+ GenlistManagerCallbacks::setGenlistManager(this);
+}
+
+GenlistManager::~GenlistManager()
+{
+ elm_genlist_item_class_free(m_historyItemClass);
+}
+
+void GenlistManager::clearWidget()
+{
+ if (m_genlist && elm_genlist_items_count(m_genlist))
+ elm_genlist_clear(m_genlist);
+}
+
+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()) {
+ m_parentLayout = parentLayout;
+ m_genlist = elm_genlist_add(parentLayout);
+ evas_object_size_hint_weight_set(m_genlist, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ 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",
+ GenlistManagerCallbacks::_genlist_edge_bottom, this);
+
+ evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_IN,
+ GenlistManagerCallbacks::_genlist_mouse_in, this);
+ evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_OUT,
+ GenlistManagerCallbacks::_genlist_mouse_out, this);
+
+ evas_object_smart_callback_add(m_genlist, "focused",
+ GenlistManagerCallbacks::_genlist_focused, this);
+ evas_object_smart_callback_add(m_genlist, "unfocused",
+ GenlistManagerCallbacks::_genlist_unfocused, this);
+ }
+ return m_genlist;
+}
+
+Evas_Object* GenlistManager::getWidget()
+{
+ if (!widgetExists())
+ createWidget(m_parentLayout);
+ return m_genlist;
+}
+
+GenlistItemsManagerPtr GenlistManager::getItemsManager()
+{
+ return m_itemsManager;
+}
+
+void GenlistManager::showWidget(const string& editedUrl,
+ shared_ptr<services::HistoryItemVector> matchedEntries)
+{
+ clearWidget();
+ prepareUrlsVector(editedUrl, matchedEntries);
+
+ m_itemsManager->setItems( { GenlistItemType::ITEM_FIRST,
+ GenlistItemType::ITEM_LAST }, nullptr);
+ Elm_Object_Item* itemAppended = nullptr;
+ 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());
+ m_itemsManager->setItemsIfNullptr( { GenlistItemType::ITEM_FIRST },
+ itemAppended);
+ }
+ m_itemsManager->setItems( { GenlistItemType::ITEM_LAST }, itemAppended);
+
+ 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<UrlPair*>(data);
+ if (!urlPair)
+ return "";
+ return urlPair->urlOriginal.c_str();
+}
+
+void GenlistManager::hideWidgetPretty()
+{
+ if (getSingleBlockHide()) {
+ setSingleBlockHide(false);
+ return;
+ }
+
+ m_itemsManager->setItems( { GenlistItemType::ITEM_CURRENT }, nullptr);
+
+ if (getWidgetPreviouslyHidden()) {
+ hideWidgetInstant();
+ return;
+ }
+ startScrollOut();
+ setWidgetPreviouslyHidden(true);
+}
+
+void GenlistManager::hideWidgetInstant()
+{
+ if (m_genlist)
+ evas_object_hide(m_genlist);
+}
+
+bool GenlistManager::getWidgetPreviouslyHidden()
+{
+ return m_widgetPreviouslyHidden;
+}
+
+void GenlistManager::setWidgetPreviouslyHidden(bool previouslyHidden)
+{
+ this->m_widgetPreviouslyHidden = previouslyHidden;
+}
+
+void GenlistManager::onMouseClick()
+{
+ if (!mouseInsideWidget) {
+ hideWidgetPretty();
+ }
+}
+
+void GenlistManager::startScrollIn()
+{
+ if (m_itemsManager->getItem(GenlistItemType::ITEM_FIRST)) {
+ addSpaces();
+ 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);
+ }
+}
+
+void GenlistManager::startScrollOut()
+{
+ addSpaces();
+ 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::addSpaces()
+{
+ 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_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_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_LAST },
+ itemAppended);
+ }
+}
+
+void GenlistManager::removeSpaces()
+{
+ if (m_itemsManager->getItem(GenlistItemType::ITEM_LAST)) {
+ elm_genlist_item_subitems_clear(
+ m_itemsManager->getItem(GenlistItemType::ITEM_LAST));
+ }
+ m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_FIRST,
+ GenlistItemType::ITEM_SPACE_LAST }, nullptr);
+}
+
+Evas_Object* GenlistManager::m_itemClassContentGet(void* data, Evas_Object* obj,
+ const char* part)
+{
+ Evas_Object* label = elm_label_add(obj);
+ if (strcmp(part, "matched_url") == 0) {
+ const UrlPair* const item = reinterpret_cast<UrlPair*>(data);
+ if (item) {
+ elm_object_text_set(label, item->urlHighlighted.c_str());
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ }
+ }
+ return label;
+}
+
+void GenlistManager::prepareUrlsVector(const string& editedUrl,
+ shared_ptr<services::HistoryItemVector> matchedEntries)
+{
+ // free previously used urls. IMPORTANT: it has to be assured that previous
+ // genlist items are not using these pointers.
+ m_readyUrlPairs.clear();
+ for (auto it : *matchedEntries) {
+ UrlPair newUrlPair(it->getUrl(),
+ m_urlMatchesStyler->getUrlHighlightedMatches(it->getUrl(),
+ editedUrl));
+ m_readyUrlPairs.push_back(make_shared < UrlPair > (newUrlPair));
+ }
+}
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef GENLISTMANAGER_H_
+#define GENLISTMANAGER_H_
+
+#include <Elementary.h>
+#include "services/HistoryService/HistoryItem.h"
+#include <boost/signals2/signal.hpp>
+
+using namespace std;
+
+namespace tizen_browser {
+namespace base_ui {
+
+class GenlistManagerCallbacks;
+class GenlistItemsManager;
+enum class GenlistItemType
+;
+typedef shared_ptr<GenlistItemsManager> GenlistItemsManagerPtr;
+class UrlMatchesStyler;
+typedef shared_ptr<UrlMatchesStyler> UrlMatchesStylerPtr;
+
+typedef struct UrlPair_s
+{
+ UrlPair_s(string a, string b) :
+ urlOriginal(a), urlHighlighted(b)
+ {
+ }
+ string urlOriginal;
+ /**
+ * Url plus styling tags.
+ */
+ string urlHighlighted;
+} UrlPair;
+
+class GenlistManager
+{
+ friend class GenlistManagerCallbacks;
+public:
+ GenlistManager();
+ ~GenlistManager();
+
+ Evas_Object* createWidget(Evas_Object* parentLayout);
+ Evas_Object* getWidget();
+ GenlistItemsManagerPtr getItemsManager();
+
+ void showWidget(const string& editedUrl,
+ shared_ptr<services::HistoryItemVector> matchedEntries);
+ /**
+ * Hide widget by scrolling out.
+ */
+ void hideWidgetPretty();
+ /**
+ * Hide widget by evas_object_hide.
+ */
+ void hideWidgetInstant();
+ void setWidgetPreviouslyHidden(bool previouslyHidden);
+ bool getWidgetPreviouslyHidden();
+ void onMouseClick();
+
+ /**
+ * Add empty list elements to allow scroll in effect.
+ */
+ 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<void(string)> signalItemSelected;
+ boost::signals2::signal<void()> signalWidgetFocused;
+ boost::signals2::signal<void()> signalWidgetUnfocused;
+ boost::signals2::signal<void()> signalItemFocusChange;
+
+ const char* getItemUrl(GenlistItemType type);
+
+private:
+ static Evas_Object* m_itemClassContentGet(void *data, Evas_Object *obj,
+ const char *part);
+
+ bool widgetExists() {return m_genlist != nullptr;}
+
+ void prepareUrlsVector(const string& editedUrl,
+ shared_ptr<services::HistoryItemVector> matchedEntries);
+
+ void onMouseFocusChange(bool mouseInsideWidget);
+
+ void startScrollIn();
+ void startScrollOut();
+
+ Evas_Object* m_parentLayout = nullptr;
+ Evas_Object* m_genlist = nullptr;
+
+ 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;
+ // don't know how to calculate:
+ const int GENLIST_H = HISTORY_ITEM_H * HISTORY_ITEMS_VISIBLE_MAX;
+
+ /*
+ * Set to true, whenever hide request occurs. Set to false, whenever show
+ * request occurs. Needed to indicate when genlist should slide in.
+ */
+ bool m_widgetPreviouslyHidden = true;
+ bool m_singleHideBlock = false;
+ /*
+ * If mouse click received and mouse is outside widget, hide it.
+ */
+ bool mouseInsideWidget = true;
+
+ Elm_Gengrid_Item_Class* m_historyItemClass;
+ Elm_Gengrid_Item_Class* m_historyItemSpaceClass;
+
+ GenlistItemsManagerPtr m_itemsManager;
+
+ /*
+ * keeps shared pointers to strings, that are ready to be displayed, so they can be
+ * passed through EFL, until they're not needed. IMPORTANT: it has to be
+ * assured, that list is not cleared until all EFL items has created their
+ * labels from these pointers in m_contentGet(). in case of segfaults, delete copy of pointers
+ * manually in m_contentGet().
+ */
+ vector<shared_ptr<UrlPair>> m_readyUrlPairs;
+ UrlMatchesStylerPtr m_urlMatchesStyler;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* GENLISTMANAGER_H_ */
--- /dev/null
+/*
+ * 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 "BrowserLogger.h"
+#include "GenlistManagerCallbacks.h"
+#include "GenlistItemsManager.h"
+#include <Ecore_Input.h>
+
+namespace tizen_browser {
+namespace base_ui {
+
+GenlistManager* GenlistManagerCallbacks::genlistManager = nullptr;
+
+GenlistManagerCallbacks::GenlistManagerCallbacks()
+{
+}
+
+GenlistManagerCallbacks::~GenlistManagerCallbacks()
+{
+}
+
+void GenlistManagerCallbacks::_genlist_edge_top(void* data,
+ Evas_Object* /*obj*/, void* /*event_info*/)
+{
+ auto manager = static_cast<GenlistManager*>(data);
+ // 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*/)
+{
+ auto manager = static_cast<GenlistManager*>(data);
+ if (manager->getWidgetPreviouslyHidden()) {
+ manager->clearWidget();
+ evas_object_hide(manager->getWidget());
+ }
+}
+
+void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/,
+ Evas_Object* /*obj*/, void* /*event_info*/)
+{
+ auto manager = static_cast<GenlistManager*>(data);
+ manager->onMouseFocusChange(true);
+}
+
+void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/,
+ Evas_Object* /*obj*/, void* /*event_info*/)
+{
+ auto manager = static_cast<GenlistManager*>(data);
+ manager->onMouseFocusChange(false);
+}
+
+void GenlistManagerCallbacks::_genlist_focused(void* /*data*/,
+ Evas_Object* /*obj*/, void* /*event_info*/)
+{
+ if (genlistManager) {
+ genlistManager->signalWidgetFocused();
+ }
+}
+
+void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/,
+ Evas_Object* /*obj*/, void* /*event_info*/)
+{
+ if (genlistManager) {
+ genlistManager->signalWidgetUnfocused();
+ }
+}
+
+void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/,
+ void* /*event_info*/)
+{
+ const UrlPair* const item = reinterpret_cast<UrlPair*>(data);
+ if (item) {
+ 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<Ecore_Event_Key *>(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 */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef GENLISTMANAGERCALLBACKS_H_
+#define GENLISTMANAGERCALLBACKS_H_
+
+#include "GenlistManager.h"
+#include <Elementary.h>
+#include <Evas.h>
+
+namespace tizen_browser {
+namespace base_ui {
+
+class GenlistManagerCallbacks
+{
+public:
+ GenlistManagerCallbacks();
+ virtual ~GenlistManagerCallbacks();
+
+ static void _genlist_edge_top(void* data, Evas_Object* obj,
+ void* event_info);
+ static void _genlist_edge_bottom(void* data, Evas_Object* obj,
+ void* event_info);
+
+ static void _genlist_mouse_in(void* data, Evas* e, Evas_Object* obj,
+ void* event_info);
+ static void _genlist_mouse_out(void* data, Evas* e, Evas_Object* obj,
+ void* event_info);
+
+ static void _genlist_focused(void* data, Evas_Object* obj,
+ void* event_info);
+ 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)
+ {
+ GenlistManagerCallbacks::genlistManager = genlistManager;
+ }
+
+private:
+ static GenlistManager* genlistManager;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* GENLISTMANAGERCALLBACKS_H_ */
--- /dev/null
+/*
+ * 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 <Elementary.h>
+#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<GenlistManager>();
+ 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<services::HistoryItemVector> 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<services::HistoryItem>(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<UrlHistoryList*>(data);
+ self->saveEntryEditedContent();
+}
+
+void UrlHistoryList::_uri_entry_unfocused(void* data, Evas_Object* /* obj */,
+ void* /* event_info */)
+{
+
+ UrlHistoryList* self = reinterpret_cast<UrlHistoryList*>(data);
+ self->hideWidgetPretty();
+}
+
+}/* namespace base_ui */
+} /* namespace tizen_browser */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef URLHISTORYLIST_H_
+#define URLHISTORYLIST_H_
+
+#include <memory>
+#include <Evas.h>
+
+#include "services/HistoryService/HistoryItem.h"
+#include <boost/signals2/signal.hpp>
+
+using namespace std;
+
+namespace tizen_browser {
+namespace base_ui {
+
+class GenlistManager;
+typedef shared_ptr<GenlistManager> GenlistManagerPtr;
+
+enum class EditedUrlState
+{
+ // url was edited by a user (by typing)
+ EDITED_BY_USER,
+ // url was edited in other way than typing (but for the first time after previous user edition)
+ EDITED_OTHER_FIRST,
+ // url was edited in other way than typing (and previously was not edited by the user)
+ EDITED_OTHER_MANY_TIMES
+};
+
+/**
+ * Manages list of url matches (URL from history). Manages top layout, creates
+ * widget displaying url items.
+ */
+class UrlHistoryList
+{
+public:
+ UrlHistoryList();
+ virtual ~UrlHistoryList();
+ 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<services::HistoryItemVector> matchedEntries);
+
+ void onItemFocusChange();
+ void onMouseClick();
+
+ boost::signals2::signal<void(shared_ptr<services::HistoryItem>)> openURLInNewTab;
+
+ int getVisibleItemsMax() const
+ {
+ return VISIBLE_ITEMS_MAX;
+ }
+
+ int getMinKeywordLength() const
+ {
+ return MIN_KEYWORD_LENGTH;
+ }
+
+private:
+ void createLayout(Evas_Object* parentLayout);
+ void onListItemSelect(std::string content);
+ void onListWidgetFocused();
+ void onListWidgetUnfocused();
+
+ 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_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;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* URLHISTORYLIST_H_ */
--- /dev/null
+/*
+ * 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 "UrlMatchesStyler.h"
+
+namespace tizen_browser {
+namespace base_ui {
+
+UrlMatchesStyler::UrlMatchesStyler() :
+ TAG_WHOLE_URL("<align=left><color=" + FONT_COLOR_NORMAL + "><font_size="+FONT_SIZE+">"),
+ TAG_WHOLE_URL_CLOSE("</color></font></align>"),
+ TAG_HIGHLIGHT("<hilight>"),
+ TAG_HIGHLIGHT_CLOSE(closeTag(TAG_HIGHLIGHT)),
+ TAG_COLOR("<color=" + FONT_COLOR_HIGHLIGHT + ">"),
+ TAG_COLOR_CLOSE(closeTag(TAG_COLOR)),
+ TAG_COMPLETE(TAG_HIGHLIGHT + TAG_COLOR),
+ TAG_COMPLETE_CLOSE(TAG_HIGHLIGHT_CLOSE + TAG_COLOR_CLOSE),
+ TAGS_COMPLETE_LEN(TAG_COMPLETE.length() + TAG_COMPLETE_CLOSE.length()) {
+}
+
+UrlMatchesStyler::~UrlMatchesStyler() {
+}
+
+string UrlMatchesStyler::closeTag(const string& tag) const {
+ string closedTag(tag);
+ return string(closedTag.insert(1, "/"));
+}
+
+string UrlMatchesStyler::getUrlHighlightedMatches(const string& styledUrl,
+ const string& highlightingKeywords) const {
+ vector < string > keywords;
+ splitKeywordsString(highlightingKeywords, keywords);
+
+ int_pairs rangesHighlight;
+ for (auto key : keywords) {
+ fillOccuranceRanges(styledUrl, key, rangesHighlight);
+ }
+
+ int_pairs mergedRangesHighlight;
+ mergeRanges(rangesHighlight, mergedRangesHighlight);
+ return getTaggedString(styledUrl, mergedRangesHighlight);
+}
+
+void UrlMatchesStyler::splitKeywordsString(const string& keywordsString,
+ vector<string>& resultKeywords) const {
+ boost::algorithm::split(resultKeywords, keywordsString,
+ boost::is_any_of("\t "), boost::token_compress_on);
+ // remove empty elements
+ for (auto it = resultKeywords.begin(); it != resultKeywords.end();) {
+ if ((*it).empty()) {
+ it = resultKeywords.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
+void UrlMatchesStyler::fillOccuranceRanges(const string& _checkedString,
+ const string& _searchedMatch, int_pairs& resultRanges) const {
+ if (_checkedString.empty() || _searchedMatch.empty())
+ return;
+
+ string checkedString(_checkedString);
+ string searchedMatch(_searchedMatch);
+ boost::algorithm::to_lower(checkedString);
+ boost::algorithm::to_lower(searchedMatch);
+
+ int len = searchedMatch.length();
+ vector<int> positions;
+ getMatchesPositions(checkedString, searchedMatch, positions);
+ for (auto pos : positions) {
+ resultRanges.push_back( { pos, pos + len - 1 });
+ }
+}
+
+void UrlMatchesStyler::getMatchesPositions(const string& checkedString,
+ const string& searchedMatch, vector<int>& resultPositions) const {
+ boost::regex match_regex(searchedMatch);
+ for (auto it = boost::sregex_iterator(checkedString.begin(),
+ checkedString.end(), match_regex); it != boost::sregex_iterator();
+ ++it) {
+ resultPositions.push_back(it->position());
+ }
+}
+
+void UrlMatchesStyler::mergeRanges(int_pairs& ranges, int_pairs& result) const {
+ if (ranges.size() == 0)
+ return;
+ sort(ranges.begin(), ranges.end());
+
+ auto current = *(ranges.begin());
+ for (auto it = ranges.begin() + 1; it != ranges.end(); ++it) {
+ if (current.second >= it->first) {
+ current.second = max(current.second, it->second);
+ } else {
+ result.push_back(current);
+ current = *it;
+ }
+ }
+ result.push_back(current);
+}
+
+string UrlMatchesStyler::getTaggedString(const string& strToHighlight,
+ const int_pairs& ranges) const {
+ string strResult(strToHighlight);
+ int insertOffset = 0;
+ for (auto pair : ranges) {
+ strResult.insert(pair.second + insertOffset + 1, TAG_COMPLETE_CLOSE);
+ strResult.insert(pair.first + insertOffset, TAG_COMPLETE);
+ insertOffset += TAGS_COMPLETE_LEN;
+ }
+ strResult.insert(strResult.length(), TAG_WHOLE_URL_CLOSE);
+ strResult.insert(0, TAG_WHOLE_URL);
+ return strResult;
+}
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef URLMATCHESSTYLER_H_
+#define URLMATCHESSTYLER_H_
+
+#include <string>
+#include <vector>
+#include <boost/algorithm/string.hpp>
+#include <boost/regex.hpp>
+#include "BrowserLogger.h"
+
+using namespace std;
+
+namespace tizen_browser {
+namespace base_ui {
+
+class UrlMatchesStyler {
+public:
+ UrlMatchesStyler();
+ virtual ~UrlMatchesStyler();
+
+ /**
+ * @brief Get string containing EFL tags, which are highlighting given keywords.
+ * @param styledUrl url which will be styled
+ * @param highlightingKeyword keywords (entered url) indicating which
+ * fragments should be highlighted
+ * @return styledUrl enriched with EFL tags
+ */
+ string getUrlHighlightedMatches(const string& styledUrl,
+ const string& highlightingKeywords) const;
+
+private:
+ typedef vector<pair<int, int>> int_pairs;
+ const string FONT_COLOR_HIGHLIGHT = "#4088D3";
+ const string FONT_COLOR_NORMAL = "#888888";
+ const string FONT_SIZE = "35";
+ const string TAG_WHOLE_URL;
+ const string TAG_WHOLE_URL_CLOSE;
+ const string TAG_HIGHLIGHT, TAG_HIGHLIGHT_CLOSE;
+ const string TAG_COLOR, TAG_COLOR_CLOSE;
+ const string TAG_COMPLETE, TAG_COMPLETE_CLOSE;
+ const int TAGS_COMPLETE_LEN;
+
+ /**
+ * @brief adds '/' to a tag (<a> -> </a>)
+ * @param tag tag to be closed
+ * @return closed tag
+ */
+ string closeTag(const string& tag) const;
+ /**
+ * @brief splits given string by removing spaces
+ * @param keywordsString string to split
+ * @param resultKeywords vector to which result strings are stored
+ */
+ void splitKeywordsString(const string& keywordsString,
+ vector<string>& resultKeywords) const;
+ /**
+ * @brief Fills vector with ranges describing beginnings end ends of occurrences of one string in another.
+ * @param checkedString the subject of search
+ * @param searchedMatch match to be searched for
+ * @param resultRanges vector filled with found ranges
+ */
+ void fillOccuranceRanges(const string& checkedString,
+ const string& searchedMatch, int_pairs& resultRanges) const;
+ /**
+ * @brief Searches the string for positions of occurrences of another string.
+ * @param checkedString the subject of search
+ * @param searchedMatch string to be searched for
+ * @param resultPositions vector filled with result positions
+ */
+ void getMatchesPositions(const string& checkedString,
+ const string& searchedMatch, vector<int>& resultPositions) const;
+ /**
+ * @brief merges ranges
+ * @param ranges vector of ranges to merge
+ * @param result vector filled with merged ranges
+ */
+ void mergeRanges(int_pairs& ranges, int_pairs& result) const;
+ /**
+ * @brief get string enriched with opening and closing tags on given positions
+ * @param strToHighlight string to be enriched with tags
+ * @param ranges positions of opening and closing tags
+ * @param tag opening tag (for every pair.first)
+ * @param tagClose closing tag (for every pair.second)
+ * @return string with tags
+ */
+ string getTaggedString(const string& strToHighlight,
+ const int_pairs& ranges) const;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* URLMATCHESSTYLER_H_ */
#include "BrowserLogger.h"
#include "ServiceManager.h"
#include "BrowserAssert.h"
+#include "UrlHistoryList/UrlHistoryList.h"
namespace tizen_browser {
namespace base_ui {
, m_progressBar(nullptr)
, m_bookmarkManagerButton(nullptr)
, m_URIEntry(new URIEntry())
+ , m_urlHistoryList(std::make_shared<UrlHistoryList>())
, m_homePageActive(false)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
return m_mainLayout;
}
+UrlHistoryPtr WebPageUI::getUrlHistoryList()
+{
+ return m_urlHistoryList;
+}
+
void WebPageUI::showUI()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
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();
}
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
namespace tizen_browser {
namespace base_ui {
+class UrlHistoryList;
+typedef std::shared_ptr<UrlHistoryList> UrlHistoryPtr;
+
class BROWSER_EXPORT WebPageUI : public tizen_browser::core::AbstractService, public tizen_browser::interfaces::AbstractUIComponent {
public:
WebPageUI();
virtual std::string getName();
virtual void init(Evas_Object* parent);
virtual Evas_Object* getContent();
+ UrlHistoryPtr getUrlHistoryList();
virtual void showUI();
virtual void hideUI();
void loadStopped();
std::unique_ptr<ButtonBar> m_leftButtonBar;
std::unique_ptr<ButtonBar> m_rightButtonBar;
std::unique_ptr<URIEntry> m_URIEntry;
+ UrlHistoryPtr m_urlHistoryList;
bool m_homePageActive;
sharedAction m_back;
--- /dev/null
+#define LIST_OFFSET_X 255
+#define LIST_OFFSET_Y 104
+#define URI_INPUTBOX_LENGTH 1720
+#define URI_INPUTBOX_LENGTH_SHORT 1460
+#define HISTORY_ITEM_W URI_INPUTBOX_LENGTH
+#define HISTORY_ITEM_H 82
+#define HISTORY_ITEMS_VISIBLE_MAX 5
+/*
+ has to be a multiple of item's height.
+*/
+#define LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX
+
+collections {
+ group {
+ name: "url_history_list";
+ parts
+ {
+ part {
+ name: "list_swallow";
+ type: SWALLOW;
+ description {
+ color: 255 0 0 150;
+ min: URI_INPUTBOX_LENGTH_SHORT LIST_MAX_H;
+ max: -1 -1;
+ visible: 1;
+ align: 0.0 0.0;
+ rel1 {
+ relative: 0 0;
+ offset: LIST_OFFSET_X LIST_OFFSET_Y;
+ }
+ rel2 {
+ relative: 1.0 0.5;
+ }
+ }
+ }
+ }
+ }
+
+ group {
+ name: "elm/genlist/item/url_historylist_grid_item/default";
+ data.item: "contents" "matched_url";
+ parts {
+ part {
+ name: "bg";
+ type: RECT;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ min: URI_INPUTBOX_LENGTH HISTORY_ITEM_H;
+ max: -1 -1;
+ visible: 1;
+ color: 255 255 255 255;
+ align: 0.0 0.0;
+ }
+ description {
+ state: "focused" 0.0;
+ inherit: "default" 0.0;
+ color: 0 119 246 255;
+ }
+ }
+ part {
+ name: "matched_url";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 1;
+ visible: 1;
+ align: 0.0 0.0;
+ rel1 {
+ to: "bg";
+ relative: 0.0 0.0;
+ offset: 48 0;
+ }
+ rel2 {
+ to: "bg";
+ relative: 1.0 1.0;
+ }
+
+ }
+ }
+ }
+ programs {
+ program {
+ name: "focused";
+ signal: "mouse,in";
+ source: "matched_url";
+ action: STATE_SET "focused" 0.0;
+ target: "bg";
+ }
+ program {
+ name: "selected";
+ signal: "mouse,out";
+ source: "matched_url";
+ action: STATE_SET "default" 0.0;
+ target: "bg";
+ }
+ }
+ }
+
+ group {
+ name: "elm/genlist/item/url_historylist_grid_item_space/default";
+ parts {
+ part {
+ name: "bg";
+ type: RECT;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ min: URI_INPUTBOX_LENGTH HISTORY_ITEM_H;
+ max: -1 -1;
+ visible: 1;
+ color: 255 255 255 0;
+ align: 0.0 0.0;
+ }
+ }
+ }
+ }
+}