Merge lp:~njpatel/unity/dash-fixes-2011-08-22 into lp:unity

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
Reviewer Review Type Date Requested Status
Gord Allott Pending
Review via email: mp+72699@code.launchpad.net

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
=== modified file 'UnityCore/Lens.cpp'
--- UnityCore/Lens.cpp 2011-08-10 09:51:24 +0000
+++ UnityCore/Lens.cpp 2011-08-24 12:31:11 +0000
@@ -173,7 +173,6 @@
173 glib::String search_string;173 glib::String search_string;
174174
175 g_variant_get(parameters, "(sa{sv})", &search_string, NULL);175 g_variant_get(parameters, "(sa{sv})", &search_string, NULL);
176 g_debug ("HELLO");
177 owner_->search_finished.emit(search_string.Str());176 owner_->search_finished.emit(search_string.Str());
178}177}
179178
180179
=== modified file 'plugins/unityshell/src/BFBLauncherIcon.cpp'
--- plugins/unityshell/src/BFBLauncherIcon.cpp 2011-08-03 14:25:30 +0000
+++ plugins/unityshell/src/BFBLauncherIcon.cpp 2011-08-24 12:31:11 +0000
@@ -50,6 +50,7 @@
50 if (arg.button == 1)50 if (arg.button == 1)
51 {51 {
52 UBusServer* ubus = ubus_server_get_default();52 UBusServer* ubus = ubus_server_get_default();
53 ubus_server_send_message(ubus, UBUS_DASH_EXTERNAL_ACTIVATION, NULL);53 ubus_server_send_message(ubus, UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
54 g_variant_new("(sus)", "home.lens", 0, ""));
54 }55 }
55}56}
5657
=== modified file 'plugins/unityshell/src/DashSearchBarSpinner.cpp'
--- plugins/unityshell/src/DashSearchBarSpinner.cpp 2011-08-09 17:45:12 +0000
+++ plugins/unityshell/src/DashSearchBarSpinner.cpp 2011-08-24 12:31:11 +0000
@@ -52,6 +52,9 @@
52{52{
53 if (_spinner_timeout)53 if (_spinner_timeout)
54 g_source_remove(_spinner_timeout);54 g_source_remove(_spinner_timeout);
55
56 if (_frame_timeout)
57 g_source_remove(_frame_timeout);
55}58}
5659
57long60long
@@ -157,8 +160,10 @@
157 texxform,160 texxform,
158 nux::color::White);161 nux::color::White);
159 }162 }
160
161 GfxContext.PopClippingRectangle();163 GfxContext.PopClippingRectangle();
164
165 if (_state == STATE_SEARCHING && !_frame_timeout)
166 _frame_timeout = g_timeout_add(22, (GSourceFunc)SearchBarSpinner::OnFrame, this);
162}167}
163168
164void169void
@@ -167,18 +172,24 @@
167}172}
168173
169gboolean174gboolean
175SearchBarSpinner::OnTimeout(SearchBarSpinner* self)
176{
177 self->_state = STATE_READY;
178 return FALSE;
179}
180
181gboolean
170SearchBarSpinner::OnFrame(SearchBarSpinner* self)182SearchBarSpinner::OnFrame(SearchBarSpinner* self)
171{183{
172 self->_rotation += 0.1f;184 self->_rotation += 0.1f;
173
174 if (self->_rotation >= 360.0f)185 if (self->_rotation >= 360.0f)
175 self->_rotation = 0.0f;186 self->_rotation = 0.0f;
176187
177 self->_2d_rotate.Rotate_z(self->_rotation);188 self->_2d_rotate.Rotate_z(self->_rotation);
189 self->_frame_timeout = 0;
178190
179 self->QueueDraw();191 self->QueueDraw();
180192 return FALSE;
181 return TRUE;
182}193}
183194
184void195void
@@ -192,12 +203,13 @@
192 if (_spinner_timeout)203 if (_spinner_timeout)
193 g_source_remove(_spinner_timeout);204 g_source_remove(_spinner_timeout);
194 _spinner_timeout = 0;205 _spinner_timeout = 0;
206
195 _2d_rotate.Rotate_z(0.0f);207 _2d_rotate.Rotate_z(0.0f);
196 _rotation = 0.0f;208 _rotation = 0.0f;
197209
198 if (_state == STATE_SEARCHING)210 if (_state == STATE_SEARCHING)
199 {211 {
200 _spinner_timeout = g_timeout_add(15, (GSourceFunc)SearchBarSpinner::OnFrame, this);212 _spinner_timeout = g_timeout_add_seconds(5, (GSourceFunc)SearchBarSpinner::OnTimeout, this);
201 }213 }
202214
203 QueueDraw();215 QueueDraw();
204216
=== modified file 'plugins/unityshell/src/DashSearchBarSpinner.h'
--- plugins/unityshell/src/DashSearchBarSpinner.h 2011-08-09 06:24:59 +0000
+++ plugins/unityshell/src/DashSearchBarSpinner.h 2011-08-24 12:31:11 +0000
@@ -56,6 +56,7 @@
56 // Introspectable methods56 // Introspectable methods
57 const gchar* GetName();57 const gchar* GetName();
58 void AddProperties(GVariantBuilder* builder);58 void AddProperties(GVariantBuilder* builder);
59 static gboolean OnTimeout(SearchBarSpinner* self);
59 static gboolean OnFrame(SearchBarSpinner* self);60 static gboolean OnFrame(SearchBarSpinner* self);
6061
61 // Key navigation62 // Key navigation
@@ -76,6 +77,7 @@
76 float _rotation;77 float _rotation;
7778
78 guint32 _spinner_timeout;79 guint32 _spinner_timeout;
80 guint32 _frame_timeout;
79};81};
8082
81}83}
8284
=== modified file 'plugins/unityshell/src/DashView.cpp'
--- plugins/unityshell/src/DashView.cpp 2011-08-22 13:48:47 +0000
+++ plugins/unityshell/src/DashView.cpp 2011-08-24 12:31:11 +0000
@@ -55,7 +55,7 @@
55 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));55 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
5656
57 Relayout();57 Relayout();
58 OnLensBarActivated("home");58 lens_bar_->Activate("home.lens");
5959
60 bg_effect_helper_.owner = this;60 bg_effect_helper_.owner = this;
61 bg_effect_helper_.enabled = false;61 bg_effect_helper_.enabled = false;
@@ -105,7 +105,7 @@
105105
106 home_view_ = new HomeView();106 home_view_ = new HomeView();
107 active_lens_view_ = home_view_;107 active_lens_view_ = home_view_;
108 lens_views_["home"] = home_view_;108 lens_views_["home.lens"] = home_view_;
109 lenses_layout_->AddView(home_view_);109 lenses_layout_->AddView(home_view_);
110110
111 lens_bar_ = new LensBar();111 lens_bar_ = new LensBar();
@@ -117,8 +117,6 @@
117{117{
118 ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,118 ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
119 sigc::mem_fun(this, &DashView::OnActivateRequest));119 sigc::mem_fun(this, &DashView::OnActivateRequest));
120 ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_QUEUE_DRAW,
121 [&] (GVariant* args) { QueueDraw(); });
122 ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED,120 ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED,
123 sigc::mem_fun(this, &DashView::OnBackgroundColorChanged));121 sigc::mem_fun(this, &DashView::OnBackgroundColorChanged));
124}122}
@@ -260,7 +258,7 @@
260 texxform,258 texxform,
261 nux::color::White);259 nux::color::White);
262 }260 }
263 {261 {
264 // Bottom repeated texture262 // Bottom repeated texture
265 int real_width = geo.width - corner->GetWidth();263 int real_width = geo.width - corner->GetWidth();
266 int offset = real_width % bottom->GetWidth();264 int offset = real_width % bottom->GetWidth();
@@ -276,7 +274,6 @@
276 texxform,274 texxform,
277 nux::color::White);275 nux::color::White);
278 }276 }
279
280 {277 {
281 // Right repeated texture278 // Right repeated texture
282 int real_height = geo.height - corner->GetHeight();279 int real_height = geo.height - corner->GetHeight();
@@ -358,7 +355,7 @@
358355
359 g_variant_get(args, "(sus)", &id, NULL, &search_string);356 g_variant_get(args, "(sus)", &id, NULL, &search_string);
360357
361 OnLensBarActivated(id.Str());358 lens_bar_->Activate(id.Str());
362359
363 // Reset focus360 // Reset focus
364 SetFocused(false);361 SetFocused(false);
@@ -405,8 +402,6 @@
405402
406 lens->activated.connect(sigc::mem_fun(this, &DashView::OnUriActivatedReply));403 lens->activated.connect(sigc::mem_fun(this, &DashView::OnUriActivatedReply));
407 lens->search_finished.connect(sigc::mem_fun(this, &DashView::OnSearchFinished));404 lens->search_finished.connect(sigc::mem_fun(this, &DashView::OnSearchFinished));
408
409 lens->Search("");
410}405}
411406
412void DashView::OnLensBarActivated(std::string const& id)407void DashView::OnLensBarActivated(std::string const& id)
@@ -418,7 +413,10 @@
418 }413 }
419414
420 for (auto it: lens_views_)415 for (auto it: lens_views_)
416 {
421 it.second->SetVisible(it.first == id);417 it.second->SetVisible(it.first == id);
418 it.second->active = it.first == id;
419 }
422420
423 LensView* view = active_lens_view_ = lens_views_[id];421 LensView* view = active_lens_view_ = lens_views_[id];
424 search_bar_->search_string = view->search_string;422 search_bar_->search_string = view->search_string;
@@ -447,7 +445,6 @@
447void DashView::OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&)445void DashView::OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&)
448{446{
449 // We don't want to close the dash if there was another activation pending447 // We don't want to close the dash if there was another activation pending
450
451 if (type == NOT_HANDLED)448 if (type == NOT_HANDLED)
452 {449 {
453 if (!DoFallbackActivation(uri))450 if (!DoFallbackActivation(uri))
454451
=== modified file 'plugins/unityshell/src/FilterExpanderLabel.cpp'
--- plugins/unityshell/src/FilterExpanderLabel.cpp 2011-08-19 15:17:30 +0000
+++ plugins/unityshell/src/FilterExpanderLabel.cpp 2011-08-24 12:31:11 +0000
@@ -34,7 +34,7 @@
34 , contents_ (NULL)34 , contents_ (NULL)
35 , right_hand_contents_ (NULL)35 , right_hand_contents_ (NULL)
36 , expander_graphic_ (NULL)36 , expander_graphic_ (NULL)
37 , label_("<span font_size='x-large'>" + label + "</span>")37 , label_("<span font_size='larger'>" + label + "</span>")
38 {38 {
39 expanded.changed.connect (sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));39 expanded.changed.connect (sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
40 BuildLayout ();40 BuildLayout ();
@@ -46,7 +46,7 @@
4646
47 void FilterExpanderLabel::SetLabel (std::string label)47 void FilterExpanderLabel::SetLabel (std::string label)
48 {48 {
49 label_ = "<style size='x-large'>" + label + "</style>";49 label_ = "<style size='larger'>" + label + "</style>";
50 cairo_label_->SetText(label.c_str());50 cairo_label_->SetText(label.c_str());
51 }51 }
5252
5353
=== modified file 'plugins/unityshell/src/FilterGenreWidget.cpp'
--- plugins/unityshell/src/FilterGenreWidget.cpp 2011-08-17 15:00:14 +0000
+++ plugins/unityshell/src/FilterGenreWidget.cpp 2011-08-24 12:31:11 +0000
@@ -25,6 +25,7 @@
25#include "FilterGenreWidget.h"25#include "FilterGenreWidget.h"
26#include "FilterGenreButton.h"26#include "FilterGenreButton.h"
27#include "FilterBasicButton.h"27#include "FilterBasicButton.h"
28#include "PlacesStyle.h"
2829
29namespace unity {30namespace unity {
3031
@@ -37,13 +38,15 @@
37 all_button_->activated.connect(sigc::mem_fun(this, &FilterGenre::OnAllActivated));38 all_button_->activated.connect(sigc::mem_fun(this, &FilterGenre::OnAllActivated));
38 all_button_->Reference();39 all_button_->Reference();
3940
41 PlacesStyle* style = PlacesStyle::GetDefault();
42
40 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);43 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
41 genre_layout_->ForceChildrenSize(true);44 genre_layout_->ForceChildrenSize(true);
42 genre_layout_->SetHeightMatchContent(true);45 genre_layout_->SetHeightMatchContent(true);
43 genre_layout_->SetVerticalInternalMargin (6);46 genre_layout_->SetVerticalInternalMargin (6);
44 genre_layout_->SetHorizontalInternalMargin (6);47 genre_layout_->SetHorizontalInternalMargin (6);
45 genre_layout_->EnablePartialVisibility (false);48 genre_layout_->EnablePartialVisibility (false);
46 genre_layout_->SetChildrenSize (120, 40);49 genre_layout_->SetChildrenSize (style->GetTileWidth() - 12, style->GetTextLineHeight() * 2);
47 genre_layout_->Reference();50 genre_layout_->Reference();
4851
49 SetRightHandView(all_button_);52 SetRightHandView(all_button_);
5053
=== modified file 'plugins/unityshell/src/FilterMultiRangeButton.cpp'
--- plugins/unityshell/src/FilterMultiRangeButton.cpp 2011-08-22 12:04:21 +0000
+++ plugins/unityshell/src/FilterMultiRangeButton.cpp 2011-08-24 12:31:11 +0000
@@ -122,7 +122,7 @@
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));
123 }123 }
124124
125 SetMinimumHeight(32);125 //SetMinimumHeight(32);
126 }126 }
127127
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)
129129
=== added file 'plugins/unityshell/src/FontSettings.cpp'
--- plugins/unityshell/src/FontSettings.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/FontSettings.cpp 2011-08-24 12:31:11 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#include "FontSettings.h"
20
21#include <cairo/cairo.h>
22
23#include <UnityCore/GLibWrapper.h>
24
25namespace unity
26{
27
28FontSettings::FontSettings()
29{
30 GtkSettings* settings = gtk_settings_get_default();
31
32 sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-hintstyle", sigc::mem_fun(this, &FontSettings::Refresh)));
33 sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-rgba", sigc::mem_fun(this, &FontSettings::Refresh)));
34
35 Refresh();
36}
37
38void FontSettings::Refresh(GtkSettings* unused0, GParamSpec* unused1)
39{
40 GtkSettings* settings = gtk_settings_get_default();
41 cairo_font_options_t* font_options = cairo_font_options_create();
42
43 {
44 cairo_subpixel_order_t order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
45 glib::String value;
46 g_object_get(settings, "gtk-xft-rgba", &value, NULL);
47
48 if (value.Str() == "rgb")
49 order = CAIRO_SUBPIXEL_ORDER_RGB;
50 else if (value.Str() == "bgr")
51 order = CAIRO_SUBPIXEL_ORDER_BGR;
52 else if (value.Str() == "vrgb")
53 order = CAIRO_SUBPIXEL_ORDER_VRGB;
54 else if (value.Str() == "vbgr")
55 order = CAIRO_SUBPIXEL_ORDER_VBGR;
56
57 cairo_font_options_set_subpixel_order(font_options, order);
58 cairo_font_options_set_antialias(font_options,
59 value.Str() == "none" ? CAIRO_ANTIALIAS_NONE
60 : CAIRO_ANTIALIAS_SUBPIXEL);
61
62 }
63
64 {
65 cairo_hint_style_t style = CAIRO_HINT_STYLE_DEFAULT;
66 glib::String value;
67 g_object_get(settings, "gtk-xft-hintstyle", &value, NULL);
68
69 if (value.Str() == "hintnone")
70 style = CAIRO_HINT_STYLE_NONE;
71 else if (value.Str() == "hintslight")
72 style = CAIRO_HINT_STYLE_SLIGHT;
73 else if (value.Str() == "hintmedium")
74 style = CAIRO_HINT_STYLE_MEDIUM;
75 else if (value.Str() == "hintfull")
76 style = CAIRO_HINT_STYLE_FULL;
77
78 cairo_font_options_set_hint_style(font_options, style);
79 }
80
81 // FIXME: Where do we read this value from?
82 cairo_font_options_set_hint_metrics(font_options, CAIRO_HINT_METRICS_ON);
83
84 gdk_screen_set_font_options(gdk_screen_get_default(), font_options);
85 cairo_font_options_destroy(font_options);
86}
87
88}
089
=== added file 'plugins/unityshell/src/FontSettings.h'
--- plugins/unityshell/src/FontSettings.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/FontSettings.h 2011-08-24 12:31:11 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#ifndef UNITY_FONT_SETTINGS_H_
20#define UNITY_FONT_SETTINGS_H_
21
22#include <gtk/gtk.h>
23
24#include <UnityCore/GLibSignal.h>
25
26namespace unity
27{
28
29class FontSettings
30{
31public:
32 FontSettings();
33
34private:
35 void Refresh(GtkSettings* unused0=nullptr, GParamSpec* unused1=nullptr);
36
37private:
38 glib::SignalManager sig_man_;
39};
40
41}
42
43#endif
044
=== modified file 'plugins/unityshell/src/HomeView.cpp'
--- plugins/unityshell/src/HomeView.cpp 2011-08-11 16:04:49 +0000
+++ plugins/unityshell/src/HomeView.cpp 2011-08-24 12:31:11 +0000
@@ -39,6 +39,7 @@
39NUX_IMPLEMENT_OBJECT_TYPE(HomeView);39NUX_IMPLEMENT_OBJECT_TYPE(HomeView);
4040
41HomeView::HomeView()41HomeView::HomeView()
42 : fix_renderering_id_(0)
42{43{
43 SetupViews();44 SetupViews();
4445
@@ -52,11 +53,17 @@
52 group->SetVisible(search != "" && counts_[group]);53 group->SetVisible(search != "" && counts_[group]);
53 }54 }
54 home_view_->SetVisible(search == "");55 home_view_->SetVisible(search == "");
56 scroll_view_->SetVisible(search != "");
57
58 QueueDraw();
55 });59 });
56}60}
5761
58HomeView::~HomeView()62HomeView::~HomeView()
59{}63{
64 if (fix_renderering_id_)
65 g_source_remove(fix_renderering_id_);
66}
6067
61void HomeView::SetupViews()68void HomeView::SetupViews()
62{69{
@@ -65,13 +72,14 @@
65 scroll_view_ = new nux::ScrollView();72 scroll_view_ = new nux::ScrollView();
66 scroll_view_->EnableVerticalScrollBar(true);73 scroll_view_->EnableVerticalScrollBar(true);
67 scroll_view_->EnableHorizontalScrollBar(false);74 scroll_view_->EnableHorizontalScrollBar(false);
75 scroll_view_->SetVisible(false);
68 layout_->AddView(scroll_view_);76 layout_->AddView(scroll_view_);
69 77
70 scroll_layout_ = new nux::VLayout();78 scroll_layout_ = new nux::VLayout();
71 scroll_view_->SetLayout(scroll_layout_);79 scroll_view_->SetLayout(scroll_layout_);
7280
73 home_view_ = new PlacesHomeView();81 home_view_ = new PlacesHomeView();
74 scroll_layout_->AddView(home_view_);82 layout_->AddView(home_view_);
7583
76 SetLayout(layout_);84 SetLayout(layout_);
77}85}
@@ -124,6 +132,8 @@
124 PlacesStyle* style = PlacesStyle::GetDefault();132 PlacesStyle* style = PlacesStyle::GetDefault();
125 group->SetCounts(style->GetDefaultNColumns(), counts_[group]);133 group->SetCounts(style->GetDefaultNColumns(), counts_[group]);
126 group->SetVisible(counts_[group]);134 group->SetVisible(counts_[group]);
135
136 QueueFixRenderering();
127}137}
128138
129void HomeView::OnGroupExpanded(PlacesGroup* group)139void HomeView::OnGroupExpanded(PlacesGroup* group)
@@ -143,6 +153,34 @@
143 }153 }
144}154}
145155
156void HomeView::QueueFixRenderering()
157{
158 if (fix_renderering_id_)
159 return;
160
161 fix_renderering_id_ = g_timeout_add(0, (GSourceFunc)FixRenderering, this);
162}
163
164gboolean HomeView::FixRenderering(HomeView* self)
165{
166 std::list<Area*> children = self->scroll_layout_->GetChildren();
167 std::list<Area*>::reverse_iterator rit;
168 bool found_one = false;
169
170 for (rit = children.rbegin(); rit != children.rend(); ++rit)
171 {
172 PlacesGroup* group = static_cast<PlacesGroup*>(*rit);
173
174 if (group->IsVisible())
175 group->SetDrawSeparator(found_one);
176
177 found_one = group->IsVisible();
178 }
179
180 self->fix_renderering_id_ = 0;
181 return FALSE;
182}
183
146long HomeView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)184long HomeView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)
147{185{
148 return layout_->ProcessEvent(ievent, traverse_info, event_info);186 return layout_->ProcessEvent(ievent, traverse_info, event_info);
149187
=== modified file 'plugins/unityshell/src/HomeView.h'
--- plugins/unityshell/src/HomeView.h 2011-08-11 01:12:21 +0000
+++ plugins/unityshell/src/HomeView.h 2011-08-24 12:31:11 +0000
@@ -60,6 +60,9 @@
60 void UpdateCounts(PlacesGroup* group);60 void UpdateCounts(PlacesGroup* group);
61 void OnGroupExpanded(PlacesGroup* group);61 void OnGroupExpanded(PlacesGroup* group);
62 void OnColumnsChanged();62 void OnColumnsChanged();
63 void QueueFixRenderering();
64
65 static gboolean FixRenderering(HomeView* self);
6366
64 long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info);67 long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info);
65 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);68 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
@@ -80,6 +83,8 @@
80 nux::VLayout* scroll_layout_;83 nux::VLayout* scroll_layout_;
8184
82 PlacesHomeView* home_view_;85 PlacesHomeView* home_view_;
86
87 guint fix_renderering_id_;
83};88};
8489
8590
8691
=== modified file 'plugins/unityshell/src/IconTexture.cpp'
--- plugins/unityshell/src/IconTexture.cpp 2011-08-02 13:37:01 +0000
+++ plugins/unityshell/src/IconTexture.cpp 2011-08-24 12:31:11 +0000
@@ -250,6 +250,11 @@
250 _texture_cached->Reference();250 _texture_cached->Reference();
251}251}
252252
253nux::BaseTexture* IconTexture::texture() const
254{
255 return _texture_cached;
256}
257
253bool258bool
254IconTexture::DoCanFocus()259IconTexture::DoCanFocus()
255{260{
256261
=== modified file 'plugins/unityshell/src/IconTexture.h'
--- plugins/unityshell/src/IconTexture.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/IconTexture.h 2011-08-24 12:31:11 +0000
@@ -45,6 +45,8 @@
4545
46 void SetAcceptKeyNavFocus(bool accept);46 void SetAcceptKeyNavFocus(bool accept);
4747
48 nux::BaseTexture* texture() const;
49
48protected:50protected:
49 // Key navigation51 // Key navigation
50 virtual bool AcceptKeyNavFocus();52 virtual bool AcceptKeyNavFocus();
@@ -54,9 +56,9 @@
54 void AddProperties(GVariantBuilder* builder);56 void AddProperties(GVariantBuilder* builder);
55 virtual bool DoCanFocus();57 virtual bool DoCanFocus();
5658
59protected:
60 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
57private:61private:
58 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
59
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);
61 void Refresh(GdkPixbuf* pixbuf);63 void Refresh(GdkPixbuf* pixbuf);
62 void IconLoaded(const char* icon_name, guint size, GdkPixbuf* pixbuf);64 void IconLoaded(const char* icon_name, guint size, GdkPixbuf* pixbuf);
6365
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2011-08-23 23:23:47 +0000
+++ plugins/unityshell/src/Launcher.cpp 2011-08-24 12:31:11 +0000
@@ -1385,7 +1385,9 @@
13851385
1386 // it's a tap on super and we didn't use any shortcuts1386 // it's a tap on super and we didn't use any shortcuts
1387 if (TapOnSuper() && !_latest_shortcut)1387 if (TapOnSuper() && !_latest_shortcut)
1388 ubus_server_send_message(ubus_server_get_default(), UBUS_DASH_EXTERNAL_ACTIVATION, NULL);1388 ubus_server_send_message(ubus_server_get_default(),
1389 UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
1390 g_variant_new("(sus)", "home.lens", 0, ""));
13891391
1390 remaining_time_before_hide = BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION - CLAMP((int)(TimeDelta(&current, &_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(&current, &_times[TIME_SUPER_PRESSED])), 0, BEFORE_HIDE_LAUNCHER_ON_SUPER_DURATION);
13911393
13921394
=== modified file 'plugins/unityshell/src/LensBar.cpp'
--- plugins/unityshell/src/LensBar.cpp 2011-08-18 15:42:39 +0000
+++ plugins/unityshell/src/LensBar.cpp 2011-08-24 12:31:11 +0000
@@ -38,24 +38,8 @@
38 : nux::View(NUX_TRACKER_LOCATION)38 : nux::View(NUX_TRACKER_LOCATION)
39{39{
40 SetupBackground();40 SetupBackground();
4141 SetupLayout();
42 layout_ = new nux::HLayout();42 SetupHomeLens();
43 layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
44 layout_->SetHorizontalInternalMargin(24);
45 SetLayout(layout_);
46
47 SetMinimumHeight(40);
48 SetMaximumHeight(40);
49
50 {
51 std::string id = "home";
52 IconTexture* icon = new IconTexture(PKGDATADIR"/lens-nav-home.svg", 26);
53 icon->SetMinMaxSize(26, 26);
54 icon->SetVisible(true);
55 layout_->AddView(icon, 0, nux::eCenter, nux::eFix);
56
57 icon->mouse_click.connect([&, id] (int x, int y, unsigned long button, unsigned long keyboard) { lens_activated.emit(id); });
58 }
59}43}
6044
61LensBar::~LensBar()45LensBar::~LensBar()
@@ -70,18 +54,49 @@
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);
71}55}
7256
57void LensBar::SetupLayout()
58{
59 layout_ = new nux::HLayout();
60 layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
61 layout_->SetHorizontalInternalMargin(32);
62 SetLayout(layout_);
63
64 SetMinimumHeight(40);
65 SetMaximumHeight(40);
66}
67
68void LensBar::SetupHomeLens()
69{
70 LensBarIcon* icon = new LensBarIcon("home.lens", PKGDATADIR"/lens-nav-home.svg");
71 icon->SetVisible(true);
72 icon->active = true;
73 icons_.push_back(icon);
74 layout_->AddView(icon, 0, nux::eCenter, nux::MINOR_SIZE_FULL);
75
76 icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); });
77}
78
73void LensBar::AddLens(Lens::Ptr& lens)79void LensBar::AddLens(Lens::Ptr& lens)
74{80{
75 std::string id = lens->id;81 LensBarIcon* icon = new LensBarIcon(lens->id, lens->icon_hint);
76 std::string icon_hint = lens->icon_hint;
77
78 IconTexture* icon = new IconTexture(icon_hint.c_str(), 26);
79 icon->SetMinMaxSize(26, 26);
80 icon->SetVisible(lens->visible);82 icon->SetVisible(lens->visible);
81 lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } );83 lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } );
84 icons_.push_back(icon);
82 layout_->AddView(icon, 0, nux::eCenter, nux::eFix);85 layout_->AddView(icon, 0, nux::eCenter, nux::eFix);
8386
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); });
88}
89
90void LensBar::Activate(std::string id)
91{
92 for (auto icon: icons_)
93 {
94 if (icon->id == id)
95 {
96 SetActive(icon);
97 break;
98 }
99 }
85}100}
86101
87long LensBar::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)102long LensBar::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)
@@ -109,12 +124,20 @@
109 nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_);124 nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_);
110 125
111 layout_->ProcessDraw(gfx_context, force_draw);126 layout_->ProcessDraw(gfx_context, force_draw);
112 127
113 nux::GetPainter().PopBackground();128 nux::GetPainter().PopBackground();
114 129
115 gfx_context.PopClippingRectangle();130 gfx_context.PopClippingRectangle();
116}131}
117132
133void LensBar::SetActive(LensBarIcon* activated)
134{
135 for (auto icon: icons_)
136 icon->active = icon == activated;
137
138 lens_activated.emit(activated->id);
139}
140
118// Keyboard navigation141// Keyboard navigation
119bool LensBar::AcceptKeyNavFocus()142bool LensBar::AcceptKeyNavFocus()
120{143{
121144
=== modified file 'plugins/unityshell/src/LensBar.h'
--- plugins/unityshell/src/LensBar.h 2011-08-18 15:42:39 +0000
+++ plugins/unityshell/src/LensBar.h 2011-08-24 12:31:11 +0000
@@ -20,6 +20,7 @@
20#define UNITY_LENS_BAR_H_20#define UNITY_LENS_BAR_H_
2121
22#include <string>22#include <string>
23#include <vector>
2324
24#include <NuxGraphics/GraphicsEngine.h>25#include <NuxGraphics/GraphicsEngine.h>
25#include <Nux/Nux.h>26#include <Nux/Nux.h>
@@ -29,36 +30,45 @@
2930
30#include "IconTexture.h"31#include "IconTexture.h"
31#include "Introspectable.h"32#include "Introspectable.h"
33#include "LensBarIcon.h"
3234
33namespace unity35namespace unity
34{36{
35namespace dash37namespace dash
36{38{
3739
38class LensBar : public nux::View, public unity::Introspectable40 class LensBar : public nux::View, public unity::Introspectable
39{41{
40 NUX_DECLARE_OBJECT_TYPE(LensBar, nux::View);42 NUX_DECLARE_OBJECT_TYPE(LensBar, nux::View);
43 typedef std::vector<LensBarIcon*> LensIcons;
4144
42public:45public:
43 LensBar();46 LensBar();
44 ~LensBar();47 ~LensBar();
4548
46 void AddLens(Lens::Ptr& lens);49 void AddLens(Lens::Ptr& lens);
50 void Activate(std::string id);
4751
48 sigc::signal<void, std::string const&> lens_activated;52 sigc::signal<void, std::string const&> lens_activated;
4953
50private:54private:
51 void SetupBackground();55 void SetupBackground();
56 void SetupLayout();
57 void SetupHomeLens();
5258
53 long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info);59 long ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info);
54 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);60 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
55 void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);61 void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
5662
63 void SetActive(LensBarIcon* icon);
64
57 bool AcceptKeyNavFocus();65 bool AcceptKeyNavFocus();
58 const gchar* GetName();66 const gchar* GetName();
59 void AddProperties(GVariantBuilder* builder);67 void AddProperties(GVariantBuilder* builder);
6068
61private:69private:
70 LensIcons icons_;
71
62 nux::ColorLayer* bg_layer_;72 nux::ColorLayer* bg_layer_;
63 nux::HLayout* layout_;73 nux::HLayout* layout_;
64};74};
6575
=== added file 'plugins/unityshell/src/LensBarIcon.cpp'
--- plugins/unityshell/src/LensBarIcon.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/LensBarIcon.cpp 2011-08-24 12:31:11 +0000
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#include "LensBarIcon.h"
20
21#include "config.h"
22
23namespace unity
24{
25namespace dash
26{
27
28NUX_IMPLEMENT_OBJECT_TYPE(LensBarIcon);
29
30LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint)
31 : IconTexture(icon_hint.c_str(), 26)
32 , id(id_)
33 , active(false)
34 , inactive_opacity_(0.4f)
35{
36 SetMinimumWidth(26);
37 SetMaximumWidth(26);
38 SetMinimumHeight(40);
39 SetMaximumHeight(40);
40 SetOpacity(inactive_opacity_);
41
42 active.changed.connect(sigc::mem_fun(this, &LensBarIcon::OnActiveChanged));
43 mouse_enter.connect([&]
44(int, int, unsigned long, unsigned long) { QueueDraw(); });
45 mouse_leave.connect([&](int, int, unsigned long, unsigned long) { QueueDraw(); });
46}
47
48LensBarIcon::~LensBarIcon()
49{}
50
51void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
52{
53 nux::Geometry geo = GetGeometry();
54
55 gfx_context.PushClippingRectangle(geo);
56
57 nux::GetPainter().PaintBackground(gfx_context, geo);
58
59 if (!texture())
60 return;
61
62 float opacity = active || IsMouseInside() ? 1.0f : inactive_opacity_;
63 int width = 0, height = 0;
64 GetTextureSize(&width, &height);
65
66 nux::Color col(1.0f * opacity, 1.0f * opacity, 1.0f * opacity, opacity);
67 nux::TexCoordXForm texxform;
68 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
69 texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
70
71 gfx_context.QRP_1Tex(geo.x + ((geo.width - width) / 2),
72 geo.y + ((geo.height - height) / 2),
73 width,
74 height,
75 texture()->GetDeviceTexture(),
76 texxform,
77 col);
78 if (active)
79 {
80 nux::Geometry geo = GetGeometry();
81 int middle = geo.x + geo.width/2;
82 int size = 4;
83 int y = geo.y + 1;
84
85 nux::GetPainter().Draw2DTriangleColor(gfx_context,
86 middle - size, y,
87 middle, y + size,
88 middle + size, y,
89 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
90 }
91
92 gfx_context.PopClippingRectangle();
93}
94
95void LensBarIcon::OnActiveChanged(bool is_active)
96{
97 QueueDraw();
98}
99
100}
101}
0102
=== added file 'plugins/unityshell/src/LensBarIcon.h'
--- plugins/unityshell/src/LensBarIcon.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/LensBarIcon.h 2011-08-24 12:31:11 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#ifndef UNITY_LENS_BAR_ICON_H_
20#define UNITY_LENS_BAR_ICON_H_
21
22#include <string>
23
24#include <NuxGraphics/GraphicsEngine.h>
25#include <Nux/Nux.h>
26#include <Nux/HLayout.h>
27#include <Nux/View.h>
28
29#include "IconTexture.h"
30
31namespace unity
32{
33namespace dash
34{
35
36class LensBarIcon : public IconTexture
37{
38 NUX_DECLARE_OBJECT_TYPE(LensBarIcon, IconTexture);
39public:
40 LensBarIcon(std::string id, std::string icon_hint);
41 ~LensBarIcon();
42
43 nux::Property<std::string> id;
44 nux::Property<bool> active;
45
46private:
47 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
48 void OnActiveChanged(bool is_active);
49
50private:
51 const float inactive_opacity_;
52};
53
54}
55}
56#endif
057
=== modified file 'plugins/unityshell/src/LensView.cpp'
--- plugins/unityshell/src/LensView.cpp 2011-08-11 01:11:11 +0000
+++ plugins/unityshell/src/LensView.cpp 2011-08-24 12:31:11 +0000
@@ -42,6 +42,7 @@
42 : nux::View(NUX_TRACKER_LOCATION)42 : nux::View(NUX_TRACKER_LOCATION)
43 , search_string("")43 , search_string("")
44 , filters_expanded(false)44 , filters_expanded(false)
45 , fix_renderering_id_(0)
45{}46{}
4647
47LensView::LensView(Lens::Ptr lens)48LensView::LensView(Lens::Ptr lens)
@@ -49,28 +50,27 @@
49 , search_string("")50 , search_string("")
50 , filters_expanded(false)51 , filters_expanded(false)
51 , lens_(lens)52 , lens_(lens)
53 , initial_activation_(true)
54 , fix_renderering_id_(0)
52{55{
53 SetupViews();56 SetupViews();
5457 SetupCategories();
55 Categories::Ptr categories = lens_->categories;58 SetupResults();
56 categories->category_added.connect(sigc::mem_fun(this, &LensView::OnCategoryAdded));59 SetupFilters();
5760
58 Results::Ptr results = lens_->results;61 PlacesStyle::GetDefault()->columns_changed.connect(sigc::mem_fun(this, &LensView::OnColumnsChanged));
59 results->result_added.connect(sigc::mem_fun(this, &LensView::OnResultAdded));62
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; });
61
62 Filters::Ptr filters = lens_->filters;
63 filters->filter_added.connect(sigc::mem_fun(this, &LensView::OnFilterAdded));
64 filters->filter_removed.connect(sigc::mem_fun(this, &LensView::OnFilterRemoved));
65
66 PlacesStyle::GetDefault()->columns_changed.connect(sigc::mem_fun(this, &LensView::OnColumnsChanged));
67
68 search_string.changed.connect([&](std::string const& search) { lens_->Search(search); });64 search_string.changed.connect([&](std::string const& search) { lens_->Search(search); });
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(); });
66 active.changed.connect(sigc::mem_fun(this, &LensView::OnActiveChanged));
70}67}
7168
72LensView::~LensView()69LensView::~LensView()
73{}70{
71 if (fix_renderering_id_)
72 g_source_remove(fix_renderering_id_);
73}
7474
75void LensView::SetupViews()75void LensView::SetupViews()
76{76{
@@ -100,6 +100,35 @@
100 SetLayout(layout_);100 SetLayout(layout_);
101}101}
102102
103void LensView::SetupCategories()
104{
105 Categories::Ptr categories = lens_->categories;
106 categories->category_added.connect(sigc::mem_fun(this, &LensView::OnCategoryAdded));
107
108 for (unsigned int i = 0; i < categories->count(); ++i)
109 OnCategoryAdded(categories->RowAtIndex(i));
110}
111
112void LensView::SetupResults()
113{
114 Results::Ptr results = lens_->results;
115 results->result_added.connect(sigc::mem_fun(this, &LensView::OnResultAdded));
116 results->result_removed.connect(sigc::mem_fun(this, &LensView::OnResultRemoved));
117
118 for (unsigned int i = 0; i < results->count(); ++i)
119 OnResultAdded(results->RowAtIndex(i));
120}
121
122void LensView::SetupFilters()
123{
124 Filters::Ptr filters = lens_->filters;
125 filters->filter_added.connect(sigc::mem_fun(this, &LensView::OnFilterAdded));
126 filters->filter_removed.connect(sigc::mem_fun(this, &LensView::OnFilterRemoved));
127
128 for (unsigned int i = 0; i < filters->count(); ++i)
129 OnFilterAdded(filters->FilterAtIndex(i));
130}
131
103void LensView::OnCategoryAdded(Category const& category)132void LensView::OnCategoryAdded(Category const& category)
104{133{
105 std::string name = category.name;134 std::string name = category.name;
@@ -128,6 +157,13 @@
128 group->SetChildView(grid);157 group->SetChildView(grid);
129158
130 scroll_layout_->AddView(group, 0);159 scroll_layout_->AddView(group, 0);
160
161 Categories::Ptr categories = lens_->categories;
162 if (category.index + 1 == categories->count())
163 {
164 lens_->Search("---");
165 lens_->Search("");
166 }
131}167}
132168
133void LensView::OnResultAdded(Result const& result)169void LensView::OnResultAdded(Result const& result)
@@ -162,6 +198,36 @@
162198
163 group->SetCounts(style->GetDefaultNColumns(), counts_[group]);199 group->SetCounts(style->GetDefaultNColumns(), counts_[group]);
164 group->SetVisible(counts_[group]);200 group->SetVisible(counts_[group]);
201
202 QueueFixRenderering();
203}
204
205void LensView::QueueFixRenderering()
206{
207 if (fix_renderering_id_)
208 return;
209
210 fix_renderering_id_ = g_timeout_add(0, (GSourceFunc)FixRenderering, this);
211}
212
213gboolean LensView::FixRenderering(LensView* self)
214{
215 std::list<Area*> children = self->scroll_layout_->GetChildren();
216 std::list<Area*>::reverse_iterator rit;
217 bool found_one = false;
218
219 for (rit = children.rbegin(); rit != children.rend(); ++rit)
220 {
221 PlacesGroup* group = static_cast<PlacesGroup*>(*rit);
222
223 if (group->IsVisible())
224 group->SetDrawSeparator(found_one);
225
226 found_one = group->IsVisible();
227 }
228
229 self->fix_renderering_id_ = 0;
230 return FALSE;
165}231}
166232
167void LensView::OnGroupExpanded(PlacesGroup* group)233void LensView::OnGroupExpanded(PlacesGroup* group)
@@ -196,6 +262,18 @@
196 filter_bar_->RemoveFilter(filter);262 filter_bar_->RemoveFilter(filter);
197}263}
198264
265void LensView::OnActiveChanged(bool is_active)
266{
267 if (is_active && initial_activation_)
268 {
269 /* We reset the lens for ourselves, in case this is a restart or something */
270 lens_->Search("");
271 initial_activation_ = false;
272 }
273
274 lens_->active = is_active;
275}
276
199long LensView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)277long LensView::ProcessEvent(nux::IEvent& ievent, long traverse_info, long event_info)
200{278{
201 return layout_->ProcessEvent(ievent, traverse_info, event_info);279 return layout_->ProcessEvent(ievent, traverse_info, event_info);
202280
=== modified file 'plugins/unityshell/src/LensView.h'
--- plugins/unityshell/src/LensView.h 2011-08-11 00:56:53 +0000
+++ plugins/unityshell/src/LensView.h 2011-08-24 12:31:11 +0000
@@ -54,11 +54,15 @@
5454
55 nux::Property<std::string> search_string;55 nux::Property<std::string> search_string;
56 nux::Property<bool> filters_expanded;56 nux::Property<bool> filters_expanded;
57 nux::Property<bool> active;
5758
58 sigc::signal<void, std::string const&> uri_activated;59 sigc::signal<void, std::string const&> uri_activated;
5960
60private:61private:
61 void SetupViews();62 void SetupViews();
63 void SetupCategories();
64 void SetupResults();
65 void SetupFilters();
6266
63 void OnCategoryAdded(Category const& category);67 void OnCategoryAdded(Category const& category);
64 void OnResultAdded(Result const& result);68 void OnResultAdded(Result const& result);
@@ -68,6 +72,10 @@
68 void OnColumnsChanged();72 void OnColumnsChanged();
69 void OnFilterAdded(Filter::Ptr filter);73 void OnFilterAdded(Filter::Ptr filter);
70 void OnFilterRemoved(Filter::Ptr filter);74 void OnFilterRemoved(Filter::Ptr filter);
75 void OnActiveChanged(bool is_active);
76 void QueueFixRenderering();
77
78 static gboolean FixRenderering(LensView* self);
7179
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);
73 virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);81 virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
@@ -82,6 +90,7 @@
82 Lens::Ptr lens_;90 Lens::Ptr lens_;
83 CategoryGroups categories_;91 CategoryGroups categories_;
84 ResultCounts counts_;92 ResultCounts counts_;
93 bool initial_activation_;
8594
86 nux::HLayout* layout_;95 nux::HLayout* layout_;
87 nux::ScrollView* scroll_view_;96 nux::ScrollView* scroll_view_;
@@ -89,6 +98,8 @@
89 nux::ScrollView* fscroll_view_;98 nux::ScrollView* fscroll_view_;
90 nux::VLayout* fscroll_layout_;99 nux::VLayout* fscroll_layout_;
91 FilterBar* filter_bar_;100 FilterBar* filter_bar_;
101
102 guint fix_renderering_id_;
92};103};
93104
94105
95106
=== modified file 'plugins/unityshell/src/PlacesGroup.cpp'
--- plugins/unityshell/src/PlacesGroup.cpp 2011-08-19 15:17:30 +0000
+++ plugins/unityshell/src/PlacesGroup.cpp 2011-08-24 12:31:11 +0000
@@ -144,7 +144,7 @@
144{144{
145 // Spaces are on purpose, want padding to be proportional to the size of the text145 // Spaces are on purpose, want padding to be proportional to the size of the text
146 // Bear with me, I'm trying something different :)146 // Bear with me, I'm trying something different :)
147 const gchar* temp = " <big>%s</big> ";147 const gchar* temp = " <span font_size='larger'>%s</span> ";
148 gchar* tmp = NULL;148 gchar* tmp = NULL;
149 gchar* final = NULL;149 gchar* final = NULL;
150 if (_cached_name != NULL)150 if (_cached_name != NULL)
151151
=== modified file 'plugins/unityshell/src/PlacesStyle.cpp'
--- plugins/unityshell/src/PlacesStyle.cpp 2011-08-09 17:27:39 +0000
+++ plugins/unityshell/src/PlacesStyle.cpp 2011-08-24 12:31:11 +0000
@@ -143,6 +143,10 @@
143 return GetHomeTileIconSize() + (_text_height * 4);143 return GetHomeTileIconSize() + (_text_height * 4);
144}144}
145145
146int PlacesStyle::GetTextLineHeight()
147{
148 return _text_height;
149}
146150
147nux::BaseTexture* PlacesStyle::GetDashBottomTile()151nux::BaseTexture* PlacesStyle::GetDashBottomTile()
148{152{
149153
=== modified file 'plugins/unityshell/src/PlacesStyle.h'
--- plugins/unityshell/src/PlacesStyle.h 2011-08-09 17:27:39 +0000
+++ plugins/unityshell/src/PlacesStyle.h 2011-08-24 12:31:11 +0000
@@ -45,6 +45,8 @@
45 int GetHomeTileWidth();45 int GetHomeTileWidth();
46 int GetHomeTileHeight();46 int GetHomeTileHeight();
4747
48 int GetTextLineHeight();
49
48 nux::BaseTexture* GetDashBottomTile();50 nux::BaseTexture* GetDashBottomTile();
49 nux::BaseTexture* GetDashRightTile();51 nux::BaseTexture* GetDashRightTile();
50 nux::BaseTexture* GetDashCorner();52 nux::BaseTexture* GetDashCorner();
5153
=== modified file 'plugins/unityshell/src/ResultRendererTile.cpp'
--- plugins/unityshell/src/ResultRendererTile.cpp 2011-08-18 09:14:53 +0000
+++ plugins/unityshell/src/ResultRendererTile.cpp 2011-08-24 12:31:11 +0000
@@ -27,6 +27,8 @@
27#include <gdk/gdk.h>27#include <gdk/gdk.h>
28#include <gtk/gtk.h>28#include <gtk/gtk.h>
2929
30#include <UnityCore/GLibWrapper.h>
31
30#include "IconLoader.h"32#include "IconLoader.h"
31#include "IconTexture.h"33#include "IconTexture.h"
32#include "PlacesStyle.h"34#include "PlacesStyle.h"
@@ -410,26 +412,34 @@
410412
411 PangoLayout* layout = NULL;413 PangoLayout* layout = NULL;
412 PangoFontDescription* desc = NULL;414 PangoFontDescription* desc = NULL;
413 PangoContext* pangoCtx = NULL;415 PangoContext* pango_context = NULL;
414 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed416 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
415417 glib::String font;
418 int dpi = -1;
419
420 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font, NULL);
421 g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, NULL);
416422
417 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));423 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
418 layout = pango_cairo_create_layout(cr);424 layout = pango_cairo_create_layout(cr);
419 desc = pango_font_description_from_string("Ubuntu 10");425 desc = pango_font_description_from_string(font.Value());
420426
421 pango_layout_set_font_description(layout, desc);427 pango_layout_set_font_description(layout, desc);
422
423 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);428 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
429
430 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
431 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START);
432 pango_layout_set_width(layout, (style->GetTileWidth() - 12)* PANGO_SCALE);
433 pango_layout_set_height(layout, -2);
434
424 pango_layout_set_markup(layout, text.c_str(), -1);435 pango_layout_set_markup(layout, text.c_str(), -1);
425 pango_layout_set_width(layout, (style->GetTileWidth() - 12)* PANGO_SCALE);436
426437 pango_context = pango_layout_get_context(layout); // is not ref'ed
427 pango_layout_set_height(layout, 2);438 pango_cairo_context_set_font_options(pango_context,
428 pangoCtx = pango_layout_get_context(layout); // is not ref'ed
429 pango_cairo_context_set_font_options(pangoCtx,
430 gdk_screen_get_font_options(screen));439 gdk_screen_get_font_options(screen));
431 // use some default DPI-value440 pango_cairo_context_set_resolution(pango_context,
432 pango_cairo_context_set_resolution(pangoCtx, 96.0f);441 dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE);
442 pango_layout_context_changed(layout);
433443
434 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);444 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
435 cairo_paint(cr);445 cairo_paint(cr);
@@ -437,8 +447,6 @@
437 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);447 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
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);
439449
440 pango_layout_context_changed(layout);
441
442 cairo_move_to(cr, 0.0f, 0.0f);450 cairo_move_to(cr, 0.0f, 0.0f);
443 pango_cairo_show_layout(cr, layout);451 pango_cairo_show_layout(cr, layout);
444452
445453
=== modified file 'plugins/unityshell/src/StaticCairoText.cpp'
--- plugins/unityshell/src/StaticCairoText.cpp 2011-08-05 15:17:12 +0000
+++ plugins/unityshell/src/StaticCairoText.cpp 2011-08-24 12:31:11 +0000
@@ -320,6 +320,7 @@
320 surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1, 1);320 surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1, 1);
321 cr = cairo_create(surface);321 cr = cairo_create(surface);
322 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));322 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
323
323 layout = pango_cairo_create_layout(cr);324 layout = pango_cairo_create_layout(cr);
324 desc = pango_font_description_from_string(font);325 desc = pango_font_description_from_string(font);
325 pango_layout_set_font_description(layout, desc);326 pango_layout_set_font_description(layout, desc);
326327
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2011-08-24 02:25:07 +0000
+++ plugins/unityshell/src/unityshell.cpp 2011-08-24 12:31:11 +0000
@@ -1371,6 +1371,7 @@
1371 gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect);1371 gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect);
1372 _primary_monitor = rect;1372 _primary_monitor = rect;
13731373
1374
1374 wt->SetWindowSize(rect.width, rect.height);1375 wt->SetWindowSize(rect.width, rect.height);
13751376
1376 lCurGeom = launcherWindow->GetGeometry();1377 lCurGeom = launcherWindow->GetGeometry();
13771378
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2011-08-22 03:06:14 +0000
+++ plugins/unityshell/src/unityshell.h 2011-08-24 12:31:11 +0000
@@ -31,6 +31,7 @@
3131
32#include "Introspectable.h"32#include "Introspectable.h"
33#include "DashController.h"33#include "DashController.h"
34#include "FontSettings.h"
34#include "Launcher.h"35#include "Launcher.h"
35#include "LauncherController.h"36#include "LauncherController.h"
36#include "PanelController.h"37#include "PanelController.h"
@@ -77,6 +78,7 @@
7778
78#include <compiztoolbox/compiztoolbox.h>79#include <compiztoolbox/compiztoolbox.h>
7980
81using unity::FontSettings;
80using namespace unity::switcher;82using namespace unity::switcher;
81using namespace unity::dash;83using namespace unity::dash;
82using unity::UBusManager;84using unity::UBusManager;
@@ -208,6 +210,7 @@
208 static void OnLauncherStartKeyNav(GVariant* data, void* value);210 static void OnLauncherStartKeyNav(GVariant* data, void* value);
209 static void OnLauncherEndKeyNav(GVariant* data, void* value);211 static void OnLauncherEndKeyNav(GVariant* data, void* value);
210212
213 FontSettings font_settings_;
211 Launcher* launcher;214 Launcher* launcher;
212 LauncherController* controller;215 LauncherController* controller;
213 DashController::Ptr dashController;216 DashController::Ptr dashController;
214217
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2011-08-16 11:34:48 +0000
+++ tests/CMakeLists.txt 2011-08-24 12:31:11 +0000
@@ -95,6 +95,8 @@
95 ${UNITY_SRC}/FilterGenreButton.cpp95 ${UNITY_SRC}/FilterGenreButton.cpp
96 ${UNITY_SRC}/FilterGenreWidget.cpp96 ${UNITY_SRC}/FilterGenreWidget.cpp
97 ${UNITY_SRC}/FilterBar.cpp97 ${UNITY_SRC}/FilterBar.cpp
98 ${UNITY_SRC}/FontSettings.cpp
99 ${UNITY_SRC}/FontSettings.h
98 ${UNITY_SRC}/IMTextEntry.cpp100 ${UNITY_SRC}/IMTextEntry.cpp
99 ${UNITY_SRC}/IMTextEntry.h101 ${UNITY_SRC}/IMTextEntry.h
100 ${UNITY_SRC}/PlacesHomeView.cpp102 ${UNITY_SRC}/PlacesHomeView.cpp
@@ -122,6 +124,8 @@
122 ${UNITY_SRC}/Introspectable.h124 ${UNITY_SRC}/Introspectable.h
123 ${UNITY_SRC}/LensBar.cpp125 ${UNITY_SRC}/LensBar.cpp
124 ${UNITY_SRC}/LensBar.h126 ${UNITY_SRC}/LensBar.h
127 ${UNITY_SRC}/LensBarIcon.cpp
128 ${UNITY_SRC}/LensBarIcon.h
125 ${UNITY_SRC}/LensView.cpp129 ${UNITY_SRC}/LensView.cpp
126 ${UNITY_SRC}/LensView.h130 ${UNITY_SRC}/LensView.h
127 ${UNITY_SRC}/PreviewApplications.cpp131 ${UNITY_SRC}/PreviewApplications.cpp
@@ -270,6 +274,8 @@
270 ${UNITY_SRC}/FilterMultiRangeButton.cpp274 ${UNITY_SRC}/FilterMultiRangeButton.cpp
271 ${UNITY_SRC}/FilterMultiRangeWidget.cpp275 ${UNITY_SRC}/FilterMultiRangeWidget.cpp
272 ${UNITY_SRC}/DashStyle.cpp276 ${UNITY_SRC}/DashStyle.cpp
277 ${UNITY_SRC}/PlacesStyle.cpp
278 ${UNITY_SRC}/PlacesStyle.h
273 )279 )
274add_dependencies(test-filters unity-core-${UNITY_API_VERSION})280add_dependencies(test-filters unity-core-${UNITY_API_VERSION})
275281
@@ -286,6 +292,8 @@
286 ${UNITY_SRC}/FilterGenreWidget.cpp292 ${UNITY_SRC}/FilterGenreWidget.cpp
287 ${UNITY_SRC}/FilterBar.cpp293 ${UNITY_SRC}/FilterBar.cpp
288 ${UNITY_SRC}/DashStyle.cpp294 ${UNITY_SRC}/DashStyle.cpp
295 ${UNITY_SRC}/PlacesStyle.cpp
296 ${UNITY_SRC}/PlacesStyle.h
289 )297 )
290add_dependencies(test-filter-bar unity-core-${UNITY_API_VERSION})298add_dependencies(test-filter-bar unity-core-${UNITY_API_VERSION})
291299
292300
=== modified file 'tests/standalone_dash.cpp'
--- tests/standalone_dash.cpp 2011-08-22 13:48:47 +0000
+++ tests/standalone_dash.cpp 2011-08-24 12:31:11 +0000
@@ -27,6 +27,7 @@
27#include <NuxCore/Logger.h>27#include <NuxCore/Logger.h>
2828
29#include "BGHash.h"29#include "BGHash.h"
30#include "FontSettings.h"
30#include "DashView.h"31#include "DashView.h"
31#include "PlacesSettings.h"32#include "PlacesSettings.h"
3233
@@ -91,6 +92,7 @@
91 gtk_init (&argc, &argv);92 gtk_init (&argc, &argv);
9293
93 unity::BGHash bghash;94 unity::BGHash bghash;
95 unity::FontSettings font_settings;
9496
95 nux::NuxInitialize(0);97 nux::NuxInitialize(0);
96 nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));98 nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));