5418b3891227060a44fe9092c91ce488a4923f89
[profile/tv/apps/web/browser.git] / services / QuickAccess / QuickAccess.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef QUICKACCESS_H
18 #define QUICKACCESS_H
19
20 #include <Evas.h>
21 #include <boost/signals2/signal.hpp>
22
23 #include "AbstractUIComponent.h"
24 #include "AbstractService.h"
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
27 #include "services/HistoryService/HistoryItem.h"
28 #include "BookmarkItem.h"
29 #include "DetailPopup.h"
30
31 namespace tizen_browser{
32 namespace base_ui{
33
34 //TODO: This class name is not revelant to what this class actually does.
35 //Rename this class and file to "QuickAccessUI".
36 class BROWSER_EXPORT QuickAccess
37         : public tizen_browser::core::AbstractService
38 {
39 public:
40     QuickAccess();
41     ~QuickAccess();
42     void init(Evas_Object *main_layout);
43     Evas_Object* getContent();
44     void showMostVisited(std::shared_ptr<services::HistoryItemVector> vec);
45     void showBookmarks(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > vec);
46     void hideUI();
47     void showUI();
48     virtual std::string getName();
49     void openDetailPopup(std::shared_ptr<services::HistoryItem> currItem, std::shared_ptr<services::HistoryItemVector> prevItems);
50     bool isDesktopMode() const;
51     void setDesktopMode(bool mode);
52     DetailPopup & getDetailPopup();
53     void backButtonClicked();
54     inline bool isMostVisitedActive() const;
55     void refreshFocusChain();
56
57     boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, int)> mostVisitedTileClicked;
58     boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURLInNewTab;
59     boost::signals2::signal<void ()> mostVisitedClicked;
60     boost::signals2::signal<void ()> bookmarkClicked;
61     boost::signals2::signal<void ()> bookmarkManagerClicked;
62
63     static const int MAX_THUMBNAIL_WIDTH;
64     static const int MAX_THUMBNAIL_HEIGHT;
65
66 private:
67     void createItemClasses();
68     void addHistoryItem(std::shared_ptr<services::HistoryItem>);
69     void addHistoryItems(std::shared_ptr<services::HistoryItemVector>);
70     void addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem>);
71     void addBookmarkItems(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >);
72     void clearHistoryGenlist();
73     void clearBookmarkGengrid();
74     Evas_Object* createBookmarkGengrid(Evas_Object *parent);
75     void showHistory();
76     void showBookmarks();
77
78     Evas_Object* createQuickAccessLayout(Evas_Object *parent);
79     Evas_Object* createMostVisitedView(Evas_Object *parent);
80     Evas_Object* createBookmarksView(Evas_Object *parent);
81     Evas_Object* createBottomButton(Evas_Object *parent);
82     Evas_Object* createTopButtons(Evas_Object *parent);
83
84     static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part);
85     static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part);
86     static void _thumbBookmarkClicked(void * data, Evas_Object * obj, void * event_info);
87     static void _thumbHistoryClicked(void * data, Evas_Object * obj, void * event_info);
88     void setEmptyView(bool empty);
89     void showNoHistoryLabel();
90
91     static void _mostVisited_clicked(void * data, Evas_Object * obj, void * event_info);
92     static void _bookmark_clicked(void * data, Evas_Object * obj, void * event_info);
93     static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info);
94
95     Evas_Object *m_parent;
96     Evas_Object *m_layout;
97     Evas_Object *m_bookmarksView;
98     Evas_Object *m_mostVisitedView;
99     Evas_Object *m_bookmarksButton;
100     Evas_Object *m_mostVisitedButton;
101     Evas_Object *m_bookmarkGengrid;
102     Evas_Object *m_bookmarkManagerButton;
103     bool m_after_history_thumb;
104     std::vector<Evas_Object *> m_tiles;
105     Eina_List* m_parentFocusChain;
106
107     Elm_Gengrid_Item_Class * m_bookmark_item_class;
108     DetailPopup m_detailPopup;
109     services::HistoryItemVector m_historyItems;
110     bool m_gengridSetup;
111     std::string edjFilePath;
112     bool m_desktopMode;
113
114     static const int MAX_TILES_NUMBER;
115     static const int BIG_TILE_INDEX;
116     static const int TOP_RIGHT_TILE_INDEX;
117     static const int BOTTOM_RIGHT_TILE_INDEX;
118     static const std::vector<std::string> TILES_NAMES;
119 };
120
121 }
122 }
123
124 #endif // QUICKACCESS_H