Merge lp:~3v1n0/unity/scaling-lockscreen into lp:unity
- scaling-lockscreen
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Andrea Azzarone | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 3864 | ||||
Proposed branch: | lp:~3v1n0/unity/scaling-lockscreen | ||||
Merge into: | lp:unity | ||||
Prerequisite: | lp:~azzar1/unity/fix-1308540 | ||||
Diff against target: |
1483 lines (+362/-193) 28 files modified
dash/previews/ErrorPreview.cpp (+1/-0) dash/previews/PaymentPreview.cpp (+3/-1) launcher/SwitcherView.cpp (+1/-1) lockscreen/BackgroundSettings.cpp (+13/-11) lockscreen/BackgroundSettings.h (+0/-1) lockscreen/CofView.cpp (+15/-2) lockscreen/CofView.h (+3/-1) lockscreen/LockScreenAbstractShield.h (+2/-0) lockscreen/LockScreenController.cpp (+10/-18) lockscreen/LockScreenController.h (+3/-2) lockscreen/LockScreenPanel.cpp (+3/-1) lockscreen/LockScreenSettings.cpp (+2/-0) lockscreen/LockScreenSettings.h (+2/-1) lockscreen/LockScreenShield.cpp (+43/-11) lockscreen/LockScreenShield.h (+3/-0) lockscreen/UserPromptView.cpp (+95/-17) lockscreen/UserPromptView.h (+5/-4) plugins/unityshell/src/unityshell.cpp (+1/-1) plugins/unityshell/src/unityshell.h (+2/-2) tests/test_previews_music_payment.cpp (+1/-0) tests/test_text_input.cpp (+1/-0) unity-shared/IconTexture.cpp (+1/-1) unity-shared/SearchBar.cpp (+12/-8) unity-shared/SearchBar.h (+9/-9) unity-shared/SearchBarSpinner.h (+0/-2) unity-shared/SpreadFilter.cpp (+3/-1) unity-shared/TextInput.cpp (+114/-79) unity-shared/TextInput.h (+14/-19) |
||||
To merge this branch: | bzr merge lp:~3v1n0/unity/scaling-lockscreen | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Andrea Azzarone (community) | Approve | ||
Review via email: mp+228583@code.launchpad.net |
Commit message
Lockscreen: scale the UI elements based on current monitor scaling
Description of the change
This branch includes also:
lp:~andyrock/unity/fix-1332509
lp:~andyrock/unity/fix-1308540
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3873
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3874
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3874
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3875
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3876
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3878
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3878
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3879
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'dash/previews/ErrorPreview.cpp' |
2 | --- dash/previews/ErrorPreview.cpp 2014-07-11 22:28:03 +0000 |
3 | +++ dash/previews/ErrorPreview.cpp 2014-08-27 22:18:22 +0000 |
4 | @@ -37,6 +37,7 @@ |
5 | |
6 | #include "stdio.h" |
7 | #include "config.h" |
8 | +#include <glib/gi18n-lib.h> |
9 | |
10 | namespace unity |
11 | { |
12 | |
13 | === modified file 'dash/previews/PaymentPreview.cpp' |
14 | --- dash/previews/PaymentPreview.cpp 2014-07-10 19:30:17 +0000 |
15 | +++ dash/previews/PaymentPreview.cpp 2014-08-27 22:18:22 +0000 |
16 | @@ -20,8 +20,10 @@ |
17 | * Manuel de la Pena <manuel.delapena@canonical.com> |
18 | * |
19 | */ |
20 | +#include "PaymentPreview.h" |
21 | + |
22 | +#include <Nux/VLayout.h> |
23 | #include <NuxCore/Logger.h> |
24 | -#include "PaymentPreview.h" |
25 | #include "unity-shared/CoverArt.h" |
26 | #include "unity-shared/DashStyle.h" |
27 | #include "unity-shared/PreviewStyle.h" |
28 | |
29 | === modified file 'launcher/SwitcherView.cpp' |
30 | --- launcher/SwitcherView.cpp 2014-07-15 16:28:45 +0000 |
31 | +++ launcher/SwitcherView.cpp 2014-08-27 22:18:22 +0000 |
32 | @@ -78,7 +78,7 @@ |
33 | icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing); |
34 | |
35 | text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER); |
36 | - text_view_->SetLines(1); |
37 | + text_view_->SetLines(-1); |
38 | text_view_->SetTextColor(nux::color::White); |
39 | text_view_->SetFont("Ubuntu Bold 10"); |
40 | text_view_->SetScale(scale); |
41 | |
42 | === modified file 'lockscreen/BackgroundSettings.cpp' |
43 | --- lockscreen/BackgroundSettings.cpp 2014-04-10 01:16:32 +0000 |
44 | +++ lockscreen/BackgroundSettings.cpp 2014-08-27 22:18:22 +0000 |
45 | @@ -25,6 +25,7 @@ |
46 | #include "LockScreenSettings.h" |
47 | #include "unity-shared/CairoTexture.h" |
48 | #include "unity-shared/PanelStyle.h" |
49 | +#include "unity-shared/UnitySettings.h" |
50 | #include "unity-shared/UScreen.h" |
51 | |
52 | namespace unity |
53 | @@ -35,7 +36,7 @@ |
54 | { |
55 | const std::string SETTINGS_NAME = "org.gnome.desktop.background"; |
56 | |
57 | -constexpr int GetGridOffset(int size) { return (size % Settings::GRID_SIZE) / 2; } |
58 | +inline int GetGridOffset(int size) { return (size % Settings::GRID_SIZE) / 2; } |
59 | } |
60 | |
61 | BackgroundSettings::BackgroundSettings() |
62 | @@ -45,26 +46,27 @@ |
63 | gnome_bg_load_from_preferences(gnome_bg_, settings); |
64 | } |
65 | |
66 | -BackgroundSettings::~BackgroundSettings() |
67 | -{} |
68 | - |
69 | BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor) |
70 | { |
71 | nux::Geometry const& geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); |
72 | + double scale = unity::Settings::Instance().em(monitor)->DPIScale(); |
73 | auto& settings = Settings::Instance(); |
74 | |
75 | nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height); |
76 | + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale); |
77 | cairo_t* c = cairo_graphics.GetInternalContext(); |
78 | |
79 | + double s_width = geo.width / scale; |
80 | + double s_height = geo.height / scale; |
81 | cairo_surface_t* bg_surface = nullptr; |
82 | |
83 | if (settings.use_user_background()) |
84 | { |
85 | - bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), geo.width, geo.height, FALSE); |
86 | + bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), s_width, s_height, FALSE); |
87 | } |
88 | else if (!settings.background().empty()) |
89 | { |
90 | - glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), geo.width, geo.height, FALSE, NULL)); |
91 | + glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), s_width, s_height, FALSE, NULL)); |
92 | |
93 | if (pixbuf) |
94 | bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL); |
95 | @@ -85,15 +87,15 @@ |
96 | |
97 | if (!settings.logo().empty()) |
98 | { |
99 | - int grid_x_offset = GetGridOffset(geo.width); |
100 | - int grid_y_offset = GetGridOffset(geo.height); |
101 | + int grid_x_offset = GetGridOffset(s_width); |
102 | + int grid_y_offset = GetGridOffset(s_height); |
103 | cairo_surface_t* logo_surface = cairo_image_surface_create_from_png(settings.logo().c_str()); |
104 | |
105 | if (logo_surface) |
106 | { |
107 | int height = cairo_image_surface_get_height(logo_surface); |
108 | int x = grid_x_offset; |
109 | - int y = grid_y_offset + Settings::GRID_SIZE * (geo.height / Settings::GRID_SIZE - 1) - height; |
110 | + int y = grid_y_offset + Settings::GRID_SIZE * (s_height / Settings::GRID_SIZE - 1) - height; |
111 | |
112 | cairo_save(c); |
113 | cairo_translate(c, x, y); |
114 | @@ -107,8 +109,8 @@ |
115 | |
116 | if (settings.draw_grid()) |
117 | { |
118 | - int width = geo.width; |
119 | - int height = geo.height; |
120 | + double width = s_width; |
121 | + double height = s_height; |
122 | int grid_x_offset = GetGridOffset(width); |
123 | int grid_y_offset = GetGridOffset(height) + panel::Style::Instance().PanelHeight(monitor); |
124 | |
125 | |
126 | === modified file 'lockscreen/BackgroundSettings.h' |
127 | --- lockscreen/BackgroundSettings.h 2014-03-06 03:55:03 +0000 |
128 | +++ lockscreen/BackgroundSettings.h 2014-08-27 22:18:22 +0000 |
129 | @@ -41,7 +41,6 @@ |
130 | { |
131 | public: |
132 | BackgroundSettings(); |
133 | - ~BackgroundSettings(); |
134 | |
135 | BaseTexturePtr GetBackgroundTexture(int monitor); |
136 | |
137 | |
138 | === modified file 'lockscreen/CofView.cpp' |
139 | --- lockscreen/CofView.cpp 2014-02-13 13:57:57 +0000 |
140 | +++ lockscreen/CofView.cpp 2014-08-27 22:18:22 +0000 |
141 | @@ -18,6 +18,7 @@ |
142 | */ |
143 | |
144 | #include "CofView.h" |
145 | +#include "unity-shared/RawPixel.h" |
146 | |
147 | #include "config.h" |
148 | |
149 | @@ -25,11 +26,23 @@ |
150 | { |
151 | namespace lockscreen |
152 | { |
153 | +namespace |
154 | +{ |
155 | +const std::string COF_FILE = "cof.png"; |
156 | +} |
157 | |
158 | CofView::CofView() |
159 | // FIXME (andy) if we get an svg cof we can make it fullscreen independent. |
160 | - : IconTexture(PKGDATADIR"/cof.png", 66) |
161 | -{} |
162 | + : IconTexture(PKGDATADIR"/"+COF_FILE, -1) |
163 | + , scale(1.0) |
164 | +{ |
165 | + scale.changed.connect([this] (double scale) { |
166 | + int w, h; |
167 | + gdk_pixbuf_get_file_info((PKGDATADIR"/" + COF_FILE).c_str(), &w, &h); |
168 | + SetSize(RawPixel(std::max(w, h)).CP(scale)); |
169 | + ReLoadIcon(); |
170 | + }); |
171 | +} |
172 | |
173 | nux::Area* CofView::FindAreaUnderMouse(nux::Point const& mouse_position, |
174 | nux::NuxEventType event_type) |
175 | |
176 | === modified file 'lockscreen/CofView.h' |
177 | --- lockscreen/CofView.h 2014-02-13 13:57:57 +0000 |
178 | +++ lockscreen/CofView.h 2014-08-27 22:18:22 +0000 |
179 | @@ -27,11 +27,13 @@ |
180 | namespace lockscreen |
181 | { |
182 | |
183 | -class CofView : public unity::IconTexture |
184 | +class CofView : public IconTexture |
185 | { |
186 | public: |
187 | CofView(); |
188 | |
189 | + nux::Property<double> scale; |
190 | + |
191 | nux::Area* FindAreaUnderMouse(nux::Point const& mouse_position, |
192 | nux::NuxEventType event_type) override; |
193 | }; |
194 | |
195 | === modified file 'lockscreen/LockScreenAbstractShield.h' |
196 | --- lockscreen/LockScreenAbstractShield.h 2014-08-27 22:18:22 +0000 |
197 | +++ lockscreen/LockScreenAbstractShield.h 2014-08-27 22:18:22 +0000 |
198 | @@ -45,6 +45,7 @@ |
199 | : MockableBaseWindow("Unity Lockscreen") |
200 | , primary(is_primary) |
201 | , monitor(monitor_num) |
202 | + , scale(1.0) |
203 | , session_manager_(session) |
204 | , indicators_(indicators) |
205 | , accelerators_(accelerators) |
206 | @@ -53,6 +54,7 @@ |
207 | |
208 | nux::Property<bool> primary; |
209 | nux::Property<int> monitor; |
210 | + nux::Property<double> scale; |
211 | |
212 | using MockableBaseWindow::RemoveLayout; |
213 | virtual bool IsIndicatorOpen() const = 0; |
214 | |
215 | === modified file 'lockscreen/LockScreenController.cpp' |
216 | --- lockscreen/LockScreenController.cpp 2014-08-27 22:18:22 +0000 |
217 | +++ lockscreen/LockScreenController.cpp 2014-08-27 22:18:22 +0000 |
218 | @@ -24,7 +24,6 @@ |
219 | |
220 | #include "LockScreenShield.h" |
221 | #include "LockScreenSettings.h" |
222 | -#include "UserPromptView.h" |
223 | #include "unity-shared/AnimationUtils.h" |
224 | #include "unity-shared/UScreen.h" |
225 | #include "unity-shared/WindowManager.h" |
226 | @@ -155,20 +154,6 @@ |
227 | primary_shield_->ActivatePanel(); |
228 | } |
229 | |
230 | -UserPromptView* Controller::CreatePromptView() |
231 | -{ |
232 | - auto* prompt_view = new UserPromptView(session_manager_); |
233 | - |
234 | - auto width = 8 * Settings::GRID_SIZE; |
235 | - auto height = 3 * Settings::GRID_SIZE; |
236 | - |
237 | - prompt_view->SetMinimumWidth(width); |
238 | - prompt_view->SetMaximumWidth(width); |
239 | - prompt_view->SetMinimumHeight(height); |
240 | - |
241 | - return prompt_view; |
242 | -} |
243 | - |
244 | void Controller::ResetPostLockScreenSaver() |
245 | { |
246 | screensaver_post_lock_timeout_.reset(); |
247 | @@ -205,9 +190,16 @@ |
248 | int shields_size = shields_.size(); |
249 | int primary = UScreen::GetDefault()->GetMonitorWithMouse(); |
250 | |
251 | + // Keep a reference of the old prompt_view |
252 | + nux::ObjectPtr<UserPromptView> prompt_view(prompt_view_.GetPointer()); |
253 | + |
254 | shields_.resize(num_monitors); |
255 | |
256 | - prompt_view_ = test_mode_ ? nullptr : CreatePromptView(); |
257 | + if (!prompt_view) |
258 | + { |
259 | + prompt_view = test_mode_ ? nullptr : new UserPromptView(session_manager_); |
260 | + prompt_view_ = prompt_view.GetPointer(); |
261 | + } |
262 | |
263 | for (int i = 0; i < num_monitors; ++i) |
264 | { |
265 | @@ -216,7 +208,7 @@ |
266 | |
267 | if (i >= shields_size) |
268 | { |
269 | - shield = shield_factory_->CreateShield(session_manager_, indicators_, accelerator_controller_->GetAccelerators(), prompt_view_, i, i == primary); |
270 | + shield = shield_factory_->CreateShield(session_manager_, indicators_, accelerator_controller_->GetAccelerators(), prompt_view, i, i == primary); |
271 | is_new = true; |
272 | } |
273 | |
274 | @@ -225,7 +217,7 @@ |
275 | |
276 | shield->SetGeometry(new_geo); |
277 | shield->SetMinMaxSize(new_geo.width, new_geo.height); |
278 | - shield->primary = (i == primary); |
279 | + shield->primary = false; |
280 | shield->monitor = i; |
281 | |
282 | // XXX: manually emit nux::Area::geometry_changed beucase nux can fail to emit it. |
283 | |
284 | === modified file 'lockscreen/LockScreenController.h' |
285 | --- lockscreen/LockScreenController.h 2014-08-27 22:18:22 +0000 |
286 | +++ lockscreen/LockScreenController.h 2014-08-27 22:18:22 +0000 |
287 | @@ -41,6 +41,8 @@ |
288 | class Controller : public sigc::trackable |
289 | { |
290 | public: |
291 | + typedef std::shared_ptr<Controller> Ptr; |
292 | + |
293 | Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, |
294 | UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(), |
295 | ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(), |
296 | @@ -54,7 +56,6 @@ |
297 | private: |
298 | friend class TestLockScreenController; |
299 | |
300 | - UserPromptView* CreatePromptView(); |
301 | void EnsureShields(std::vector<nux::Geometry> const& monitors); |
302 | void EnsureBlankWindow(); |
303 | void LockScreen(); |
304 | @@ -75,6 +76,7 @@ |
305 | |
306 | std::vector<nux::ObjectPtr<AbstractShield>> shields_; |
307 | nux::ObjectWeakPtr<AbstractShield> primary_shield_; |
308 | + nux::ObjectWeakPtr<UserPromptView> prompt_view_; |
309 | nux::ObjectPtr<nux::BaseWindow> blank_window_; |
310 | |
311 | DBusManager::Ptr dbus_manager_; |
312 | @@ -83,7 +85,6 @@ |
313 | AcceleratorController::Ptr accelerator_controller_; |
314 | UpstartWrapper::Ptr upstart_wrapper_; |
315 | ShieldFactoryInterface::Ptr shield_factory_; |
316 | - nux::ObjectPtr<UserPromptView> prompt_view_; |
317 | |
318 | nux::animation::AnimateValue<double> fade_animator_; |
319 | nux::animation::AnimateValue<double> blank_window_animator_; |
320 | |
321 | === modified file 'lockscreen/LockScreenPanel.cpp' |
322 | --- lockscreen/LockScreenPanel.cpp 2014-05-12 22:00:44 +0000 |
323 | +++ lockscreen/LockScreenPanel.cpp 2014-08-27 22:18:22 +0000 |
324 | @@ -82,7 +82,9 @@ |
325 | indicators_->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest)); |
326 | |
327 | monitor.changed.connect([this, hostname] (int monitor) { |
328 | - hostname->SetScale(unity::Settings::Instance().em(monitor)->DPIScale()); |
329 | + double scale = unity::Settings::Instance().em(monitor)->DPIScale(); |
330 | + hostname->SetScale(scale); |
331 | + static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0); |
332 | indicators_view_->SetMonitor(monitor); |
333 | BuildTexture(); |
334 | QueueRelayout(); |
335 | |
336 | === modified file 'lockscreen/LockScreenSettings.cpp' |
337 | --- lockscreen/LockScreenSettings.cpp 2014-04-09 01:36:22 +0000 |
338 | +++ lockscreen/LockScreenSettings.cpp 2014-08-27 22:18:22 +0000 |
339 | @@ -55,6 +55,8 @@ |
340 | const std::string USE_OSK = "screen-keyboard-enabled"; |
341 | } |
342 | |
343 | +const RawPixel Settings::GRID_SIZE = 40_em; |
344 | + |
345 | struct Settings::Impl |
346 | { |
347 | Impl() |
348 | |
349 | === modified file 'lockscreen/LockScreenSettings.h' |
350 | --- lockscreen/LockScreenSettings.h 2014-04-09 01:36:22 +0000 |
351 | +++ lockscreen/LockScreenSettings.h 2014-08-27 22:18:22 +0000 |
352 | @@ -21,6 +21,7 @@ |
353 | #define UNITY_LOCKSCREEN_SETTINGS_H |
354 | |
355 | #include <NuxCore/Property.h> |
356 | +#include "unity-shared/RawPixel.h" |
357 | |
358 | namespace unity |
359 | { |
360 | @@ -48,7 +49,7 @@ |
361 | nux::Property<bool> lock_on_suspend; |
362 | nux::Property<bool> use_legacy; |
363 | |
364 | - static const int GRID_SIZE = 40; |
365 | + static const RawPixel GRID_SIZE; |
366 | |
367 | private: |
368 | struct Impl; |
369 | |
370 | === modified file 'lockscreen/LockScreenShield.cpp' |
371 | --- lockscreen/LockScreenShield.cpp 2014-08-27 22:18:22 +0000 |
372 | +++ lockscreen/LockScreenShield.cpp 2014-08-27 22:18:22 +0000 |
373 | @@ -30,6 +30,7 @@ |
374 | #include "LockScreenSettings.h" |
375 | #include "UserPromptView.h" |
376 | #include "unity-shared/UScreen.h" |
377 | +#include "unity-shared/UnitySettings.h" |
378 | #include "unity-shared/WindowManager.h" |
379 | |
380 | namespace unity |
381 | @@ -50,14 +51,19 @@ |
382 | : AbstractShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary) |
383 | , bg_settings_(std::make_shared<BackgroundSettings>()) |
384 | , panel_view_(nullptr) |
385 | + , cof_view_(nullptr) |
386 | { |
387 | + UpdateScale(); |
388 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); |
389 | |
390 | EnableInputWindow(true); |
391 | |
392 | + unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Shield::UpdateScale)); |
393 | geometry_changed.connect([this] (nux::Area*, nux::Geometry&) { UpdateBackgroundTexture();}); |
394 | |
395 | monitor.changed.connect([this] (int monitor) { |
396 | + UpdateScale(); |
397 | + |
398 | if (panel_view_) |
399 | panel_view_->monitor = monitor; |
400 | |
401 | @@ -72,12 +78,31 @@ |
402 | QueueDraw(); |
403 | }); |
404 | |
405 | + scale.changed.connect([this] (double scale) { |
406 | + if (prompt_view_ && primary()) |
407 | + prompt_view_->scale = scale; |
408 | + |
409 | + if (cof_view_) |
410 | + cof_view_->scale = scale; |
411 | + |
412 | + if (prompt_layout_) |
413 | + prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale)); |
414 | + |
415 | + background_layer_.reset(); |
416 | + UpdateBackgroundTexture(); |
417 | + }); |
418 | + |
419 | mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) { |
420 | auto const& abs_geo = GetAbsoluteGeometry(); |
421 | grab_motion.emit(abs_geo.x + x, abs_geo.y + y); |
422 | }); |
423 | } |
424 | |
425 | +void Shield::UpdateScale() |
426 | +{ |
427 | + scale = unity::Settings::Instance().em(monitor)->DPIScale(); |
428 | +} |
429 | + |
430 | void Shield::UpdateBackgroundTexture() |
431 | { |
432 | auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); |
433 | @@ -119,12 +144,13 @@ |
434 | { |
435 | if (primary_layout_) |
436 | { |
437 | + if (prompt_view_) |
438 | + { |
439 | + prompt_view_->scale = scale(); |
440 | + prompt_layout_->AddView(prompt_view_.GetPointer()); |
441 | + } |
442 | + |
443 | GrabScreen(false); |
444 | - |
445 | - if (prompt_view_ && prompt_view_->GetParentObject()) |
446 | - static_cast<nux::Layout*>(prompt_view_->GetParentObject())->RemoveChildObject(prompt_view_.GetPointer()); |
447 | - prompt_layout_->AddView(prompt_view_.GetPointer()); |
448 | - |
449 | SetLayout(primary_layout_.GetPointer()); |
450 | return; |
451 | } |
452 | @@ -137,11 +163,13 @@ |
453 | main_layout->AddView(CreatePanel()); |
454 | |
455 | prompt_layout_ = new nux::HLayout(); |
456 | - prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE); |
457 | + prompt_layout_->SetLeftAndRightPadding(2 * Settings::GRID_SIZE.CP(scale)); |
458 | |
459 | - if (prompt_view_ && prompt_view_->GetParentObject()) |
460 | - static_cast<nux::Layout*>(prompt_view_->GetParentObject())->RemoveChildObject(prompt_view_.GetPointer()); |
461 | - prompt_layout_->AddView(prompt_view_.GetPointer()); |
462 | + if (prompt_view_) |
463 | + { |
464 | + prompt_view_->scale = scale(); |
465 | + prompt_layout_->AddView(prompt_view_.GetPointer()); |
466 | + } |
467 | |
468 | // 10 is just a random number to center the prompt view. |
469 | main_layout->AddSpace(0, 10); |
470 | @@ -151,6 +179,9 @@ |
471 | |
472 | void Shield::ShowSecondaryView() |
473 | { |
474 | + if (prompt_layout_) |
475 | + prompt_layout_->RemoveChildObject(prompt_view_.GetPointer()); |
476 | + |
477 | if (cof_layout_) |
478 | { |
479 | SetLayout(cof_layout_.GetPointer()); |
480 | @@ -162,8 +193,9 @@ |
481 | SetLayout(cof_layout_.GetPointer()); |
482 | |
483 | // The circle of friends |
484 | - CofView* cof_view = new CofView(); |
485 | - main_layout->AddView(cof_view); |
486 | + cof_view_ = new CofView(); |
487 | + cof_view_->scale = scale(); |
488 | + main_layout->AddView(cof_view_); |
489 | } |
490 | |
491 | Panel* Shield::CreatePanel() |
492 | |
493 | === modified file 'lockscreen/LockScreenShield.h' |
494 | --- lockscreen/LockScreenShield.h 2014-08-27 22:18:22 +0000 |
495 | +++ lockscreen/LockScreenShield.h 2014-08-27 22:18:22 +0000 |
496 | @@ -33,6 +33,7 @@ |
497 | class UserAuthenticator; |
498 | class UserPromptView; |
499 | class Panel; |
500 | +class CofView; |
501 | |
502 | class Shield : public AbstractShield |
503 | { |
504 | @@ -56,6 +57,7 @@ |
505 | void GrabScreen(bool cancel_on_failure); |
506 | void ShowPrimaryView(); |
507 | void ShowSecondaryView(); |
508 | + void UpdateScale(); |
509 | Panel* CreatePanel(); |
510 | |
511 | std::shared_ptr<BackgroundSettings> bg_settings_; |
512 | @@ -67,6 +69,7 @@ |
513 | connection::Wrapper regrab_conn_; |
514 | glib::Source::UniquePtr regrab_timeout_; |
515 | Panel* panel_view_; |
516 | + CofView* cof_view_; |
517 | }; |
518 | |
519 | } |
520 | |
521 | === modified file 'lockscreen/UserPromptView.cpp' |
522 | --- lockscreen/UserPromptView.cpp 2014-08-11 12:30:29 +0000 |
523 | +++ lockscreen/UserPromptView.cpp 2014-08-27 22:18:22 +0000 |
524 | @@ -19,6 +19,9 @@ |
525 | |
526 | #include "UserPromptView.h" |
527 | |
528 | +#include "config.h" |
529 | +#include <glib/gi18n-lib.h> |
530 | + |
531 | #include <boost/algorithm/string/trim.hpp> |
532 | #include <Nux/VLayout.h> |
533 | |
534 | @@ -38,12 +41,12 @@ |
535 | const RawPixel LAYOUT_MARGIN = 10_em; |
536 | const RawPixel MSG_LAYOUT_MARGIN = 15_em; |
537 | const RawPixel PROMPT_LAYOUT_MARGIN = 5_em; |
538 | - |
539 | const int PROMPT_FONT_SIZE = 13; |
540 | |
541 | -nux::AbstractPaintLayer* CrateBackgroundLayer(int width, int height) |
542 | +nux::AbstractPaintLayer* CrateBackgroundLayer(double width, double height, double scale) |
543 | { |
544 | nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); |
545 | + cairo_surface_set_device_scale(cg.GetSurface(), scale, scale); |
546 | cairo_t* cr = cg.GetInternalContext(); |
547 | |
548 | cairo_set_source_rgba(cr, 0.1, 0.1, 0.1, 0.4); |
549 | @@ -52,12 +55,12 @@ |
550 | 1.0, |
551 | 0, 0, |
552 | Settings::GRID_SIZE * 0.3, |
553 | - width, height); |
554 | + width/scale, height/scale); |
555 | |
556 | cairo_fill_preserve(cr); |
557 | |
558 | - cairo_set_source_rgba (cr, 0.4, 0.4, 0.4, 0.4); |
559 | - cairo_set_line_width (cr, 1); |
560 | + cairo_set_source_rgba(cr, 0.4, 0.4, 0.4, 0.4); |
561 | + cairo_set_line_width(cr, 1); |
562 | cairo_stroke (cr); |
563 | |
564 | // Create the texture layer |
565 | @@ -98,7 +101,11 @@ |
566 | |
567 | UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager) |
568 | : nux::View(NUX_TRACKER_LOCATION) |
569 | + , scale(1.0) |
570 | , session_manager_(session_manager) |
571 | + , username_(nullptr) |
572 | + , msg_layout_(nullptr) |
573 | + , prompt_layout_(nullptr) |
574 | { |
575 | user_authenticator_.echo_on_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ |
576 | AddPrompt(message, /* visible */ true, promise); |
577 | @@ -120,12 +127,65 @@ |
578 | ResetLayout(); |
579 | }); |
580 | |
581 | + scale.changed.connect(sigc::hide(sigc::mem_fun(this, &UserPromptView::UpdateSize))); |
582 | + |
583 | + UpdateSize(); |
584 | ResetLayout(); |
585 | |
586 | user_authenticator_.AuthenticateStart(session_manager_->UserName(), |
587 | sigc::mem_fun(this, &UserPromptView::AuthenticationCb)); |
588 | } |
589 | |
590 | +void UserPromptView::UpdateSize() |
591 | +{ |
592 | + auto width = 8 * Settings::GRID_SIZE.CP(scale); |
593 | + auto height = 3 * Settings::GRID_SIZE.CP(scale); |
594 | + |
595 | + SetMinimumWidth(width); |
596 | + SetMaximumWidth(width); |
597 | + SetMinimumHeight(height); |
598 | + |
599 | + if (nux::Layout* layout = GetLayout()) |
600 | + { |
601 | + layout->SetLeftAndRightPadding(PADDING.CP(scale)); |
602 | + layout->SetTopAndBottomPadding(PADDING.CP(scale)); |
603 | + static_cast<nux::VLayout*>(layout)->SetVerticalInternalMargin(LAYOUT_MARGIN.CP(scale)); |
604 | + } |
605 | + |
606 | + if (username_) |
607 | + username_->SetScale(scale); |
608 | + |
609 | + if (msg_layout_) |
610 | + { |
611 | + msg_layout_->SetVerticalInternalMargin(MSG_LAYOUT_MARGIN.CP(scale)); |
612 | + |
613 | + for (auto* area : msg_layout_->GetChildren()) |
614 | + { |
615 | + area->SetMaximumWidth(width); |
616 | + static_cast<StaticCairoText*>(area)->SetScale(scale); |
617 | + } |
618 | + } |
619 | + |
620 | + if (prompt_layout_) |
621 | + { |
622 | + prompt_layout_->SetVerticalInternalMargin(PROMPT_LAYOUT_MARGIN.CP(scale)); |
623 | + |
624 | + for (auto* area : prompt_layout_->GetChildren()) |
625 | + { |
626 | + auto* text_input = static_cast<TextInput*>(area); |
627 | + text_input->SetMinimumHeight(Settings::GRID_SIZE.CP(scale)); |
628 | + text_input->SetMaximumHeight(Settings::GRID_SIZE.CP(scale)); |
629 | + text_input->scale = scale(); |
630 | + } |
631 | + } |
632 | + |
633 | + bg_layer_.reset(); |
634 | + |
635 | + ComputeContentSize(); |
636 | + QueueRelayout(); |
637 | + QueueDraw(); |
638 | +} |
639 | + |
640 | bool UserPromptView::InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character) |
641 | { |
642 | if ((eventType == nux::NUX_KEYDOWN) && (key_sym == NUX_VK_ESCAPE)) |
643 | @@ -145,24 +205,25 @@ |
644 | |
645 | SetLayout(new nux::VLayout()); |
646 | |
647 | - GetLayout()->SetLeftAndRightPadding(PADDING); |
648 | - GetLayout()->SetTopAndBottomPadding(PADDING); |
649 | - static_cast<nux::VLayout*>(GetLayout())->SetVerticalInternalMargin(LAYOUT_MARGIN); |
650 | + GetLayout()->SetLeftAndRightPadding(PADDING.CP(scale)); |
651 | + GetLayout()->SetTopAndBottomPadding(PADDING.CP(scale)); |
652 | + static_cast<nux::VLayout*>(GetLayout())->SetVerticalInternalMargin(LAYOUT_MARGIN.CP(scale)); |
653 | |
654 | auto const& real_name = session_manager_->RealName(); |
655 | auto const& name = (real_name.empty() ? session_manager_->UserName() : real_name); |
656 | |
657 | - unity::StaticCairoText* username = new unity::StaticCairoText(name); |
658 | - username->SetFont("Ubuntu "+std::to_string(PROMPT_FONT_SIZE)); |
659 | - GetLayout()->AddView(username); |
660 | + username_ = new unity::StaticCairoText(name); |
661 | + username_->SetScale(scale); |
662 | + username_->SetFont("Ubuntu "+std::to_string(PROMPT_FONT_SIZE)); |
663 | + GetLayout()->AddView(username_); |
664 | |
665 | msg_layout_ = new nux::VLayout(); |
666 | - msg_layout_->SetVerticalInternalMargin(MSG_LAYOUT_MARGIN); |
667 | + msg_layout_->SetVerticalInternalMargin(MSG_LAYOUT_MARGIN.CP(scale)); |
668 | msg_layout_->SetReconfigureParentLayoutOnGeometryChange(true); |
669 | GetLayout()->AddLayout(msg_layout_); |
670 | |
671 | prompt_layout_ = new nux::VLayout(); |
672 | - prompt_layout_->SetVerticalInternalMargin(PROMPT_LAYOUT_MARGIN); |
673 | + prompt_layout_->SetVerticalInternalMargin(PROMPT_LAYOUT_MARGIN.CP(scale)); |
674 | prompt_layout_->SetReconfigureParentLayoutOnGeometryChange(true); |
675 | GetLayout()->AddLayout(prompt_layout_); |
676 | |
677 | @@ -187,6 +248,21 @@ |
678 | } |
679 | } |
680 | |
681 | +void UserPromptView::EnsureBGLayer() |
682 | +{ |
683 | + auto const& geo = GetGeometry(); |
684 | + |
685 | + if (bg_layer_) |
686 | + { |
687 | + auto const& layer_geo = bg_layer_->GetGeometry(); |
688 | + |
689 | + if (layer_geo.width == geo.width && layer_geo.height == geo.height) |
690 | + return; |
691 | + } |
692 | + |
693 | + bg_layer_.reset(CrateBackgroundLayer(geo.width, geo.height, scale)); |
694 | +} |
695 | + |
696 | void UserPromptView::Draw(nux::GraphicsEngine& graphics_engine, bool /* force_draw */) |
697 | { |
698 | nux::Geometry const& geo = GetGeometry(); |
699 | @@ -194,7 +270,7 @@ |
700 | graphics_engine.PushClippingRectangle(geo); |
701 | nux::GetPainter().PaintBackground(graphics_engine, geo); |
702 | |
703 | - bg_layer_.reset(CrateBackgroundLayer(geo.width, geo.height)); |
704 | + EnsureBGLayer(); |
705 | nux::GetPainter().PushDrawLayer(graphics_engine, geo, bg_layer_.get()); |
706 | |
707 | nux::GetPainter().PopBackground(); |
708 | @@ -208,7 +284,7 @@ |
709 | |
710 | if (!IsFullRedraw()) |
711 | { |
712 | - bg_layer_.reset(CrateBackgroundLayer(geo.width, geo.height)); |
713 | + EnsureBGLayer(); |
714 | nux::GetPainter().PushLayer(graphics_engine, geo, bg_layer_.get()); |
715 | } |
716 | |
717 | @@ -238,6 +314,7 @@ |
718 | auto* text_input = new unity::TextInput(); |
719 | auto* text_entry = text_input->text_entry(); |
720 | |
721 | + text_input->scale = scale(); |
722 | text_input->input_hint = SanitizeMessage(message); |
723 | text_input->hint_font_size = PROMPT_FONT_SIZE; |
724 | text_input->show_caps_lock = true; |
725 | @@ -247,8 +324,8 @@ |
726 | text_entry->SetToggleCursorVisibilityOnKeyFocus(true); |
727 | text_entry->clipboard_enabled = false; |
728 | |
729 | - text_input->SetMinimumHeight(Settings::GRID_SIZE); |
730 | - text_input->SetMaximumHeight(Settings::GRID_SIZE); |
731 | + text_input->SetMinimumHeight(Settings::GRID_SIZE.CP(scale)); |
732 | + text_input->SetMaximumHeight(Settings::GRID_SIZE.CP(scale)); |
733 | prompt_layout_->AddView(text_input, 1); |
734 | focus_queue_.push_back(text_input); |
735 | |
736 | @@ -289,6 +366,7 @@ |
737 | { |
738 | nux::Geometry const& geo = GetGeometry(); |
739 | auto* view = new unity::StaticCairoText(""); |
740 | + view->SetScale(scale); |
741 | view->SetFont(Settings::Instance().font_name()); |
742 | view->SetTextColor(color); |
743 | view->SetText(message); |
744 | |
745 | === modified file 'lockscreen/UserPromptView.h' |
746 | --- lockscreen/UserPromptView.h 2014-04-16 19:19:41 +0000 |
747 | +++ lockscreen/UserPromptView.h 2014-08-27 22:18:22 +0000 |
748 | @@ -48,7 +48,8 @@ |
749 | { |
750 | public: |
751 | UserPromptView(session::Manager::Ptr const& session_manager); |
752 | - ~UserPromptView() {}; |
753 | + |
754 | + nux::Property<double> scale; |
755 | |
756 | nux::View* focus_view(); |
757 | |
758 | @@ -62,17 +63,17 @@ |
759 | |
760 | private: |
761 | void ResetLayout(); |
762 | + void UpdateSize(); |
763 | + void EnsureBGLayer(); |
764 | |
765 | bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); |
766 | |
767 | session::Manager::Ptr session_manager_; |
768 | UserAuthenticatorPam user_authenticator_; |
769 | std::shared_ptr<nux::AbstractPaintLayer> bg_layer_; |
770 | + StaticCairoText* username_; |
771 | nux::VLayout* msg_layout_; |
772 | nux::VLayout* prompt_layout_; |
773 | - StaticCairoText* message_; |
774 | - StaticCairoText* error_; |
775 | - StaticCairoText* invalid_login_; |
776 | std::deque<TextInput*> focus_queue_; |
777 | |
778 | nux::Geometry cached_focused_geo_; |
779 | |
780 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
781 | --- plugins/unityshell/src/unityshell.cpp 2014-08-11 12:30:55 +0000 |
782 | +++ plugins/unityshell/src/unityshell.cpp 2014-08-27 22:18:22 +0000 |
783 | @@ -4002,7 +4002,7 @@ |
784 | return launcher_controller_; |
785 | } |
786 | |
787 | -std::shared_ptr<lockscreen::Controller> UnityScreen::lockscreen_controller() |
788 | +lockscreen::Controller::Ptr UnityScreen::lockscreen_controller() |
789 | { |
790 | return lockscreen_controller_; |
791 | } |
792 | |
793 | === modified file 'plugins/unityshell/src/unityshell.h' |
794 | --- plugins/unityshell/src/unityshell.h 2014-07-10 21:19:18 +0000 |
795 | +++ plugins/unityshell/src/unityshell.h 2014-08-27 22:18:22 +0000 |
796 | @@ -239,7 +239,7 @@ |
797 | |
798 | switcher::Controller::Ptr switcher_controller(); |
799 | launcher::Controller::Ptr launcher_controller(); |
800 | - std::shared_ptr<lockscreen::Controller> lockscreen_controller(); |
801 | + lockscreen::Controller::Ptr lockscreen_controller(); |
802 | |
803 | bool DoesPointIntersectUnityGeos(nux::Point const& pt); |
804 | |
805 | @@ -348,7 +348,7 @@ |
806 | session::DBusManager::Ptr session_dbus_manager_; |
807 | session::Controller::Ptr session_controller_; |
808 | lockscreen::DBusManager::Ptr screensaver_dbus_manager_; |
809 | - std::shared_ptr<lockscreen::Controller> lockscreen_controller_; |
810 | + lockscreen::Controller::Ptr lockscreen_controller_; |
811 | debug::DebugDBusInterface debugger_; |
812 | std::unique_ptr<BGHash> bghash_; |
813 | spread::Filter::Ptr spread_filter_; |
814 | |
815 | === modified file 'tests/test_previews_music_payment.cpp' |
816 | --- tests/test_previews_music_payment.cpp 2014-03-21 04:40:12 +0000 |
817 | +++ tests/test_previews_music_payment.cpp 2014-08-27 22:18:22 +0000 |
818 | @@ -21,6 +21,7 @@ |
819 | #include <gmock/gmock.h> |
820 | |
821 | #include <Nux/Nux.h> |
822 | +#include <Nux/VLayout.h> |
823 | #include <Nux/BaseWindow.h> |
824 | #include <unity-shared/StaticCairoText.h> |
825 | #include <unity-shared/CoverArt.h> |
826 | |
827 | === modified file 'tests/test_text_input.cpp' |
828 | --- tests/test_text_input.cpp 2014-03-21 04:40:12 +0000 |
829 | +++ tests/test_text_input.cpp 2014-08-27 22:18:22 +0000 |
830 | @@ -23,6 +23,7 @@ |
831 | #include <gtest/gtest.h> |
832 | |
833 | #include "unity-shared/DashStyle.h" |
834 | +#include "unity-shared/StaticCairoText.h" |
835 | #include "unity-shared/TextInput.h" |
836 | #include "test_utils.h" |
837 | |
838 | |
839 | === modified file 'unity-shared/IconTexture.cpp' |
840 | --- unity-shared/IconTexture.cpp 2014-07-09 10:30:59 +0000 |
841 | +++ unity-shared/IconTexture.cpp 2014-08-27 22:18:22 +0000 |
842 | @@ -142,7 +142,7 @@ |
843 | -1, _size, |
844 | sigc::mem_fun(this, &IconTexture::IconLoaded)); |
845 | } |
846 | - else if (_icon_name.find("http://") == 0) |
847 | + else if (_icon_name.find("://") != std::string::npos) |
848 | { |
849 | _handle = IconLoader::GetDefault().LoadFromURI(_icon_name, |
850 | -1, _size, sigc::mem_fun(this, &IconTexture::IconLoaded)); |
851 | |
852 | === modified file 'unity-shared/SearchBar.cpp' |
853 | --- unity-shared/SearchBar.cpp 2014-07-09 10:52:06 +0000 |
854 | +++ unity-shared/SearchBar.cpp 2014-08-27 22:18:22 +0000 |
855 | @@ -20,17 +20,24 @@ |
856 | #include "config.h" |
857 | |
858 | #include <Nux/Nux.h> |
859 | +#include <Nux/LayeredLayout.h> |
860 | #include <Nux/HLayout.h> |
861 | #include <Nux/VLayout.h> |
862 | +#include <Nux/TextEntry.h> |
863 | #include <NuxCore/Logger.h> |
864 | |
865 | +#include <gtk/gtk.h> |
866 | #include <glib/gi18n-lib.h> |
867 | |
868 | #include "SearchBar.h" |
869 | #include "CairoTexture.h" |
870 | #include "DashStyle.h" |
871 | #include "GraphicsUtils.h" |
872 | +#include "IconTexture.h" |
873 | +#include "IMTextEntry.h" |
874 | #include "RawPixel.h" |
875 | +#include "SearchBarSpinner.h" |
876 | +#include "StaticCairoText.h" |
877 | #include "UnitySettings.h" |
878 | |
879 | namespace unity |
880 | @@ -252,9 +259,8 @@ |
881 | expand_icon_->mouse_click.connect(mouse_expand); |
882 | } |
883 | |
884 | - sig_manager_.Add<void, GtkSettings*, GParamSpec*>(gtk_settings_get_default(), "notify::gtk-font-name", |
885 | - sigc::mem_fun(this, &SearchBar::OnFontChanged)); |
886 | - OnFontChanged(gtk_settings_get_default()); |
887 | + sig_manager_.Add<void, GtkSettings*>(gtk_settings_get_default(), "notify::gtk-font-name", sigc::hide(sigc::mem_fun(this, &SearchBar::OnFontChanged))); |
888 | + OnFontChanged(); |
889 | |
890 | search_hint.changed.connect([this](std::string const& s) { OnSearchHintChanged(); }); |
891 | search_string.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_search_string)); |
892 | @@ -347,13 +353,13 @@ |
893 | UpdateSearchBarSize(); |
894 | } |
895 | |
896 | -void SearchBar::OnFontChanged(GtkSettings* settings, GParamSpec* pspec) |
897 | +void SearchBar::OnFontChanged() |
898 | { |
899 | glib::String font_name; |
900 | PangoFontDescription* desc; |
901 | std::ostringstream font_desc; |
902 | |
903 | - g_object_get(settings, "gtk-font-name", &font_name, NULL); |
904 | + g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, NULL); |
905 | |
906 | desc = pango_font_description_from_string(font_name.Value()); |
907 | if (desc) |
908 | @@ -586,7 +592,7 @@ |
909 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.7f); |
910 | cairo_stroke(cr); |
911 | |
912 | - nux::BaseTexture* texture2D = texture_from_cairo_graphics(cairo_graphics); |
913 | + auto texture2D = texture_ptr_from_cairo_graphics(cairo_graphics); |
914 | |
915 | nux::TexCoordXForm texxform; |
916 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); |
917 | @@ -602,8 +608,6 @@ |
918 | nux::color::White, |
919 | true, |
920 | rop)); |
921 | - |
922 | - texture2D->UnReference(); |
923 | } |
924 | |
925 | void SearchBar::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) |
926 | |
927 | === modified file 'unity-shared/SearchBar.h' |
928 | --- unity-shared/SearchBar.h 2014-03-20 04:05:39 +0000 |
929 | +++ unity-shared/SearchBar.h 2014-08-27 22:18:22 +0000 |
930 | @@ -20,28 +20,28 @@ |
931 | #ifndef SEARCH_BAR_H |
932 | #define SEARCH_BAR_H |
933 | |
934 | -#include <gtk/gtk.h> |
935 | +#include <Nux/TextEntry.h> |
936 | #include <NuxCore/Property.h> |
937 | -#include <Nux/LayeredLayout.h> |
938 | -#include <Nux/VLayout.h> |
939 | -#include <Nux/TextEntry.h> |
940 | #include <UnityCore/GLibSignal.h> |
941 | #include <UnityCore/GLibSource.h> |
942 | |
943 | -#include "SearchBarSpinner.h" |
944 | -#include "unity-shared/IconTexture.h" |
945 | -#include "unity-shared/IMTextEntry.h" |
946 | #include "unity-shared/Introspectable.h" |
947 | -#include "unity-shared/StaticCairoText.h" |
948 | |
949 | namespace nux |
950 | { |
951 | class AbstractPaintLayer; |
952 | +class LayeredLayout; |
953 | class LinearLayout; |
954 | +class SpaceLayout; |
955 | +class VLayout; |
956 | } |
957 | |
958 | namespace unity |
959 | { |
960 | +class IconTexture; |
961 | +class IMTextEntry; |
962 | +class SearchBarSpinner; |
963 | +class StaticCairoText; |
964 | |
965 | class SearchBar : public unity::debug::Introspectable, public nux::View |
966 | { |
967 | @@ -71,7 +71,7 @@ |
968 | sigc::signal<void, std::string const&> live_search_reached; |
969 | |
970 | private: |
971 | - void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL); |
972 | + void OnFontChanged(); |
973 | void OnSearchHintChanged(); |
974 | |
975 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); |
976 | |
977 | === modified file 'unity-shared/SearchBarSpinner.h' |
978 | --- unity-shared/SearchBarSpinner.h 2014-07-10 19:30:17 +0000 |
979 | +++ unity-shared/SearchBarSpinner.h 2014-08-27 22:18:22 +0000 |
980 | @@ -22,8 +22,6 @@ |
981 | |
982 | #include <Nux/Nux.h> |
983 | #include <Nux/View.h> |
984 | -#include <NuxGraphics/GraphicsEngine.h> |
985 | -#include <Nux/TextureArea.h> |
986 | #include <NuxCore/Math/Matrix4.h> |
987 | #include <UnityCore/GLibSource.h> |
988 | #include "unity-shared/Introspectable.h" |
989 | |
990 | === modified file 'unity-shared/SpreadFilter.cpp' |
991 | --- unity-shared/SpreadFilter.cpp 2014-07-09 10:53:43 +0000 |
992 | +++ unity-shared/SpreadFilter.cpp 2014-08-27 22:18:22 +0000 |
993 | @@ -20,11 +20,13 @@ |
994 | #include "SpreadFilter.h" |
995 | |
996 | #include <Nux/HLayout.h> |
997 | +#include <UnityCore/GLibWrapper.h> |
998 | + |
999 | #include "AnimationUtils.h" |
1000 | +#include "ApplicationManager.h" |
1001 | #include "SearchBar.h" |
1002 | #include "UnitySettings.h" |
1003 | #include "WindowManager.h" |
1004 | -#include "ApplicationManager.h" |
1005 | #include "RawPixel.h" |
1006 | |
1007 | namespace unity |
1008 | |
1009 | === modified file 'unity-shared/TextInput.cpp' |
1010 | --- unity-shared/TextInput.cpp 2014-08-11 12:30:29 +0000 |
1011 | +++ unity-shared/TextInput.cpp 2014-08-27 22:18:22 +0000 |
1012 | @@ -17,25 +17,38 @@ |
1013 | * Authored by: Manuel de la Pena <manuel.delapena@canonical.com> |
1014 | */ |
1015 | |
1016 | +#include "config.h" |
1017 | #include "TextInput.h" |
1018 | -#include "unity-shared/IconTexture.h" |
1019 | -#include "unity-shared/DashStyle.h" |
1020 | -#include "unity-shared/RawPixel.h" |
1021 | -#include "unity-shared/PreviewStyle.h" |
1022 | -#include "unity-shared/TextureCache.h" |
1023 | + |
1024 | +#include <gtk/gtk.h> |
1025 | +#include <glib/gi18n-lib.h> |
1026 | + |
1027 | +#include <Nux/LayeredLayout.h> |
1028 | +#include <Nux/HLayout.h> |
1029 | +#include <Nux/VLayout.h> |
1030 | +#include <NuxCore/Logger.h> |
1031 | + |
1032 | +#include "CairoTexture.h" |
1033 | +#include "StaticCairoText.h" |
1034 | +#include "IconTexture.h" |
1035 | +#include "IMTextEntry.h" |
1036 | +#include "DashStyle.h" |
1037 | +#include "PreviewStyle.h" |
1038 | +#include "RawPixel.h" |
1039 | +#include "TextureCache.h" |
1040 | +#include "UnitySettings.h" |
1041 | |
1042 | namespace unity |
1043 | { |
1044 | |
1045 | namespace |
1046 | { |
1047 | -const float kExpandDefaultIconOpacity = 1.0f; |
1048 | - |
1049 | -const int SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10; |
1050 | -const int LEFT_INTERNAL_PADDING = 6; |
1051 | -const int TEXT_INPUT_RIGHT_BORDER = 10; |
1052 | - |
1053 | -const int HIGHLIGHT_HEIGHT = 24; |
1054 | +const int BORDER_RADIUS = 5; |
1055 | +const int TOOLTIP_WAIT = 500; |
1056 | +const RawPixel SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10_em; |
1057 | +const RawPixel LEFT_INTERNAL_PADDING = 6_em; |
1058 | +const RawPixel TEXT_INPUT_RIGHT_BORDER = 10_em; |
1059 | +const RawPixel HINT_PADDING = 3_em; |
1060 | |
1061 | const RawPixel TOOLTIP_Y_OFFSET = 3_em; |
1062 | const RawPixel TOOLTIP_OFFSET = 10_em; |
1063 | @@ -47,15 +60,11 @@ |
1064 | const int HINT_LABEL_FONT_SIZE = 11; |
1065 | |
1066 | const std::string PANGO_ENTRY_DEFAULT_FONT_FAMILY = "Ubuntu"; |
1067 | -const int PANGO_ENTRY_FONT_SIZE = 14; |
1068 | - |
1069 | -} |
1070 | +const RawPixel PANGO_ENTRY_FONT_SIZE = 14_em; |
1071 | |
1072 | nux::logging::Logger logger("unity.textinput"); |
1073 | |
1074 | -NUX_IMPLEMENT_OBJECT_TYPE(TextInput); |
1075 | - |
1076 | -nux::AbstractPaintLayer* CreateWarningLayer(nux::BaseTexture* texture) |
1077 | +std::shared_ptr<nux::AbstractPaintLayer> CreateWarningLayer(nux::BaseTexture* texture) |
1078 | { |
1079 | // Create the texture layer |
1080 | nux::TexCoordXForm texxform; |
1081 | @@ -71,12 +80,11 @@ |
1082 | rop.SrcBlend = GL_ONE; |
1083 | rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; |
1084 | |
1085 | - return (new nux::TextureLayer(texture->GetDeviceTexture(), |
1086 | - texxform, |
1087 | - nux::color::White, |
1088 | - true, |
1089 | - rop)); |
1090 | -} |
1091 | + return std::make_shared<nux::TextureLayer>(texture->GetDeviceTexture(), texxform, nux::color::White, true, rop); |
1092 | +} |
1093 | +} |
1094 | + |
1095 | +NUX_IMPLEMENT_OBJECT_TYPE(TextInput); |
1096 | |
1097 | TextInput::TextInput(NUX_FILE_LINE_DECL) |
1098 | : View(NUX_FILE_LINE_PARAM) |
1099 | @@ -85,30 +93,30 @@ |
1100 | , hint_font_size(HINT_LABEL_FONT_SIZE) |
1101 | , show_activator(false) |
1102 | , show_caps_lock(false) |
1103 | + , scale(1.0) |
1104 | , bg_layer_(new nux::ColorLayer(nux::Color(0xff595853), true)) |
1105 | , caps_lock_on(false) |
1106 | , last_width_(-1) |
1107 | , last_height_(-1) |
1108 | - , mouse_over_warning_icon_(false) |
1109 | { |
1110 | layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); |
1111 | - layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING, TEXT_INPUT_RIGHT_BORDER); |
1112 | - layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT); |
1113 | + layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING.CP(scale), TEXT_INPUT_RIGHT_BORDER.CP(scale)); |
1114 | + layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT.CP(scale)); |
1115 | SetLayout(layout_); |
1116 | |
1117 | - nux::HLayout* hint_layout = new nux::HLayout(NUX_TRACKER_LOCATION); |
1118 | - hint_layout->SetLeftAndRightPadding(3, 3); |
1119 | + hint_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); |
1120 | + hint_layout_->SetLeftAndRightPadding(HINT_PADDING.CP(scale), HINT_PADDING.CP(scale)); |
1121 | |
1122 | hint_ = new StaticCairoText(""); |
1123 | hint_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 0.5f)); |
1124 | - hint_layout->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1125 | + hint_->SetScale(scale); |
1126 | + hint_layout_->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1127 | hint_font_name.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateHintFont))); |
1128 | hint_font_size.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateHintFont))); |
1129 | UpdateHintFont(); |
1130 | |
1131 | pango_entry_ = new IMTextEntry(); |
1132 | pango_entry_->SetFontFamily(PANGO_ENTRY_DEFAULT_FONT_FAMILY.c_str()); |
1133 | - pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE); |
1134 | pango_entry_->cursor_moved.connect([this](int i) { QueueDraw(); }); |
1135 | pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown)); |
1136 | pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus)); |
1137 | @@ -117,14 +125,16 @@ |
1138 | }); |
1139 | |
1140 | layered_layout_ = new nux::LayeredLayout(); |
1141 | - layered_layout_->AddLayer(hint_layout); |
1142 | + layered_layout_->AddLayer(hint_layout_); |
1143 | layered_layout_->AddLayer(pango_entry_); |
1144 | layered_layout_->SetPaintAll(true); |
1145 | layered_layout_->SetActiveLayerN(1); |
1146 | layout_->AddView(layered_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); |
1147 | |
1148 | + UpdateSize(); |
1149 | + |
1150 | // Caps lock warning |
1151 | - warning_ = new IconTexture(LoadWarningIcon(DEFAULT_ICON_SIZE)); |
1152 | + warning_ = new IconTexture(LoadWarningIcon(DEFAULT_ICON_SIZE.CP(scale))); |
1153 | warning_->SetVisible(caps_lock_on()); |
1154 | layout_->AddView(warning_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1155 | caps_lock_on.changed.connect([this] (bool on) { |
1156 | @@ -136,15 +146,12 @@ |
1157 | } |
1158 | }); |
1159 | |
1160 | - show_caps_lock.changed.connect([this] (bool changed) { |
1161 | - if (!warning_tooltip_.IsValid()) |
1162 | - LoadWarningTooltip(); |
1163 | - |
1164 | - CheckIfCapsLockOn(); |
1165 | - }); |
1166 | + show_caps_lock.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::CheckIfCapsLockOn))); |
1167 | + scale.changed.connect(sigc::mem_fun(this, &TextInput::UpdateScale)); |
1168 | + Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::UpdateSize))); |
1169 | |
1170 | // Activator |
1171 | - activator_ = new IconTexture(LoadActivatorIcon(DEFAULT_ICON_SIZE)); |
1172 | + activator_ = new IconTexture(LoadActivatorIcon(DEFAULT_ICON_SIZE.CP(scale))); |
1173 | activator_->SetVisible(show_activator()); |
1174 | layout_->AddView(activator_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1175 | |
1176 | @@ -159,12 +166,15 @@ |
1177 | // Spinner |
1178 | spinner_ = new SearchBarSpinner(); |
1179 | spinner_->SetVisible(false); |
1180 | - spinner_->SetMinMaxSize(22, 22); |
1181 | + spinner_->scale = scale(); |
1182 | layout_->AddView(spinner_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
1183 | |
1184 | - sig_manager_.Add<void, GtkSettings*, GParamSpec*>(gtk_settings_get_default(), |
1185 | - "notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged)); |
1186 | - OnFontChanged(gtk_settings_get_default()); |
1187 | + sig_manager_.Add<void, GtkSettings*>(gtk_settings_get_default(), "notify::gtk-font-name", sigc::hide(sigc::mem_fun(this, &TextInput::OnFontChanged))); |
1188 | + OnFontChanged(); |
1189 | + |
1190 | + sig_manager_.Add<void, GdkKeymap*>(gdk_keymap_get_default(), "state-changed", [this](GdkKeymap*) { |
1191 | + CheckIfCapsLockOn(); |
1192 | + }); |
1193 | |
1194 | sig_manager_.Add<void, GdkKeymap*>(gdk_keymap_get_default(), "state-changed", [this](GdkKeymap*) { |
1195 | CheckIfCapsLockOn(); |
1196 | @@ -177,16 +187,47 @@ |
1197 | input_hint.changed.connect([this](std::string const& s) { OnInputHintChanged(); }); |
1198 | |
1199 | warning_->mouse_enter.connect([this] (int x, int y, int button, int key_flags) { |
1200 | - mouse_over_warning_icon_ = true; |
1201 | - QueueDraw(); |
1202 | + tooltip_timeout_.reset(new glib::Timeout(TOOLTIP_WAIT, [this] { |
1203 | + tooltip_timeout_.reset(); |
1204 | + QueueDraw(); |
1205 | + return false; |
1206 | + })); |
1207 | }); |
1208 | |
1209 | warning_->mouse_leave.connect([this] (int x, int y, int button, int key_flags) { |
1210 | - mouse_over_warning_icon_ = false; |
1211 | - QueueDraw(); |
1212 | + tooltip_timeout_ ? tooltip_timeout_.reset() : QueueDraw(); |
1213 | }); |
1214 | } |
1215 | |
1216 | +void TextInput::UpdateSize() |
1217 | +{ |
1218 | + pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE.CP(scale * Settings::Instance().font_scaling())); |
1219 | + int entry_min = pango_entry_->GetMinimumHeight(); |
1220 | + pango_entry_->SetMaximumHeight(entry_min); |
1221 | + layered_layout_->SetMinimumHeight(entry_min); |
1222 | + layered_layout_->SetMaximumHeight(entry_min); |
1223 | +} |
1224 | + |
1225 | +void TextInput::UpdateScale(double scale) |
1226 | +{ |
1227 | + layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING.CP(scale), TEXT_INPUT_RIGHT_BORDER.CP(scale)); |
1228 | + layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT.CP(scale)); |
1229 | + |
1230 | + UpdateSize(); |
1231 | + |
1232 | + hint_layout_->SetLeftAndRightPadding(HINT_PADDING.CP(scale), HINT_PADDING.CP(scale)); |
1233 | + hint_->SetScale(scale); |
1234 | + hint_->SetMaximumHeight(pango_entry_->GetMinimumHeight()); |
1235 | + |
1236 | + spinner_->scale = scale; |
1237 | + activator_->SetTexture(LoadActivatorIcon(DEFAULT_ICON_SIZE.CP(scale))); |
1238 | + warning_->SetTexture(LoadWarningIcon(DEFAULT_ICON_SIZE.CP(scale))); |
1239 | + warning_tooltip_.Release(); |
1240 | + |
1241 | + QueueRelayout(); |
1242 | + QueueDraw(); |
1243 | +} |
1244 | + |
1245 | void TextInput::CheckIfCapsLockOn() |
1246 | { |
1247 | GdkKeymap* keymap = gdk_keymap_get_default(); |
1248 | @@ -196,11 +237,7 @@ |
1249 | void TextInput::SetSpinnerVisible(bool visible) |
1250 | { |
1251 | spinner_->SetVisible(visible); |
1252 | - |
1253 | - if (visible) |
1254 | - activator_->SetVisible(false); |
1255 | - else |
1256 | - activator_->SetVisible(show_activator()); |
1257 | + activator_->SetVisible(!visible && show_activator()); |
1258 | } |
1259 | |
1260 | void TextInput::SetSpinnerState(SpinnerState spinner_state) |
1261 | @@ -269,6 +306,7 @@ |
1262 | std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free); |
1263 | pango_context_set_font_description(context, desc.get()); |
1264 | pango_context_set_language(context, gtk_get_default_language()); |
1265 | + pango_cairo_context_set_resolution(context, 96.0 * Settings::Instance().font_scaling()); |
1266 | |
1267 | pango_layout_set_height(layout, -1); //avoid wrap lines |
1268 | pango_layout_set_text(layout, _("Caps lock is on"), -1); |
1269 | @@ -278,7 +316,8 @@ |
1270 | extents.width += TOOLTIP_OFFSET; |
1271 | extents.height += TOOLTIP_OFFSET; |
1272 | |
1273 | - nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, extents.width, extents.height); |
1274 | + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, RawPixel(extents.width).CP(scale), RawPixel(extents.height).CP(scale)); |
1275 | + cairo_surface_set_device_scale(cg.GetSurface(), scale, scale); |
1276 | cairo_t* cr = cg.GetInternalContext(); |
1277 | |
1278 | gtk_render_background(style_context, cr, 0, 0, extents.width, extents.height); |
1279 | @@ -288,27 +327,28 @@ |
1280 | warning_tooltip_ = texture_ptr_from_cairo_graphics(cg); |
1281 | } |
1282 | |
1283 | -void TextInput::OnFontChanged(GtkSettings* settings, GParamSpec* pspec) |
1284 | +void TextInput::OnFontChanged() |
1285 | { |
1286 | glib::String font_name; |
1287 | PangoFontDescription* desc; |
1288 | |
1289 | - g_object_get(settings, "gtk-font-name", &font_name, NULL); |
1290 | + g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, NULL); |
1291 | |
1292 | desc = pango_font_description_from_string(font_name.Value()); |
1293 | if (desc) |
1294 | { |
1295 | pango_entry_->SetFontFamily(pango_font_description_get_family(desc)); |
1296 | - pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE); |
1297 | pango_entry_->SetFontOptions(gdk_screen_get_font_options(gdk_screen_get_default())); |
1298 | + UpdateSize(); |
1299 | |
1300 | if (hint_font_name() == HINT_LABEL_DEFAULT_FONT_NAME) |
1301 | { |
1302 | std::ostringstream font_desc; |
1303 | font_desc << pango_font_description_get_family(desc) << " " << hint_font_size(); |
1304 | hint_->SetFont(font_desc.str().c_str()); |
1305 | - pango_font_description_free(desc); |
1306 | } |
1307 | + |
1308 | + pango_font_description_free(desc); |
1309 | } |
1310 | } |
1311 | |
1312 | @@ -356,8 +396,8 @@ |
1313 | |
1314 | layout_->ProcessDraw(GfxContext, force_draw); |
1315 | |
1316 | - if (caps_lock_on && mouse_over_warning_icon_) |
1317 | - PaintWarningTooltip(GfxContext); |
1318 | + if (caps_lock_on && warning_->IsMouseInside() && !tooltip_timeout_) |
1319 | + PaintWarningTooltip(GfxContext); |
1320 | |
1321 | if (!IsFullRedraw()) |
1322 | { |
1323 | @@ -373,42 +413,39 @@ |
1324 | |
1325 | void TextInput::PaintWarningTooltip(nux::GraphicsEngine& graphics_engine) |
1326 | { |
1327 | - nux::Geometry warning_geo = warning_->GetGeometry(); |
1328 | - |
1329 | - nux::Geometry tooltip_geo = {warning_geo.x - (warning_tooltip_->GetWidth() + TOOLTIP_OFFSET / 2), |
1330 | - warning_geo.y - TOOLTIP_Y_OFFSET, |
1331 | + nux::Geometry const& warning_geo = warning_->GetGeometry(); |
1332 | + |
1333 | + if (!warning_tooltip_.IsValid()) |
1334 | + LoadWarningTooltip(); |
1335 | + |
1336 | + nux::Geometry tooltip_geo = {warning_geo.x - (warning_tooltip_->GetWidth() + TOOLTIP_OFFSET.CP(scale) / 2), |
1337 | + warning_geo.y - TOOLTIP_Y_OFFSET.CP(scale), |
1338 | warning_tooltip_->GetWidth(), |
1339 | warning_tooltip_->GetHeight()}; |
1340 | |
1341 | - nux::GetPainter().PushDrawLayer(graphics_engine, tooltip_geo, CreateWarningLayer(warning_tooltip_.GetPointer())); |
1342 | + auto const& warning_layer = CreateWarningLayer(warning_tooltip_.GetPointer()); |
1343 | + nux::GetPainter().PushDrawLayer(graphics_engine, tooltip_geo, warning_layer.get()); |
1344 | } |
1345 | |
1346 | void TextInput::UpdateBackground(bool force) |
1347 | { |
1348 | - int RADIUS = 5; |
1349 | nux::Geometry geo(GetGeometry()); |
1350 | |
1351 | - LOG_DEBUG(logger) << "height: " |
1352 | - << geo.height << " - " |
1353 | - << layout_->GetGeometry().height << " - " |
1354 | - << pango_entry_->GetGeometry().height; |
1355 | - |
1356 | - if (geo.width == last_width_ |
1357 | - && geo.height == last_height_ |
1358 | - && force == false) |
1359 | + if (geo.width == last_width_ && geo.height == last_height_ && !force) |
1360 | return; |
1361 | |
1362 | last_width_ = geo.width; |
1363 | last_height_ = geo.height; |
1364 | |
1365 | nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, last_width_, last_height_); |
1366 | + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale); |
1367 | cairo_t* cr = cairo_graphics.GetInternalContext(); |
1368 | |
1369 | cairo_graphics.DrawRoundedRectangle(cr, |
1370 | 1.0f, |
1371 | 0.5, 0.5, |
1372 | - RADIUS, |
1373 | - last_width_ - 1, last_height_ - 1, |
1374 | + BORDER_RADIUS, |
1375 | + (last_width_/scale) - 1, (last_height_/scale) - 1, |
1376 | false); |
1377 | |
1378 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1379 | @@ -418,7 +455,7 @@ |
1380 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.7f); |
1381 | cairo_stroke(cr); |
1382 | |
1383 | - nux::BaseTexture* texture2D = texture_from_cairo_graphics(cairo_graphics); |
1384 | + auto texture2D = texture_ptr_from_cairo_graphics(cairo_graphics); |
1385 | |
1386 | nux::TexCoordXForm texxform; |
1387 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); |
1388 | @@ -434,8 +471,6 @@ |
1389 | nux::color::White, |
1390 | true, |
1391 | rop)); |
1392 | - |
1393 | - texture2D->UnReference(); |
1394 | } |
1395 | |
1396 | void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) |
1397 | |
1398 | === modified file 'unity-shared/TextInput.h' |
1399 | --- unity-shared/TextInput.h 2014-08-11 12:30:29 +0000 |
1400 | +++ unity-shared/TextInput.h 2014-08-27 22:18:22 +0000 |
1401 | @@ -20,36 +20,27 @@ |
1402 | #ifndef TEXTINPUT_H |
1403 | #define TEXTINPUT_H |
1404 | |
1405 | -#include "config.h" |
1406 | - |
1407 | -#include <glib/gi18n-lib.h> |
1408 | -#include <gtk/gtk.h> |
1409 | - |
1410 | #include <Nux/Nux.h> |
1411 | -#include <Nux/HLayout.h> |
1412 | -#include <Nux/LayeredLayout.h> |
1413 | -#include <Nux/VLayout.h> |
1414 | -#include <Nux/TextEntry.h> |
1415 | -#include <NuxCore/Logger.h> |
1416 | -#include <NuxCore/Property.h> |
1417 | #include <UnityCore/GLibSignal.h> |
1418 | #include <UnityCore/GLibSource.h> |
1419 | |
1420 | -#include "CairoTexture.h" |
1421 | -#include "unity-shared/IconTexture.h" |
1422 | -#include "unity-shared/IMTextEntry.h" |
1423 | -#include "unity-shared/Introspectable.h" |
1424 | -#include "unity-shared/SearchBarSpinner.h" |
1425 | -#include "unity-shared/StaticCairoText.h" |
1426 | +#include "Introspectable.h" |
1427 | +#include "IMTextEntry.h" |
1428 | +#include "SearchBarSpinner.h" |
1429 | |
1430 | namespace nux |
1431 | { |
1432 | class AbstractPaintLayer; |
1433 | +class LayeredLayout; |
1434 | class LinearLayout; |
1435 | +class HLayout; |
1436 | } |
1437 | |
1438 | namespace unity |
1439 | { |
1440 | +class IconTexture; |
1441 | +class StaticCairoText; |
1442 | +class SearchBarSpinner; |
1443 | |
1444 | class TextInput : public unity::debug::Introspectable, public nux::View |
1445 | { |
1446 | @@ -74,13 +65,16 @@ |
1447 | nux::ROProperty<bool> im_preedit; |
1448 | nux::Property<bool> show_activator; |
1449 | nux::Property<bool> show_caps_lock; |
1450 | + nux::Property<double> scale; |
1451 | |
1452 | private: |
1453 | - void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL); |
1454 | + void OnFontChanged(); |
1455 | void UpdateHintFont(); |
1456 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); |
1457 | void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
1458 | void UpdateBackground(bool force); |
1459 | + void UpdateScale(double); |
1460 | + void UpdateSize(); |
1461 | |
1462 | std::string GetName() const; |
1463 | |
1464 | @@ -118,18 +112,19 @@ |
1465 | std::unique_ptr<nux::AbstractPaintLayer> bg_layer_; |
1466 | std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_; |
1467 | nux::HLayout* layout_; |
1468 | + nux::HLayout* hint_layout_; |
1469 | nux::LayeredLayout* layered_layout_; |
1470 | SearchBarSpinner* spinner_; |
1471 | |
1472 | nux::Property<bool> caps_lock_on; |
1473 | int last_width_; |
1474 | int last_height_; |
1475 | - bool mouse_over_warning_icon_; |
1476 | |
1477 | IconTexture* warning_; |
1478 | IconTexture* activator_; |
1479 | nux::ObjectPtr<nux::BaseTexture> warning_tooltip_; |
1480 | |
1481 | + glib::Source::UniquePtr tooltip_timeout_; |
1482 | glib::SignalManager sig_manager_; |
1483 | }; |
1484 |
FAILED: Continuous integration, rev:3872 jenkins. qa.ubuntu. com/job/ unity-ci/ 1033/ jenkins. qa.ubuntu. com/job/ unity-utopic- amd64-ci/ 120/console jenkins. qa.ubuntu. com/job/ unity-utopic- armhf-ci/ 120/console jenkins. qa.ubuntu. com/job/ unity-utopic- i386-ci/ 120/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1033/ rebuild
http://