Merge lp:~unity-team/unity/dash-fixes-2011-03-14 into lp:unity
- dash-fixes-2011-03-14
- 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: | 961 | ||||||||||||||||||||
Proposed branch: | lp:~unity-team/unity/dash-fixes-2011-03-14 | ||||||||||||||||||||
Merge into: | lp:unity | ||||||||||||||||||||
Diff against target: |
1219 lines (+418/-62) 22 files modified
com.canonical.Unity.gschema.xml (+10/-0) src/IconTexture.cpp (+41/-4) src/IconTexture.h (+6/-0) src/PanelMenuView.cpp (+31/-3) src/PanelMenuView.h (+4/-0) src/PlaceLauncherIcon.cpp (+1/-1) src/PlacesController.cpp (+7/-5) src/PlacesGroup.cpp (+52/-13) src/PlacesGroup.h (+6/-1) src/PlacesGroupController.cpp (+6/-0) src/PlacesGroupController.h (+2/-0) src/PlacesHomeView.cpp (+14/-10) src/PlacesResultsController.cpp (+36/-3) src/PlacesResultsController.h (+3/-0) src/PlacesResultsView.cpp (+4/-2) src/PlacesSearchBar.cpp (+15/-6) src/PlacesSearchBar.h (+1/-0) src/PlacesSettings.cpp (+13/-0) src/PlacesSettings.h (+3/-0) src/PlacesView.cpp (+139/-11) src/PlacesView.h (+21/-1) tests/TestPlaces.cpp (+3/-2) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~unity-team/unity/dash-fixes-2011-03-14 | ||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gord Allott | Pending | ||
Review via email: mp+53589@code.launchpad.net |
Commit message
Description of the change
Bugs linked, also adds resizing dash and other fixes
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 'com.canonical.Unity.gschema.xml' |
2 | --- com.canonical.Unity.gschema.xml 2011-03-07 15:25:13 +0000 |
3 | +++ com.canonical.Unity.gschema.xml 2011-03-16 09:38:19 +0000 |
4 | @@ -5,12 +5,22 @@ |
5 | <value nick="Netbook" value="2" /> |
6 | </enum> |
7 | |
8 | + <enum id="home-expanded-enum"> |
9 | + <value nick="Not Expanded" value="0" /> |
10 | + <value nick="Expanded" value="1" /> |
11 | + </enum> |
12 | + |
13 | <schema path="/desktop/unity/" id="com.canonical.Unity" gettext-domain="unity"> |
14 | <key enum="form-factor-enum" name="form-factor"> |
15 | <default>"Automatic"</default> |
16 | <summary>The form factor Unity should target.</summary> |
17 | <description>The form factor chosen will affect the size and appearance of the Dash, Launcher and also the Window Management behaviour.</description> |
18 | </key> |
19 | + <key enum="home-expanded-enum" name="home-expanded"> |
20 | + <default>"Expanded"</default> |
21 | + <summary>Whether the home screen should be expanded.</summary> |
22 | + <description>Whether the home screen should be expanded.</description> |
23 | + </key> |
24 | </schema> |
25 | <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> |
26 | <key type="as" name="favorites"> |
27 | |
28 | === modified file 'src/IconTexture.cpp' |
29 | --- src/IconTexture.cpp 2011-03-10 13:03:21 +0000 |
30 | +++ src/IconTexture.cpp 2011-03-16 09:38:19 +0000 |
31 | @@ -31,6 +31,23 @@ |
32 | |
33 | #define DEFAULT_ICON "text-x-preview" |
34 | |
35 | +IconTexture::IconTexture (nux::BaseTexture *texture, guint width, guint height) |
36 | +: TextureArea (NUX_TRACKER_LOCATION), |
37 | + _icon_name (NULL), |
38 | + _size (height), |
39 | + _texture_cached (texture), |
40 | + _texture_width (width), |
41 | + _texture_height (height), |
42 | + _loading (false), |
43 | + _opacity (1.0f) |
44 | +{ |
45 | + _texture_cached->Reference (); |
46 | + |
47 | + SetMinMaxSize (width, height); |
48 | + SetCanFocus (false); |
49 | + _can_pass_focus_to_composite_layout = false; |
50 | +} |
51 | + |
52 | IconTexture::IconTexture (const char *icon_name, unsigned int size, bool defer_icon_loading) |
53 | : TextureArea (NUX_TRACKER_LOCATION), |
54 | _icon_name (NULL), |
55 | @@ -38,7 +55,8 @@ |
56 | _texture_cached (NULL), |
57 | _texture_width (0), |
58 | _texture_height (0), |
59 | - _loading (false) |
60 | + _loading (false), |
61 | + _opacity (1.0f) |
62 | { |
63 | _icon_name = g_strdup (icon_name ? icon_name : DEFAULT_ICON); |
64 | |
65 | @@ -79,17 +97,18 @@ |
66 | void |
67 | IconTexture::LoadIcon () |
68 | { |
69 | +#define DEFAULT_GICON ". GThemedIcon text-x-preview" |
70 | GIcon *icon; |
71 | |
72 | if (_loading) |
73 | return; |
74 | _loading = true; |
75 | |
76 | - icon = g_icon_new_for_string (_icon_name, NULL); |
77 | + icon = g_icon_new_for_string (_icon_name ? _icon_name : DEFAULT_GICON, NULL); |
78 | |
79 | if (G_IS_ICON (icon)) |
80 | { |
81 | - IconLoader::GetDefault ()->LoadFromGIconString (_icon_name, |
82 | + IconLoader::GetDefault ()->LoadFromGIconString (_icon_name ? _icon_name : DEFAULT_GICON, |
83 | _size, |
84 | sigc::mem_fun (this, &IconTexture::IconLoaded)); |
85 | g_object_unref (icon); |
86 | @@ -162,6 +181,7 @@ |
87 | |
88 | if (_texture_cached) |
89 | { |
90 | + nux::Color col (1.0f * _opacity, 1.0f * _opacity, 1.0f * _opacity, _opacity); |
91 | nux::TexCoordXForm texxform; |
92 | texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD); |
93 | texxform.SetWrap (nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); |
94 | @@ -172,7 +192,7 @@ |
95 | _texture_height, |
96 | _texture_cached->GetDeviceTexture (), |
97 | texxform, |
98 | - nux::Color::White); |
99 | + col); |
100 | } |
101 | |
102 | GfxContext.PopClippingRectangle (); |
103 | @@ -187,6 +207,23 @@ |
104 | *height = _texture_height; |
105 | } |
106 | |
107 | +void |
108 | +IconTexture::SetOpacity (float opacity) |
109 | +{ |
110 | + _opacity = opacity; |
111 | + |
112 | + QueueDraw (); |
113 | +} |
114 | + |
115 | +void |
116 | +IconTexture::SetTexture (nux::BaseTexture *texture) |
117 | +{ |
118 | + if (_texture_cached) |
119 | + _texture_cached->UnReference (); |
120 | + _texture_cached = texture; |
121 | + _texture_cached->Reference (); |
122 | +} |
123 | + |
124 | bool |
125 | IconTexture::DoCanFocus () |
126 | { |
127 | |
128 | === modified file 'src/IconTexture.h' |
129 | --- src/IconTexture.h 2011-03-09 11:18:33 +0000 |
130 | +++ src/IconTexture.h 2011-03-16 09:38:19 +0000 |
131 | @@ -30,6 +30,7 @@ |
132 | class IconTexture : public nux::TextureArea, public Introspectable |
133 | { |
134 | public: |
135 | + IconTexture (nux::BaseTexture *texture, guint width, guint height); |
136 | IconTexture (const char *icon_name, unsigned int size, bool defer_icon_loading=false); |
137 | ~IconTexture (); |
138 | |
139 | @@ -39,6 +40,9 @@ |
140 | |
141 | void LoadIcon (); |
142 | |
143 | + void SetOpacity (float opacity); |
144 | + void SetTexture (nux::BaseTexture *texture); |
145 | + |
146 | protected: |
147 | const gchar* GetName (); |
148 | void AddProperties (GVariantBuilder *builder); |
149 | @@ -60,6 +64,8 @@ |
150 | int _texture_height; |
151 | |
152 | bool _loading; |
153 | + |
154 | + float _opacity; |
155 | }; |
156 | |
157 | #endif // ICON_TEXTURE_H |
158 | |
159 | === modified file 'src/PanelMenuView.cpp' |
160 | --- src/PanelMenuView.cpp 2011-03-10 13:39:09 +0000 |
161 | +++ src/PanelMenuView.cpp 2011-03-16 09:38:19 +0000 |
162 | @@ -38,6 +38,9 @@ |
163 | |
164 | #include <gio/gdesktopappinfo.h> |
165 | |
166 | +#include "ubus-server.h" |
167 | +#include "UBusMessages.h" |
168 | + |
169 | #define BUTTONS_WIDTH 72 |
170 | |
171 | static void on_active_window_changed (BamfMatcher *matcher, |
172 | @@ -61,7 +64,8 @@ |
173 | _is_own_window (false), |
174 | _last_active_view (NULL), |
175 | _last_width (0), |
176 | - _last_height (0) |
177 | + _last_height (0), |
178 | + _places_showing (false) |
179 | { |
180 | WindowManager *win_manager; |
181 | |
182 | @@ -106,6 +110,15 @@ |
183 | |
184 | PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &PanelMenuView::Refresh)); |
185 | |
186 | + // Register for all the interesting events |
187 | + UBusServer *ubus = ubus_server_get_default (); |
188 | + ubus_server_register_interest (ubus, UBUS_PLACE_VIEW_SHOWN, |
189 | + (UBusCallback)PanelMenuView::OnPlaceViewShown, |
190 | + this); |
191 | + ubus_server_register_interest (ubus, UBUS_PLACE_VIEW_HIDDEN, |
192 | + (UBusCallback)PanelMenuView::OnPlaceViewHidden, |
193 | + this); |
194 | + |
195 | Refresh (); |
196 | } |
197 | |
198 | @@ -236,7 +249,7 @@ |
199 | nux::ColorLayer layer (nux::Color (0x00000000), true, rop); |
200 | gPainter.PushDrawLayer (GfxContext, GetGeometry (), &layer); |
201 | |
202 | - if (_is_own_window) |
203 | + if (_is_own_window || _places_showing) |
204 | { |
205 | |
206 | } |
207 | @@ -334,7 +347,7 @@ |
208 | |
209 | GfxContext.PushClippingRectangle (geo); |
210 | |
211 | - if (!_is_own_window) |
212 | + if (!_is_own_window && !_places_showing) |
213 | { |
214 | if (_is_inside || _last_active_view) |
215 | { |
216 | @@ -886,3 +899,18 @@ |
217 | { |
218 | self->OnNameChanged (new_name, old_name); |
219 | } |
220 | + |
221 | +void |
222 | +PanelMenuView::OnPlaceViewShown (GVariant *data, PanelMenuView *self) |
223 | +{ |
224 | + self->_places_showing = true; |
225 | + self->QueueDraw (); |
226 | +} |
227 | + |
228 | +void |
229 | +PanelMenuView::OnPlaceViewHidden (GVariant *data, PanelMenuView *self) |
230 | +{ |
231 | + self->_places_showing = false; |
232 | + self->QueueDraw (); |
233 | +} |
234 | + |
235 | |
236 | === modified file 'src/PanelMenuView.h' |
237 | --- src/PanelMenuView.h 2011-03-07 10:59:31 +0000 |
238 | +++ src/PanelMenuView.h 2011-03-16 09:38:19 +0000 |
239 | @@ -93,6 +93,8 @@ |
240 | |
241 | private: |
242 | gchar * GetActiveViewName (); |
243 | + static void OnPlaceViewShown (GVariant *data, PanelMenuView *self); |
244 | + static void OnPlaceViewHidden (GVariant *data, PanelMenuView *self); |
245 | |
246 | private: |
247 | BamfMatcher* _matcher; |
248 | @@ -119,5 +121,7 @@ |
249 | |
250 | int _last_width; |
251 | int _last_height; |
252 | + |
253 | + bool _places_showing; |
254 | }; |
255 | #endif |
256 | |
257 | === modified file 'src/PlaceLauncherIcon.cpp' |
258 | --- src/PlaceLauncherIcon.cpp 2011-03-09 17:25:03 +0000 |
259 | +++ src/PlaceLauncherIcon.cpp 2011-03-16 09:38:19 +0000 |
260 | @@ -97,7 +97,7 @@ |
261 | |
262 | temp = g_markup_escape_text (section.GetName (), -1); |
263 | menu_item = dbusmenu_menuitem_new (); |
264 | - dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, section.GetName ()); |
265 | + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, temp); |
266 | dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
267 | dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
268 | dbusmenu_menuitem_property_set_int (menu_item, SECTION_NUMBER, _current_menu.size ()); |
269 | |
270 | === modified file 'src/PlacesController.cpp' |
271 | --- src/PlacesController.cpp 2011-03-10 13:15:55 +0000 |
272 | +++ src/PlacesController.cpp 2011-03-16 09:38:19 +0000 |
273 | @@ -32,6 +32,8 @@ |
274 | |
275 | #include "PlacesController.h" |
276 | |
277 | +#define PANEL_HEIGHT 24 |
278 | + |
279 | int PlacesController::_launcher_size = 66; |
280 | |
281 | PlacesController::PlacesController () |
282 | @@ -102,7 +104,7 @@ |
283 | |
284 | self->GetWindowSize (&width, &height); |
285 | self->_window->SetGeometry (nux::Geometry (self->_monitor_rect.x + _launcher_size, |
286 | - self->_monitor_rect.y + 24, |
287 | + self->_monitor_rect.y + PANEL_HEIGHT, |
288 | width, |
289 | height)); |
290 | } |
291 | @@ -234,7 +236,7 @@ |
292 | else |
293 | { |
294 | width = rect.width - _launcher_size; |
295 | - height = rect.height - 24; |
296 | + height = rect.height - PANEL_HEIGHT; |
297 | |
298 | _view->SetSizeMode (PlacesView::SIZE_MODE_FULLSCREEN); |
299 | style->SetDefaultNColumns (width / tile_width); |
300 | @@ -253,7 +255,7 @@ |
301 | |
302 | self->GetWindowSize (&width, &height); |
303 | geo = nux::Geometry (self->_monitor_rect.x + self->_launcher_size, |
304 | - self->_monitor_rect.y + 24, |
305 | + self->_monitor_rect.y + PANEL_HEIGHT, |
306 | width, |
307 | height); |
308 | } |
309 | @@ -265,7 +267,7 @@ |
310 | _fullscren_request = true; |
311 | GetWindowSize (&width, &height); |
312 | _window->SetGeometry (nux::Geometry (_monitor_rect.x + _launcher_size, |
313 | - _monitor_rect.y + 24, |
314 | + _monitor_rect.y + PANEL_HEIGHT, |
315 | width, |
316 | height)); |
317 | } |
318 | @@ -287,7 +289,7 @@ |
319 | void |
320 | PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags) |
321 | { |
322 | - nux::Geometry geo (_monitor_rect.x, _monitor_rect.y, _launcher_size, 24); |
323 | + nux::Geometry geo (_monitor_rect.x, _monitor_rect.y, _launcher_size, PANEL_HEIGHT); |
324 | if (!geo.IsPointInside (x, y)) |
325 | Hide (); |
326 | } |
327 | |
328 | === modified file 'src/PlacesGroup.cpp' |
329 | --- src/PlacesGroup.cpp 2011-03-10 13:03:21 +0000 |
330 | +++ src/PlacesGroup.cpp 2011-03-16 09:38:19 +0000 |
331 | @@ -46,6 +46,8 @@ |
332 | |
333 | static const nux::Color kExpandDefaultTextColor (1.0f, 1.0f, 1.0f, 0.6f); |
334 | static const nux::Color kExpandHoverTextColor (1.0f, 1.0f, 1.0f, 1.0f); |
335 | +static const float kExpandDefaultIconOpacity = 0.6f; |
336 | +static const float kExpandHoverIconOpacity = 1.0f; |
337 | |
338 | |
339 | PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL) |
340 | @@ -54,13 +56,15 @@ |
341 | _idle_id (0), |
342 | _is_expanded (true), |
343 | _n_visible_items_in_unexpand_mode (0), |
344 | - _n_total_items (0) |
345 | + _n_total_items (0), |
346 | + _draw_sep (true) |
347 | { |
348 | PlacesStyle *style = PlacesStyle::GetDefault (); |
349 | nux::BaseTexture *arrow = style->GetGroupUnexpandIcon (); |
350 | |
351 | _cached_name = NULL; |
352 | _group_layout = new nux::VLayout ("", NUX_TRACKER_LOCATION); |
353 | + _group_layout->SetVerticalExternalMargin (12); |
354 | |
355 | _header_layout = new nux::HLayout (NUX_TRACKER_LOCATION); |
356 | _group_layout->AddLayout (_header_layout, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL); |
357 | @@ -81,14 +85,12 @@ |
358 | _expand_label->SetCanFocus (true); |
359 | _expand_label->FocusActivated.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelActivated)); |
360 | _expand_label->FocusChanged.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelFocusChanged)); |
361 | - |
362 | - |
363 | + |
364 | _header_layout->AddView (_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); |
365 | |
366 | - _expand_icon = new nux::TextureArea (); |
367 | - _expand_icon->SetTexture (arrow); |
368 | + _expand_icon = new IconTexture (arrow, arrow->GetWidth (), arrow->GetHeight ()); |
369 | + _expand_icon->SetOpacity (kExpandDefaultIconOpacity); |
370 | _expand_icon->SetMinimumSize (arrow->GetWidth (), arrow->GetHeight ()); |
371 | - _expand_icon->SetCanFocus (false); |
372 | _header_layout->AddView (_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); |
373 | |
374 | SetLayout (_group_layout); |
375 | @@ -122,7 +124,16 @@ |
376 | void |
377 | PlacesGroup::OnLabelFocusChanged (nux::Area *label) |
378 | { |
379 | - RefreshLabel (); |
380 | + if (_expand_label->GetFocused ()) |
381 | + { |
382 | + _expand_label->SetTextColor (kExpandHoverTextColor); |
383 | + _expand_icon->SetOpacity (kExpandHoverIconOpacity); |
384 | + } |
385 | + else if (!IsMouseInside ()) |
386 | + { |
387 | + _expand_label->SetTextColor (kExpandDefaultTextColor); |
388 | + _expand_icon->SetOpacity (kExpandDefaultIconOpacity); |
389 | + } |
390 | } |
391 | void |
392 | PlacesGroup::SetName (const char *name) |
393 | @@ -130,7 +141,6 @@ |
394 | // Spaces are on purpose, want padding to be proportional to the size of the text |
395 | // Bear with me, I'm trying something different :) |
396 | const gchar *temp = " <big>%s</big> "; |
397 | - const gchar *temp_focused = " <big><b>%s</b></big> "; |
398 | gchar *tmp = NULL; |
399 | gchar *final = NULL; |
400 | if (_cached_name != NULL) |
401 | @@ -142,10 +152,7 @@ |
402 | |
403 | tmp = g_markup_escape_text (name, -1); |
404 | |
405 | - if (_expand_label->GetFocused ()) |
406 | - final = g_strdup_printf (temp_focused, tmp); |
407 | - else |
408 | - final = g_strdup_printf (temp, tmp); |
409 | + final = g_strdup_printf (temp, tmp); |
410 | |
411 | _name->SetText (final); |
412 | |
413 | @@ -264,6 +271,19 @@ |
414 | void PlacesGroup::Draw (nux::GraphicsEngine& GfxContext, |
415 | bool forceDraw) |
416 | { |
417 | + nux::Geometry geo = GetGeometry (); |
418 | + nux::Color col (0.2f, 0.2f, 0.2f, 0.2f); |
419 | + |
420 | + GfxContext.PushClippingRectangle (geo); |
421 | + |
422 | + if (_draw_sep) |
423 | + nux::GetPainter ().Draw2DLine (GfxContext, |
424 | + geo.x, geo.y + geo.height - 1, |
425 | + geo.x + geo.width, geo.y + geo.height - 1, |
426 | + col, |
427 | + col); |
428 | + |
429 | + GfxContext.PopClippingRectangle (); |
430 | } |
431 | |
432 | void |
433 | @@ -319,10 +339,29 @@ |
434 | PlacesGroup::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags) |
435 | { |
436 | _expand_label->SetTextColor (kExpandHoverTextColor); |
437 | + _expand_icon->SetOpacity (kExpandHoverIconOpacity); |
438 | } |
439 | |
440 | void |
441 | PlacesGroup::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags) |
442 | { |
443 | - _expand_label->SetTextColor (kExpandDefaultTextColor); |
444 | + if (!_expand_label->GetFocused ()) |
445 | + { |
446 | + _expand_label->SetTextColor (kExpandDefaultTextColor); |
447 | + _expand_icon->SetOpacity (kExpandDefaultIconOpacity); |
448 | + } |
449 | +} |
450 | + |
451 | +int |
452 | +PlacesGroup::GetHeaderHeight () |
453 | +{ |
454 | + return _header_layout->GetGeometry ().height; |
455 | +} |
456 | + |
457 | +void |
458 | +PlacesGroup::SetDrawSeparator (bool draw_it) |
459 | +{ |
460 | + _draw_sep = draw_it; |
461 | + |
462 | + QueueDraw (); |
463 | } |
464 | |
465 | === modified file 'src/PlacesGroup.h' |
466 | --- src/PlacesGroup.h 2011-03-10 12:42:07 +0000 |
467 | +++ src/PlacesGroup.h 2011-03-16 09:38:19 +0000 |
468 | @@ -51,6 +51,10 @@ |
469 | void SetExpanded (bool is_expanded); |
470 | bool GetExpanded (); |
471 | |
472 | + int GetHeaderHeight (); |
473 | + |
474 | + void SetDrawSeparator (bool draw_it); |
475 | + |
476 | sigc::signal<void> expanded; |
477 | |
478 | private: |
479 | @@ -77,7 +81,7 @@ |
480 | IconTexture *_icon; |
481 | nux::StaticCairoText *_name; |
482 | nux::StaticCairoText *_expand_label; |
483 | - nux::TextureArea *_expand_icon; |
484 | + IconTexture *_expand_icon; |
485 | |
486 | guint32 _idle_id; |
487 | |
488 | @@ -85,6 +89,7 @@ |
489 | guint _n_visible_items_in_unexpand_mode; |
490 | guint _n_total_items; |
491 | char *_cached_name; |
492 | + bool _draw_sep; |
493 | }; |
494 | |
495 | #endif |
496 | |
497 | === modified file 'src/PlacesGroupController.cpp' |
498 | --- src/PlacesGroupController.cpp 2011-03-09 14:13:41 +0000 |
499 | +++ src/PlacesGroupController.cpp 2011-03-16 09:38:19 +0000 |
500 | @@ -257,3 +257,9 @@ |
501 | PlacesGroupController::AddProperties (GVariantBuilder *builder) |
502 | { |
503 | } |
504 | + |
505 | +int |
506 | +PlacesGroupController::GetTotalResults () |
507 | +{ |
508 | + return _queue.size (); |
509 | +} |
510 | |
511 | === modified file 'src/PlacesGroupController.h' |
512 | --- src/PlacesGroupController.h 2011-03-09 14:13:41 +0000 |
513 | +++ src/PlacesGroupController.h 2011-03-16 09:38:19 +0000 |
514 | @@ -43,6 +43,8 @@ |
515 | |
516 | bool ActivateFirst (); |
517 | |
518 | + int GetTotalResults (); |
519 | + |
520 | protected: |
521 | const gchar* GetName (); |
522 | void AddProperties (GVariantBuilder *builder); |
523 | |
524 | === modified file 'src/PlacesHomeView.cpp' |
525 | --- src/PlacesHomeView.cpp 2011-03-10 15:06:32 +0000 |
526 | +++ src/PlacesHomeView.cpp 2011-03-16 09:38:19 +0000 |
527 | @@ -39,6 +39,7 @@ |
528 | |
529 | #include "PlacesHomeView.h" |
530 | |
531 | +#include "PlacesSettings.h" |
532 | #include "PlacesSimpleTile.h" |
533 | #include "PlacesStyle.h" |
534 | |
535 | @@ -91,10 +92,12 @@ |
536 | _layout->SetChildrenSize (style->GetHomeTileWidth (), style->GetHomeTileHeight ()); |
537 | _layout->EnablePartialVisibility (false); |
538 | _layout->SetHeightMatchContent (true); |
539 | - _layout->SetVerticalExternalMargin (16); |
540 | + _layout->SetVerticalExternalMargin (32); |
541 | _layout->SetHorizontalExternalMargin (32); |
542 | _layout->SetVerticalInternalMargin (32); |
543 | _layout->SetHorizontalInternalMargin (32); |
544 | + _layout->SetMinMaxSize ((style->GetHomeTileWidth () * 4) + (32 * 5), |
545 | + (style->GetHomeTileHeight () * 2) + (32 *3)); |
546 | |
547 | _client = gconf_client_get_default (); |
548 | gconf_client_add_dir (_client, |
549 | @@ -125,9 +128,11 @@ |
550 | this, |
551 | NULL, NULL); |
552 | |
553 | - Refresh (); |
554 | - |
555 | expanded.connect (sigc::mem_fun (this, &PlacesHomeView::Refresh)); |
556 | + |
557 | + SetExpanded (PlacesSettings::GetDefault ()->GetHomeExpanded ()); |
558 | + if (GetExpanded ()) |
559 | + Refresh (); |
560 | } |
561 | |
562 | PlacesHomeView::~PlacesHomeView () |
563 | @@ -150,14 +155,13 @@ |
564 | PlacesStyle *style = PlacesStyle::GetDefault (); |
565 | Shortcut *shortcut = NULL; |
566 | gchar *markup = NULL; |
567 | - const char *temp = "<big><b>%s</b></big>"; |
568 | + const char *temp = "<big>%s</big>"; |
569 | int icon_size = style->GetHomeTileIconSize (); |
570 | |
571 | - GetCompositionLayout ()->SetVerticalExternalMargin (4); |
572 | - GetCompositionLayout ()->SetHorizontalExternalMargin (18); |
573 | - |
574 | _layout->Clear (); |
575 | |
576 | + PlacesSettings::GetDefault ()->SetHomeExpanded (GetExpanded ()); |
577 | + |
578 | if (!GetExpanded ()) |
579 | return; |
580 | |
581 | @@ -168,7 +172,7 @@ |
582 | icon_size); |
583 | shortcut->_id = TYPE_PLACE; |
584 | shortcut->_place_id = g_strdup ("/com/canonical/unity/applicationsplace/applications"); |
585 | - shortcut->_place_section = 4; |
586 | + shortcut->_place_section = 9; |
587 | _layout->AddView (shortcut, 1, nux::eLeft, nux::eFull); |
588 | shortcut->sigClick.connect (sigc::mem_fun (this, &PlacesHomeView::OnShortcutClicked)); |
589 | g_free (markup); |
590 | @@ -180,7 +184,7 @@ |
591 | icon_size); |
592 | shortcut->_id = TYPE_PLACE; |
593 | shortcut->_place_id = g_strdup ("/com/canonical/unity/applicationsplace/applications"); |
594 | - shortcut->_place_section = 3; |
595 | + shortcut->_place_section = 8; |
596 | _layout->AddView (shortcut, 1, nux::eLeft, nux::eFull); |
597 | shortcut->sigClick.connect (sigc::mem_fun (this, &PlacesHomeView::OnShortcutClicked)); |
598 | g_free (markup); |
599 | @@ -246,7 +250,7 @@ |
600 | gchar *real_exec; |
601 | GDesktopAppInfo *info; |
602 | |
603 | - markup = g_strdup_printf ("<big><b>%s</b></big>", name); |
604 | + markup = g_strdup_printf ("<big>%s</big>", name); |
605 | |
606 | // We're going to try and create a desktop id from a exec string. Now, this is hairy at the |
607 | // best of times but the following is the closest best-guess without having to do D-Bus |
608 | |
609 | === modified file 'src/PlacesResultsController.cpp' |
610 | --- src/PlacesResultsController.cpp 2011-03-08 18:01:39 +0000 |
611 | +++ src/PlacesResultsController.cpp 2011-03-16 09:38:19 +0000 |
612 | @@ -29,6 +29,7 @@ |
613 | #include "PlacesResultsController.h" |
614 | |
615 | PlacesResultsController::PlacesResultsController () |
616 | +: _make_things_look_nice_id (0) |
617 | { |
618 | _results_view = NULL; |
619 | } |
620 | @@ -60,6 +61,7 @@ |
621 | PlacesGroupController *controller = new PlacesGroupController (entry, group); |
622 | |
623 | _id_to_group[group.GetId ()] = controller; |
624 | + _groups.push_back (controller); |
625 | _results_view->AddGroup (controller->GetGroup ()); |
626 | _results_view->QueueRelayout (); |
627 | } |
628 | @@ -75,6 +77,9 @@ |
629 | return; |
630 | |
631 | controller->AddResult (group, result); |
632 | + |
633 | + if (!_make_things_look_nice_id) |
634 | + _make_things_look_nice_id = g_idle_add ((GSourceFunc)PlacesResultsController::MakeThingsLookNice, this); |
635 | } |
636 | |
637 | void |
638 | @@ -88,6 +93,9 @@ |
639 | return; |
640 | |
641 | controller->RemoveResult (group, result); |
642 | + |
643 | + if (!_make_things_look_nice_id) |
644 | + _make_things_look_nice_id = g_idle_add ((GSourceFunc)PlacesResultsController::MakeThingsLookNice, this); |
645 | } |
646 | |
647 | void |
648 | @@ -99,6 +107,7 @@ |
649 | (it->second)->UnReference (); |
650 | |
651 | _id_to_group.erase (_id_to_group.begin (), _id_to_group.end ()); |
652 | + _groups.erase (_groups.begin (), _groups.end ()); |
653 | |
654 | _results_view->Clear (); |
655 | } |
656 | @@ -106,10 +115,10 @@ |
657 | bool |
658 | PlacesResultsController::ActivateFirst () |
659 | { |
660 | - std::map <const void *, PlacesGroupController *>::iterator it, eit = _id_to_group.end (); |
661 | + std::vector<PlacesGroupController *>::iterator it, eit = _groups.end (); |
662 | |
663 | - for (it = _id_to_group.begin (); it != eit; ++it) |
664 | - if ((it->second)->ActivateFirst ()) |
665 | + for (it = _groups.begin (); it != eit; ++it) |
666 | + if ((*it)->ActivateFirst ()) |
667 | return true; |
668 | |
669 | return false; |
670 | @@ -129,3 +138,27 @@ |
671 | { |
672 | |
673 | } |
674 | + |
675 | +gboolean |
676 | +PlacesResultsController::MakeThingsLookNice (PlacesResultsController *self) |
677 | +{ |
678 | + PlacesGroup *last_active_group = NULL; |
679 | + std::vector<PlacesGroupController *>::iterator it, eit = self->_groups.end (); |
680 | + |
681 | + for (it = self->_groups.begin (); it != eit; ++it) |
682 | + { |
683 | + PlacesGroupController *controller = *it; |
684 | + |
685 | + if (controller && controller->GetTotalResults ()) |
686 | + { |
687 | + last_active_group = controller->GetGroup (); |
688 | + last_active_group->SetDrawSeparator (true); |
689 | + } |
690 | + } |
691 | + if (last_active_group) |
692 | + last_active_group->SetDrawSeparator (false); |
693 | + |
694 | + self->_make_things_look_nice_id = 0; |
695 | + |
696 | + return FALSE; |
697 | +} |
698 | |
699 | === modified file 'src/PlacesResultsController.h' |
700 | --- src/PlacesResultsController.h 2011-03-08 18:01:39 +0000 |
701 | +++ src/PlacesResultsController.h 2011-03-16 09:38:19 +0000 |
702 | @@ -49,10 +49,13 @@ |
703 | protected: |
704 | const gchar* GetName (); |
705 | void AddProperties (GVariantBuilder *builder); |
706 | + static gboolean MakeThingsLookNice (PlacesResultsController *self); |
707 | |
708 | private: |
709 | PlacesResultsView *_results_view; |
710 | std::map<const void *, PlacesGroupController *> _id_to_group; |
711 | + std::vector<PlacesGroupController *> _groups; |
712 | + guint32 _make_things_look_nice_id; |
713 | }; |
714 | |
715 | #endif // PLACES_RESULTS_CONTROLLER_H |
716 | |
717 | === modified file 'src/PlacesResultsView.cpp' |
718 | --- src/PlacesResultsView.cpp 2011-03-10 13:03:21 +0000 |
719 | +++ src/PlacesResultsView.cpp 2011-03-16 09:38:19 +0000 |
720 | @@ -34,8 +34,10 @@ |
721 | _layout = new nux::VLayout (NUX_TRACKER_LOCATION); |
722 | |
723 | _layout->SetContentDistribution(nux::MAJOR_POSITION_TOP); |
724 | - _layout->SetHorizontalExternalMargin (14); |
725 | - _layout->SetVerticalInternalMargin (14); |
726 | + _layout->SetHorizontalExternalMargin (0); |
727 | + _layout->SetVerticalInternalMargin (0); |
728 | + setBorder (0); |
729 | + setTopBorder (0); |
730 | |
731 | SetLayout (_layout); |
732 | |
733 | |
734 | === modified file 'src/PlacesSearchBar.cpp' |
735 | --- src/PlacesSearchBar.cpp 2011-03-10 13:03:21 +0000 |
736 | +++ src/PlacesSearchBar.cpp 2011-03-16 09:38:19 +0000 |
737 | @@ -97,13 +97,13 @@ |
738 | _layout->SetHorizontalExternalMargin (18); |
739 | |
740 | SetLayout (_layout); |
741 | - |
742 | SetCompositionLayout (_layout); |
743 | |
744 | g_signal_connect (gtk_settings_get_default (), "notify::gtk-font-name", |
745 | G_CALLBACK (OnFontChanged), this); |
746 | OnFontChanged (NULL, NULL, this); |
747 | |
748 | + _pango_entry->cursor_moved.connect (sigc::mem_fun (this, &PlacesSearchBar::OnLayeredLayoutQueueDraw)); |
749 | } |
750 | |
751 | PlacesSearchBar::~PlacesSearchBar () |
752 | @@ -149,7 +149,9 @@ |
753 | |
754 | UpdateBackground (); |
755 | |
756 | - GfxContext.PushClippingRectangle (geo); |
757 | + GfxContext.PushClippingRectangle (geo); |
758 | + |
759 | + nux::GetPainter ().PaintBackground (GfxContext, geo); |
760 | |
761 | _bg_layer->SetGeometry (nux::Geometry (geo.x, geo.y, _last_width, geo.height)); |
762 | nux::GetPainter ().RenderSinglePaintLayer (GfxContext, |
763 | @@ -189,14 +191,16 @@ |
764 | if (_entry) |
765 | { |
766 | // i18n: This is for a dynamic place name i.e. "Search Files & Folders" |
767 | - const gchar *search_template = _("<span font_size='x-small' font_style='italic'>Search %s</span>"); |
768 | + const gchar *search_template = _("Search %s"); |
769 | + gchar *markup; |
770 | gchar *res; |
771 | gchar *tmp; |
772 | |
773 | tmp = g_markup_escape_text (entry->GetName (), -1); |
774 | res = g_strdup_printf (search_template, tmp); |
775 | + markup = g_strdup_printf ("<span font_size='x-small' font_style='italic'> %s </span>", res); |
776 | |
777 | - _hint->SetText (res); |
778 | + _hint->SetText (markup); |
779 | _pango_entry->SetText (search_string ? search_string : ""); |
780 | |
781 | _entry->SetActiveSection (section_id); |
782 | @@ -208,6 +212,7 @@ |
783 | |
784 | g_free (res); |
785 | g_free (tmp); |
786 | + g_free (markup); |
787 | } |
788 | else |
789 | { |
790 | @@ -305,6 +310,12 @@ |
791 | } |
792 | |
793 | void |
794 | +PlacesSearchBar::OnLayeredLayoutQueueDraw (int i) |
795 | +{ |
796 | + QueueDraw (); |
797 | +} |
798 | + |
799 | +void |
800 | PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self) |
801 | { |
802 | #define HOW_LARGE 8 |
803 | @@ -465,6 +476,4 @@ |
804 | ); |
805 | |
806 | texture2D->UnReference (); |
807 | - |
808 | - QueueDraw (); |
809 | } |
810 | |
811 | === modified file 'src/PlacesSearchBar.h' |
812 | --- src/PlacesSearchBar.h 2011-03-10 13:03:21 +0000 |
813 | +++ src/PlacesSearchBar.h 2011-03-16 09:38:19 +0000 |
814 | @@ -72,6 +72,7 @@ |
815 | void OnComboChanged (nux::ComboBoxSimple *simple); |
816 | void OnMenuClosing (nux::MenuPage *menu, int x, int y); |
817 | void OnEntryActivated (); |
818 | + void OnLayeredLayoutQueueDraw (int i); |
819 | |
820 | static bool OnLiveSearchTimeout (PlacesSearchBar *self); |
821 | static void OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self); |
822 | |
823 | === modified file 'src/PlacesSettings.cpp' |
824 | --- src/PlacesSettings.cpp 2011-03-10 11:17:26 +0000 |
825 | +++ src/PlacesSettings.cpp 2011-03-16 09:38:19 +0000 |
826 | @@ -21,6 +21,8 @@ |
827 | |
828 | #include "PlacesSettings.h" |
829 | |
830 | +#define HOME_EXPANDED "home-expanded" |
831 | + |
832 | static PlacesSettings *_places_settings = NULL; |
833 | |
834 | PlacesSettings::PlacesSettings () |
835 | @@ -105,3 +107,14 @@ |
836 | _dash_blur_type = type; |
837 | } |
838 | |
839 | +bool |
840 | +PlacesSettings::GetHomeExpanded () |
841 | +{ |
842 | + return g_settings_get_enum (_settings, HOME_EXPANDED) == 1 ? true : false; |
843 | +} |
844 | + |
845 | +void |
846 | +PlacesSettings::SetHomeExpanded (bool expanded) |
847 | +{ |
848 | + g_settings_set_enum (_settings, HOME_EXPANDED, expanded ? 1 : 0); |
849 | +} |
850 | |
851 | === modified file 'src/PlacesSettings.h' |
852 | --- src/PlacesSettings.h 2011-03-10 11:17:26 +0000 |
853 | +++ src/PlacesSettings.h 2011-03-16 09:38:19 +0000 |
854 | @@ -52,6 +52,9 @@ |
855 | DashBlurType GetDashBlurType (); |
856 | void SetDashBlurType (DashBlurType type); |
857 | |
858 | + bool GetHomeExpanded (); |
859 | + void SetHomeExpanded (bool expanded); |
860 | + |
861 | sigc::signal<void, PlacesSettings *> changed; |
862 | |
863 | private: |
864 | |
865 | === modified file 'src/PlacesView.cpp' |
866 | --- src/PlacesView.cpp 2011-03-10 15:21:45 +0000 |
867 | +++ src/PlacesView.cpp 2011-03-16 09:38:19 +0000 |
868 | @@ -41,7 +41,12 @@ |
869 | : nux::View (NUX_TRACKER_LOCATION), |
870 | _factory (factory), |
871 | _entry (NULL), |
872 | - _size_mode (SIZE_MODE_FULLSCREEN) |
873 | + _size_mode (SIZE_MODE_FULLSCREEN), |
874 | + _shrink_mode (SHRINK_MODE_NONE), |
875 | + _target_height (1), |
876 | + _actual_height (1), |
877 | + _resize_id (0), |
878 | + _alt_f2_entry (NULL) |
879 | { |
880 | LoadPlaces (); |
881 | _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded)); |
882 | @@ -54,6 +59,7 @@ |
883 | _layout->AddLayout (vlayout, 1, nux::eCenter, nux::eFull); |
884 | |
885 | _h_spacer= new nux::SpaceLayout (1, 1, 1, nux::AREA_MAX_HEIGHT); |
886 | + _h_spacer->SetVisible (false); |
887 | _layout->AddLayout (_h_spacer, 0, nux::eCenter, nux::eFull); |
888 | |
889 | _search_bar = new PlacesSearchBar (); |
890 | @@ -63,13 +69,21 @@ |
891 | _search_bar->search_changed.connect (sigc::mem_fun (this, &PlacesView::OnSearchChanged)); |
892 | _search_bar->activated.connect (sigc::mem_fun (this, &PlacesView::OnEntryActivated)); |
893 | |
894 | + nux::HLayout *hlayout = new nux::HLayout (NUX_TRACKER_LOCATION); |
895 | + vlayout->AddLayout (hlayout, 1, nux::eCenter, nux::eFull); |
896 | + |
897 | + nux::SpaceLayout *slayout = new nux::SpaceLayout (24, 24, 1, nux::AREA_MAX_HEIGHT); |
898 | + hlayout->AddLayout (slayout, 1, nux::eCenter, nux::eFull); |
899 | + |
900 | _layered_layout = new nux::LayeredLayout (NUX_TRACKER_LOCATION); |
901 | - vlayout->AddLayout (_layered_layout, 1, nux::eCenter, nux::eFull); |
902 | + hlayout->AddLayout (_layered_layout, 1, nux::eCenter, nux::eFull); |
903 | |
904 | _v_spacer = new nux::SpaceLayout (1, nux::AREA_MAX_WIDTH, 1, 1); |
905 | + _v_spacer->SetVisible (false); |
906 | vlayout->AddLayout (_v_spacer, 0, nux::eCenter, nux::eFull); |
907 | |
908 | _home_view = new PlacesHomeView (); |
909 | + _home_view->expanded.connect (sigc::mem_fun (this, &PlacesView::ReEvaluateShrinkMode)); |
910 | _layered_layout->AddLayer (_home_view); |
911 | AddChild (_home_view); |
912 | |
913 | @@ -121,8 +135,6 @@ |
914 | long |
915 | PlacesView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
916 | { |
917 | - // FIXME: This breaks with multi-monitor |
918 | - nux::Geometry homebutton (0.0f, 0.0f, 66.0f, 24.0f); |
919 | long ret = TraverseInfo; |
920 | |
921 | if ((ievent.e_event == nux::NUX_KEYDOWN) && |
922 | @@ -138,7 +150,7 @@ |
923 | nux::BaseTexture *corner = style->GetDashCorner (); |
924 | nux::Geometry geo = GetAbsoluteGeometry (); |
925 | nux::Geometry fullscreen (geo.x + geo.width - corner->GetWidth (), |
926 | - geo.y + geo.height - corner->GetHeight (), |
927 | + geo.y + _actual_height - corner->GetHeight (), |
928 | corner->GetWidth (), |
929 | corner->GetHeight ()); |
930 | |
931 | @@ -149,6 +161,13 @@ |
932 | |
933 | return TraverseInfo |= nux::eMouseEventSolved; |
934 | } |
935 | + |
936 | + geo.height = _actual_height; |
937 | + if (!geo.IsPointInside (ievent.e_x, ievent.e_y)) |
938 | + { |
939 | + SetActiveEntry (NULL, 0, ""); |
940 | + return TraverseInfo |= nux::eMouseEventSolved; |
941 | + } |
942 | } |
943 | |
944 | ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo); |
945 | @@ -171,7 +190,8 @@ |
946 | GfxContext.GetRenderStates ().SetBlend (true); |
947 | GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER); |
948 | |
949 | - nux::Geometry _bg_blur_geo = GetGeometry (); |
950 | + geo.height = _actual_height; |
951 | + nux::Geometry _bg_blur_geo = geo; |
952 | |
953 | if ((_size_mode == SIZE_MODE_HOVER)) |
954 | { |
955 | @@ -316,10 +336,13 @@ |
956 | PlacesView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw) |
957 | { |
958 | PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType (); |
959 | + nux::Geometry clip_geo = GetGeometry (); |
960 | bool paint_blur = type != PlacesSettings::NO_BLUR; |
961 | int bgs = 1; |
962 | |
963 | - GfxContext.PushClippingRectangle (GetGeometry() ); |
964 | + clip_geo.height = _bg_layer->GetGeometry ().height -1; |
965 | + GfxContext.PushClippingRectangle (clip_geo); |
966 | + |
967 | GfxContext.GetRenderStates ().SetBlend (true); |
968 | GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER); |
969 | |
970 | @@ -344,7 +367,9 @@ |
971 | nux::GetPainter ().PushLayer (GfxContext, _bg_layer->GetGeometry (), _bg_layer); |
972 | |
973 | if (_layout) |
974 | + { |
975 | _layout->ProcessDraw (GfxContext, force_draw); |
976 | + } |
977 | |
978 | nux::GetPainter ().PopBackground (bgs); |
979 | |
980 | @@ -360,6 +385,12 @@ |
981 | PlacesView::AboutToShow () |
982 | { |
983 | _bg_blur_texture.Release (); |
984 | + if (_resize_id) |
985 | + g_source_remove (_resize_id); |
986 | + _resize_id = 0; |
987 | + _actual_height = _last_height = _target_height; |
988 | + |
989 | + _search_bar->_pango_entry->SetFocused (true); |
990 | } |
991 | |
992 | void |
993 | @@ -370,6 +401,9 @@ |
994 | |
995 | if (entry == NULL) |
996 | entry = _home_entry; |
997 | + else if (!_alt_f2_entry |
998 | + && g_strcmp0 (entry->GetId (), "/com/canonical/unity/applicationsplace/runner") ==0) |
999 | + _alt_f2_entry = entry; |
1000 | |
1001 | if (_entry) |
1002 | { |
1003 | @@ -399,7 +433,10 @@ |
1004 | else |
1005 | _layered_layout->SetActiveLayer (_results_view); |
1006 | |
1007 | - |
1008 | + if (_entry == _alt_f2_entry) |
1009 | + _actual_height = _target_height = _last_height = _search_bar->GetGeometry ().height; |
1010 | + |
1011 | + ReEvaluateShrinkMode (); |
1012 | } |
1013 | |
1014 | PlaceEntry * |
1015 | @@ -414,16 +451,87 @@ |
1016 | return _results_controller; |
1017 | } |
1018 | |
1019 | +gboolean |
1020 | +PlacesView::OnResizeFrame (PlacesView *self) |
1021 | +{ |
1022 | +#define _LENGTH_ 200000 |
1023 | + gint64 diff; |
1024 | + float progress; |
1025 | + float last_height; |
1026 | + |
1027 | + diff = g_get_monotonic_time () - self->_resize_start_time; |
1028 | + |
1029 | + progress = diff/(float)_LENGTH_; |
1030 | + |
1031 | + last_height = self->_last_height; |
1032 | + |
1033 | + if (self->_target_height > self->_last_height) |
1034 | + { |
1035 | + self->_actual_height = last_height + ((self->_target_height - last_height) * progress); |
1036 | + } |
1037 | + else |
1038 | + { |
1039 | + self->_actual_height = last_height - ((last_height - self->_target_height) * progress); |
1040 | + } |
1041 | + |
1042 | + if (diff > _LENGTH_) |
1043 | + { |
1044 | + self->_resize_id = 0; |
1045 | + |
1046 | + // Make sure the state is right |
1047 | + self->_actual_height = self->_target_height; |
1048 | + |
1049 | + self->QueueDraw (); |
1050 | + return FALSE; |
1051 | + } |
1052 | + |
1053 | + self->QueueDraw (); |
1054 | + return TRUE; |
1055 | +} |
1056 | + |
1057 | void |
1058 | PlacesView::OnResultsViewGeometryChanged (nux::Area *view, nux::Geometry& view_geo) |
1059 | { |
1060 | - if (view_geo.height >= _results_view->GetGeometry ().height) |
1061 | +#define UNEXPANDED_HOME_PADDING 12 |
1062 | + nux::BaseTexture *corner = PlacesStyle::GetDefault ()->GetDashCorner (); |
1063 | + |
1064 | + if (_shrink_mode == SHRINK_MODE_NONE || _size_mode == SIZE_MODE_FULLSCREEN) |
1065 | { |
1066 | - ; |
1067 | + _target_height = GetGeometry ().height; |
1068 | + _actual_height = _target_height; |
1069 | } |
1070 | else |
1071 | { |
1072 | - ; |
1073 | + gint target_height = _search_bar->GetGeometry ().height; |
1074 | + |
1075 | + if (_layered_layout->GetActiveLayer () == _home_view) |
1076 | + { |
1077 | + if (_home_view->GetExpanded ()) |
1078 | + target_height += _home_view->GetLayout ()->GetContentHeight (); |
1079 | + else |
1080 | + target_height += _home_view->GetHeaderHeight () + UNEXPANDED_HOME_PADDING; |
1081 | + } |
1082 | + else |
1083 | + { |
1084 | + target_height += _results_view->GetLayout ()->GetContentHeight (); |
1085 | + } |
1086 | + |
1087 | + target_height += corner->GetHeight (); |
1088 | + if (target_height >= GetGeometry ().height) |
1089 | + target_height = GetGeometry ().height; |
1090 | + |
1091 | + if (_target_height != target_height) |
1092 | + { |
1093 | + _target_height = target_height; |
1094 | + _last_height = _actual_height; |
1095 | + _resize_start_time = g_get_monotonic_time (); |
1096 | + |
1097 | + if (_resize_id) |
1098 | + g_source_remove (_resize_id); |
1099 | + _resize_id = g_timeout_add (15, (GSourceFunc)PlacesView::OnResizeFrame, this); |
1100 | + } |
1101 | + |
1102 | + QueueDraw (); |
1103 | } |
1104 | } |
1105 | |
1106 | @@ -459,6 +567,10 @@ |
1107 | _v_spacer->SetMaximumHeight (corner->GetHeight ()); |
1108 | } |
1109 | |
1110 | + _h_spacer->SetVisible (size_mode == SIZE_MODE_HOVER); |
1111 | + _v_spacer->SetVisible (size_mode == SIZE_MODE_HOVER); |
1112 | + |
1113 | + ReEvaluateShrinkMode (); |
1114 | QueueDraw (); |
1115 | } |
1116 | |
1117 | @@ -660,6 +772,22 @@ |
1118 | }; |
1119 | } |
1120 | |
1121 | +void |
1122 | +PlacesView::ReEvaluateShrinkMode () |
1123 | +{ |
1124 | + if (_size_mode == SIZE_MODE_FULLSCREEN) |
1125 | + _shrink_mode = SHRINK_MODE_NONE; |
1126 | + |
1127 | + if (_entry == _home_entry || _entry == _alt_f2_entry) |
1128 | + { |
1129 | + _shrink_mode = SHRINK_MODE_CONTENTS; |
1130 | + } |
1131 | + else |
1132 | + _shrink_mode = SHRINK_MODE_NONE; |
1133 | + |
1134 | + nux::Geometry geo = _results_view->GetGeometry (); |
1135 | + OnResultsViewGeometryChanged (_results_view, geo); |
1136 | +} |
1137 | |
1138 | // |
1139 | // Introspection |
1140 | |
1141 | === modified file 'src/PlacesView.h' |
1142 | --- src/PlacesView.h 2011-03-10 11:17:26 +0000 |
1143 | +++ src/PlacesView.h 2011-03-16 09:38:19 +0000 |
1144 | @@ -47,12 +47,20 @@ |
1145 | NUX_DECLARE_OBJECT_TYPE (PlacesView, nux::View); |
1146 | public: |
1147 | |
1148 | + // Current size of the Dash |
1149 | enum SizeMode |
1150 | { |
1151 | SIZE_MODE_FULLSCREEN, |
1152 | SIZE_MODE_HOVER |
1153 | }; |
1154 | |
1155 | + // This controls how the Dash resizes to it's contents |
1156 | + enum ShrinkMode |
1157 | + { |
1158 | + SHRINK_MODE_NONE, |
1159 | + SHRINK_MODE_CONTENTS |
1160 | + }; |
1161 | + |
1162 | PlacesView (PlaceFactory *factory); |
1163 | ~PlacesView (); |
1164 | |
1165 | @@ -109,6 +117,9 @@ |
1166 | void LoadPlaces (); |
1167 | void OnPlaceAdded (Place *place); |
1168 | void OnPlaceResultActivated (const char *uri, ActivationResult res); |
1169 | + void ReEvaluateShrinkMode (); |
1170 | + |
1171 | + static gboolean OnResizeFrame (PlacesView *self); |
1172 | |
1173 | private: |
1174 | PlaceFactory *_factory; |
1175 | @@ -130,10 +141,19 @@ |
1176 | nux::SpaceLayout *_h_spacer; |
1177 | nux::SpaceLayout *_v_spacer; |
1178 | |
1179 | - SizeMode _size_mode; |
1180 | + SizeMode _size_mode; |
1181 | + ShrinkMode _shrink_mode; |
1182 | |
1183 | nux::ObjectPtr <nux::IOpenGLBaseTexture> _bg_blur_texture; |
1184 | nux::Geometry _bg_blur_geo; |
1185 | + |
1186 | + gint _target_height; |
1187 | + gint _actual_height; |
1188 | + guint _resize_id; |
1189 | + gint _last_height; |
1190 | + gint64 _resize_start_time; |
1191 | + |
1192 | + PlaceEntry *_alt_f2_entry; |
1193 | }; |
1194 | |
1195 | #endif // PANEL_HOME_BUTTON_H |
1196 | |
1197 | === modified file 'tests/TestPlaces.cpp' |
1198 | --- tests/TestPlaces.cpp 2011-03-10 12:42:07 +0000 |
1199 | +++ tests/TestPlaces.cpp 2011-03-16 09:38:19 +0000 |
1200 | @@ -55,8 +55,9 @@ |
1201 | _factory->place_added.connect (sigc::mem_fun (this, &TestApp::OnPlaceAdded)); |
1202 | |
1203 | PlacesView *view = new PlacesView (_factory); |
1204 | - view->SetMinMaxSize(1024, 500); |
1205 | + view->SetMinMaxSize(1024, 768); |
1206 | layout->AddView(view, 1, nux::eCenter, nux::eFix); |
1207 | + view->SetSizeMode (PlacesView::SIZE_MODE_HOVER); |
1208 | |
1209 | layout->SetContentDistribution(nux::eStackCenter); |
1210 | layout->SetFocused (true); |
1211 | @@ -151,7 +152,7 @@ |
1212 | nux::NuxInitialize(0); |
1213 | |
1214 | nux::WindowThread* wt = nux::CreateGUIThread("Unity Places", |
1215 | - 1024, 500, 0, &ThreadWidgetInit, 0); |
1216 | + 1024, 768, 0, &ThreadWidgetInit, 0); |
1217 | app = new TestApp (); |
1218 | |
1219 | wt->Run(NULL); |