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