Merge lp:~unity-team/unity/trusty-1332947 into lp:unity/7.2

Proposed by Stephen M. Webb
Status: Rejected
Rejected by: Stephen M. Webb
Proposed branch: lp:~unity-team/unity/trusty-1332947
Merge into: lp:unity/7.2
Diff against target: 445 lines (+85/-63)
10 files modified
dash/FilterBasicButton.cpp (+6/-3)
dash/previews/ActionButton.cpp (+5/-2)
debian/changelog (+8/-0)
launcher/Launcher.cpp (+0/-2)
launcher/Tooltip.cpp (+5/-4)
unity-shared/DashStyle.cpp (+8/-11)
unity-shared/IconRenderer.cpp (+38/-34)
unity-shared/IconRenderer.h (+0/-2)
unity-shared/SearchBar.cpp (+6/-4)
unity-shared/UnitySettings.cpp (+9/-1)
To merge this branch: bzr merge lp:~unity-team/unity/trusty-1332947
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+244132@code.launchpad.net

Commit message

SearchBar, ActionButtons, IconRenderer: include the font scaling when scaling textual items

Description of the change

SearchBar, ActionButtons, IconRenderer: include the font scaling when scaling textual items.

User font scaling settings should be applied to all the items containing text.
Fixed some elements missing support (fixes #1332947, #1361751, #1362162, #1362346).

This change is cherry-picked from trunk for SRUing into Ubuntu 14.04 LTS.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/FilterBasicButton.cpp'
2--- dash/FilterBasicButton.cpp 2014-07-24 14:03:10 +0000
3+++ dash/FilterBasicButton.cpp 2014-12-09 13:54:54 +0000
4@@ -20,6 +20,7 @@
5 */
6
7 #include "unity-shared/DashStyle.h"
8+#include "unity-shared/UnitySettings.h"
9 #include "FilterBasicButton.h"
10
11 namespace unity
12@@ -70,6 +71,7 @@
13 });
14
15 scale.changed.connect(sigc::mem_fun(this, &FilterBasicButton::UpdateScale));
16+ Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &FilterBasicButton::InitTheme)));
17 }
18
19 void FilterBasicButton::InitTheme()
20@@ -81,11 +83,12 @@
21 normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
22 focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));
23
24- SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
25+ double font_scaling = Settings::Instance().font_scaling() * scale;
26+ SetMinimumWidth(MIN_BUTTON_WIDTH.CP(font_scaling));
27 ApplyMinWidth();
28
29- SetMinimumHeight(BUTTON_HEIGHT.CP(scale));
30- SetMaximumHeight(BUTTON_HEIGHT.CP(scale));
31+ SetMinimumHeight(BUTTON_HEIGHT.CP(font_scaling));
32+ SetMaximumHeight(BUTTON_HEIGHT.CP(font_scaling));
33 }
34
35 void FilterBasicButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)
36
37=== modified file 'dash/previews/ActionButton.cpp'
38--- dash/previews/ActionButton.cpp 2014-07-24 14:03:10 +0000
39+++ dash/previews/ActionButton.cpp 2014-12-09 13:54:54 +0000
40@@ -25,6 +25,7 @@
41 #include <Nux/HLayout.h>
42 #include "unity-shared/IconTexture.h"
43 #include "unity-shared/StaticCairoText.h"
44+#include "unity-shared/UnitySettings.h"
45
46 namespace unity
47 {
48@@ -51,6 +52,7 @@
49 Init();
50 BuildLayout(label, icon_hint, "");
51 scale.changed.connect(sigc::mem_fun(this, &ActionButton::UpdateScale));
52+ Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &ActionButton::InitTheme)));
53 }
54
55 ActionButton::~ActionButton()
56@@ -93,8 +95,9 @@
57 cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
58 cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay)));
59
60- SetMinimumHeight(MIN_BUTTON_HEIGHT.CP(scale));
61- SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
62+ double font_scaling = Settings::Instance().font_scaling() * scale;
63+ SetMinimumHeight(MIN_BUTTON_HEIGHT.CP(font_scaling));
64+ SetMinimumWidth(MIN_BUTTON_WIDTH.CP(font_scaling));
65 }
66
67 void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint)
68
69=== modified file 'debian/changelog'
70--- debian/changelog 2014-08-26 13:49:00 +0000
71+++ debian/changelog 2014-12-09 13:54:54 +0000
72@@ -1,3 +1,11 @@
73+unity (7.2.3+14.04.20140826-0ubuntu2) UNRELEASED; urgency=medium
74+
75+ * SearchBar, ActionButtons, IconRenderer: include the font scaling when
76+ scaling textual items (lp: #1332947) (lp: #1361751) (lp: #1362162)
77+ (lp: #1362346).
78+
79+ -- Marco Trevisan (TreviƱo) <mail@3v1n0.net> Tue, 09 Dec 2014 08:45:00 -0500
80+
81 unity (7.2.3+14.04.20140826-0ubuntu1) trusty; urgency=medium
82
83 [ Andrea Azzarone ]
84
85=== modified file 'launcher/Launcher.cpp'
86--- launcher/Launcher.cpp 2014-08-06 14:19:10 +0000
87+++ launcher/Launcher.cpp 2014-12-09 13:54:54 +0000
88@@ -1516,8 +1516,6 @@
89
90 void Launcher::SetIconSize(int tile_size, int icon_size)
91 {
92- ui::IconRenderer::DestroyShortcutTextures();
93-
94 icon_size_ = tile_size;
95 icon_renderer_->scale = cv_->DPIScale();
96 icon_renderer_->SetTargetSize(icon_size_.CP(cv_), RawPixel(icon_size).CP(cv_), SPACE_BETWEEN_ICONS.CP(cv_));
97
98=== modified file 'launcher/Tooltip.cpp'
99--- launcher/Tooltip.cpp 2014-03-24 23:44:58 +0000
100+++ launcher/Tooltip.cpp 2014-12-09 13:54:54 +0000
101@@ -144,11 +144,12 @@
102 _tooltip_text->SetMinimumWidth(text_min_width);
103 _tooltip_text->SetMinimumHeight(text_height);
104
105+ int space_height = _padding.CP(cv_) + CORNER_RADIUS.CP(cv_);
106 if (text_height < ANCHOR_HEIGHT.CP(cv_))
107- {
108- _top_space->SetMinMaxSize(1, (ANCHOR_HEIGHT.CP(cv_) - text_height) / 2 + _padding.CP(cv_) + CORNER_RADIUS.CP(cv_));
109- _bottom_space->SetMinMaxSize(1, (ANCHOR_HEIGHT.CP(cv_) - text_height) / 2 + 1 + _padding.CP(cv_) + CORNER_RADIUS.CP(cv_));
110- }
111+ space_height += (ANCHOR_HEIGHT.CP(cv_) - text_height) / 2;
112+
113+ _top_space->SetMinMaxSize(1, space_height);
114+ _bottom_space->SetMinMaxSize(1, space_height + 1);
115
116 CairoBaseWindow::PreLayoutManagement();
117 }
118
119=== modified file 'unity-shared/DashStyle.cpp'
120--- unity-shared/DashStyle.cpp 2014-07-24 14:14:47 +0000
121+++ unity-shared/DashStyle.cpp 2014-12-09 13:54:54 +0000
122@@ -383,9 +383,9 @@
123 ::pango_layout_context_changed(layout);
124
125 PangoRectangle log_rect;
126- ::pango_layout_get_extents(layout, NULL, &log_rect);
127- text_width_ = log_rect.width / PANGO_SCALE;
128- text_height_ = log_rect.height / PANGO_SCALE;
129+ ::pango_layout_get_pixel_extents(layout, NULL, &log_rect);
130+ text_width_ = log_rect.width;
131+ text_height_ = log_rect.height;
132
133 owner_->changed.emit();
134
135@@ -1396,10 +1396,10 @@
136
137 pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
138 pango_layout_context_changed(layout);
139- pango_layout_get_extents(layout, &inkRect, NULL);
140+ pango_layout_get_pixel_extents(layout, &inkRect, NULL);
141
142- width = inkRect.width / PANGO_SCALE;
143- height = inkRect.height / PANGO_SCALE;
144+ width = inkRect.width;
145+ height = inkRect.height;
146
147 // clean up
148 pango_font_description_free(desc);
149@@ -1444,11 +1444,8 @@
150
151 if (text_size > 0)
152 {
153- pango_font_description_set_absolute_size(desc, text_size * PANGO_SCALE);
154- }
155- else if (desc)
156- {
157- text_size = pango_font_description_get_size(desc) / PANGO_SCALE;
158+ text_size = pango_units_from_double(Settings::Instance().font_scaling() * text_size);
159+ pango_font_description_set_absolute_size(desc, text_size);
160 }
161
162 PangoWeight weight;
163
164=== modified file 'unity-shared/IconRenderer.cpp'
165--- unity-shared/IconRenderer.cpp 2014-05-08 18:52:16 +0000
166+++ unity-shared/IconRenderer.cpp 2014-12-09 13:54:54 +0000
167@@ -31,6 +31,8 @@
168 #include "unity-shared/CairoTexture.h"
169 #include "unity-shared/DecorationStyle.h"
170 #include "unity-shared/TextureCache.h"
171+#include "unity-shared/UnitySettings.h"
172+#include "unity-shared/WindowManager.h"
173 #include "GraphicsUtils.h"
174
175 #include <gtk/gtk.h>
176@@ -210,7 +212,6 @@
177 return instance;
178 }
179
180- nux::ObjectPtr<nux::BaseTexture> RenderLabelTexture(char label, int icon_size, nux::Color const& bg_color);
181 nux::ObjectPtr<nux::IOpenGLBaseTexture> offscreen_progress_texture;
182 nux::ObjectPtr<nux::IOpenGLShaderProgram> shader_program_uv_persp_correction;
183 #ifndef USE_GLES
184@@ -224,8 +225,6 @@
185 int ColorifyColor;
186 int DesatFactor;
187
188- std::map<char, BaseTexturePtr> labels;
189-
190 private:
191 TexturesPool();
192
193@@ -249,14 +248,18 @@
194 LocalTextures(IconRenderer* parent)
195 : parent_(parent)
196 {
197- theme_conn_ = decoration::Style::Get()->theme.changed.connect([this] (std::string const&) {
198+ connections_.Add(decoration::Style::Get()->theme.changed.connect([this] (std::string const&) {
199 auto& cache = TextureCache::GetDefault();
200
201 for (auto const& tex_data : texture_files_)
202 cache.Invalidate(tex_data.name, tex_data.size, tex_data.size);
203
204 ReloadIconSizedTextures(parent_->icon_size, parent_->image_size);
205- });
206+ }));
207+
208+ auto clear_labels = sigc::hide(sigc::mem_fun(this, &LocalTextures::ClearLabels));
209+ connections_.Add(Settings::Instance().font_scaling.changed.connect(clear_labels));
210+ connections_.Add(WindowManager::Default().average_color.changed.connect(clear_labels));
211 }
212
213 void ReloadIconSizedTextures(int icon_size, int image_size)
214@@ -298,6 +301,22 @@
215 *tex_data.tex_ptr = cache.FindTexture(tex_data.name, tex_data.size, tex_data.size, texture_loader);
216 }
217
218+ nux::BaseTexture* RenderLabelTexture(char label, int icon_size, nux::Color const&);
219+
220+ BaseTexturePtr const& GetLabelTexture(char label, int icon_size, nux::Color const& color)
221+ {
222+ labels_.push_back(TextureCache::GetDefault().FindTexture(std::string(1, label), icon_size, icon_size, [this, &color] (std::string const& label, int size, int) {
223+ return RenderLabelTexture(label[0], size, color);
224+ }));
225+
226+ return labels_.back();
227+ }
228+
229+ void ClearLabels()
230+ {
231+ labels_.clear();
232+ }
233+
234 BaseTexturePtr icon_background;
235 BaseTexturePtr icon_selected_background;
236 BaseTexturePtr icon_edge;
237@@ -315,7 +334,8 @@
238 IconRenderer* parent_;
239 struct TextureData { BaseTexturePtr* tex_ptr; std::string name; int size; };
240 std::vector<TextureData> texture_files_;
241- connection::Wrapper theme_conn_;
242+ std::vector<BaseTexturePtr> labels_;
243+ connection::Manager connections_;
244 };
245
246 IconRenderer::IconRenderer()
247@@ -335,6 +355,7 @@
248 icon_size = tile_size;
249 image_size = image_size_;
250 local_textures_->ReloadIconSizedTextures(icon_size, image_size);
251+ local_textures_->ClearLabels();
252 }
253
254 spacing = spacing_;
255@@ -741,20 +762,8 @@
256 // draw superkey-shortcut label
257 if (arg.draw_shortcut && arg.shortcut_label)
258 {
259- char shortcut = (char) arg.shortcut_label;
260-
261- BaseTexturePtr label;
262- auto label_it = textures_->labels.find(shortcut);
263-
264- if (label_it != textures_->labels.end())
265- {
266- label = label_it->second;
267- }
268- else
269- {
270- label = textures_->RenderLabelTexture(shortcut, icon_size, shortcut_color);
271- textures_->labels[shortcut] = label;
272- }
273+ char shortcut = static_cast<char>(arg.shortcut_label);
274+ auto const& label = local_textures_->GetLabelTexture(shortcut, icon_size, shortcut_color);
275
276 RenderElement(GfxContext,
277 arg,
278@@ -767,7 +776,7 @@
279 }
280 }
281
282-nux::ObjectPtr<nux::BaseTexture> IconRenderer::TexturesPool::RenderLabelTexture(char label, int icon_size, nux::Color const& bg_color)
283+nux::BaseTexture* IconRenderer::LocalTextures::RenderLabelTexture(char label, int icon_size, nux::Color const& bg_color)
284 {
285 nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, icon_size, icon_size);
286 cairo_t* cr = cg.GetInternalContext();
287@@ -791,27 +800,27 @@
288 cairo_set_source_rgba(cr, bg_color.red, bg_color.green, bg_color.blue, 0.20f);
289 cairo_fill(cr);
290
291- const double text_ratio = 0.75;
292- double text_size = label_size * text_ratio;
293 glib::Object<PangoLayout> layout(pango_cairo_create_layout(cr));
294 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, NULL);
295 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name),
296 pango_font_description_free);
297- pango_font_description_set_absolute_size(desc.get(), text_size * PANGO_SCALE);
298+ const double text_ratio = 0.75;
299+ int text_size = pango_units_from_double(label_size * text_ratio * Settings::Instance().font_scaling());
300+ pango_font_description_set_absolute_size(desc.get(), text_size);
301 pango_layout_set_font_description(layout, desc.get());
302 pango_layout_set_text(layout, &label, 1);
303
304- nux::Size extents;
305- pango_layout_get_pixel_size(layout, &extents.width, &extents.height);
306+ PangoRectangle ink_rect;
307+ pango_layout_get_pixel_extents(layout, &ink_rect, nullptr);
308
309 // position and paint text
310 cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
311- double x = label_x - std::round((extents.width - label_w) / 2.0f);
312- double y = label_y - std::round((extents.height - label_h) / 2.0f);
313+ double x = label_x - std::round((ink_rect.width - label_w) / 2.0f) - ink_rect.x;
314+ double y = label_y - std::round((ink_rect.height - label_h) / 2.0f) - ink_rect.y;
315 cairo_move_to(cr, x, y);
316 pango_cairo_show_layout(cr, layout);
317
318- return texture_ptr_from_cairo_graphics(cg);
319+ return texture_from_cairo_graphics(cg);
320 }
321
322 void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext,
323@@ -1153,11 +1162,6 @@
324 unity::graphics::PopOffscreenRenderTarget();
325 }
326
327-void IconRenderer::DestroyShortcutTextures()
328-{
329- TexturesPool::Get()->labels.clear();
330-}
331-
332 void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
333 int ViewportWidth,
334 int ViewportHeight,
335
336=== modified file 'unity-shared/IconRenderer.h'
337--- unity-shared/IconRenderer.h 2014-02-27 02:37:18 +0000
338+++ unity-shared/IconRenderer.h 2014-12-09 13:54:54 +0000
339@@ -44,8 +44,6 @@
340
341 void SetTargetSize(int tile_size, int image_size, int spacing);
342
343- static void DestroyShortcutTextures();
344-
345 protected:
346 void RenderElement(nux::GraphicsEngine& GfxContext,
347 RenderArg const& arg,
348
349=== modified file 'unity-shared/SearchBar.cpp'
350--- unity-shared/SearchBar.cpp 2014-07-24 14:03:10 +0000
351+++ unity-shared/SearchBar.cpp 2014-12-09 13:54:54 +0000
352@@ -65,7 +65,7 @@
353 const RawPixel FILTER_HORIZONTAL_MARGIN = 8_em;
354
355 // Fonts
356-const std::string HINT_LABEL_FONT_SIZE = "20px";
357+const std::string HINT_LABEL_FONT_SIZE = "15"; // == 20px
358 const std::string HINT_LABEL_FONT_STYLE = "Italic";
359 const std::string HINT_LABEL_DEFAULT_FONT = "Ubuntu " + HINT_LABEL_FONT_STYLE + " " + HINT_LABEL_FONT_SIZE;
360
361@@ -263,6 +263,7 @@
362 im_preedit.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_preedit));
363 showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged));
364 scale.changed.connect(sigc::mem_fun(this, &SearchBar::UpdateScale));
365+ Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &SearchBar::UpdateSearchBarSize)));
366 can_refine_search.changed.connect([this] (bool can_refine)
367 {
368 if (show_filter_hint_)
369@@ -289,7 +290,8 @@
370
371 entry_layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_SPINNER_AND_TEXT.CP(scale()));
372
373- pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE.CP(scale()));
374+ double font_scaling = scale() * Settings::Instance().font_scaling();
375+ pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE.CP(font_scaling));
376
377 if (show_filter_hint_)
378 {
379@@ -329,7 +331,7 @@
380 layered_layout_->SetMinimumHeight(entry_min);
381 layered_layout_->SetMaximumHeight(entry_min);
382
383- int search_bar_height = style.GetSearchBarHeight().CP(scale);
384+ int search_bar_height = style.GetSearchBarHeight().CP(font_scaling);
385 SetMinimumHeight(search_bar_height);
386 SetMaximumHeight(search_bar_height);
387 }
388@@ -359,7 +361,7 @@
389 if (desc)
390 {
391 pango_entry_->SetFontFamily(pango_font_description_get_family(desc));
392- pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE);
393+ pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE.CP(scale * Settings::Instance().font_scaling()));
394 pango_entry_->SetFontOptions(gdk_screen_get_font_options(gdk_screen_get_default()));
395
396 font_desc << pango_font_description_get_family(desc) << " " << HINT_LABEL_FONT_STYLE << " " << HINT_LABEL_FONT_SIZE;
397
398=== modified file 'unity-shared/UnitySettings.cpp'
399--- unity-shared/UnitySettings.cpp 2014-07-24 13:49:53 +0000
400+++ unity-shared/UnitySettings.cpp 2014-12-09 13:54:54 +0000
401@@ -20,6 +20,7 @@
402
403 #include <glib.h>
404 #include <NuxCore/Logger.h>
405+#include <UnityCore/GLibSource.h>
406 #include <UnityCore/Variant.h>
407
408 #include "DecorationStyle.h"
409@@ -60,6 +61,7 @@
410
411 const int DEFAULT_LAUNCHER_WIDTH = 64;
412 const int MINIMUM_DESKTOP_HEIGHT = 800;
413+const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;
414 const double DEFAULT_DPI = 96.0f;
415 }
416
417@@ -302,6 +304,7 @@
418 void UpdateAppsScaling(double scale)
419 {
420 changing_gnome_settings_ = true;
421+ changing_gnome_settings_timeout_.reset();
422 unsigned integer_scaling = std::max<unsigned>(1, scale);
423 double point_scaling = scale / static_cast<double>(integer_scaling);
424 double text_scale_factor = parent_->font_scaling() * point_scaling;
425@@ -310,7 +313,11 @@
426 g_settings_set_int(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str(), cursor_size);
427 g_settings_set_uint(gnome_ui_settings_, GNOME_SCALE_FACTOR.c_str(), integer_scaling);
428 g_settings_set_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);
429- changing_gnome_settings_ = false;
430+
431+ changing_gnome_settings_timeout_.reset(new glib::TimeoutSeconds(GNOME_SETTINGS_CHANGED_WAIT_SECONDS, [this] {
432+ changing_gnome_settings_ = false;
433+ return false;
434+ }, glib::Source::Priority::LOW));
435 }
436
437 Settings* parent_;
438@@ -319,6 +326,7 @@
439 glib::Object<GSettings> ui_settings_;
440 glib::Object<GSettings> ubuntu_ui_settings_;
441 glib::Object<GSettings> gnome_ui_settings_;
442+ glib::Source::UniquePtr changing_gnome_settings_timeout_;
443 glib::SignalManager signals_;
444 std::vector<EMConverter::Ptr> em_converters_;
445 std::vector<int> launcher_widths_;

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: