Fixed navigating using 'Backspace' key
[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     boost::signals2::signal<void ()> switchViewToWebPage;
63
64     static const int MAX_THUMBNAIL_WIDTH;
65     static const int MAX_THUMBNAIL_HEIGHT;
66
67 private:
68     void createItemClasses();
69     void addHistoryItem(std::shared_ptr<services::HistoryItem>);
70     void addHistoryItems(std::shared_ptr<services::HistoryItemVector>);
71     void addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem>);
72     void addBookmarkItems(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >);
73     void clearHistoryGenlist();
74     void clearBookmarkGengrid();
75     Evas_Object* createBookmarkGengrid(Evas_Object *parent);
76     void showHistory();
77     void showBookmarks();
78
79     Evas_Object* createQuickAccessLayout(Evas_Object *parent);
80     Evas_Object* createMostVisitedView(Evas_Object *parent);
81     Evas_Object* createBookmarksView(Evas_Object *parent);
82     Evas_Object* createBottomButton(Evas_Object *parent);
83     Evas_Object* createTopButtons(Evas_Object *parent);
84
85     static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part);
86     static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part);
87     static void _thumbBookmarkClicked(void * data, Evas_Object * obj, void * event_info);
88     static void _thumbHistoryClicked(void * data, Evas_Object * obj, void * event_info);
89     void setEmptyView(bool empty);
90     void showNoHistoryLabel();
91
92     static void _mostVisited_clicked(void * data, Evas_Object * obj, void * event_info);
93     static void _bookmark_clicked(void * data, Evas_Object * obj, void * event_info);
94     static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info);
95
96     Evas_Object *m_parent;
97     Evas_Object *m_layout;
98     Evas_Object *m_bookmarksView;
99     Evas_Object *m_mostVisitedView;
100     Evas_Object *m_bookmarksButton;
101     Evas_Object *m_mostVisitedButton;
102     Evas_Object *m_bookmarkGengrid;
103     Evas_Object *m_bookmarkManagerButton;
104     bool m_after_history_thumb;
105     std::vector<Evas_Object *> m_tiles;
106     Eina_List* m_parentFocusChain;
107
108     Elm_Gengrid_Item_Class * m_bookmark_item_class;
109     DetailPopup m_detailPopup;
110     services::HistoryItemVector m_historyItems;
111     bool m_gengridSetup;
112     std::string edjFilePath;
113     bool m_desktopMode;
114
115     static const int MAX_TILES_NUMBER;
116     static const int BIG_TILE_INDEX;
117     static const int TOP_RIGHT_TILE_INDEX;
118     static const int BOTTOM_RIGHT_TILE_INDEX;
119     static const std::vector<std::string> TILES_NAMES;
120 };
121
122 }
123 }
124
125 #endif // QUICKACCESS_H