Merge lp:~njpatel/unity/dash-fixes-2011-08-22 into lp:unity
- dash-fixes-2011-08-22
- Merge into trunk
Proposed by
Neil J. Patel
Status: | Merged |
---|---|
Approved by: | Gord Allott |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1413 |
Proposed branch: | lp:~njpatel/unity/dash-fixes-2011-08-22 |
Merge into: | lp:unity |
Diff against target: |
1339 lines (+587/-82) 30 files modified
UnityCore/Lens.cpp (+0/-1) plugins/unityshell/src/BFBLauncherIcon.cpp (+2/-1) plugins/unityshell/src/DashSearchBarSpinner.cpp (+17/-5) plugins/unityshell/src/DashSearchBarSpinner.h (+2/-0) plugins/unityshell/src/DashView.cpp (+7/-10) plugins/unityshell/src/FilterExpanderLabel.cpp (+2/-2) plugins/unityshell/src/FilterGenreWidget.cpp (+4/-1) plugins/unityshell/src/FilterMultiRangeButton.cpp (+1/-1) plugins/unityshell/src/FontSettings.cpp (+88/-0) plugins/unityshell/src/FontSettings.h (+43/-0) plugins/unityshell/src/HomeView.cpp (+40/-2) plugins/unityshell/src/HomeView.h (+5/-0) plugins/unityshell/src/IconTexture.cpp (+5/-0) plugins/unityshell/src/IconTexture.h (+4/-2) plugins/unityshell/src/Launcher.cpp (+3/-1) plugins/unityshell/src/LensBar.cpp (+48/-25) plugins/unityshell/src/LensBar.h (+11/-1) plugins/unityshell/src/LensBarIcon.cpp (+101/-0) plugins/unityshell/src/LensBarIcon.h (+56/-0) plugins/unityshell/src/LensView.cpp (+94/-16) plugins/unityshell/src/LensView.h (+11/-0) plugins/unityshell/src/PlacesGroup.cpp (+1/-1) plugins/unityshell/src/PlacesStyle.cpp (+4/-0) plugins/unityshell/src/PlacesStyle.h (+2/-0) plugins/unityshell/src/ResultRendererTile.cpp (+21/-13) plugins/unityshell/src/StaticCairoText.cpp (+1/-0) plugins/unityshell/src/unityshell.cpp (+1/-0) plugins/unityshell/src/unityshell.h (+3/-0) tests/CMakeLists.txt (+8/-0) tests/standalone_dash.cpp (+2/-0) |
To merge this branch: | bzr merge lp:~njpatel/unity/dash-fixes-2011-08-22 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gord Allott | Pending | ||
Review via email:
|
Commit message
Description of the change
Miscellaneous fixes for the dash for renderering and also fixes a bunch of bugs.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'UnityCore/Lens.cpp' | |||
2 | --- UnityCore/Lens.cpp 2011-08-10 09:51:24 +0000 | |||
3 | +++ UnityCore/Lens.cpp 2011-08-24 12:31:11 +0000 | |||
4 | @@ -173,7 +173,6 @@ | |||
5 | 173 | glib::String search_string; | 173 | glib::String search_string; |
6 | 174 | 174 | ||
7 | 175 | g_variant_get(parameters, "(sa{sv})", &search_string, NULL); | 175 | g_variant_get(parameters, "(sa{sv})", &search_string, NULL); |
8 | 176 | g_debug ("HELLO"); | ||
9 | 177 | owner_->search_finished.emit(search_string.Str()); | 176 | owner_->search_finished.emit(search_string.Str()); |
10 | 178 | } | 177 | } |
11 | 179 | 178 | ||
12 | 180 | 179 | ||
13 | === modified file 'plugins/unityshell/src/BFBLauncherIcon.cpp' | |||
14 | --- plugins/unityshell/src/BFBLauncherIcon.cpp 2011-08-03 14:25:30 +0000 | |||
15 | +++ plugins/unityshell/src/BFBLauncherIcon.cpp 2011-08-24 12:31:11 +0000 | |||
16 | @@ -50,6 +50,7 @@ | |||
17 | 50 | if (arg.button == 1) | 50 | if (arg.button == 1) |
18 | 51 | { | 51 | { |
19 | 52 | UBusServer* ubus = ubus_server_get_default(); | 52 | UBusServer* ubus = ubus_server_get_default(); |
21 | 53 | ubus_server_send_message(ubus, UBUS_DASH_EXTERNAL_ACTIVATION, NULL); | 53 | ubus_server_send_message(ubus, UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, |
22 | 54 | g_variant_new("(sus)", "home.lens", 0, "")); | ||
23 | 54 | } | 55 | } |
24 | 55 | } | 56 | } |
25 | 56 | 57 | ||
26 | === modified file 'plugins/unityshell/src/DashSearchBarSpinner.cpp' | |||
27 | --- plugins/unityshell/src/DashSearchBarSpinner.cpp 2011-08-09 17:45:12 +0000 | |||
28 | +++ plugins/unityshell/src/DashSearchBarSpinner.cpp 2011-08-24 12:31:11 +0000 | |||
29 | @@ -52,6 +52,9 @@ | |||
30 | 52 | { | 52 | { |
31 | 53 | if (_spinner_timeout) | 53 | if (_spinner_timeout) |
32 | 54 | g_source_remove(_spinner_timeout); | 54 | g_source_remove(_spinner_timeout); |
33 | 55 | |||
34 | 56 | if (_frame_timeout) | ||
35 | 57 | g_source_remove(_frame_timeout); | ||
36 | 55 | } | 58 | } |
37 | 56 | 59 | ||
38 | 57 | long | 60 | long |
39 | @@ -157,8 +160,10 @@ | |||
40 | 157 | texxform, | 160 | texxform, |
41 | 158 | nux::color::White); | 161 | nux::color::White); |
42 | 159 | } | 162 | } |
43 | 160 | |||
44 | 161 | GfxContext.PopClippingRectangle(); | 163 | GfxContext.PopClippingRectangle(); |
45 | 164 | |||
46 | 165 | if (_state == STATE_SEARCHING && !_frame_timeout) | ||
47 | 166 | _frame_timeout = g_timeout_add(22, (GSourceFunc)SearchBarSpinner::OnFrame, this); | ||
48 | 162 | } | 167 | } |
49 | 163 | 168 | ||
50 | 164 | void | 169 | void |
51 | @@ -167,18 +172,24 @@ | |||
52 | 167 | } | 172 | } |
53 | 168 | 173 | ||
54 | 169 | gboolean | 174 | gboolean |
55 | 175 | SearchBarSpinner::OnTimeout(SearchBarSpinner* self) | ||
56 | 176 | { | ||
57 | 177 | self->_state = STATE_READY; | ||
58 | 178 | return FALSE; | ||
59 | 179 | } | ||
60 | 180 | |||
61 | 181 | gboolean | ||
62 | 170 | SearchBarSpinner::OnFrame(SearchBarSpinner* self) | 182 | SearchBarSpinner::OnFrame(SearchBarSpinner* self) |
63 | 171 | { | 183 | { |
64 | 172 | self->_rotation += 0.1f; | 184 | self->_rotation += 0.1f; |
65 | 173 | |||
66 | 174 | if (self->_rotation >= 360.0f) | 185 | if (self->_rotation >= 360.0f) |
67 | 175 | self->_rotation = 0.0f; | 186 | self->_rotation = 0.0f; |
68 | 176 | 187 | ||
69 | 177 | self->_2d_rotate.Rotate_z(self->_rotation); | 188 | self->_2d_rotate.Rotate_z(self->_rotation); |
70 | 189 | self->_frame_timeout = 0; | ||
71 | 178 | 190 | ||
72 | 179 | self->QueueDraw(); | 191 | self->QueueDraw(); |
75 | 180 | 192 | return FALSE; | |
74 | 181 | return TRUE; | ||
76 | 182 | } | 193 | } |
77 | 183 | 194 | ||
78 | 184 | void | 195 | void |
79 | @@ -192,12 +203,13 @@ | |||
80 | 192 | if (_spinner_timeout) | 203 | if (_spinner_timeout) |
81 | 193 | g_source_remove(_spinner_timeout); | 204 | g_source_remove(_spinner_timeout); |
82 | 194 | _spinner_timeout = 0; | 205 | _spinner_timeout = 0; |
83 | 206 | |||
84 | 195 | _2d_rotate.Rotate_z(0.0f); | 207 | _2d_rotate.Rotate_z(0.0f); |
85 | 196 | _rotation = 0.0f; | 208 | _rotation = 0.0f; |
86 | 197 | 209 | ||
87 | 198 | if (_state == STATE_SEARCHING) | 210 | if (_state == STATE_SEARCHING) |
88 | 199 | { | 211 | { |
90 | 200 | _spinner_timeout = g_timeout_add(15, (GSourceFunc)SearchBarSpinner::OnFrame, this); | 212 | _spinner_timeout = g_timeout_add_seconds(5, (GSourceFunc)SearchBarSpinner::OnTimeout, this); |
91 | 201 | } | 213 | } |
92 | 202 | 214 | ||
93 | 203 | QueueDraw(); | 215 | QueueDraw(); |
94 | 204 | 216 | ||
95 | === modified file 'plugins/unityshell/src/DashSearchBarSpinner.h' | |||
96 | --- plugins/unityshell/src/DashSearchBarSpinner.h 2011-08-09 06:24:59 +0000 | |||
97 | +++ plugins/unityshell/src/DashSearchBarSpinner.h 2011-08-24 12:31:11 +0000 | |||
98 | @@ -56,6 +56,7 @@ | |||
99 | 56 | // Introspectable methods | 56 | // Introspectable methods |
100 | 57 | const gchar* GetName(); | 57 | const gchar* GetName(); |
101 | 58 | void AddProperties(GVariantBuilder* builder); | 58 | void AddProperties(GVariantBuilder* builder); |
102 | 59 | static gboolean OnTimeout(SearchBarSpinner* self); | ||
103 | 59 | static gboolean OnFrame(SearchBarSpinner* self); | 60 | static gboolean OnFrame(SearchBarSpinner* self); |
104 | 60 | 61 | ||
105 | 61 | // Key navigation | 62 | // Key navigation |
106 | @@ -76,6 +77,7 @@ | |||
107 | 76 | float _rotation; | 77 | float _rotation; |
108 | 77 | 78 | ||
109 | 78 | guint32 _spinner_timeout; | 79 | guint32 _spinner_timeout; |
110 | 80 | guint32 _frame_timeout; | ||
111 | 79 | }; | 81 | }; |
112 | 80 | 82 | ||
113 | 81 | } | 83 | } |
114 | 82 | 84 | ||
115 | === modified file 'plugins/unityshell/src/DashView.cpp' | |||
116 | --- plugins/unityshell/src/DashView.cpp 2011-08-22 13:48:47 +0000 | |||
117 | +++ plugins/unityshell/src/DashView.cpp 2011-08-24 12:31:11 +0000 | |||
118 | @@ -55,7 +55,7 @@ | |||
119 | 55 | mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); | 55 | mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); |
120 | 56 | 56 | ||
121 | 57 | Relayout(); | 57 | Relayout(); |
123 | 58 | OnLensBarActivated("home"); | 58 | lens_bar_->Activate("home.lens"); |
124 | 59 | 59 | ||
125 | 60 | bg_effect_helper_.owner = this; | 60 | bg_effect_helper_.owner = this; |
126 | 61 | bg_effect_helper_.enabled = false; | 61 | bg_effect_helper_.enabled = false; |
127 | @@ -105,7 +105,7 @@ | |||
128 | 105 | 105 | ||
129 | 106 | home_view_ = new HomeView(); | 106 | home_view_ = new HomeView(); |
130 | 107 | active_lens_view_ = home_view_; | 107 | active_lens_view_ = home_view_; |
132 | 108 | lens_views_["home"] = home_view_; | 108 | lens_views_["home.lens"] = home_view_; |
133 | 109 | lenses_layout_->AddView(home_view_); | 109 | lenses_layout_->AddView(home_view_); |
134 | 110 | 110 | ||
135 | 111 | lens_bar_ = new LensBar(); | 111 | lens_bar_ = new LensBar(); |
136 | @@ -117,8 +117,6 @@ | |||
137 | 117 | { | 117 | { |
138 | 118 | ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, | 118 | ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, |
139 | 119 | sigc::mem_fun(this, &DashView::OnActivateRequest)); | 119 | sigc::mem_fun(this, &DashView::OnActivateRequest)); |
140 | 120 | ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_QUEUE_DRAW, | ||
141 | 121 | [&] (GVariant* args) { QueueDraw(); }); | ||
142 | 122 | ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, | 120 | ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, |
143 | 123 | sigc::mem_fun(this, &DashView::OnBackgroundColorChanged)); | 121 | sigc::mem_fun(this, &DashView::OnBackgroundColorChanged)); |
144 | 124 | } | 122 | } |
145 | @@ -260,7 +258,7 @@ | |||
146 | 260 | texxform, | 258 | texxform, |
147 | 261 | nux::color::White); | 259 | nux::color::White); |
148 | 262 | } | 260 | } |
150 | 263 | { | 261 | { |
151 | 264 | // Bottom repeated texture | 262 | // Bottom repeated texture |
152 | 265 | int real_width = geo.width - corner->GetWidth(); | 263 | int real_width = geo.width - corner->GetWidth(); |
153 | 266 | int offset = real_width % bottom->GetWidth(); | 264 | int offset = real_width % bottom->GetWidth(); |
154 | @@ -276,7 +274,6 @@ | |||
155 | 276 | texxform, | 274 | texxform, |
156 | 277 | nux::color::White); | 275 | nux::color::White); |
157 | 278 | } | 276 | } |
158 | 279 | |||
159 | 280 | { | 277 | { |
160 | 281 | // Right repeated texture | 278 | // Right repeated texture |
161 | 282 | int real_height = geo.height - corner->GetHeight(); | 279 | int real_height = geo.height - corner->GetHeight(); |
162 | @@ -358,7 +355,7 @@ | |||
163 | 358 | 355 | ||
164 | 359 | g_variant_get(args, "(sus)", &id, NULL, &search_string); | 356 | g_variant_get(args, "(sus)", &id, NULL, &search_string); |
165 | 360 | 357 | ||
167 | 361 | OnLensBarActivated(id.Str()); | 358 | lens_bar_->Activate(id.Str()); |
168 | 362 | 359 | ||
169 | 363 | // Reset focus | 360 | // Reset focus |
170 | 364 | SetFocused(false); | 361 | SetFocused(false); |
171 | @@ -405,8 +402,6 @@ | |||
172 | 405 | 402 | ||
173 | 406 | lens->activated.connect(sigc::mem_fun(this, &DashView::OnUriActivatedReply)); | 403 | lens->activated.connect(sigc::mem_fun(this, &DashView::OnUriActivatedReply)); |
174 | 407 | lens->search_finished.connect(sigc::mem_fun(this, &DashView::OnSearchFinished)); | 404 | lens->search_finished.connect(sigc::mem_fun(this, &DashView::OnSearchFinished)); |
175 | 408 | |||
176 | 409 | lens->Search(""); | ||
177 | 410 | } | 405 | } |
178 | 411 | 406 | ||
179 | 412 | void DashView::OnLensBarActivated(std::string const& id) | 407 | void DashView::OnLensBarActivated(std::string const& id) |
180 | @@ -418,7 +413,10 @@ | |||
181 | 418 | } | 413 | } |
182 | 419 | 414 | ||
183 | 420 | for (auto it: lens_views_) | 415 | for (auto it: lens_views_) |
184 | 416 | { | ||
185 | 421 | it.second->SetVisible(it.first == id); | 417 | it.second->SetVisible(it.first == id); |
186 | 418 | it.second->active = it.first == id; | ||
187 | 419 | } | ||
188 | 422 | 420 | ||
189 | 423 | LensView* view = active_lens_view_ = lens_views_[id]; | 421 | LensView* view = active_lens_view_ = lens_views_[id]; |
190 | 424 | search_bar_->search_string = view->search_string; | 422 | search_bar_->search_string = view->search_string; |
191 | @@ -447,7 +445,6 @@ | |||
192 | 447 | void DashView::OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&) | 445 | void DashView::OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&) |
193 | 448 | { | 446 | { |
194 | 449 | // We don't want to close the dash if there was another activation pending | 447 | // We don't want to close the dash if there was another activation pending |
195 | 450 | |||
196 | 451 | if (type == NOT_HANDLED) | 448 | if (type == NOT_HANDLED) |
197 | 452 | { | 449 | { |
198 | 453 | if (!DoFallbackActivation(uri)) | 450 | if (!DoFallbackActivation(uri)) |
199 | 454 | 451 | ||
200 | === modified file 'plugins/unityshell/src/FilterExpanderLabel.cpp' | |||
201 | --- plugins/unityshell/src/FilterExpanderLabel.cpp 2011-08-19 15:17:30 +0000 | |||
202 | +++ plugins/unityshell/src/FilterExpanderLabel.cpp 2011-08-24 12:31:11 +0000 | |||
203 | @@ -34,7 +34,7 @@ | |||
204 | 34 | , contents_ (NULL) | 34 | , contents_ (NULL) |
205 | 35 | , right_hand_contents_ (NULL) | 35 | , right_hand_contents_ (NULL) |
206 | 36 | , expander_graphic_ (NULL) | 36 | , expander_graphic_ (NULL) |
208 | 37 | , label_("<span font_size='x-large'>" + label + "</span>") | 37 | , label_("<span font_size='larger'>" + label + "</span>") |
209 | 38 | { | 38 | { |
210 | 39 | expanded.changed.connect (sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange)); | 39 | expanded.changed.connect (sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange)); |
211 | 40 | BuildLayout (); | 40 | BuildLayout (); |
212 | @@ -46,7 +46,7 @@ | |||
213 | 46 | 46 | ||
214 | 47 | void FilterExpanderLabel::SetLabel (std::string label) | 47 | void FilterExpanderLabel::SetLabel (std::string label) |
215 | 48 | { | 48 | { |
217 | 49 | label_ = "<style size='x-large'>" + label + "</style>"; | 49 | label_ = "<style size='larger'>" + label + "</style>"; |
218 | 50 | cairo_label_->SetText(label.c_str()); | 50 | cairo_label_->SetText(label.c_str()); |
219 | 51 | } | 51 | } |
220 | 52 | 52 | ||
221 | 53 | 53 | ||
222 | === modified file 'plugins/unityshell/src/FilterGenreWidget.cpp' | |||
223 | --- plugins/unityshell/src/FilterGenreWidget.cpp 2011-08-17 15:00:14 +0000 | |||
224 | +++ plugins/unityshell/src/FilterGenreWidget.cpp 2011-08-24 12:31:11 +0000 | |||
225 | @@ -25,6 +25,7 @@ | |||
226 | 25 | #include "FilterGenreWidget.h" | 25 | #include "FilterGenreWidget.h" |
227 | 26 | #include "FilterGenreButton.h" | 26 | #include "FilterGenreButton.h" |
228 | 27 | #include "FilterBasicButton.h" | 27 | #include "FilterBasicButton.h" |
229 | 28 | #include "PlacesStyle.h" | ||
230 | 28 | 29 | ||
231 | 29 | namespace unity { | 30 | namespace unity { |
232 | 30 | 31 | ||
233 | @@ -37,13 +38,15 @@ | |||
234 | 37 | all_button_->activated.connect(sigc::mem_fun(this, &FilterGenre::OnAllActivated)); | 38 | all_button_->activated.connect(sigc::mem_fun(this, &FilterGenre::OnAllActivated)); |
235 | 38 | all_button_->Reference(); | 39 | all_button_->Reference(); |
236 | 39 | 40 | ||
237 | 41 | PlacesStyle* style = PlacesStyle::GetDefault(); | ||
238 | 42 | |||
239 | 40 | genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION); | 43 | genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION); |
240 | 41 | genre_layout_->ForceChildrenSize(true); | 44 | genre_layout_->ForceChildrenSize(true); |
241 | 42 | genre_layout_->SetHeightMatchContent(true); | 45 | genre_layout_->SetHeightMatchContent(true); |
242 | 43 | genre_layout_->SetVerticalInternalMargin (6); | 46 | genre_layout_->SetVerticalInternalMargin (6); |
243 | 44 | genre_layout_->SetHorizontalInternalMargin (6); | 47 | genre_layout_->SetHorizontalInternalMargin (6); |
244 | 45 | genre_layout_->EnablePartialVisibility (false); | 48 | genre_layout_->EnablePartialVisibility (false); |
246 | 46 | genre_layout_->SetChildrenSize (120, 40); | 49 | genre_layout_->SetChildrenSize (style->GetTileWidth() - 12, style->GetTextLineHeight() * 2); |
247 | 47 | genre_layout_->Reference(); | 50 | genre_layout_->Reference(); |
248 | 48 | 51 | ||
249 | 49 | SetRightHandView(all_button_); | 52 | SetRightHandView(all_button_); |
250 | 50 | 53 | ||
251 | === modified file 'plugins/unityshell/src/FilterMultiRangeButton.cpp' | |||
252 | --- plugins/unityshell/src/FilterMultiRangeButton.cpp 2011-08-22 12:04:21 +0000 | |||
253 | +++ plugins/unityshell/src/FilterMultiRangeButton.cpp 2011-08-24 12:31:11 +0000 | |||
254 | @@ -122,7 +122,7 @@ | |||
255 | 122 | normal_ = new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::State::NUX_STATE_NORMAL)); | 122 | normal_ = new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::State::NUX_STATE_NORMAL)); |
256 | 123 | } | 123 | } |
257 | 124 | 124 | ||
259 | 125 | SetMinimumHeight(32); | 125 | //SetMinimumHeight(32); |
260 | 126 | } | 126 | } |
261 | 127 | 127 | ||
262 | 128 | void FilterMultiRangeButton::RedrawTheme (nux::Geometry const& geom, cairo_t *cr, nux::State faked_state) | 128 | void FilterMultiRangeButton::RedrawTheme (nux::Geometry const& geom, cairo_t *cr, nux::State faked_state) |
263 | 129 | 129 | ||
264 | === added file 'plugins/unityshell/src/FontSettings.cpp' | |||
265 | --- plugins/unityshell/src/FontSettings.cpp 1970-01-01 00:00:00 +0000 | |||
266 | +++ plugins/unityshell/src/FontSettings.cpp 2011-08-24 12:31:11 +0000 | |||
267 | @@ -0,0 +1,88 @@ | |||
268 | 1 | /* | ||
269 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
270 | 3 | * | ||
271 | 4 | * This program is free software: you can redistribute it and/or modify | ||
272 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
273 | 6 | * published by the Free Software Foundation. | ||
274 | 7 | * | ||
275 | 8 | * This program is distributed in the hope that it will be useful, | ||
276 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
277 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
278 | 11 | * GNU General Public License for more details. | ||
279 | 12 | * | ||
280 | 13 | * You should have received a copy of the GNU General Public License | ||
281 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
282 | 15 | * | ||
283 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | ||
284 | 17 | */ | ||
285 | 18 | |||
286 | 19 | #include "FontSettings.h" | ||
287 | 20 | |||
288 | 21 | #include <cairo/cairo.h> | ||
289 | 22 | |||
290 | 23 | #include <UnityCore/GLibWrapper.h> | ||
291 | 24 | |||
292 | 25 | namespace unity | ||
293 | 26 | { | ||
294 | 27 | |||
295 | 28 | FontSettings::FontSettings() | ||
296 | 29 | { | ||
297 | 30 | GtkSettings* settings = gtk_settings_get_default(); | ||
298 | 31 | |||
299 | 32 | sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-hintstyle", sigc::mem_fun(this, &FontSettings::Refresh))); | ||
300 | 33 | sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-rgba", sigc::mem_fun(this, &FontSettings::Refresh))); | ||
301 | 34 | |||
302 | 35 | Refresh(); | ||
303 | 36 | } | ||
304 | 37 | |||
305 | 38 | void FontSettings::Refresh(GtkSettings* unused0, GParamSpec* unused1) | ||
306 | 39 | { | ||
307 | 40 | GtkSettings* settings = gtk_settings_get_default(); | ||
308 | 41 | cairo_font_options_t* font_options = cairo_font_options_create(); | ||
309 | 42 | |||
310 | 43 | { | ||
311 | 44 | cairo_subpixel_order_t order = CAIRO_SUBPIXEL_ORDER_DEFAULT; | ||
312 | 45 | glib::String value; | ||
313 | 46 | g_object_get(settings, "gtk-xft-rgba", &value, NULL); | ||
314 | 47 | |||
315 | 48 | if (value.Str() == "rgb") | ||
316 | 49 | order = CAIRO_SUBPIXEL_ORDER_RGB; | ||
317 | 50 | else if (value.Str() == "bgr") | ||
318 | 51 | order = CAIRO_SUBPIXEL_ORDER_BGR; | ||
319 | 52 | else if (value.Str() == "vrgb") | ||
320 | 53 | order = CAIRO_SUBPIXEL_ORDER_VRGB; | ||
321 | 54 | else if (value.Str() == "vbgr") | ||
322 | 55 | order = CAIRO_SUBPIXEL_ORDER_VBGR; | ||
323 | 56 | |||
324 | 57 | cairo_font_options_set_subpixel_order(font_options, order); | ||
325 | 58 | cairo_font_options_set_antialias(font_options, | ||
326 | 59 | value.Str() == "none" ? CAIRO_ANTIALIAS_NONE | ||
327 | 60 | : CAIRO_ANTIALIAS_SUBPIXEL); | ||
328 | 61 | |||
329 | 62 | } | ||
330 | 63 | |||
331 | 64 | { | ||
332 | 65 | cairo_hint_style_t style = CAIRO_HINT_STYLE_DEFAULT; | ||
333 | 66 | glib::String value; | ||
334 | 67 | g_object_get(settings, "gtk-xft-hintstyle", &value, NULL); | ||
335 | 68 | |||
336 | 69 | if (value.Str() == "hintnone") | ||
337 | 70 | style = CAIRO_HINT_STYLE_NONE; | ||
338 | 71 | else if (value.Str() == "hintslight") | ||
339 | 72 | style = CAIRO_HINT_STYLE_SLIGHT; | ||
340 | 73 | else if (value.Str() == "hintmedium") | ||
341 | 74 | style = CAIRO_HINT_STYLE_MEDIUM; | ||
342 | 75 | else if (value.Str() == "hintfull") | ||
343 | 76 | style = CAIRO_HINT_STYLE_FULL; | ||
344 | 77 | |||
345 | 78 | cairo_font_options_set_hint_style(font_options, style); | ||
346 | 79 | } | ||
347 | 80 | |||
348 | 81 | // FIXME: Where do we read this value from? | ||
349 | 82 | cairo_font_options_set_hint_metrics(font_options, CAIRO_HINT_METRICS_ON); | ||
350 | 83 | |||
351 | 84 | gdk_screen_set_font_options(gdk_screen_get_default(), font_options); | ||
352 | 85 | cairo_font_options_destroy(font_options); | ||
353 | 86 | } | ||
354 | 87 | |||
355 | 88 | } | ||
356 | 0 | 89 | ||
357 | === added file 'plugins/unityshell/src/FontSettings.h' | |||
358 | --- plugins/unityshell/src/FontSettings.h 1970-01-01 00:00:00 +0000 | |||
359 | +++ plugins/unityshell/src/FontSettings.h 2011-08-24 12:31:11 +0000 | |||
360 | @@ -0,0 +1,43 @@ | |||
361 | 1 | /* | ||
362 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
363 | 3 | * | ||
364 | 4 | * This program is free software: you can redistribute it and/or modify | ||
365 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
366 | 6 | * published by the Free Software Foundation. | ||
367 | 7 | * | ||
368 | 8 | * This program is distributed in the hope that it will be useful, | ||
369 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
370 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
371 | 11 | * GNU General Public License for more details. | ||
372 | 12 | * | ||
373 | 13 | * You should have received a copy of the GNU General Public License | ||
374 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
375 | 15 | * | ||
376 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | ||
377 | 17 | */ | ||
378 | 18 | |||
379 | 19 | #ifndef UNITY_FONT_SETTINGS_H_ | ||
380 | 20 | #define UNITY_FONT_SETTINGS_H_ | ||
381 | 21 | |||
382 | 22 | #include <gtk/gtk.h> | ||
383 | 23 | |||
384 | 24 | #include <UnityCore/GLibSignal.h> | ||
385 | 25 | |||
386 | 26 | namespace unity | ||
387 | 27 | { | ||
388 | 28 | |||
389 | 29 | class FontSettings | ||
390 | 30 | { | ||
391 | 31 | public: | ||
392 | 32 | FontSettings(); | ||
393 | 33 | |||
394 | 34 | private: | ||
395 | 35 | void Refresh(GtkSettings* unused0=nullptr, GParamSpec* unused1=nullptr); | ||
396 | 36 | |||
397 | 37 | private: | ||
398 | 38 | glib::SignalManager sig_man_; | ||
399 | 39 | }; | ||
400 | 40 | |||
401 | 41 | } | ||
402 | 42 | |||
403 | 43 | #endif | ||
404 | 0 | 44 | ||
405 | === modified file 'plugins/unityshell/src/HomeView.cpp' | |||
406 | --- plugins/unityshell/src/HomeView.cpp 2011-08-11 16:04:49 +0000 | |||
407 | +++ plugins/unityshell/src/HomeView.cpp 2011-08-24 12:31:11 +0000 | |||
408 | @@ -39,6 +39,7 @@ | |||
409 | 39 | NUX_IMPLEMENT_OBJECT_TYPE(HomeView); | 39 | NUX_IMPLEMENT_OBJECT_TYPE(HomeView); |
410 | 40 | 40 | ||
411 | 41 | HomeView::HomeView() | 41 | HomeView::HomeView() |
412 | 42 | : fix_renderering_id_(0) | ||
413 | 42 | { | 43 | { |
414 | 43 | SetupViews(); | 44 | SetupViews(); |
415 | 44 | 45 | ||
416 | @@ -52,11 +53,17 @@ | |||
417 | 52 | group->SetVisible(search != "" && counts_[group]); | 53 | group->SetVisible(search != "" && counts_[group]); |
418 | 53 | } | 54 | } |
419 | 54 | home_view_->SetVisible(search == ""); | 55 | home_view_->SetVisible(search == ""); |
420 | 56 | scroll_view_->SetVisible(search != ""); | ||
421 | 57 | |||
422 | 58 | QueueDraw(); | ||
423 | 55 | }); | 59 | }); |
424 | 56 | } | 60 | } |
425 | 57 | 61 | ||
426 | 58 | HomeView::~HomeView() | 62 | HomeView::~HomeView() |
428 | 59 | {} | 63 | { |
429 | 64 | if (fix_renderering_id_) | ||
430 | 65 | g_source_remove(fix_renderering_id_); | ||
431 | 66 | } | ||
432 | 60 | 67 | ||
433 | 61 | void HomeView::SetupViews() | 68 | void HomeView::SetupViews() |
434 | 62 | { | 69 | { |
435 | @@ -65,13 +72,14 @@ | |||
436 | 65 | scroll_view_ = new nux::ScrollView(); | 72 | scroll_view_ = new nux::ScrollView(); |
437 | 66 | scroll_view_->EnableVerticalScrollBar(true); | 73 | scroll_view_->EnableVerticalScrollBar(true); |
438 | 67 | scroll_view_->EnableHorizontalScrollBar(false); | 74 | scroll_view_->EnableHorizontalScrollBar(false); |
439 | 75 | scroll_view_->SetVisible(false); | ||
440 | 68 | layout_->AddView(scroll_view_); | 76 | layout_->AddView(scroll_view_); |
441 | 69 | 77 | ||
442 | 70 | scroll_layout_ = new nux::VLayout(); | 78 | scroll_layout_ = new nux::VLayout(); |
443 | 71 | scroll_view_->SetLayout(scroll_layout_); | 79 | scroll_view_->SetLayout(scroll_layout_); |
444 | 72 | 80 | ||
445 | 73 | home_view_ = new PlacesHomeView(); | 81 | home_view_ = new PlacesHomeView(); |
447 | 74 | scroll_layout_->AddView(home_view_); | 82 | layout_->AddView(home_view_); |
448 | 75 | 83 | ||
449 | 76 | SetLayout(layout_); | 84 | SetLayout(layout_); |
450 | 77 | } | 85 | } |
451 | @@ -124,6 +132,8 @@ | |||
452 | 124 | PlacesStyle* style = PlacesStyle::GetDefault(); | 132 | PlacesStyle* style = PlacesStyle::GetDefault(); |
453 | 125 | group->SetCounts(style->GetDefaultNColumns(), counts_[group]); | 133 | group->SetCounts(style->GetDefaultNColumns(), counts_[group]); |
454 | 126 | group->SetVisible(counts_[group]); | 134 | group->SetVisible(counts_[group]); |
455 | 135 | |||
456 | 136 | QueueFixRenderering(); | ||
457 | 127 | } | 137 | } |
458 | 128 | 138 | ||
459 | 129 | void HomeView::OnGroupExpanded(PlacesGroup* group) | 139 | void HomeView::OnGroupExpanded(PlacesGroup* group) |
460 | @@ -143,6 +153,34 @@ | |||
461 | 143 | } | 153 | } |
462 | 144 | } | 154 | } |
463 | 145 | 155 | ||
464 | 156 | void HomeView::QueueFixRenderering() | ||
465 | 157 | { | ||
466 | 158 | if (fix_renderering_id_) | ||
467 | 159 | return; | ||
468 | 160 | |||
469 | 161 | fix_renderering_id_ = g_timeout_add(0, (GSourceFunc)FixRenderering, this); | ||
470 | 162 | } | ||
471 | 163 | |||
472 | 164 | gboolean HomeView::FixRenderering(HomeView* self) | ||
473 | 165 | { | ||
474 | 166 | std::list<Area*> children = self->scroll_layout_->GetChildren(); | ||
475 | 167 | std::list<Area*>::reverse_iterator rit; | ||
476 | 168 | bool found_one = false; | ||
477 | 169 | |||
478 | 170 | for (rit = children.rbegin(); rit != children.rend(); ++rit) | ||
479 | 171 | { | ||
480 | 172 | PlacesGroup* group = static_cast<PlacesGroup*>(*rit); | ||
481 | 173 | |||
482 | 174 | if (group->IsVisible()) | ||
483 | 175 | group->SetDrawSeparator(found_one); | ||
484 | 176 | |||
485 | 177 | found_one = group->IsVisible(); | ||
486 | 178 | } | ||
487 | 179 | |||
488 | 180 | self->fix_renderering_id_ = 0; | ||
489 | 181 | return FALSE; | ||
490 | 182 | } | ||
491 | 183 | |||
492 | 146 | long HomeView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) | 184 | long HomeView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) |
493 | 147 | { | 185 | { |
494 | 148 | return layout_->ProcessEvent(ievent, traverse_info, event_info); | 186 | return layout_->ProcessEvent(ievent, traverse_info, event_info); |
495 | 149 | 187 | ||
496 | === modified file 'plugins/unityshell/src/HomeView.h' | |||
497 | --- plugins/unityshell/src/HomeView.h 2011-08-11 01:12:21 +0000 | |||
498 | +++ plugins/unityshell/src/HomeView.h 2011-08-24 12:31:11 +0000 | |||
499 | @@ -60,6 +60,9 @@ | |||
500 | 60 | void UpdateCounts(PlacesGroup* group); | 60 | void UpdateCounts(PlacesGroup* group); |
501 | 61 | void OnGroupExpanded(PlacesGroup* group); | 61 | void OnGroupExpanded(PlacesGroup* group); |
502 | 62 | void OnColumnsChanged(); | 62 | void OnColumnsChanged(); |
503 | 63 | void QueueFixRenderering(); | ||
504 | 64 | |||
505 | 65 | static gboolean FixRenderering(HomeView* self); | ||
506 | 63 | 66 | ||
507 | 64 | long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); | 67 | long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); |
508 | 65 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); | 68 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); |
509 | @@ -80,6 +83,8 @@ | |||
510 | 80 | nux::VLayout* scroll_layout_; | 83 | nux::VLayout* scroll_layout_; |
511 | 81 | 84 | ||
512 | 82 | PlacesHomeView* home_view_; | 85 | PlacesHomeView* home_view_; |
513 | 86 | |||
514 | 87 | guint fix_renderering_id_; | ||
515 | 83 | }; | 88 | }; |
516 | 84 | 89 | ||
517 | 85 | 90 | ||
518 | 86 | 91 | ||
519 | === modified file 'plugins/unityshell/src/IconTexture.cpp' | |||
520 | --- plugins/unityshell/src/IconTexture.cpp 2011-08-02 13:37:01 +0000 | |||
521 | +++ plugins/unityshell/src/IconTexture.cpp 2011-08-24 12:31:11 +0000 | |||
522 | @@ -250,6 +250,11 @@ | |||
523 | 250 | _texture_cached->Reference(); | 250 | _texture_cached->Reference(); |
524 | 251 | } | 251 | } |
525 | 252 | 252 | ||
526 | 253 | nux::BaseTexture* IconTexture::texture() const | ||
527 | 254 | { | ||
528 | 255 | return _texture_cached; | ||
529 | 256 | } | ||
530 | 257 | |||
531 | 253 | bool | 258 | bool |
532 | 254 | IconTexture::DoCanFocus() | 259 | IconTexture::DoCanFocus() |
533 | 255 | { | 260 | { |
534 | 256 | 261 | ||
535 | === modified file 'plugins/unityshell/src/IconTexture.h' | |||
536 | --- plugins/unityshell/src/IconTexture.h 2011-07-21 14:59:25 +0000 | |||
537 | +++ plugins/unityshell/src/IconTexture.h 2011-08-24 12:31:11 +0000 | |||
538 | @@ -45,6 +45,8 @@ | |||
539 | 45 | 45 | ||
540 | 46 | void SetAcceptKeyNavFocus(bool accept); | 46 | void SetAcceptKeyNavFocus(bool accept); |
541 | 47 | 47 | ||
542 | 48 | nux::BaseTexture* texture() const; | ||
543 | 49 | |||
544 | 48 | protected: | 50 | protected: |
545 | 49 | // Key navigation | 51 | // Key navigation |
546 | 50 | virtual bool AcceptKeyNavFocus(); | 52 | virtual bool AcceptKeyNavFocus(); |
547 | @@ -54,9 +56,9 @@ | |||
548 | 54 | void AddProperties(GVariantBuilder* builder); | 56 | void AddProperties(GVariantBuilder* builder); |
549 | 55 | virtual bool DoCanFocus(); | 57 | virtual bool DoCanFocus(); |
550 | 56 | 58 | ||
551 | 59 | protected: | ||
552 | 60 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
553 | 57 | private: | 61 | private: |
554 | 58 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
555 | 59 | |||
556 | 60 | void CreateTextureCallback(const char* texid, int width, int height, nux::BaseTexture** texture); | 62 | void CreateTextureCallback(const char* texid, int width, int height, nux::BaseTexture** texture); |
557 | 61 | void Refresh(GdkPixbuf* pixbuf); | 63 | void Refresh(GdkPixbuf* pixbuf); |
558 | 62 | void IconLoaded(const char* icon_name, guint size, GdkPixbuf* pixbuf); | 64 | void IconLoaded(const char* icon_name, guint size, GdkPixbuf* pixbuf); |
559 | 63 | 65 | ||
560 | === modified file 'plugins/unityshell/src/Launcher.cpp' | |||
561 | --- plugins/unityshell/src/Launcher.cpp 2011-08-23 23:23:47 +0000 | |||
562 | +++ plugins/unityshell/src/Launcher.cpp 2011-08-24 12:31:11 +0000 | |||
563 | @@ -1385,7 +1385,9 @@ | |||
564 | 1385 | 1385 | ||
565 | 1386 | // it's a tap on super and we didn't use any shortcuts | 1386 | // it's a tap on super and we didn't use any shortcuts |
566 | 1387 | if (TapOnSuper() && !_latest_shortcut) | 1387 | if (TapOnSuper() && !_latest_shortcut) |
568 | 1388 | ubus_server_send_message(ubus_server_get_default(), UBUS_DASH_EXTERNAL_ACTIVATION, NULL); | 1388 | ubus_server_send_message(ubus_server_get_default(), |
569 | 1389 | UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, | ||
570 | 1390 | g_variant_new("(sus)", "home.lens", 0, "")); | ||
571 | 1389 | 1391 | ||
572 | 1390 | remaining_time_before_hide = BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION - CLAMP((int)(TimeDelta(¤t, &_times[TIME_SUPER_PRESSED])), 0, BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION); | 1392 | remaining_time_before_hide = BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION - CLAMP((int)(TimeDelta(¤t, &_times[TIME_SUPER_PRESSED])), 0, BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION); |
573 | 1391 | 1393 | ||
574 | 1392 | 1394 | ||
575 | === modified file 'plugins/unityshell/src/LensBar.cpp' | |||
576 | --- plugins/unityshell/src/LensBar.cpp 2011-08-18 15:42:39 +0000 | |||
577 | +++ plugins/unityshell/src/LensBar.cpp 2011-08-24 12:31:11 +0000 | |||
578 | @@ -38,24 +38,8 @@ | |||
579 | 38 | : nux::View(NUX_TRACKER_LOCATION) | 38 | : nux::View(NUX_TRACKER_LOCATION) |
580 | 39 | { | 39 | { |
581 | 40 | SetupBackground(); | 40 | SetupBackground(); |
600 | 41 | 41 | SetupLayout(); | |
601 | 42 | layout_ = new nux::HLayout(); | 42 | SetupHomeLens(); |
584 | 43 | layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER); | ||
585 | 44 | layout_->SetHorizontalInternalMargin(24); | ||
586 | 45 | SetLayout(layout_); | ||
587 | 46 | |||
588 | 47 | SetMinimumHeight(40); | ||
589 | 48 | SetMaximumHeight(40); | ||
590 | 49 | |||
591 | 50 | { | ||
592 | 51 | std::string id = "home"; | ||
593 | 52 | IconTexture* icon = new IconTexture(PKGDATADIR"/lens-nav-home.svg", 26); | ||
594 | 53 | icon->SetMinMaxSize(26, 26); | ||
595 | 54 | icon->SetVisible(true); | ||
596 | 55 | layout_->AddView(icon, 0, nux::eCenter, nux::eFix); | ||
597 | 56 | |||
598 | 57 | icon->mouse_click.connect([&, id] (int x, int y, unsigned long button, unsigned long keyboard) { lens_activated.emit(id); }); | ||
599 | 58 | } | ||
602 | 59 | } | 43 | } |
603 | 60 | 44 | ||
604 | 61 | LensBar::~LensBar() | 45 | LensBar::~LensBar() |
605 | @@ -70,18 +54,49 @@ | |||
606 | 70 | bg_layer_ = new nux::ColorLayer(nux::Color(0.0f, 0.0f, 0.0f, 0.2f), true, rop); | 54 | bg_layer_ = new nux::ColorLayer(nux::Color(0.0f, 0.0f, 0.0f, 0.2f), true, rop); |
607 | 71 | } | 55 | } |
608 | 72 | 56 | ||
609 | 57 | void LensBar::SetupLayout() | ||
610 | 58 | { | ||
611 | 59 | layout_ = new nux::HLayout(); | ||
612 | 60 | layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER); | ||
613 | 61 | layout_->SetHorizontalInternalMargin(32); | ||
614 | 62 | SetLayout(layout_); | ||
615 | 63 | |||
616 | 64 | SetMinimumHeight(40); | ||
617 | 65 | SetMaximumHeight(40); | ||
618 | 66 | } | ||
619 | 67 | |||
620 | 68 | void LensBar::SetupHomeLens() | ||
621 | 69 | { | ||
622 | 70 | LensBarIcon* icon = new LensBarIcon("home.lens", PKGDATADIR"/lens-nav-home.svg"); | ||
623 | 71 | icon->SetVisible(true); | ||
624 | 72 | icon->active = true; | ||
625 | 73 | icons_.push_back(icon); | ||
626 | 74 | layout_->AddView(icon, 0, nux::eCenter, nux::MINOR_SIZE_FULL); | ||
627 | 75 | |||
628 | 76 | icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); }); | ||
629 | 77 | } | ||
630 | 78 | |||
631 | 73 | void LensBar::AddLens(Lens::Ptr& lens) | 79 | void LensBar::AddLens(Lens::Ptr& lens) |
632 | 74 | { | 80 | { |
638 | 75 | std::string id = lens->id; | 81 | LensBarIcon* icon = new LensBarIcon(lens->id, lens->icon_hint); |
634 | 76 | std::string icon_hint = lens->icon_hint; | ||
635 | 77 | |||
636 | 78 | IconTexture* icon = new IconTexture(icon_hint.c_str(), 26); | ||
637 | 79 | icon->SetMinMaxSize(26, 26); | ||
639 | 80 | icon->SetVisible(lens->visible); | 82 | icon->SetVisible(lens->visible); |
640 | 81 | lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } ); | 83 | lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } ); |
641 | 84 | icons_.push_back(icon); | ||
642 | 82 | layout_->AddView(icon, 0, nux::eCenter, nux::eFix); | 85 | layout_->AddView(icon, 0, nux::eCenter, nux::eFix); |
643 | 83 | 86 | ||
645 | 84 | icon->mouse_click.connect([&, id] (int x, int y, unsigned long button, unsigned long keyboard) { lens_activated.emit(id); }); | 87 | icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); }); |
646 | 88 | } | ||
647 | 89 | |||
648 | 90 | void LensBar::Activate(std::string id) | ||
649 | 91 | { | ||
650 | 92 | for (auto icon: icons_) | ||
651 | 93 | { | ||
652 | 94 | if (icon->id == id) | ||
653 | 95 | { | ||
654 | 96 | SetActive(icon); | ||
655 | 97 | break; | ||
656 | 98 | } | ||
657 | 99 | } | ||
658 | 85 | } | 100 | } |
659 | 86 | 101 | ||
660 | 87 | long LensBar::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) | 102 | long LensBar::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) |
661 | @@ -109,12 +124,20 @@ | |||
662 | 109 | nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_); | 124 | nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_); |
663 | 110 | 125 | ||
664 | 111 | layout_->ProcessDraw(gfx_context, force_draw); | 126 | layout_->ProcessDraw(gfx_context, force_draw); |
666 | 112 | 127 | ||
667 | 113 | nux::GetPainter().PopBackground(); | 128 | nux::GetPainter().PopBackground(); |
668 | 114 | 129 | ||
669 | 115 | gfx_context.PopClippingRectangle(); | 130 | gfx_context.PopClippingRectangle(); |
670 | 116 | } | 131 | } |
671 | 117 | 132 | ||
672 | 133 | void LensBar::SetActive(LensBarIcon* activated) | ||
673 | 134 | { | ||
674 | 135 | for (auto icon: icons_) | ||
675 | 136 | icon->active = icon == activated; | ||
676 | 137 | |||
677 | 138 | lens_activated.emit(activated->id); | ||
678 | 139 | } | ||
679 | 140 | |||
680 | 118 | // Keyboard navigation | 141 | // Keyboard navigation |
681 | 119 | bool LensBar::AcceptKeyNavFocus() | 142 | bool LensBar::AcceptKeyNavFocus() |
682 | 120 | { | 143 | { |
683 | 121 | 144 | ||
684 | === modified file 'plugins/unityshell/src/LensBar.h' | |||
685 | --- plugins/unityshell/src/LensBar.h 2011-08-18 15:42:39 +0000 | |||
686 | +++ plugins/unityshell/src/LensBar.h 2011-08-24 12:31:11 +0000 | |||
687 | @@ -20,6 +20,7 @@ | |||
688 | 20 | #define UNITY_LENS_BAR_H_ | 20 | #define UNITY_LENS_BAR_H_ |
689 | 21 | 21 | ||
690 | 22 | #include <string> | 22 | #include <string> |
691 | 23 | #include <vector> | ||
692 | 23 | 24 | ||
693 | 24 | #include <NuxGraphics/GraphicsEngine.h> | 25 | #include <NuxGraphics/GraphicsEngine.h> |
694 | 25 | #include <Nux/Nux.h> | 26 | #include <Nux/Nux.h> |
695 | @@ -29,36 +30,45 @@ | |||
696 | 29 | 30 | ||
697 | 30 | #include "IconTexture.h" | 31 | #include "IconTexture.h" |
698 | 31 | #include "Introspectable.h" | 32 | #include "Introspectable.h" |
699 | 33 | #include "LensBarIcon.h" | ||
700 | 32 | 34 | ||
701 | 33 | namespace unity | 35 | namespace unity |
702 | 34 | { | 36 | { |
703 | 35 | namespace dash | 37 | namespace dash |
704 | 36 | { | 38 | { |
705 | 37 | 39 | ||
707 | 38 | class LensBar : public nux::View, public unity::Introspectable | 40 | class LensBar : public nux::View, public unity::Introspectable |
708 | 39 | { | 41 | { |
709 | 40 | NUX_DECLARE_OBJECT_TYPE(LensBar, nux::View); | 42 | NUX_DECLARE_OBJECT_TYPE(LensBar, nux::View); |
710 | 43 | typedef std::vector<LensBarIcon*> LensIcons; | ||
711 | 41 | 44 | ||
712 | 42 | public: | 45 | public: |
713 | 43 | LensBar(); | 46 | LensBar(); |
714 | 44 | ~LensBar(); | 47 | ~LensBar(); |
715 | 45 | 48 | ||
716 | 46 | void AddLens(Lens::Ptr& lens); | 49 | void AddLens(Lens::Ptr& lens); |
717 | 50 | void Activate(std::string id); | ||
718 | 47 | 51 | ||
719 | 48 | sigc::signal<void, std::string const&> lens_activated; | 52 | sigc::signal<void, std::string const&> lens_activated; |
720 | 49 | 53 | ||
721 | 50 | private: | 54 | private: |
722 | 51 | void SetupBackground(); | 55 | void SetupBackground(); |
723 | 56 | void SetupLayout(); | ||
724 | 57 | void SetupHomeLens(); | ||
725 | 52 | 58 | ||
726 | 53 | long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); | 59 | long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); |
727 | 54 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); | 60 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); |
728 | 55 | void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw); | 61 | void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw); |
729 | 56 | 62 | ||
730 | 63 | void SetActive(LensBarIcon* icon); | ||
731 | 64 | |||
732 | 57 | bool AcceptKeyNavFocus(); | 65 | bool AcceptKeyNavFocus(); |
733 | 58 | const gchar* GetName(); | 66 | const gchar* GetName(); |
734 | 59 | void AddProperties(GVariantBuilder* builder); | 67 | void AddProperties(GVariantBuilder* builder); |
735 | 60 | 68 | ||
736 | 61 | private: | 69 | private: |
737 | 70 | LensIcons icons_; | ||
738 | 71 | |||
739 | 62 | nux::ColorLayer* bg_layer_; | 72 | nux::ColorLayer* bg_layer_; |
740 | 63 | nux::HLayout* layout_; | 73 | nux::HLayout* layout_; |
741 | 64 | }; | 74 | }; |
742 | 65 | 75 | ||
743 | === added file 'plugins/unityshell/src/LensBarIcon.cpp' | |||
744 | --- plugins/unityshell/src/LensBarIcon.cpp 1970-01-01 00:00:00 +0000 | |||
745 | +++ plugins/unityshell/src/LensBarIcon.cpp 2011-08-24 12:31:11 +0000 | |||
746 | @@ -0,0 +1,101 @@ | |||
747 | 1 | /* | ||
748 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
749 | 3 | * | ||
750 | 4 | * This program is free software: you can redistribute it and/or modify | ||
751 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
752 | 6 | * published by the Free Software Foundation. | ||
753 | 7 | * | ||
754 | 8 | * This program is distributed in the hope that it will be useful, | ||
755 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
756 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
757 | 11 | * GNU General Public License for more details. | ||
758 | 12 | * | ||
759 | 13 | * You should have received a copy of the GNU General Public License | ||
760 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
761 | 15 | * | ||
762 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | ||
763 | 17 | */ | ||
764 | 18 | |||
765 | 19 | #include "LensBarIcon.h" | ||
766 | 20 | |||
767 | 21 | #include "config.h" | ||
768 | 22 | |||
769 | 23 | namespace unity | ||
770 | 24 | { | ||
771 | 25 | namespace dash | ||
772 | 26 | { | ||
773 | 27 | |||
774 | 28 | NUX_IMPLEMENT_OBJECT_TYPE(LensBarIcon); | ||
775 | 29 | |||
776 | 30 | LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint) | ||
777 | 31 | : IconTexture(icon_hint.c_str(), 26) | ||
778 | 32 | , id(id_) | ||
779 | 33 | , active(false) | ||
780 | 34 | , inactive_opacity_(0.4f) | ||
781 | 35 | { | ||
782 | 36 | SetMinimumWidth(26); | ||
783 | 37 | SetMaximumWidth(26); | ||
784 | 38 | SetMinimumHeight(40); | ||
785 | 39 | SetMaximumHeight(40); | ||
786 | 40 | SetOpacity(inactive_opacity_); | ||
787 | 41 | |||
788 | 42 | active.changed.connect(sigc::mem_fun(this, &LensBarIcon::OnActiveChanged)); | ||
789 | 43 | mouse_enter.connect([&] | ||
790 | 44 | (int, int, unsigned long, unsigned long) { QueueDraw(); }); | ||
791 | 45 | mouse_leave.connect([&](int, int, unsigned long, unsigned long) { QueueDraw(); }); | ||
792 | 46 | } | ||
793 | 47 | |||
794 | 48 | LensBarIcon::~LensBarIcon() | ||
795 | 49 | {} | ||
796 | 50 | |||
797 | 51 | void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) | ||
798 | 52 | { | ||
799 | 53 | nux::Geometry geo = GetGeometry(); | ||
800 | 54 | |||
801 | 55 | gfx_context.PushClippingRectangle(geo); | ||
802 | 56 | |||
803 | 57 | nux::GetPainter().PaintBackground(gfx_context, geo); | ||
804 | 58 | |||
805 | 59 | if (!texture()) | ||
806 | 60 | return; | ||
807 | 61 | |||
808 | 62 | float opacity = active || IsMouseInside() ? 1.0f : inactive_opacity_; | ||
809 | 63 | int width = 0, height = 0; | ||
810 | 64 | GetTextureSize(&width, &height); | ||
811 | 65 | |||
812 | 66 | nux::Color col(1.0f * opacity, 1.0f * opacity, 1.0f * opacity, opacity); | ||
813 | 67 | nux::TexCoordXForm texxform; | ||
814 | 68 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); | ||
815 | 69 | texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); | ||
816 | 70 | |||
817 | 71 | gfx_context.QRP_1Tex(geo.x + ((geo.width - width) / 2), | ||
818 | 72 | geo.y + ((geo.height - height) / 2), | ||
819 | 73 | width, | ||
820 | 74 | height, | ||
821 | 75 | texture()->GetDeviceTexture(), | ||
822 | 76 | texxform, | ||
823 | 77 | col); | ||
824 | 78 | if (active) | ||
825 | 79 | { | ||
826 | 80 | nux::Geometry geo = GetGeometry(); | ||
827 | 81 | int middle = geo.x + geo.width/2; | ||
828 | 82 | int size = 4; | ||
829 | 83 | int y = geo.y + 1; | ||
830 | 84 | |||
831 | 85 | nux::GetPainter().Draw2DTriangleColor(gfx_context, | ||
832 | 86 | middle - size, y, | ||
833 | 87 | middle, y + size, | ||
834 | 88 | middle + size, y, | ||
835 | 89 | nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); | ||
836 | 90 | } | ||
837 | 91 | |||
838 | 92 | gfx_context.PopClippingRectangle(); | ||
839 | 93 | } | ||
840 | 94 | |||
841 | 95 | void LensBarIcon::OnActiveChanged(bool is_active) | ||
842 | 96 | { | ||
843 | 97 | QueueDraw(); | ||
844 | 98 | } | ||
845 | 99 | |||
846 | 100 | } | ||
847 | 101 | } | ||
848 | 0 | 102 | ||
849 | === added file 'plugins/unityshell/src/LensBarIcon.h' | |||
850 | --- plugins/unityshell/src/LensBarIcon.h 1970-01-01 00:00:00 +0000 | |||
851 | +++ plugins/unityshell/src/LensBarIcon.h 2011-08-24 12:31:11 +0000 | |||
852 | @@ -0,0 +1,56 @@ | |||
853 | 1 | /* | ||
854 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
855 | 3 | * | ||
856 | 4 | * This program is free software: you can redistribute it and/or modify | ||
857 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
858 | 6 | * published by the Free Software Foundation. | ||
859 | 7 | * | ||
860 | 8 | * This program is distributed in the hope that it will be useful, | ||
861 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
862 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
863 | 11 | * GNU General Public License for more details. | ||
864 | 12 | * | ||
865 | 13 | * You should have received a copy of the GNU General Public License | ||
866 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
867 | 15 | * | ||
868 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | ||
869 | 17 | */ | ||
870 | 18 | |||
871 | 19 | #ifndef UNITY_LENS_BAR_ICON_H_ | ||
872 | 20 | #define UNITY_LENS_BAR_ICON_H_ | ||
873 | 21 | |||
874 | 22 | #include <string> | ||
875 | 23 | |||
876 | 24 | #include <NuxGraphics/GraphicsEngine.h> | ||
877 | 25 | #include <Nux/Nux.h> | ||
878 | 26 | #include <Nux/HLayout.h> | ||
879 | 27 | #include <Nux/View.h> | ||
880 | 28 | |||
881 | 29 | #include "IconTexture.h" | ||
882 | 30 | |||
883 | 31 | namespace unity | ||
884 | 32 | { | ||
885 | 33 | namespace dash | ||
886 | 34 | { | ||
887 | 35 | |||
888 | 36 | class LensBarIcon : public IconTexture | ||
889 | 37 | { | ||
890 | 38 | NUX_DECLARE_OBJECT_TYPE(LensBarIcon, IconTexture); | ||
891 | 39 | public: | ||
892 | 40 | LensBarIcon(std::string id, std::string icon_hint); | ||
893 | 41 | ~LensBarIcon(); | ||
894 | 42 | |||
895 | 43 | nux::Property<std::string> id; | ||
896 | 44 | nux::Property<bool> active; | ||
897 | 45 | |||
898 | 46 | private: | ||
899 | 47 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); | ||
900 | 48 | void OnActiveChanged(bool is_active); | ||
901 | 49 | |||
902 | 50 | private: | ||
903 | 51 | const float inactive_opacity_; | ||
904 | 52 | }; | ||
905 | 53 | |||
906 | 54 | } | ||
907 | 55 | } | ||
908 | 56 | #endif | ||
909 | 0 | 57 | ||
910 | === modified file 'plugins/unityshell/src/LensView.cpp' | |||
911 | --- plugins/unityshell/src/LensView.cpp 2011-08-11 01:11:11 +0000 | |||
912 | +++ plugins/unityshell/src/LensView.cpp 2011-08-24 12:31:11 +0000 | |||
913 | @@ -42,6 +42,7 @@ | |||
914 | 42 | : nux::View(NUX_TRACKER_LOCATION) | 42 | : nux::View(NUX_TRACKER_LOCATION) |
915 | 43 | , search_string("") | 43 | , search_string("") |
916 | 44 | , filters_expanded(false) | 44 | , filters_expanded(false) |
917 | 45 | , fix_renderering_id_(0) | ||
918 | 45 | {} | 46 | {} |
919 | 46 | 47 | ||
920 | 47 | LensView::LensView(Lens::Ptr lens) | 48 | LensView::LensView(Lens::Ptr lens) |
921 | @@ -49,28 +50,27 @@ | |||
922 | 49 | , search_string("") | 50 | , search_string("") |
923 | 50 | , filters_expanded(false) | 51 | , filters_expanded(false) |
924 | 51 | , lens_(lens) | 52 | , lens_(lens) |
925 | 53 | , initial_activation_(true) | ||
926 | 54 | , fix_renderering_id_(0) | ||
927 | 52 | { | 55 | { |
928 | 53 | SetupViews(); | 56 | SetupViews(); |
943 | 54 | 57 | SetupCategories(); | |
944 | 55 | Categories::Ptr categories = lens_->categories; | 58 | SetupResults(); |
945 | 56 | categories->category_added.connect(sigc::mem_fun(this, &LensView::OnCategoryAdded)); | 59 | SetupFilters(); |
946 | 57 | 60 | ||
947 | 58 | Results::Ptr results = lens_->results; | 61 | PlacesStyle::GetDefault()->columns_changed.connect(sigc::mem_fun(this, &LensView::OnColumnsChanged)); |
948 | 59 | results->result_added.connect(sigc::mem_fun(this, &LensView::OnResultAdded)); | 62 | |
949 | 60 | results->result_removed.connect(sigc::mem_fun(this, &LensView::OnResultRemoved)); | 63 | lens_->connected.changed.connect([&](bool is_connected) { if (is_connected) initial_activation_ = true; }); |
936 | 61 | |||
937 | 62 | Filters::Ptr filters = lens_->filters; | ||
938 | 63 | filters->filter_added.connect(sigc::mem_fun(this, &LensView::OnFilterAdded)); | ||
939 | 64 | filters->filter_removed.connect(sigc::mem_fun(this, &LensView::OnFilterRemoved)); | ||
940 | 65 | |||
941 | 66 | PlacesStyle::GetDefault()->columns_changed.connect(sigc::mem_fun(this, &LensView::OnColumnsChanged)); | ||
942 | 67 | |||
950 | 68 | search_string.changed.connect([&](std::string const& search) { lens_->Search(search); }); | 64 | search_string.changed.connect([&](std::string const& search) { lens_->Search(search); }); |
952 | 69 | filters_expanded.changed.connect([&](bool expanded) { fscroll_view_->SetVisible(expanded); ubus_manager_.SendMessage(UBUS_PLACE_VIEW_QUEUE_DRAW); }); | 65 | filters_expanded.changed.connect([&](bool expanded) { fscroll_view_->SetVisible(expanded); QueueRelayout(); }); |
953 | 66 | active.changed.connect(sigc::mem_fun(this, &LensView::OnActiveChanged)); | ||
954 | 70 | } | 67 | } |
955 | 71 | 68 | ||
956 | 72 | LensView::~LensView() | 69 | LensView::~LensView() |
958 | 73 | {} | 70 | { |
959 | 71 | if (fix_renderering_id_) | ||
960 | 72 | g_source_remove(fix_renderering_id_); | ||
961 | 73 | } | ||
962 | 74 | 74 | ||
963 | 75 | void LensView::SetupViews() | 75 | void LensView::SetupViews() |
964 | 76 | { | 76 | { |
965 | @@ -100,6 +100,35 @@ | |||
966 | 100 | SetLayout(layout_); | 100 | SetLayout(layout_); |
967 | 101 | } | 101 | } |
968 | 102 | 102 | ||
969 | 103 | void LensView::SetupCategories() | ||
970 | 104 | { | ||
971 | 105 | Categories::Ptr categories = lens_->categories; | ||
972 | 106 | categories->category_added.connect(sigc::mem_fun(this, &LensView::OnCategoryAdded)); | ||
973 | 107 | |||
974 | 108 | for (unsigned int i = 0; i < categories->count(); ++i) | ||
975 | 109 | OnCategoryAdded(categories->RowAtIndex(i)); | ||
976 | 110 | } | ||
977 | 111 | |||
978 | 112 | void LensView::SetupResults() | ||
979 | 113 | { | ||
980 | 114 | Results::Ptr results = lens_->results; | ||
981 | 115 | results->result_added.connect(sigc::mem_fun(this, &LensView::OnResultAdded)); | ||
982 | 116 | results->result_removed.connect(sigc::mem_fun(this, &LensView::OnResultRemoved)); | ||
983 | 117 | |||
984 | 118 | for (unsigned int i = 0; i < results->count(); ++i) | ||
985 | 119 | OnResultAdded(results->RowAtIndex(i)); | ||
986 | 120 | } | ||
987 | 121 | |||
988 | 122 | void LensView::SetupFilters() | ||
989 | 123 | { | ||
990 | 124 | Filters::Ptr filters = lens_->filters; | ||
991 | 125 | filters->filter_added.connect(sigc::mem_fun(this, &LensView::OnFilterAdded)); | ||
992 | 126 | filters->filter_removed.connect(sigc::mem_fun(this, &LensView::OnFilterRemoved)); | ||
993 | 127 | |||
994 | 128 | for (unsigned int i = 0; i < filters->count(); ++i) | ||
995 | 129 | OnFilterAdded(filters->FilterAtIndex(i)); | ||
996 | 130 | } | ||
997 | 131 | |||
998 | 103 | void LensView::OnCategoryAdded(Category const& category) | 132 | void LensView::OnCategoryAdded(Category const& category) |
999 | 104 | { | 133 | { |
1000 | 105 | std::string name = category.name; | 134 | std::string name = category.name; |
1001 | @@ -128,6 +157,13 @@ | |||
1002 | 128 | group->SetChildView(grid); | 157 | group->SetChildView(grid); |
1003 | 129 | 158 | ||
1004 | 130 | scroll_layout_->AddView(group, 0); | 159 | scroll_layout_->AddView(group, 0); |
1005 | 160 | |||
1006 | 161 | Categories::Ptr categories = lens_->categories; | ||
1007 | 162 | if (category.index + 1 == categories->count()) | ||
1008 | 163 | { | ||
1009 | 164 | lens_->Search("---"); | ||
1010 | 165 | lens_->Search(""); | ||
1011 | 166 | } | ||
1012 | 131 | } | 167 | } |
1013 | 132 | 168 | ||
1014 | 133 | void LensView::OnResultAdded(Result const& result) | 169 | void LensView::OnResultAdded(Result const& result) |
1015 | @@ -162,6 +198,36 @@ | |||
1016 | 162 | 198 | ||
1017 | 163 | group->SetCounts(style->GetDefaultNColumns(), counts_[group]); | 199 | group->SetCounts(style->GetDefaultNColumns(), counts_[group]); |
1018 | 164 | group->SetVisible(counts_[group]); | 200 | group->SetVisible(counts_[group]); |
1019 | 201 | |||
1020 | 202 | QueueFixRenderering(); | ||
1021 | 203 | } | ||
1022 | 204 | |||
1023 | 205 | void LensView::QueueFixRenderering() | ||
1024 | 206 | { | ||
1025 | 207 | if (fix_renderering_id_) | ||
1026 | 208 | return; | ||
1027 | 209 | |||
1028 | 210 | fix_renderering_id_ = g_timeout_add(0, (GSourceFunc)FixRenderering, this); | ||
1029 | 211 | } | ||
1030 | 212 | |||
1031 | 213 | gboolean LensView::FixRenderering(LensView* self) | ||
1032 | 214 | { | ||
1033 | 215 | std::list<Area*> children = self->scroll_layout_->GetChildren(); | ||
1034 | 216 | std::list<Area*>::reverse_iterator rit; | ||
1035 | 217 | bool found_one = false; | ||
1036 | 218 | |||
1037 | 219 | for (rit = children.rbegin(); rit != children.rend(); ++rit) | ||
1038 | 220 | { | ||
1039 | 221 | PlacesGroup* group = static_cast<PlacesGroup*>(*rit); | ||
1040 | 222 | |||
1041 | 223 | if (group->IsVisible()) | ||
1042 | 224 | group->SetDrawSeparator(found_one); | ||
1043 | 225 | |||
1044 | 226 | found_one = group->IsVisible(); | ||
1045 | 227 | } | ||
1046 | 228 | |||
1047 | 229 | self->fix_renderering_id_ = 0; | ||
1048 | 230 | return FALSE; | ||
1049 | 165 | } | 231 | } |
1050 | 166 | 232 | ||
1051 | 167 | void LensView::OnGroupExpanded(PlacesGroup* group) | 233 | void LensView::OnGroupExpanded(PlacesGroup* group) |
1052 | @@ -196,6 +262,18 @@ | |||
1053 | 196 | filter_bar_->RemoveFilter(filter); | 262 | filter_bar_->RemoveFilter(filter); |
1054 | 197 | } | 263 | } |
1055 | 198 | 264 | ||
1056 | 265 | void LensView::OnActiveChanged(bool is_active) | ||
1057 | 266 | { | ||
1058 | 267 | if (is_active && initial_activation_) | ||
1059 | 268 | { | ||
1060 | 269 | /* We reset the lens for ourselves, in case this is a restart or something */ | ||
1061 | 270 | lens_->Search(""); | ||
1062 | 271 | initial_activation_ = false; | ||
1063 | 272 | } | ||
1064 | 273 | |||
1065 | 274 | lens_->active = is_active; | ||
1066 | 275 | } | ||
1067 | 276 | |||
1068 | 199 | long LensView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) | 277 | long LensView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info) |
1069 | 200 | { | 278 | { |
1070 | 201 | return layout_->ProcessEvent(ievent, traverse_info, event_info); | 279 | return layout_->ProcessEvent(ievent, traverse_info, event_info); |
1071 | 202 | 280 | ||
1072 | === modified file 'plugins/unityshell/src/LensView.h' | |||
1073 | --- plugins/unityshell/src/LensView.h 2011-08-11 00:56:53 +0000 | |||
1074 | +++ plugins/unityshell/src/LensView.h 2011-08-24 12:31:11 +0000 | |||
1075 | @@ -54,11 +54,15 @@ | |||
1076 | 54 | 54 | ||
1077 | 55 | nux::Property<std::string> search_string; | 55 | nux::Property<std::string> search_string; |
1078 | 56 | nux::Property<bool> filters_expanded; | 56 | nux::Property<bool> filters_expanded; |
1079 | 57 | nux::Property<bool> active; | ||
1080 | 57 | 58 | ||
1081 | 58 | sigc::signal<void, std::string const&> uri_activated; | 59 | sigc::signal<void, std::string const&> uri_activated; |
1082 | 59 | 60 | ||
1083 | 60 | private: | 61 | private: |
1084 | 61 | void SetupViews(); | 62 | void SetupViews(); |
1085 | 63 | void SetupCategories(); | ||
1086 | 64 | void SetupResults(); | ||
1087 | 65 | void SetupFilters(); | ||
1088 | 62 | 66 | ||
1089 | 63 | void OnCategoryAdded(Category const& category); | 67 | void OnCategoryAdded(Category const& category); |
1090 | 64 | void OnResultAdded(Result const& result); | 68 | void OnResultAdded(Result const& result); |
1091 | @@ -68,6 +72,10 @@ | |||
1092 | 68 | void OnColumnsChanged(); | 72 | void OnColumnsChanged(); |
1093 | 69 | void OnFilterAdded(Filter::Ptr filter); | 73 | void OnFilterAdded(Filter::Ptr filter); |
1094 | 70 | void OnFilterRemoved(Filter::Ptr filter); | 74 | void OnFilterRemoved(Filter::Ptr filter); |
1095 | 75 | void OnActiveChanged(bool is_active); | ||
1096 | 76 | void QueueFixRenderering(); | ||
1097 | 77 | |||
1098 | 78 | static gboolean FixRenderering(LensView* self); | ||
1099 | 71 | 79 | ||
1100 | 72 | virtual long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); | 80 | virtual long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info); |
1101 | 73 | virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); | 81 | virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); |
1102 | @@ -82,6 +90,7 @@ | |||
1103 | 82 | Lens::Ptr lens_; | 90 | Lens::Ptr lens_; |
1104 | 83 | CategoryGroups categories_; | 91 | CategoryGroups categories_; |
1105 | 84 | ResultCounts counts_; | 92 | ResultCounts counts_; |
1106 | 93 | bool initial_activation_; | ||
1107 | 85 | 94 | ||
1108 | 86 | nux::HLayout* layout_; | 95 | nux::HLayout* layout_; |
1109 | 87 | nux::ScrollView* scroll_view_; | 96 | nux::ScrollView* scroll_view_; |
1110 | @@ -89,6 +98,8 @@ | |||
1111 | 89 | nux::ScrollView* fscroll_view_; | 98 | nux::ScrollView* fscroll_view_; |
1112 | 90 | nux::VLayout* fscroll_layout_; | 99 | nux::VLayout* fscroll_layout_; |
1113 | 91 | FilterBar* filter_bar_; | 100 | FilterBar* filter_bar_; |
1114 | 101 | |||
1115 | 102 | guint fix_renderering_id_; | ||
1116 | 92 | }; | 103 | }; |
1117 | 93 | 104 | ||
1118 | 94 | 105 | ||
1119 | 95 | 106 | ||
1120 | === modified file 'plugins/unityshell/src/PlacesGroup.cpp' | |||
1121 | --- plugins/unityshell/src/PlacesGroup.cpp 2011-08-19 15:17:30 +0000 | |||
1122 | +++ plugins/unityshell/src/PlacesGroup.cpp 2011-08-24 12:31:11 +0000 | |||
1123 | @@ -144,7 +144,7 @@ | |||
1124 | 144 | { | 144 | { |
1125 | 145 | // Spaces are on purpose, want padding to be proportional to the size of the text | 145 | // Spaces are on purpose, want padding to be proportional to the size of the text |
1126 | 146 | // Bear with me, I'm trying something different :) | 146 | // Bear with me, I'm trying something different :) |
1128 | 147 | const gchar* temp = " <big>%s</big> "; | 147 | const gchar* temp = " <span font_size='larger'>%s</span> "; |
1129 | 148 | gchar* tmp = NULL; | 148 | gchar* tmp = NULL; |
1130 | 149 | gchar* final = NULL; | 149 | gchar* final = NULL; |
1131 | 150 | if (_cached_name != NULL) | 150 | if (_cached_name != NULL) |
1132 | 151 | 151 | ||
1133 | === modified file 'plugins/unityshell/src/PlacesStyle.cpp' | |||
1134 | --- plugins/unityshell/src/PlacesStyle.cpp 2011-08-09 17:27:39 +0000 | |||
1135 | +++ plugins/unityshell/src/PlacesStyle.cpp 2011-08-24 12:31:11 +0000 | |||
1136 | @@ -143,6 +143,10 @@ | |||
1137 | 143 | return GetHomeTileIconSize() + (_text_height * 4); | 143 | return GetHomeTileIconSize() + (_text_height * 4); |
1138 | 144 | } | 144 | } |
1139 | 145 | 145 | ||
1140 | 146 | int PlacesStyle::GetTextLineHeight() | ||
1141 | 147 | { | ||
1142 | 148 | return _text_height; | ||
1143 | 149 | } | ||
1144 | 146 | 150 | ||
1145 | 147 | nux::BaseTexture* PlacesStyle::GetDashBottomTile() | 151 | nux::BaseTexture* PlacesStyle::GetDashBottomTile() |
1146 | 148 | { | 152 | { |
1147 | 149 | 153 | ||
1148 | === modified file 'plugins/unityshell/src/PlacesStyle.h' | |||
1149 | --- plugins/unityshell/src/PlacesStyle.h 2011-08-09 17:27:39 +0000 | |||
1150 | +++ plugins/unityshell/src/PlacesStyle.h 2011-08-24 12:31:11 +0000 | |||
1151 | @@ -45,6 +45,8 @@ | |||
1152 | 45 | int GetHomeTileWidth(); | 45 | int GetHomeTileWidth(); |
1153 | 46 | int GetHomeTileHeight(); | 46 | int GetHomeTileHeight(); |
1154 | 47 | 47 | ||
1155 | 48 | int GetTextLineHeight(); | ||
1156 | 49 | |||
1157 | 48 | nux::BaseTexture* GetDashBottomTile(); | 50 | nux::BaseTexture* GetDashBottomTile(); |
1158 | 49 | nux::BaseTexture* GetDashRightTile(); | 51 | nux::BaseTexture* GetDashRightTile(); |
1159 | 50 | nux::BaseTexture* GetDashCorner(); | 52 | nux::BaseTexture* GetDashCorner(); |
1160 | 51 | 53 | ||
1161 | === modified file 'plugins/unityshell/src/ResultRendererTile.cpp' | |||
1162 | --- plugins/unityshell/src/ResultRendererTile.cpp 2011-08-18 09:14:53 +0000 | |||
1163 | +++ plugins/unityshell/src/ResultRendererTile.cpp 2011-08-24 12:31:11 +0000 | |||
1164 | @@ -27,6 +27,8 @@ | |||
1165 | 27 | #include <gdk/gdk.h> | 27 | #include <gdk/gdk.h> |
1166 | 28 | #include <gtk/gtk.h> | 28 | #include <gtk/gtk.h> |
1167 | 29 | 29 | ||
1168 | 30 | #include <UnityCore/GLibWrapper.h> | ||
1169 | 31 | |||
1170 | 30 | #include "IconLoader.h" | 32 | #include "IconLoader.h" |
1171 | 31 | #include "IconTexture.h" | 33 | #include "IconTexture.h" |
1172 | 32 | #include "PlacesStyle.h" | 34 | #include "PlacesStyle.h" |
1173 | @@ -410,26 +412,34 @@ | |||
1174 | 410 | 412 | ||
1175 | 411 | PangoLayout* layout = NULL; | 413 | PangoLayout* layout = NULL; |
1176 | 412 | PangoFontDescription* desc = NULL; | 414 | PangoFontDescription* desc = NULL; |
1178 | 413 | PangoContext* pangoCtx = NULL; | 415 | PangoContext* pango_context = NULL; |
1179 | 414 | GdkScreen* screen = gdk_screen_get_default(); // not ref'ed | 416 | GdkScreen* screen = gdk_screen_get_default(); // not ref'ed |
1181 | 415 | 417 | glib::String font; | |
1182 | 418 | int dpi = -1; | ||
1183 | 419 | |||
1184 | 420 | g_object_get(gtk_settings_get_default(), "gtk-font-name", &font, NULL); | ||
1185 | 421 | g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, NULL); | ||
1186 | 416 | 422 | ||
1187 | 417 | cairo_set_font_options(cr, gdk_screen_get_font_options(screen)); | 423 | cairo_set_font_options(cr, gdk_screen_get_font_options(screen)); |
1188 | 418 | layout = pango_cairo_create_layout(cr); | 424 | layout = pango_cairo_create_layout(cr); |
1190 | 419 | desc = pango_font_description_from_string("Ubuntu 10"); | 425 | desc = pango_font_description_from_string(font.Value()); |
1191 | 420 | 426 | ||
1192 | 421 | pango_layout_set_font_description(layout, desc); | 427 | pango_layout_set_font_description(layout, desc); |
1193 | 422 | |||
1194 | 423 | pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); | 428 | pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); |
1195 | 429 | |||
1196 | 430 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); | ||
1197 | 431 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START); | ||
1198 | 432 | pango_layout_set_width(layout, (style->GetTileWidth() - 12)* PANGO_SCALE); | ||
1199 | 433 | pango_layout_set_height(layout, -2); | ||
1200 | 434 | |||
1201 | 424 | pango_layout_set_markup(layout, text.c_str(), -1); | 435 | pango_layout_set_markup(layout, text.c_str(), -1); |
1207 | 425 | pango_layout_set_width(layout, (style->GetTileWidth() - 12)* PANGO_SCALE); | 436 | |
1208 | 426 | 437 | pango_context = pango_layout_get_context(layout); // is not ref'ed | |
1209 | 427 | pango_layout_set_height(layout, 2); | 438 | pango_cairo_context_set_font_options(pango_context, |
1205 | 428 | pangoCtx = pango_layout_get_context(layout); // is not ref'ed | ||
1206 | 429 | pango_cairo_context_set_font_options(pangoCtx, | ||
1210 | 430 | gdk_screen_get_font_options(screen)); | 439 | gdk_screen_get_font_options(screen)); |
1213 | 431 | // use some default DPI-value | 440 | pango_cairo_context_set_resolution(pango_context, |
1214 | 432 | pango_cairo_context_set_resolution(pangoCtx, 96.0f); | 441 | dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE); |
1215 | 442 | pango_layout_context_changed(layout); | ||
1216 | 433 | 443 | ||
1217 | 434 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); | 444 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); |
1218 | 435 | cairo_paint(cr); | 445 | cairo_paint(cr); |
1219 | @@ -437,8 +447,6 @@ | |||
1220 | 437 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | 447 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1221 | 438 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); | 448 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); |
1222 | 439 | 449 | ||
1223 | 440 | pango_layout_context_changed(layout); | ||
1224 | 441 | |||
1225 | 442 | cairo_move_to(cr, 0.0f, 0.0f); | 450 | cairo_move_to(cr, 0.0f, 0.0f); |
1226 | 443 | pango_cairo_show_layout(cr, layout); | 451 | pango_cairo_show_layout(cr, layout); |
1227 | 444 | 452 | ||
1228 | 445 | 453 | ||
1229 | === modified file 'plugins/unityshell/src/StaticCairoText.cpp' | |||
1230 | --- plugins/unityshell/src/StaticCairoText.cpp 2011-08-05 15:17:12 +0000 | |||
1231 | +++ plugins/unityshell/src/StaticCairoText.cpp 2011-08-24 12:31:11 +0000 | |||
1232 | @@ -320,6 +320,7 @@ | |||
1233 | 320 | surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1, 1); | 320 | surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1, 1); |
1234 | 321 | cr = cairo_create(surface); | 321 | cr = cairo_create(surface); |
1235 | 322 | cairo_set_font_options(cr, gdk_screen_get_font_options(screen)); | 322 | cairo_set_font_options(cr, gdk_screen_get_font_options(screen)); |
1236 | 323 | |||
1237 | 323 | layout = pango_cairo_create_layout(cr); | 324 | layout = pango_cairo_create_layout(cr); |
1238 | 324 | desc = pango_font_description_from_string(font); | 325 | desc = pango_font_description_from_string(font); |
1239 | 325 | pango_layout_set_font_description(layout, desc); | 326 | pango_layout_set_font_description(layout, desc); |
1240 | 326 | 327 | ||
1241 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
1242 | --- plugins/unityshell/src/unityshell.cpp 2011-08-24 02:25:07 +0000 | |||
1243 | +++ plugins/unityshell/src/unityshell.cpp 2011-08-24 12:31:11 +0000 | |||
1244 | @@ -1371,6 +1371,7 @@ | |||
1245 | 1371 | gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect); | 1371 | gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect); |
1246 | 1372 | _primary_monitor = rect; | 1372 | _primary_monitor = rect; |
1247 | 1373 | 1373 | ||
1248 | 1374 | |||
1249 | 1374 | wt->SetWindowSize(rect.width, rect.height); | 1375 | wt->SetWindowSize(rect.width, rect.height); |
1250 | 1375 | 1376 | ||
1251 | 1376 | lCurGeom = launcherWindow->GetGeometry(); | 1377 | lCurGeom = launcherWindow->GetGeometry(); |
1252 | 1377 | 1378 | ||
1253 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
1254 | --- plugins/unityshell/src/unityshell.h 2011-08-22 03:06:14 +0000 | |||
1255 | +++ plugins/unityshell/src/unityshell.h 2011-08-24 12:31:11 +0000 | |||
1256 | @@ -31,6 +31,7 @@ | |||
1257 | 31 | 31 | ||
1258 | 32 | #include "Introspectable.h" | 32 | #include "Introspectable.h" |
1259 | 33 | #include "DashController.h" | 33 | #include "DashController.h" |
1260 | 34 | #include "FontSettings.h" | ||
1261 | 34 | #include "Launcher.h" | 35 | #include "Launcher.h" |
1262 | 35 | #include "LauncherController.h" | 36 | #include "LauncherController.h" |
1263 | 36 | #include "PanelController.h" | 37 | #include "PanelController.h" |
1264 | @@ -77,6 +78,7 @@ | |||
1265 | 77 | 78 | ||
1266 | 78 | #include <compiztoolbox/compiztoolbox.h> | 79 | #include <compiztoolbox/compiztoolbox.h> |
1267 | 79 | 80 | ||
1268 | 81 | using unity::FontSettings; | ||
1269 | 80 | using namespace unity::switcher; | 82 | using namespace unity::switcher; |
1270 | 81 | using namespace unity::dash; | 83 | using namespace unity::dash; |
1271 | 82 | using unity::UBusManager; | 84 | using unity::UBusManager; |
1272 | @@ -208,6 +210,7 @@ | |||
1273 | 208 | static void OnLauncherStartKeyNav(GVariant* data, void* value); | 210 | static void OnLauncherStartKeyNav(GVariant* data, void* value); |
1274 | 209 | static void OnLauncherEndKeyNav(GVariant* data, void* value); | 211 | static void OnLauncherEndKeyNav(GVariant* data, void* value); |
1275 | 210 | 212 | ||
1276 | 213 | FontSettings font_settings_; | ||
1277 | 211 | Launcher* launcher; | 214 | Launcher* launcher; |
1278 | 212 | LauncherController* controller; | 215 | LauncherController* controller; |
1279 | 213 | DashController::Ptr dashController; | 216 | DashController::Ptr dashController; |
1280 | 214 | 217 | ||
1281 | === modified file 'tests/CMakeLists.txt' | |||
1282 | --- tests/CMakeLists.txt 2011-08-16 11:34:48 +0000 | |||
1283 | +++ tests/CMakeLists.txt 2011-08-24 12:31:11 +0000 | |||
1284 | @@ -95,6 +95,8 @@ | |||
1285 | 95 | ${UNITY_SRC}/FilterGenreButton.cpp | 95 | ${UNITY_SRC}/FilterGenreButton.cpp |
1286 | 96 | ${UNITY_SRC}/FilterGenreWidget.cpp | 96 | ${UNITY_SRC}/FilterGenreWidget.cpp |
1287 | 97 | ${UNITY_SRC}/FilterBar.cpp | 97 | ${UNITY_SRC}/FilterBar.cpp |
1288 | 98 | ${UNITY_SRC}/FontSettings.cpp | ||
1289 | 99 | ${UNITY_SRC}/FontSettings.h | ||
1290 | 98 | ${UNITY_SRC}/IMTextEntry.cpp | 100 | ${UNITY_SRC}/IMTextEntry.cpp |
1291 | 99 | ${UNITY_SRC}/IMTextEntry.h | 101 | ${UNITY_SRC}/IMTextEntry.h |
1292 | 100 | ${UNITY_SRC}/PlacesHomeView.cpp | 102 | ${UNITY_SRC}/PlacesHomeView.cpp |
1293 | @@ -122,6 +124,8 @@ | |||
1294 | 122 | ${UNITY_SRC}/Introspectable.h | 124 | ${UNITY_SRC}/Introspectable.h |
1295 | 123 | ${UNITY_SRC}/LensBar.cpp | 125 | ${UNITY_SRC}/LensBar.cpp |
1296 | 124 | ${UNITY_SRC}/LensBar.h | 126 | ${UNITY_SRC}/LensBar.h |
1297 | 127 | ${UNITY_SRC}/LensBarIcon.cpp | ||
1298 | 128 | ${UNITY_SRC}/LensBarIcon.h | ||
1299 | 125 | ${UNITY_SRC}/LensView.cpp | 129 | ${UNITY_SRC}/LensView.cpp |
1300 | 126 | ${UNITY_SRC}/LensView.h | 130 | ${UNITY_SRC}/LensView.h |
1301 | 127 | ${UNITY_SRC}/PreviewApplications.cpp | 131 | ${UNITY_SRC}/PreviewApplications.cpp |
1302 | @@ -270,6 +274,8 @@ | |||
1303 | 270 | ${UNITY_SRC}/FilterMultiRangeButton.cpp | 274 | ${UNITY_SRC}/FilterMultiRangeButton.cpp |
1304 | 271 | ${UNITY_SRC}/FilterMultiRangeWidget.cpp | 275 | ${UNITY_SRC}/FilterMultiRangeWidget.cpp |
1305 | 272 | ${UNITY_SRC}/DashStyle.cpp | 276 | ${UNITY_SRC}/DashStyle.cpp |
1306 | 277 | ${UNITY_SRC}/PlacesStyle.cpp | ||
1307 | 278 | ${UNITY_SRC}/PlacesStyle.h | ||
1308 | 273 | ) | 279 | ) |
1309 | 274 | add_dependencies(test-filters unity-core-${UNITY_API_VERSION}) | 280 | add_dependencies(test-filters unity-core-${UNITY_API_VERSION}) |
1310 | 275 | 281 | ||
1311 | @@ -286,6 +292,8 @@ | |||
1312 | 286 | ${UNITY_SRC}/FilterGenreWidget.cpp | 292 | ${UNITY_SRC}/FilterGenreWidget.cpp |
1313 | 287 | ${UNITY_SRC}/FilterBar.cpp | 293 | ${UNITY_SRC}/FilterBar.cpp |
1314 | 288 | ${UNITY_SRC}/DashStyle.cpp | 294 | ${UNITY_SRC}/DashStyle.cpp |
1315 | 295 | ${UNITY_SRC}/PlacesStyle.cpp | ||
1316 | 296 | ${UNITY_SRC}/PlacesStyle.h | ||
1317 | 289 | ) | 297 | ) |
1318 | 290 | add_dependencies(test-filter-bar unity-core-${UNITY_API_VERSION}) | 298 | add_dependencies(test-filter-bar unity-core-${UNITY_API_VERSION}) |
1319 | 291 | 299 | ||
1320 | 292 | 300 | ||
1321 | === modified file 'tests/standalone_dash.cpp' | |||
1322 | --- tests/standalone_dash.cpp 2011-08-22 13:48:47 +0000 | |||
1323 | +++ tests/standalone_dash.cpp 2011-08-24 12:31:11 +0000 | |||
1324 | @@ -27,6 +27,7 @@ | |||
1325 | 27 | #include <NuxCore/Logger.h> | 27 | #include <NuxCore/Logger.h> |
1326 | 28 | 28 | ||
1327 | 29 | #include "BGHash.h" | 29 | #include "BGHash.h" |
1328 | 30 | #include "FontSettings.h" | ||
1329 | 30 | #include "DashView.h" | 31 | #include "DashView.h" |
1330 | 31 | #include "PlacesSettings.h" | 32 | #include "PlacesSettings.h" |
1331 | 32 | 33 | ||
1332 | @@ -91,6 +92,7 @@ | |||
1333 | 91 | gtk_init (&argc, &argv); | 92 | gtk_init (&argc, &argv); |
1334 | 92 | 93 | ||
1335 | 93 | unity::BGHash bghash; | 94 | unity::BGHash bghash; |
1336 | 95 | unity::FontSettings font_settings; | ||
1337 | 94 | 96 | ||
1338 | 95 | nux::NuxInitialize(0); | 97 | nux::NuxInitialize(0); |
1339 | 96 | nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); | 98 | nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); |