2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef GENLISTMANAGER_H_
18 #define GENLISTMANAGER_H_
20 #include <Elementary.h>
21 #include "services/HistoryService/HistoryItem.h"
22 #include <boost/signals2/signal.hpp>
23 #include "BrowserLogger.h"
27 namespace tizen_browser {
30 class GenlistManagerCallbacks;
31 class UrlMatchesStyler;
32 typedef shared_ptr<UrlMatchesStyler> UrlMatchesStylerPtr;
34 typedef struct UrlPair_s {
35 UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {}
37 string urlHighlighted;
42 friend class GenlistManagerCallbacks;
47 Evas_Object* createWidget(Evas_Object* parentLayout);
48 Evas_Object* getWidget();
50 void showWidget(const string& editedUrl,
51 shared_ptr<services::HistoryItemVector> matchedEntries);
52 void hideWidgetPretty();
53 void hideWidgetInstant();
54 bool isWidgetHidden();
58 * Add empty list elements to allow scroll in effect.
64 boost::signals2::signal<void(string)> signalItemSelected;
65 boost::signals2::signal<void()> signalWidgetFocused;
66 boost::signals2::signal<void()> signalWidgetUnfocused;
69 static Evas_Object* m_contentGet(void *data, Evas_Object *obj,
73 return m_genlist != nullptr;
75 void prepareUrlsVector(const string& editedUrl,
76 shared_ptr<services::HistoryItemVector> matchedEntries);
78 void setLastEdgeTop(bool edgeTop);
79 bool getLastEdgeTop();
80 void onMouseFocusChange(bool mouseInsideWidget);
83 void startScrollOut();
85 Evas_Object* m_parentLayout = nullptr;
86 Evas_Object* m_genlist = nullptr;
87 const bool genlistShowScrollbar = false;
89 // don't know how to get from edc:
90 const int HISTORY_ITEM_H = 82;
91 const int HISTORY_ITEMS_VISIBLE_MAX = 5;
92 // don't know how to calculate:
93 const int GENLIST_H = HISTORY_ITEM_H * HISTORY_ITEMS_VISIBLE_MAX;
96 * Set to true, whenever hide request occurs. Set to false, whenever show
97 * request occurs. Needed to indicate when genlist should slide in.
99 bool widgetPreviouslyHidden = true;
101 * If mouse click received and mouse is outside widget, hide it.
103 bool mouseInsideWidget = true;
105 * needed to indicate direction of the scroll in 'anim,stop' callback
107 bool lastEdgeTop = true;
109 Elm_Gengrid_Item_Class* m_historyItemClass;
110 Elm_Gengrid_Item_Class* m_historyItemSpaceClass;
111 Elm_Object_Item* m_itemUrlFirst = nullptr;
112 Elm_Object_Item* m_itemUrlLast = nullptr;
113 Elm_Object_Item* m_itemSpaceFirst = nullptr;
114 Elm_Object_Item* m_itemSpaceLast = nullptr;
117 * keeps shared pointers to strings, that are ready to be displayed, so they can be
118 * passed through EFL, until they're not needed. IMPORTANT: it has to be
119 * assured, that list is not cleared until all EFL items has created their
120 * labels from these pointers in m_contentGet(). in case of segfaults, delete copy of pointers
121 * manually in m_contentGet().
123 vector<shared_ptr<string>> m_readyUrls;
124 vector<shared_ptr<UrlPair>> m_readyUrlPairs;
125 UrlMatchesStylerPtr m_urlMatchesStyler;
129 } /* namespace base_ui */
130 } /* namespace tizen_browser */
132 #endif /* GENLISTMANAGER_H_ */