2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
19
#ifndef UNITY_DASH_VIEW_H_
20
#define UNITY_DASH_VIEW_H_
23
#include <Nux/PaintLayer.h>
25
#include <Nux/VLayout.h>
27
#include <UnityCore/FilesystemLenses.h>
28
#include <UnityCore/HomeLens.h>
29
#include <UnityCore/GLibSource.h>
31
#include "ApplicationStarter.h"
34
#include "previews/PreviewContainer.h"
35
#include "PreviewStateMachine.h"
36
#include "UnityCore/Preview.h"
38
#include "unity-shared/BackgroundEffectHelper.h"
39
#include "unity-shared/BGHash.h"
40
#include "unity-shared/Introspectable.h"
41
#include "unity-shared/OverlayRenderer.h"
42
#include "unity-shared/SearchBar.h"
43
#include "unity-shared/UBusWrapper.h"
44
#include "unity-shared/OverlayWindowButtons.h"
47
namespace na = nux::animation;
56
class DashView : public nux::View, public unity::debug::Introspectable
58
NUX_DECLARE_OBJECT_TYPE(DashView, nux::View);
59
typedef std::map<std::string, nux::ObjectPtr<LensView>> LensViews;
62
DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter);
69
void OnActivateRequest(GVariant* args);
70
void SetMonitorOffset(int x, int y);
72
bool IsCommandLensOpen() const;
74
std::string const GetIdForShortcutActivation(std::string const& shortcut) const;
75
std::vector<char> GetAllShortcuts();
77
nux::View* default_focus() const;
79
nux::Geometry const& GetContentGeometry() const;
82
void ProcessDndEnter();
84
virtual Area* FindKeyFocusArea(unsigned int key_symbol,
85
unsigned long x11_key_code,
86
unsigned long special_keys_state);
90
void SetupUBusConnections();
91
void OnBGColorChanged(GVariant *data);
92
nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
94
void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
95
void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
96
virtual long PostLayoutManagement (long LayoutResult);
97
nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);
100
void DrawDashSplit(nux::GraphicsEngine& graphics_engine, nux::Geometry& split_clip);
101
void DrawPreviewContainer(nux::GraphicsEngine& graphics_engine);
102
void DrawPreviewResultTextures(nux::GraphicsEngine& gfx_context, bool force_draw);
103
void DrawPreview(nux::GraphicsEngine& gfx_context, bool force_draw);
104
void StartPreviewAnimation();
105
void EndPreviewAnimation();
107
void BuildPreview(Preview::Ptr model);
109
void OnPreviewAnimationFinished();
110
void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
111
void OnBackgroundColorChanged(GVariant* args);
112
void OnSearchChanged(std::string const& search_string);
113
void OnLiveSearchReached(std::string const& search_string);
114
void OnLensAdded(Lens::Ptr& lens);
115
void OnLensBarActivated(std::string const& id);
116
void OnSearchFinished(Lens::Hints const& hints, glib::Error const& error);
117
void OnGlobalSearchFinished(Lens::Hints const& hints, glib::Error const& error);
118
void OnAppsGlobalSearchFinished(Lens::Ptr const& lens);
119
void OnUriActivated(ResultView::ActivateType type, std::string const& uri, GVariant* data, std::string const& unique_id);
120
void OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&);
121
bool DoFallbackActivation(std::string const& uri);
122
bool LaunchApp(std::string const& appname);
123
void OnEntryActivated();
124
std::string AnalyseLensURI(std::string const& uri);
125
void UpdateLensFilter(std::string lens, std::string filter, std::string value);
126
void UpdateLensFilterValue(Filter::Ptr filter, std::string value);
127
void EnsureLensesInitialized();
129
bool AcceptKeyNavFocus();
130
bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
131
std::string GetName() const;
132
void AddProperties(GVariantBuilder* builder);
134
nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
136
UBusManager ubus_manager_;
138
HomeLens::Ptr home_lens_;
139
LensViews lens_views_;
141
ApplicationStarter::Ptr application_starter_;
144
PreviewStateMachine preview_state_machine_;
145
previews::PreviewContainer::Ptr preview_container_;
146
bool preview_displaying_;
147
std::string stored_activated_unique_id_;
148
dash::previews::Navigation preview_navigation_mode_;
150
nux::VLayout* layout_;
151
DashLayout* content_layout_;
152
nux::View* content_view_;
153
nux::HLayout* search_bar_layout_;
154
SearchBar* search_bar_;
155
nux::VLayout* lenses_layout_;
158
nux::ObjectPtr<LensView> home_view_;
159
nux::ObjectPtr<LensView> active_lens_view_;
160
nux::ObjectPtr<LensView> preview_lens_view_;
163
nux::Geometry content_geo_;
164
OverlayRenderer renderer_;
166
std::string last_activated_uri_;
167
guint64 last_activated_timestamp_;
168
bool search_in_progress_;
169
bool activate_on_finish_;
173
glib::Source::UniquePtr searching_timeout_;
174
glib::Source::UniquePtr hide_message_delay_;
176
nux::ObjectPtr<nux::IOpenGLBaseTexture> dash_view_copy_;
177
nux::ObjectPtr<nux::IOpenGLBaseTexture> search_view_copy_;
178
nux::ObjectPtr<nux::IOpenGLBaseTexture> filter_view_copy_;
179
nux::ObjectPtr<nux::IOpenGLBaseTexture> layout_copy_;
181
int opening_column_x_;
183
int opening_column_width_;
184
int opening_row_height_;
186
nux::Color background_color_;
188
std::unique_ptr<na::AnimateValue<float>> split_animation_;
189
float animate_split_value_;
191
std::unique_ptr<na::AnimateValue<float>> preview_container_animation_;
192
float animate_preview_container_value_;
194
std::unique_ptr<na::AnimateValue<float>> preview_animation_;
195
float animate_preview_value_;
197
nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;