Merge lp:~azzar1/unity/fix-841907 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2191
Proposed branch: lp:~azzar1/unity/fix-841907
Merge into: lp:unity
Diff against target: 348 lines (+45/-70)
7 files modified
plugins/unityshell/src/DashStyle.cpp (+1/-1)
plugins/unityshell/src/DashStyle.h (+0/-2)
plugins/unityshell/src/DashView.cpp (+5/-5)
plugins/unityshell/src/FilterBar.cpp (+1/-1)
plugins/unityshell/src/HudView.cpp (+4/-5)
plugins/unityshell/src/SearchBar.cpp (+32/-52)
plugins/unityshell/src/SearchBar.h (+2/-4)
To merge this branch: bzr merge lp:~azzar1/unity/fix-841907
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Andrea Cimitan (community) design Approve
Review via email: mp+99541@code.launchpad.net

Commit message

Makes the dash search entry horizontally extensible.

Description of the change

== Problem ==
The Dash search box should expand horizontally when the Dash switches to full screen mode

== Fix ==
Don't use a fixed width for the search bar but let's use nux layout sytem. I'd like to make the search entry a completely different widget but it's too late now.

== Test ==
Not applicable. It's a visual change and we just need design review.

== Screenshots ==
* http://ubuntuone.com/70SSXbKqoxAgsCBJIr93Am
* http://ubuntuone.com/4PPCiKC3JD1D9vmUJpDrVv
* http://ubuntuone.com/2ng5chy0faDhF3EYKgkxhr

To post a comment you must log in.
Revision history for this message
Omer Akram (om26er) wrote :

Aww man, I totally love u for this bug fix :-*

Revision history for this message
Andrea Cimitan (cimi) :
review: Approve (design)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Cool, looks good, works well.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashStyle.cpp'
2--- plugins/unityshell/src/DashStyle.cpp 2012-03-21 14:18:06 +0000
3+++ plugins/unityshell/src/DashStyle.cpp 2012-03-27 15:22:27 +0000
4@@ -2235,7 +2235,7 @@
5
6 int Style::GetSpaceBetweenLensAndFilters() const
7 {
8- return 9;
9+ return 10;
10 }
11
12 int Style::GetFilterViewRightPadding() const
13
14=== modified file 'plugins/unityshell/src/DashStyle.h'
15--- plugins/unityshell/src/DashStyle.h 2012-03-21 14:18:06 +0000
16+++ plugins/unityshell/src/DashStyle.h 2012-03-27 15:22:27 +0000
17@@ -228,8 +228,6 @@
18 int GetCategorySeparatorLeftPadding() const;
19 int GetCategorySeparatorRightPadding() const;
20
21- const static int SEARCH_BAR_EXTRA_PADDING = 1;
22-
23 sigc::signal<void> changed;
24
25 private:
26
27=== modified file 'plugins/unityshell/src/DashView.cpp'
28--- plugins/unityshell/src/DashView.cpp 2012-03-22 09:02:06 +0000
29+++ plugins/unityshell/src/DashView.cpp 2012-03-27 15:22:27 +0000
30@@ -176,17 +176,17 @@
31 SetLayout(layout_);
32
33 content_layout_ = new DashLayout(NUX_TRACKER_LOCATION);
34- content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding() - style.SEARCH_BAR_EXTRA_PADDING, 0);
35+ content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding(), 0);
36 layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
37
38 search_bar_layout_ = new nux::HLayout();
39- search_bar_layout_->SetLeftAndRightPadding(style.GetSearchBarLeftPadding() - style.SEARCH_BAR_EXTRA_PADDING, style.GetSearchBarLeftPadding() - style.GetFilterResultsHighlightRightPadding() - style.SEARCH_BAR_EXTRA_PADDING);
40+ search_bar_layout_->SetLeftAndRightPadding(style.GetSearchBarLeftPadding(), 0);
41 content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
42
43 search_bar_ = new SearchBar();
44 AddChild(search_bar_);
45- search_bar_->SetMinimumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
46- search_bar_->SetMaximumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
47+ search_bar_->SetMinimumHeight(style.GetSearchBarHeight());
48+ search_bar_->SetMaximumHeight(style.GetSearchBarHeight());
49 search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated));
50 search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged));
51 search_bar_->live_search_reached.connect(sigc::mem_fun(this, &DashView::OnLiveSearchReached));
52@@ -269,7 +269,7 @@
53
54 width = MAX(width, tile_width * 6);
55
56- width += 19 + 40; // add the left padding and the group plugin padding
57+ width += 20 + 40; // add the left padding and the group plugin padding
58
59 height = search_bar_->GetGeometry().height;
60 height += tile_height * 3;
61
62=== modified file 'plugins/unityshell/src/FilterBar.cpp'
63--- plugins/unityshell/src/FilterBar.cpp 2012-03-21 14:18:06 +0000
64+++ plugins/unityshell/src/FilterBar.cpp 2012-03-27 15:22:27 +0000
65@@ -60,7 +60,7 @@
66 dash::Style& style = dash::Style::Instance();
67
68 nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
69- layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding() - style.SEARCH_BAR_EXTRA_PADDING);
70+ layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding());
71 layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding());
72 SetLayout(layout);
73 }
74
75=== modified file 'plugins/unityshell/src/HudView.cpp'
76--- plugins/unityshell/src/HudView.cpp 2012-03-21 15:07:29 +0000
77+++ plugins/unityshell/src/HudView.cpp 2012-03-27 15:22:27 +0000
78@@ -333,7 +333,7 @@
79
80 namespace
81 {
82- const int top_spacing = 9;
83+ const int top_spacing = 11;
84 const int content_width = 941;
85 const int icon_vertical_margin = 5;
86 const int spacing_between_icon_and_content = 8;
87@@ -369,10 +369,9 @@
88 content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0);
89
90 // add the search bar to the composite
91- search_bar_ = new unity::SearchBar(content_width, true);
92- search_bar_->disable_glow = true;
93- search_bar_->SetMinimumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
94- search_bar_->SetMaximumHeight(style.GetSearchBarHeight() + style.SEARCH_BAR_EXTRA_PADDING * 2);
95+ search_bar_ = new unity::SearchBar(true);
96+ search_bar_->SetMinimumHeight(style.GetSearchBarHeight());
97+ search_bar_->SetMaximumHeight(style.GetSearchBarHeight());
98 search_bar_->search_hint = default_text;
99 search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged));
100 AddChild(search_bar_.GetPointer());
101
102=== modified file 'plugins/unityshell/src/SearchBar.cpp'
103--- plugins/unityshell/src/SearchBar.cpp 2012-03-21 18:37:19 +0000
104+++ plugins/unityshell/src/SearchBar.cpp 2012-03-27 15:22:27 +0000
105@@ -50,7 +50,9 @@
106 const int SPINNER_TIMEOUT = 100;
107
108 const int SPACE_BETWEEN_SPINNER_AND_TEXT = 5;
109-const int LEFT_INTERNAL_PADDING = 7;
110+const int SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10;
111+const int LEFT_INTERNAL_PADDING = 6;
112+const int SEARCH_ENTRY_RIGHT_BORDER = 10;
113
114 const int HIGHLIGHT_HEIGHT = 24;
115
116@@ -121,42 +123,23 @@
117 , search_hint("")
118 , showing_filters(false)
119 , can_refine_search(false)
120- , disable_glow(false)
121 , show_filter_hint_(true)
122 , expander_view_(nullptr)
123 , show_filters_(nullptr)
124- , search_bar_width_(621)
125 , live_search_timeout_(0)
126 , start_spinner_timeout_(0)
127 {
128 Init();
129 }
130
131-SearchBar::SearchBar(int search_bar_width, bool show_filter_hint_, NUX_FILE_LINE_DECL)
132+SearchBar::SearchBar(bool show_filter_hint_, NUX_FILE_LINE_DECL)
133 : View(NUX_FILE_LINE_PARAM)
134 , search_hint("")
135 , showing_filters(false)
136 , can_refine_search(false)
137- , disable_glow(false)
138 , show_filter_hint_(show_filter_hint_)
139 , expander_view_(nullptr)
140 , show_filters_(nullptr)
141- , search_bar_width_(search_bar_width)
142- , live_search_timeout_(0)
143- , start_spinner_timeout_(0)
144-{
145- Init();
146-}
147-
148-SearchBar::SearchBar(int search_bar_width, NUX_FILE_LINE_DECL)
149- : View(NUX_FILE_LINE_PARAM)
150- , search_hint("")
151- , showing_filters(false)
152- , can_refine_search(false)
153- , disable_glow(false)
154- , show_filter_hint_(true)
155- , expander_view_(nullptr)
156- , search_bar_width_(search_bar_width)
157 , live_search_timeout_(0)
158 , start_spinner_timeout_(0)
159 {
160@@ -165,25 +148,30 @@
161
162 void SearchBar::Init()
163 {
164- nux::BaseTexture* icon = dash::Style::Instance().GetSearchMagnifyIcon();
165+ dash::Style& style = dash::Style::Instance();
166+ nux::BaseTexture* icon = style.GetSearchMagnifyIcon();
167
168 bg_layer_ = new nux::ColorLayer(nux::Color(0xff595853), true);
169
170 layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
171- layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING, 10);
172- layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_SPINNER_AND_TEXT);
173+ layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING, SEARCH_ENTRY_RIGHT_BORDER);
174+ layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT);
175 SetLayout(layout_);
176
177+ entry_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
178+ entry_layout_->SetLeftAndRightPadding(0, 10);
179+ layout_->AddLayout(entry_layout_);
180+
181 spinner_ = new SearchBarSpinner();
182 spinner_->SetMinMaxSize(icon->GetWidth(), icon->GetHeight());
183 spinner_->mouse_click.connect(sigc::mem_fun(this, &SearchBar::OnClearClicked));
184- layout_->AddView(spinner_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
185+ entry_layout_->AddView(spinner_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
186+ entry_layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_SPINNER_AND_TEXT);
187
188 nux::HLayout* hint_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
189
190 hint_ = new nux::StaticCairoText(" ");
191 hint_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
192- hint_->SetMaximumWidth(search_bar_width_ - icon->GetWidth());
193 hint_->SetFont(HINT_LABEL_DEFAULT_FONT.c_str());
194 hint_layout->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
195
196@@ -195,16 +183,13 @@
197 pango_entry_->cursor_moved.connect([&](int i) { QueueDraw(); });
198 pango_entry_->mouse_down.connect(sigc::mem_fun(this, &SearchBar::OnMouseButtonDown));
199 pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &SearchBar::OnEndKeyFocus));
200- pango_entry_->SetMaximumWidth(search_bar_width_ - 1.5 * icon->GetWidth());
201
202 layered_layout_ = new nux::LayeredLayout();
203 layered_layout_->AddLayout(hint_layout);
204 layered_layout_->AddLayer(pango_entry_);
205 layered_layout_->SetPaintAll(true);
206 layered_layout_->SetActiveLayerN(1);
207- layered_layout_->SetMinimumWidth(search_bar_width_);
208- layered_layout_->SetMaximumWidth(search_bar_width_);
209- layout_->AddView(layered_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
210+ entry_layout_->AddView(layered_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
211
212 if (show_filter_hint_)
213 {
214@@ -217,7 +202,7 @@
215 show_filters_->SetLines(1);
216
217 nux::BaseTexture* arrow;
218- arrow = dash::Style::Instance().GetGroupExpandIcon();
219+ arrow = style.GetGroupExpandIcon();
220 expand_icon_ = new IconTexture(arrow,
221 arrow->GetWidth(),
222 arrow->GetHeight());
223@@ -227,6 +212,8 @@
224
225 filter_layout_ = new nux::HLayout();
226 filter_layout_->SetHorizontalInternalMargin(8);
227+ filter_layout_->SetLeftAndRightPadding(style.GetFilterResultsHighlightLeftPadding(), style.GetFilterResultsHighlightRightPadding());
228+ filter_layout_->SetContentDistribution(nux::MAJOR_POSITION_END);
229 filter_layout_->AddView(show_filters_, 0, nux::MINOR_POSITION_CENTER);
230
231 arrow_layout_ = new nux::VLayout();
232@@ -238,16 +225,18 @@
233
234 filter_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
235
236- layout_->AddLayout(new nux::SpaceLayout(1, 10000, 0, 1), 1);
237-
238 expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
239 expander_view_->SetVisible(false);
240 expander_view_->SetLayout(filter_layout_);
241 layout_->AddView(expander_view_, 0, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL);
242
243- // Fix bug #917047
244- show_filters_->SetMaximumWidth(dash::Style::Instance().GetFilterBarWidth() - 60);
245- show_filters_->SetMinimumWidth(dash::Style::Instance().GetFilterBarWidth() - 60);
246+ int width = style.GetFilterBarWidth() +
247+ style.GetFilterResultsHighlightLeftPadding() +
248+ style.GetFilterResultsHighlightRightPadding();
249+
250+ expander_view_->SetMaximumWidth(width);
251+ expander_view_->SetMinimumWidth(width);
252+ show_filters_->SetMaximumWidth(style.GetFilterBarWidth() - arrow_layout_->GetBaseWidth() - 8);
253
254 // Lambda functions
255 auto mouse_expand = [&](int, int, unsigned long, unsigned long)
256@@ -293,15 +282,6 @@
257 expand_icon_->SetVisible(can_refine);
258 }
259 });
260-
261- disable_glow.changed.connect([&](bool disabled)
262- {
263- layout_->SetVerticalExternalMargin(0);
264- layout_->SetHorizontalExternalMargin(0);
265- UpdateBackground(true);
266- QueueDraw();
267- });
268-
269 }
270
271 SearchBar::~SearchBar()
272@@ -426,13 +406,10 @@
273 {
274 dash::Style& style = dash::Style::Instance();
275
276- nux::Geometry geo(show_filters_->GetGeometry());
277- nux::Geometry const& geo_arrow = arrow_layout_->GetGeometry();
278+ nux::Geometry geo(expander_view_->GetGeometry());
279
280 geo.y -= (HIGHLIGHT_HEIGHT- geo.height) / 2;
281 geo.height = HIGHLIGHT_HEIGHT;
282- geo.width = style.GetFilterBarWidth() + style.GetFilterBarLeftPadding() + style.GetFilterBarRightPadding();
283- geo.x = geo_arrow.x + (geo_arrow.width - 1) - geo.width + style.GetFilterBarLeftPadding();
284
285 if (!highlight_layer_)
286 highlight_layer_.reset(style.FocusOverlay(geo.width, geo.height));
287@@ -514,7 +491,10 @@
288 {
289 int RADIUS = 5;
290 nux::Geometry geo(GetGeometry());
291- geo.width = layered_layout_->GetGeometry().width;
292+ geo.width = layered_layout_->GetAbsoluteX() +
293+ layered_layout_->GetAbsoluteWidth() -
294+ GetAbsoluteX() +
295+ SEARCH_ENTRY_RIGHT_BORDER;
296
297 LOG_DEBUG(logger) << "height: "
298 << geo.height << " - "
299@@ -534,9 +514,9 @@
300
301 cairo_graphics.DrawRoundedRectangle(cr,
302 1.0f,
303- 1 + 0.5, 1 + 0.5,
304+ 0.5, 0.5,
305 RADIUS,
306- last_width_ - 1 - 2, last_height_ - 1 - 2,
307+ last_width_ - 1, last_height_ - 1,
308 false);
309
310 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
311
312=== modified file 'plugins/unityshell/src/SearchBar.h'
313--- plugins/unityshell/src/SearchBar.h 2012-03-14 06:24:18 +0000
314+++ plugins/unityshell/src/SearchBar.h 2012-03-27 15:22:27 +0000
315@@ -57,8 +57,7 @@
316 public:
317 typedef nux::ObjectPtr<SearchBar> Ptr;
318 SearchBar(NUX_FILE_LINE_PROTO);
319- SearchBar(int search_width, bool show_filter_hint, NUX_FILE_LINE_PROTO);
320- SearchBar(int search_width, NUX_FILE_LINE_PROTO);
321+ SearchBar(bool show_filter_hint, NUX_FILE_LINE_PROTO);
322 ~SearchBar();
323
324 void SearchFinished();
325@@ -69,7 +68,6 @@
326 nux::Property<std::string> search_hint;
327 nux::Property<bool> showing_filters;
328 nux::Property<bool> can_refine_search;
329- nux::Property<bool> disable_glow;
330 nux::ROProperty<bool> im_active;
331
332 sigc::signal<void> activated;
333@@ -115,6 +113,7 @@
334 nux::AbstractPaintLayer* bg_layer_;
335 std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_;
336 nux::HLayout* layout_;
337+ nux::HLayout* entry_layout_;
338 nux::LayeredLayout* layered_layout_;
339 nux::StaticCairoText* hint_;
340 nux::LinearLayout* expander_layout_;
341@@ -126,7 +125,6 @@
342 nux::SpaceLayout* arrow_top_space_;
343 nux::SpaceLayout* arrow_bottom_space_;
344 IconTexture* expand_icon_;
345- int search_bar_width_;
346
347 int last_width_;
348 int last_height_;