diff -Nru unity-7.2.2+14.04.20140714/AUTHORS unity-7.2.3+14.04.20140826/AUTHORS --- unity-7.2.2+14.04.20140714/AUTHORS 2014-07-14 16:30:44.000000000 +0200 +++ unity-7.2.3+14.04.20140826/AUTHORS 2014-08-26 15:48:40.000000000 +0200 @@ -49,6 +49,7 @@ Christopher Townsend Chris Townsend Chris Townsend + Chris Townsend , Andrea Azzarone CI bot Daniel d'Andrada Daniel van Vugt @@ -117,6 +118,7 @@ Marco Trevisan (Treviño) , Andrea Cimitan Marco Trevisan (Treviño) , Brandon Schaefer Marco Trevisan (Treviño) , Brandon Schaefer , Tim Penhey + Marco Trevisan (Treviño) , Eleni Maria Stea Marco Trevisan (Treviño) , Lukas Vacek Marco Trevisan (Treviño) , Michal Hruby Marco Trevisan (Treviño) , Sam Spilsbury @@ -187,6 +189,7 @@ smspillaz , Sam Spilsbury Stephen M. Webb Stephen M. Webb , Andrew McCarthy + Stephen M. Webb , Pawel Szubert Steve Langasek Sven Baars Tarmac diff -Nru unity-7.2.2+14.04.20140714/ChangeLog unity-7.2.3+14.04.20140826/ChangeLog --- unity-7.2.2+14.04.20140714/ChangeLog 2014-07-14 16:30:44.000000000 +0200 +++ unity-7.2.3+14.04.20140826/ChangeLog 2014-08-26 15:48:40.000000000 +0200 @@ -1,3 +1,123 @@ +2014-07-24 Chris Townsend + + Added changelog entry for lp:1340477. + +2014-07-24 Marco Trevisan (Treviño) + + Hud: scale to match current DPI settings for monitor + +2014-07-24 Chris Townsend + + Added changelog entries for lp:1283415 and lp:1340394. + +2014-07-24 Marco Trevisan (Treviño) + + OverlayRendering: correctly scale the overlays borders and edges to match settings + + DashStyle has been modified to return smart pointers of textures that are loaded + depending on the scale level. The cache will make sure that we don't duplicate + the textures and that they get removed when not needed anymore. + + Also thanks to this the SearchBarSpinner textures (and the other spinners as well) + uses the SVGs scaled at the proper size (I desgined a new SVG for the magnifier, + as we only had a PNG). + +2014-07-24 Chris Townsend + + Added changelog entry for lp:1340171. + +2014-07-24 Marco Trevisan (Treviño) + + FilterWidgets: add support for scaling. + +2014-07-24 Chris Townsend + + Added changelog entries for lp:1339629. + +2014-07-24 Marco Trevisan (Treviño) + + Previews: scale the dash preview contents to match current monitor scaling + + Improved also the scaling of search-bar, spinner, categories and many other components. + +2014-07-23 Chris Townsend + + Added changelog entries for lp:1324114. + +2014-07-23 Stephen M. Webb + + Reduce the scope of the kill command when restarting Compiz. + +2014-07-23 Chris Townsend + + Add changelog entries for lp:1306211, lp:1320051, and lp:1320071. + +2014-07-23 Marco Trevisan (Treviño) + + LockScreenAcceleratorController: do ther configured action on power special keys press + + We finally can suspend, shutdown, hibernate or start the screensaver when the screen is locked, using + the Suspend, Sleep, Hibernate and PowerOff hardware keys. + + Also the Shutdown dialog doesn't allow now to lock the session if it is not allowed by settings. + +2014-07-23 Chris Townsend + + Add changelog entry for lp:1292391. + +2014-07-23 Andrea Azzarone + + Manually emit nux::Area::geometry_changed beucase nux can fail to emit it. + +2014-07-23 Chris Townsend + + Add changelog entry for lp:1312107. + +2014-07-23 Andrea Azzarone + + Remove cross fade effect during lock/unlocking. A simple fading works just fine. + +2014-07-14 CI bot + + Releasing 7.2.2+14.04.20140714-0ubuntu1 + +2014-07-14 Chris Townsend + + Release Unity 7.2.2. + Approved by: Stephen M. Webb + +2014-07-03 Chris Townsend + + Bump upstream release to 7.2.2. + +2014-07-14 Chris Townsend + + Prepare for upstream micro-release 7.2.2 that includes fixes for the following bugs: + Bug #607796: Launcher, Window management - Dragging and holding a selection over an entry in the Launcher should spread out windows belonging to that application + Bug #727902: Launcher icon highlighting should not switch off as soon the cursor moves after the app spread appears. + Bug #741869: Unity/compiz intercepts Super and Alt keypresses from grabbed windows like VMs. + Bug #754580: Cannot move tabs between multiple Firefox or Chromium windows while using Unity unless windows are both unmaximized, unminimized, and visible. + Bug #839728: Launcher - dragging a item on top of a launcher tile that is a valid drop receptacle in the Launcher should cause that launcher tile to glow + Bug #924840: Keyboard shortcuts overlay text too long + Bug #1281058: [UIFe] The system shutdowns when multiple accounts are open + Bug #1283775: Launcher: icon pips are not always updated properly + Bug #1304882: [Regression] Launcher doesn't reappear fully after hiding from DND + Bug #1305586: Lock screen is unusable when some windows have a keyboard/mouse grab + Bug #1307738: Lockscreen caps lock icon drawn under text entry, should be a white icon. + Bug #1308288: Lockscreen warning icon has no tooltip + Bug #1308323: Shutdown/reboot/login/logout dialogs not scaled after toggling UI scale Edit + Bug #1308911: Clipboard contents are accessible within lockscreen + Bug #1309739: Unity launcher icon edge illumination is offset + Bug #1310200: Indicators disappear at the panel (clementine, dropbox, skype etc) + Bug #1313280: Fullscreen window set to "Always on Top" in single-monitor will hide the lockscreen + Bug #1316005: Panel shadow appears over full screen applications w/ locally integrated menus enabled + Bug #1317348: Switcher (Alt-Tab) does not respect monitor-defined scaling factor + Bug #1317356: Shortcut hint does not respect monitor scaling factor + Bug #1317869: Keyboard shortcuts overlay does not show up when workspaces are enabled at 1366x768 + Bug #1320438: Unity launcher auto hide fails on screen unlock using "Super+L" + Bug #1321043: [regression] lock screen bypass with touchpad Fixes: 607796, 727902, 741869, 754580, 839728, 924840, 1281058, 1283775, 1304882, 1305586, 1307738, 1308288, 1308323, 1308911, 1309739, 1310200, 1313280, 1316005, 1317348, 1317356, 1317869, 1320438, 1321043 + Approved by: Marco Trevisan (Treviño) + 2014-07-01 Chris Townsend Add changelog entry for lp:1281058. diff -Nru unity-7.2.2+14.04.20140714/CMakeLists.txt unity-7.2.3+14.04.20140826/CMakeLists.txt --- unity-7.2.2+14.04.20140714/CMakeLists.txt 2014-07-14 16:30:44.000000000 +0200 +++ unity-7.2.3+14.04.20140826/CMakeLists.txt 2014-08-26 15:48:40.000000000 +0200 @@ -10,7 +10,7 @@ set (PROJECT_NAME "unity") set (UNITY_MAJOR 7) set (UNITY_MINOR 2) -set (UNITY_MICRO 2) +set (UNITY_MICRO 3) set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}") set (UNITY_API_VERSION "6.0") set (UNITY_COMPONENTS_VERSION "6") diff -Nru unity-7.2.2+14.04.20140714/dash/DashController.cpp unity-7.2.3+14.04.20140826/dash/DashController.cpp --- unity-7.2.2+14.04.20140714/dash/DashController.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/DashController.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -468,8 +468,8 @@ nux::Geometry const& view_content_geo(view_->GetContentGeometry()); nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height); - geo.width += style.GetDashRightTileWidth(); - geo.height += style.GetDashBottomTileHeight(); + geo.width += style.GetDashRightTileWidth().CP(view_->scale()); + geo.height += style.GetDashBottomTileHeight().CP(view_->scale()); return geo; } diff -Nru unity-7.2.2+14.04.20140714/dash/DashView.cpp unity-7.2.3+14.04.20140826/dash/DashView.cpp --- unity-7.2.2+14.04.20140714/dash/DashView.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/DashView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -36,7 +36,6 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/KeyboardUtil.h" #include "unity-shared/PreviewStyle.h" -#include "unity-shared/RawPixel.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UnitySettings.h" #include "unity-shared/WindowManager.h" @@ -57,6 +56,8 @@ const RawPixel DASH_RESULT_RIGHT_PAD = 35_em; const RawPixel PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10_em; +const RawPixel PREVIEW_CONTAINER_TRIANGLE_WIDTH = 14_em; +const RawPixel PREVIEW_CONTAINER_TRIANGLE_HEIGHT = 12_em; const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 1000; } @@ -112,6 +113,7 @@ DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter) : nux::View(NUX_TRACKER_LOCATION) + , scale(Settings::Instance().em()->DPIScale()) , scopes_(scopes) , application_starter_(application_starter) , preview_container_(nullptr) @@ -129,7 +131,6 @@ , animate_preview_container_value_(0.0) , animate_preview_value_(0.0) , overlay_window_buttons_(new OverlayWindowButtons()) - , cv_(Settings::Instance().em()) , monitor_(0) { renderer_.SetOwner(this); @@ -144,7 +145,6 @@ mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview)); - Relayout(); if (scopes_) { @@ -159,6 +159,8 @@ }); unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &DashView::OnDPIChanged)); + scale.changed.connect(sigc::mem_fun(this, &DashView::UpdateScale)); + UpdateScale(scale()); } DashView::~DashView() @@ -232,13 +234,13 @@ if (!preview_container_) { - preview_container_ = previews::PreviewContainer::Ptr(new previews::PreviewContainer()); + preview_container_ = new previews::PreviewContainer(); preview_container_->SetRedirectRenderingToTexture(true); AddChild(preview_container_.GetPointer()); preview_container_->SetParentObject(this); } preview_container_->Preview(model, previews::Navigation::NONE); // no swipe left or right - + preview_container_->scale = scale(); preview_container_->SetGeometry(scopes_layout_->GetGeometry()); preview_displaying_ = true; @@ -265,6 +267,7 @@ { // got a new preview whilst already displaying, we probably clicked a navigation button. preview_container_->Preview(model, preview_navigation_mode_); // TODO + preview_container_->scale = scale(); } if (G_LIKELY(preview_state_machine_.left_results() > 0 && preview_state_machine_.right_results() > 0)) @@ -466,10 +469,7 @@ if (monitor_ != monitor) { monitor_ = monitor; - cv_ = Settings::Instance().em(monitor_); - - OnDPIChanged(); - Relayout(); + scale = Settings::Instance().em(monitor_)->DPIScale(); } /* Give the scopes a chance to prep data before we map them */ @@ -492,6 +492,7 @@ overlay_window_buttons_->Show(); + renderer_.scale = scale(); renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false); renderer_.AboutToShow(); } @@ -499,7 +500,7 @@ void DashView::AboutToHide() { if (BackgroundEffectHelper::blur_type == BLUR_STATIC) - { + { content_geo_ = {0, 0, 0, 0}; renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false); } @@ -547,7 +548,7 @@ content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); search_bar_ = new SearchBar(true); - search_bar_->scale = cv_->DPIScale(); + search_bar_->scale = scale(); AddChild(search_bar_); search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); @@ -576,8 +577,11 @@ void DashView::OnDPIChanged() { - double scale = cv_->DPIScale(); + scale = Settings::Instance().em(monitor_)->DPIScale(); +} +void DashView::UpdateScale(double scale) +{ UpdateDashViewSize(); for (auto& scope : scope_views_) @@ -585,27 +589,23 @@ search_bar_->scale = scale; scope_bar_->scale = scale; + renderer_.scale = scale; + + if (preview_container_) + preview_container_->scale = scale; + + Relayout(); } void DashView::UpdateDashViewSize() { dash::Style const& style = dash::Style::Instance(); - RawPixel const v_separator_size = style.GetVSeparatorSize(); - RawPixel const h_separator_size = style.GetHSeparatorSize(); - RawPixel const view_top_padding = style.GetDashViewTopPadding(); - - RawPixel const search_bar_left_padding = style.GetSearchBarLeftPadding(); - RawPixel const search_bar_height = style.GetSearchBarHeight(); - - layout_->SetLeftAndRightPadding(v_separator_size.CP(cv_), 0); - layout_->SetTopAndBottomPadding(h_separator_size.CP(cv_), 0); - - content_layout_->SetTopAndBottomPadding(view_top_padding.CP(cv_), 0); + layout_->SetLeftAndRightPadding(style.GetVSeparatorSize().CP(scale), 0); + layout_->SetTopAndBottomPadding(style.GetHSeparatorSize().CP(scale), 0); - search_bar_layout_->SetLeftAndRightPadding(search_bar_left_padding.CP(cv_), 0); - search_bar_->SetMinimumHeight(search_bar_height.CP(cv_)); - search_bar_->SetMaximumHeight(search_bar_height.CP(cv_)); + content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding().CP(scale), 0); + search_bar_layout_->SetLeftAndRightPadding(style.GetSearchBarLeftPadding().CP(scale), 0); } void DashView::SetupUBusConnections() @@ -626,7 +626,7 @@ content_geo_ = GetBestFitGeometry(geo); dash::Style& style = dash::Style::Instance(); - RawPixel const top_padding = style.GetDashViewTopPadding(); + int top_padding = style.GetDashViewTopPadding().CP(scale); // kinda hacky, but it makes sure the content isn't so big that it throws // the bottom of the dash off the screen @@ -634,18 +634,17 @@ scopes_layout_->SetMaximumHeight (std::max(0, content_geo_.height - search_bar_->GetGeometry().height - scope_bar_->GetGeometry().height - - top_padding.CP(cv_))); + top_padding)); scopes_layout_->SetMinimumHeight (std::max(0, content_geo_.height - search_bar_->GetGeometry().height - scope_bar_->GetGeometry().height - - top_padding.CP(cv_))); + top_padding)); layout_->SetMinMaxSize(content_geo_.width, content_geo_.y + content_geo_.height); // Minus the padding that gets added to the left - RawPixel const tile_width = style.GetTileWidth(); - style.SetDefaultNColumns(floorf((content_geo_.width - cv_->CP(32)) / tile_width.CP(cv_))); + style.columns_number = floorf((content_geo_.width - (32_em).CP(scale)) / style.GetTileWidth().CP(scale)); ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height)); @@ -666,33 +665,24 @@ int panel_height = renderer_.y_offset; int width = 0, height = 0; - RawPixel const tile_width = style.GetTileWidth(); - RawPixel const tile_height = style.GetTileHeight(); - RawPixel const group_top_space = style.GetPlacesGroupTopSpace(); - RawPixel const category_icon_size = style.GetCategoryIconSize(); - RawPixel const group_top_padding = style.GetPlacesGroupResultTopPadding(); + int tile_width = style.GetTileWidth().CP(scale); - int category_height = (group_top_space.CP(cv_) + category_icon_size.CP(cv_) + - group_top_padding.CP(cv_) + tile_height.CP(cv_)); + int category_height = (style.GetPlacesGroupTopSpace().CP(scale) + + style.GetCategoryIconSize().CP(scale) + + style.GetPlacesGroupResultTopPadding().CP(scale) + + style.GetTileHeight().CP(scale)); int half = for_geo.width / 2; // if default dash size is bigger than half a screens worth of items, go for that. - while ((width += tile_width.CP(cv_)) < half) - ; + while ((width += tile_width) < half); - RawPixel const v_separator_size = style.GetVSeparatorSize(); - RawPixel const group_left_padding = style.GetPlacesGroupResultLeftPadding(); + width = std::max(width, tile_width * DASH_TILE_HORIZONTAL_COUNT); + width += style.GetVSeparatorSize().CP(scale); + width += style.GetPlacesGroupResultLeftPadding().CP(scale) + DASH_RESULT_RIGHT_PAD.CP(scale); - width = std::max(width, tile_width.CP(cv_) * DASH_TILE_HORIZONTAL_COUNT); - width += v_separator_size.CP(cv_); - width += group_left_padding.CP(cv_) + DASH_RESULT_RIGHT_PAD.CP(cv_); - - RawPixel const h_separator_size = style.GetHSeparatorSize(); - RawPixel const top_padding = style.GetDashViewTopPadding(); - - height = h_separator_size.CP(cv_); - height += top_padding.CP(cv_); + height = style.GetHSeparatorSize().CP(scale); + height += style.GetDashViewTopPadding().CP(scale); height += search_bar_->GetGeometry().height; height += category_height * DASH_DEFAULT_CATEGORY_COUNT; // adding three categories height += scope_bar_->GetGeometry().height; @@ -806,7 +796,7 @@ texxform.voffset = (scope_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight(); int start_y = scope_bar_->GetY(); - int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_); + int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale); int scope_y = (1.0f - animate_split_value_) * start_y + (animate_split_value_ * final_y); @@ -830,7 +820,7 @@ texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight(); start_y = search_bar_->GetY(); - final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_); + final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale); graphics_engine.QRP_1Tex ( @@ -848,7 +838,7 @@ texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight(); int start_x = active_scope_view_->filter_bar()->GetX(); - int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_); + int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale); int filter_x = (1.0f - animate_split_value_) * start_x + (animate_split_value_ * final_x); @@ -872,7 +862,7 @@ texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight(); int start_y = search_bar_->GetY(); - int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_); + int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale); graphics_engine.QRP_1Tex ( @@ -906,8 +896,8 @@ // Triangle pointed at preview item if (opening_column_x_ != -1) { - int final_width = cv_->CP(14); - int final_height = cv_->CP(12); + int final_width = PREVIEW_CONTAINER_TRIANGLE_WIDTH.CP(scale); + int final_height = PREVIEW_CONTAINER_TRIANGLE_HEIGHT.CP(scale); int x_center = geo_content.x + (opening_column_x_ - geo_abs.x) + opening_column_width_ / 2; int start_y = geo_abs_preview.y - geo_abs.y; @@ -1136,11 +1126,8 @@ if (Settings::Instance().form_factor() == FormFactor::DESKTOP) { dash::Style& style = dash::Style::Instance(); - RawPixel const right_title_width = style.GetDashRightTileWidth(); - RawPixel const bottom_title_width = style.GetDashBottomTileHeight(); - - geo.width += right_title_width.CP(cv_); - geo.height += bottom_title_width.CP(cv_); + geo.width += style.GetDashRightTileWidth().CP(scale); + geo.height += style.GetDashBottomTileHeight().CP(scale); } } @@ -1282,7 +1269,7 @@ nux::ObjectPtr view(new ScopeView(scope, search_bar_->show_filters())); AddChild(view.GetPointer()); - view->scale = cv_->DPIScale(); + view->scale = scale(); view->SetVisible(false); view->result_activated.connect(sigc::mem_fun(this, &DashView::OnResultActivated)); @@ -1500,9 +1487,6 @@ int num_rows = 1; // The search bar std::vector button_on_monitor; - RawPixel const right_title_width = style.GetDashRightTileWidth(); - RawPixel const bottom_title_width = style.GetDashBottomTileHeight(); - if (active_scope_view_.IsValid()) num_rows += active_scope_view_->GetNumRows(); @@ -1521,8 +1505,8 @@ introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height)) .add("num_rows", num_rows) .add("form_factor", form_factor) - .add("right-border-width", right_title_width.CP(cv_)) - .add("bottom-border-height", bottom_title_width.CP(cv_)) + .add("right-border-width", style.GetDashRightTileWidth().CP(scale)) + .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale)) .add("preview_displaying", preview_displaying_) .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_) .add("dash_maximized", style.always_maximised()) diff -Nru unity-7.2.2+14.04.20140714/dash/DashView.h unity-7.2.3+14.04.20140826/dash/DashView.h --- unity-7.2.2+14.04.20140714/dash/DashView.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/DashView.h 2014-08-26 15:48:28.000000000 +0200 @@ -37,7 +37,6 @@ #include "unity-shared/BackgroundEffectHelper.h" #include "unity-shared/BGHash.h" -#include "unity-shared/EMConverter.h" #include "unity-shared/Introspectable.h" #include "unity-shared/OverlayRenderer.h" #include "unity-shared/SearchBar.h" @@ -63,6 +62,8 @@ DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter); ~DashView(); + nux::Property scale; + void AboutToShow(int monitor); void AboutToHide(); void Relayout(); @@ -131,6 +132,7 @@ nux::Geometry GetRenderAbsoluteGeometry() const; void UpdateDashViewSize(); + void UpdateScale(double scale); void OnDPIChanged(); nux::Area* KeyNavIteration(nux::KeyNavDirection direction); @@ -195,7 +197,6 @@ nux::ObjectPtr overlay_window_buttons_; - EMConverter::Ptr cv_; int monitor_; friend class TestDashView; diff -Nru unity-7.2.2+14.04.20140714/dash/FilterBar.cpp unity-7.2.3+14.04.20140826/dash/FilterBar.cpp --- unity-7.2.2+14.04.20140714/dash/FilterBar.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterBar.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -47,28 +47,20 @@ : View(NUX_FILE_LINE_PARAM) , scale(DEFAULT_SCALE) { - Init(); -} - -FilterBar::~FilterBar() -{ -} - -void FilterBar::Init() -{ - dash::Style& style = dash::Style::Instance(); - - nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); - layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding()); - layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding()); + SetLayout(new nux::VLayout(NUX_TRACKER_LOCATION)); scale.changed.connect(sigc::mem_fun(this, &FilterBar::UpdateScale)); - SetLayout(layout); + UpdateScale(scale); } void FilterBar::UpdateScale(double scale) { for (auto& filters : filter_map_) filters.second->scale = scale; + + auto& style = dash::Style::Instance(); + auto* layout = static_cast(GetLayout()); + layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding().CP(scale) - style.GetFilterHighlightPadding().CP(scale)); + layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale)); } void FilterBar::SetFilters(Filters::Ptr const& filters) @@ -118,9 +110,7 @@ } void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) -{ - -} +{} void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { diff -Nru unity-7.2.2+14.04.20140714/dash/FilterBar.h unity-7.2.3+14.04.20140826/dash/FilterBar.h --- unity-7.2.2+14.04.20140714/dash/FilterBar.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterBar.h 2014-08-26 15:48:28.000000000 +0200 @@ -42,7 +42,6 @@ NUX_DECLARE_OBJECT_TYPE(FilterBar, nux::View); public: FilterBar(NUX_FILE_LINE_PROTO); - ~FilterBar(); nux::Property scale; @@ -62,7 +61,6 @@ virtual void AddProperties(debug::IntrospectionData&); private: - void Init(); void UpdateScale(double scale); FilterFactory factory_; diff -Nru unity-7.2.2+14.04.20140714/dash/FilterBasicButton.cpp unity-7.2.3+14.04.20140826/dash/FilterBasicButton.cpp --- unity-7.2.2+14.04.20140714/dash/FilterBasicButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterBasicButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -22,53 +22,36 @@ #include "unity-shared/DashStyle.h" #include "FilterBasicButton.h" -namespace -{ -const int kMinButtonHeight = 30; -const int kMinButtonWidth = 48; -const int kFontSizePx = 15; // 15px == 11pt -} - namespace unity { namespace dash { - +namespace +{ +const RawPixel BUTTON_HEIGHT = 30_em; +const RawPixel MIN_BUTTON_WIDTH = 48_em; +const int FONT_SIZE_PX = 15; // 15px == 11pt +} + NUX_IMPLEMENT_OBJECT_TYPE(FilterBasicButton); FilterBasicButton::FilterBasicButton(nux::TextureArea* image, NUX_FILE_LINE_DECL) - : nux::ToggleButton(image, NUX_FILE_LINE_PARAM) -{ - Init(); -} + : FilterBasicButton(std::string(), image, NUX_FILE_LINE_PARAM) +{} + +FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL) + : FilterBasicButton(std::string(), NUX_FILE_LINE_PARAM) +{} FilterBasicButton::FilterBasicButton(std::string const& label, NUX_FILE_LINE_DECL) - : nux::ToggleButton(NUX_FILE_LINE_PARAM) - , label_(label) -{ - Init(); -} + : FilterBasicButton(label, nullptr, NUX_FILE_LINE_PARAM) +{} FilterBasicButton::FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_DECL) : nux::ToggleButton(image, NUX_FILE_LINE_PARAM) + , scale(1.0) , label_(label) { - Init(); -} - -FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL) - : nux::ToggleButton(NUX_FILE_LINE_PARAM) -{ - Init(); -} - -FilterBasicButton::~FilterBasicButton() -{ -} - -void FilterBasicButton::Init() -{ - InitTheme(); SetAcceptKeyNavFocusOnMouseDown(false); SetAcceptKeyNavFocusOnMouseEnter(true); @@ -85,34 +68,44 @@ if (GetInputEventSensitivity()) Active() ? Deactivate() : Activate(); }); + + scale.changed.connect(sigc::mem_fun(this, &FilterBasicButton::UpdateScale)); } void FilterBasicButton::InitTheme() { - if (!active_) - { - nux::Geometry const& geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); + + prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); + active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); + normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); + focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay))); - prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); - active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); - normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); - focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay))); - } + SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale)); + ApplyMinWidth(); - SetMinimumHeight(kMinButtonHeight); - SetMinimumWidth(kMinButtonWidth); + SetMinimumHeight(BUTTON_HEIGHT.CP(scale)); + SetMaximumHeight(BUTTON_HEIGHT.CP(scale)); } void FilterBasicButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state) { - Style::Instance().Button(cr, faked_state, label_, kFontSizePx, Alignment::CENTER, true); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); + Style::Instance().Button(cr, faked_state, label_, FONT_SIZE_PX, Alignment::CENTER, true); } void FilterBasicButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr) { + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); Style::Instance().ButtonFocusOverlay(cr); } +void FilterBasicButton::UpdateScale(double scale) +{ + InitTheme(); + QueueDraw(); +} + long FilterBasicButton::ComputeContentSize() { long ret = nux::Button::ComputeContentSize(); diff -Nru unity-7.2.2+14.04.20140714/dash/FilterBasicButton.h unity-7.2.3+14.04.20140826/dash/FilterBasicButton.h --- unity-7.2.2+14.04.20140714/dash/FilterBasicButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterBasicButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -39,15 +39,15 @@ FilterBasicButton(std::string const& label, NUX_FILE_LINE_PROTO); FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_PROTO); FilterBasicButton(NUX_FILE_LINE_PROTO); - virtual ~FilterBasicButton(); - void SetClearBeforeDraw(bool clear_before_draw); + nux::Property scale; + protected: virtual long ComputeContentSize(); virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); - void Init(); void InitTheme(); + void SetClearBeforeDraw(bool clear_before_draw); void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state); void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr); @@ -61,6 +61,8 @@ nux::Geometry cached_geometry_; private: + void UpdateScale(double); + std::string label_; bool clear_before_draw_; }; diff -Nru unity-7.2.2+14.04.20140714/dash/FilterExpanderLabel.cpp unity-7.2.3+14.04.20140826/dash/FilterExpanderLabel.cpp --- unity-7.2.2+14.04.20140714/dash/FilterExpanderLabel.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterExpanderLabel.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -22,16 +22,20 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/GraphicsUtils.h" -#include "unity-shared/RawPixel.h" #include "FilterExpanderLabel.h" +namespace unity +{ +namespace dash +{ namespace { - +const double DEFAULT_SCALE = 1.0; const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f; - -// expander_layout_ -const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8; +const RawPixel EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8_em; +const RawPixel ARROW_HORIZONTAL_PADDING = 2_em; +const RawPixel ARROW_TOP_PADDING = 11_em; +const RawPixel ARROW_BOTTOM_PADDING = 9_em; // font const char* const FONT_EXPANDER_LABEL = "Ubuntu 13"; // 17px = 13 @@ -72,16 +76,6 @@ } -namespace unity -{ -namespace dash -{ - -namespace -{ - double const DEFAULT_SCALE = 1.0; -} - NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel); FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL) @@ -94,8 +88,6 @@ , expander_layout_(nullptr) , right_hand_contents_(nullptr) , cairo_label_(nullptr) - , raw_label_(label) - , label_("label") { scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale)); expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange)); @@ -104,14 +96,13 @@ void FilterExpanderLabel::SetLabel(std::string const& label) { - raw_label_ = label; - - cairo_label_->SetText(label.c_str()); + cairo_label_->SetText(label); } void FilterExpanderLabel::UpdateScale(double scale) { cairo_label_->SetScale(scale); + UpdateLayoutSizes(); } void FilterExpanderLabel::SetRightHandView(nux::View* view) @@ -143,40 +134,27 @@ void FilterExpanderLabel::BuildLayout() { - dash::Style& style = dash::Style::Instance(); - layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); - layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding(), style.GetFilterBarRightPadding()); - top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding()); - expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN); expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION); expander_view_->SetLayout(expander_layout_); top_bar_layout_->AddView(expander_view_, 1); - cairo_label_ = new StaticCairoText(label_.c_str(), NUX_TRACKER_LOCATION); + cairo_label_ = new StaticCairoText("", NUX_TRACKER_LOCATION); cairo_label_->SetFont(FONT_EXPANDER_LABEL); + cairo_label_->SetScale(scale); cairo_label_->SetTextColor(nux::color::White); cairo_label_->SetAcceptKeyboardEvent(false); - nux::BaseTexture* arrow; - arrow = dash::Style::Instance().GetGroupUnexpandIcon(); - expand_icon_ = new IconTexture(arrow, - arrow->GetWidth(), - arrow->GetHeight()); + expand_icon_ = new IconTexture(Style::Instance().GetGroupUnexpandIcon()); expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY); - expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); + expand_icon_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); expand_icon_->SetVisible(true); + arrow_layout_ = new nux::VLayout(); - arrow_top_space_ = new nux::SpaceLayout(2, 2, 11, 11); - arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 9, 9); - arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER); arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER); - arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER); expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); @@ -209,8 +187,25 @@ cairo_label_->mouse_click.connect(mouse_expand); expand_icon_->mouse_click.connect(mouse_expand); + UpdateLayoutSizes(); +} + +void FilterExpanderLabel::UpdateLayoutSizes() +{ + auto& style = dash::Style::Instance(); + + layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding().CP(scale), style.GetFilterBarRightPadding().CP(scale)); + top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding().CP(scale)); + expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN.CP(scale)); + + auto const& tex = expand_icon_->texture(); + expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale)); + + arrow_layout_->SetLeftAndRightPadding(ARROW_HORIZONTAL_PADDING.CP(scale)); + arrow_layout_->SetTopAndBottomPadding(ARROW_TOP_PADDING.CP(scale), ARROW_BOTTOM_PADDING.CP(scale)); + QueueRelayout(); - NeedRedraw(); + QueueDraw(); } void FilterExpanderLabel::DoExpandChange(bool change) @@ -221,6 +216,9 @@ else expand_icon_->SetTexture(style.GetGroupExpandIcon()); + auto const& tex = expand_icon_->texture(); + expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale)); + if (change and contents_ and !contents_->IsChildOf(layout_)) { layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition(1)); @@ -278,7 +276,7 @@ graphics::ClearGeometry(right_hand_contents_->GetGeometry()); if (expanded()) - ClearRedirectedRenderChildArea(); + ClearRedirectedRenderChildArea(); } if (focus_layer_ && ShouldBeHighlighted()) @@ -296,7 +294,7 @@ if (IsFullRedraw()) { - nux::GetPainter().PopPaintLayerStack(); + nux::GetPainter().PopPaintLayerStack(); } else if (pushed_paint_layers > 0) { diff -Nru unity-7.2.2+14.04.20140714/dash/FilterExpanderLabel.h unity-7.2.3+14.04.20140826/dash/FilterExpanderLabel.h --- unity-7.2.2+14.04.20140714/dash/FilterExpanderLabel.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterExpanderLabel.h 2014-08-26 15:48:28.000000000 +0200 @@ -80,21 +80,18 @@ private: void BuildLayout(); + void UpdateLayoutSizes(); void DoExpandChange(bool change); bool ShouldBeHighlighted(); void UpdateScale(double scale); - nux::LinearLayout* layout_; + nux::VLayout* layout_; nux::LinearLayout* top_bar_layout_; nux::View* expander_view_; nux::LinearLayout* expander_layout_; nux::View* right_hand_contents_; StaticCairoText* cairo_label_; - std::string raw_label_; - std::string label_; nux::VLayout* arrow_layout_; - nux::SpaceLayout* arrow_top_space_; - nux::SpaceLayout* arrow_bottom_space_; IconTexture* expand_icon_; nux::ObjectPtr contents_; diff -Nru unity-7.2.2+14.04.20140714/dash/FilterGenreWidget.cpp unity-7.2.3+14.04.20140826/dash/FilterGenreWidget.cpp --- unity-7.2.2+14.04.20140714/dash/FilterGenreWidget.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterGenreWidget.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -35,6 +35,11 @@ { namespace dash { +namespace +{ +const RawPixel CHILDREN_SPACE = 12_em; +const RawPixel CHILDREN_SPACE_SMALLER = 10_em; +} NUX_IMPLEMENT_OBJECT_TYPE(FilterGenre); @@ -42,33 +47,41 @@ : FilterExpanderLabel(_("Categories"), NUX_FILE_LINE_PARAM) , all_button_(nullptr) { - dash::Style& style = dash::Style::Instance(); - InitTheme(); - genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION); genre_layout_->ForceChildrenSize(true); genre_layout_->MatchContentSize(true); - genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding(), style.GetFilterHighlightPadding()); genre_layout_->EnablePartialVisibility(false); + UpdateSize(columns); + SetContents(genre_layout_); + + scale.changed.connect([this, columns] (double scale) { + if (all_button_) all_button_->scale = scale; + + for (auto* button : buttons_) + button->scale = scale; + + UpdateSize(columns); + }); +} + +void FilterGenre::UpdateSize(int columns) +{ + auto& style = dash::Style::Instance(); + genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale), style.GetFilterHighlightPadding().CP(scale)); + if (columns == 3) { - genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 12 * 2) / 3, style.GetFilterButtonHeight()); - genre_layout_->SetSpaceBetweenChildren (12, 12); + genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE.CP(scale) * 2) / 3, style.GetFilterButtonHeight().CP(scale)); + genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale), CHILDREN_SPACE.CP(scale)); } else { - genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 10 ) / 2, style.GetFilterButtonHeight()); - genre_layout_->SetSpaceBetweenChildren (10, 12); + genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE_SMALLER.CP(scale)) / 2, style.GetFilterButtonHeight().CP(scale)); + genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE_SMALLER.CP(scale), CHILDREN_SPACE.CP(scale)); } - - SetContents(genre_layout_); -} - -FilterGenre::~FilterGenre() -{ } void FilterGenre::SetFilter(Filter::Ptr const& filter) @@ -81,11 +94,14 @@ all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr; SetRightHandView(all_button_); if (all_button_) + { + all_button_->scale = scale(); all_button_->SetFilter(filter_); + } }; show_button_func(filter_->show_all_button); filter_->show_all_button.changed.connect(show_button_func); - + expanded = !filter_->collapsed(); filter_->option_added.connect(sigc::mem_fun(this, &FilterGenre::OnOptionAdded)); @@ -106,6 +122,7 @@ std::string label(escape.Value()); FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION); + button->scale = scale(); button->SetFilter(new_filter); genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); buttons_.push_back(button); @@ -121,7 +138,7 @@ { genre_layout_->RemoveChildObject(*it); buttons_.erase(it); - + QueueRelayout(); break; } diff -Nru unity-7.2.2+14.04.20140714/dash/FilterGenreWidget.h unity-7.2.3+14.04.20140826/dash/FilterGenreWidget.h --- unity-7.2.2+14.04.20140714/dash/FilterGenreWidget.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterGenreWidget.h 2014-08-26 15:48:28.000000000 +0200 @@ -46,7 +46,6 @@ NUX_DECLARE_OBJECT_TYPE(FilterGenre, FilterExpanderLabel); public: FilterGenre(int columns, NUX_FILE_LINE_PROTO); - virtual ~FilterGenre(); void SetFilter(Filter::Ptr const& filter); std::string GetFilterType(); @@ -59,6 +58,7 @@ private: void OnOptionAdded(FilterOption::Ptr const& new_filter); void OnOptionRemoved(FilterOption::Ptr const& removed_filter); + void UpdateSize(int columns); nux::GridHLayout* genre_layout_; FilterAllButton* all_button_; diff -Nru unity-7.2.2+14.04.20140714/dash/FilterMultiRangeButton.cpp unity-7.2.3+14.04.20140826/dash/FilterMultiRangeButton.cpp --- unity-7.2.2+14.04.20140714/dash/FilterMultiRangeButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterMultiRangeButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -33,29 +33,18 @@ namespace { -const int kFontSizePx = 10; - -const int kLayoutPadLeftRight = 4; -const int kLayoutPadtopBottom = 2; +const int FONT_SIZE_PX = 10; } NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRangeButton); FilterMultiRangeButton::FilterMultiRangeButton(NUX_FILE_LINE_DECL) : nux::ToggleButton(NUX_FILE_LINE_PARAM) + , scale(1.0) , theme_init_(false) , has_arrow_(MultiRangeArrow::NONE) , side_(MultiRangeSide::CENTER) { - Init(); -} - -FilterMultiRangeButton::~FilterMultiRangeButton() -{ -} - -void FilterMultiRangeButton::Init() -{ InitTheme(); // Controlled by parent widget SetAcceptKeyNavFocusOnMouseDown(false); @@ -64,6 +53,8 @@ state_change.connect(sigc::mem_fun(this, &FilterMultiRangeButton::OnActivated)); key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection) { QueueDraw(); }); key_nav_focus_activate.connect([this](nux::Area* area) { Active() ? Deactivate() : Activate(); }); + + scale.changed.connect(sigc::hide(sigc::mem_fun(this, &FilterMultiRangeButton::InitTheme))); } void FilterMultiRangeButton::OnActivated(nux::Area* area) @@ -133,27 +124,26 @@ void FilterMultiRangeButton::InitTheme() { - if (!active_[MapKey(MultiRangeArrow::LEFT, MultiRangeSide::LEFT)]) - { - nux::Geometry const& geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); - std::vector sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER}; - std::vector arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE}; + std::vector sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER}; + std::vector arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE}; - for (auto arrow : arrows) + for (auto arrow : arrows) + { + for (auto side : sides) { - for (auto side : sides) - { - active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side))); - normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side))); - prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side))); - focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side))); - } + active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side))); + normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side))); + prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side))); + focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side))); } } - SetMinimumHeight(dash::Style::Instance().GetFilterButtonHeight() + 3); + SetMinimumHeight(Style::Instance().GetFilterButtonHeight().CP(scale) + (3_em).CP(scale)); theme_init_ = true; + + QueueDraw(); } void FilterMultiRangeButton::RedrawTheme(nux::Geometry const& geom, @@ -187,8 +177,9 @@ else segment = Segment::RIGHT; - Style::Instance().MultiRangeSegment(cr, faked_state, name, kFontSizePx, arrow, segment); - NeedRedraw(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); + Style::Instance().MultiRangeSegment(cr, faked_state, name, FONT_SIZE_PX, arrow, segment); + QueueDraw(); } void FilterMultiRangeButton::RedrawFocusOverlay(nux::Geometry const& geom, @@ -214,6 +205,7 @@ else segment = Segment::RIGHT; + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); Style::Instance().MultiRangeFocusOverlay(cr, arrow, segment); QueueDraw(); } diff -Nru unity-7.2.2+14.04.20140714/dash/FilterMultiRangeButton.h unity-7.2.3+14.04.20140826/dash/FilterMultiRangeButton.h --- unity-7.2.2+14.04.20140714/dash/FilterMultiRangeButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterMultiRangeButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -54,8 +54,9 @@ { NUX_DECLARE_OBJECT_TYPE(FilterMultiRangeButton, nux::ToggleButton); public: - FilterMultiRangeButton (NUX_FILE_LINE_PROTO); - virtual ~FilterMultiRangeButton(); + FilterMultiRangeButton(NUX_FILE_LINE_PROTO); + + nux::Property scale; void SetFilter(FilterOption::Ptr const& filter); FilterOption::Ptr GetFilter(); @@ -69,7 +70,6 @@ private: void InitTheme(); - void Init(); void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, diff -Nru unity-7.2.2+14.04.20140714/dash/FilterMultiRangeWidget.cpp unity-7.2.3+14.04.20140826/dash/FilterMultiRangeWidget.cpp --- unity-7.2.2+14.04.20140714/dash/FilterMultiRangeWidget.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterMultiRangeWidget.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -64,6 +64,13 @@ mouse_up.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseUp)); mouse_drag.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseDrag)); + + scale.changed.connect([this] (double scale) { + if (all_button_) all_button_->scale = scale; + + for (auto const& button : buttons_) + button->scale = scale; + }); } void FilterMultiRangeWidget::SetFilter(Filter::Ptr const& filter) @@ -83,11 +90,14 @@ all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr; SetRightHandView(all_button_); if (all_button_) + { + all_button_->scale = scale(); all_button_->SetFilter(filter_); + } }; show_button_func(filter_->show_all_button); filter_->show_all_button.changed.connect(show_button_func); - + expanded = !filter_->collapsed(); filter_->option_added.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::OnOptionAdded)); @@ -151,6 +161,7 @@ void FilterMultiRangeWidget::OnOptionAdded(FilterOption::Ptr const& new_filter) { FilterMultiRangeButtonPtr button(new FilterMultiRangeButton(NUX_TRACKER_LOCATION)); + button->scale = scale(); button->SetFilter(new_filter); layout_->AddView(button.GetPointer()); buttons_.push_back(button); diff -Nru unity-7.2.2+14.04.20140714/dash/FilterRatingsButton.cpp unity-7.2.3+14.04.20140826/dash/FilterRatingsButton.cpp --- unity-7.2.2+14.04.20140714/dash/FilterRatingsButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterRatingsButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright 2011 Canonical Ltd. + * Copyright 2014 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, as @@ -15,255 +15,62 @@ * License version 3 along with this program. If not, see * * - * Authored by: Gordon Allott + * Authored by: Marco Trevisan * */ -#include - -#include -#include - -#include "unity-shared/DashStyle.h" #include "FilterRatingsButton.h" namespace { -const int star_size = 28; -const int star_gap = 10; -const int num_stars = 5; +const int STAR_SIZE = 28; +const int STAR_GAP = 10; } namespace unity { namespace dash { - + NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsButton); FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL) - : nux::ToggleButton(NUX_FILE_LINE_PARAM) - , focused_star_(-1) -{ - SetAcceptKeyNavFocusOnMouseDown(false); - SetAcceptKeyNavFocusOnMouseEnter(true); - - mouse_up.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseUp)); - mouse_move.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseMove)); - mouse_drag.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseDrag)); - - key_nav_focus_change.connect([this](nux::Area* area, bool has_focus, nux::KeyNavDirection direction) - { - if (has_focus) - focused_star_ = 0; - else if (!has_focus) - focused_star_ = -1; - - QueueDraw(); - }); - - key_nav_focus_activate.connect([this](nux::Area*) { filter_->rating = static_cast(focused_star_+1)/num_stars; }); - key_down.connect(sigc::mem_fun(this, &FilterRatingsButton::OnKeyDown)); -} - -FilterRatingsButton::~FilterRatingsButton() -{ -} + : RatingsButton(STAR_SIZE, STAR_GAP, NUX_FILE_LINE_PARAM) +{} void FilterRatingsButton::SetFilter(Filter::Ptr const& filter) { filter_ = std::static_pointer_cast(filter); - filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::OnRatingsChanged)); - NeedRedraw(); -} - -std::string FilterRatingsButton::GetFilterType() -{ - return "FilterRatingsButton"; -} - -void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - int rating = 0; - if (filter_ && filter_->filtering) - rating = static_cast(filter_->rating * num_stars); - // FIXME: 9/26/2011 - // We should probably support an API for saying whether the ratings - // should or shouldn't support half stars...but our only consumer at - // the moment is the applications scope which according to design - // (Bug #839759) shouldn't. So for now just force rounding. - // int total_half_stars = rating % 2; - // int total_full_stars = rating / 2; - int total_full_stars = rating; - - nux::Geometry const& geo = GetGeometry(); - nux::Geometry geo_star(geo); - geo_star.width = star_size; - - gPainter.PaintBackground(GfxContext, geo); - // set up our texture mode - nux::TexCoordXForm texxform; - texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); - texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); - - // clear what is behind us - unsigned int alpha = 0, src = 0, dest = 0; - - GfxContext.GetRenderStates().GetBlend(alpha, src, dest); - GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - nux::Color col = nux::color::Black; - col.alpha = 0; - GfxContext.QRP_Color(geo.x, - geo.y, - geo.width, - geo.height, - col); - - for (int index = 0; index < num_stars; ++index) - { - Style& style = Style::Instance(); - nux::BaseTexture* texture = style.GetStarSelectedIcon(); - if (index < total_full_stars) - { - if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL) - texture = style.GetStarSelectedIcon(); - else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT) - texture = style.GetStarSelectedIcon(); - else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED) - texture = style.GetStarSelectedIcon(); - } - else - { - if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL) - texture = style.GetStarDeselectedIcon(); - else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT) - texture = style.GetStarDeselectedIcon(); - else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED) - texture = style.GetStarDeselectedIcon(); - } - - GfxContext.QRP_1Tex(geo_star.x, - geo_star.y, - geo_star.width, - geo_star.height, - texture->GetDeviceTexture(), - texxform, - nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); - - if (focused_star_ == index) - { - GfxContext.QRP_1Tex(geo_star.x, - geo_star.y, - geo_star.width, - geo_star.height, - style.GetStarHighlightIcon()->GetDeviceTexture(), - texxform, - nux::Color(1.0f, 1.0f, 1.0f, 0.5f)); - } - - geo_star.x += geo_star.width + star_gap; - - } - - GfxContext.GetRenderStates().SetBlend(alpha, src, dest); - -} - -static void _UpdateRatingToMouse(RatingsFilter::Ptr filter, int x) -{ - int width = 180; - float new_rating = (static_cast(x) / width); - - // FIXME: change to * 2 once we decide to support also half-stars - new_rating = ceil((num_stars * 1) * new_rating) / (num_stars * 1); - new_rating = (new_rating > 1) ? 1 : ((new_rating < 0) ? 0 : new_rating); - - if (filter) - filter->rating = new_rating; -} - -void FilterRatingsButton::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags) -{ - _UpdateRatingToMouse(filter_, x); -} - -void FilterRatingsButton::RecvMouseDrag(int x, int y, int dx, int dy, - unsigned long button_flags, - unsigned long key_flags) -{ - _UpdateRatingToMouse(filter_, x); + filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::SetRating)); + QueueDraw(); } -void FilterRatingsButton::OnRatingsChanged(int rating) +RatingsFilter::Ptr FilterRatingsButton::GetFilter() const { - NeedRedraw(); + return filter_; } -void FilterRatingsButton::RecvMouseMove(int x, int y, int dx, int dy, - unsigned long button_flags, - unsigned long key_flags) +std::string FilterRatingsButton::GetFilterType() { - int width = 180; - focused_star_ = std::max(0, std::min(static_cast(ceil((static_cast(x) / width) * num_stars) - 1), num_stars - 1)); - - if (!HasKeyFocus()) - nux::GetWindowCompositor().SetKeyFocusArea(this); - - QueueDraw(); + return "FilterRatingsButton"; } - -bool FilterRatingsButton::InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character) +std::string FilterRatingsButton::GetName() const { - nux::KeyNavDirection direction = nux::KEY_NAV_NONE; - - switch (keysym) - { - case NUX_VK_LEFT: - direction = nux::KeyNavDirection::KEY_NAV_LEFT; - break; - case NUX_VK_RIGHT: - direction = nux::KeyNavDirection::KEY_NAV_RIGHT; - break; - default: - direction = nux::KeyNavDirection::KEY_NAV_NONE; - break; - } - - if (direction == nux::KeyNavDirection::KEY_NAV_NONE) - return false; - else if (direction == nux::KEY_NAV_LEFT && (focused_star_ <= 0)) - return false; - else if (direction == nux::KEY_NAV_RIGHT && (focused_star_ >= num_stars - 1)) - return false; - else - return true; + return "FilterRatingsButton"; } - -void FilterRatingsButton::OnKeyDown(unsigned long event_type, unsigned long event_keysym, - unsigned long event_state, const TCHAR* character, - unsigned short key_repeat_count) +void FilterRatingsButton::SetRating(float rating) { - switch (event_keysym) - { - case NUX_VK_LEFT: - --focused_star_; - break; - case NUX_VK_RIGHT: - ++focused_star_; - break; - default: - return; - } + if (filter_) + filter_->rating = rating; QueueDraw(); } -bool FilterRatingsButton::AcceptKeyNavFocus() +float FilterRatingsButton::GetRating() const { - return true; + return (filter_ && filter_->filtering) ? filter_->rating : 0; } } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/dash/FilterRatingsButton.h unity-7.2.3+14.04.20140826/dash/FilterRatingsButton.h --- unity-7.2.2+14.04.20140714/dash/FilterRatingsButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterRatingsButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -25,46 +25,33 @@ #include #include -#include -#include #include +#include "unity-shared/RatingsButton.h" namespace unity { namespace dash { -class FilterRatingsButton : public nux::ToggleButton +class FilterRatingsButton : public RatingsButton { - NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, nux::ToggleButton); + NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, RatingsButton); public: FilterRatingsButton(NUX_FILE_LINE_PROTO); - virtual ~FilterRatingsButton(); void SetFilter(Filter::Ptr const& filter); - RatingsFilter::Ptr GetFilter(); + RatingsFilter::Ptr GetFilter() const; std::string GetFilterType(); protected: - virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); + // Introspectable methods + std::string GetName() const; - // Key-nav - virtual bool AcceptKeyNavFocus(); - virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character); + void SetRating(float rating) override; + float GetRating() const override; private: - void OnKeyDown(unsigned long event_type, unsigned long event_keysym, - unsigned long event_state, const TCHAR* character, - unsigned short key_repeat_count); - - void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); - void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); - void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); - void OnRatingsChanged(int rating); - dash::RatingsFilter::Ptr filter_; - int focused_star_; - }; } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/dash/FilterRatingsWidget.cpp unity-7.2.3+14.04.20140826/dash/FilterRatingsWidget.cpp --- unity-7.2.2+14.04.20140714/dash/FilterRatingsWidget.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterRatingsWidget.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -33,15 +33,14 @@ #include "FilterRatingsButton.h" #include "FilterRatingsWidget.h" -namespace -{ -const int star_size = 28; -} - namespace unity { namespace dash { +namespace +{ +const RawPixel STAR_SIZE = 28_em; +} NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsWidget); @@ -49,22 +48,30 @@ : FilterExpanderLabel(_("Rating"), NUX_FILE_LINE_PARAM) , all_button_(nullptr) { - dash::Style& style = dash::Style::Instance(); - const int top_padding = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding() - 1; // -1 (PNGs have an 1px top padding) - const int bottom_padding = style.GetFilterHighlightPadding(); - nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); - layout->SetTopAndBottomPadding(top_padding, bottom_padding); ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION); - ratings_->SetMinimumHeight(star_size); layout->AddView(ratings_); + UpdateSize(); SetContents(layout); + + scale.changed.connect([this] (double scale) { + if (all_button_) all_button_->scale = scale; + UpdateSize(); + }); } -FilterRatingsWidget::~FilterRatingsWidget() +void FilterRatingsWidget::UpdateSize() { + dash::Style& style = dash::Style::Instance(); + int top_padding = style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale) - (1_em).CP(scale); // -1 (PNGs have an 1px top padding) + int bottom_padding = style.GetFilterHighlightPadding().CP(scale); + static_cast(GetLayout())->SetTopAndBottomPadding(top_padding, bottom_padding); + + ratings_->scale = scale(); + ratings_->SetMinimumHeight(STAR_SIZE.CP(scale)); + ratings_->ApplyMinHeight(); } void FilterRatingsWidget::SetFilter(Filter::Ptr const& filter) @@ -77,7 +84,10 @@ all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr; SetRightHandView(all_button_); if (all_button_) + { + all_button_->scale = scale(); all_button_->SetFilter(filter_); + } }; show_button_func(filter_->show_all_button); filter_->show_all_button.changed.connect(show_button_func); diff -Nru unity-7.2.2+14.04.20140714/dash/FilterRatingsWidget.h unity-7.2.3+14.04.20140826/dash/FilterRatingsWidget.h --- unity-7.2.2+14.04.20140714/dash/FilterRatingsWidget.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/FilterRatingsWidget.h 2014-08-26 15:48:28.000000000 +0200 @@ -45,7 +45,6 @@ NUX_DECLARE_OBJECT_TYPE(FilterRatingsWidget, FilterExpanderLabel); public: FilterRatingsWidget(NUX_FILE_LINE_PROTO); - virtual ~FilterRatingsWidget(); void SetFilter(Filter::Ptr const& filter); std::string GetFilterType(); @@ -54,6 +53,8 @@ void ClearRedirectedRenderChildArea(); private: + void UpdateSize(); + FilterAllButton* all_button_; FilterRatingsButton* ratings_; RatingsFilter::Ptr filter_; diff -Nru unity-7.2.2+14.04.20140714/dash/PlacesGroup.cpp unity-7.2.3+14.04.20140826/dash/PlacesGroup.cpp --- unity-7.2.2+14.04.20140714/dash/PlacesGroup.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/PlacesGroup.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -33,7 +33,6 @@ #include "unity-shared/UBusWrapper.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/GraphicsUtils.h" -#include "unity-shared/RawPixel.h" #include "ResultView.h" #include "ResultViewGrid.h" @@ -133,10 +132,8 @@ SetAcceptKeyNavFocusOnMouseEnter(false); scale.changed.connect(sigc::mem_fun(this, &PlacesGroup::UpdateScale)); - nux::BaseTexture* arrow = _style.GetGroupExpandIcon(); - - _background = _style.GetCategoryBackground(); - _background_nofilters = _style.GetCategoryBackgroundNoFilters(); + _background = _style.GetCategoryBackground().GetPointer(); + _background_nofilters = _style.GetCategoryBackgroundNoFilters().GetPointer(); nux::ROPConfig rop; rop.Blend = true; @@ -144,8 +141,8 @@ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; nux::TexCoordXForm texxform; - _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(), - texxform, + _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(), + texxform, nux::color::White, false, rop)); @@ -160,11 +157,10 @@ _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL); _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION); - _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding(), 0); + _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0); _header_view->SetLayout(_header_layout); - RawPixel const icon_size = _style.GetCategoryIconSize(); - _icon = new IconTexture("", icon_size.CP(scale())); + _icon = new IconTexture("", _style.GetCategoryIconSize().CP(scale)); _header_layout->AddView(_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); _text_layout = new nux::HLayout(NUX_TRACKER_LOCATION); @@ -172,6 +168,7 @@ _name = new StaticCairoText("", NUX_TRACKER_LOCATION); _name->SetFont(NAME_LABEL_FONT); + _name->SetLines(-1); _name->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END); _name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); _text_layout->AddView(_name, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); @@ -184,16 +181,17 @@ _expand_label = new StaticCairoText("", NUX_TRACKER_LOCATION); _expand_label->SetFont(EXPANDER_LABEL_FONT); + _expand_label->SetLines(-1); _expand_label->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END); _expand_label->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); _expand_label->SetTextColor(kExpandDefaultTextColor); _expand_label_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); - _expand_icon = new IconTexture(arrow, arrow->GetWidth(), arrow->GetHeight()); + _expand_icon = new IconTexture(_style.GetGroupExpandIcon()); + _expand_icon->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); _expand_icon->SetOpacity(kExpandDefaultIconOpacity); - _expand_icon->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); _expand_icon->SetVisible(false); - _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); + _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); SetLayout(_group_layout); @@ -223,16 +221,16 @@ void PlacesGroup::UpdatePlacesGroupSize() { - RawPixel const icon_size = _style.GetCategoryIconSize(); - RawPixel const group_top = _style.GetPlacesGroupTopSpace(); + int icon_size = _style.GetCategoryIconSize().CP(scale); + int top_space = _style.GetPlacesGroupTopSpace().CP(scale); - int top_space = group_top.CP(scale()); _space_layout->SetMinimumSize(top_space, top_space); _space_layout->SetMaximumSize(top_space, top_space); _header_layout->SetSpaceBetweenChildren(SPACE_BETWEEN_CHILDREN.CP(scale())); + _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0); - _icon->SetMinMaxSize(icon_size.CP(scale()), icon_size.CP(scale())); + _icon->SetMinMaxSize(icon_size, icon_size); _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(scale())); _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(scale())); @@ -241,15 +239,16 @@ void PlacesGroup::UpdateScale(double scale) { - RawPixel const icon_size = _style.GetCategoryIconSize(); - + _name->SetMinimumSize(nux::AREA_MIN_WIDTH, nux::AREA_MIN_HEIGHT); + _name->SetMaximumSize(nux::AREA_MAX_WIDTH, nux::AREA_MAX_HEIGHT); _name->SetScale(scale); _expand_label->SetScale(scale); - _icon->SetSize(icon_size.CP(scale)); + _icon->SetSize(_style.GetCategoryIconSize().CP(scale)); _icon->ReLoadIcon(); - // FIXME _expand_icon, needs some work here. Not as easy as _icon + auto const& arrow = _expand_icon->texture(); + _expand_icon->SetMinMaxSize(RawPixel(arrow->GetWidth()).CP(scale), RawPixel(arrow->GetHeight()).CP(scale)); if (_child_view) _child_view->scale = scale; @@ -279,7 +278,6 @@ void -// FIXME _expand_icon, needs some work here. Not as easy as _icon PlacesGroup::SetName(std::string const& name) { if (_cached_name != name) @@ -310,7 +308,7 @@ void PlacesGroup::SetIcon(std::string const& path_to_emblem) { - _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize()); + _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize().CP(scale)); } void @@ -318,11 +316,8 @@ { if (_child_layout) { - RawPixel const result_top_padding = _style.GetPlacesGroupResultTopPadding(); - RawPixel const result_left_padding = _style.GetPlacesGroupResultLeftPadding(); - - _child_layout->SetTopAndBottomPadding(result_top_padding.CP(scale()), 0); - _child_layout->SetLeftAndRightPadding(result_left_padding.CP(scale()), 0); + _child_layout->SetTopAndBottomPadding(_style.GetPlacesGroupResultTopPadding().CP(scale), 0); + _child_layout->SetLeftAndRightPadding(_style.GetPlacesGroupResultLeftPadding().CP(scale), 0); } } @@ -462,7 +457,7 @@ // only the width matters if (_cached_geometry.GetWidth() != geo.GetWidth()) { - _focus_layer.reset(_style.FocusOverlay(geo.width - + _focus_layer.reset(_style.FocusOverlay(geo.width - kHighlightLeftPadding.CP(scale()) - kHighlightRightPadding.CP(scale()), kHighlightHeight.CP(scale()))); @@ -595,6 +590,9 @@ else _expand_icon->SetTexture(_style.GetGroupExpandIcon()); + auto const& tex = _expand_icon->texture(); + _expand_icon->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale)); + expanded.emit(this); } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ActionButton.cpp unity-7.2.3+14.04.20140826/dash/previews/ActionButton.cpp --- unity-7.2.2+14.04.20140714/dash/previews/ActionButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ActionButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -26,22 +26,23 @@ #include "unity-shared/IconTexture.h" #include "unity-shared/StaticCairoText.h" +namespace unity +{ namespace { -const int kMinButtonHeight = 34; -const int kMinButtonWidth = 48; +const RawPixel MIN_BUTTON_HEIGHT = 34_em; +const RawPixel MIN_BUTTON_WIDTH = 48_em; -const int icon_size = 24; +const RawPixel icon_size = 24_em; } -namespace unity -{ namespace dash { DECLARE_LOGGER(logger, "unity.dash.preview.action"); ActionButton::ActionButton(std::string const& action_hint, std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_DECL) : nux::AbstractButton(NUX_FILE_LINE_PARAM) + , scale(1.0) , action_hint_(action_hint) , image_(nullptr) { @@ -49,6 +50,7 @@ SetAcceptKeyNavFocusOnMouseEnter(true); Init(); BuildLayout(label, icon_hint, ""); + scale.changed.connect(sigc::mem_fun(this, &ActionButton::UpdateScale)); } ActionButton::~ActionButton() @@ -84,22 +86,19 @@ void ActionButton::InitTheme() { - if (!cr_active_) - { - nux::Geometry const& geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); - cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); - cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); - cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); - cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay))); - } + cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); + cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); + cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); + cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay))); - SetMinimumHeight(kMinButtonHeight); - SetMinimumWidth(kMinButtonWidth); + SetMinimumHeight(MIN_BUTTON_HEIGHT.CP(scale)); + SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale)); } void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint) -{ +{ extra_font_hint_= font_hint; if (extra_text_) { @@ -123,13 +122,13 @@ if (!icon_hint_.empty()) { - image_ = new IconTexture(icon_hint, icon_size); + image_ = new IconTexture(icon_hint, icon_size.CP(scale)); image_->texture_updated.connect([this](nux::ObjectPtr const&) { BuildLayout(label_, icon_hint_, extra_hint_); }); image_->SetInputEventSensitivity(false); - image_->SetMinMaxSize(icon_size, icon_size); + image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale)); } } @@ -192,11 +191,13 @@ void ActionButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state) { + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); Style::Instance().Button(cr, faked_state, "", -1, Alignment::CENTER, true); } void ActionButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr) { + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); Style::Instance().ButtonFocusOverlay(cr, 0.20f); } @@ -311,5 +312,27 @@ return extra_hint_; } +void ActionButton::UpdateScale(double scale) +{ + InitTheme(); + + if (image_) + { + image_->SetSize(icon_size.CP(scale)); + image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale)); + image_->ReLoadIcon(); + } + + if (static_text_) + static_text_->SetScale(scale); + + if (extra_text_) + extra_text_->SetScale(scale); + + QueueRelayout(); + QueueDraw(); +} + + } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ActionButton.h unity-7.2.3+14.04.20140826/dash/previews/ActionButton.h --- unity-7.2.2+14.04.20140714/dash/previews/ActionButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ActionButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -59,6 +59,8 @@ std::string GetLabel() const; std::string GetExtraText() const; + nux::Property scale; + protected: virtual long ComputeContentSize(); virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); @@ -95,6 +97,8 @@ nux::ObjectPtr image_; nux::ObjectPtr static_text_; nux::ObjectPtr extra_text_; + + void UpdateScale(double scale); }; } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ActionLink.cpp unity-7.2.3+14.04.20140826/dash/previews/ActionLink.cpp --- unity-7.2.2+14.04.20140714/dash/previews/ActionLink.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ActionLink.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -40,12 +40,15 @@ ActionLink::ActionLink(std::string const& action_hint, std::string const& label, NUX_FILE_LINE_DECL) : nux::AbstractButton(NUX_FILE_LINE_PARAM) + , scale(1.0) , action_hint_(action_hint) , aligment_(StaticCairoText::NUX_ALIGN_CENTRE) , underline_(StaticCairoText::NUX_UNDERLINE_SINGLE) { Init(); BuildLayout(label); + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &ActionLink::UpdateScale)); } std::string ActionLink::GetName() const @@ -109,6 +112,7 @@ static_text_ = new StaticCairoText(label_, true, NUX_TRACKER_LOCATION); if (!font_hint_.empty()) static_text_->SetFont(font_hint_); + static_text_->SetScale(scale); static_text_->SetInputEventSensitivity(false); static_text_->SetTextAlignment(aligment_); static_text_->SetUnderline(underline_); @@ -243,5 +247,14 @@ return label_; } +void ActionLink::UpdateScale(double scale) +{ + if (static_text_) + static_text_->SetScale(scale); + + QueueRelayout(); + QueueDraw(); +} + } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ActionLink.h unity-7.2.3+14.04.20140826/dash/previews/ActionLink.h --- unity-7.2.2+14.04.20140714/dash/previews/ActionLink.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ActionLink.h 2014-08-26 15:48:28.000000000 +0200 @@ -47,6 +47,7 @@ nux::RWProperty text_aligment; nux::RWProperty underline_state; nux::RWProperty font_hint; + nux::Property scale; void Activate() {} void Deactivate() {} @@ -90,8 +91,7 @@ StaticCairoText::UnderlineState underline_; private: typedef std::unique_ptr NuxCairoPtr; - - + void UpdateScale(double scale); }; } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ApplicationPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/ApplicationPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/ApplicationPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ApplicationPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/IconTexture.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include #include #include @@ -46,23 +45,31 @@ { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.application"); -class DetailsScrollView : public nux::ScrollView +namespace { -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } + const RawPixel ICON_SPACE_CHILDREN = 3_em; + const RawPixel DATA_SPACE_CHILDREN = 16_em; + const RawPixel INFO_SPACE_CHILDREN = 12_em; + const RawPixel COPYRIGHT_SPACE_CHILDREN = 8_em; + const RawPixel ICON_SIZE = 72_em; +} -}; +DECLARE_LOGGER(logger, "unity.dash.preview.application"); NUX_IMPLEMENT_OBJECT_TYPE(ApplicationPreview); ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) : Preview(preview_model) +, title_subtitle_layout_(nullptr) +, image_data_layout_(nullptr) +, main_app_info_(nullptr) +, icon_layout_(nullptr) +, app_data_layout_(nullptr) +, app_updated_copywrite_layout_(nullptr) +, app_info_layout_(nullptr) +, app_info_scroll_(nullptr) +, actions_layout_(nullptr) { SetupViews(); } @@ -121,12 +128,13 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; - nux::HLayout* image_data_layout = new nux::HLayout(); - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); + image_data_layout_ = new nux::HLayout(); + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); ///////////////////// // Image image_ = new CoverArt(); + image_->scale = scale(); AddChild(image_.GetPointer()); UpdateCoverArtImage(image_.GetPointer()); ///////////////////// @@ -134,34 +142,36 @@ ///////////////////// // App Data Panel full_data_layout_ = new nux::VLayout(); - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); - full_data_layout_->SetSpaceBetweenChildren(16); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale)); ///////////////////// // Main App Info - nux::HLayout* main_app_info = new nux::HLayout(); - main_app_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails()); + main_app_info_ = new nux::HLayout(); + main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); ///////////////////// // Icon Layout - nux::VLayout* icon_layout = new nux::VLayout(); - icon_layout->SetSpaceBetweenChildren(3); - app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72); + icon_layout_ = new nux::VLayout(); + icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale)); + app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", ICON_SIZE.CP(scale)); AddChild(app_icon_.GetPointer()); - app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth()); - app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth()); + app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale)); + app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale)); app_icon_->mouse_click.connect(on_mouse_down); - icon_layout->AddView(app_icon_.GetPointer(), 0); + icon_layout_->AddView(app_icon_.GetPointer(), 0); - if (app_preview_model->rating >= 0) { + if (app_preview_model->rating >= 0) + { app_rating_ = new PreviewRatingsWidget(); AddChild(app_rating_.GetPointer()); - app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight()); - app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight()); + app_rating_->scale = scale(); + app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale)); + app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); app_rating_->SetRating(app_preview_model->rating); app_rating_->SetReviews(app_preview_model->num_ratings); app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - icon_layout->AddView(app_rating_.GetPointer(), 0); + icon_layout_->AddView(app_rating_.GetPointer(), 0); } ///////////////////// @@ -169,15 +179,16 @@ ///////////////////// // Data - nux::VLayout* app_data_layout = new nux::VLayout(); - app_data_layout->SetSpaceBetweenChildren(16); + app_data_layout_ = new nux::VLayout(); + app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale)); title_subtitle_layout_ = new nux::VLayout(); - title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); + title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetLines(-1); + title_->SetScale(scale); title_->SetFont(style.title_font().c_str()); title_->mouse_click.connect(on_mouse_down); title_subtitle_layout_->AddView(title_.GetPointer(), 1); @@ -188,12 +199,13 @@ AddChild(subtitle_.GetPointer()); subtitle_->SetFont(style.subtitle_size_font().c_str()); subtitle_->SetLines(-1); + subtitle_->SetScale(scale); subtitle_->mouse_click.connect(on_mouse_down); title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1); } - nux::VLayout* app_updated_copywrite_layout = new nux::VLayout(); - app_updated_copywrite_layout->SetSpaceBetweenChildren(8); + app_updated_copywrite_layout_ = new nux::VLayout(); + app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale)); if (!app_preview_model->license.Get().empty()) { @@ -201,8 +213,9 @@ AddChild(license_.GetPointer()); license_->SetFont(style.app_license_font().c_str()); license_->SetLines(-1); + license_->SetScale(scale); license_->mouse_click.connect(on_mouse_down); - app_updated_copywrite_layout->AddView(license_.GetPointer(), 1); + app_updated_copywrite_layout_->AddView(license_.GetPointer(), 1); } if (!app_preview_model->last_update.Get().empty()) @@ -213,8 +226,9 @@ last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION); AddChild(last_update_.GetPointer()); last_update_->SetFont(style.app_last_update_font().c_str()); + last_update_->SetScale(scale); last_update_->mouse_click.connect(on_mouse_down); - app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1); + app_updated_copywrite_layout_->AddView(last_update_.GetPointer(), 1); } if (!app_preview_model->copyright.Get().empty()) @@ -223,29 +237,32 @@ AddChild(copywrite_.GetPointer()); copywrite_->SetFont(style.app_copywrite_font().c_str()); copywrite_->SetLines(-1); + copywrite_->SetScale(scale); copywrite_->mouse_click.connect(on_mouse_down); - app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1); + app_updated_copywrite_layout_->AddView(copywrite_.GetPointer(), 1); } - app_data_layout->AddLayout(title_subtitle_layout_); - app_data_layout->AddLayout(app_updated_copywrite_layout); + app_data_layout_->AddLayout(title_subtitle_layout_); + app_data_layout_->AddLayout(app_updated_copywrite_layout_); // buffer space ///////////////////// - main_app_info->AddLayout(icon_layout, 0); - main_app_info->AddLayout(app_data_layout, 1); + main_app_info_->AddLayout(icon_layout_, 0); + main_app_info_->AddLayout(app_data_layout_, 1); ///////////////////// ///////////////////// // Description - nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* app_info = new ScrollView(NUX_TRACKER_LOCATION); + app_info_scroll_ = app_info; + app_info->scale = scale(); app_info->EnableHorizontalScrollBar(false); app_info->mouse_click.connect(on_mouse_down); - nux::VLayout* app_info_layout = new nux::VLayout(); - app_info_layout->SetSpaceBetweenChildren(12); - app_info->SetLayout(app_info_layout); + app_info_layout_ = new nux::VLayout(); + app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale)); + app_info->SetLayout(app_info_layout_); if (!preview_model_->description.Get().empty()) { @@ -256,36 +273,36 @@ description_->SetLines(-style.GetDescriptionLineCount()); description_->SetLineSpacing(style.GetDescriptionLineSpacing()); description_->mouse_click.connect(on_mouse_down); - app_info_layout->AddView(description_.GetPointer()); + app_info_layout_->AddView(description_.GetPointer()); } if (!preview_model_->GetInfoHints().empty()) { - preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); + preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale)); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - app_info_layout->AddView(preview_info_hints_.GetPointer()); + app_info_layout_->AddView(preview_info_hints_.GetPointer()); } ///////////////////// ///////////////////// // Actions action_buttons_.clear(); - nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); /////////////////// - full_data_layout_->AddLayout(main_app_info, 0); + full_data_layout_->AddLayout(main_app_info_, 0); full_data_layout_->AddView(app_info, 1); - full_data_layout_->AddLayout(actions_layout, 0); + full_data_layout_->AddLayout(actions_layout_, 0); ///////////////////// - - image_data_layout->AddView(image_.GetPointer(), 0); - image_data_layout->AddLayout(full_data_layout_, 1); + + image_data_layout_->AddView(image_.GetPointer(), 0); + image_data_layout_->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); - SetLayout(image_data_layout); + SetLayout(image_data_layout_); } void ApplicationPreview::PreLayoutManagement() @@ -296,12 +313,16 @@ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height); - if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth()) - geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth()); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) + - style.GetDetailsLeftMargin().CP(scale) + - style.GetDetailsRightMargin().CP(scale); + if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale)) + geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); + image_->SetMinMaxSize(geo_art.width, geo_art.height); - int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); - int top_app_info_max_width = MAX(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails()); + int details_width = std::max(0, content_width - geo_art.width); + int top_app_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth().CP(scale) - style.GetSpaceBetweenIconAndDetails().CP(scale)); if (title_) { title_->SetMaximumWidth(top_app_info_max_width); } if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); } @@ -310,12 +331,77 @@ if (copywrite_) { copywrite_->SetMaximumWidth(top_app_info_max_width); } if (description_) { description_->SetMaximumWidth(details_width); } + int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); + int button_h = style.GetActionButtonHeight().CP(scale); + for (nux::AbstractButton* button : action_buttons_) + button->SetMinMaxSize(button_w, button_h); + + Preview::PreLayoutManagement(); +} + +void ApplicationPreview::UpdateScale(double scale) +{ + Preview::UpdateScale(scale); + + previews::Style& style = dash::previews::Style::Instance(); + + if (app_icon_) { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight()); + app_icon_->SetSize(ICON_SIZE.CP(scale)); + app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale)); + app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale)); + app_icon_->ReLoadIcon(); } - Preview::PreLayoutManagement(); + if (app_info_scroll_) + app_info_scroll_->scale = scale; + + if (license_) + license_->SetScale(scale); + + if (last_update_) + last_update_->SetScale(scale); + + if (copywrite_) + copywrite_->SetScale(scale); + + if (app_rating_) + { + app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale)); + app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); + app_rating_->scale = scale; + } + + if (image_data_layout_) + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); + + if (full_data_layout_) + { + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale)); + } + + if (main_app_info_) + main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); + + if (icon_layout_) + icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale)); + + if (app_data_layout_) + app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale)); + + if (title_subtitle_layout_) + title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); + + if (app_info_layout_) + app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale)); + + if (actions_layout_) + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); + + if (app_updated_copywrite_layout_) + app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale)); } } // namespace previews diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ApplicationPreview.h unity-7.2.3+14.04.20140826/dash/previews/ApplicationPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/ApplicationPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ApplicationPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -24,6 +24,7 @@ #define APPLICATIONPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -54,9 +55,18 @@ virtual void PreLayoutManagement(); virtual void SetupViews(); + void UpdateScale(double scale) override; protected: nux::VLayout* title_subtitle_layout_; + nux::HLayout* image_data_layout_; + nux::HLayout* main_app_info_; + nux::VLayout* icon_layout_; + nux::VLayout* app_data_layout_; + nux::VLayout* app_updated_copywrite_layout_; + nux::VLayout* app_info_layout_; + ScrollView* app_info_scroll_; + nux::Layout* actions_layout_; nux::ObjectPtr app_icon_; nux::ObjectPtr app_rating_; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ErrorPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/ErrorPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/ErrorPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ErrorPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -26,7 +26,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/StaticCairoText.h" -#include "unity-shared/PlacesVScrollBar.h" #include #include #include @@ -50,22 +49,18 @@ { nux::logging::Logger logger("unity.dash.previews.ErrorPreview"); +const RawPixel TITLE_DATA_MAX_SIZE = 76_em; +const RawPixel TITLE_DATA_CHILDREN_SPACE = 10_em; +const RawPixel LINE_SPACING = 10_em; +const RawPixel TITLE_MAX_WIDTH = 480_em; +const RawPixel CHILDREN_SPACE = 5_em; +const RawPixel BUTTONS_DATA_SPACE = 20_em; +const RawPixel INTRO_SPACE = 110_em; } const std::string ErrorPreview::CANCEL_ACTION = "cancel"; const std::string ErrorPreview::GO_TO_U1_ACTION = "open_u1_link"; -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(ErrorPreview) ErrorPreview::ErrorPreview(dash::Preview::Ptr preview_model) @@ -73,6 +68,9 @@ { PaymentPreview::SetupBackground(); SetupViews(); + + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &ErrorPreview::UpdateScale)); } ErrorPreview::~ErrorPreview() @@ -114,6 +112,7 @@ for (dash::Preview::ActionPtr action : preview_model_->GetActions()) { nux::ObjectPtr button = this->CreateButton(action); + button->scale = scale(); button->activate.connect(sigc::mem_fun(this, &ErrorPreview::OnActionActivated)); buttons_map_.insert(std::make_pair(action->id, button)); } @@ -123,8 +122,8 @@ { previews::Style& style = dash::previews::Style::Instance(); nux::VLayout* title_data_layout = new nux::VLayout(); - title_data_layout->SetMaximumHeight(76); - title_data_layout->SetSpaceBetweenChildren(10); + title_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale)); + title_data_layout->SetSpaceBetweenChildren(TITLE_DATA_CHILDREN_SPACE.CP(scale)); title_ = new StaticCairoText( preview_model_->title.Get(), true, @@ -133,7 +132,7 @@ title_->SetFont(style.payment_title_font()); title_->SetLines(-1); title_->SetFont(style.title_font()); - title_->SetMaximumWidth(480); + title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale)); title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END); title_data_layout->AddView(title_.GetPointer(), 1); @@ -151,9 +150,9 @@ { previews::Style& style = dash::previews::Style::Instance(); nux::VLayout *prize_data_layout = new nux::VLayout(); - prize_data_layout->SetMaximumHeight(76); - prize_data_layout->SetSpaceBetweenChildren(5); - prize_data_layout->SetPadding(0, 10, 0, 0); + prize_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale)); + prize_data_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + prize_data_layout->SetPadding(0, TITLE_DATA_CHILDREN_SPACE.CP(scale), 0, 0); purchase_prize_ = new StaticCairoText( error_preview_model_->purchase_prize.Get(), true, @@ -188,16 +187,17 @@ nux::HLayout *intro_layout = new nux::HLayout(); nux::VLayout *icon_layout = new nux::VLayout(); - icon_layout->SetPadding(78, 10, 90, 43); - intro_layout->SetPadding(75, 20, 0, 0); - intro_layout->SetSpaceBetweenChildren(5); + icon_layout->SetPadding((78_em).CP(scale), (10_em).CP(scale), (90_em).CP(scale), (43_em).CP(scale)); + intro_layout->SetPadding((75_em).CP(scale), (20_em).CP(scale), 0, 0); + intro_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); intro_ = new StaticCairoText( error_preview_model_->header.Get(), true, NUX_TRACKER_LOCATION); intro_->SetFont(style.payment_intro_font().c_str()); + intro_->SetScale(scale); intro_->SetLines(-3); - intro_->SetLineSpacing(10); + intro_->SetLineSpacing(LINE_SPACING.CP(scale)); intro_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END); intro_layout->AddView(intro_.GetPointer());//, 0, nux::MINOR_POSITION_CENTER); @@ -220,9 +220,9 @@ actions_buffer_h->AddSpace(0, 1); nux::HLayout* buttons_data_layout = new TabIteratorHLayout(tab_iterator_); - buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions()); + buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale)); - buttons_data_layout->AddSpace(20, 1); + buttons_data_layout->AddSpace(BUTTONS_DATA_SPACE.CP(scale), 1); if(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer()){ ActionButton* button = (ActionButton*)buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(); buttons_data_layout->AddView(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(), @@ -249,11 +249,11 @@ previews::Style& style = dash::previews::Style::Instance(); - int width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + int width = std::max(0, geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale)); if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); } if(header_layout_) { header_layout_->SetMaximumWidth(width); } - if(intro_) { intro_->SetMaximumWidth(width - 110); } + if(intro_) { intro_->SetMaximumWidth(width - INTRO_SPACE.CP(scale)); } if(footer_layout_) { footer_layout_->SetMaximumWidth(width); } Preview::PreLayoutManagement(); @@ -274,6 +274,33 @@ PaymentPreview::SetupViews(); } +void ErrorPreview::UpdateScale(double scale) +{ + if (intro_) + intro_->SetScale(scale); + + if (purchase_hint_) + purchase_hint_->SetScale(scale); + if (purchase_prize_) + purchase_prize_->SetScale(scale); + if (purchase_type_) + purchase_type_->SetScale(scale); + + if (warning_texture_) + { + previews::Style& style = dash::previews::Style::Instance(); + RawPixel width(style.GetWarningIcon()->GetWidth()); + RawPixel height(style.GetWarningIcon()->GetHeight()); + + warning_texture_->SetSize(std::max(width, height).CP(scale)); + warning_texture_->ReLoadIcon(); + } + + if (title_) + title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale)); + + Preview::UpdateScale(scale); +} } } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/ErrorPreview.h unity-7.2.3+14.04.20140826/dash/previews/ErrorPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/ErrorPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/ErrorPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -94,6 +94,8 @@ void PreLayoutManagement(); virtual void SetupViews(); + virtual void UpdateScale(double scale); + // content elements nux::ObjectPtr image_; nux::ObjectPtr intro_; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/GenericPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/GenericPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/GenericPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/GenericPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -23,7 +23,6 @@ #include "unity-shared/IntrospectableWrappers.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include #include #include @@ -40,25 +39,28 @@ { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.generic"); -class DetailsScrollView : public nux::ScrollView +namespace { -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } + const RawPixel CHILDREN_SPACE = 12_em; + const RawPixel FULL_CHILDREN_SPACE = 16_em; +} -}; +DECLARE_LOGGER(logger, "unity.dash.preview.generic"); NUX_IMPLEMENT_OBJECT_TYPE(GenericPreview); GenericPreview::GenericPreview(dash::Preview::Ptr preview_model) : Preview(preview_model) +, image_data_layout_(nullptr) +, preview_info_layout_(nullptr) +, preview_info_scroll_(nullptr) +, preview_data_layout_(nullptr) +, actions_layout_(nullptr) { SetupViews(); + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &GenericPreview::UpdateScale)); } GenericPreview::~GenericPreview() @@ -72,7 +74,7 @@ gfx_engine.PushClippingRectangle(base); nux::GetPainter().PaintBackground(gfx_engine, base); - gfx_engine.PopClippingRectangle(); + gfx_engine.PopClippingRectangle(); } void GenericPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw) @@ -113,8 +115,8 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; - nux::HLayout* image_data_layout = new nux::HLayout(); - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); + image_data_layout_ = new nux::HLayout(); + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); ///////////////////// // Image @@ -126,21 +128,22 @@ ///////////////////// // Data Panel full_data_layout_ = new nux::VLayout(); - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); - full_data_layout_->SetSpaceBetweenChildren(16); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, + style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale)); ///////////////////// // Data - nux::VLayout* preview_data_layout = new nux::VLayout(); - preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); + preview_data_layout_ = new nux::VLayout(); + preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetLines(-1); title_->SetFont(style.title_font().c_str()); title_->mouse_click.connect(on_mouse_down); - preview_data_layout->AddView(title_.GetPointer(), 1); + preview_data_layout_->AddView(title_.GetPointer(), 1); if (!preview_model_->subtitle.Get().empty()) { @@ -149,19 +152,21 @@ subtitle_->SetLines(-1); subtitle_->SetFont(style.subtitle_size_font().c_str()); subtitle_->mouse_click.connect(on_mouse_down); - preview_data_layout->AddView(subtitle_.GetPointer(), 1); + preview_data_layout_->AddView(subtitle_.GetPointer(), 1); } ///////////////////// ///////////////////// // Description - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); + preview_info_scroll_ = preview_info; + preview_info->scale = scale(); preview_info->EnableHorizontalScrollBar(false); preview_info->mouse_click.connect(on_mouse_down); - nux::VLayout* preview_info_layout = new nux::VLayout(); - preview_info_layout->SetSpaceBetweenChildren(12); - preview_info->SetLayout(preview_info_layout); + preview_info_layout_ = new nux::VLayout(); + preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + preview_info->SetLayout(preview_info_layout_); if (!preview_model_->description.Get().empty()) { @@ -172,37 +177,37 @@ description_->SetLines(-style.GetDescriptionLineCount()); description_->SetLineSpacing(style.GetDescriptionLineSpacing()); description_->mouse_click.connect(on_mouse_down); - preview_info_layout->AddView(description_.GetPointer()); + preview_info_layout_->AddView(description_.GetPointer()); } if (!preview_model_->GetInfoHints().empty()) { - preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); + preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale)); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - preview_info_layout->AddView(preview_info_hints_.GetPointer()); + preview_info_layout_->AddView(preview_info_hints_.GetPointer()); } ///////////////////// ///////////////////// // Actions action_buttons_.clear(); - nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); /////////////////// - full_data_layout_->AddLayout(preview_data_layout, 0); + full_data_layout_->AddLayout(preview_data_layout_, 0); full_data_layout_->AddView(preview_info, 1); - full_data_layout_->AddView(actions_layout, 0); + full_data_layout_->AddView(actions_layout_, 0); ///////////////////// - image_data_layout->AddView(image_.GetPointer(), 0); + image_data_layout_->AddView(image_.GetPointer(), 0); - image_data_layout->AddLayout(full_data_layout_, 1); + image_data_layout_->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); - SetLayout(image_data_layout); + SetLayout(image_data_layout_); } void GenericPreview::PreLayoutManagement() @@ -213,22 +218,61 @@ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height); - if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth()) - geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth()); - image_->SetMinMaxSize(geo_art.width, geo_art.height); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) + - style.GetDetailsLeftMargin().CP(scale) + - style.GetDetailsRightMargin().CP(scale); - int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale)) + geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); + + image_->SetMinMaxSize(geo_art.width, geo_art.height); + int details_width = std::max(0, content_width - geo_art.width); if (title_) { title_->SetMaximumWidth(details_width); } if (subtitle_) { subtitle_->SetMaximumWidth(details_width); } if (description_) { description_->SetMaximumWidth(details_width); } + int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); + int button_h = style.GetActionButtonHeight().CP(scale); + for (nux::AbstractButton* button : action_buttons_) + button->SetMinMaxSize(button_w, button_h); + + Preview::PreLayoutManagement(); +} + +void GenericPreview::UpdateScale(double scale) +{ + if (image_) + image_->scale = scale; + + if (preview_info_scroll_) + preview_info_scroll_->scale = scale; + + if (preview_info_hints_) + preview_info_hints_->scale = scale; + + previews::Style& style = dash::previews::Style::Instance(); + + if (full_data_layout_) { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight()); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale)); } - Preview::PreLayoutManagement(); + if (image_data_layout_) + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); + + if (preview_info_layout_) + preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + + if (preview_data_layout_) + preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); + + if (actions_layout_) + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); + + Preview::UpdateScale(scale); } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/GenericPreview.h unity-7.2.3+14.04.20140826/dash/previews/GenericPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/GenericPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/GenericPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -23,8 +23,9 @@ #ifndef GENERICPREVIEW_H #define GENERICPREVIEW_H -#include "Preview.h" #include +#include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -52,6 +53,13 @@ virtual void PreLayoutManagement(); virtual void SetupViews(); + virtual void UpdateScale(double scale); + + nux::HLayout* image_data_layout_; + nux::VLayout* preview_info_layout_; + ScrollView* preview_info_scroll_; + nux::VLayout* preview_data_layout_; + nux::Layout* actions_layout_; }; } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MoviePreview.cpp unity-7.2.3+14.04.20140826/dash/previews/MoviePreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/MoviePreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MoviePreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -23,7 +23,6 @@ #include "unity-shared/IntrospectableWrappers.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include #include #include @@ -41,23 +40,23 @@ { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.movie"); -class DetailsScrollView : public nux::ScrollView +namespace { -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } + const RawPixel CHILDREN_SPACE = 16_em; + const RawPixel PREVIEW_INFO_CHILDREN_SPACE = 12_em; +} -}; +DECLARE_LOGGER(logger, "unity.dash.preview.movie"); NUX_IMPLEMENT_OBJECT_TYPE(MoviePreview); MoviePreview::MoviePreview(dash::Preview::Ptr preview_model) : Preview(preview_model) +, image_data_layout_(nullptr) +, preview_info_layout_(nullptr) +, preview_info_scroll_(nullptr) +, actions_layout_(nullptr) { SetupViews(); } @@ -123,8 +122,8 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; - nux::HLayout* image_data_layout = new nux::HLayout(); - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); + image_data_layout_ = new nux::HLayout(); + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); ///////////////////// // Image @@ -136,8 +135,8 @@ ///////////////////// // Data Panel full_data_layout_ = new nux::VLayout(); - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); - full_data_layout_->SetSpaceBetweenChildren(16); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); ///////////////////// // Data @@ -148,6 +147,7 @@ title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetLines(-1); + title_->SetScale(scale); title_->SetFont(style.title_font().c_str()); title_->mouse_click.connect(on_mouse_down); app_data_layout->AddView(title_.GetPointer(), 1); @@ -157,6 +157,7 @@ subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION); AddChild(subtitle_.GetPointer()); subtitle_->SetLines(-1); + subtitle_->SetScale(scale); subtitle_->SetFont(style.subtitle_size_font().c_str()); subtitle_->mouse_click.connect(on_mouse_down); app_data_layout->AddView(subtitle_.GetPointer(), 1); @@ -166,8 +167,8 @@ if (movie_preview_model->rating >= 0) { rating_ = new PreviewRatingsWidget(); AddChild(rating_.GetPointer()); - rating_->SetMaximumHeight(style.GetRatingWidgetHeight()); - rating_->SetMinimumHeight(style.GetRatingWidgetHeight()); + rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale)); + rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); rating_->SetRating(movie_preview_model->rating); rating_->SetReviews(movie_preview_model->num_ratings); rating_->request_close().connect([this]() { preview_container_->request_close.emit(); }); @@ -175,20 +176,23 @@ ///////////////////// // Description - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); + preview_info_scroll_ = preview_info; + preview_info->scale = scale(); preview_info->EnableHorizontalScrollBar(false); preview_info->mouse_click.connect(on_mouse_down); - nux::VLayout* preview_info_layout = new nux::VLayout(); - preview_info_layout->SetSpaceBetweenChildren(12); - preview_info->SetLayout(preview_info_layout); + preview_info_layout_ = new nux::VLayout(); + preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE.CP(scale)); + preview_info->SetLayout(preview_info_layout_); if (!preview_model_->GetInfoHints().empty()) { preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); + preview_info_hints_->scale = scale(); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0); + preview_info_layout_->AddView(preview_info_hints_.GetPointer(), 0); } if (!preview_model_->description.Get().empty()) @@ -196,34 +200,35 @@ description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped! AddChild(description_.GetPointer()); description_->SetFont(style.description_font().c_str()); + description_->SetScale(scale); description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP); description_->SetLines(-style.GetDescriptionLineCount()); description_->SetLineSpacing(style.GetDescriptionLineSpacing()); description_->mouse_click.connect(on_mouse_down); - preview_info_layout->AddView(description_.GetPointer()); + preview_info_layout_->AddView(description_.GetPointer()); } ///////////////////// ///////////////////// // Actions action_buttons_.clear(); - nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); /////////////////// full_data_layout_->AddLayout(app_data_layout, 0); if (rating_ != NULL) full_data_layout_->AddView(rating_.GetPointer(), 0); full_data_layout_->AddView(preview_info, 1); - full_data_layout_->AddView(actions_layout, 0); + full_data_layout_->AddView(actions_layout_, 0); ///////////////////// - image_data_layout->AddView(image_.GetPointer(), 0); - image_data_layout->AddLayout(full_data_layout_, 1); + image_data_layout_->AddView(image_.GetPointer(), 0); + image_data_layout_->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); - SetLayout(image_data_layout); + SetLayout(image_data_layout_); } @@ -235,11 +240,13 @@ nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height); - if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth()) - geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth()); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale); + if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale)) + geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); + image_->SetMinMaxSize(geo_art.width, geo_art.height); - int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + int details_width = std::max(0, geo.width - geo_art.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale)); if (title_) { title_->SetMaximumWidth(details_width); } if (subtitle_) { subtitle_->SetMaximumWidth(details_width); } @@ -247,12 +254,49 @@ for (nux::AbstractButton* button : action_buttons_) { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight()); + button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale)); } Preview::PreLayoutManagement(); } +void MoviePreview::UpdateScale(double scale) +{ + Preview::UpdateScale(scale); + + if (image_) + image_->scale = scale; + + if (preview_info_hints_) + preview_info_hints_->scale = scale; + + previews::Style& style = dash::previews::Style::Instance(); + + if (full_data_layout_) + { + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + } + + if (image_data_layout_) + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); + + if (rating_) + { + rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale)); + rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); + } + + if (preview_info_scroll_) + preview_info_scroll_->scale = scale; + + if (preview_info_layout_) + preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE); + + if (actions_layout_) + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); +} + } // namespace previews } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MoviePreview.h unity-7.2.3+14.04.20140826/dash/previews/MoviePreview.h --- unity-7.2.2+14.04.20140714/dash/previews/MoviePreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MoviePreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -24,6 +24,7 @@ #define MOVIEPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -55,9 +56,15 @@ virtual void OnNavigateInComplete(); virtual void SetupViews(); - + virtual void UpdateScale(double scale); + protected: nux::ObjectPtr rating_; + + nux::HLayout* image_data_layout_; + nux::VLayout* preview_info_layout_; + ScrollView* preview_info_scroll_; + nux::Layout* actions_layout_; }; } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MusicPaymentPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/MusicPaymentPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/MusicPaymentPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MusicPaymentPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/StaticCairoText.h" -#include "unity-shared/PlacesVScrollBar.h" #include "config.h" #include @@ -49,6 +48,22 @@ { nux::logging::Logger logger("unity.dash.previews.payment.preview.music"); +const RawPixel DATA_MAX_HEIGHT = 76_em; +const RawPixel TITLE_CHILDREN_SPACE = 10_em; +const RawPixel PRIZE_CHILDREN_SPACE = 5_em; +const RawPixel TITLE_MAX_WIDTH = 480_em; +const RawPixel INTRO_MIN_HEIGHT = 50_em; +const RawPixel FORM_MIN_HEIGHT = 107_em; +const RawPixel FORM_PADDING = 20_em; +const RawPixel LABELS_CHILDREN_SPACE = 18_em; +const RawPixel PASSWORD_MIN_HEIGHT = 40_em; +const RawPixel PASSWORD_MIN_WIDTH = 240_em; +const RawPixel ACTIONS_CHILDREN_SPACE_MAX = 16_em; +const RawPixel ACTIONS_CHILDREN_SPACE_MIN = 8_em; +const RawPixel BUTTONS_SPACE = 20_em; +const RawPixel HEADER_CHILDREN_SPACE = 10_em; +const RawPixel HEADER_MAX_SIZE = 76_em; +const RawPixel BODY_CHILDREN_SPACE = 20_em; } // static string definitions @@ -59,17 +74,6 @@ const std::string MusicPaymentPreview::CANCEL_PURCHASE_ACTION = "cancel_purchase"; const std::string MusicPaymentPreview::PURCHASE_ALBUM_ACTION = "purchase_album"; -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(MusicPaymentPreview) MusicPaymentPreview::MusicPaymentPreview(dash::Preview::Ptr preview_model) @@ -77,6 +81,7 @@ { SetupViews(); PaymentPreview::SetupBackground(); + UpdateScale(scale); } std::string MusicPaymentPreview::GetName() const @@ -127,6 +132,7 @@ || MusicPaymentPreview::FORGOT_PASSWORD_ACTION == action_id) { nux::ObjectPtr link = this->CreateLink(action); + link->scale = scale(); link->activate.connect(sigc::mem_fun(this, &MusicPaymentPreview::OnActionLinkActivated)); @@ -137,6 +143,7 @@ nux::ObjectPtr button = this->CreateButton(action); button->activate.connect(sigc::mem_fun(this, &MusicPaymentPreview::OnActionActivated)); + button->scale = scale(); buttons_map_.insert(std::make_pair(action->id, button)); } @@ -148,8 +155,8 @@ { previews::Style& style = dash::previews::Style::Instance(); nux::VLayout* title_data_layout = new nux::VLayout(); - title_data_layout->SetMaximumHeight(76); - title_data_layout->SetSpaceBetweenChildren(10); + title_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale)); + title_data_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale)); title_ = new StaticCairoText( preview_model_->title.Get(), true, @@ -157,8 +164,9 @@ title_->SetFont(style.payment_title_font()); title_->SetLines(-1); + title_->SetScale(scale); title_->SetFont(style.title_font()); - title_->SetMaximumWidth(480); + title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale)); title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END); title_data_layout->AddView(title_.GetPointer(), 1); @@ -166,6 +174,7 @@ preview_model_->subtitle.Get(), true, NUX_TRACKER_LOCATION); subtitle_->SetLines(-1); + subtitle_->SetScale(scale); subtitle_->SetFont(style.payment_subtitle_font()); title_data_layout->AddView(subtitle_.GetPointer(), 1); title_data_layout->AddSpace(1, 1); @@ -176,14 +185,15 @@ { previews::Style& style = dash::previews::Style::Instance(); nux::VLayout *prize_data_layout = new nux::VLayout(); - prize_data_layout->SetMaximumHeight(76); - prize_data_layout->SetSpaceBetweenChildren(5); - prize_data_layout->SetPadding(0, 10, 0, 0); + prize_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale)); + prize_data_layout->SetSpaceBetweenChildren(PRIZE_CHILDREN_SPACE.CP(scale)); + prize_data_layout->SetPadding(0, TITLE_CHILDREN_SPACE.CP(scale), 0, 0); purchase_prize_ = new StaticCairoText( payment_preview_model_->purchase_prize.Get(), true, NUX_TRACKER_LOCATION); purchase_prize_->SetLines(-1); + purchase_prize_->SetScale(scale); purchase_prize_->SetFont(style.payment_prize_title_font()); prize_data_layout->AddView(purchase_prize_.GetPointer(), 1, nux::MINOR_POSITION_END); @@ -192,6 +202,7 @@ _("Ubuntu One best offer"), true, NUX_TRACKER_LOCATION); purchase_hint_->SetLines(-1); + purchase_hint_->SetScale(scale); purchase_hint_->SetFont(style.payment_prize_subtitle_font()); prize_data_layout->AddView(purchase_hint_.GetPointer(), 1, nux::MINOR_POSITION_END); @@ -200,6 +211,7 @@ payment_preview_model_->purchase_type.Get(), true, NUX_TRACKER_LOCATION); purchase_type_->SetLines(-1); + purchase_type_->SetScale(scale); purchase_type_->SetFont(style.payment_prize_subtitle_font()); prize_data_layout->AddView(purchase_type_.GetPointer(), 1, nux::MINOR_POSITION_END); @@ -210,31 +222,30 @@ { previews::Style& style = dash::previews::Style::Instance(); nux::VLayout *body_layout = new nux::VLayout(); - body_layout->SetSpaceBetweenChildren(20); + body_layout->SetSpaceBetweenChildren(BODY_CHILDREN_SPACE.CP(scale)); intro_ = new StaticCairoText( payment_preview_model_->header.Get(), true, NUX_TRACKER_LOCATION); intro_->SetFont(style.payment_intro_font()); - intro_->SetLineSpacing(10); + intro_->SetScale(scale); + intro_->SetLineSpacing(TITLE_CHILDREN_SPACE.CP(scale)); intro_->SetLines(-style.GetDescriptionLineCount()); - intro_->SetMinimumHeight(50); + intro_->SetMinimumHeight(INTRO_MIN_HEIGHT.CP(scale)); form_layout_ = new nux::HLayout(); - form_layout_->SetSpaceBetweenChildren(10); - form_layout_->SetMinimumHeight(107); - form_layout_->SetLeftAndRightPadding(20); - form_layout_->SetTopAndBottomPadding(10); + form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale)); + form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale)); + form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale)); + form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale)); form_layout_->AddLayout(GetFormLabels(), 1, nux::MINOR_POSITION_END); form_layout_->AddLayout(GetFormFields(), 1, nux::MINOR_POSITION_END); form_layout_->AddLayout(GetFormActions(), 1, nux::MINOR_POSITION_END); - body_layout->AddView(intro_.GetPointer(), 1); body_layout->AddLayout(form_layout_.GetPointer(), 1); - return body_layout; } @@ -244,17 +255,18 @@ nux::VLayout *labels_layout = new nux::VLayout(); if (error_message_.empty()) { - labels_layout->SetSpaceBetweenChildren(18); + labels_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale)); } else { - labels_layout->SetSpaceBetweenChildren(10); + labels_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale)); } email_label_ = new StaticCairoText( _("Ubuntu One email:"), true, NUX_TRACKER_LOCATION); email_label_->SetLines(-1); + email_label_->SetScale(scale); email_label_->SetFont(style.payment_form_labels_font()); labels_layout->AddView(email_label_.GetPointer(), 0, nux::MINOR_POSITION_END); @@ -262,6 +274,7 @@ _("Payment method:"), true, NUX_TRACKER_LOCATION); payment_label_->SetLines(-1); + payment_label_->SetScale(scale); payment_label_->SetFont(style.payment_form_labels_font()); labels_layout->AddView(payment_label_.GetPointer(), 0, nux::MINOR_POSITION_END); @@ -269,8 +282,9 @@ _("Ubuntu One password:"), true, NUX_TRACKER_LOCATION); password_label_->SetLines(-1); + password_label_->SetScale(scale); password_label_->SetFont(style.payment_form_labels_font()); - password_label_->SetMinimumHeight(40); + password_label_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale)); labels_layout->AddView(password_label_.GetPointer(), 0, nux::MINOR_POSITION_END); return labels_layout; @@ -282,17 +296,18 @@ nux::VLayout *fields_layout = new nux::VLayout(); if (error_message_.empty()) { - fields_layout->SetSpaceBetweenChildren(18); + fields_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale)); } else { - fields_layout->SetSpaceBetweenChildren(10); + fields_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale)); } email_ = new StaticCairoText( payment_preview_model_->email.Get(), true, NUX_TRACKER_LOCATION); email_->SetLines(-1); + email_->SetScale(scale); email_->SetFont(style.payment_form_data_font()); fields_layout->AddView(email_.GetPointer(), 1, nux::MINOR_POSITION_START); @@ -301,13 +316,14 @@ payment_preview_model_->payment_method.Get(), true, NUX_TRACKER_LOCATION); payment_->SetLines(-1); + payment_->SetScale(scale); payment_->SetFont(style.payment_form_data_font()); fields_layout->AddView(payment_.GetPointer(), 1, nux::MINOR_POSITION_START); password_entry_ = new TextInput(); - password_entry_->SetMinimumHeight(40); - password_entry_->SetMinimumWidth(240); + password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale)); + password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale)); password_entry_->input_hint = _("Password"); fields_layout->AddView(password_entry_.GetPointer(), @@ -322,6 +338,7 @@ StaticCairoText* error = new StaticCairoText( _("Wrong password"), true, NUX_TRACKER_LOCATION); error->SetLines(-1); + error->SetScale(scale); error->SetFont(style.payment_form_data_font()); // ensure it is an error using red error->SetTextColor(style.payment_error_color()); @@ -337,11 +354,11 @@ nux::VLayout *actions_layout = new nux::VLayout(); if (error_message_.empty()) { - actions_layout->SetSpaceBetweenChildren(16); + actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MAX.CP(scale)); } else { - actions_layout->SetSpaceBetweenChildren(8); + actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MIN.CP(scale)); } nux::ObjectPtr empty_; @@ -349,6 +366,7 @@ "", true, NUX_TRACKER_LOCATION); empty_->SetLines(-1); + empty_->SetScale(scale); empty_->SetFont(style.payment_form_labels_font()); actions_layout->AddView(empty_.GetPointer(), 1, nux::MINOR_POSITION_START); @@ -374,14 +392,14 @@ actions_buffer_h->AddSpace(0, 1); nux::HLayout* buttons_data_layout = new nux::HLayout(); - buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions()); + buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale)); - lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth(), - style.GetPaymentLockHeight()); + lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth().CP(scale), + style.GetPaymentLockHeight().CP(scale)); buttons_data_layout->AddView(lock_texture_.GetPointer(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN); - buttons_data_layout->AddSpace(20, 1); + buttons_data_layout->AddSpace(BUTTONS_SPACE.CP(scale), 1); if(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer()) buttons_data_layout->AddView(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f, @@ -413,7 +431,8 @@ previews::Style& style = dash::previews::Style::Instance(); - int width = std::max(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale); + int width = std::max(0, content_width); if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); } if(header_layout_) { header_layout_->SetMaximumWidth(width); } @@ -460,6 +479,49 @@ PaymentPreview::SetupViews(); } +void MusicPaymentPreview::UpdateScale(double scale) +{ + PaymentPreview::UpdateScale(scale); + + if (intro_) + intro_->SetScale(scale); + if (email_label_) + email_label_->SetScale(scale); + if (payment_label_) + payment_label_->SetScale(scale); + if (payment_) + payment_->SetScale(scale); + if (password_label_) + password_label_->SetScale(scale); + if (purchase_hint_) + purchase_hint_->SetScale(scale); + if (purchase_prize_) + purchase_prize_->SetScale(scale); + if (purchase_type_) + purchase_type_->SetScale(scale); + if (change_payment_) + change_payment_->SetScale(scale); + if (error_label_) + error_label_->SetScale(scale); + + previews::Style& style = dash::previews::Style::Instance(); + if (lock_texture_) + lock_texture_->SetSize(std::max(style.GetPaymentLockWidth().CP(scale), style.GetPaymentLockHeight().CP(scale))); + + if (password_entry_) + { + password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale)); + password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale)); + } + + if (form_layout_) + { + form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale)); + form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale)); + form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale)); + form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale)); + } +} } } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MusicPaymentPreview.h unity-7.2.3+14.04.20140826/dash/previews/MusicPaymentPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/MusicPaymentPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MusicPaymentPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -90,6 +90,7 @@ void OnActionLinkActivated(ActionLink* link, std::string const& id); virtual void SetupViews(); + virtual void UpdateScale(double scale) override; void PreLayoutManagement(); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MusicPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/MusicPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/MusicPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MusicPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -42,14 +42,27 @@ { namespace previews { + +namespace +{ + const RawPixel CHILDREN_SPACE = 16_em; + const RawPixel ICON_LEFT_RIGHT_PADDING = 10_em; + const RawPixel WARNING_MIN_HEIGHT = 50_em; + const RawPixel WARNING_MAX_WIDTH = 300_em; +} + DECLARE_LOGGER(logger, "unity.dash.preview.music"); NUX_IMPLEMENT_OBJECT_TYPE(MusicPreview); MusicPreview::MusicPreview(dash::Preview::Ptr preview_model) : Preview(preview_model) +, actions_layout_(nullptr) +, image_data_layout_(nullptr) +, icon_layout_(nullptr) { SetupViews(); + UpdateScale(scale); } MusicPreview::~MusicPreview() @@ -130,13 +143,13 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; - nux::HLayout* image_data_layout = new nux::HLayout(); - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); + image_data_layout_ = new nux::HLayout(); + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); ///////////////////// // Image image_ = new CoverArt(); - + image_->scale = scale(); AddChild(image_.GetPointer()); UpdateCoverArtImage(image_.GetPointer()); ///////////////////// @@ -144,20 +157,21 @@ ///////////////////// // App Data Panel full_data_layout_ = new nux::VLayout(); - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); - full_data_layout_->SetSpaceBetweenChildren(16); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); ///////////////////// // Music Info - nux::VLayout* album_data_layout = new nux::VLayout(); - album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); + album_data_layout_ = new nux::VLayout(); + album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetFont(style.title_font().c_str()); title_->SetLines(-1); + title_->SetScale(scale); title_->mouse_click.connect(on_mouse_down); - album_data_layout->AddView(title_.GetPointer(), 1); + album_data_layout_->AddView(title_.GetPointer(), 1); if (!preview_model_->subtitle.Get().empty()) { @@ -165,8 +179,9 @@ AddChild(subtitle_.GetPointer()); subtitle_->SetFont(style.subtitle_size_font().c_str()); subtitle_->SetLines(-1); + subtitle_->SetScale(scale); subtitle_->mouse_click.connect(on_mouse_down); - album_data_layout->AddView(subtitle_.GetPointer(), 1); + album_data_layout_->AddView(subtitle_.GetPointer(), 1); } ///////////////////// @@ -177,6 +192,7 @@ if (tracks_model) { tracks_ = new previews::Tracks(tracks_model, NUX_TRACKER_LOCATION); + tracks_->scale = scale(); AddChild(tracks_.GetPointer()); tracks_->mouse_click.connect(on_mouse_down); } @@ -187,7 +203,7 @@ ///////////////////// // Hints && Actions nux::VLayout* hints_layout = NULL; - nux::Layout* actions_layout = NULL; + actions_layout_ = NULL; bool has_u1_creds = HasUbuntuOneCredentials(); if (has_u1_creds) @@ -197,70 +213,72 @@ hints_layout = new nux::VLayout(); hints_layout->SetSpaceBetweenChildren(0); hints_layout->AddSpace(0, 1); - preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); + preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale)); + preview_info_hints_->scale = scale(); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); hints_layout->AddView(preview_info_hints_.GetPointer(), 0); // If there are actions, we use a vertical layout action_buttons_.clear(); - actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_ = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); } else // otherwise we add a grid layout. { action_buttons_.clear(); - actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); if (action_buttons_.size() < 2) hint_actions_layout->AddSpace(0, 1); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); } } else { // let the user know he needs to connect previews::Style& style = dash::previews::Style::Instance(); - actions_layout = new nux::HLayout(); - nux::VLayout* icon_layout = new nux::VLayout(); - icon_layout->SetLeftAndRightPadding(10); + nux::HLayout* actions_layout = new nux::HLayout(); + icon_layout_ = new nux::VLayout(); + icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale)); warning_texture_ = new IconTexture(style.GetWarningIcon()); - icon_layout->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START, + icon_layout_->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN); - actions_layout->AddLayout(icon_layout, 0, nux::MINOR_POSITION_CENTER); + actions_layout->AddLayout(icon_layout_, 0, nux::MINOR_POSITION_CENTER); warning_msg_ = new StaticCairoText( no_credentials_message_, true, NUX_TRACKER_LOCATION); - AddChild(warning_msg_.GetPointer()); + AddChild(warning_msg_.GetPointer()); warning_msg_->SetFont(style.u1_warning_font().c_str()); warning_msg_->SetLines(-2); - warning_msg_->SetMinimumHeight(50); - warning_msg_->SetMaximumWidth(300); + warning_msg_->SetScale(scale); + warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale)); + warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale)); actions_layout->AddView(warning_msg_.GetPointer(), 0, nux::MINOR_POSITION_CENTER); } - + ///////////////////// if (hints_layout) hint_actions_layout->AddView(hints_layout, 1); - hint_actions_layout->AddView(actions_layout, 0); + hint_actions_layout->AddView(actions_layout_, 0); - full_data_layout_->AddLayout(album_data_layout, 0); + full_data_layout_->AddLayout(album_data_layout_, 0); if (tracks_) { full_data_layout_->AddView(tracks_.GetPointer(), 1); } full_data_layout_->AddLayout(hint_actions_layout, 0); ///////////////////// - - image_data_layout->AddView(image_.GetPointer(), 0); - image_data_layout->AddLayout(full_data_layout_, 1); + + image_data_layout_->AddView(image_.GetPointer(), 0); + image_data_layout_->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); - SetLayout(image_data_layout); + SetLayout(image_data_layout_); } void MusicPreview::PreLayoutManagement() @@ -272,23 +290,23 @@ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height); - if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth()) - geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth()); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale); + if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale)) + geo_art.width = MAX(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); image_->SetMinMaxSize(geo_art.width, geo_art.height); - int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + int details_width = MAX(0, content_width - geo_art.width); if (title_) { title_->SetMaximumWidth(details_width); } if (subtitle_) { subtitle_->SetMaximumWidth(details_width); } for (nux::AbstractButton* button : action_buttons_) { - int action_width = CLAMP((details_width - style.GetSpaceBetweenActions()) / - 2, 0, style.GetActionButtonMaximumWidth()); + int action_width = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); // do not use SetMinMax because width has to be able to grow button->SetMinimumWidth(action_width); - button->SetMinimumHeight(style.GetActionButtonHeight()); - button->SetMaximumHeight(style.GetActionButtonHeight()); + button->SetMinimumHeight(style.GetActionButtonHeight().CP(scale)); + button->SetMaximumHeight(style.GetActionButtonHeight().CP(scale)); } Preview::PreLayoutManagement(); @@ -300,6 +318,47 @@ player.Stop(); } +void MusicPreview::UpdateScale(double scale) +{ + Preview::UpdateScale(scale); + + if (tracks_) + tracks_->scale = scale; + + if (preview_info_hints_) + preview_info_hints_->scale = scale; + + if (icon_layout_) + icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale)); + + if (warning_msg_) + { + warning_msg_->SetScale(scale); + warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale)); + warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale)); + } + + previews::Style& style = dash::previews::Style::Instance(); + + if (image_data_layout_) + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); + + if (full_data_layout_) + { + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + } + + if (album_data_layout_) + album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); + + if (actions_layout_) + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); + + if (icon_layout_) + icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale)); +} + } // namespace previews } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/MusicPreview.h unity-7.2.3+14.04.20140826/dash/previews/MusicPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/MusicPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/MusicPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -24,6 +24,7 @@ #define MUSICPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/IconTexture.h" namespace unity @@ -53,6 +54,7 @@ virtual void PreLayoutManagement(); virtual void SetupViews(); + virtual void UpdateScale(double scale); virtual void OnNavigateOut(); @@ -64,6 +66,10 @@ nux::ObjectPtr warning_texture_; std::string no_credentials_message_; + nux::Layout* actions_layout_; + nux::HLayout* image_data_layout_; + nux::VLayout* icon_layout_; + nux::VLayout* album_data_layout_; }; } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PaymentPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/PaymentPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/PaymentPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PaymentPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -23,6 +23,7 @@ #include #include "PaymentPreview.h" #include "unity-shared/CoverArt.h" +#include "unity-shared/DashStyle.h" #include "unity-shared/PreviewStyle.h" namespace unity @@ -39,6 +40,15 @@ nux::logging::Logger logger("unity.dash.previews.payment.preview"); +const RawPixel CONTENT_DATA_CHILDREN_SPACE = 5_em; +const RawPixel CONTENT_DATA_PADDING = 10_em; +const RawPixel OVERLAY_LAYOUT_SPACE = 20_em; +const RawPixel HEADER_CHILDREN_SPACE = 10_em; +const RawPixel HEADER_MAX_SIZE = 76_em; +const RawPixel IMAGE_MIN_MAX_SIZE = 64_em; +const RawPixel HEADER_SPACE = 10_em; +const RawPixel LINK_MIN_WIDTH = 178_em; +const RawPixel LINK_MAX_HEIGHT = 34_em; } class OverlaySpinner : public unity::debug::Introspectable, public nux::View @@ -47,6 +57,8 @@ public: OverlaySpinner(); + nux::Property scale; + void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); @@ -61,7 +73,7 @@ private: bool OnFrameTimeout(); - nux::BaseTexture* spin_; + nux::ObjectPtr spin_; glib::Source::UniquePtr frame_timeout_; @@ -72,15 +84,19 @@ NUX_IMPLEMENT_OBJECT_TYPE(OverlaySpinner); OverlaySpinner::OverlaySpinner() - : nux::View(NUX_TRACKER_LOCATION), - rotation_(0.0f) + : nux::View(NUX_TRACKER_LOCATION) + , scale(1.0) + , rotation_(0.0f) { - previews::Style& style = dash::previews::Style::Instance(); - - spin_ = style.GetSearchSpinIcon(); + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); rotate_.Identity(); rotate_.Rotate_z(0.0); + + scale.changed.connect([this] (double scale) { + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); + QueueDraw(); + }); } void OverlaySpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) @@ -183,8 +199,12 @@ : Preview(preview_model) , data_(nullptr) , full_data_layout_(nullptr) -{ -} +, content_data_layout_(nullptr) +, overlay_layout_(nullptr) +, header_layout_(nullptr) +, body_layout_(nullptr) +, footer_layout_(nullptr) +{} std::string PaymentPreview::GetName() const { @@ -199,18 +219,18 @@ nux::Layout* PaymentPreview::GetHeader() { nux::HLayout* header_data_layout = new nux::HLayout(); - header_data_layout->SetSpaceBetweenChildren(10); - header_data_layout->SetMaximumHeight(76); - header_data_layout->SetMinimumHeight(76); + header_data_layout->SetSpaceBetweenChildren(HEADER_CHILDREN_SPACE.CP(scale)); + header_data_layout->SetMaximumHeight(HEADER_MAX_SIZE.CP(scale)); + header_data_layout->SetMinimumHeight(HEADER_MAX_SIZE.CP(scale)); image_ = new CoverArt(); - image_->SetMinMaxSize(64, 64); + image_->SetMinMaxSize(IMAGE_MIN_MAX_SIZE.CP(scale), IMAGE_MIN_MAX_SIZE.CP(scale)); AddChild(image_.GetPointer()); UpdateCoverArtImage(image_.GetPointer()); header_data_layout->AddView(image_.GetPointer(), 0); header_data_layout->AddLayout(GetTitle(), 0); - header_data_layout->AddSpace(10, 1); + header_data_layout->AddSpace(HEADER_SPACE.CP(scale), 1); header_data_layout->AddLayout(GetPrice(), 0); return header_data_layout; } @@ -223,8 +243,8 @@ link = new ActionLink(action->id, action->display_name, NUX_TRACKER_LOCATION); link->font_hint.Set(style.payment_form_labels_font().c_str()); - link->SetMinimumWidth(178); - link->SetMaximumHeight(34); + link->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale)); + link->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale)); return link; } @@ -239,8 +259,8 @@ NUX_TRACKER_LOCATION); button->SetFont(style.action_font()); button->SetExtraHint(action->extra_text, style.action_extra_font()); - button->SetMinimumWidth(178); - button->SetMaximumHeight(34); + button->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale)); + button->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale)); return button; } @@ -327,8 +347,8 @@ // layout to be used to show the info content_data_layout_ = new nux::VLayout(); - content_data_layout_->SetSpaceBetweenChildren(5); - content_data_layout_->SetPadding(10, 10, 0, 10); + content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale)); + content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale)); header_layout_ = GetHeader(); @@ -344,21 +364,37 @@ // layout to draw an overlay overlay_layout_ = new nux::VLayout(); - StaticCairoText* calculating = new StaticCairoText( + calculating_ = new StaticCairoText( "Performing purchase", true, NUX_TRACKER_LOCATION); OverlaySpinner* spinner_ = new OverlaySpinner(); - overlay_layout_->AddSpace(20, 1); - overlay_layout_->AddView(calculating, 0, nux::MINOR_POSITION_CENTER); + overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1); + overlay_layout_->AddView(calculating_, 0, nux::MINOR_POSITION_CENTER); overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER); - overlay_layout_->AddSpace(20, 1); + overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1); + scale.changed.connect([this, spinner_] (double scale) { spinner_->scale = scale; }); full_data_layout_->AddLayout(overlay_layout_.GetPointer()); + UpdateScale(scale); SetLayout(full_data_layout_.GetPointer()); } +void PaymentPreview::UpdateScale(double scale) +{ + Preview::UpdateScale(scale); + + if (calculating_) + calculating_->SetScale(scale); + + if (content_data_layout_) + { + content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale)); + content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale)); + } +} + } } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PaymentPreview.h unity-7.2.3+14.04.20140826/dash/previews/PaymentPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/PaymentPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PaymentPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -106,6 +106,7 @@ virtual void LoadActions() = 0; virtual void SetupViews(); + virtual void UpdateScale(double scale) override; virtual void SetupBackground(); nux::ObjectPtr full_data_layout_; @@ -115,6 +116,8 @@ nux::ObjectPtr body_layout_; nux::ObjectPtr footer_layout_; + StaticCairoText* calculating_; + // content elements nux::ObjectPtr image_; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewContainer.cpp unity-7.2.3+14.04.20140826/dash/previews/PreviewContainer.cpp --- unity-7.2.2+14.04.20140714/dash/previews/PreviewContainer.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewContainer.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -23,11 +23,11 @@ #include "PreviewContainer.h" #include #include -#include #include "unity-shared/IntrospectableWrappers.h" #include "unity-shared/TimeUtil.h" #include "unity-shared/PreviewStyle.h" +#include "unity-shared/DashStyle.h" #include "unity-shared/GraphicsUtils.h" #include "PreviewNavigator.h" #include @@ -52,13 +52,15 @@ const int PREVIEW_SPINNER_WAIT = 2000; const std::string ANIMATION_IDLE = "animation-idle"; +const RawPixel CHILDREN_SPACE = 6_em; } class PreviewContent : public nux::Layout, public debug::Introspectable { public: PreviewContent(PreviewContainer*const parent) - : parent_(parent) + : scale(1.0) + , parent_(parent) , progress_(0.0) , curve_progress_(0.0) , animating_(false) @@ -73,9 +75,19 @@ // Need to update the preview geometries when updating the container geo. UpdateAnimationProgress(progress_, curve_progress_); }); - Style& style = previews::Style::Instance(); - spin_= style.GetSearchSpinIcon(32); + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); + scale.changed.connect(sigc::mem_fun(this, &PreviewContent::UpdateScale)); + } + + void UpdateScale(double scale) + { + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); + + for (auto* area : GetChildren()) + static_cast(area)->scale = scale; + + QueueDraw(); } // From debug::Introspectable @@ -107,6 +119,7 @@ AddChild(preview.GetPointer()); AddView(preview.GetPointer()); preview->SetVisible(false); + preview->scale = scale(); } else { @@ -355,6 +368,7 @@ sigc::signal start_navigation; sigc::signal continue_navigation; sigc::signal end_navigation; + nux::Property scale; private: PreviewContainer*const parent_; @@ -394,6 +408,7 @@ PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) + , scale(1.0) , preview_layout_(nullptr) , nav_disabled_(Navigation::NONE) , navigation_progress_speed_(0.0) @@ -408,6 +423,7 @@ key_down.connect(sigc::mem_fun(this, &PreviewContainer::OnKeyDown)); mouse_click.connect(sigc::mem_fun(this, &PreviewContainer::OnMouseDown)); + scale.changed.connect(sigc::mem_fun(this, &PreviewContainer::UpdateScale)); } PreviewContainer::~PreviewContainer() @@ -417,13 +433,12 @@ void PreviewContainer::Preview(dash::Preview::Ptr preview_model, Navigation direction) { previews::Preview::Ptr preview_view = preview_model ? previews::Preview::PreviewForModel(preview_model) : previews::Preview::Ptr(); - + if (preview_view) { preview_view->request_close().connect([this]() { request_close.emit(); }); + preview_layout_->PushPreview(preview_view, direction); } - - preview_layout_->PushPreview(preview_view, direction); } void PreviewContainer::DisableNavButton(Navigation button) @@ -458,29 +473,32 @@ nux::VLayout* layout = new nux::VLayout(); SetLayout(layout); - layout->AddLayout(new nux::SpaceLayout(0,0,style.GetPreviewTopPadding(),style.GetPreviewTopPadding())); + + layout->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0); layout_content_ = new nux::HLayout(); - layout_content_->SetSpaceBetweenChildren(6); + layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); layout->AddLayout(layout_content_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); layout_content_->AddSpace(0, 1); nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION); AddChild(nav_left_); - nav_left_->SetMinimumWidth(style.GetNavigatorWidth()); - nav_left_->SetMaximumWidth(style.GetNavigatorWidth()); + nav_left_->scale = scale(); + nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale)); + nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale)); nav_left_->activated.connect([this]() { navigate_left.emit(); }); layout_content_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); preview_layout_ = new PreviewContent(this); - preview_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight()); + preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale)); AddChild(preview_layout_); layout_content_->AddLayout(preview_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION); AddChild(nav_right_); - nav_right_->SetMinimumWidth(style.GetNavigatorWidth()); - nav_right_->SetMaximumWidth(style.GetNavigatorWidth()); + nav_right_->scale = scale(); + nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale)); + nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale)); nav_right_->activated.connect([this]() { navigate_right.emit(); }); layout_content_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); layout_content_->AddSpace(0, 1); @@ -492,7 +510,7 @@ // reset animation clock. if (navigation_count_ == 0) clock_gettime(CLOCK_MONOTONIC, &last_progress_time_); - + float navigation_progress_remaining = CLAMP((1.0 - preview_layout_->GetAnimationProgress()) + navigation_count_, 1.0f, 10.0f); navigation_count_++; @@ -534,7 +552,7 @@ gfx_engine.GetRenderStates().SetBlend(false); gfx_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); } - + // rely on the compiz event loop to come back to us in a nice throttling if (AnimationInProgress()) { @@ -595,11 +613,12 @@ bool PreviewContainer::QueueAnimation() { animation_timer_.reset(); - + timespec current; clock_gettime(CLOCK_MONOTONIC, ¤t); float progress = GetSwipeAnimationProgress(current); - preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out. + if (preview_layout_) + preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out. last_progress_time_ = current; QueueDraw(); @@ -691,7 +710,30 @@ nux::Geometry PreviewContainer::GetLayoutGeometry() const { - return layout_content_->GetAbsoluteGeometry(); + return layout_content_->GetAbsoluteGeometry(); +} + +void PreviewContainer::UpdateScale(double scale) +{ + previews::Style& style = previews::Style::Instance(); + + GetLayout()->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0); + + preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale)); + preview_layout_->scale = scale; + + layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + + nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale)); + nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale)); + nav_left_->scale = scale; + + nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale)); + nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale)); + nav_right_->scale = scale; + + QueueRelayout(); + QueueDraw(); } } // namespace previews diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewContainer.h unity-7.2.3+14.04.20140826/dash/previews/PreviewContainer.h --- unity-7.2.2+14.04.20140714/dash/previews/PreviewContainer.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewContainer.h 2014-08-26 15:48:28.000000000 +0200 @@ -25,6 +25,7 @@ #include #include +#include #include #include "Preview.h" #include "unity-shared/Introspectable.h" @@ -74,6 +75,8 @@ sigc::signal navigate_right; sigc::signal request_close; + nux::Property scale; + bool AcceptKeyNavFocus(); nux::Area* KeyNavIteration(nux::KeyNavDirection direction); @@ -91,7 +94,7 @@ bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character); void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count); - + private: void SetupViews(); @@ -101,6 +104,8 @@ bool QueueAnimation(); private: + void UpdateScale(double scale); + // View related nux::HLayout* layout_content_; PreviewNavigator* nav_left_; @@ -112,7 +117,7 @@ struct timespec last_progress_time_; float navigation_progress_speed_; int navigation_count_; - + glib::Source::UniquePtr animation_timer_; friend class PreviewContent; }; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Preview.cpp unity-7.2.3+14.04.20140826/dash/previews/Preview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/Preview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Preview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,6 +38,7 @@ #include "MusicPaymentPreview.h" #include "SocialPreview.h" #include "PreviewInfoHintWidget.h" +#include "ActionButton.h" namespace unity { @@ -100,14 +101,16 @@ Preview::Preview(dash::Preview::Ptr preview_model) : View(NUX_TRACKER_LOCATION) + , scale(1.0f) , preview_model_(preview_model) , tab_iterator_(new TabIterator()) , full_data_layout_(nullptr) , image_(nullptr) , title_(nullptr) , subtitle_(nullptr) + , preview_container_(new PreviewContainer) { - preview_container_ = new PreviewContainer; + scale.changed.connect(sigc::mem_fun(this, &Preview::UpdateScale)); } Preview::~Preview() @@ -138,13 +141,13 @@ previews::Style& style = dash::previews::Style::Instance(); nux::VLayout* actions_layout_v = new nux::VLayout(); - actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions()); + actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale)); uint rows = actions.size() / 2 + ((actions.size() % 2 > 0) ? 1 : 0); uint action_iter = 0; for (uint i = 0; i < rows; i++) { nux::HLayout* actions_layout_h = new TabIteratorHLayout(tab_iterator_); - actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions()); + actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale)); for (uint j = 0; j < 2 && action_iter < actions.size(); j++, action_iter++) { @@ -172,7 +175,7 @@ previews::Style& style = dash::previews::Style::Instance(); nux::VLayout* actions_layout_v = new TabIteratorVLayout(tab_iterator_); - actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions()); + actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale)); uint action_iter = 0; for (uint i = 0; i < actions.size(); i++) @@ -215,7 +218,7 @@ else cover_art->SetNoImageAvailable(); cover_art->SetFont(style.no_preview_image_font()); - + cover_art->mouse_click.connect(on_mouse_down); } @@ -279,6 +282,37 @@ return preview_container_->request_close; } +void Preview::UpdateScale(double scale) +{ + if (image_) + image_->scale = scale; + + if (title_) + title_->SetScale(scale); + if (subtitle_) + subtitle_->SetScale(scale); + if (description_) + description_->SetScale(scale); + + if (preview_container_) + preview_container_->scale = scale; + + if (preview_info_hints_) + preview_info_hints_->scale = scale; + + for (nux::AbstractButton* button : action_buttons_) + { + if (ActionButton* bn = dynamic_cast(button)) + bn->scale = scale; + + if (ActionLink* link = dynamic_cast(button)) + link->scale = scale; + } + + QueueRelayout(); + QueueDraw(); } -} -} + +} // preview +} // dash +} // unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Preview.h unity-7.2.3+14.04.20140826/dash/previews/Preview.h --- unity-7.2.2+14.04.20140714/dash/previews/Preview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Preview.h 2014-08-26 15:48:28.000000000 +0200 @@ -74,6 +74,8 @@ unsigned long special_keys_state); virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction); + nux::Property scale; + protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {} virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {} @@ -88,6 +90,8 @@ virtual void SetupViews() = 0; + virtual void UpdateScale(double scale); + nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list& buttons); nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list& buttons); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewInfoHintWidget.cpp unity-7.2.3+14.04.20140826/dash/previews/PreviewInfoHintWidget.cpp --- unity-7.2.2+14.04.20140714/dash/previews/PreviewInfoHintWidget.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewInfoHintWidget.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -17,6 +17,7 @@ * * * Authored by: Nick Dedekind + * Marco Trevisan * */ @@ -41,21 +42,23 @@ DECLARE_LOGGER(logger, "unity.dash.preview.infohintwidget"); namespace { -const int layout_spacing = 12; +const RawPixel LAYOUT_SPACING = 12_em; +const RawPixel HINTS_SPACING = 6_em; } NUX_IMPLEMENT_OBJECT_TYPE(PreviewInfoHintWidget); PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size) : View(NUX_TRACKER_LOCATION) +, scale(1.0) , icon_size_(icon_size) +, layout_(nullptr) +, info_names_layout_(nullptr) +, info_values_layout_(nullptr) , preview_model_(preview_model) { SetupViews(); -} - -PreviewInfoHintWidget::~PreviewInfoHintWidget() -{ + scale.changed.connect(sigc::mem_fun(this, &PreviewInfoHintWidget::UpdateScale)); } void PreviewInfoHintWidget::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) @@ -96,7 +99,7 @@ { std::stringstream ss; const GVariantType* info_hint_type = g_variant_get_type(variant); - + if (g_variant_type_equal(info_hint_type, G_VARIANT_TYPE_BOOLEAN)) { ss << g_variant_get_int16(variant); @@ -144,96 +147,89 @@ void PreviewInfoHintWidget::SetupViews() { RemoveLayout(); - info_hints_.clear(); - - previews::Style& style = previews::Style::Instance(); + auto& style = previews::Style::Instance(); auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); }; - nux::VLayout* layout = new nux::VLayout(); - layout->SetSpaceBetweenChildren(6); - - for (dash::Preview::InfoHintPtr info_hint : preview_model_->GetInfoHints()) - { - nux::HLayout* hint_layout = new nux::HLayout(); - hint_layout->SetSpaceBetweenChildren(layout_spacing); + layout_ = new nux::HLayout(); + layout_->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); - StaticCairoTextPtr info_name; - if (!info_hint->display_name.empty()) - { - // The "%s" is used in the dash preview to display the ": " infos - std::string tmp_display_name = glib::String(g_strdup_printf (_("%s:"), info_hint->display_name.c_str())).Str(); + auto *hint_vlayout = new nux::VLayout(); + hint_vlayout->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale)); + layout_->AddLayout(hint_vlayout); + info_names_layout_ = hint_vlayout; + + hint_vlayout = new nux::VLayout(); + hint_vlayout->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale)); + layout_->AddLayout(hint_vlayout); + info_values_layout_ = hint_vlayout; - info_name = new StaticCairoText(tmp_display_name, true, NUX_TRACKER_LOCATION); - info_name->SetFont(style.info_hint_bold_font()); - info_name->SetLines(-1); - info_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); - info_name->mouse_click.connect(on_mouse_down); - hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER); - } + for (dash::Preview::InfoHintPtr const& info_hint : preview_model_->GetInfoHints()) + { + // The "%s" is used in the dash preview to display the ": " infos + auto const& name = glib::String(g_strdup_printf (_("%s:"), info_hint->display_name.c_str())).Str(); + auto* info_name = new StaticCairoText(name == ":" ? "" : name, true, NUX_TRACKER_LOCATION); + info_name->SetFont(style.info_hint_bold_font()); + info_name->SetLines(-1); + info_name->SetScale(scale); + info_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); + info_name->SetMinimumWidth(style.GetInfoHintNameMinimumWidth().CP(scale)); + info_name->SetMaximumWidth(style.GetInfoHintNameMaximumWidth().CP(scale)); + info_name->mouse_click.connect(on_mouse_down); + info_names_layout_->AddView(info_name, 1, nux::MINOR_POSITION_RIGHT); - StaticCairoTextPtr info_value(new StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION)); + auto* info_value = new StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION); info_value->SetFont(style.info_hint_font()); info_value->SetLines(-1); + info_value->SetScale(scale); info_value->mouse_click.connect(on_mouse_down); - hint_layout->AddView(info_value.GetPointer(), 1, nux::MINOR_POSITION_CENTER); - - InfoHint info_hint_views(info_name, info_value); - info_hints_.push_back(info_hint_views); - - layout->AddLayout(hint_layout, 0); + info_values_layout_->AddView(info_value, 1, nux::MINOR_POSITION_LEFT); } mouse_click.connect(on_mouse_down); - SetLayout(layout); + SetLayout(layout_); } void PreviewInfoHintWidget::PreLayoutManagement() { - previews::Style& style = previews::Style::Instance(); - nux::Geometry const& geo = GetGeometry(); - - int info_hint_width = 0; - for (InfoHint const& info_hint : info_hints_) + if (info_names_layout_ && info_values_layout_) { - int width = style.GetInfoHintNameMinimumWidth(); - if (info_hint.first) - { - width = info_hint.first->GetTextExtents().width; - - if (width < style.GetInfoHintNameMinimumWidth()) - width = style.GetInfoHintNameMinimumWidth(); - else if (width > style.GetInfoHintNameMaximumWidth()) - width = style.GetInfoHintNameMaximumWidth(); - } + nux::Geometry const& geo = GetGeometry(); + info_names_layout_->SetMaximumWidth(info_names_layout_->GetContentWidth()); + int max_width = std::max(0, geo.width - info_names_layout_->GetWidth() - LAYOUT_SPACING.CP(scale) -1); - if (info_hint_width < width) - { - info_hint_width = width; - } + for (auto value : info_values_layout_->GetChildren()) + value->SetMaximumWidth(max_width); } - int info_value_width = geo.width; - info_value_width -= layout_spacing; - info_value_width -= info_hint_width; - info_value_width = MAX(0, info_value_width); + View::PreLayoutManagement(); +} + +void PreviewInfoHintWidget::UpdateScale(double scale) +{ + if (layout_) + layout_->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); - for (InfoHint const& info_hint : info_hints_) + if (info_names_layout_) { - if (info_hint.first) - { - info_hint.first->SetMinimumWidth(info_hint_width); - info_hint.first->SetMaximumWidth(info_hint_width); - } - if (info_hint.second) - { - info_hint.second->SetMaximumWidth(info_value_width); - } + info_names_layout_->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale)); + + for (auto* area : info_names_layout_->GetChildren()) + static_cast(area)->SetScale(scale); } - View::PreLayoutManagement(); + if (info_values_layout_) + { + info_values_layout_->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale)); + + for (auto* area : info_values_layout_->GetChildren()) + static_cast(area)->SetScale(scale); + } + + QueueRelayout(); + QueueDraw(); } } // namespace previews diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewInfoHintWidget.h unity-7.2.3+14.04.20140826/dash/previews/PreviewInfoHintWidget.h --- unity-7.2.2+14.04.20140714/dash/previews/PreviewInfoHintWidget.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewInfoHintWidget.h 2014-08-26 15:48:28.000000000 +0200 @@ -48,12 +48,13 @@ NUX_DECLARE_OBJECT_TYPE(PreviewInfoHintWidget, nux::View); PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size); - virtual ~PreviewInfoHintWidget(); + + nux::Property scale; // From debug::Introspectable std::string GetName() const; void AddProperties(debug::IntrospectionData&); - + void PreLayoutManagement(); sigc::signal request_close() const { return preview_container_.request_close; } @@ -61,7 +62,7 @@ protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - + virtual bool AcceptKeyNavFocus() { return false; } void SetupBackground(); @@ -74,16 +75,16 @@ protected: int icon_size_; + nux::HLayout* layout_; + nux::VLayout* info_names_layout_; + nux::VLayout* info_values_layout_; - typedef nux::ObjectPtr StaticCairoTextPtr; - typedef std::pair InfoHint; - std::list info_hints_; - dash::Preview::Ptr preview_model_; - typedef nux::ObjectPtr BaseTexturePtr; private: PreviewContainer preview_container_; + + void UpdateScale(double scale); }; } // namespace previews diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewNavigator.cpp unity-7.2.3+14.04.20140826/dash/previews/PreviewNavigator.cpp --- unity-7.2.2+14.04.20140714/dash/previews/PreviewNavigator.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewNavigator.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -40,12 +40,16 @@ PreviewNavigator::PreviewNavigator(Orientation direction, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) + , scale(1.0) , direction_(direction) , texture_(nullptr) , visual_state_(VisualState::NORMAL) { SetupViews(); UpdateTexture(); + + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &PreviewNavigator::UpdateScale)); } void PreviewNavigator::SetEnabled(bool enabled) @@ -97,7 +101,7 @@ void PreviewNavigator::SetupViews() { previews::Style& style = dash::previews::Style::Instance(); - + if (direction_ == Orientation::LEFT || direction_ == Orientation::RIGHT) { nux::VLayout* vlayout = new nux::VLayout(); @@ -107,9 +111,9 @@ layout_ = hlayout; if (direction_ == Orientation::LEFT) - texture_ = new IconTexture(Style::Instance().GetNavLeftIcon(), style.GetNavigatorIconSize(), style.GetNavigatorIconSize()); - else - texture_ = new IconTexture(Style::Instance().GetNavRightIcon(), style.GetNavigatorIconSize(), style.GetNavigatorIconSize()); + texture_ = new IconTexture(Style::Instance().GetNavLeftIcon(), style.GetNavigatorIconSize().CP(scale), style.GetNavigatorIconSize().CP(scale)); + else + texture_ = new IconTexture(Style::Instance().GetNavRightIcon(), style.GetNavigatorIconSize().CP(scale), style.GetNavigatorIconSize().CP(scale)); texture_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); vlayout->AddSpace(0,1); @@ -138,7 +142,7 @@ if (texture_) { AddChild(texture_); - layout_->AddView(texture_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); + layout_->AddView(texture_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); texture_->mouse_click.connect([this](int, int, unsigned long, unsigned long) { activated.emit(); }); texture_->mouse_enter.connect(sigc::mem_fun(this, &PreviewNavigator::TexRecvMouseEnter)); @@ -179,6 +183,19 @@ } } +void PreviewNavigator::UpdateScale(double scale) +{ + previews::Style& style = dash::previews::Style::Instance(); + + if (texture_) + { + int icon_size = style.GetNavigatorIconSize().CP(scale); + texture_->SetMinMaxSize(icon_size, icon_size); + } + + QueueRelayout(); + QueueDraw(); +} } // namespace previews } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewNavigator.h unity-7.2.3+14.04.20140826/dash/previews/PreviewNavigator.h --- unity-7.2.2+14.04.20140714/dash/previews/PreviewNavigator.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewNavigator.h 2014-08-26 15:48:28.000000000 +0200 @@ -43,7 +43,7 @@ { NUX_DECLARE_OBJECT_TYPE(PreviewNavigator, nux::View); public: - typedef nux::ObjectPtr Ptr; + typedef nux::ObjectPtr Ptr; PreviewNavigator(Orientation direction, NUX_FILE_LINE_PROTO); void SetEnabled(bool enabled); @@ -53,9 +53,11 @@ void AddProperties(debug::IntrospectionData&); sigc::signal activated; - + virtual bool AcceptKeyNavFocus() { return false; } + nux::Property scale; + private: virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw); @@ -66,6 +68,7 @@ void UpdateTexture(); void SetupViews(); + void UpdateScale(double scale); private: const Orientation direction_; @@ -77,11 +80,12 @@ NORMAL, ACTIVE }; - VisualState visual_state_; + VisualState visual_state_; + }; } // namespace previews } // namespace dash } // namespace unity -#endif // PREVIEWNAVIGATOR_H \ Manca newline alla fine del file +#endif // PREVIEWNAVIGATOR_H diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewRatingsWidget.cpp unity-7.2.3+14.04.20140826/dash/previews/PreviewRatingsWidget.cpp --- unity-7.2.2+14.04.20140714/dash/previews/PreviewRatingsWidget.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewRatingsWidget.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -29,6 +29,7 @@ #include "unity-shared/RatingsButton.h" #include "unity-shared/StaticCairoText.h" #include "unity-shared/PreviewStyle.h" +#include "unity-shared/DashStyle.h" #include "PreviewRatingsWidget.h" namespace unity @@ -38,35 +39,44 @@ namespace previews { +namespace +{ + const RawPixel CHILDREN_SPACE = 3_em; + const int RATINGS_SIZE = 18; + const int RATINGS_GAP = 2; +} + NUX_IMPLEMENT_OBJECT_TYPE(PreviewRatingsWidget); PreviewRatingsWidget::PreviewRatingsWidget(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) + , scale(1.0) { - nux::VLayout* layout = new nux::VLayout(); - layout->SetSpaceBetweenChildren(3); + layout_ = new nux::VLayout(); + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); previews::Style& style = previews::Style::Instance(); auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); }; - ratings_ = new RatingsButton(18,2); + ratings_ = new RatingsButton(RATINGS_SIZE, RATINGS_GAP); ratings_->SetEditable(false); ratings_->mouse_click.connect(on_mouse_down); - layout->AddView(ratings_); - + ratings_->scale = scale(); + layout_->AddView(ratings_); + reviews_ = new StaticCairoText("", NUX_TRACKER_LOCATION); reviews_->SetFont(style.user_rating_font()); + reviews_->SetScale(scale); reviews_->mouse_click.connect(on_mouse_down); - layout->AddView(reviews_); + layout_->AddView(reviews_); mouse_click.connect(on_mouse_down); - SetLayout(layout); -} + SetLayout(layout_); -PreviewRatingsWidget::~PreviewRatingsWidget() -{ + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &PreviewRatingsWidget::UpdateScale)); } void PreviewRatingsWidget::SetRating(float rating) @@ -114,6 +124,17 @@ .add(GetAbsoluteGeometry()); } +void PreviewRatingsWidget::UpdateScale(double scale) +{ + reviews_->SetScale(scale); + ratings_->scale = scale; + preview_container_.scale = scale; + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + + QueueRelayout(); + QueueDraw(); +} + } // namespace previews } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/PreviewRatingsWidget.h unity-7.2.3+14.04.20140826/dash/previews/PreviewRatingsWidget.h --- unity-7.2.2+14.04.20140714/dash/previews/PreviewRatingsWidget.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/PreviewRatingsWidget.h 2014-08-26 15:48:28.000000000 +0200 @@ -45,19 +45,20 @@ NUX_DECLARE_OBJECT_TYPE(PreviewRatingsWidget, nux::View); public: PreviewRatingsWidget(NUX_FILE_LINE_PROTO); - virtual ~PreviewRatingsWidget(); void SetRating(float rating); float GetRating() const; void SetReviews(int count); + nux::Property scale; + sigc::signal request_close() const { return preview_container_.request_close; } protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - + virtual bool AcceptKeyNavFocus() { return false; } // From debug::Introspectable @@ -65,9 +66,13 @@ void AddProperties(debug::IntrospectionData&); private: + void UpdateScale(double scale); + RatingsButton* ratings_; StaticCairoText* reviews_; + nux::VLayout* layout_; + PreviewContainer preview_container_; }; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewComments.cpp unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewComments.cpp --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewComments.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewComments.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -40,20 +40,19 @@ namespace { -const int layout_spacing = 12; +const RawPixel LAYOUT_SPACING = 12_em; +const RawPixel CHILDREN_SPACE = 6_em; } NUX_IMPLEMENT_OBJECT_TYPE(SocialPreviewComments); SocialPreviewComments::SocialPreviewComments(dash::Preview::Ptr preview_model, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) +, scale(1.0) , preview_model_(preview_model) { SetupViews(); -} - -SocialPreviewComments::~SocialPreviewComments() -{ + scale.changed.connect(sigc::hide(sigc::mem_fun(this, &SocialPreviewComments::SetupViews))); } void SocialPreviewComments::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) @@ -85,24 +84,20 @@ nux::Geometry const& geo = GetGeometry(); int comment_width = 0; + int minimum_detail_width = style.GetDetailsPanelMinimumWidth().CP(scale); + for (Comment const& comment : comments_) { - int width = style.GetDetailsPanelMinimumWidth(); - if (comment.first) - { - width = comment.first->GetTextExtents().width; + int width = minimum_detail_width; - if (width < style.GetDetailsPanelMinimumWidth()) - width = style.GetDetailsPanelMinimumWidth(); - } + if (comment.first) + width = std::max(minimum_detail_width, comment.first->GetTextExtents().width); if (comment_width < width) - { comment_width = width; - } } - int comment_value_width = MAX(0, geo.width - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); + int comment_value_width = MAX(0, geo.width - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale)); for (Comment const& comment : comments_) { @@ -122,7 +117,6 @@ { dash::SocialPreview* social_preview_model = dynamic_cast(preview_model_.get()); - RemoveLayout(); comments_.clear(); @@ -131,13 +125,12 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); }; nux::VLayout* layout = new nux::VLayout(); - layout->SetSpaceBetweenChildren(6); + layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); for (dash::SocialPreview::CommentPtr comment : social_preview_model->GetComments()) { - nux::HLayout* name_layout = new nux::HLayout(); - name_layout->SetSpaceBetweenChildren(layout_spacing); + name_layout->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); StaticCairoTextPtr comment_name; if (!comment->display_name.empty()) @@ -145,6 +138,7 @@ comment_name = new StaticCairoText(comment->display_name, true, NUX_TRACKER_LOCATION); comment_name->SetFont(style.info_hint_bold_font()); comment_name->SetLines(-1); + comment_name->SetScale(scale); comment_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); comment_name->mouse_click.connect(on_mouse_down); name_layout->AddView(comment_name.GetPointer(), 0, nux::MINOR_POSITION_START); @@ -156,19 +150,20 @@ comment_time = new StaticCairoText(comment->time, true, NUX_TRACKER_LOCATION); comment_time->SetFont(style.info_hint_font()); comment_time->SetLines(-1); + comment_time->SetScale(scale); comment_time->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); comment_time->mouse_click.connect(on_mouse_down); name_layout->AddView(comment_time.GetPointer(), 0, nux::MINOR_POSITION_START); } - nux::HLayout* comment_layout = new nux::HLayout(); - comment_layout->SetSpaceBetweenChildren(layout_spacing); + comment_layout->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); StaticCairoTextPtr comment_value(new StaticCairoText(comment->content, false, NUX_TRACKER_LOCATION)); comment_value->SetFont(style.info_hint_font()); comment_value->SetLines(-7); + comment_value->SetScale(scale); comment_value->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); comment_value->mouse_click.connect(on_mouse_down); comment_layout->AddView(comment_value.GetPointer(), 1, nux::MINOR_POSITION_START); @@ -182,7 +177,6 @@ mouse_click.connect(on_mouse_down); SetLayout(layout); - } std::string SocialPreviewComments::GetName() const diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewComments.h unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewComments.h --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewComments.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewComments.h 2014-08-26 15:48:28.000000000 +0200 @@ -46,12 +46,11 @@ SocialPreviewComments(dash::Preview::Ptr preview_model, NUX_FILE_LINE_PROTO); - virtual ~SocialPreviewComments(); + nux::Property scale; sigc::signal request_close() const { return preview_container_.request_close; } protected: - typedef nux::ObjectPtr StaticCairoTextPtr; typedef std::pair Comment; std::list comments_; @@ -70,9 +69,6 @@ virtual void AddProperties(debug::IntrospectionData&); private: - - typedef std::unique_ptr NuxCairoPtr; - PreviewContainer preview_container_; }; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewContent.cpp unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewContent.cpp --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewContent.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewContent.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,16 +38,17 @@ namespace { -const int BUBBLE_WIDTH = 300; -const int BUBBLE_HEIGHT = 250; -const int TAIL_HEIGHT = 50; +const RawPixel BUBBLE_WIDTH = 300_em; +const RawPixel BUBBLE_HEIGHT = 250_em; +const RawPixel TAIL_HEIGHT = 50_em; const int TAIL_POS_FROM_RIGHT = 60; +const RawPixel TEXT_LINE_SPACING = 5_em; } -inline nux::Geometry GetBubbleGeometry(nux::Geometry const& geo) +inline nux::Geometry GetBubbleGeometry(nux::Geometry const& geo, double scale) { - int width = MIN(BUBBLE_WIDTH, geo.width); - int height = MIN(BUBBLE_HEIGHT + TAIL_HEIGHT, geo.height); + int width = std::min(BUBBLE_WIDTH.CP(scale), geo.width); + int height = std::min(BUBBLE_HEIGHT.CP(scale) + TAIL_HEIGHT.CP(scale), geo.height); return nux::Geometry(geo.x + (geo.width - width)/2, geo.y + (geo.height - height)/2, width, height); } @@ -56,14 +57,13 @@ SocialPreviewContent::SocialPreviewContent(std::string const& text, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) +, scale(1.0) { SetupViews(); if (text.length() > 0) SetText(text); -} - -SocialPreviewContent::~SocialPreviewContent() -{ + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &SocialPreviewContent::UpdateScale)); } void SocialPreviewContent::SetText(std::string const& text) @@ -94,7 +94,7 @@ nux::ObjectPtr tex = cr_bubble_->GetTexture()->GetDeviceTexture(); - nux::Geometry geo_bubble(GetBubbleGeometry(geo)); + nux::Geometry geo_bubble(GetBubbleGeometry(geo, scale)); gfx_engine.QRP_1Tex(geo_bubble.x, geo_bubble.y, @@ -134,8 +134,9 @@ text_ = new StaticCairoText("", false, NUX_TRACKER_LOCATION); text_->SetLines(-8); + text_->SetScale(scale); text_->SetFont(style.content_font()); - text_->SetLineSpacing(5); + text_->SetLineSpacing(TEXT_LINE_SPACING.CP(scale)); text_->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_MIDDLE); text_->mouse_click.connect(on_mouse_down); @@ -146,17 +147,18 @@ SetLayout(layout); - cr_bubble_.reset(new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &SocialPreviewContent::RedrawBubble), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); + nux::Geometry bubble_geo = GetGeometry(); + cr_bubble_.reset(new nux::CairoWrapper(bubble_geo, sigc::bind(sigc::mem_fun(this, &SocialPreviewContent::RedrawBubble), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); } void SocialPreviewContent::UpdateBaloonTexture() { nux::Geometry const& geo = GetGeometry(); - nux::Geometry geo_cr(GetBubbleGeometry(geo)); + nux::Geometry geo_cr(GetBubbleGeometry(geo, scale)); int max_width = std::max(0, (int)(geo_cr.width - 2*(geo_cr.width*0.1))); - int max_height = std::max(0, (int)((geo_cr.height - TAIL_HEIGHT) - 2*((geo_cr.height - TAIL_HEIGHT)*0.1))); + int max_height = std::max(0, (int)((geo_cr.height - TAIL_HEIGHT.CP(scale)) - 2*((geo_cr.height - TAIL_HEIGHT.CP(scale))*0.1))); // this will update the texture with the actual size of the text. text_->SetMaximumHeight(max_height); @@ -165,7 +167,7 @@ // center text text_->SetBaseX(geo_cr.x + geo_cr.width/2 - geo_text.width/2); - text_->SetBaseY(geo_cr.y + geo_cr.height/2 - geo_text.height/2 - TAIL_HEIGHT/2); + text_->SetBaseY(geo_cr.y + geo_cr.height/2 - geo_text.height/2 - TAIL_HEIGHT.CP(scale)/2); if (geo_cr.width > 0 && geo_cr.height > 0) { @@ -175,8 +177,9 @@ void SocialPreviewContent::RedrawBubble(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state) { - double width = std::max(0, cairo_image_surface_get_width(cairo_get_target(cr))); - double height = std::max(0, cairo_image_surface_get_height(cairo_get_target(cr)) - TAIL_HEIGHT); + auto* surface = cairo_get_target(cr); + double width = std::max(0.0, cairo_image_surface_get_width(surface) / scale()); + double height = std::max(0.0, cairo_image_surface_get_height(surface) / scale() - TAIL_HEIGHT); double tailPosition = width - TAIL_POS_FROM_RIGHT - TAIL_HEIGHT; if (width > 0 && height > 0) @@ -222,11 +225,14 @@ double tailPosition, double tailWidth) { + auto* surface = cairo_get_target(cr); + // sanity check if (cairo_status(cr) != CAIRO_STATUS_SUCCESS && - cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) + cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) return; + cairo_surface_set_device_scale(surface, scale(), scale()); cairo_set_line_width(cr, line_width); bool odd = line_width != double((int)line_width); @@ -314,6 +320,14 @@ introspection.add(GetAbsoluteGeometry()); } +void SocialPreviewContent::UpdateScale(double scale) +{ + if (text_) + text_->SetScale(scale); + + UpdateBaloonTexture(); +} + } } } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewContent.h unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewContent.h --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreviewContent.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreviewContent.h 2014-08-26 15:48:28.000000000 +0200 @@ -46,7 +46,8 @@ NUX_DECLARE_OBJECT_TYPE(SocialPreviewContent, nux::View); SocialPreviewContent(std::string const& text, NUX_FILE_LINE_PROTO); - virtual ~SocialPreviewContent(); + + nux::Property scale; void SetText(std::string const& text); @@ -76,6 +77,8 @@ virtual void AddProperties(debug::IntrospectionData&); private: + void UpdateScale(double scale); + nux::ObjectPtr text_; typedef std::unique_ptr NuxCairoPtr; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/SocialPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/IconTexture.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include #include #include @@ -49,23 +48,29 @@ { DECLARE_LOGGER(logger, "unity.dash.preview.social"); -class DetailsScrollView : public nux::ScrollView +namespace { -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; + const RawPixel CHILDREN_SPACE = 16_em; + const RawPixel ICON_CHILDREN_SPACE = 3_em; + const RawPixel SOCIAL_INFO_CHILDREN_SPACE = 12_em; +} NUX_IMPLEMENT_OBJECT_TYPE(SocialPreview); SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) : Preview(preview_model) +, image_data_layout_(nullptr) +, main_social_info_(nullptr) +, comments_layout_(nullptr) +, social_content_layout_(nullptr) +, social_data_layout_(nullptr) +, social_info_layout_(nullptr) +, social_info_scroll_(nullptr) +, icon_layout_(nullptr) +, actions_layout_(nullptr) { SetupViews(); + UpdateScale(scale); } SocialPreview::~SocialPreview() @@ -122,23 +127,24 @@ auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; - nux::HLayout* image_data_layout = new nux::HLayout(); - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); + image_data_layout_ = new nux::HLayout(); + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); - nux::VLayout* social_content_layout = new nux::VLayout(); - social_content_layout->SetSpaceBetweenChildren(16); - + nux::VLayout* social_content_layout_ = new nux::VLayout(); + social_content_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); if (social_preview_model->description.Get().length() > 0) { content_ = new SocialPreviewContent(social_preview_model->description, NUX_TRACKER_LOCATION); content_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - social_content_layout->AddView(content_.GetPointer(), 1); - } else { + social_content_layout_->AddView(content_.GetPointer(), 1); + } + else + { image_ = new CoverArt(); AddChild(image_.GetPointer()); UpdateCoverArtImage(image_.GetPointer()); - social_content_layout->AddView(image_.GetPointer(), 1); + social_content_layout_->AddView(image_.GetPointer(), 1); } ///////////////////// @@ -146,34 +152,35 @@ ///////////////////// // Social Data Panel full_data_layout_ = new nux::VLayout(); - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); - full_data_layout_->SetSpaceBetweenChildren(16); + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); ///////////////////// // Main Social Info - nux::HLayout* main_social_info = new nux::HLayout(); - main_social_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails()); + main_social_info_ = new nux::HLayout(); + main_social_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); ///////////////////// // Icon Layout - nux::VLayout* icon_layout = new nux::VLayout(); - icon_layout->SetSpaceBetweenChildren(3); - avatar_ = new IconTexture(social_preview_model->avatar.Get().RawPtr() ? g_icon_to_string(social_preview_model->avatar.Get().RawPtr()) : "", MIN(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight())); + icon_layout_ = new nux::VLayout(); + icon_layout_->SetSpaceBetweenChildren(ICON_CHILDREN_SPACE.CP(scale)); + avatar_ = new IconTexture(social_preview_model->avatar() ? g_icon_to_string(social_preview_model->avatar()) : "", MIN(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale))); AddChild(avatar_.GetPointer()); - avatar_->SetMinMaxSize(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight()); + avatar_->SetMinMaxSize(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale)); avatar_->mouse_click.connect(on_mouse_down); - icon_layout->AddView(avatar_.GetPointer(), 0); + icon_layout_->AddView(avatar_.GetPointer(), 0); ///////////////////// ///////////////////// // Data - nux::VLayout* social_data_layout = new nux::VLayout(); - social_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); + social_data_layout_ = new nux::VLayout(); + social_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetLines(-1); + title_->SetScale(scale); title_->SetFont(style.title_font().c_str()); title_->mouse_click.connect(on_mouse_down); @@ -181,109 +188,171 @@ AddChild(subtitle_.GetPointer()); subtitle_->SetFont(style.content_font().c_str()); subtitle_->SetLines(-1); + subtitle_->SetScale(scale); subtitle_->mouse_click.connect(on_mouse_down); - social_data_layout->AddView(title_.GetPointer(), 0); - social_data_layout->AddView(subtitle_.GetPointer(), 0); - social_data_layout->AddSpace(0, 1); + social_data_layout_->AddView(title_.GetPointer(), 0); + social_data_layout_->AddView(subtitle_.GetPointer(), 0); + social_data_layout_->AddSpace(0, 1); // buffer space ///////////////////// - main_social_info->AddLayout(icon_layout, 0); - main_social_info->AddLayout(social_data_layout, 1); + main_social_info_->AddLayout(icon_layout_, 0); + main_social_info_->AddLayout(social_data_layout_, 1); ///////////////////// ///////////////////// // Details - nux::ScrollView* social_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* social_info = new ScrollView(NUX_TRACKER_LOCATION); + social_info_scroll_ = social_info; + social_info->scale = scale(); social_info->EnableHorizontalScrollBar(false); social_info->mouse_click.connect(on_mouse_down); - nux::VLayout* social_info_layout = new nux::VLayout(); - social_info_layout->SetSpaceBetweenChildren(12); - social_info->SetLayout(social_info_layout); + social_info_layout_ = new nux::VLayout(); + social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); + social_info->SetLayout(social_info_layout_); if (!preview_model_->GetInfoHints().empty()) { preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetAvatarAreaWidth()); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - social_info_layout->AddView(preview_info_hints_.GetPointer(), 0); + social_info_layout_->AddView(preview_info_hints_.GetPointer(), 0); } ///////////////////// // Comments/Replies if (!social_preview_model->GetComments().empty()) { - nux::HLayout* comments_layout = new nux::HLayout(); - comments_layout->SetSpaceBetweenChildren(12); + comments_layout_ = new nux::HLayout(); + comments_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); std::string tmp_comments_hint = _("Comments"); tmp_comments_hint += ":"; comments_hint_ = new StaticCairoText(tmp_comments_hint, true, NUX_TRACKER_LOCATION); AddChild(comments_hint_.GetPointer()); comments_hint_->SetLines(-1); + comments_hint_->SetScale(scale); comments_hint_->SetFont(style.info_hint_bold_font().c_str()); comments_hint_->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); comments_hint_->mouse_click.connect(on_mouse_down); - comments_layout->AddView(comments_hint_.GetPointer(), 0, nux::MINOR_POSITION_START); + comments_layout_->AddView(comments_hint_.GetPointer(), 0, nux::MINOR_POSITION_START); comments_ = new SocialPreviewComments(preview_model_, NUX_TRACKER_LOCATION); AddChild(comments_.GetPointer()); comments_->request_close().connect([this]() { preview_container_->request_close.emit(); }); - comments_layout->AddView(comments_.GetPointer()); - social_info_layout->AddView(comments_layout, 0); + comments_layout_->AddView(comments_.GetPointer()); + social_info_layout_->AddView(comments_layout_, 0); } ///////////////////// // Actions action_buttons_.clear(); - nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); /////////////////// - full_data_layout_->AddLayout(main_social_info, 0, nux::MINOR_POSITION_START); + full_data_layout_->AddLayout(main_social_info_, 0, nux::MINOR_POSITION_START); full_data_layout_->AddView(social_info, 1, nux::MINOR_POSITION_START); //full_data_layout_->AddView(comments_.GetPointer(), 1, nux::MINOR_POSITION_START); - full_data_layout_->AddLayout(actions_layout, 0); + full_data_layout_->AddLayout(actions_layout_, 0); ///////////////////// - - image_data_layout->AddView(social_content_layout, 0); - image_data_layout->AddLayout(full_data_layout_, 1); + + image_data_layout_->AddView(social_content_layout_, 0); + image_data_layout_->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); - SetLayout(image_data_layout); + SetLayout(image_data_layout_); } void SocialPreview::PreLayoutManagement() { nux::Geometry geo = GetGeometry(); - previews::Style& style = dash::previews::Style::Instance(); nux::Geometry geo_content(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height); - if (geo.width - geo_content.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth()) - geo_content.width = std::max(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth()); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) + - style.GetDetailsLeftMargin().CP(scale) + - style.GetDetailsRightMargin().CP(scale); + + if (content_width - geo_content.width < style.GetDetailsPanelMinimumWidth().CP(scale)) + geo_content.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); + if (content_) { content_->SetMinMaxSize(geo_content.width, geo_content.height); } if (image_) { image_->SetMinMaxSize(geo_content.width, geo_content.height); } - int details_width = std::max(0, geo.width - geo_content.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); - int top_social_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails()); + int details_width = std::max(0, content_width - geo_content.width); + int top_social_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth().CP(scale) - style.GetSpaceBetweenIconAndDetails().CP(scale)); if (title_) { title_->SetMaximumWidth(top_social_info_max_width); } if (subtitle_) { subtitle_->SetMaximumWidth(top_social_info_max_width); } if (comments_) { comments_->SetMaximumWidth(top_social_info_max_width); } - if (comments_hint_) { comments_hint_->SetMinimumWidth(style.GetInfoHintNameMinimumWidth()); } + if (comments_hint_) { comments_hint_->SetMinimumWidth(style.GetInfoHintNameMinimumWidth().CP(scale)); } + + int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); + int button_h = style.GetActionButtonHeight().CP(scale); for (nux::AbstractButton* button : action_buttons_) + button->SetMinMaxSize(button_w, button_h); + + Preview::PreLayoutManagement(); +} + +void SocialPreview::UpdateScale(double scale) +{ + Preview::UpdateScale(scale); + + if (preview_info_hints_) + preview_info_hints_->scale = scale; + + previews::Style& style = dash::previews::Style::Instance(); + + if (avatar_) { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight()); + avatar_->SetMinMaxSize(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale)); + avatar_->SetSize(MIN(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale))); + avatar_->ReLoadIcon(); } - Preview::PreLayoutManagement(); + if (image_data_layout_) + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); + + if (social_content_layout_) + social_content_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + + if (main_social_info_) + main_social_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); + + if (icon_layout_) + icon_layout_->SetSpaceBetweenChildren(ICON_CHILDREN_SPACE.CP(scale)); + + if (social_data_layout_) + social_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); + + if (social_info_layout_) + social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); + + if (social_info_scroll_) + social_info_scroll_->scale = scale; + + if (actions_layout_) + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); + + if (content_) + content_->scale = scale; + + if (comments_) + comments_->scale = scale; + + if (comments_layout_) + comments_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); + + if (comments_hint_) + comments_hint_->SetScale(scale); } } // namespace previews diff -Nru unity-7.2.2+14.04.20140714/dash/previews/SocialPreview.h unity-7.2.3+14.04.20140826/dash/previews/SocialPreview.h --- unity-7.2.2+14.04.20140714/dash/previews/SocialPreview.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/SocialPreview.h 2014-08-26 15:48:28.000000000 +0200 @@ -24,6 +24,7 @@ #define SOCIALPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -56,11 +57,22 @@ virtual void PreLayoutManagement(); virtual void SetupViews(); + virtual void UpdateScale(double scale) override; protected: nux::VLayout* sender_layout_; nux::VLayout* title_layout_; + nux::HLayout* image_data_layout_; + nux::HLayout* main_social_info_; + nux::HLayout* comments_layout_; + nux::VLayout* social_content_layout_; + nux::VLayout* social_data_layout_; + nux::VLayout* social_info_layout_; + ScrollView* social_info_scroll_; + nux::VLayout* icon_layout_; + nux::Layout* actions_layout_; + nux::ObjectPtr avatar_; nux::ObjectPtr content_; nux::ObjectPtr comments_; diff -Nru unity-7.2.2+14.04.20140714/dash/previews/StandaloneApplicationPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/StandaloneApplicationPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/StandaloneApplicationPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/StandaloneApplicationPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -39,12 +39,14 @@ #include "PreviewContainer.h" -#define WIDTH 972 -#define HEIGHT 452 +const unity::RawPixel WIDTH(1000); +const unity::RawPixel HEIGHT(600); using namespace unity; using namespace unity::dash; +static double scale = 1.0; + class DummyView : public nux::View { public: @@ -146,6 +148,7 @@ container_->navigate_right.connect(sigc::mem_fun(this, &TestRunner::NavRight)); container_->navigate_left.connect(sigc::mem_fun(this, &TestRunner::NavLeft)); container_->request_close.connect([this]() { exit(0); }); + container_->scale = scale; DummyView* dummyView = new DummyView(container_.GetPointer()); layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); @@ -162,9 +165,9 @@ description << "Application description " << i << std::endl; // creates a generic preview object - glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL)); - glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL)); + glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-music.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); + glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-people.svg", NULL)); GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal)); g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99")); @@ -207,9 +210,10 @@ The service allows users to communicate with peers by voice, video, and instant messaging over the Internet. Phone calls may be placed to recipients on the traditional telephone networks. Calls to other users within the Skype service are free of charge, while calls to landline telephones and mobile phones are charged via a debit-based user account system."; // creates a generic preview object - glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL)); - glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL)); + glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-music.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); + glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-people.svg", NULL)); + glib::Object iconHint4(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-people.svg", NULL)); GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal)); g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99")); @@ -233,6 +237,9 @@ unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh")); unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("d", 12.1)); + if (nav_iter % 2 == 0) + unity_protocol_preview_add_info_hint(proto_obj, "desc", "Very long long description", iconHint4, g_variant_new("s", "So looong description that does not fit into")); + glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef()); @@ -255,9 +262,9 @@ The service allows users to communicate with peers by voice, video, and instant messaging over the Internet. Phone calls may be placed to recipients on the traditional telephone networks. Calls to other users within the Skype service are free of charge, while calls to landline telephones and mobile phones are charged via a debit-based user account system."; // creates a generic preview object - glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL)); - glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL)); + glib::Object iconHint1(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-music.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); + glib::Object iconHint3(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-people.svg", NULL)); GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal)); g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99")); @@ -313,10 +320,22 @@ unity::dash::previews::Style panel_style; unity::dash::Style dash_style; unity::ThumbnailGenerator thumbnail_generator; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 's', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Unity Preview"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), - WIDTH, HEIGHT, + WIDTH.CP(scale), HEIGHT.CP(scale), 0, &TestRunner::InitWindowThread, test_runner); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/StandaloneErrorPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/StandaloneErrorPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/StandaloneErrorPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/StandaloneErrorPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -39,13 +39,14 @@ #include "Preview.h" #include "PreviewContainer.h" - -#define WIDTH 1100 -#define HEIGHT 600 +const unity::RawPixel WIDTH(1100); +const unity::RawPixel HEIGHT(600); using namespace unity; using namespace unity::dash; +static double scale = 1.0; + namespace { nux::logging::Logger logger("unity.dash.StandaloneMusicPreview"); @@ -150,6 +151,7 @@ container_ = new previews::PreviewContainer(NUX_TRACKER_LOCATION); container_->request_close.connect([this]() { exit(0); }); container_->DisableNavButton(previews::Navigation::BOTH); + container_->scale = scale; DummyView* dummyView = new DummyView(container_.GetPointer()); layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); @@ -206,10 +208,22 @@ unity::dash::previews::Style panel_style; unity::dash::Style dash_style; unity::ThumbnailGenerator thumbnail_generator; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 's', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Unity Preview"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), - WIDTH, HEIGHT, + WIDTH.CP(scale), HEIGHT.CP(scale), 0, &TestRunner::InitWindowThread, test_runner); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/StandaloneMoviePreview.cpp unity-7.2.3+14.04.20140826/dash/previews/StandaloneMoviePreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/StandaloneMoviePreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/StandaloneMoviePreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -39,12 +39,14 @@ #include "PreviewContainer.h" -#define WIDTH 972 -#define HEIGHT 452 +const unity::RawPixel WIDTH(1000); +const unity::RawPixel HEIGHT(600); using namespace unity; using namespace unity::dash; +static double scale = 1.0; + class DummyView : public nux::View { public: @@ -145,6 +147,7 @@ container_->navigate_right.connect(sigc::mem_fun(this, &TestRunner::NavRight)); container_->navigate_left.connect(sigc::mem_fun(this, &TestRunner::NavLeft)); container_->request_close.connect([this]() { exit(0); }); + container_->scale = scale; DummyView* dummyView = new DummyView(container_.GetPointer()); layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); @@ -234,10 +237,22 @@ unity::dash::previews::Style panel_style; unity::dash::Style dash_style; unity::ThumbnailGenerator thumbnail_generator; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 's', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Unity Preview"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), - WIDTH, HEIGHT, + WIDTH.CP(scale), HEIGHT.CP(scale), 0, &TestRunner::InitWindowThread, test_runner); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/StandaloneMusicPaymentPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/StandaloneMusicPaymentPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/StandaloneMusicPaymentPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/StandaloneMusicPaymentPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,15 +38,15 @@ #include "Preview.h" #include "PreviewContainer.h" - -#define WIDTH 1100 -#define HEIGHT 600 +const unity::RawPixel WIDTH(1100); +const unity::RawPixel HEIGHT(600); using namespace unity; using namespace unity::dash; namespace { +static double scale = 1.0; nux::logging::Logger logger("unity.dash.StandaloneMusicPreview"); } @@ -190,6 +190,7 @@ dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); container_->Preview(preview_model, previews::Navigation::LEFT); + container_->scale = scale; } void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) @@ -211,10 +212,22 @@ unity::dash::previews::Style panel_style; unity::dash::Style dash_style; unity::ThumbnailGenerator thumbnail_generator; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 's', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Unity Preview"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), - WIDTH, HEIGHT, + WIDTH.CP(scale), HEIGHT.CP(scale), 0, &TestRunner::InitWindowThread, test_runner); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/StandaloneSocialPreview.cpp unity-7.2.3+14.04.20140826/dash/previews/StandaloneSocialPreview.cpp --- unity-7.2.2+14.04.20140714/dash/previews/StandaloneSocialPreview.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/StandaloneSocialPreview.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,9 +38,10 @@ #include "Preview.h" #include "PreviewContainer.h" +const unity::RawPixel WIDTH(1000); +const unity::RawPixel HEIGHT(600); -#define WIDTH 910 -#define HEIGHT 400 +static double scale = 1.0; using namespace unity; using namespace unity::dash; @@ -146,6 +147,7 @@ container_->navigate_right.connect(sigc::mem_fun(this, &TestRunner::NavRight)); container_->navigate_left.connect(sigc::mem_fun(this, &TestRunner::NavLeft)); container_->request_close.connect([this]() { exit(0); }); + container_->scale = scale; DummyView* dummyView = new DummyView(container_.GetPointer()); layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); @@ -157,7 +159,8 @@ const char* description = "Lorem ipsum dolor sit amet, id eruditi referrentur cum, et est enim persequeris. Munere docendi intellegebat pro id, nam no delenit facilisis similique, ut usu eros aliquando. Electram postulant accusamus ut ius, cum ad impedit facilis mediocrem. At cum tamquam."; glib::Object iconHint1(g_icon_new_for_string("/usr/share/pixmaps/faces/sunflower.jpg", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/6/lens-nav-home.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); + glib::Object iconHint3(g_icon_new_for_string("/usr/share/icons/unity-icon-theme/places/svg/service-twitter.svg", NULL)); glib::Object proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_social_preview_new())); @@ -169,7 +172,7 @@ unity_protocol_preview_set_subtitle(proto_obj, subtitle); unity_protocol_preview_set_description(proto_obj, description); unity_protocol_preview_add_action(proto_obj, "view", "View", iconHint2, 0); - unity_protocol_preview_add_action(proto_obj, "retweet", "Retweet", nullptr, 0); + unity_protocol_preview_add_action(proto_obj, "retweet", "Retweet", iconHint3, 0); unity_protocol_social_preview_add_comment(UNITY_PROTOCOL_SOCIAL_PREVIEW(proto_obj.RawPtr()), "comment", "Stacy", "Lorem ipsum dolor sit amet, id eruditi referrentur cum, et est enim persequeris. Munere docendi intellegebat pro id, nam no delenit facilisis similique, ut usu eros aliquando. Electram postulant accusamus ut ius, cum ad impedit facilis mediocrem. At cum tamquam.", "13 minutes ago"); unity_protocol_social_preview_add_comment(UNITY_PROTOCOL_SOCIAL_PREVIEW(proto_obj.RawPtr()), "comment", "Jeremy", "This is a comment", "4 hours ago"); unity_protocol_social_preview_add_comment(UNITY_PROTOCOL_SOCIAL_PREVIEW(proto_obj.RawPtr()), "comment", "Stacy", "This is a comment", "4 hours ago"); @@ -180,7 +183,6 @@ dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); container_->Preview(preview_model, previews::Navigation::RIGHT); - } void TestRunner::NavRight() @@ -191,7 +193,7 @@ // creates a generic preview object glib::Object iconHint1(g_icon_new_for_string("/usr/share/pixmaps/faces/astronaut.jpg", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/6/lens-nav-home.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); glib::Object proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_social_preview_new())); @@ -226,7 +228,7 @@ const char* description = "Profile pictures are what people want them to think they look like. Tagged pictures are what they really look like."; glib::Object iconHint1(g_icon_new_for_string("/usr/share/pixmaps/faces/soccerball.png", NULL)); - glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/6/lens-nav-home.svg", NULL)); + glib::Object iconHint2(g_icon_new_for_string("/usr/share/unity/icons/lens-nav-home.svg", NULL)); glib::Object proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_social_preview_new())); @@ -269,10 +271,22 @@ unity::dash::previews::Style panel_style; unity::dash::Style dash_style; unity::ThumbnailGenerator thumbnail_generator; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 's', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Unity Preview"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), - WIDTH, HEIGHT, + WIDTH.CP(scale), HEIGHT.CP(scale), 0, &TestRunner::InitWindowThread, test_runner); diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Track.cpp unity-7.2.3+14.04.20140826/dash/previews/Track.cpp --- unity-7.2.2+14.04.20140714/dash/previews/Track.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Track.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -37,6 +37,13 @@ namespace previews { +DECLARE_LOGGER(logger, "unity.dash.preview.music.track"); +namespace +{ +const RawPixel LAYOUT_SPACING = 6_em; +const RawPixel TITLE_PADDING = 3_em; +} + class TmpView : public nux::View { public: @@ -49,17 +56,11 @@ if (GetCompositionLayout()) GetCompositionLayout()->ProcessDraw(gfx_engine, force_draw); } - + virtual bool AcceptKeyNavFocus() { return false; } }; -DECLARE_LOGGER(logger, "unity.dash.preview.music.track"); -namespace -{ -const int layout_spacing = 6; -} - NUX_IMPLEMENT_OBJECT_TYPE(Track); class TrackProgressLayer : public nux::AbstractPaintLayer @@ -126,12 +127,14 @@ Track::Track(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) + , scale(1.0) , play_state_(PlayerState::STOPPED) , progress_(0.0) , mouse_over_(false) { SetupBackground(); SetupViews(); + scale.changed.connect(sigc::mem_fun(this, &Track::UpdateScale)); } std::string Track::GetName() const @@ -202,23 +205,25 @@ layout->SetLeftAndRightPadding(0,0); nux::BaseTexture* tex_play = style.GetPlayIcon(); - IconTexture* status_play = new IconTexture(tex_play, style.GetStatusIconSize(), style.GetStatusIconSize()); - status_play->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); + status_play_ = new IconTexture(tex_play, style.GetStatusIconSize().CP(scale), style.GetStatusIconSize().CP(scale)); + status_play_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); nux::BaseTexture* tex_pause = style.GetPauseIcon(); - IconTexture* status_pause = new IconTexture(tex_pause, style.GetStatusIconSize(), style.GetStatusIconSize()); - status_pause->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); + status_pause_ = new IconTexture(tex_pause, style.GetStatusIconSize().CP(scale), style.GetStatusIconSize().CP(scale)); + status_pause_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); track_number_ = new StaticCairoText("", NUX_TRACKER_LOCATION); track_number_->SetTextAlignment(StaticCairoText::NUX_ALIGN_CENTRE); track_number_->SetTextVerticalAlignment(StaticCairoText::NUX_ALIGN_CENTRE); track_number_->SetLines(-1); + track_number_->SetScale(scale); track_number_->SetFont(style.track_font()); title_ = new StaticCairoText("", NUX_TRACKER_LOCATION); title_->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); title_->SetTextVerticalAlignment(StaticCairoText::NUX_ALIGN_CENTRE); title_->SetLines(-1); + title_->SetScale(scale); title_->SetFont(style.track_font()); duration_ = new StaticCairoText("", NUX_TRACKER_LOCATION); @@ -226,21 +231,22 @@ duration_->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); duration_->SetTextVerticalAlignment(StaticCairoText::NUX_ALIGN_CENTRE); duration_->SetLines(-1); + duration_->SetMinimumWidth(style.GetMusicDurationWidth().CP(scale)); + duration_->SetMaximumWidth(style.GetMusicDurationWidth().CP(scale)); + duration_->SetScale(scale); duration_->SetFont(style.track_font()); - duration_->SetMaximumWidth(style.GetMusicDurationWidth()); - duration_->SetMaximumWidth(style.GetMusicDurationWidth()); // Layouts // stick text fields in a layout so they don't alter thier geometry. status_play_layout_ = new TmpView(); status_play_layout_->SetLayout(new nux::HLayout()); status_play_layout_->GetLayout()->AddSpace(0, 1); - status_play_layout_->GetLayout()->AddView(status_play, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); + status_play_layout_->GetLayout()->AddView(status_play_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); status_play_layout_->GetLayout()->AddSpace(0, 1); status_pause_layout_ = new TmpView(); status_pause_layout_->SetLayout(new nux::HLayout()); status_pause_layout_->GetLayout()->AddSpace(0, 1); - status_pause_layout_->GetLayout()->AddView(status_pause, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); + status_pause_layout_->GetLayout()->AddView(status_pause_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); status_pause_layout_->GetLayout()->AddSpace(0, 1); track_number_layout_ = new TmpView(); @@ -256,7 +262,7 @@ track_status_layout_->SetActiveLayer(track_number_layout_); title_layout_ = new nux::HLayout(); - title_layout_->SetLeftAndRightPadding(3); + title_layout_->SetLeftAndRightPadding(TITLE_PADDING.CP(scale)); title_layout_->AddView(title_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); title_layout_->AddSpace(0, 0); @@ -316,7 +322,7 @@ progress_layer_->SetGeometry(geo_progress); nux::GetPainter().RenderSinglePaintLayer(gfx_engine, progress_layer_->GetGeometry(), progress_layer_.get()); } - + gfx_engine.GetRenderStates().SetBlend(alpha, src, dest); } @@ -435,12 +441,29 @@ track_status_layout_->SetMinimumWidth(geo.height); track_status_layout_->SetMaximumWidth(geo.height); - const int max_width = std::max(GetGeometry().width - geo.height - style.GetMusicDurationWidth() - layout_spacing*2, 0); + const int max_width = std::max(GetGeometry().width - geo.height - style.GetMusicDurationWidth().CP(scale) - LAYOUT_SPACING.CP(scale)*2, 0); title_->SetMaximumWidth(max_width); View::PreLayoutManagement(); } +void Track::UpdateScale(double scale) +{ + auto& style = Style::Instance(); + int icon_size = style.GetStatusIconSize().CP(scale); + track_number_->SetScale(scale); + title_->SetScale(scale); + duration_->SetMaximumWidth(style.GetMusicDurationWidth().CP(scale)); + duration_->SetMinimumWidth(style.GetMusicDurationWidth().CP(scale)); + duration_->SetScale(scale); + title_layout_->SetLeftAndRightPadding(TITLE_PADDING.CP(scale)); + status_play_->SetMinMaxSize(icon_size, icon_size); + status_pause_->SetMinMaxSize(icon_size, icon_size); + + QueueRelayout(); + QueueDraw(); +} + } // namespace previews } // namespace dash } // namesapce unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Track.h unity-7.2.3+14.04.20140826/dash/previews/Track.h --- unity-7.2.2+14.04.20140714/dash/previews/Track.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Track.h 2014-08-26 15:48:28.000000000 +0200 @@ -55,18 +55,20 @@ void Update(dash::Track const& track_row); + nux::Property scale; + protected: virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw); virtual void PreLayoutManagement(); virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type); - + // From debug::Introspectable std::string GetName() const; void AddProperties(debug::IntrospectionData&); - + virtual bool AcceptKeyNavFocus() { return false; } - + void SetupBackground(); void SetupViews(); @@ -97,9 +99,14 @@ nux::View* status_pause_layout_; nux::View* track_number_layout_; nux::LayeredLayout* track_status_layout_; + IconTexture* status_play_; + IconTexture* status_pause_; bool mouse_over_; connection::Wrapper player_connection_; + +private: + void UpdateScale(double scale); }; } diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Tracks.cpp unity-7.2.3+14.04.20140826/dash/previews/Tracks.cpp --- unity-7.2.2+14.04.20140714/dash/previews/Tracks.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Tracks.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -24,7 +24,6 @@ #include #include #include "unity-shared/IntrospectableWrappers.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include "unity-shared/PreviewStyle.h" #include @@ -34,7 +33,12 @@ { namespace previews { + +namespace +{ DECLARE_LOGGER(logger, "unity.dash.preview.music.tracks"); +const RawPixel CHILDREN_SPACE = 1_em; +} NUX_IMPLEMENT_OBJECT_TYPE(Tracks); @@ -54,6 +58,9 @@ for (std::size_t i = 0; i < tracks_->count.Get(); ++i) OnTrackAdded(tracks_->RowAtIndex(i)); } + + UpdateScale(scale); + scale.changed.connect(sigc::mem_fun(this, &Tracks::UpdateScale)); } std::string Tracks::GetName() const @@ -69,11 +76,10 @@ void Tracks::SetupViews() { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); EnableHorizontalScrollBar(false); layout_ = new nux::VLayout(); - layout_->SetPadding(0, previews::Style::Instance().GetDetailsRightMargin(), 0, 0); - layout_->SetSpaceBetweenChildren(1); + layout_->SetPadding(0, previews::Style::Instance().GetDetailsRightMargin().CP(scale), 0, 0); + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); SetLayout(layout_); } @@ -84,6 +90,7 @@ return; pos->second->Update(track_row); + pos->second->scale = scale(); } void Tracks::OnTrackAdded(dash::Track const& track_row) @@ -100,8 +107,9 @@ AddChild(track_view.GetPointer()); track_view->Update(track_row); - track_view->SetMinimumHeight(style.GetTrackHeight()); - track_view->SetMaximumHeight(style.GetTrackHeight()); + track_view->SetMinimumHeight(style.GetTrackHeight().CP(scale)); + track_view->SetMaximumHeight(style.GetTrackHeight().CP(scale)); + track_view->scale = scale(); layout_->AddView(track_view.GetPointer(), 0); m_tracks[track_uri] = track_view; @@ -111,7 +119,7 @@ void Tracks::OnTrackRemoved(dash::Track const& track_row) { LOG_TRACE(logger) << "OnTrackRemoved for " << track_row.title.Get(); - + auto pos = m_tracks.find(track_row.uri.Get()); if (pos == m_tracks.end()) return; @@ -121,6 +129,27 @@ ComputeContentSize(); } +void Tracks::UpdateScale(double scale) +{ + int track_height = Style::Instance().GetTrackHeight().CP(scale); + + for (auto const& track : m_tracks) + { + track.second->SetMinimumHeight(track_height); + track.second->SetMaximumHeight(track_height); + track.second->scale = scale; + } + + if (layout_) + { + layout_->SetPadding(0, Style::Instance().GetDetailsRightMargin().CP(scale), 0, 0); + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); + } + + QueueRelayout(); + QueueDraw(); +} + } // namespace previews } // namespace dash } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/dash/previews/Tracks.h unity-7.2.3+14.04.20140826/dash/previews/Tracks.h --- unity-7.2.2+14.04.20140714/dash/previews/Tracks.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/previews/Tracks.h 2014-08-26 15:48:28.000000000 +0200 @@ -27,6 +27,7 @@ #include #include #include +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/Introspectable.h" #include "Track.h" @@ -44,7 +45,7 @@ namespace previews { -class Tracks : public debug::Introspectable, public nux::ScrollView +class Tracks : public debug::Introspectable, public dash::ScrollView { public: typedef nux::ObjectPtr Ptr; @@ -71,6 +72,9 @@ nux::VLayout* layout_; std::map m_tracks; connection::Manager sig_conn_; + +private: + void UpdateScale(double scale); }; } diff -Nru unity-7.2.2+14.04.20140714/dash/ResultRendererHorizontalTile.cpp unity-7.2.3+14.04.20140826/dash/ResultRendererHorizontalTile.cpp --- unity-7.2.2+14.04.20140714/dash/ResultRendererHorizontalTile.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ResultRendererHorizontalTile.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -247,8 +247,8 @@ 0.0f, 0.0f, CARD_VIEW_HIGHLIGHT_CORNER_RADIUS, - width, - height, + width/scale(), + height/scale(), false); cairo_fill(cr); diff -Nru unity-7.2.2+14.04.20140714/dash/ResultRendererTile.cpp unity-7.2.3+14.04.20140826/dash/ResultRendererTile.cpp --- unity-7.2.2+14.04.20140714/dash/ResultRendererTile.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ResultRendererTile.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -31,7 +31,6 @@ #include "unity-shared/CairoTexture.h" #include "unity-shared/DashStyle.h" #include "unity-shared/TextureCache.h" -#include "unity-shared/RawPixel.h" #include "unity-shared/UnitySettings.h" namespace unity @@ -120,13 +119,7 @@ return; dash::Style const& style = dash::Style::Instance(); - RawPixel const tile_size = style.GetTileImageSize(); - RawPixel const tile_width = style.GetTileWidth(); - RawPixel const tile_height = style.GetTileHeight(); - RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth(); - RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight(); - - int tile_icon_size = tile_size.CP(scale()); + int tile_icon_size = style.GetTileImageSize().CP(scale); // set up our texture mode nux::TexCoordXForm texxform; @@ -148,8 +141,8 @@ // render highlight if its needed if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL) { - int highlight_x = (geometry.x + geometry.width/2) - tile_highlight_width.CP(scale())/2; - int highlight_y = (geometry.y + PADDING.CP(scale()) + tile_icon_size / 2) - tile_highlight_height.CP(scale())/2; + int highlight_x = (geometry.x + geometry.width/2) - style.GetTileIconHightlightWidth().CP(scale)/2; + int highlight_y = (geometry.y + PADDING.CP(scale) + tile_icon_size / 2) - style.GetTileIconHightlightHeight().CP(scale)/2; RenderTexture(GfxContext, highlight_x, @@ -179,10 +172,10 @@ if (container->text) { RenderTexture(GfxContext, - geometry.x + PADDING.CP(scale()), - geometry.y + tile_icon_size + SPACING.CP(scale()), - tile_width.CP(scale()) - (PADDING.CP(scale()) * 2), - tile_height.CP(scale()) - tile_icon_size - SPACING.CP(scale()), + geometry.x + PADDING.CP(scale), + geometry.y + tile_icon_size + SPACING.CP(scale), + style.GetTileWidth().CP(scale) - (PADDING.CP(scale) * 2), + style.GetTileHeight().CP(scale) - tile_icon_size - SPACING.CP(scale), container->text->GetDeviceTexture(), texxform, color, @@ -273,10 +266,8 @@ void ResultRendererTile::LoadIcon(Result const& row) { Style const& style = Style::Instance(); - RawPixel const tile_size = style.GetTileImageSize(); - RawPixel const tile_gsize = style.GetTileGIconSize(); - RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth(); - RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight(); + int tile_size = style.GetTileImageSize().CP(scale); + int tile_gsize = style.GetTileGIconSize().CP(scale); std::string const& icon_hint = row.icon_hint; std::string const& icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON; @@ -288,8 +279,8 @@ { TextureCache& cache = TextureCache::GetDefault(); BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", - tile_highlight_width.CP(scale()), - tile_highlight_height.CP(scale()), + style.GetTileIconHightlightWidth().CP(scale), + style.GetTileIconHightlightHeight().CP(scale), sigc::mem_fun(this, &ResultRendererTile::DrawHighlight))); container->prelight = texture_prelight; } @@ -300,13 +291,13 @@ { bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON); container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, - tile_size.CP(scale()), + tile_size, use_large_icon ? - tile_size.CP(scale()) : tile_gsize.CP(scale()), slot); + tile_size : tile_gsize, slot); } else { - container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize.CP(scale()), slot); + container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize, slot); } } @@ -333,15 +324,12 @@ } else { - Style const& style = Style::Instance(); - RawPixel const tile_size = style.GetTileImageSize(); - // slow path for non square icons that must be resized to fit in the square // texture float aspect = static_cast(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 if (aspect < 1.0f) { - pixbuf_width = tile_size.CP(scale()); + pixbuf_width = Style::Instance().GetTileImageSize().CP(scale); pixbuf_height = pixbuf_width * aspect; if (pixbuf_height > height) @@ -470,13 +458,10 @@ void ResultRendererTile::LoadText(Result const& row) { Style const& style = Style::Instance(); - RawPixel const tile_size = style.GetTileImageSize(); - RawPixel const tile_width = style.GetTileWidth(); - RawPixel const tile_height = style.GetTileHeight(); nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32, - tile_width.CP(scale()) - (PADDING.CP(scale()) * 2), - tile_height.CP(scale()) - tile_size.CP(scale()) - SPACING.CP(scale())); + style.GetTileWidth().CP(scale()) - (PADDING.CP(scale()) * 2), + style.GetTileHeight().CP(scale()) - style.GetTileImageSize().CP(scale()) - SPACING.CP(scale())); cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale()); cairo_t* cr = _cairoGraphics.GetInternalContext(); @@ -499,7 +484,7 @@ pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START); - pango_layout_set_width(layout, (tile_width - (PADDING * 2))* PANGO_SCALE); + pango_layout_set_width(layout, (style.GetTileWidth() - (PADDING * 2))* PANGO_SCALE); pango_layout_set_height(layout, -2); // FIXME bug #1239381 diff -Nru unity-7.2.2+14.04.20140714/dash/ScopeBar.cpp unity-7.2.3+14.04.20140826/dash/ScopeBar.cpp --- unity-7.2.2+14.04.20140714/dash/ScopeBar.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ScopeBar.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -27,7 +27,6 @@ #include "unity-shared/StaticCairoText.h" #include "unity-shared/CairoTexture.h" #include "unity-shared/GraphicsUtils.h" -#include "unity-shared/RawPixel.h" #include "unity-shared/UBusMessages.h" namespace unity @@ -71,6 +70,9 @@ for (auto icon : icons_) icon->scale = scale; + + QueueDraw(); + QueueRelayout(); } void ScopeBar::SetupLayout() diff -Nru unity-7.2.2+14.04.20140714/dash/ScopeBarIcon.cpp unity-7.2.3+14.04.20140826/dash/ScopeBarIcon.cpp --- unity-7.2.2+14.04.20140714/dash/ScopeBarIcon.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ScopeBarIcon.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -17,7 +17,6 @@ */ #include "unity-shared/DashStyle.h" -#include "unity-shared/RawPixel.h" #include "ScopeBarIcon.h" #include "config.h" diff -Nru unity-7.2.2+14.04.20140714/dash/ScopeView.cpp unity-7.2.3+14.04.20140826/dash/ScopeView.cpp --- unity-7.2.2+14.04.20140714/dash/ScopeView.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ScopeView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -29,9 +29,8 @@ #include "ResultRendererHorizontalTile.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UBusWrapper.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/GraphicsUtils.h" -#include "unity-shared/RawPixel.h" #include "config.h" #include @@ -52,16 +51,14 @@ } // This is so we can access some protected members in scrollview. -class ScopeScrollView: public nux::ScrollView +class ScopeScrollView: public dash::ScrollView { public: - ScopeScrollView(nux::VScrollBar* scroll_bar, NUX_FILE_LINE_DECL) - : nux::ScrollView(NUX_FILE_LINE_PARAM) + ScopeScrollView(NUX_FILE_LINE_DECL) + : ScrollView(NUX_FILE_LINE_PARAM) , right_area_(nullptr) , up_area_(nullptr) { - SetVScrollBar(scroll_bar); - OnVisibleChanged.connect([this] (nux::Area* /*area*/, bool visible) { if (m_horizontal_scrollbar_enable) _hscrollbar->SetVisible(visible); @@ -237,8 +234,8 @@ { layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - scroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), - NUX_TRACKER_LOCATION); + scroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); + scroll_view_->scale = scale(); scroll_view_->EnableVerticalScrollBar(true); scroll_view_->EnableHorizontalScrollBar(false); layout_->AddView(scroll_view_); @@ -250,9 +247,11 @@ no_results_ = new StaticCairoText("", NUX_TRACKER_LOCATION); no_results_->SetTextColor(nux::color::White); no_results_->SetVisible(false); + no_results_->SetScale(scale); scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); - fscroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), NUX_TRACKER_LOCATION); + fscroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); + fscroll_view_->scale = scale(); fscroll_view_->EnableVerticalScrollBar(true); fscroll_view_->EnableHorizontalScrollBar(false); fscroll_view_->SetVisible(false); @@ -276,19 +275,17 @@ { dash::Style const& style = dash::Style::Instance(); - RawPixel const scope_filter_space = style.GetSpaceBetweenScopeAndFilters(); - RawPixel const right_padding = style.GetFilterViewRightPadding(); - RawPixel const filter_width = style.GetFilterBarWidth() + - style.GetFilterBarLeftPadding() + - style.GetFilterBarRightPadding(); - - double scale = this->scale(); - layout_->SetSpaceBetweenChildren(scope_filter_space.CP(scale)); - - fscroll_view_->SetMinimumWidth(filter_width.CP(scale) + right_padding.CP(scale)); - fscroll_view_->SetMaximumWidth(filter_width.CP(scale) + right_padding.CP(scale)); - filter_bar_->SetMinimumWidth(filter_width.CP(scale)); - filter_bar_->SetMaximumWidth(filter_width.CP(scale)); + int right_padding = style.GetFilterViewRightPadding().CP(scale); + int filter_width = style.GetFilterBarWidth().CP(scale) + + style.GetFilterBarLeftPadding().CP(scale) + + style.GetFilterBarRightPadding().CP(scale); + + layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenScopeAndFilters().CP(scale)); + + fscroll_view_->SetMinimumWidth(filter_width + right_padding); + fscroll_view_->SetMaximumWidth(filter_width + right_padding); + filter_bar_->SetMinimumWidth(filter_width); + filter_bar_->SetMaximumWidth(filter_width); } void ScopeView::UpdateScale(double scale) @@ -298,7 +295,10 @@ for (auto& group : category_views_) group->scale = scale; + scroll_view_->scale = scale; + fscroll_view_->scale = scale; filter_bar_->scale = scale; + no_results_->SetScale(scale); } void ScopeView::SetupCategories(Categories::Ptr const& categories) diff -Nru unity-7.2.2+14.04.20140714/dash/ScopeView.h unity-7.2.3+14.04.20140826/dash/ScopeView.h --- unity-7.2.2+14.04.20140714/dash/ScopeView.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/ScopeView.h 2014-08-26 15:48:28.000000000 +0200 @@ -36,7 +36,6 @@ #include "PlacesGroup.h" #include "ResultViewGrid.h" #include "unity-shared/UBusWrapper.h" -#include "unity-shared/PlacesVScrollBar.h" namespace unity { diff -Nru unity-7.2.2+14.04.20140714/dash/StandaloneDash.cpp unity-7.2.3+14.04.20140826/dash/StandaloneDash.cpp --- unity-7.2.2+14.04.20140714/dash/StandaloneDash.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/dash/StandaloneDash.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -36,47 +36,50 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/PanelStyle.h" #include "unity-shared/ThumbnailGenerator.h" -#include "UnityCore/GSettingsScopes.h" +#include "unity-shared/UBusMessages.h" +#include "unity-shared/UBusServer.h" +#include +#include -#define WIDTH 1024 -#define HEIGHT 768 +const unity::RawPixel WIDTH(1024); +const unity::RawPixel HEIGHT(768); using namespace unity::dash; class TestRunner { public: - TestRunner (); - ~TestRunner (); + TestRunner(std::string const& scope, double scale) + : scope_(scope) + , scale_(scale) + {} static void InitWindowThread (nux::NThread* thread, void* InitData); void Init (); + std::string scope_; + double scale_; nux::Layout *layout; }; -TestRunner::TestRunner () -{ -} - -TestRunner::~TestRunner () -{ -} - void TestRunner::Init () { layout = new nux::HLayout(NUX_TRACKER_LOCATION); - DashView* view = new DashView(std::make_shared(), + DashView* view = new DashView(std::make_shared(), std::make_shared()); + view->scale = scale_; view->DisableBlur(); - view->SetMinMaxSize(WIDTH, HEIGHT); + view->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_)); layout->AddView (view, 1, nux::MINOR_POSITION_CENTER); - layout->SetMinMaxSize(WIDTH, HEIGHT); + layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_)); view->AboutToShow(0); nux::GetWindowThread()->SetLayout (layout); nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus()); + + unity::UBusServer().SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, + g_variant_new("(sus)", scope_.c_str(), GOTO_DASH_URI, "")); } void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) @@ -87,8 +90,6 @@ int main(int argc, char **argv) { - nux::WindowThread* wt = NULL; - gtk_init (&argc, &argv); unity::BGHash bghash; @@ -102,17 +103,30 @@ unity::dash::Style dash_style; unity::panel::Style panel_style; - TestRunner *test_runner = new TestRunner (); - wt = nux::CreateGUIThread(TEXT("Unity Dash"), - WIDTH, HEIGHT, - 0, - &TestRunner::InitWindowThread, - test_runner); + double scale = 1.0; + unity::glib::String scope; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scope", 's', 0, G_OPTION_ARG_STRING, &scope, "The default scope ", "S" }, + { "scaling-factor", 'f', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Standalone Dash"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; + + TestRunner *test_runner = new TestRunner(scope.Str(), scale); + std::unique_ptr wt(nux::CreateGUIThread(TEXT("Unity Dash"), + WIDTH.CP(scale), HEIGHT.CP(scale), + 0, &TestRunner::InitWindowThread, test_runner)); nux::NuxTimerTickSource tick_source; nux::animation::AnimationController animation_controller(tick_source); + wt->Run(nullptr); - wt->Run (NULL); - delete wt; - return 0; + return EXIT_SUCCESS; } diff -Nru unity-7.2.2+14.04.20140714/debian/changelog unity-7.2.3+14.04.20140826/debian/changelog --- unity-7.2.2+14.04.20140714/debian/changelog 2014-09-22 17:00:29.000000000 +0200 +++ unity-7.2.3+14.04.20140826/debian/changelog 2014-09-22 17:00:30.000000000 +0200 @@ -1,3 +1,112 @@ +unity (7.2.3+14.04.20140826-0ubuntu1) trusty; urgency=medium + + [ Andrea Azzarone ] + * Remove cross fade effect during lock/unlocking. A simple fading + works just fine. (LP: #1312107) + * Manually emit nux::Area::geometry_changed beucase nux can fail to + emit it. (LP: #1292391) + + [ Pawel Szubert ] + * Reduce the scope of the kill command when restarting Compiz. + (LP: #1324114) + + [ Marco Trevisan (Treviño) ] + * LockScreenAcceleratorController: do ther configured action on power + special keys press. We finally can suspend, shutdown, hibernate or + start the screensaver when the screen is locked, using the Suspend, + Sleep, Hibernate and PowerOff hardware keys. Also the Shutdown + dialog doesn't allow now to lock the session if it is not allowed by + settings. (LP: #1306211) (LP: #1320051) (LP: #1320071) + * Previews: scale the dash preview contents to match current monitor + scaling. Improved also the scaling of search-bar, spinner, categories + and many other components. (LP: #1339629) + * FilterWidgets: add support for scaling (LP: #1340171) + * OverlayRendering: correctly scale the overlays borders and edges to + match settings. DashStyle has been modified to return smart pointers + of textures that are loaded depending on the scale level. The cache + will make sure that we don't duplicate the textures and that they + get removed when not needed anymore. Also thanks to this the + SearchBarSpinner textures (and the other spinners as well) uses the + SVGs scaled at the proper size (I desgined a new SVG for the + magnifier, as we only had a PNG). (LP: #1283415) (LP: #1340394) + * Hud: scale to match current DPI settings for monitor. (LP: #1340477) + + [ Eleni Maria Stea ] + * Previews: scale the dash preview contents to match current monitor + scaling. Improved also the scaling of search-bar, spinner, categories + and many other components. (LP: #1339629) + + [ Stephen M. Webb ] + * Reduce the scope of the kill command when restarting Compiz. + (LP: #1324114) + + [ Chris Townsend ] + * Bump version to 7.2.3. + + -- Ubuntu daily release Tue, 26 Aug 2014 13:49:00 +0000 + +unity (7.2.2+14.04.20140714-0ubuntu2) trusty; urgency=medium + + [ Andrea Azzarone ] + * Remove cross fade effect during lock/unlocking. A simple fading + works just fine. (LP: #1312107) + * Manually emit nux::Area::geometry_changed beucase nux can fail to + emit it. (LP: #1292391) + * TextInput: use GdkKeymap to check the caps-lock status (LP: #1347735) + + [ Pawel Szubert ] + * Reduce the scope of the kill command when restarting Compiz. + (LP: #1324114) + + [ Marco Trevisan (Treviño) ] + * LockScreenAcceleratorController: do ther configured action on power + special keys press. We finally can suspend, shutdown, hibernate or + start the screensaver when the screen is locked, using the Suspend, + Sleep, Hibernate and PowerOff hardware keys. Also the Shutdown + dialog doesn't allow now to lock the session if it is not allowed by + settings. (LP: #1306211) (LP: #1320051) (LP: #1320071) + * Previews: scale the dash preview contents to match current monitor + scaling. Improved also the scaling of search-bar, spinner, categories + and many other components. (LP: #1339629) + * FilterWidgets: add support for scaling (LP: #1340171) + * OverlayRendering: correctly scale the overlays borders and edges to + match settings. DashStyle has been modified to return smart pointers + of textures that are loaded depending on the scale level. The cache + will make sure that we don't duplicate the textures and that they + get removed when not needed anymore. Also thanks to this the + SearchBarSpinner textures (and the other spinners as well) uses the + SVGs scaled at the proper size (I desgined a new SVG for the + magnifier, as we only had a PNG). (LP: #1283415) (LP: #1340394) + * Hud: scale to match current DPI settings for monitor. (LP: #1340477) + * PlacesOverlayVScrollBar and VScrollBarOverlayWindow: add support for + scaling. Add a new ScrollView class to create ScrollViews with an + OverlayScrollbar and with scaling support. Using them in dash Scopes and + Previews. (LP: #1340996) + * LockScreenShield: Add GrabScreen function and retry to make sure we really + get the grab. It might happen that the grab is not possible because the + PluginAdapter::IsScreenGrabbed request has still not being fully processed, + and thus nux is not able to grab the pointer/keyboard. By doing this we + instead try to grab the screen, and if this is not happening, we wait a + little until we don't get the ungrab event. In this way, if we eventually + get the grab, all will work as expected. Otherwise, we cancel the lock + request (very unlikely to happen). (LP: #1349128) + * PlacesOverlayVScrollBar: redirect the mouse wheel scroll events coming from + the thumb to the scrollview. This will make the scrollview to handle then and + perform the same scrolling action it would do otherwise. (LP: #1340992) + * SwitcherView, PanelService: correctly handle horizontal and vertical scroll + events (LP: #1342208) (LP: #1342731) + + [ Eleni Maria Stea ] + * Previews: scale the dash preview contents to match current monitor + scaling. Improved also the scaling of search-bar, spinner, categories + and many other components. (LP: #1339629) + + [ Stephen M. Webb ] + * Reduce the scope of the kill command when restarting Compiz. + (LP: #1324114) + + -- Chris Townsend Wed, 23 Jul 2014 11:49:11 -0400 + unity (7.2.2+14.04.20140714-0ubuntu1.1) trusty-security; urgency=medium * SECURITY UPDATE: more screen locking fixes (LP: #1349128) @@ -2080,7 +2189,6 @@ unity (7.0.0daily13.05.08ubuntu.unity.next-0ubuntu1) raring; urgency=low * Automatic snapshot from revision 3317 (ubuntu-unity/next) - unity (7.0.0daily13.05.01.1ubuntu.unity.next-0ubuntu1) raring; urgency=low [ Sebastien Bacher ] diff -Nru unity-7.2.2+14.04.20140714/debian/patches/lp1349128.patch unity-7.2.3+14.04.20140826/debian/patches/lp1349128.patch --- unity-7.2.2+14.04.20140714/debian/patches/lp1349128.patch 2014-09-22 17:00:29.000000000 +0200 +++ unity-7.2.3+14.04.20140826/debian/patches/lp1349128.patch 1970-01-01 01:00:00.000000000 +0100 @@ -1,164 +0,0 @@ -Description: fix more screen locking issues -Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3845 -Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3846 -Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3847 -Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1349128 - -Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp -=================================================================== ---- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenController.cpp 2014-07-14 10:30:31.000000000 -0400 -+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp 2014-07-30 15:13:14.677682810 -0400 -@@ -45,9 +45,9 @@ - bool AcceptKeyNavFocus() override { return true; } - bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; }; - }; --} - - DECLARE_LOGGER(logger, "unity.lockscreen"); -+} - - Controller::Controller(DBusManager::Ptr const& dbus_manager, - session::Manager::Ptr const& session_manager, -Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp -=================================================================== ---- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenShield.cpp 2014-07-14 10:30:31.000000000 -0400 -+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp 2014-07-30 15:13:17.505682826 -0400 -@@ -19,6 +19,7 @@ - - #include "LockScreenShield.h" - -+#include - #include - #include - #include -@@ -35,6 +36,10 @@ - { - namespace lockscreen - { -+namespace -+{ -+DECLARE_LOGGER(logger, "unity.lockscreen.shield"); -+} - - Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, Accelerators::Ptr const& accelerators, int monitor_num, bool is_primary) - : AbstractShield(session_manager, indicators, accelerators, monitor_num, is_primary) -@@ -56,12 +61,7 @@ - }); - - primary.changed.connect([this] (bool is_primary) { -- if (!is_primary) -- { -- UnGrabPointer(); -- UnGrabKeyboard(); -- } -- -+ regrab_conn_->disconnect(); - is_primary ? ShowPrimaryView() : ShowSecondaryView(); - if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary); - QueueRelayout(); -@@ -86,17 +86,41 @@ - } - } - --void Shield::ShowPrimaryView() -+void Shield::GrabScreen(bool cancel_on_failure) - { -- GrabPointer(); -- GrabKeyboard(); -+ auto& wc = nux::GetWindowCompositor(); -+ -+ if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this)) -+ { -+ regrab_conn_->disconnect(); -+ regrab_timeout_.reset(); -+ } -+ else -+ { -+ auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false); -+ regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb); - -+ if (cancel_on_failure) -+ { -+ regrab_timeout_.reset(new glib::Timeout(50, [this] { -+ LOG_ERROR(logger) << "Impossible to get the grab to lock the screen"; -+ session_manager_->unlock_requested.emit(); -+ return false; -+ })); -+ } -+ } -+} -+ -+void Shield::ShowPrimaryView() -+{ - if (primary_layout_) - { -+ GrabScreen(false); - SetLayout(primary_layout_.GetPointer()); - return; - } - -+ GrabScreen(true); - nux::Layout* main_layout = new nux::VLayout(); - primary_layout_ = main_layout; - SetLayout(primary_layout_.GetPointer()); -@@ -149,19 +173,7 @@ - } - else - { -- auto& wc = nux::GetWindowCompositor(); -- -- if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this)) -- { -- regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] { -- if (primary()) -- { -- GrabPointer(); -- GrabKeyboard(); -- } -- regrab_conn_->disconnect(); -- }); -- } -+ GrabScreen(false); - } - } - }); -Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h -=================================================================== ---- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenShield.h 2014-07-14 10:30:31.000000000 -0400 -+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h 2014-07-30 15:13:14.677682810 -0400 -@@ -21,6 +21,7 @@ - #define UNITY_LOCKSCREEN_SHIELD_H - - #include -+#include - #include "LockScreenAbstractShield.h" - - namespace unity -@@ -48,6 +49,7 @@ - - private: - void UpdateBackgroundTexture(); -+ void GrabScreen(bool cancel_on_failure); - void ShowPrimaryView(); - void ShowSecondaryView(); - Panel* CreatePanel(); -@@ -59,6 +61,7 @@ - nux::ObjectPtr cof_layout_; - connection::Wrapper panel_active_conn_; - connection::Wrapper regrab_conn_; -+ glib::Source::UniquePtr regrab_timeout_; - UserPromptView* prompt_view_; - Panel* panel_view_; - }; -Index: unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp -=================================================================== ---- unity-7.2.2+14.04.20140714.orig/unity-shared/PluginAdapter.cpp 2014-07-14 10:30:31.000000000 -0400 -+++ unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp 2014-07-30 15:13:11.953682795 -0400 -@@ -1254,6 +1254,7 @@ - if (ret == GrabSuccess) - { - XUngrabKeyboard(dpy, CurrentTime); -+ XFlush(dpy); - - if (CompWindow* w = m_Screen->findWindow(m_Screen->activeWindow())) - w->moveInputFocusTo(); diff -Nru unity-7.2.2+14.04.20140714/debian/patches/series unity-7.2.3+14.04.20140826/debian/patches/series --- unity-7.2.2+14.04.20140714/debian/patches/series 2014-09-22 17:00:29.000000000 +0200 +++ unity-7.2.3+14.04.20140826/debian/patches/series 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -lp1349128.patch diff -Nru unity-7.2.2+14.04.20140714/hud/HudAbstractView.h unity-7.2.3+14.04.20140826/hud/HudAbstractView.h --- unity-7.2.2+14.04.20140714/hud/HudAbstractView.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudAbstractView.h 2014-08-26 15:48:28.000000000 +0200 @@ -40,6 +40,9 @@ typedef nux::ObjectPtr Ptr; AbstractView(); + ~AbstractView() = default; + + nux::Property scale; virtual void AboutToShow() = 0; virtual void AboutToHide() = 0; diff -Nru unity-7.2.2+14.04.20140714/hud/HudButton.cpp unity-7.2.3+14.04.20140826/hud/HudButton.cpp --- unity-7.2.2+14.04.20140714/hud/HudButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,28 +38,32 @@ #include "HudButton.h" #include "HudPrivate.h" -DECLARE_LOGGER(logger, "unity.hud.button"); -namespace -{ -const int hlayout_left_padding = 46; -const char* const button_font = "Ubuntu 13"; // 17px = 13 -} - namespace unity { namespace hud { +namespace +{ +DECLARE_LOGGER(logger, "unity.hud.button"); +const RawPixel HLAYOUT_LEFT_PADDING = 46_em; +const RawPixel HEIGHT = 42_em; +const char* const button_font = "Ubuntu 13"; // 17px = 13 +} + NUX_IMPLEMENT_OBJECT_TYPE(HudButton); HudButton::HudButton(NUX_FILE_LINE_DECL) : nux::Button(NUX_FILE_LINE_PARAM) + , label([this] { return query_ ? query_->formatted_text : ""; }) , is_rounded(false) + , fake_focused(false) + , scale(1.0) , is_focused_(false) , skip_draw_(true) { hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1); + hlayout_->SetLeftAndRightPadding(HLAYOUT_LEFT_PADDING.CP(scale), 0); SetLayout(hlayout_); InitTheme(); @@ -89,6 +93,12 @@ { fake_focused = false; }); + + scale.changed.connect([this] (double scale) { + hlayout_->SetLeftAndRightPadding(HLAYOUT_LEFT_PADDING.CP(scale), 0); + InitTheme(); + SetQuery(query_); + }); } void HudButton::InitTheme() @@ -101,23 +111,20 @@ normal_->Invalidate(geo); }); - SetMinimumHeight(42); + SetMinimumHeight(HEIGHT.CP(scale)); + SetMaximumHeight(HEIGHT.CP(scale)); - if (!active_) - { - nux::Geometry const& geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); - prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); - active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); - normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); - } + prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); + active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); + normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); } void HudButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state) { - dash::Style::Instance().SquareButton(cr, faked_state, "", - is_rounded, 17, - dash::Alignment::LEFT, true); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); + dash::Style::Instance().SquareButton(cr, faked_state, "", is_rounded, 17, dash::Alignment::LEFT, true); } bool HudButton::AcceptKeyNavFocus() @@ -207,17 +214,23 @@ } } -void HudButton::SetQuery(Query::Ptr query) +void HudButton::SetQuery(Query::Ptr const& query) { query_ = query; - label = query->formatted_text; - auto items(impl::RefactorText(label)); + if (!query_) + { + hlayout_->Clear(); + return; + } + + auto items(impl::RefactorText(query_->formatted_text)); hlayout_->Clear(); for (auto item : items) { StaticCairoText* text = new StaticCairoText(item.first); + text->SetScale(scale); text->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, item.second ? 1.0f : 0.5f)); text->SetFont(button_font); text->SetInputEventSensitivity(false); @@ -225,7 +238,7 @@ } } -Query::Ptr HudButton::GetQuery() +Query::Ptr const& HudButton::GetQuery() const { return query_; } @@ -235,7 +248,6 @@ skip_draw_ = skip_draw; } - // Introspectable std::string HudButton::GetName() const { diff -Nru unity-7.2.2+14.04.20140714/hud/HudButton.h unity-7.2.3+14.04.20140826/hud/HudButton.h --- unity-7.2.2+14.04.20140714/hud/HudButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -36,7 +36,7 @@ namespace hud { -class HudButton : public nux::Button, public unity::debug::Introspectable +class HudButton : public nux::Button, public unity::debug::Introspectable { NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button); @@ -45,14 +45,15 @@ HudButton(NUX_FILE_LINE_PROTO); - void SetQuery(Query::Ptr query); - std::shared_ptr GetQuery(); + void SetQuery(Query::Ptr const&); + Query::Ptr const& GetQuery() const; void SetSkipDraw(bool skip_draw); - nux::Property label; + nux::ROProperty label; nux::Property is_rounded; nux::Property fake_focused; + nux::Property scale; protected: virtual bool AcceptKeyNavFocus(); diff -Nru unity-7.2.2+14.04.20140714/hud/HudController.cpp unity-7.2.3+14.04.20140826/hud/HudController.cpp --- unity-7.2.2+14.04.20140714/hud/HudController.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudController.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -107,6 +107,8 @@ hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished)); timeline_animator_.updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); + Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &Controller::OnDPIChanged)); + EnsureHud(); } @@ -140,6 +142,7 @@ { LOG_DEBUG(logger) << "SetupHudView called"; view_ = create_view_(); + view_->scale = Settings::Instance().em(monitor_index_)->DPIScale(); layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); layout_->AddView(view_, 1, nux::MINOR_POSITION_START); @@ -206,7 +209,11 @@ int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_index_); if (view_) - view_->SetIcon(icon_name, tile_size, icon_size, launcher_width - tile_size); + { + double scale = view_->scale(); + int tsize = tile_size().CP(scale); + view_->SetIcon(icon_name, tsize, icon_size().CP(scale), launcher_width - tsize); + } ubus.SendMessage(UBUS_HUD_ICON_CHANGED, g_variant_new_string(icon_name.c_str())); } @@ -344,6 +351,7 @@ { Relayout(); monitor_index_ = ideal_monitor; + view_->scale = Settings::Instance().em(monitor_index_)->DPIScale(); } view_->ShowEmbeddedIcon(!IsLockedToLauncher(monitor_index_)); @@ -508,6 +516,12 @@ view_->SearchFinished(); } +void Controller::OnDPIChanged() +{ + if (view_) + view_->scale = Settings::Instance().em(monitor_index_)->DPIScale(); +} + // Introspectable std::string Controller::GetName() const { diff -Nru unity-7.2.2+14.04.20140714/hud/HudController.h unity-7.2.3+14.04.20140826/hud/HudController.h --- unity-7.2.2+14.04.20140714/hud/HudController.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudController.h 2014-08-26 15:48:28.000000000 +0200 @@ -32,6 +32,7 @@ #include #include "unity-shared/UBusWrapper.h" +#include "unity-shared/RawPixel.h" #include "unity-shared/ResizingBaseWindow.h" #include "HudView.h" @@ -53,8 +54,8 @@ nux::ObjectPtr HudView() const; nux::BaseWindow* window() const; - nux::Property icon_size; - nux::Property tile_size; + nux::Property icon_size; + nux::Property tile_size; nux::Property launcher_locked_out; nux::Property multiple_launchers; @@ -88,6 +89,7 @@ void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); void OnScreenUngrabbed(); + void OnDPIChanged(); void OnExternalShowHud(GVariant* variant); void OnExternalHideHud(GVariant* variant); void OnActivateRequest(GVariant* variant); diff -Nru unity-7.2.2+14.04.20140714/hud/HudIcon.cpp unity-7.2.3+14.04.20140826/hud/HudIcon.cpp --- unity-7.2.2+14.04.20140714/hud/HudIcon.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudIcon.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -45,8 +45,7 @@ IconTexture::SetByIconName(icon_name, icon_size); icon_renderer_.SetTargetSize(tile_size, icon_size, 0); - SetMinimumHeight(tile_size + padding); - SetMinimumWidth(tile_size + padding); + SetMinMaxSize(tile_size + padding, tile_size + padding); } void Icon::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) diff -Nru unity-7.2.2+14.04.20140714/hud/HudView.cpp unity-7.2.3+14.04.20140826/hud/HudView.cpp --- unity-7.2.2+14.04.20140714/hud/HudView.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -31,6 +31,7 @@ #include "unity-shared/Introspectable.h" #include "unity-shared/UBusMessages.h" +#include "unity-shared/UnitySettings.h" #include "unity-shared/DashStyle.h" #include "unity-shared/WindowManager.h" @@ -41,18 +42,17 @@ DECLARE_LOGGER(logger, "unity.hud.view"); namespace { -const int grow_anim_length = 90 * 1000; -const int pause_before_grow_length = 32 * 1000; - -const int default_width = 960; -const int default_height = 276; -const int content_width = 939; - -const int top_padding = 11; -const int bottom_padding = 10; -const int left_padding = 11; -const int right_padding = 0; +const int GROW_ANIM_LENGTH = 90 * 1000; +const int PAUSE_BEFORE_GROW_LENGTH = 32 * 1000; +const RawPixel DEFAULT_WIDTH = 960_em; +const RawPixel DEFAULT_HEIGHT = 276_em; +const RawPixel CONTENT_WIDTH = 939_em; + +const RawPixel TOP_PADDING = 11_em; +const RawPixel BOTTOM_PADDING = 10_em; +const RawPixel LEFT_PADDING = 11_em; +const RawPixel RIGHT_PADDING = 0_em; } NUX_IMPLEMENT_OBJECT_TYPE(View); @@ -70,6 +70,8 @@ , keyboard_stole_focus_(false) , overlay_window_buttons_(new OverlayWindowButtons()) { + scale = Settings::Instance().em()->DPIScale(); + renderer_.scale = scale(); renderer_.SetOwner(this); renderer_.need_redraw.connect([this] () { QueueDraw(); @@ -120,14 +122,11 @@ }); mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); + scale.changed.connect(sigc::mem_fun(this, &View::UpdateScale)); QueueDraw(); } -View::~View() -{ -} - void View::SetMonitorOffset(int x, int y) { renderer_.x_offset = x; @@ -140,9 +139,9 @@ int target_height = content_layout_->GetGeometry().height; // only animate if we are after our defined pause time - if (diff > pause_before_grow_length) + if (diff > PAUSE_BEFORE_GROW_LENGTH) { - float progress = (diff - pause_before_grow_length) / grow_anim_length; + float progress = (diff - PAUSE_BEFORE_GROW_LENGTH) / GROW_ANIM_LENGTH; int last_height = last_known_height_; int new_height = 0; @@ -167,7 +166,7 @@ button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_)); } - if (diff > grow_anim_length + pause_before_grow_length) + if (diff > GROW_ANIM_LENGTH + PAUSE_BEFORE_GROW_LENGTH) { // ensure we are at our final location and update last known height current_height_ = target_height; @@ -232,9 +231,10 @@ HudButton::Ptr button(new HudButton()); buttons_.push_front(button); + button->scale = scale(); button->SetInputEventSensitivity(false); - button->SetMinimumWidth(content_width); - button->SetMaximumWidth(content_width); + button->SetMinimumWidth(CONTENT_WIDTH.CP(scale)); + button->SetMaximumWidth(CONTENT_WIDTH.CP(scale)); button->SetQuery(query); button_views_->AddView(button.GetPointer(), 0, nux::MINOR_POSITION_START); @@ -292,7 +292,7 @@ icon_->SetIcon(icon_name, size, tile_size, padding); /* We need to compute this value manually, since the _content_layout height changes */ - int content_height = search_bar_->GetBaseHeight() + top_padding + bottom_padding; + int content_height = search_bar_->GetBaseHeight() + TOP_PADDING.CP(scale) + BOTTOM_PADDING.CP(scale); icon_->SetMinimumHeight(std::max(icon_->GetMinimumHeight(), content_height)); QueueDraw(); @@ -327,10 +327,8 @@ // look tight nux::Geometry View::GetBestFitGeometry(nux::Geometry const& for_geo) { - //FIXME - remove magic values, replace with scalable text depending on DPI - // requires smarter font settings really... - int width = default_width; - int height = default_height; + int width = DEFAULT_WIDTH.CP(scale); + int height = DEFAULT_HEIGHT.CP(scale); if (show_embedded_icon_) width += icon_->GetGeometry().width; @@ -367,8 +365,6 @@ void View::SetupViews() { - dash::Style& style = dash::Style::Instance(); - nux::VLayout* super_layout = new nux::VLayout(); layout_ = new nux::HLayout(); { @@ -383,20 +379,20 @@ content_layout_ = new nux::VLayout(); { // Set the layout paddings - content_layout_->SetLeftAndRightPadding(left_padding, right_padding); - content_layout_->SetTopAndBottomPadding(top_padding, bottom_padding); + content_layout_->SetLeftAndRightPadding(LEFT_PADDING.CP(scale), RIGHT_PADDING.CP(scale)); + content_layout_->SetTopAndBottomPadding(TOP_PADDING.CP(scale), BOTTOM_PADDING.CP(scale)); // add the search bar to the composite search_bar_ = new unity::SearchBar(true); - search_bar_->SetMinimumHeight(style.GetSearchBarHeight()); - search_bar_->SetMaximumHeight(style.GetSearchBarHeight()); + search_bar_->scale = scale(); search_bar_->search_hint = _("Type your command"); search_bar_->live_search_reached.connect(sigc::mem_fun(this, &View::OnSearchChanged)); AddChild(search_bar_.GetPointer()); content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_START); button_views_ = new nux::VLayout(); - button_views_->SetMaximumWidth(content_width); + button_views_->SetMinimumWidth(CONTENT_WIDTH.CP(scale)); + button_views_->SetMaximumWidth(CONTENT_WIDTH.CP(scale)); content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_START); } @@ -491,11 +487,11 @@ if (!buttons_.empty()) // See bug #1008603. { - int height = 3; - int x = search_bar_->GetBaseX() + 1; + int height = (3_em).CP(scale); + int x = search_bar_->GetBaseX() + (1_em).CP(scale); int y = search_bar_->GetBaseY() + search_bar_->GetBaseHeight() - height; nux::GetPainter().Draw2DLine(gfx_context, x, y, x, y + height, nux::color::White * 0.13); - x += content_width - 1; + x += CONTENT_WIDTH.CP(scale) - (1_em).CP(scale); nux::GetPainter().Draw2DLine(gfx_context, x, y, x, y + height, nux::color::White * 0.13); } @@ -791,6 +787,26 @@ return geo; } +void View::UpdateScale(double scale) +{ + content_layout_->SetLeftAndRightPadding(LEFT_PADDING.CP(scale), RIGHT_PADDING.CP(scale)); + content_layout_->SetTopAndBottomPadding(TOP_PADDING.CP(scale), BOTTOM_PADDING.CP(scale)); + + button_views_->SetMinimumWidth(CONTENT_WIDTH.CP(scale)); + button_views_->SetMaximumWidth(CONTENT_WIDTH.CP(scale)); + + for (auto const& button : buttons_) + { + button->SetMinimumWidth(CONTENT_WIDTH.CP(scale)); + button->SetMaximumWidth(CONTENT_WIDTH.CP(scale)); + button->scale = scale; + } + + renderer_.scale = scale; + search_bar_->scale = scale; + UpdateLayoutGeometry(); + QueueDraw(); +} } } diff -Nru unity-7.2.2+14.04.20140714/hud/HudView.h unity-7.2.3+14.04.20140826/hud/HudView.h --- unity-7.2.2+14.04.20140714/hud/HudView.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/HudView.h 2014-08-26 15:48:28.000000000 +0200 @@ -46,7 +46,6 @@ typedef nux::ObjectPtr Ptr; View(); - ~View(); void ResetToDefault(); @@ -62,7 +61,7 @@ void AboutToHide(); void SetMonitorOffset(int x, int y); - + nux::Geometry GetContentGeometry(); protected: @@ -86,6 +85,7 @@ nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo); void UpdateLayoutGeometry(); + void UpdateScale(double); void ProcessGrowShrink(); diff -Nru unity-7.2.2+14.04.20140714/hud/StandaloneHud.cpp unity-7.2.3+14.04.20140826/hud/StandaloneHud.cpp --- unity-7.2.2+14.04.20140714/hud/StandaloneHud.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/hud/StandaloneHud.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -30,10 +30,15 @@ #include "HudView.h" #include "unity-shared/DashStyle.h" #include "unity-shared/UnitySettings.h" +#include "unity-shared/PanelStyle.h" #include DECLARE_LOGGER(logger, "unity.tests.hud"); +using namespace unity; + +static double scale = 1.0; + class TestRunner { public: @@ -44,7 +49,6 @@ void Init (); nux::Layout *layout; unity::hud::View* hud_view_; - unity::Settings dash_settings_; private: unity::hud::Hud hud_service_; @@ -64,7 +68,8 @@ LOG_WARNING(logger) << "test init"; layout = new nux::VLayout(); - hud_view_ = new unity::hud::View(); + hud_view_ = new hud::View(); + hud_view_->scale = scale; layout->AddView (hud_view_, 1, nux::MINOR_POSITION_START); nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus()); @@ -84,15 +89,15 @@ break; } } - + hud_view_->SetIcon(icon_name, 42, 52, 0); }); hud_view_->query_activated.connect([this] (unity::hud::Query::Ptr query) { hud_service_.ExecuteQuery(query, 0); - }); - + }); + hud_view_->query_selected.connect([this] (unity::hud::Query::Ptr query) { hud_view_->SetIcon(query->icon_name, 42, 52, 0); }); @@ -135,22 +140,33 @@ gtk_init (&argc, &argv); nux::NuxInitialize(0); - + // Slightly higher as we're more likely to test things we know will fail nux::logging::configure_logging("unity.hud=debug"); - + nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); LOG_DEBUG(logger) << "starting the standalone hud"; // The instances for the pseudo-singletons. unity::Settings settings; - unity::dash::Style dash_style; + panel::Style panel_style; + dash::Style dash_style; + unity::glib::Error err; + + GOptionEntry args_parsed[] = + { + { "scaling-factor", 'f', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" }, + { NULL } + }; + + std::shared_ptr ctx(g_option_context_new("Standalone Hud"), g_option_context_free); + g_option_context_add_main_entries(ctx.get(), args_parsed, NULL); + if (!g_option_context_parse(ctx.get(), &argc, &argv, &err)) + std::cerr << "Got error when parsing arguments: " << err << std::endl; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Hud Prototype Test"), - 1200, 768, - 0, - &TestRunner::InitWindowThread, - test_runner); + (1200_em).CP(scale), (768_em).CP(scale), 0, + &TestRunner::InitWindowThread, test_runner); st = nux::CreateSystemThread (NULL, ControlThread, wt); diff -Nru unity-7.2.2+14.04.20140714/launcher/Launcher.cpp unity-7.2.3+14.04.20140826/launcher/Launcher.cpp --- unity-7.2.2+14.04.20140714/launcher/Launcher.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/launcher/Launcher.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -2200,7 +2200,7 @@ return; bool alt_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_ALT); - if (alt_pressed) + if (alt_pressed && abs(wheel_delta) != NUX_MOUSEWHEEL_DELTA) { ScrollLauncher(wheel_delta); } diff -Nru unity-7.2.2+14.04.20140714/launcher/SwitcherView.cpp unity-7.2.3+14.04.20140826/launcher/SwitcherView.cpp --- unity-7.2.2+14.04.20140714/launcher/SwitcherView.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/launcher/SwitcherView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -49,6 +49,7 @@ unsigned int const ANIMATION_LENGTH = 250; unsigned int const MAX_DIRECTIONS_CHANGED = 3; + unsigned int const SCROLL_WHEEL_EVENTS_DISTANCE = 75; double const TEXT_TILE_MULTIPLIER = 3.5; } @@ -69,6 +70,7 @@ , animation_(animation_length) , last_icon_selected_(-1) , last_detail_icon_selected_(-1) + , last_mouse_scroll_time_(0) , check_mouse_first_time_(true) { icon_renderer_->pip_style = OVER_TILE; @@ -435,6 +437,13 @@ void SwitcherView::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigned long /*button_flags*/, unsigned long /*key_flags*/) { + auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; + + if (timestamp - last_mouse_scroll_time_ <= SCROLL_WHEEL_EVENTS_DISTANCE) + return; + + last_mouse_scroll_time_ = timestamp; + if (model_->detail_selection) { HandleDetailMouseWheel(wheel_delta); @@ -447,7 +456,7 @@ void SwitcherView::HandleDetailMouseWheel(int wheel_delta) { - if (wheel_delta > 0) + if (wheel_delta < 0) { model_->NextDetail(); } @@ -459,7 +468,7 @@ void SwitcherView::HandleMouseWheel(int wheel_delta) { - if (wheel_delta > 0) + if (wheel_delta < 0) { model_->Next(); } diff -Nru unity-7.2.2+14.04.20140714/launcher/SwitcherView.h unity-7.2.3+14.04.20140826/launcher/SwitcherView.h --- unity-7.2.2+14.04.20140714/launcher/SwitcherView.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/launcher/SwitcherView.h 2014-08-26 15:48:28.000000000 +0200 @@ -157,6 +157,7 @@ int last_icon_selected_; int last_detail_icon_selected_; + uint64_t last_mouse_scroll_time_; bool check_mouse_first_time_; DeltaTracker delta_tracker_; diff -Nru unity-7.2.2+14.04.20140714/lockscreen/LockScreenAcceleratorController.cpp unity-7.2.3+14.04.20140826/lockscreen/LockScreenAcceleratorController.cpp --- unity-7.2.2+14.04.20140714/lockscreen/LockScreenAcceleratorController.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/LockScreenAcceleratorController.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -32,6 +32,17 @@ const char* const MEDIA_KEYS_KEY_VOLUME_MUTE = "volume-mute"; const char* const MEDIA_KEYS_KEY_VOLUME_DOWN = "volume-down"; const char* const MEDIA_KEYS_KEY_VOLUME_UP = "volume-up"; + +const char* const POWER_SCHEMA = "org.gnome.settings-daemon.plugins.power"; +const char* const SUSPEND_BUTTON_ACTION_KEY = "button-suspend"; +const char* const SLEEP_BUTTON_ACTION_KEY = "button-sleep"; +const char* const HIBERNATE_BUTTON_ACTION_KEY = "button-hibernate"; +const char* const POWER_BUTTON_ACTION_KEY = "button-power"; +const char* const POWER_KEY_SUSPEND = "XF86Suspend"; +const char* const POWER_KEY_SLEEP = "XF86Sleep"; +const char* const POWER_KEY_HIBERNATE = "XF86Hibernate"; +const char* const POWER_KEY_POWEROFF = "XF86PowerOff"; + const char* const INPUT_SWITCH_SCHEMA = "org.gnome.desktop.wm.keybindings"; const char* const INPUT_SWITCH_KEY_PREVIOUS_SOURCE = "switch-input-source-backward"; const char* const INPUT_SWITCH_KEY_NEXT_SOURCE = "switch-input-source"; @@ -89,15 +100,32 @@ INDICATOR_KEYBOARD_ACTION_SCROLL, g_variant_new_int32(-offset)); } + +void PowerAction(session::Manager::Ptr const& session, const char *action_key) +{ + glib::Object settings(g_settings_new(POWER_SCHEMA)); + auto const& action = glib::String(g_settings_get_string(settings, action_key)).Str(); + + if (action == "interactive") + session->shutdown_requested.emit(session->HasInhibitors()); + else if (action == "shutdown") + session->reboot_requested.emit(session->HasInhibitors()); + else if (action == "suspend") + session->Suspend(); + else if (action == "hibernate") + session->Hibernate(); + else if (action == "blank") + session->ScreenSaverActivate(); +} } // namespace -AcceleratorController::AcceleratorController() +AcceleratorController::AcceleratorController(session::Manager::Ptr const& session) : accelerators_(new Accelerators) { auto settings = glib::Object(g_settings_new(MEDIA_KEYS_SCHEMA)); auto accelerator = std::make_shared(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_MUTE))); - accelerator->activated.connect(std::function(MuteIndicatorSound)); + accelerator->activated.connect(std::function(MuteIndicatorSound)); accelerators_->Add(accelerator); accelerator = std::make_shared(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_DOWN))); @@ -108,6 +136,22 @@ accelerator->activated.connect(std::bind(ScrollIndicatorSound, +1)); accelerators_->Add(accelerator); + accelerator = std::make_shared(POWER_KEY_SUSPEND); + accelerator->activated.connect(std::bind(PowerAction, session, SUSPEND_BUTTON_ACTION_KEY)); + accelerators_->Add(accelerator); + + accelerator = std::make_shared(POWER_KEY_SLEEP); + accelerator->activated.connect(std::bind(PowerAction, session, SLEEP_BUTTON_ACTION_KEY)); + accelerators_->Add(accelerator); + + accelerator = std::make_shared(POWER_KEY_HIBERNATE); + accelerator->activated.connect(std::bind(PowerAction, session, HIBERNATE_BUTTON_ACTION_KEY)); + accelerators_->Add(accelerator); + + accelerator = std::make_shared(POWER_KEY_POWEROFF); + accelerator->activated.connect(std::bind(PowerAction, session, POWER_BUTTON_ACTION_KEY)); + accelerators_->Add(accelerator); + settings = glib::Object(g_settings_new(INPUT_SWITCH_SCHEMA)); auto variant = glib::Variant(g_settings_get_value(settings, INPUT_SWITCH_KEY_PREVIOUS_SOURCE), glib::StealRef()); diff -Nru unity-7.2.2+14.04.20140714/lockscreen/LockScreenAcceleratorController.h unity-7.2.3+14.04.20140826/lockscreen/LockScreenAcceleratorController.h --- unity-7.2.2+14.04.20140714/lockscreen/LockScreenAcceleratorController.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/LockScreenAcceleratorController.h 2014-08-26 15:48:28.000000000 +0200 @@ -20,6 +20,7 @@ #ifndef UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER #define UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER +#include #include "LockScreenAccelerators.h" namespace unity @@ -32,7 +33,7 @@ public: typedef std::shared_ptr Ptr; - AcceleratorController(); + AcceleratorController(session::Manager::Ptr const&); Accelerators::Ptr const& GetAccelerators() const; diff -Nru unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp unity-7.2.3+14.04.20140826/lockscreen/LockScreenController.cpp --- unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/LockScreenController.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -45,9 +45,9 @@ bool AcceptKeyNavFocus() override { return true; } bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; }; }; -} DECLARE_LOGGER(logger, "unity.lockscreen"); +} Controller::Controller(DBusManager::Ptr const& dbus_manager, session::Manager::Ptr const& session_manager, @@ -104,7 +104,7 @@ key_connection_->disconnect(); uscreen_connection_->block(); hidden_window_connection_->block(); - session_manager_->unlocked.emit(); + session_manager_->is_locked = false; std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr const& shield) { shield->RemoveLayout(); @@ -203,11 +203,18 @@ is_new = true; } - shield->SetGeometry(monitors[i]); - shield->SetMinMaxSize(monitors[i].width, monitors[i].height); + auto old_geo = shield->GetGeometry(); + auto new_geo = monitors[i]; + + shield->SetGeometry(new_geo); + shield->SetMinMaxSize(new_geo.width, new_geo.height); shield->primary = (i == primary); shield->monitor = i; + // XXX: manually emit nux::Area::geometry_changed beucase nux can fail to emit it. + if (old_geo != new_geo) + shield->geometry_changed.emit(shield.GetPointer(), new_geo); + if (is_new && fade_animator_.GetCurrentValue() > 0) { shield->SetOpacity(fade_animator_.GetCurrentValue()); @@ -342,7 +349,7 @@ HideBlankWindow(); LockScreen(); - session_manager_->locked.emit(); + session_manager_->is_locked = true; if (prompt_activation_) { @@ -403,7 +410,7 @@ indicators_ = std::make_shared(); upstart_wrapper_->Emit("desktop-lock"); - accelerator_controller_ = std::make_shared(); + accelerator_controller_ = std::make_shared(session_manager_); auto activate_key = WindowManager::Default().activate_indicators_key(); auto accelerator = std::make_shared(activate_key.second, 0, activate_key.first); accelerator->activated.connect(std::bind(std::mem_fn(&Controller::ActivatePanel), this)); diff -Nru unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp unity-7.2.3+14.04.20140826/lockscreen/LockScreenShield.cpp --- unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/LockScreenShield.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -19,6 +19,7 @@ #include "LockScreenShield.h" +#include #include #include #include @@ -35,6 +36,11 @@ { namespace lockscreen { +namespace +{ +DECLARE_LOGGER(logger, "unity.lockscreen.shield"); +const unsigned MAX_GRAB_WAIT = 50; +} Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, Accelerators::Ptr const& accelerators, int monitor_num, bool is_primary) : AbstractShield(session_manager, indicators, accelerators, monitor_num, is_primary) @@ -56,12 +62,7 @@ }); primary.changed.connect([this] (bool is_primary) { - if (!is_primary) - { - UnGrabPointer(); - UnGrabKeyboard(); - } - + regrab_conn_->disconnect(); is_primary ? ShowPrimaryView() : ShowSecondaryView(); if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary); QueueRelayout(); @@ -86,17 +87,41 @@ } } -void Shield::ShowPrimaryView() +void Shield::GrabScreen(bool cancel_on_failure) { - GrabPointer(); - GrabKeyboard(); + auto& wc = nux::GetWindowCompositor(); + + if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this)) + { + regrab_conn_->disconnect(); + regrab_timeout_.reset(); + } + else + { + auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false); + regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb); + if (cancel_on_failure) + { + regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] { + LOG_ERROR(logger) << "Impossible to get the grab to lock the screen"; + session_manager_->unlock_requested.emit(); + return false; + })); + } + } +} + +void Shield::ShowPrimaryView() +{ if (primary_layout_) { + GrabScreen(false); SetLayout(primary_layout_.GetPointer()); return; } + GrabScreen(true); nux::Layout* main_layout = new nux::VLayout(); primary_layout_ = main_layout; SetLayout(primary_layout_.GetPointer()); @@ -149,19 +174,7 @@ } else { - auto& wc = nux::GetWindowCompositor(); - - if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this)) - { - regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] { - if (primary()) - { - GrabPointer(); - GrabKeyboard(); - } - regrab_conn_->disconnect(); - }); - } + GrabScreen(false); } } }); diff -Nru unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h unity-7.2.3+14.04.20140826/lockscreen/LockScreenShield.h --- unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/LockScreenShield.h 2014-08-26 15:48:28.000000000 +0200 @@ -21,6 +21,7 @@ #define UNITY_LOCKSCREEN_SHIELD_H #include +#include #include "LockScreenAbstractShield.h" namespace unity @@ -48,6 +49,7 @@ private: void UpdateBackgroundTexture(); + void GrabScreen(bool cancel_on_failure); void ShowPrimaryView(); void ShowSecondaryView(); Panel* CreatePanel(); @@ -59,6 +61,7 @@ nux::ObjectPtr cof_layout_; connection::Wrapper panel_active_conn_; connection::Wrapper regrab_conn_; + glib::Source::UniquePtr regrab_timeout_; UserPromptView* prompt_view_; Panel* panel_view_; }; diff -Nru unity-7.2.2+14.04.20140714/lockscreen/UserPromptView.cpp unity-7.2.3+14.04.20140826/lockscreen/UserPromptView.cpp --- unity-7.2.2+14.04.20140714/lockscreen/UserPromptView.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/lockscreen/UserPromptView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -24,7 +24,6 @@ #include "LockScreenSettings.h" #include "unity-shared/CairoTexture.h" -#include "unity-shared/DashStyle.h" #include "unity-shared/TextInput.h" #include "unity-shared/StaticCairoText.h" #include "unity-shared/RawPixel.h" diff -Nru unity-7.2.2+14.04.20140714/plugins/unityshell/src/unityshell.cpp unity-7.2.3+14.04.20140826/plugins/unityshell/src/unityshell.cpp --- unity-7.2.2+14.04.20140714/plugins/unityshell/src/unityshell.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/plugins/unityshell/src/unityshell.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -2895,7 +2895,7 @@ GLWindowPaintAttrib wAttrib = attrib; - if (uScreen->lockscreen_controller_->IsLocked()) + if (uScreen->lockscreen_controller_->IsLocked() && uScreen->lockscreen_controller_->opacity() == 1.0) { if (!window->minimized() && !CanBypassLockScreen()) { @@ -2903,7 +2903,7 @@ // (well, it works too much, as it applies to menus too), so we need // to paint the windows at the proper opacity, overriding any other // paint plugin (animation, fade?) that might interfere with us. - wAttrib.opacity = COMPIZ_COMPOSITE_OPAQUE * (1.0f - uScreen->lockscreen_controller_->opacity()); + wAttrib.opacity = 0.0; int old_index = gWindow->glPaintGetCurrentIndex(); gWindow->glPaintSetCurrentIndex(MAXSHORT); bool ret = gWindow->glPaint(wAttrib, matrix, region, mask); @@ -3821,7 +3821,7 @@ // We notify that super/alt have been released, to avoid to leave unity in inconsistent state CompOption::Vector options(8); options[7].setName("time", CompOption::TypeInt); - options[7].value().set((int) screen->getCurrentTime()); + options[7].value().set(screen->getCurrentTime()); showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, options); showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, options); @@ -3952,8 +3952,8 @@ /* The launcher geometry includes 1px used to draw the right margin * that must not be considered when drawing an overlay */ - int launcher_width = w - 1; - Launcher const* const launcher = static_cast(area); + auto* launcher = static_cast(area); + int launcher_width = w - (1_em).CP(unity_settings_.em(launcher->monitor)->DPIScale()); unity::Settings::Instance().SetLauncherWidth(launcher_width, launcher->monitor); shortcut_controller_->SetAdjustment(launcher_width, panel_style_.PanelHeight(launcher->monitor)); @@ -3967,18 +3967,22 @@ screen->setOptionForPlugin("scale", "x_offset", v); }; - for (auto const& launcher : launcher_controller_->launchers()) - { - launcher->size_changed.connect(on_launcher_size_changed); - - on_launcher_size_changed(launcher.GetPointer(), launcher->GetWidth(), launcher->GetHeight()); - } + auto check_launchers_size = [this, on_launcher_size_changed] { + launcher_size_connections_.Clear(); - UScreen::GetDefault()->changed.connect([this, on_launcher_size_changed] (int, std::vector const&) { for (auto const& launcher : launcher_controller_->launchers()) + { + launcher_size_connections_.Add(launcher->size_changed.connect(on_launcher_size_changed)); on_launcher_size_changed(launcher.GetPointer(), launcher->GetWidth(), launcher->GetHeight()); + } + }; + + UScreen::GetDefault()->changed.connect([this, check_launchers_size] (int, std::vector const&) { + check_launchers_size(); }); + check_launchers_size(); + launcher_controller_->options()->scroll_inactive_icons = optionGetScrollInactiveIcons(); launcher_controller_->options()->minimize_window_on_click = optionGetLauncherMinimizeWindow(); diff -Nru unity-7.2.2+14.04.20140714/plugins/unityshell/src/unityshell.h unity-7.2.3+14.04.20140826/plugins/unityshell/src/unityshell.h --- unity-7.2.2+14.04.20140714/plugins/unityshell/src/unityshell.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/plugins/unityshell/src/unityshell.h 2014-08-26 15:48:28.000000000 +0200 @@ -423,6 +423,7 @@ UBusManager ubus_manager_; glib::SourceManager sources_; connection::Wrapper hud_ungrab_slot_; + connection::Manager launcher_size_connections_; CompRegion buffered_compiz_damage_this_frame_; CompRegion buffered_compiz_damage_last_frame_; I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/dash_fullscreen_icon.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/dash_fullscreen_icon.png sono diversi I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/dash_left_edge.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/dash_left_edge.png sono diversi I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/find_files.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/find_files.png sono diversi I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/find_internet_apps.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/find_internet_apps.png sono diversi I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/find_media_apps.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/find_media_apps.png sono diversi I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/find_more_apps.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/find_more_apps.png sono diversi diff -Nru unity-7.2.2+14.04.20140714/resources/flow-view.svg unity-7.2.3+14.04.20140826/resources/flow-view.svg --- unity-7.2.2+14.04.20140714/resources/flow-view.svg 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/resources/flow-view.svg 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ - - - - - - - - - - - - \ Manca newline alla fine del file diff -Nru unity-7.2.2+14.04.20140714/resources/grid-view.svg unity-7.2.3+14.04.20140826/resources/grid-view.svg --- unity-7.2.2+14.04.20140714/resources/grid-view.svg 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/resources/grid-view.svg 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ - - - - - - - - - - - - \ Manca newline alla fine del file I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/search_magnify.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/search_magnify.png sono diversi diff -Nru unity-7.2.2+14.04.20140714/resources/search_magnify.svg unity-7.2.3+14.04.20140826/resources/search_magnify.svg --- unity-7.2.2+14.04.20140714/resources/search_magnify.svg 1970-01-01 01:00:00.000000000 +0100 +++ unity-7.2.3+14.04.20140826/resources/search_magnify.svg 2014-08-26 15:48:28.000000000 +0200 @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + I file binari /tmp/gf7ZI7q07G/unity-7.2.2+14.04.20140714/resources/shortcuts_group_icon.png e /tmp/QwN4ImiWb0/unity-7.2.3+14.04.20140826/resources/shortcuts_group_icon.png sono diversi diff -Nru unity-7.2.2+14.04.20140714/services/panel-service.c unity-7.2.3+14.04.20140826/services/panel-service.c --- unity-7.2.2+14.04.20140714/services/panel-service.c 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/services/panel-service.c 2014-08-26 15:48:28.000000000 +0200 @@ -46,6 +46,9 @@ #define N_TIMEOUT_SLOTS 50 #define MAX_INDICATOR_ENTRIES 100 +#define NUX_VERTICAL_SCROLL_DELTA 120 +#define NUX_HORIZONTAL_SCROLL_DELTA (NUX_VERTICAL_SCROLL_DELTA ^ 2) + #define COMPIZ_OPTION_SCHEMA "org.compiz.unityshell" #define COMPIZ_OPTION_PATH "/org/compiz/profiles/unity/plugins/" #define MENU_TOGGLE_KEYBINDING_KEY "panel-first-menu" @@ -2399,9 +2402,28 @@ entry = get_indicator_entry_by_id (self, entry_id); g_return_if_fail (entry); - GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP; + GdkScrollDirection direction = G_MAXINT; - object = get_entry_parent_indicator (entry); - g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, - abs(delta/120), direction); + switch (delta) + { + case NUX_VERTICAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_UP; + break; + case -NUX_VERTICAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_DOWN; + break; + case NUX_HORIZONTAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_LEFT; + break; + case -NUX_HORIZONTAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_RIGHT; + break; + } + + if (direction != G_MAXINT) + { + object = get_entry_parent_indicator (entry); + g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, + entry, 1, direction); + } } diff -Nru unity-7.2.2+14.04.20140714/shutdown/SessionDBusManager.cpp unity-7.2.3+14.04.20140826/shutdown/SessionDBusManager.cpp --- unity-7.2.2+14.04.20140714/shutdown/SessionDBusManager.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/shutdown/SessionDBusManager.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -53,14 +53,20 @@ + + + + + + - + - + - + @@ -121,7 +127,7 @@ } else if (method == "RequestLogout") { - session_->logout_requested.emit(false); + session_->logout_requested.emit(session_->HasInhibitors()); } else if (method == "Reboot") { @@ -129,7 +135,7 @@ } else if (method == "RequestReboot") { - session_->reboot_requested.emit(false); + session_->reboot_requested.emit(session_->HasInhibitors()); } else if (method == "Shutdown") { @@ -137,7 +143,7 @@ } else if (method == "RequestShutdown") { - session_->shutdown_requested.emit(false); + session_->shutdown_requested.emit(session_->HasInhibitors()); } else if (method == "Suspend") { @@ -152,17 +158,25 @@ session_->CancelAction(); session_->cancel_requested.emit(); } + else if (method == "IsLocked") + { + return g_variant_new("(b)", session_->is_locked() != false); + } + else if (method == "CanLock") + { + return g_variant_new("(b)", session_->CanLock() != false); + } else if (method == "CanShutdown") { - return g_variant_new("(b)", session_->CanShutdown() != FALSE); + return g_variant_new("(b)", session_->CanShutdown() != false); } else if (method == "CanSuspend") { - return g_variant_new("(b)", session_->CanSuspend() != FALSE); + return g_variant_new("(b)", session_->CanSuspend() != false); } else if (method == "CanHibernate") { - return g_variant_new("(b)", session_->CanHibernate() != FALSE); + return g_variant_new("(b)", session_->CanHibernate() != false); } return nullptr; diff -Nru unity-7.2.2+14.04.20140714/shutdown/SessionView.cpp unity-7.2.3+14.04.20140826/shutdown/SessionView.cpp --- unity-7.2.2+14.04.20140714/shutdown/SessionView.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/shutdown/SessionView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -91,16 +91,17 @@ return false; }); - mode.changed.connect([this] (Mode m) { - UpdateText(); - Populate(); - }); - + mode.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateContents))); scale.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateViewSize))); + UpdateContents(); +} - UpdateViewSize(); +void View::UpdateContents() +{ + SetVisible(true); + PopulateButtons(); UpdateText(); - Populate(); + UpdateViewSize(); } void View::UpdateViewSize() @@ -115,11 +116,17 @@ ReloadCloseButtonTexture(); buttons_layout_->SetSpaceBetweenChildren(style::BUTTONS_SPACE.CP(scale())); + auto const& buttons = buttons_layout_->GetChildren(); - for (auto* area : buttons_layout_->GetChildren()) + for (auto* area : buttons) + static_cast(area)->scale = scale(); + + if (buttons.size() == 1) { - auto* button = static_cast(area); - button->scale = scale(); + auto* button = buttons.front(); + button->ComputeContentSize(); + int padding = button->GetWidth()/2 + style::MAIN_SPACE.CP(scale())/2; + buttons_layout_->SetLeftAndRightPadding(padding, padding); } } @@ -201,20 +208,26 @@ subtitle_->SetText(glib::String(g_strdup_printf(message.c_str(), name.c_str())).Str()); } -void View::Populate() +void View::PopulateButtons() { debug::Introspectable::RemoveAllChildren(); buttons_layout_->Clear(); + buttons_layout_->SetLeftAndRightPadding(0, 0); key_focus_area_ = this; if (mode() == Mode::LOGOUT) { - auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); - button->scale = scale(); - button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); - AddButton(button); + if (manager_->is_locked()) + return; - button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); + if (manager_->CanLock()) + { + auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); + button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); + AddButton(button); + } + + auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); key_focus_area_ = button; AddButton(button); @@ -223,23 +236,23 @@ { if (mode() == Mode::FULL) { - auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); - button->scale = scale(); - button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); - AddButton(button); + if (manager_->CanLock()) + { + auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); + button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); + AddButton(button); + } if (manager_->CanSuspend()) { - button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION); - button->scale = scale(); + auto* button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Suspend)); AddButton(button); } if (manager_->CanHibernate()) { - button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION); - button->scale = scale(); + auto* button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Hibernate)); AddButton(button); } @@ -248,28 +261,34 @@ if (manager_->CanShutdown()) { auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION); - button->scale = scale(); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot)); AddButton(button); button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION); - button->scale = scale(); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown)); key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_; AddButton(button); } - else if (mode() == Mode::FULL) + else if (mode() == Mode::FULL && !manager_->is_locked()) { auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); - button->scale = scale(); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); AddButton(button); } } + + cancel_idle_.reset(); + if (buttons_layout_->GetChildren().empty()) + { + // There's nothing to show here, let's cancel the action and hide + SetVisible(false); + cancel_idle_.reset(new glib::Idle([this] { request_close.emit(); return false; })); + } } void View::AddButton(Button* button) { + button->scale = scale(); button->activated.connect([this] {request_hide.emit();}); buttons_layout_->AddView(button); debug::Introspectable::AddChild(button); diff -Nru unity-7.2.2+14.04.20140714/shutdown/SessionView.h unity-7.2.3+14.04.20140826/shutdown/SessionView.h --- unity-7.2.2+14.04.20140714/shutdown/SessionView.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/shutdown/SessionView.h 2014-08-26 15:48:28.000000000 +0200 @@ -25,10 +25,10 @@ #include #include -#include "UnityCore/SessionManager.h" +#include +#include #include "unity-shared/EMConverter.h" #include "unity-shared/UnityWindowView.h" -#include "UnityCore/SessionManager.h" namespace unity { @@ -73,10 +73,10 @@ private: friend class TestSessionView; - void UpdateViewSize(); - + void PopulateButtons(); void UpdateText(); - void Populate(); + void UpdateContents(); + void UpdateViewSize(); void AddButton(Button*); Manager::Ptr manager_; @@ -85,6 +85,7 @@ nux::VLayout* main_layout_; nux::HLayout* buttons_layout_; nux::InputArea* key_focus_area_; + glib::Source::UniquePtr cancel_idle_; }; } // namespace session diff -Nru unity-7.2.2+14.04.20140714/shutdown/StandaloneSession.cpp unity-7.2.3+14.04.20140826/shutdown/StandaloneSession.cpp --- unity-7.2.2+14.04.20140714/shutdown/StandaloneSession.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/shutdown/StandaloneSession.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -52,9 +52,11 @@ void CancelAction() { std::cout << "CancelAction" << std::endl; } + bool CanLock() const {return true;} bool CanShutdown() const {return true;} bool CanSuspend() const {return true;} bool CanHibernate() const {return true;} + bool HasInhibitors() const {return false;} }; struct SessionWindow diff -Nru unity-7.2.2+14.04.20140714/tests/autopilot/unity/emulators/switcher.py unity-7.2.3+14.04.20140826/tests/autopilot/unity/emulators/switcher.py --- unity-7.2.2+14.04.20140714/tests/autopilot/unity/emulators/switcher.py 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/autopilot/unity/emulators/switcher.py 2014-08-26 15:48:28.000000000 +0200 @@ -189,14 +189,14 @@ def next_via_mouse(self): """Move to the next icon using the mouse scroll wheel.""" logger.debug("Selecting next item in switcher with mouse scroll wheel.") - self._mouse.press(6) - self._mouse.release(6) + self._mouse.press(7) + self._mouse.release(7) def previous_via_mouse(self): """Move to the previous icon using the mouse scroll wheel.""" logger.debug("Selecting previous item in switcher with mouse scroll wheel.") - self._mouse.press(7) - self._mouse.release(7) + self._mouse.press(6) + self._mouse.release(6) @property def detail_selection_index(self): diff -Nru unity-7.2.2+14.04.20140714/tests/test_mock_session_manager.h unity-7.2.3+14.04.20140826/tests/test_mock_session_manager.h --- unity-7.2.2+14.04.20140714/tests/test_mock_session_manager.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/test_mock_session_manager.h 2014-08-26 15:48:28.000000000 +0200 @@ -44,9 +44,11 @@ MOCK_METHOD0(Hibernate, void()); MOCK_METHOD0(CancelAction, void()); + MOCK_CONST_METHOD0(CanLock, bool()); MOCK_CONST_METHOD0(CanShutdown, bool()); MOCK_CONST_METHOD0(CanSuspend, bool()); MOCK_CONST_METHOD0(CanHibernate, bool()); + MOCK_CONST_METHOD0(HasInhibitors, bool()); }; } // session diff -Nru unity-7.2.2+14.04.20140714/tests/test_places_group.cpp unity-7.2.3+14.04.20140826/tests/test_places_group.cpp --- unity-7.2.2+14.04.20140714/tests/test_places_group.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/test_places_group.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -40,18 +40,18 @@ } MOCK_METHOD2(FocusOverlay, nux::AbstractPaintLayer*(int width, int height)); - MOCK_METHOD0(GetCategoryBackground, nux::BaseTexture*()); - MOCK_METHOD0(GetCategoryBackgroundNoFilters, nux::BaseTexture*()); + MOCK_CONST_METHOD0(GetCategoryBackground, nux::ObjectPtr const&()); + MOCK_CONST_METHOD0(GetCategoryBackgroundNoFilters, nux::ObjectPtr const&()); - MOCK_METHOD0(GetGroupExpandIcon, nux::BaseTexture*()); - MOCK_METHOD0(GetGroupUnexpandIcon, nux::BaseTexture*()); + MOCK_CONST_METHOD0(GetGroupExpandIcon, nux::ObjectPtr const&()); + MOCK_CONST_METHOD0(GetGroupUnexpandIcon, nux::ObjectPtr const&()); - MOCK_CONST_METHOD0(GetCategoryIconSize, int()); - MOCK_CONST_METHOD0(GetCategoryHeaderLeftPadding, int()); + MOCK_CONST_METHOD0(GetCategoryIconSize, RawPixel()); + MOCK_CONST_METHOD0(GetCategoryHeaderLeftPadding, RawPixel()); - MOCK_CONST_METHOD0(GetPlacesGroupTopSpace, int()); - MOCK_CONST_METHOD0(GetPlacesGroupResultTopPadding, int()); - MOCK_CONST_METHOD0(GetPlacesGroupResultLeftPadding, int()); + MOCK_CONST_METHOD0(GetPlacesGroupTopSpace, RawPixel()); + MOCK_CONST_METHOD0(GetPlacesGroupResultTopPadding, RawPixel()); + MOCK_CONST_METHOD0(GetPlacesGroupResultLeftPadding, RawPixel()); nux::ObjectPtr base_texture_; }; @@ -72,23 +72,32 @@ ON_CALL(dash_style_, FocusOverlay(_, _)) .WillByDefault(Return(new nux::ColorLayer(nux::color::White))); - ON_CALL(dash_style_, GetCategoryBackground()) - .WillByDefault(Return(dash_style_.base_texture_.GetPointer())); + ON_CALL(Const(dash_style_), GetCategoryBackground()) + .WillByDefault(ReturnRef(dash_style_.base_texture_)); - ON_CALL(dash_style_, GetCategoryBackgroundNoFilters()) - .WillByDefault(Return(dash_style_.base_texture_.GetPointer())); + ON_CALL(Const(dash_style_), GetCategoryBackgroundNoFilters()) + .WillByDefault(ReturnRef(dash_style_.base_texture_)); - ON_CALL(dash_style_, GetGroupExpandIcon()) - .WillByDefault(Return(dash_style_.base_texture_.GetPointer())); + ON_CALL(Const(dash_style_), GetGroupExpandIcon()) + .WillByDefault(ReturnRef(dash_style_.base_texture_)); - ON_CALL(dash_style_, GetGroupUnexpandIcon()) - .WillByDefault(Return(dash_style_.base_texture_.GetPointer())); + ON_CALL(Const(dash_style_), GetGroupUnexpandIcon()) + .WillByDefault(ReturnRef(dash_style_.base_texture_)); ON_CALL(dash_style_, GetCategoryHeaderLeftPadding()) - .WillByDefault(Return(19)); + .WillByDefault(Return(19_em)); ON_CALL(dash_style_, GetPlacesGroupTopSpace()) - .WillByDefault(Return(7)); + .WillByDefault(Return(7_em)); + + ON_CALL(dash_style_, GetCategoryIconSize()) + .WillByDefault(Return(0_em)); + + ON_CALL(dash_style_, GetPlacesGroupResultTopPadding()) + .WillByDefault(Return(0_em)); + + ON_CALL(dash_style_, GetPlacesGroupResultLeftPadding()) + .WillByDefault(Return(0_em)); } NiceMock dash_style_; diff -Nru unity-7.2.2+14.04.20140714/tests/test_previews_payment.cpp unity-7.2.3+14.04.20140826/tests/test_previews_payment.cpp --- unity-7.2.2+14.04.20140714/tests/test_previews_payment.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/test_previews_payment.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -146,7 +146,6 @@ // needed for styles dash::Style dash_style; - }; TEST_F(TestPaymentPreview, GetHeaderCallsCorrectMethods) @@ -157,7 +156,7 @@ ON_CALL(*preview.GetPointer(), GetPrice()).WillByDefault(Return(new nux::VLayout())); EXPECT_CALL(*preview.GetPointer(), GetPrice()).Times(1); - preview->GetHeader(); + preview->GetHeader()->UnReference(); } TEST_F(TestPaymentPreview, SetupViewsCallCorrectMethods) diff -Nru unity-7.2.2+14.04.20140714/tests/test_session_controller.cpp unity-7.2.3+14.04.20140826/tests/test_session_controller.cpp --- unity-7.2.2+14.04.20140714/tests/test_session_controller.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/test_session_controller.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -41,6 +41,7 @@ , manager(std::make_shared>()) , controller(manager) { + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); } diff -Nru unity-7.2.2+14.04.20140714/tests/test_session_view.cpp unity-7.2.3+14.04.20140826/tests/test_session_view.cpp --- unity-7.2.2+14.04.20140714/tests/test_session_view.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tests/test_session_view.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -137,6 +137,7 @@ TEST_F(TestSessionView, FullModeButtons) { + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); ON_CALL(*manager, CanSuspend()).WillByDefault(testing::Return(true)); ON_CALL(*manager, CanHibernate()).WillByDefault(testing::Return(true)); @@ -166,6 +167,11 @@ view.mode.changed.emit(View::Mode::FULL); EXPECT_EQ(view.GetButtonByAction(Button::Action::HIBERNATE), nullptr); + + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(false)); + view.mode.changed.emit(View::Mode::FULL); + + EXPECT_EQ(view.GetButtonByAction(Button::Action::LOCK), nullptr); } TEST_F(TestSessionView, ShutdownModeButtons) @@ -181,6 +187,7 @@ TEST_F(TestSessionView, LogoutModeButtons) { + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); view.mode = View::Mode::LOGOUT; EXPECT_EQ(view.GetButtons().size(), 2); @@ -189,6 +196,16 @@ EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); } +TEST_F(TestSessionView, LogoutLightModeButtons) +{ + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(false)); + view.mode = View::Mode::LOGOUT; + + EXPECT_EQ(view.GetButtons().size(), 1); + EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 0); + EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); +} + TEST_F(TestSessionView, FullModeTitle) { EXPECT_TRUE(view.GetTitle().empty()); @@ -213,8 +230,9 @@ { bool request_hide = false; view.request_hide.connect([&request_hide] { request_hide = true; }); + view.mode = View::Mode::LOGOUT; - auto button = view.GetButtonByAction(Button::Action::LOCK); + auto button = view.GetButtonByAction(Button::Action::LOGOUT); ASSERT_NE(button, nullptr); button->activated.emit(); @@ -223,7 +241,8 @@ TEST_F(TestSessionView, ButtonsActivateDeselectButton) { - auto button = view.GetButtonByAction(Button::Action::LOCK); + view.mode = View::Mode::LOGOUT; + auto button = view.GetButtonByAction(Button::Action::LOGOUT); ASSERT_NE(button, nullptr); button->highlighted = true; button->activated.emit(); @@ -233,6 +252,8 @@ TEST_F(TestSessionView, LockButtonActivateLocks) { + ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); + view.mode = View::Mode::LOGOUT; EXPECT_CALL(*manager, LockScreen()); auto button = view.GetButtonByAction(Button::Action::LOCK); ASSERT_NE(button, nullptr); diff -Nru unity-7.2.2+14.04.20140714/tools/unity.cmake unity-7.2.3+14.04.20140826/tools/unity.cmake --- unity-7.2.2+14.04.20140714/tools/unity.cmake 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/tools/unity.cmake 2014-08-26 15:48:28.000000000 +0200 @@ -22,6 +22,7 @@ import glob from optparse import OptionParser import os +import re import shutil import signal import subprocess @@ -100,7 +101,19 @@ # kill a previous compiz if was there (this is a hack as compiz can # sometimes get stuck and not exit on --replace) - subprocess.call (["pkill", "-9", "compiz"]) + display = "DISPLAY=" + os.environ["DISPLAY"] + pids = [pid for pid in os.listdir("/proc") if pid.isdigit()] + + for pid in pids: + try: + pid_path = os.path.join("/proc", pid) + cmdline = open(os.path.join(pid_path, "cmdline"), "rb").read() + if re.match(r"^compiz\b", cmdline): + compiz_env = open(os.path.join(pid_path, "environ"), "rb").read() + if display in compiz_env: + subprocess.call (["kill", "-9", pid]) + except IOError: + continue # shell = True as it's the simpest way to | tee. # In this case, we need a string and not a list diff -Nru unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManager.cpp unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManager.cpp --- unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManager.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManager.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -91,6 +91,11 @@ shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE); shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall)); + manager_->is_locked = false; + manager_->is_locked.changed.connect([this] (bool locked) { + locked ? manager_->locked.emit() : manager_->unlocked.emit(); + }); + { const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID"); @@ -421,21 +426,13 @@ { EnsureCancelPendingAction(); - // FIXME (andy) we should ask gnome-session to emit the logind signal - glib::Object lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); - - if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str())) - { - manager_->ScreenSaverActivate(); - return; - } - else if (manager_->UserName().find("guest-") == 0) + if (!manager_->CanLock()) { - LOG_INFO(logger) << "Impossible to lock a guest session"; manager_->ScreenSaverActivate(); return; } + // FIXME (andy) we should ask gnome-session to emit the logind signal prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit(); } @@ -454,6 +451,39 @@ }); } +bool GnomeManager::Impl::HasInhibitors() +{ + glib::Error error; + glib::Object bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error)); + + if (error) + { + LOG_ERROR(logger) << "Impossible to get the session bus, to fetch the inhibitors: " << error; + return false; + } + + enum class Inhibited : unsigned + { + LOGOUT = 1, + USER_SWITCH = 2, + SUSPEND = 4, + IDLE_SET = 8 + }; + + glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager", + "/org/gnome/SessionManager", "org.gnome.SessionManager", + "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr, + G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); + + if (error) + { + LOG_ERROR(logger) << "Impossible to get the inhibitors: " << error; + return false; + } + + return inhibitors.GetBool(); +} + // Public implementation GnomeManager::GnomeManager() @@ -617,6 +647,19 @@ }); } +bool GnomeManager::CanLock() const +{ + glib::Object lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); + + if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()) || + UserName().find("guest-") == 0 || is_locked()) + { + return false; + } + + return true; +} + bool GnomeManager::CanShutdown() const { return impl_->can_shutdown_; @@ -632,6 +675,11 @@ return impl_->can_hibernate_; } +bool GnomeManager::HasInhibitors() const +{ + return impl_->HasInhibitors(); +} + void GnomeManager::CancelAction() { impl_->CancelAction(); diff -Nru unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManager.h unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManager.h --- unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManager.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManager.h 2014-08-26 15:48:28.000000000 +0200 @@ -47,9 +47,11 @@ void Suspend(); void Hibernate(); + bool CanLock() const; bool CanShutdown() const; bool CanSuspend() const; bool CanHibernate() const; + bool HasInhibitors() const; void CancelAction(); diff -Nru unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManagerImpl.h unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManagerImpl.h --- unity-7.2.2+14.04.20140714/UnityCore/GnomeSessionManagerImpl.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/UnityCore/GnomeSessionManagerImpl.h 2014-08-26 15:48:28.000000000 +0200 @@ -51,6 +51,7 @@ void ConfirmShutdown(); void CancelAction(); void ClosedDialog(); + bool HasInhibitors(); void EnsureCancelPendingAction(); void LockScreen(bool prompt); diff -Nru unity-7.2.2+14.04.20140714/UnityCore/SessionManager.h unity-7.2.3+14.04.20140826/UnityCore/SessionManager.h --- unity-7.2.2+14.04.20140714/UnityCore/SessionManager.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/UnityCore/SessionManager.h 2014-08-26 15:48:28.000000000 +0200 @@ -39,6 +39,7 @@ virtual ~Manager() = default; nux::ROProperty have_other_open_sessions; + nux::Property is_locked; virtual std::string RealName() const = 0; virtual std::string UserName() const = 0; @@ -54,9 +55,11 @@ virtual void Suspend() = 0; virtual void Hibernate() = 0; + virtual bool CanLock() const = 0; virtual bool CanShutdown() const = 0; virtual bool CanSuspend() const = 0; virtual bool CanHibernate() const = 0; + virtual bool HasInhibitors() const = 0; virtual void CancelAction() = 0; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/CMakeLists.txt unity-7.2.3+14.04.20140826/unity-shared/CMakeLists.txt --- unity-7.2.2+14.04.20140714/unity-shared/CMakeLists.txt 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/CMakeLists.txt 2014-08-26 15:48:28.000000000 +0200 @@ -44,6 +44,7 @@ LineSeparator.cpp MenuManager.cpp OverlayRenderer.cpp + OverlayScrollView.cpp OverlayWindowButtons.cpp PanelStyle.cpp PlacesVScrollBar.cpp diff -Nru unity-7.2.2+14.04.20140714/unity-shared/CoverArt.cpp unity-7.2.3+14.04.20140826/unity-shared/CoverArt.cpp --- unity-7.2.2+14.04.20140714/unity-shared/CoverArt.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/CoverArt.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -42,7 +42,8 @@ namespace { -const int ICON_SIZE = 256; +const RawPixel ICON_SIZE = 256_em; +const RawPixel THUMBNAIL_SIZE = 512_em; const int IMAGE_TIMEOUT = 30; } @@ -50,6 +51,7 @@ CoverArt::CoverArt() : View(NUX_TRACKER_LOCATION) + , scale(1.0) , overlay_text_(nullptr) , thumb_handle_(0) , slot_handle_(0) @@ -58,6 +60,7 @@ , rotation_(0.0) { SetupViews(); + scale.changed.connect(sigc::mem_fun(this, &CoverArt::UpdateScale)); } CoverArt::~CoverArt() @@ -118,12 +121,12 @@ if (icon.IsType(G_TYPE_ICON)) { StartWaiting(); - slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded)); + slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE.CP(scale), ICON_SIZE.CP(scale), sigc::mem_fun(this, &CoverArt::IconLoaded)); } else { StartWaiting(); - slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded)); + slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, ICON_SIZE.CP(scale), ICON_SIZE.CP(scale), sigc::mem_fun(this, &CoverArt::IconLoaded)); } } else @@ -134,7 +137,7 @@ void CoverArt::GenerateImage(std::string const& uri) { - notifier_ = ThumbnailGenerator::Instance().GetThumbnail(uri, 512); + notifier_ = ThumbnailGenerator::Instance().GetThumbnail(uri, THUMBNAIL_SIZE.CP(scale)); if (notifier_) { StartWaiting(); @@ -144,7 +147,7 @@ else { StopWaiting(); - SetNoImageAvailable(); + SetNoImageAvailable(); } } @@ -168,7 +171,7 @@ SetNoImageAvailable(); return false; })); - + QueueDraw(); } @@ -186,7 +189,7 @@ GetLayout()->RemoveChildObject(overlay_text_); GetLayout()->AddView(overlay_text_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0, nux::LayoutPosition(1)); ComputeContentSize(); - + QueueDraw(); } } @@ -221,7 +224,7 @@ GetLayout()->RemoveChildObject(overlay_text_); if (pixbuf_width == pixbuf_height) - { + { // quick path for square icons texture_screenshot_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true)); } @@ -257,14 +260,16 @@ return; } - nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height); + nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, RawPixel(pixbuf_width).CP(scale), RawPixel(pixbuf_height).CP(scale)); + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale); + cairo_t* cr = cairo_graphics.GetInternalContext(); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); - float scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf); - cairo_scale(cr, scale, scale); + float size_ratio = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf); + cairo_scale(cr, size_ratio, size_ratio); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); @@ -349,7 +354,7 @@ if (image_aspect > base_apsect) { imageDest.SetHeight(float(imageDest.GetWidth()) / image_aspect); - } + } if (image_aspect < base_apsect) { imageDest.SetWidth(image_aspect * imageDest.GetHeight()); @@ -360,16 +365,10 @@ imageDest = nux::Geometry(0, 0, texture_screenshot_->GetWidth(), texture_screenshot_->GetHeight()); } - texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); texxform.SetFilter(nux::TEXFILTER_LINEAR, nux::TEXFILTER_LINEAR); - texxform.u0 = 0; - texxform.v0 = 0; - texxform.u1 = imageDest.width; - texxform.v1 = imageDest.height; - gfx_engine.QRP_1Tex(base.x + (float(base.GetWidth() - imageDest.GetWidth()) / 2), base.y + (float(base.GetHeight() - imageDest.GetHeight()) / 2), imageDest.width, @@ -384,14 +383,14 @@ { nux::TexCoordXForm texxform; texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); - texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); - texxform.min_filter = nux::TEXFILTER_LINEAR; - texxform.mag_filter = nux::TEXFILTER_LINEAR; - - nux::Geometry spin_geo(base.x + ((base.width - spin_->GetWidth()) / 2), - base.y + ((base.height - spin_->GetHeight()) / 2), - spin_->GetWidth(), - spin_->GetHeight()); + texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); + texxform.SetFilter(nux::TEXFILTER_LINEAR, nux::TEXFILTER_LINEAR); + + nux::Size spin_size(spin_->GetWidth(), spin_->GetHeight()); + nux::Geometry spin_geo(base.x + ((base.width - spin_size.width) / 2), + base.y + ((base.height - spin_size.height) / 2), + spin_size.width, + spin_size.height); // Geometry (== Rect) uses integers which were rounded above, // hence an extra 0.5 offset for odd sizes is needed // because pure floating point is not being used. @@ -425,7 +424,7 @@ } } } - + gfx_engine.GetRenderStates().SetBlend(alpha, src, dest); if (GetLayout()) @@ -449,10 +448,10 @@ overlay_text_->SetTextAlignment(StaticCairoText::NUX_ALIGN_CENTRE); overlay_text_->SetFont("Ubuntu 14"); overlay_text_->SetLines(-3); + overlay_text_->SetScale(scale); overlay_text_->SetText(_("No Image Available")); - dash::Style& style = dash::Style::Instance(); - spin_ = style.GetSearchSpinIcon(); + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); rotate_matrix_.Identity(); rotate_matrix_.Rotate_z(0.0); @@ -496,6 +495,16 @@ return false; } +void CoverArt::UpdateScale(double scale) +{ + if (overlay_text_) + overlay_text_->SetScale(scale); + + spin_ = dash::Style::Instance().GetSearchSpinIcon(scale); + + QueueDraw(); +} + } } } diff -Nru unity-7.2.2+14.04.20140714/unity-shared/CoverArt.h unity-7.2.3+14.04.20140826/unity-shared/CoverArt.h --- unity-7.2.2+14.04.20140714/unity-shared/CoverArt.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/CoverArt.h 2014-08-26 15:48:28.000000000 +0200 @@ -58,10 +58,12 @@ void SetFont(std::string const& font); + nux::Property scale; + protected: virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw); - + virtual bool AcceptKeyNavFocus() { return false; } void SetupViews(); @@ -80,6 +82,8 @@ virtual void AddProperties(debug::IntrospectionData&); private: + void UpdateScale(double scale); + nux::ObjectPtr texture_screenshot_; StaticCairoText* overlay_text_; @@ -88,10 +92,10 @@ int slot_handle_; bool stretch_image_; ThumbnailNotifier::Ptr notifier_; - + // Spinner bool waiting_; - nux::BaseTexture* spin_; + nux::ObjectPtr spin_; glib::Source::UniquePtr spinner_timeout_; glib::Source::UniquePtr frame_timeout_; nux::Matrix4 rotate_matrix_; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/DashStyle.cpp unity-7.2.3+14.04.20140826/unity-shared/DashStyle.cpp --- unity-7.2.2+14.04.20140714/unity-shared/DashStyle.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/DashStyle.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -48,8 +48,6 @@ #define DASH_WIDGETS_FILE DATADIR"/unity/themes/dash-widgets.json" -typedef nux::ObjectPtr BaseTexturePtr; - namespace unity { namespace dash @@ -92,11 +90,21 @@ } } +template +inline void get_actual_cairo_size(cairo_t* cr, T* width, T* height) +{ + double w_scale, h_scale; + auto* surface = cairo_get_target(cr); + cairo_surface_get_device_scale(surface, &w_scale, &h_scale); + *width = cairo_image_surface_get_width(surface) / w_scale; + *height = cairo_image_surface_get_height(surface) / h_scale; +} + class LazyLoadTexture { public: LazyLoadTexture(std::string const& filename, int size = -1); - nux::BaseTexture* texture(); + BaseTexturePtr const& texture(); private: void LoadTexture(); private: @@ -167,6 +175,13 @@ void UpdateFormFactor(FormFactor); void OnFontChanged(GtkSettings* object, GParamSpec* pspec); + BaseTexturePtr LoadScaledTexture(std::string const& name, double scale) + { + int w, h; + gdk_pixbuf_get_file_info((PKGDATADIR"/" + name).c_str(), &w, &h); + return TextureCache::GetDefault().FindTexture(name, RawPixel(w).CP(scale), RawPixel(h).CP(scale)); + } + // Members Style* owner_; @@ -207,32 +222,12 @@ int text_width_; int text_height_; - int number_of_columns_; LazyLoadTexture category_texture_; LazyLoadTexture category_texture_no_filters_; - LazyLoadTexture dash_bottom_texture_; - LazyLoadTexture dash_bottom_texture_mask_; - LazyLoadTexture dash_right_texture_; - LazyLoadTexture dash_right_texture_mask_; - LazyLoadTexture dash_corner_texture_; - LazyLoadTexture dash_corner_texture_mask_; - LazyLoadTexture dash_fullscreen_icon_; - LazyLoadTexture dash_left_edge_; - LazyLoadTexture dash_left_corner_; - LazyLoadTexture dash_left_corner_mask_; - LazyLoadTexture dash_left_tile_; - LazyLoadTexture dash_top_corner_; - LazyLoadTexture dash_top_corner_mask_; - LazyLoadTexture dash_top_tile_; LazyLoadTexture dash_shine_; - LazyLoadTexture search_magnify_texture_; - LazyLoadTexture search_circle_texture_; - LazyLoadTexture search_close_texture_; - LazyLoadTexture search_spin_texture_; - LazyLoadTexture information_texture_; LazyLoadTexture refine_gradient_corner_; @@ -258,28 +253,9 @@ , text_color_(nux::color::White) , text_width_(0) , text_height_(0) - , number_of_columns_(6) , category_texture_("/category_gradient.png") , category_texture_no_filters_("/category_gradient_no_refine.png") - , dash_bottom_texture_("/dash_bottom_border_tile.png") - , dash_bottom_texture_mask_("/dash_bottom_border_tile_mask.png") - , dash_right_texture_("/dash_right_border_tile.png") - , dash_right_texture_mask_("/dash_right_border_tile_mask.png") - , dash_corner_texture_("/dash_bottom_right_corner.png") - , dash_corner_texture_mask_("/dash_bottom_right_corner_mask.png") - , dash_fullscreen_icon_("/dash_fullscreen_icon.png") - , dash_left_edge_("/dash_left_edge.png") - , dash_left_corner_("/dash_bottom_left_corner.png") - , dash_left_corner_mask_("/dash_bottom_left_corner_mask.png") - , dash_left_tile_("/dash_left_tile.png") - , dash_top_corner_("/dash_top_right_corner.png") - , dash_top_corner_mask_("/dash_top_right_corner_mask.png") - , dash_top_tile_("/dash_top_tile.png") , dash_shine_("/dash_sheen.png") - , search_magnify_texture_("/search_magnify.png") - , search_circle_texture_("/search_circle.svg", 32) - , search_close_texture_("/search_close.svg", 32) - , search_spin_texture_("/search_spin.svg", 32) , information_texture_("/information_icon.svg") , refine_gradient_corner_("/refine_gradient_corner.png") , refine_gradient_dash_("/refine_gradient_dash.png") @@ -427,7 +403,8 @@ } Style::Style() - : always_maximised(false) + : columns_number(6) + , always_maximised(false) , pimpl(new Impl(this)) { if (style_instance) @@ -682,9 +659,8 @@ cairo_surface_flush(surface); pixels = cairo_image_surface_get_data(surface); - width = cairo_image_surface_get_width(surface); - height = cairo_image_surface_get_height(surface); format = cairo_image_surface_get_format(surface); + get_actual_cairo_size(cr, &width, &height); switch (format) { @@ -782,8 +758,8 @@ { double x = 0.0; double y = 0.0; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); /*double xt = 0.0; double yt = 0.0;*/ @@ -830,8 +806,11 @@ { double x = 2.0; double y = 2.0; - double w = cairo_image_surface_get_width(cairo_get_target(cr)) - 4.0; - double h = cairo_image_surface_get_height(cairo_get_target(cr)) - 4.0; + + double w, h; + get_actual_cairo_size(cr, &w, &h); + w -= 4.0; + h -= 4.0; // - these absolute values are the "cost" of getting only a SVG from design // and not a generic formular how to approximate the curve-shape, thus @@ -1212,8 +1191,10 @@ { double x = 0.0; double y = 2.0; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)) - 4.0; + + double w, h; + get_actual_cairo_size(cr, &w, &h); + h -= 4.0; // - these absolute values are the "cost" of getting only a SVG from design // and not a generic formular how to approximate the curve-shape, thus @@ -1446,9 +1427,7 @@ gchar* fontName = NULL; //double horizMargin = 10.0; - w = cairo_image_surface_get_width(cairo_get_target(cr)); - h = cairo_image_surface_get_height(cairo_get_target(cr)); - + get_actual_cairo_size(cr, &w, &h); w -= 2 * horizMargin; if (!screen) @@ -1577,6 +1556,8 @@ const unsigned char* data = NULL; int width = 0; int height = 0; + double w_scale = 0; + double h_scale = 0; int stride = 0; unsigned char* buffer = NULL; cairo_surface_t* surface = NULL; @@ -1586,9 +1567,9 @@ // aquire info about image-surface target = cairo_get_target(cr); data = cairo_image_surface_get_data(target); - width = cairo_image_surface_get_width(target); - height = cairo_image_surface_get_height(target); stride = cairo_image_surface_get_stride(target); + get_actual_cairo_size(cr, &width, &height); + cairo_surface_get_device_scale(target, &w_scale, &h_scale); cairo_format_t format = cairo_image_surface_get_format(target); // get buffer @@ -1621,6 +1602,7 @@ } // blur and blend overlay onto initial image-surface + cairo_surface_set_device_scale(surface, w_scale, h_scale); Blur(blurred_cr, blurSize); cairo_set_source_surface(cr, surface, 0.0, 0.0); old = SetBlendMode(cr, mode); @@ -1649,8 +1631,8 @@ garnish = GetButtonGarnishSize(); //ButtonOutlinePath(cr, true); - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); cairo_set_line_width(cr, pimpl->button_label_border_size_[state]); @@ -1743,8 +1725,8 @@ if (zeromargin == false) garnish = GetButtonGarnishSize(); - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); double x = garnish; double y = garnish; @@ -1854,8 +1836,8 @@ if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) return false; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); nux::Color color(nux::color::White); color.alpha = alpha; @@ -1891,10 +1873,11 @@ return false; //ButtonOutlinePathSegment(cr, segment); - double x = 0.0; - double y = 2.0; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)) - 4.0; + double x = 0.0; + double y = 2.0; + double w, h; + get_actual_cairo_size(cr, &w, &h); + h -= 4.0; if (segment == Segment::LEFT) { @@ -1969,8 +1952,9 @@ double x = 0.0; double y = 2.0; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)) - 4.0; + double w, h; + get_actual_cairo_size(cr, &w, &h); + h -= 4.0; if (segment == Segment::LEFT) { @@ -2062,8 +2046,8 @@ if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) return false; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); double x = w / 2.0; double y = 2.0; @@ -2090,8 +2074,8 @@ if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) return false; - double w = cairo_image_surface_get_width(cairo_get_target(cr)); - double h = cairo_image_surface_get_height(cairo_get_target(cr)); + double w, h; + get_actual_cairo_size(cr, &w, &h); double x = 2.0; double y = h / 2.0; @@ -2109,389 +2093,363 @@ return true; } -int Style::GetButtonGarnishSize() +BaseTexturePtr Style::GetDashBottomTile(double scale) const { - int maxBlurSize = 0; - - for (int i = 0; i < STATES; i++) - { - if (maxBlurSize < pimpl->button_label_blur_size_[i]) - maxBlurSize = pimpl->button_label_blur_size_[i]; - } - - return 2 * maxBlurSize; + return pimpl->LoadScaledTexture("dash_bottom_border_tile.png", scale); } -int Style::GetSeparatorGarnishSize() +BaseTexturePtr Style::GetDashBottomTileMask(double scale) const { - return pimpl->separator_blur_size_; + return pimpl->LoadScaledTexture("dash_bottom_border_tile_mask.png", scale); } -int Style::GetScrollbarGarnishSize() +BaseTexturePtr Style::GetDashRightTile(double scale) const { - return pimpl->scrollbar_blur_size_; + return pimpl->LoadScaledTexture("dash_right_border_tile.png", scale); } -nux::Color const& Style::GetTextColor() const +BaseTexturePtr Style::GetDashRightTileMask(double scale) const { - return pimpl->text_color_; + return pimpl->LoadScaledTexture("dash_right_border_tile_mask.png", scale); } -int Style::GetDefaultNColumns() const +BaseTexturePtr Style::GetDashLeftTile(double scale) const { - return pimpl->number_of_columns_; + return pimpl->LoadScaledTexture("dash_left_tile.png", scale); } -void Style::SetDefaultNColumns(int n_cols) +BaseTexturePtr Style::GetDashTopTile(double scale) const { - if (pimpl->number_of_columns_ == n_cols) - return; - - pimpl->number_of_columns_ = n_cols; - - columns_changed.emit(); + return pimpl->LoadScaledTexture("dash_top_tile.png", scale); } -int Style::GetTileGIconSize() const +BaseTexturePtr Style::GetDashCorner(double scale) const { - return 64; + return pimpl->LoadScaledTexture("dash_bottom_right_corner.png", scale); } -int Style::GetTileImageSize() const +BaseTexturePtr Style::GetDashCornerMask(double scale) const { - return 96; + return pimpl->LoadScaledTexture("dash_bottom_right_corner_mask.png", scale); } -int Style::GetTileWidth() const +BaseTexturePtr Style::GetDashLeftCorner(double scale) const { - return std::max(pimpl->text_width_, 150); + return pimpl->LoadScaledTexture("dash_bottom_left_corner.png", scale); } -int Style::GetTileHeight() const +BaseTexturePtr Style::GetDashLeftCornerMask(double scale) const { - return std::max(GetTileImageSize() + (pimpl->text_height_ * 2) + 15, - GetTileImageSize() + 32); // magic design numbers. + return pimpl->LoadScaledTexture("dash_bottom_left_corner_mask.png", scale); } -int Style::GetTileIconHightlightHeight() const +BaseTexturePtr Style::GetDashTopCorner(double scale) const { - return 106; + return pimpl->LoadScaledTexture("dash_top_right_corner.png", scale); } -int Style::GetTileIconHightlightWidth() const +BaseTexturePtr Style::GetDashTopCornerMask(double scale) const { - return 106; + return pimpl->LoadScaledTexture("dash_top_right_corner_mask.png", scale); } -int Style::GetHomeTileIconSize() const +BaseTexturePtr Style::GetSearchMagnifyIcon(double scale) const { - return 104; + return pimpl->LoadScaledTexture("search_magnify.svg", scale); } -int Style::GetHomeTileWidth() const +BaseTexturePtr Style::GetSearchCircleIcon(double scale) const { - return pimpl->text_width_ * 1.2; + return pimpl->LoadScaledTexture("search_circle.svg", scale); } -int Style::GetHomeTileHeight() const +BaseTexturePtr Style::GetSearchCloseIcon(double scale) const { - return GetHomeTileIconSize() + (pimpl->text_height_ * 5); + return pimpl->LoadScaledTexture("search_close.svg", scale); } -int Style::GetTextLineHeight() const +BaseTexturePtr Style::GetSearchSpinIcon(double scale) const { - return pimpl->text_height_; + return pimpl->LoadScaledTexture("search_spin.svg", scale); } -nux::BaseTexture* Style::GetCategoryBackground() -{ - return pimpl->category_texture_.texture(); -} - -nux::BaseTexture* Style::GetCategoryBackgroundNoFilters() +RawPixel Style::GetButtonGarnishSize() const { - return pimpl->category_texture_no_filters_.texture(); -} + int maxBlurSize = 0; -nux::BaseTexture* Style::GetDashBottomTile() -{ - return pimpl->dash_bottom_texture_.texture(); -} + for (int i = 0; i < STATES; i++) + { + if (maxBlurSize < pimpl->button_label_blur_size_[i]) + maxBlurSize = pimpl->button_label_blur_size_[i]; + } -nux::BaseTexture* Style::GetDashBottomTileMask() -{ - return pimpl->dash_bottom_texture_mask_.texture(); + return 2 * maxBlurSize; } -nux::BaseTexture* Style::GetDashRightTile() +RawPixel Style::GetSeparatorGarnishSize() const { - return pimpl->dash_right_texture_.texture(); + return pimpl->separator_blur_size_; } -nux::BaseTexture* Style::GetDashRightTileMask() +RawPixel Style::GetScrollbarGarnishSize() const { - return pimpl->dash_right_texture_mask_.texture(); + return pimpl->scrollbar_blur_size_; } -nux::BaseTexture* Style::GetDashCorner() +nux::Color const& Style::GetTextColor() const { - return pimpl->dash_corner_texture_.texture(); + return pimpl->text_color_; } -nux::BaseTexture* Style::GetDashCornerMask() +RawPixel Style::GetTileGIconSize() const { - return pimpl->dash_corner_texture_mask_.texture(); + return 64; } -nux::BaseTexture* Style::GetDashLeftEdge() +RawPixel Style::GetTileImageSize() const { - return pimpl->dash_left_edge_.texture(); + return 96; } -nux::BaseTexture* Style::GetDashLeftCorner() +RawPixel Style::GetTileWidth() const { - return pimpl->dash_left_corner_.texture(); + return std::max(pimpl->text_width_, 150); } -nux::BaseTexture* Style::GetDashLeftCornerMask() +RawPixel Style::GetTileHeight() const { - return pimpl->dash_left_corner_mask_.texture(); + return std::max(GetTileImageSize() + (pimpl->text_height_ * 2) + 15, + GetTileImageSize() + 32); // magic design numbers. } -nux::BaseTexture* Style::GetDashLeftTile() +RawPixel Style::GetTileIconHightlightHeight() const { - return pimpl->dash_left_tile_.texture(); + return 106; } -nux::BaseTexture* Style::GetDashTopCorner() +RawPixel Style::GetTileIconHightlightWidth() const { - return pimpl->dash_top_corner_.texture(); + return 106; } -nux::BaseTexture* Style::GetDashTopCornerMask() +RawPixel Style::GetHomeTileIconSize() const { - return pimpl->dash_top_corner_mask_.texture(); + return 104; } -nux::BaseTexture* Style::GetDashTopTile() +RawPixel Style::GetHomeTileWidth() const { - return pimpl->dash_top_tile_.texture(); + return pimpl->text_width_ * 1.2; } -nux::BaseTexture* Style::GetDashFullscreenIcon() +RawPixel Style::GetHomeTileHeight() const { - return pimpl->dash_fullscreen_icon_.texture(); + return GetHomeTileIconSize() + (pimpl->text_height_ * 5); } -nux::BaseTexture* Style::GetSearchMagnifyIcon() +RawPixel Style::GetTextLineHeight() const { - return pimpl->search_magnify_texture_.texture(); + return pimpl->text_height_; } -nux::BaseTexture* Style::GetSearchCircleIcon() -{ - return pimpl->search_circle_texture_.texture(); -} -nux::BaseTexture* Style::GetSearchCloseIcon() +BaseTexturePtr const& Style::GetCategoryBackground() const { - return pimpl->search_close_texture_.texture(); + return pimpl->category_texture_.texture(); } -nux::BaseTexture* Style::GetSearchSpinIcon() +BaseTexturePtr const& Style::GetCategoryBackgroundNoFilters() const { - return pimpl->search_spin_texture_.texture(); + return pimpl->category_texture_no_filters_.texture(); } -nux::BaseTexture* Style::GetInformationTexture() +BaseTexturePtr const& Style::GetInformationTexture() const { return pimpl->information_texture_.texture(); } -nux::BaseTexture* Style::GetRefineTextureCorner() +BaseTexturePtr const& Style::GetRefineTextureCorner() const { return pimpl->refine_gradient_corner_.texture(); } -nux::BaseTexture* Style::GetRefineTextureDash() +BaseTexturePtr const& Style::GetRefineTextureDash() const { return pimpl->refine_gradient_dash_.texture(); } -nux::BaseTexture* Style::GetGroupUnexpandIcon() +BaseTexturePtr const& Style::GetGroupUnexpandIcon() const { return pimpl->group_unexpand_texture_.texture(); } -nux::BaseTexture* Style::GetGroupExpandIcon() +BaseTexturePtr const& Style::GetGroupExpandIcon() const { return pimpl->group_expand_texture_.texture(); } -nux::BaseTexture* Style::GetStarDeselectedIcon() +BaseTexturePtr const& Style::GetStarDeselectedIcon() const { return pimpl->star_deselected_texture_.texture(); } -nux::BaseTexture* Style::GetStarSelectedIcon() +BaseTexturePtr const& Style::GetStarSelectedIcon() const { return pimpl->star_selected_texture_.texture(); } -nux::BaseTexture* Style::GetStarHighlightIcon() +BaseTexturePtr const& Style::GetStarHighlightIcon() const { return pimpl->star_highlight_texture_.texture(); } -nux::BaseTexture* Style::GetDashShine() +BaseTexturePtr const& Style::GetDashShine() const { return pimpl->dash_shine_.texture(); } -int Style::GetDashBottomTileHeight() const +RawPixel Style::GetDashBottomTileHeight() const { return 30; } -int Style::GetDashRightTileWidth() const +RawPixel Style::GetDashRightTileWidth() const { return 30; } -int Style::GetVSeparatorSize() const +RawPixel Style::GetVSeparatorSize() const { return 1; } -int Style::GetHSeparatorSize() const +RawPixel Style::GetHSeparatorSize() const { return 1; - } -int Style::GetFilterBarWidth() const +RawPixel Style::GetFilterBarWidth() const { return 300; } - -int Style::GetFilterBarLeftPadding() const +RawPixel Style::GetFilterBarLeftPadding() const { return 5; } -int Style::GetFilterBarRightPadding() const +RawPixel Style::GetFilterBarRightPadding() const { return 5; } -int Style::GetDashViewTopPadding() const +RawPixel Style::GetDashViewTopPadding() const { return 10; } -int Style::GetSearchBarLeftPadding() const +RawPixel Style::GetSearchBarLeftPadding() const { return 10; } -int Style::GetSearchBarRightPadding() const +RawPixel Style::GetSearchBarRightPadding() const { return 10; } -int Style::GetSearchBarHeight() const +RawPixel Style::GetSearchBarHeight() const { return 42; } -int Style::GetFilterResultsHighlightRightPadding() const +RawPixel Style::GetFilterResultsHighlightRightPadding() const { return 5; } -int Style::GetFilterResultsHighlightLeftPadding() const +RawPixel Style::GetFilterResultsHighlightLeftPadding() const { return 5; } -int Style::GetFilterBarTopPadding() const +RawPixel Style::GetFilterBarTopPadding() const { return 10; } -int Style::GetFilterHighlightPadding() const +RawPixel Style::GetFilterHighlightPadding() const { return 2; } -int Style::GetSpaceBetweenFilterWidgets() const +RawPixel Style::GetSpaceBetweenFilterWidgets() const { return 12; } -int Style::GetAllButtonHeight() const +RawPixel Style::GetAllButtonHeight() const { return 30; } -int Style::GetFilterButtonHeight() const +RawPixel Style::GetFilterButtonHeight() const { return 30; } -int Style::GetSpaceBetweenScopeAndFilters() const +RawPixel Style::GetSpaceBetweenScopeAndFilters() const { return 10; } -int Style::GetFilterViewRightPadding() const +RawPixel Style::GetFilterViewRightPadding() const { return 10; } -int Style::GetScrollbarWidth() const +RawPixel Style::GetScrollbarWidth() const { return 3; } -int Style::GetCategoryIconSize() const +RawPixel Style::GetCategoryIconSize() const { return 22; } -int Style::GetCategoryHighlightHeight() const +RawPixel Style::GetCategoryHighlightHeight() const { return 24; } -int Style::GetPlacesGroupTopSpace() const +RawPixel Style::GetPlacesGroupTopSpace() const { return 7; } -int Style::GetPlacesGroupResultTopPadding() const +RawPixel Style::GetPlacesGroupResultTopPadding() const { return 2; } -int Style::GetPlacesGroupResultLeftPadding() const +RawPixel Style::GetPlacesGroupResultLeftPadding() const { return 25; } -int Style::GetCategoryHeaderLeftPadding() const +RawPixel Style::GetCategoryHeaderLeftPadding() const { return 19; } -int Style::GetCategorySeparatorLeftPadding() const +RawPixel Style::GetCategorySeparatorLeftPadding() const { return 15; } -int Style::GetCategorySeparatorRightPadding() const +RawPixel Style::GetCategorySeparatorRightPadding() const { return 15; } @@ -2505,11 +2463,11 @@ { } -nux::BaseTexture* LazyLoadTexture::texture() +BaseTexturePtr const& LazyLoadTexture::texture() { if (!texture_) LoadTexture(); - return texture_.GetPointer(); + return texture_; } void LazyLoadTexture::LoadTexture() diff -Nru unity-7.2.2+14.04.20140714/unity-shared/DashStyle.h unity-7.2.3+14.04.20140826/unity-shared/DashStyle.h --- unity-7.2.2+14.04.20140714/unity-shared/DashStyle.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/DashStyle.h 2014-08-26 15:48:28.000000000 +0200 @@ -37,6 +37,7 @@ { namespace dash { +typedef nux::ObjectPtr BaseTexturePtr; enum class StockIcon { CHECKMARK, @@ -135,11 +136,11 @@ virtual bool SeparatorHoriz(cairo_t* cr); - virtual int GetButtonGarnishSize(); + RawPixel GetButtonGarnishSize() const; - virtual int GetSeparatorGarnishSize(); + RawPixel GetSeparatorGarnishSize() const; - virtual int GetScrollbarGarnishSize(); + RawPixel GetScrollbarGarnishSize() const; void Blur(cairo_t* cr, int size); @@ -153,111 +154,104 @@ nux::Color const& GetTextColor() const; - // TODO nux::Property - int GetDefaultNColumns() const; - void SetDefaultNColumns(int n_cols); - sigc::signal columns_changed; - - int GetTileGIconSize() const; - int GetTileImageSize() const; - int GetTileWidth() const; - int GetTileHeight() const; - int GetTileIconHightlightHeight() const; - int GetTileIconHightlightWidth() const; - - int GetHomeTileIconSize() const; - int GetHomeTileWidth() const; - int GetHomeTileHeight() const; - - int GetTextLineHeight() const; - - nux::BaseTexture* GetCategoryBackground(); - nux::BaseTexture* GetCategoryBackgroundNoFilters(); - nux::BaseTexture* GetDashBottomTile(); - nux::BaseTexture* GetDashBottomTileMask(); - nux::BaseTexture* GetDashRightTile(); - nux::BaseTexture* GetDashRightTileMask(); - nux::BaseTexture* GetDashCorner(); - nux::BaseTexture* GetDashCornerMask(); - nux::BaseTexture* GetDashFullscreenIcon(); - nux::BaseTexture* GetDashLeftEdge(); - nux::BaseTexture* GetDashLeftCorner(); - nux::BaseTexture* GetDashLeftCornerMask(); - nux::BaseTexture* GetDashLeftTile(); - nux::BaseTexture* GetDashTopCorner(); - nux::BaseTexture* GetDashTopCornerMask(); - nux::BaseTexture* GetDashTopTile(); - - int GetDashBottomTileHeight() const; - int GetDashRightTileWidth() const; - - nux::BaseTexture* GetDashShine(); - - nux::BaseTexture* GetSearchMagnifyIcon(); - nux::BaseTexture* GetSearchCircleIcon(); - nux::BaseTexture* GetSearchCloseIcon(); - nux::BaseTexture* GetSearchSpinIcon(); - - nux::BaseTexture* GetGroupUnexpandIcon(); - nux::BaseTexture* GetGroupExpandIcon(); - - nux::BaseTexture* GetStarDeselectedIcon(); - nux::BaseTexture* GetStarSelectedIcon(); - nux::BaseTexture* GetStarHighlightIcon(); - - nux::BaseTexture* GetInformationTexture(); - - nux::BaseTexture* GetRefineTextureCorner(); - nux::BaseTexture* GetRefineTextureDash(); - + RawPixel GetTileGIconSize() const; + RawPixel GetTileImageSize() const; + RawPixel GetTileWidth() const; + RawPixel GetTileHeight() const; + RawPixel GetTileIconHightlightHeight() const; + RawPixel GetTileIconHightlightWidth() const; + + RawPixel GetHomeTileIconSize() const; + RawPixel GetHomeTileWidth() const; + RawPixel GetHomeTileHeight() const; + + RawPixel GetTextLineHeight() const; + + BaseTexturePtr const& GetCategoryBackground() const; + BaseTexturePtr const& GetCategoryBackgroundNoFilters() const; + + BaseTexturePtr GetDashBottomTile(double scale) const; + BaseTexturePtr GetDashBottomTileMask(double scale) const; + BaseTexturePtr GetDashRightTile(double scale) const; + BaseTexturePtr GetDashRightTileMask(double scale) const; + BaseTexturePtr GetDashLeftTile(double scale) const; + BaseTexturePtr GetDashTopTile(double scale) const; + + BaseTexturePtr GetDashCorner(double scale) const; + BaseTexturePtr GetDashCornerMask(double scale) const; + BaseTexturePtr GetDashLeftCorner(double scale) const; + BaseTexturePtr GetDashLeftCornerMask(double scale) const; + BaseTexturePtr GetDashTopCorner(double scale) const; + BaseTexturePtr GetDashTopCornerMask(double scale) const; + + RawPixel GetDashBottomTileHeight() const; + RawPixel GetDashRightTileWidth() const; + + BaseTexturePtr const& GetDashShine() const; + + BaseTexturePtr GetSearchMagnifyIcon(double scale) const; + BaseTexturePtr GetSearchCircleIcon(double scale) const; + BaseTexturePtr GetSearchCloseIcon(double scale) const; + BaseTexturePtr GetSearchSpinIcon(double scale) const; + + BaseTexturePtr const& GetGroupUnexpandIcon() const; + BaseTexturePtr const& GetGroupExpandIcon() const; + + BaseTexturePtr const& GetStarDeselectedIcon() const; + BaseTexturePtr const& GetStarSelectedIcon() const; + BaseTexturePtr const& GetStarHighlightIcon() const; + + BaseTexturePtr const& GetInformationTexture() const; + + BaseTexturePtr const& GetRefineTextureCorner() const; + BaseTexturePtr const& GetRefineTextureDash() const; + // Returns the width of the separator between the dash and the launcher. - int GetVSeparatorSize() const; + RawPixel GetVSeparatorSize() const; // Returns the height of the separator between the dash and the top panel. - int GetHSeparatorSize() const; + RawPixel GetHSeparatorSize() const; // Practically it is the space between the top border of the dash and the searchbar. - int GetDashViewTopPadding() const; + RawPixel GetDashViewTopPadding() const; + - // Search bar - int GetSearchBarLeftPadding() const; - int GetSearchBarRightPadding() const; - int GetSearchBarHeight() const; - int GetFilterResultsHighlightRightPadding() const; - int GetFilterResultsHighlightLeftPadding() const; + RawPixel GetSearchBarLeftPadding() const; + RawPixel GetSearchBarRightPadding() const; + RawPixel GetSearchBarHeight() const; // Filter bar - int GetFilterBarTopPadding() const; - int GetFilterHighlightPadding() const; - int GetSpaceBetweenFilterWidgets() const; - int GetAllButtonHeight() const; - int GetFilterBarLeftPadding() const; - int GetFilterBarRightPadding() const; - int GetFilterBarWidth() const; - int GetFilterButtonHeight() const; - int GetFilterViewRightPadding() const; + RawPixel GetFilterResultsHighlightRightPadding() const; + RawPixel GetFilterResultsHighlightLeftPadding() const; + RawPixel GetFilterBarTopPadding() const; + RawPixel GetFilterHighlightPadding() const; + RawPixel GetSpaceBetweenFilterWidgets() const; + RawPixel GetAllButtonHeight() const; + RawPixel GetFilterBarLeftPadding() const; + RawPixel GetFilterBarRightPadding() const; + RawPixel GetFilterBarWidth() const; + RawPixel GetFilterButtonHeight() const; + RawPixel GetFilterViewRightPadding() const; - int GetSpaceBetweenScopeAndFilters() const; + RawPixel GetSpaceBetweenScopeAndFilters() const; // Scrollbars - int GetScrollbarWidth() const; + RawPixel GetScrollbarWidth() const; // Places Group - int GetCategoryIconSize() const; - int GetCategoryHighlightHeight() const; - int GetPlacesGroupTopSpace() const; - int GetPlacesGroupResultTopPadding() const; - int GetPlacesGroupResultLeftPadding() const; - int GetCategoryHeaderLeftPadding() const; - int GetCategorySeparatorLeftPadding() const; - int GetCategorySeparatorRightPadding() const; - - bool GetUseBlur() const; - + RawPixel GetCategoryIconSize() const; + RawPixel GetCategoryHighlightHeight() const; + RawPixel GetPlacesGroupTopSpace() const; + RawPixel GetPlacesGroupResultTopPadding() const; + RawPixel GetPlacesGroupResultLeftPadding() const; + RawPixel GetCategoryHeaderLeftPadding() const; + RawPixel GetCategorySeparatorLeftPadding() const; + RawPixel GetCategorySeparatorRightPadding() const; sigc::signal changed; + nux::Property columns_number; nux::Property always_maximised; nux::Property preview_mode; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/DashStyleInterface.h unity-7.2.3+14.04.20140826/unity-shared/DashStyleInterface.h --- unity-7.2.2+14.04.20140714/unity-shared/DashStyleInterface.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/DashStyleInterface.h 2014-08-26 15:48:28.000000000 +0200 @@ -21,10 +21,12 @@ #define UNITYSHELL_DASH_STYLE_INTERFACE_H #include +#include "unity-shared/RawPixel.h" namespace nux { class AbstractPaintLayer; class BaseTexture; + template class ObjectPtr; } namespace unity { @@ -37,17 +39,17 @@ virtual nux::AbstractPaintLayer* FocusOverlay(int width, int height) = 0; - virtual nux::BaseTexture* GetCategoryBackground() = 0; - virtual nux::BaseTexture* GetCategoryBackgroundNoFilters() = 0; + virtual nux::ObjectPtr const& GetCategoryBackground() const = 0; + virtual nux::ObjectPtr const& GetCategoryBackgroundNoFilters() const = 0; - virtual nux::BaseTexture* GetGroupUnexpandIcon() = 0; - virtual nux::BaseTexture* GetGroupExpandIcon() = 0; + virtual nux::ObjectPtr const& GetGroupUnexpandIcon() const = 0; + virtual nux::ObjectPtr const& GetGroupExpandIcon() const = 0; - virtual int GetCategoryIconSize() const = 0; - virtual int GetCategoryHeaderLeftPadding() const = 0; - virtual int GetPlacesGroupTopSpace() const = 0; - virtual int GetPlacesGroupResultTopPadding() const = 0; - virtual int GetPlacesGroupResultLeftPadding() const = 0; + virtual RawPixel GetCategoryIconSize() const = 0; + virtual RawPixel GetCategoryHeaderLeftPadding() const = 0; + virtual RawPixel GetPlacesGroupTopSpace() const = 0; + virtual RawPixel GetPlacesGroupResultTopPadding() const = 0; + virtual RawPixel GetPlacesGroupResultLeftPadding() const = 0; }; } diff -Nru unity-7.2.2+14.04.20140714/unity-shared/IconTexture.cpp unity-7.2.3+14.04.20140826/unity-shared/IconTexture.cpp --- unity-7.2.2+14.04.20140714/unity-shared/IconTexture.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/IconTexture.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -226,37 +226,27 @@ if (_draw_mode == DrawMode::STRETCH_WITH_ASPECT) { nux::Geometry imageDest = geo; - - float geo_apsect = float(geo.GetWidth()) / geo.GetHeight(); + + float geo_apsect = float(geo.width) / geo.width; float image_aspect = float(_texture_cached->GetWidth()) / _texture_cached->GetHeight(); if (image_aspect > geo_apsect) { imageDest.SetHeight(float(imageDest.GetWidth()) / image_aspect); - } + } if (image_aspect < geo_apsect) { imageDest.SetWidth(image_aspect * imageDest.GetHeight()); } - else - { - imageDest = nux::Geometry(0, 0, _texture_cached->GetWidth(), _texture_cached->GetHeight()); - } texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); texxform.SetFilter(nux::TEXFILTER_LINEAR, nux::TEXFILTER_LINEAR); - texxform.u0 = 0; - texxform.v0 = 0; - texxform.u1 = imageDest.width; - texxform.v1 = imageDest.height; - - int border_width = 1; - GfxContext.QRP_1Tex(geo.x + (float(geo.GetWidth() - imageDest.GetWidth()) / 2) + border_width, - geo.y + (float(geo.GetHeight() - imageDest.GetHeight()) / 2) + border_width, - imageDest.width - (border_width * 2), - imageDest.height - (border_width * 2), + GfxContext.QRP_1Tex(geo.x + (float(geo.GetWidth() - imageDest.GetWidth()) / 2), + geo.y + (float(geo.GetHeight() - imageDest.GetHeight()) / 2), + imageDest.width, + imageDest.height, _texture_cached.GetPointer()->GetDeviceTexture(), texxform, col); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/OverlayRenderer.cpp unity-7.2.3+14.04.20140826/unity-shared/OverlayRenderer.cpp --- unity-7.2.2+14.04.20140714/unity-shared/OverlayRenderer.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/OverlayRenderer.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -35,8 +35,19 @@ DECLARE_LOGGER(logger, "unity.overlayrenderer"); namespace { -const int INNER_CORNER_RADIUS = 5; -const int EXCESS_BORDER = 10; +const RawPixel INNER_CORNER_RADIUS = 5_em; +const RawPixel EXCESS_BORDER = 10_em; + +const RawPixel LEFT_CORNER_OFFSET = 10_em; +const RawPixel TOP_CORNER_OFFSET = 10_em; + +const nux::Color LINE_COLOR = nux::color::White * 0.07f; +const RawPixel GRADIENT_HEIGHT = 50_em; +const RawPixel VERTICAL_PADDING = 20_em; + +// Now that we mask the corners of the dash, +// draw longer lines to fill the minimal gaps +const RawPixel CORNER_OVERLAP = 3_em; } // Impl class @@ -45,8 +56,9 @@ public: OverlayRendererImpl(OverlayRenderer *parent_); - void ComputeLargerGeometries(nux::Geometry& larger_absolute_geo, nux::Geometry& larger_content_geo, bool force_edges); void UpdateTextures(); + void LoadScaledTextures(); + void ComputeLargerGeometries(nux::Geometry& larger_absolute_geo, nux::Geometry& larger_content_geo, bool force_edges); void OnBgColorChanged(nux::Color const& new_color); void Draw(nux::GraphicsEngine& gfx_context, nux::Geometry const& content_geo, nux::Geometry const& absolute_geo, nux::Geometry const& geometry, bool force_draw); @@ -63,6 +75,20 @@ std::unique_ptr bg_refine_gradient_; + nux::ObjectPtr bottom_texture_; + nux::ObjectPtr bottom_texture_mask_; + nux::ObjectPtr right_texture_; + nux::ObjectPtr right_texture_mask_; + nux::ObjectPtr left_texture_; + nux::ObjectPtr top_texture_; + + nux::ObjectPtr corner_; + nux::ObjectPtr corner_mask_; + nux::ObjectPtr left_corner_; + nux::ObjectPtr left_corner_mask_; + nux::ObjectPtr top_corner_; + nux::ObjectPtr top_corner_mask_; + // temporary variable that stores the number of backgrounds we have rendered int bgs; bool visible; @@ -88,7 +114,29 @@ : visible(false) , parent(parent_) { + parent->scale = Settings::Instance().em()->DPIScale(); + parent->scale.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures))); UpdateTextures(); + LoadScaledTextures(); +} + +void OverlayRendererImpl::LoadScaledTextures() +{ + double scale = parent->scale; + auto& style = dash::Style::Instance(); + bottom_texture_ = style.GetDashBottomTile(scale); + bottom_texture_mask_ = style.GetDashBottomTileMask(scale); + right_texture_ = style.GetDashRightTile(scale); + right_texture_mask_ = style.GetDashRightTileMask(scale); + left_texture_ = style.GetDashLeftTile(scale); + top_texture_ = style.GetDashTopTile(scale); + + corner_ = style.GetDashCorner(scale); + corner_mask_ = style.GetDashCornerMask(scale); + left_corner_ = style.GetDashLeftCorner(scale); + left_corner_mask_ = style.GetDashLeftCornerMask(scale); + top_corner_ = style.GetDashTopCorner(scale); + top_corner_mask_ = style.GetDashTopCornerMask(scale); } void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color) @@ -133,9 +181,10 @@ } bg_darken_layer_ = std::make_shared(darken_colour, false, rop); - bg_shine_texture_ = unity::dash::Style::Instance().GetDashShine()->GetDeviceTexture(); + bg_shine_texture_ = dash::Style::Instance().GetDashShine()->GetDeviceTexture(); + + auto const& bg_refine_tex = dash::Style::Instance().GetRefineTextureDash(); - nux::BaseTexture* bg_refine_tex = unity::dash::Style::Instance().GetRefineTextureDash(); if (bg_refine_tex) { rop.Blend = true; @@ -397,7 +446,7 @@ void OverlayRendererImpl::ComputeLargerGeometries(nux::Geometry& larger_absolute_geo, nux::Geometry& larger_content_geo, bool force_edges) { - int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0; + int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER.CP(parent->scale) : 0; larger_absolute_geo.OffsetSize(excess_border, excess_border); larger_content_geo.OffsetSize(excess_border, excess_border); } @@ -427,6 +476,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry const& content_geo, nux::Geometry const& absolute_geo, nux::Geometry const& geometry, bool force_edges) { nux::Geometry geo(content_geo); + double scale = parent->scale; nux::Geometry larger_content_geo = content_geo; nux::Geometry larger_absolute_geo = absolute_geo; @@ -480,32 +530,22 @@ gfx_context.GetRenderStates().SetBlend(true); gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); - const double line_opacity = 0.1f; - const int gradient_height = 50; - const int vertical_padding = 20; - - // Now that we mask the corners of the dash, - // draw longer lines to fill the minimal gaps - const int corner_overlap = 3; - - nux::Color line_color = nux::color::White * line_opacity; - // Vertical lancher/dash separator nux::GetPainter().Paint2DQuadColor(gfx_context, nux::Geometry(geometry.x, - geometry.y + vertical_padding, - style.GetVSeparatorSize(), - gradient_height), + geometry.y + VERTICAL_PADDING.CP(scale), + style.GetVSeparatorSize().CP(scale), + GRADIENT_HEIGHT.CP(scale)), nux::color::Transparent, - line_color * 0.7f, // less opacity - line_color * 0.7f, // less opacity + LINE_COLOR, + LINE_COLOR, nux::color::Transparent); nux::GetPainter().Draw2DLine(gfx_context, geometry.x, - geometry.y + vertical_padding + gradient_height, - style.GetVSeparatorSize(), - geometry.y + content_geo.height + INNER_CORNER_RADIUS + corner_overlap, - line_color * 0.7f); // less opacity + geometry.y + VERTICAL_PADDING.CP(scale) + GRADIENT_HEIGHT.CP(scale), + style.GetVSeparatorSize().CP(scale), + geometry.y + content_geo.height + INNER_CORNER_RADIUS.CP(scale) + CORNER_OVERLAP.CP(scale), + LINE_COLOR); //Draw the background bg_darken_layer_->SetGeometry(larger_content_geo); @@ -544,9 +584,9 @@ int gradien_width = std::min(bg_refine_gradient_->GetDeviceTexture()->GetWidth(), larger_content_geo.width); int gradien_height = std::min(bg_refine_gradient_->GetDeviceTexture()->GetHeight(), larger_content_geo.height); - nux::Geometry geo_refine(larger_content_geo.x + larger_content_geo.width - gradien_width, + nux::Geometry geo_refine(larger_content_geo.x + larger_content_geo.width - gradien_width, larger_content_geo.y, - gradien_width, + gradien_width, gradien_height); bg_refine_gradient_->SetGeometry(geo_refine); @@ -565,36 +605,38 @@ gfx_context.GetRenderStates().SetBlend(true); gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); - dash::Style& style = dash::Style::Instance(); - nux::BaseTexture* bottom = style.GetDashBottomTile(); - nux::BaseTexture* bottom_mask = style.GetDashBottomTileMask(); - nux::BaseTexture* right = style.GetDashRightTile(); - nux::BaseTexture* right_mask = style.GetDashRightTileMask(); - nux::BaseTexture* corner = style.GetDashCorner(); - nux::BaseTexture* corner_mask = style.GetDashCornerMask(); - nux::BaseTexture* left_corner = style.GetDashLeftCorner(); - nux::BaseTexture* left_corner_mask = style.GetDashLeftCornerMask(); - nux::BaseTexture* left_tile = style.GetDashLeftTile(); - nux::BaseTexture* top_corner = style.GetDashTopCorner(); - nux::BaseTexture* top_corner_mask = style.GetDashTopCornerMask(); - nux::BaseTexture* top_tile = style.GetDashTopTile(); nux::TexCoordXForm texxform; + auto const& bottom = bottom_texture_; + auto const& bottom_mask = bottom_texture_mask_; + auto const& right = right_texture_; + auto const& right_mask = right_texture_mask_; + auto const& corner = corner_; + auto const& corner_mask = corner_mask_; + auto const& left_corner = left_corner_; + auto const& left_corner_mask = left_corner_mask_; + auto const& left_tile = left_texture_; + auto const& top_corner = top_corner_; + auto const& top_corner_mask = top_corner_mask_; + auto const& top_tile = top_texture_; + + int left_corner_offset = LEFT_CORNER_OFFSET.CP(scale); + int top_corner_offset = TOP_CORNER_OFFSET.CP(scale); + nux::Size corner_size(corner->GetWidth(), corner->GetHeight()); + nux::Size top_corner_size(top_corner->GetWidth(), top_corner->GetHeight()); + nux::Size left_corner_size(left_corner->GetWidth(), left_corner->GetHeight()); - int left_corner_offset = 10; - int top_corner_offset = 10; - - geo.width += corner->GetWidth() - 10; - geo.height += corner->GetHeight() - 10; + geo.width += corner_size.width - left_corner_offset; + geo.height += corner_size.height - top_corner_offset; { // Corner texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); // Selectively erase blur region in the curbe - gfx_context.QRP_ColorModTexAlpha(geo.x + (geo.width - corner->GetWidth()), - geo.y + (geo.height - corner->GetHeight()), - corner->GetWidth(), - corner->GetHeight(), + gfx_context.QRP_ColorModTexAlpha(geo.x + (geo.width - corner_size.width), + geo.y + (geo.height - corner_size.height), + corner_size.width, + corner_size.height, corner_mask->GetDeviceTexture(), texxform, nux::color::Black); @@ -602,10 +644,10 @@ // Write correct alpha gfx_context.GetRenderStates().SetBlend(false); gfx_context.GetRenderStates().SetColorMask(false, false, false, true); - RenderInverseMask(gfx_context, geo.x + (geo.width - corner->GetWidth()), - geo.y + (geo.height - corner->GetHeight()), - corner->GetWidth(), - corner->GetHeight(), + RenderInverseMask(gfx_context, geo.x + (geo.width - corner_size.width), + geo.y + (geo.height - corner_size.height), + corner_size.width, + corner_size.height, corner_mask->GetDeviceTexture(), texxform, nux::color::White); @@ -614,24 +656,24 @@ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); gfx_context.GetRenderStates().SetColorMask(true, true, true, true); - gfx_context.QRP_1Tex(geo.x + (geo.width - corner->GetWidth()), - geo.y + (geo.height - corner->GetHeight()), - corner->GetWidth(), - corner->GetHeight(), + gfx_context.QRP_1Tex(geo.x + (geo.width - corner_size.width), + geo.y + (geo.height - corner_size.height), + corner_size.width, + corner_size.height, corner->GetDeviceTexture(), texxform, nux::color::White); } { // Bottom repeated texture - int real_width = geo.width - (left_corner->GetWidth() - left_corner_offset) - corner->GetWidth(); + int real_width = geo.width - (left_corner_size.width - left_corner_offset) - corner_size.width; int offset = real_width % bottom->GetWidth(); texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); // Selectively erase blur region in the curbe - gfx_context.QRP_ColorModTexAlpha(left_corner->GetWidth() - left_corner_offset - offset, + gfx_context.QRP_ColorModTexAlpha(left_corner_size.width - left_corner_offset - offset, geo.y + (geo.height - bottom->GetHeight()), real_width + offset, bottom->GetHeight(), @@ -642,7 +684,7 @@ // Write correct alpha gfx_context.GetRenderStates().SetBlend(false); gfx_context.GetRenderStates().SetColorMask(false, false, false, true); - RenderInverseMask(gfx_context, left_corner->GetWidth() - left_corner_offset - offset, + RenderInverseMask(gfx_context, left_corner_size.width - left_corner_offset - offset, geo.y + (geo.height - bottom->GetHeight()), real_width + offset, bottom->GetHeight(), @@ -654,7 +696,7 @@ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); gfx_context.GetRenderStates().SetColorMask(true, true, true, true); - gfx_context.QRP_1Tex(left_corner->GetWidth() - left_corner_offset - offset, + gfx_context.QRP_1Tex(left_corner_size.width - left_corner_offset - offset, geo.y + (geo.height - bottom->GetHeight()), real_width + offset, bottom->GetHeight(), @@ -669,9 +711,9 @@ // Selectively erase blur region in the curbe gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset, - geo.y + (geo.height - left_corner->GetHeight()), - left_corner->GetWidth(), - left_corner->GetHeight(), + geo.y + (geo.height - left_corner_size.height), + left_corner_size.width, + left_corner_size.height, left_corner_mask->GetDeviceTexture(), texxform, nux::color::Black); @@ -680,9 +722,9 @@ gfx_context.GetRenderStates().SetBlend(false); gfx_context.GetRenderStates().SetColorMask(false, false, false, true); RenderInverseMask(gfx_context, geo.x - left_corner_offset, - geo.y + (geo.height - left_corner->GetHeight()), - left_corner->GetWidth(), - left_corner->GetHeight(), + geo.y + (geo.height - left_corner_size.height), + left_corner_size.width, + left_corner_size.height, left_corner_mask->GetDeviceTexture(), texxform, nux::color::White); @@ -692,9 +734,9 @@ gfx_context.GetRenderStates().SetColorMask(true, true, true, true); gfx_context.QRP_1Tex(geo.x - left_corner_offset, - geo.y + (geo.height - left_corner->GetHeight()), - left_corner->GetWidth(), - left_corner->GetHeight(), + geo.y + (geo.height - left_corner_size.height), + left_corner_size.width, + left_corner_size.height, left_corner->GetDeviceTexture(), texxform, nux::color::White); @@ -708,7 +750,7 @@ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); - gfx_context.QRP_1Tex(geo.x - 10, + gfx_context.QRP_1Tex(geo.x - left_corner_offset, geo.y + geo.height, left_tile->GetWidth(), real_height + offset, @@ -723,9 +765,9 @@ // Selectively erase blur region in the curbe gfx_context.QRP_ColorModTexAlpha(geo.x + geo.width - right->GetWidth(), - geo.y + top_corner->GetHeight() - top_corner_offset, + geo.y + top_corner_size.height - top_corner_offset, right->GetWidth(), - geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset), + geo.height - corner_size.height - (top_corner_size.height - top_corner_offset), right_mask->GetDeviceTexture(), texxform, nux::color::Black); @@ -734,9 +776,9 @@ gfx_context.GetRenderStates().SetBlend(false); gfx_context.GetRenderStates().SetColorMask(false, false, false, true); RenderInverseMask(gfx_context, geo.x + geo.width - right->GetWidth(), - geo.y + top_corner->GetHeight() - top_corner_offset, + geo.y + top_corner_size.height - top_corner_offset, right->GetWidth(), - geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset), + geo.height - corner_size.height - (top_corner_size.height - top_corner_offset), right_mask->GetDeviceTexture(), texxform, nux::color::White); @@ -746,9 +788,9 @@ gfx_context.GetRenderStates().SetColorMask(true, true, true, true); gfx_context.QRP_1Tex(geo.x + geo.width - right->GetWidth(), - geo.y + top_corner->GetHeight() - top_corner_offset, + geo.y + top_corner_size.height - top_corner_offset, right->GetWidth(), - geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset), + geo.height - corner_size.height - (top_corner_size.height - top_corner_offset), right->GetDeviceTexture(), texxform, nux::color::White); @@ -761,8 +803,8 @@ // Selectively erase blur region in the curbe gfx_context.QRP_ColorModTexAlpha(geo.x + geo.width - right->GetWidth(), geo.y - top_corner_offset, - top_corner->GetWidth(), - top_corner->GetHeight(), + top_corner_size.width, + top_corner_size.height, top_corner_mask->GetDeviceTexture(), texxform, nux::color::Black); @@ -772,8 +814,8 @@ gfx_context.GetRenderStates().SetColorMask(false, false, false, true); RenderInverseMask(gfx_context, geo.x + geo.width - right->GetWidth(), geo.y - top_corner_offset, - top_corner->GetWidth(), - top_corner->GetHeight(), + top_corner_size.width, + top_corner_size.height, top_corner_mask->GetDeviceTexture(), texxform, nux::color::White); @@ -783,8 +825,8 @@ gfx_context.GetRenderStates().SetColorMask(true, true, true, true); gfx_context.QRP_1Tex(geo.x + geo.width - right->GetWidth(), geo.y - top_corner_offset, - top_corner->GetWidth(), - top_corner->GetHeight(), + top_corner_size.width, + top_corner_size.height, top_corner->GetDeviceTexture(), texxform, nux::color::White); @@ -796,7 +838,7 @@ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); gfx_context.QRP_1Tex(geo.x + geo.width, - geo.y - 10, + geo.y - top_corner_offset, geometry.width - (geo.x + geo.width), top_tile->GetHeight(), top_tile->GetDeviceTexture(), @@ -925,9 +967,7 @@ OverlayRenderer::OverlayRenderer() : pimpl_(new OverlayRendererImpl(this)) -{ - -} +{} OverlayRenderer::~OverlayRenderer() diff -Nru unity-7.2.2+14.04.20140714/unity-shared/OverlayRenderer.h unity-7.2.3+14.04.20140826/unity-shared/OverlayRenderer.h --- unity-7.2.2+14.04.20140714/unity-shared/OverlayRenderer.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/OverlayRenderer.h 2014-08-26 15:48:28.000000000 +0200 @@ -39,6 +39,7 @@ nux::Property x_offset; nux::Property y_offset; + nux::Property scale; OverlayRenderer(); ~OverlayRenderer(); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/OverlayScrollView.cpp unity-7.2.3+14.04.20140826/unity-shared/OverlayScrollView.cpp --- unity-7.2.2+14.04.20140714/unity-shared/OverlayScrollView.cpp 1970-01-01 01:00:00.000000000 +0100 +++ unity-7.2.3+14.04.20140826/unity-shared/OverlayScrollView.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -0,0 +1,56 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Marco Trevisan + */ + +#include "OverlayScrollView.h" +#include "PlacesOverlayVScrollBar.h" +#include "RawPixel.h" + +namespace unity +{ +namespace dash +{ +namespace +{ + const RawPixel MOUSE_WHEEL_SCROLL_SIZE = 32_em; +} + +ScrollView::ScrollView(NUX_FILE_LINE_DECL) + : nux::ScrollView(NUX_FILE_LINE_PARAM) +{ + auto* scrollbar = new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION); + SetVScrollBar(scrollbar); + + scale.SetGetterFunction([scrollbar] { return scrollbar->scale(); }); + scale.SetSetterFunction([scrollbar] (double scale) { + if (scrollbar->scale() == scale) + return false; + + scrollbar->scale = scale; + return true; + }); + + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); + + scale.changed.connect([this] (double scale) { + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); + }); +} + +} // dash namespace +} // unity namespace \ Manca newline alla fine del file diff -Nru unity-7.2.2+14.04.20140714/unity-shared/OverlayScrollView.h unity-7.2.3+14.04.20140826/unity-shared/OverlayScrollView.h --- unity-7.2.2+14.04.20140714/unity-shared/OverlayScrollView.h 1970-01-01 01:00:00.000000000 +0100 +++ unity-7.2.3+14.04.20140826/unity-shared/OverlayScrollView.h 2014-08-26 15:48:28.000000000 +0200 @@ -0,0 +1,43 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Marco Trevisan + */ + +#ifndef _UNITY_SCROLL_VIEW_H_ +#define _UNITY_SCROLL_VIEW_H_ + +#include + +namespace unity +{ +namespace dash +{ + +class ScrollView : public nux::ScrollView +{ +public: + ScrollView(NUX_FILE_LINE_PROTO); + + nux::RWProperty scale; + + using nux::ScrollView::SetVScrollBar; +}; + +} // dash namespace +} // unity namespace + +#endif // _UNITY_SCROLL_VIEW_H_ diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PlacesOverlayVScrollBar.cpp unity-7.2.3+14.04.20140826/unity-shared/PlacesOverlayVScrollBar.cpp --- unity-7.2.2+14.04.20140714/unity-shared/PlacesOverlayVScrollBar.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PlacesOverlayVScrollBar.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -19,33 +19,46 @@ #include -#include "PlacesOverlayVScrollBar.h" #include "CairoTexture.h" - -namespace -{ - int const PROXIMITY = 7; - int const SCROLL_ANIMATION = 400; - int const MAX_CONNECTOR_ANIMATION = 200; -} +#include "PlacesOverlayVScrollBar.h" +#include "RawPixel.h" namespace unity { namespace dash { +namespace +{ + const RawPixel PROXIMITY = 7_em; + const int SCROLL_ANIMATION = 400; + const int MAX_CONNECTOR_ANIMATION = 200; + const nux::Color CONNECTOR_COLOR = nux::color::Gray; +} + +class PlacesOverlayVScrollBar::ProximityArea : public nux::InputAreaProximity, public sigc::trackable +{ +public: + ProximityArea(nux::InputArea* area, unsigned prox) + : nux::InputAreaProximity(area, prox) + , proximity([this] { return proximity_; }, [this] (unsigned px) { proximity_ = px; return false; }) + {} + + nux::RWProperty proximity; +}; PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) : PlacesVScrollBar(NUX_FILE_LINE_PARAM) , overlay_window_(new VScrollBarOverlayWindow(_track->GetAbsoluteGeometry())) - , area_prox_(this, PROXIMITY) + , area_prox_(std::make_shared(this, PROXIMITY.CP(scale))) , thumb_above_slider_(false) , connector_height_(0) , mouse_down_offset_(0) , delta_update_(0) { - area_prox_.mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); - area_prox_.mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); + area_prox_->mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); + area_prox_->mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); + overlay_window_->scale = scale(); overlay_window_->mouse_enter.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseEnter)); overlay_window_->mouse_leave.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseLeave)); overlay_window_->mouse_down.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseDown)); @@ -53,11 +66,17 @@ overlay_window_->mouse_click.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseClick)); overlay_window_->mouse_move.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseMove)); overlay_window_->mouse_drag.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseDrag)); + overlay_window_->mouse_wheel.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseWheel)); overlay_window_->sigHidden.connect(sigc::hide(sigc::mem_fun(this, &PlacesOverlayVScrollBar::ResetConnector))); _track->geometry_changed.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnTrackGeometryChanged)); OnVisibleChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnVisibilityChanged)); OnSensitiveChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnSensitivityChanged)); + + scale.changed.connect([this] (double scale) { + area_prox_->proximity = PROXIMITY.CP(scale); + overlay_window_->scale = scale; + }); } void PlacesOverlayVScrollBar::OnTrackGeometryChanged(nux::Area* /*area*/, nux::Geometry& /*geo*/) @@ -353,6 +372,12 @@ MouseDraggingOverlay(y, dy); } +void PlacesOverlayVScrollBar::OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state) +{ + mouse_wheel.emit(x, y, delta, mouse_state, key_state); + UpdateConnectorPosition(); +} + void PlacesOverlayVScrollBar::MouseDraggingOverlay(int y, int dy) { int const thumb_offset = overlay_window_->GetThumbOffsetY() + mouse_down_offset_; @@ -410,30 +435,25 @@ if (connector_height_ < 0) return; - int width = 3; + int width = _slider->GetWidth(); int height = connector_height_; - float const radius = 1.5f; - float const aspect = 1.0f; - - cairo_t* cr = NULL; - nux::color::RedGreenBlue const& connector_bg = nux::color::Gray; + if (connector_texture_ && connector_texture_->GetWidth() == width && connector_texture_->GetHeight() == height) + return; nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics.GetInternalContext(); - cairo_save(cr); + cairo_t* cr = cairoGraphics.GetInternalContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_save(cr); - - cairo_set_source_rgba(cr, connector_bg.red, connector_bg.green, connector_bg.blue, 0.8); - cairoGraphics.DrawRoundedRectangle(cr, aspect, 0.0f, 0.0f, radius, width, height); - cairo_fill_preserve(cr); + cairo_set_source_rgba(cr, CONNECTOR_COLOR.red, CONNECTOR_COLOR.green, CONNECTOR_COLOR.blue, 0.8); + cairo_rectangle(cr, 0, 0, static_cast(width)/scale(), static_cast(height)/scale()); + cairo_fill(cr); - connector_texture_.Adopt(texture_from_cairo_graphics(cairoGraphics)); + connector_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); QueueDraw(); } diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PlacesOverlayVScrollBar.h unity-7.2.3+14.04.20140826/unity-shared/PlacesOverlayVScrollBar.h --- unity-7.2.2+14.04.20140714/unity-shared/PlacesOverlayVScrollBar.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PlacesOverlayVScrollBar.h 2014-08-26 15:48:28.000000000 +0200 @@ -67,10 +67,10 @@ void OnMouseDown(int x, int y, unsigned int button_flags, unsigned int key_flags); void OnMouseUp(int x, int y, unsigned int button_flags, unsigned int key_flags); - void OnMouseMove(int x, int y, int dx, int dy, unsigned int button_flags, unsigned int key_flags); - void OnMouseDrag(int x, int y, int dx, int dy, unsigned int button_flags, unsigned int key_flags); + void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state); + void MouseDraggingOverlay(int y, int dy); bool IsMouseInTopHalfOfThumb(int y); @@ -80,7 +80,7 @@ void UpdateConnectorPosition(); void ResetConnector(); - + void UpdateStepY(); void SetupAnimation(int start, int stop, int milliseconds); @@ -93,7 +93,9 @@ void UpdateConnectorTexture(); nux::ObjectPtr overlay_window_; - nux::InputAreaProximity area_prox_; + + class ProximityArea; + std::shared_ptr area_prox_; nux::animation::AnimateValue animation_; connection::Wrapper tweening_connection_; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PlacesVScrollBar.cpp unity-7.2.3+14.04.20140826/unity-shared/PlacesVScrollBar.cpp --- unity-7.2.2+14.04.20140714/unity-shared/PlacesVScrollBar.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PlacesVScrollBar.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2011 Canonical Ltd + * Copyright (C) 2011-2014 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -15,44 +15,53 @@ * along with this program. If not, see . * * Authored by: Mirco Müller + * Marco Trevisan */ #include +#include #include "unity-shared/CairoTexture.h" +#include "unity-shared/RawPixel.h" #include "PlacesVScrollBar.h" -using unity::texture_from_cairo_graphics; - namespace unity { namespace dash { +namespace +{ +const RawPixel BUTTONS_HEIGHT = 15_em; +const RawPixel WIDTH = 3_em; +} PlacesVScrollBar::PlacesVScrollBar(NUX_FILE_LINE_DECL) - : VScrollBar(NUX_FILE_LINE_PARAM), - _slider_texture(NULL) + : nux::VScrollBar(NUX_FILE_LINE_PARAM) + , scale(1.0) { - _scroll_up_button->SetMaximumHeight(15); - _scroll_up_button->SetMinimumHeight(15); - - _scroll_down_button->SetMaximumHeight(15); - _scroll_down_button->SetMinimumHeight(15); - - _slider->SetMinimumWidth(3); - _slider->SetMaximumWidth(3); - SetMinimumWidth(3); - SetMaximumWidth(3); + UpdateSize(); + scale.changed.connect([this] (double scale) { + UpdateSize(); + QueueRelayout(); + QueueDraw(); + }); } -PlacesVScrollBar::~PlacesVScrollBar() +void PlacesVScrollBar::UpdateSize() { - if (_slider_texture) - _slider_texture->UnReference(); + _scroll_up_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); + _scroll_up_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); + + _scroll_down_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); + _scroll_down_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); + + _slider->SetMinimumWidth(WIDTH.CP(scale)); + _slider->SetMaximumWidth(WIDTH.CP(scale)); + SetMinimumWidth(WIDTH.CP(scale)); + SetMaximumWidth(WIDTH.CP(scale)); } -void -PlacesVScrollBar::PreLayoutManagement() +void PlacesVScrollBar::PreLayoutManagement() { nux::VScrollBar::PreLayoutManagement(); } @@ -69,8 +78,8 @@ void PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if(!RedirectedAncestor()) - { + if (!RedirectedAncestor()) + { DrawScrollbar(graphics_engine); } } @@ -78,15 +87,19 @@ void PlacesVScrollBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if(RedirectedAncestor()) - { - DrawScrollbar(graphics_engine); + if (RedirectedAncestor()) + { + DrawScrollbar(graphics_engine); } } void PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) { + // check if textures have been computed... if they haven't, exit function + if (!slider_texture_) + return; + nux::Color color = nux::color::White; nux::Geometry const& base = GetGeometry(); nux::TexCoordXForm texxform; @@ -95,9 +108,6 @@ unsigned int alpha = 0, src = 0, dest = 0; graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // check if textures have been computed... if they haven't, exit function - if (!_slider_texture) - return; texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); @@ -112,7 +122,7 @@ slider_geo.y, slider_geo.width, slider_geo.height, - _slider_texture->GetDeviceTexture(), + slider_texture_->GetDeviceTexture(), texxform, color); } @@ -123,35 +133,26 @@ void PlacesVScrollBar::UpdateTexture() { - nux::CairoGraphics* cairoGraphics = NULL; - cairo_t* cr = NULL; - // update texture of slider int width = _slider->GetBaseWidth(); int height = _slider->GetBaseHeight(); - cairoGraphics = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics->GetContext(); + + if (slider_texture_ && slider_texture_->GetWidth() == width && slider_texture_->GetHeight() == height) + return; + + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); + auto* cr = cg.GetContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); - cairoGraphics->DrawRoundedRectangle(cr, - 1.0f, - 0.0, - 0.0, - 1.5, - 3.0, - (double) height - 3.0); + cg.DrawRoundedRectangle(cr, 1.0f, 0.0, 0.0, 1.5, 3.0, static_cast(height)/scale() - 3.0); cairo_fill(cr); - if (_slider_texture) - _slider_texture->UnReference(); - _slider_texture = texture_from_cairo_graphics(*cairoGraphics); - - cairo_destroy(cr); - delete cairoGraphics; + slider_texture_ = texture_ptr_from_cairo_graphics(cg); } } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PlacesVScrollBar.h unity-7.2.3+14.04.20140826/unity-shared/PlacesVScrollBar.h --- unity-7.2.2+14.04.20140714/unity-shared/PlacesVScrollBar.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PlacesVScrollBar.h 2014-08-26 15:48:28.000000000 +0200 @@ -20,12 +20,7 @@ #ifndef PLACES_VSCROLLBAR_H #define PLACES_VSCROLLBAR_H -#include -#include -#include -#include #include -#include namespace unity { @@ -36,23 +31,23 @@ { public: PlacesVScrollBar(NUX_FILE_LINE_PROTO); - virtual ~PlacesVScrollBar(); + + nux::Property scale; protected: virtual void PreLayoutManagement(); virtual long PostLayoutManagement(long LayoutResult); - void Draw(nux::GraphicsEngine& gfxContext, - bool forceDraw); - void DrawContent(nux::GraphicsEngine& gfxContext, - bool forceDraw); + void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw); + void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); private: + void UpdateSize(); void UpdateTexture(); void DrawScrollbar(nux::GraphicsEngine& graphics_engine); private: - nux::BaseTexture* _slider_texture; + nux::ObjectPtr slider_texture_; }; } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp unity-7.2.3+14.04.20140826/unity-shared/PluginAdapter.cpp --- unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PluginAdapter.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -1254,6 +1254,7 @@ if (ret == GrabSuccess) { XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); if (CompWindow* w = m_Screen->findWindow(m_Screen->activeWindow())) w->moveInputFocusTo(); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PreviewStyle.cpp unity-7.2.3+14.04.20140826/unity-shared/PreviewStyle.cpp --- unity-7.2.2+14.04.20140714/unity-shared/PreviewStyle.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PreviewStyle.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -40,8 +40,8 @@ { Style* style_instance = nullptr; -const int preview_width = 770; -const int preview_height = 380; +const RawPixel preview_width = 770_em; +const RawPixel preview_height = 380_em; typedef nux::ObjectPtr BaseTexturePtr; @@ -98,7 +98,6 @@ , preview_nav_right_texture_("/preview_next.svg") , preview_play_texture_("/preview_play.svg") , preview_pause_texture_("/preview_pause.svg") - , preview_spin_texture_("/search_spin.svg") , warning_icon_texture_("/warning_icon.png") { } @@ -110,7 +109,6 @@ LazyLoadTexture<32> preview_nav_right_texture_; LazyLoadTexture<32> preview_play_texture_; LazyLoadTexture<32> preview_pause_texture_; - LazyLoadTexture<32> preview_spin_texture_; LazyLoadTexture<22> warning_icon_texture_; }; @@ -153,100 +151,99 @@ return new nux::ColorLayer(nux::Color(0.0f, 0.0f, 0.0f, 0.1f), true, rop); } -int Style::GetNavigatorWidth() const +RawPixel Style::GetNavigatorWidth() const { - return 42; + return 42_em; } -int Style::GetNavigatorIconSize() const +RawPixel Style::GetNavigatorIconSize() const { - return 24; + return 24_em; } -int Style::GetPreviewWidth() const +RawPixel Style::GetPreviewWidth() const { return preview_width; } -int Style::GetPreviewHeight() const +RawPixel Style::GetPreviewHeight() const { return preview_height; } - -int Style::GetPreviewTopPadding() const +RawPixel Style::GetPreviewTopPadding() const { - return 100; + return 100_em; } -int Style::GetDetailsTopMargin() const +RawPixel Style::GetDetailsTopMargin() const { - return 5; + return 5_em; } -int Style::GetDetailsBottomMargin() const +RawPixel Style::GetDetailsBottomMargin() const { - return 10; + return 10_em; } -int Style::GetDetailsRightMargin() const +RawPixel Style::GetDetailsRightMargin() const { - return 10; + return 10_em; } -int Style::GetDetailsLeftMargin() const +RawPixel Style::GetDetailsLeftMargin() const { - return 10; + return 10_em; } -int Style::GetPanelSplitWidth() const +RawPixel Style::GetPanelSplitWidth() const { - return 10; + return 10_em; } -int Style::GetAppIconAreaWidth() const +RawPixel Style::GetAppIconAreaWidth() const { - return 105; + return 105_em; } -int Style::GetSpaceBetweenTitleAndSubtitle() const +RawPixel Style::GetSpaceBetweenTitleAndSubtitle() const { - return 6; + return 6_em; } -int Style::GetSpaceBetweenIconAndDetails() const +RawPixel Style::GetSpaceBetweenIconAndDetails() const { - return 18; + return 18_em; } -int Style::GetTrackHeight() const +RawPixel Style::GetTrackHeight() const { - return 28; + return 28_em; } -int Style::GetMusicDurationWidth() const +RawPixel Style::GetMusicDurationWidth() const { - return 40; + return 40_em; } -int Style::GetActionButtonHeight() const +RawPixel Style::GetActionButtonHeight() const { - return 34; + return 34_em; } -int Style::GetActionButtonMaximumWidth() const +RawPixel Style::GetActionButtonMaximumWidth() const { - return 175; + return 175_em; } -int Style::GetSpaceBetweenActions() const +RawPixel Style::GetSpaceBetweenActions() const { - return 10; + return 10_em; } -int Style::GetTrackBarHeight() const +RawPixel Style::GetTrackBarHeight() const { - return 25; + return 25_em; } float Style::GetAppImageAspectRatio() const @@ -254,24 +251,24 @@ return 1.0; } -int Style::GetDetailsPanelMinimumWidth() const +RawPixel Style::GetDetailsPanelMinimumWidth() const { - return 300; + return 300_em; } -int Style::GetInfoHintIconSizeWidth() const +RawPixel Style::GetInfoHintIconSizeWidth() const { - return 24; + return 24_em; } -int Style::GetInfoHintNameMinimumWidth() const +RawPixel Style::GetInfoHintNameMinimumWidth() const { - return 100; + return 100_em; } -int Style::GetInfoHintNameMaximumWidth() const +RawPixel Style::GetInfoHintNameMaximumWidth() const { - return 160; + return 160_em; } float Style::GetDescriptionLineSpacing() const @@ -279,19 +276,19 @@ return 2.0; } -int Style::GetDescriptionLineCount() const +RawPixel Style::GetDescriptionLineCount() const { - return 20; + return 20_em; } -int Style::GetRatingWidgetHeight() const +RawPixel Style::GetRatingWidgetHeight() const { - return 36; + return 36_em; } -int Style::GetStatusIconSize() const +RawPixel Style::GetStatusIconSize() const { - return 12; + return 10_em; } std::string Style::payment_title_font() const @@ -344,39 +341,39 @@ return nux::Color(255, 0, 0); } -int Style::GetPaymentIconAreaWidth() const +RawPixel Style::GetPaymentIconAreaWidth() const { - return 64; + return 64_em; } -int Style::GetPaymentTextInputHeight() const +RawPixel Style::GetPaymentTextInputHeight() const { - return 40; + return 40_em; } -int Style::GetPaymentLockWidth() const +RawPixel Style::GetPaymentLockWidth() const { - return 22; + return 22_em; } -int Style::GetPaymentLockHeight() const +RawPixel Style::GetPaymentLockHeight() const { - return 22; + return 22_em; } -int Style::GetPaymentHeaderWidth() const +RawPixel Style::GetPaymentHeaderWidth() const { - return 850; + return 850_em; } -int Style::GetPaymentHeaderSpace() const +RawPixel Style::GetPaymentHeaderSpace() const { - return 0; + return 0_em; } -int Style::GetPaymentFormSpace() const +RawPixel Style::GetPaymentFormSpace() const { - return 5; + return 5_em; } std::string Style::u1_warning_font() const @@ -389,14 +386,14 @@ return float(540)/380; } -int Style::GetAvatarAreaWidth() const +RawPixel Style::GetAvatarAreaWidth() const { - return 100; + return 100_em; } -int Style::GetAvatarAreaHeight() const +RawPixel Style::GetAvatarAreaHeight() const { - return 100; + return 100_em; } std::string Style::content_font() const @@ -504,11 +501,6 @@ return pimpl->warning_icon_texture_.texture(); } -nux::BaseTexture* Style::GetSearchSpinIcon(int size) -{ - return pimpl->preview_spin_texture_.texture(size); -} - } // namespace previews } // namespace dash diff -Nru unity-7.2.2+14.04.20140714/unity-shared/PreviewStyle.h unity-7.2.3+14.04.20140826/unity-shared/PreviewStyle.h --- unity-7.2.2+14.04.20140714/unity-shared/PreviewStyle.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/PreviewStyle.h 2014-08-26 15:48:28.000000000 +0200 @@ -29,6 +29,8 @@ #include #include +#include "unity-shared/RawPixel.h" + namespace nux { class BaseTexture; @@ -57,38 +59,38 @@ static Style& Instance(); - int GetNavigatorWidth() const; - int GetNavigatorIconSize() const; + RawPixel GetNavigatorWidth() const; + RawPixel GetNavigatorIconSize() const; - int GetPreviewWidth() const; - int GetPreviewHeight() const; - int GetPreviewTopPadding() const; + RawPixel GetPreviewWidth() const; + RawPixel GetPreviewHeight() const; + RawPixel GetPreviewTopPadding() const; - int GetDetailsTopMargin() const; - int GetDetailsBottomMargin() const; - int GetDetailsRightMargin() const; - int GetDetailsLeftMargin() const; - int GetPanelSplitWidth() const; + RawPixel GetDetailsTopMargin() const; + RawPixel GetDetailsBottomMargin() const; + RawPixel GetDetailsRightMargin() const; + RawPixel GetDetailsLeftMargin() const; + RawPixel GetPanelSplitWidth() const; - int GetSpaceBetweenTitleAndSubtitle() const; + RawPixel GetSpaceBetweenTitleAndSubtitle() const; - int GetActionButtonHeight() const; - int GetSpaceBetweenActions() const; - int GetActionButtonMaximumWidth() const; + RawPixel GetActionButtonHeight() const; + RawPixel GetSpaceBetweenActions() const; + RawPixel GetActionButtonMaximumWidth() const; - int GetDetailsPanelMinimumWidth() const; + RawPixel GetDetailsPanelMinimumWidth() const; - int GetInfoHintIconSizeWidth() const; - int GetInfoHintNameMinimumWidth() const; - int GetInfoHintNameMaximumWidth() const; + RawPixel GetInfoHintIconSizeWidth() const; + RawPixel GetInfoHintNameMinimumWidth() const; + RawPixel GetInfoHintNameMaximumWidth() const; - int GetCommentNameMinimumWidth() const; - int GetCommentNameMaximumWidth() const; + RawPixel GetCommentNameMinimumWidth() const; + RawPixel GetCommentNameMaximumWidth() const; float GetDescriptionLineSpacing() const; - int GetDescriptionLineCount() const; + RawPixel GetDescriptionLineCount() const; - int GetRatingWidgetHeight() const; + RawPixel GetRatingWidgetHeight() const; bool GetShadowBackgroundEnabled() const; @@ -113,8 +115,8 @@ float GetAppImageAspectRatio() const; - int GetAppIconAreaWidth() const; - int GetSpaceBetweenIconAndDetails() const; + RawPixel GetAppIconAreaWidth() const; + RawPixel GetSpaceBetweenIconAndDetails() const; //////////////////////////////// //////////////////////////////// @@ -123,22 +125,22 @@ std::string u1_warning_font() const; nux::BaseTexture* GetWarningIcon(); - int GetTrackHeight() const; + RawPixel GetTrackHeight() const; //////////////////////////////// //////////////////////////////// // Movie Preview float GetVideoImageAspectRatio() const; - int GetTrackBarHeight() const; - int GetMusicDurationWidth() const; - int GetStatusIconSize() const; + RawPixel GetTrackBarHeight() const; + RawPixel GetMusicDurationWidth() const; + RawPixel GetStatusIconSize() const; //////////////////////////////// //////////////////////////////// // Social Preview - int GetAvatarAreaWidth() const; - int GetAvatarAreaHeight() const; + RawPixel GetAvatarAreaWidth() const; + RawPixel GetAvatarAreaHeight() const; std::string content_font() const; @@ -149,7 +151,6 @@ nux::BaseTexture* GetPlayIcon(); nux::BaseTexture* GetPauseIcon(); nux::BaseTexture* GetLockIcon(); - nux::BaseTexture* GetSearchSpinIcon(int size = -1); //////////////////////////////// // Payment Preview @@ -165,13 +166,13 @@ nux::Color payment_error_color() const; - int GetPaymentIconAreaWidth() const; - int GetPaymentTextInputHeight() const; - int GetPaymentLockWidth() const; - int GetPaymentLockHeight() const; - int GetPaymentHeaderWidth() const; - int GetPaymentHeaderSpace() const; - int GetPaymentFormSpace() const; + RawPixel GetPaymentIconAreaWidth() const; + RawPixel GetPaymentTextInputHeight() const; + RawPixel GetPaymentLockWidth() const; + RawPixel GetPaymentLockHeight() const; + RawPixel GetPaymentHeaderWidth() const; + RawPixel GetPaymentHeaderSpace() const; + RawPixel GetPaymentFormSpace() const; ///////////////////////////////// diff -Nru unity-7.2.2+14.04.20140714/unity-shared/RatingsButton.cpp unity-7.2.3+14.04.20140826/unity-shared/RatingsButton.cpp --- unity-7.2.2+14.04.20140714/unity-shared/RatingsButton.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/RatingsButton.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -29,18 +29,19 @@ namespace { -const int num_stars = 5; +const int NUM_STARS = 5; } namespace unity { RatingsButton::RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_DECL) : nux::ToggleButton(NUX_FILE_LINE_PARAM) + , scale(1.0) + , star_size_(star_size) + , star_gap_(star_gap) , editable_(true) , rating_(0.0) , focused_star_(-1) - , star_size_(star_size) - , star_gap_(star_gap) { SetAcceptKeyNavFocusOnMouseDown(false); SetAcceptKeyNavFocusOnMouseEnter(true); @@ -58,12 +59,11 @@ QueueDraw(); }); - key_nav_focus_activate.connect([this](nux::Area*) { SetRating(static_cast(focused_star_+1)/num_stars); }); + + key_nav_focus_activate.connect([this](nux::Area*) { SetRating(static_cast(focused_star_+1)/NUM_STARS); }); key_down.connect(sigc::mem_fun(this, &RatingsButton::OnKeyDown)); -} -RatingsButton::~RatingsButton() -{ + scale.changed.connect(sigc::hide(sigc::mem_fun(this, &RatingsButton::QueueDraw))); } void RatingsButton::SetEditable(bool editable) @@ -76,7 +76,7 @@ void RatingsButton::SetRating(float rating) { - rating_ = rating; + rating_ = rating; QueueDraw(); } @@ -87,7 +87,7 @@ void RatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { - int rating = static_cast(rating_ * num_stars); + int rating = static_cast(GetRating() * NUM_STARS); // FIXME: 9/26/2011 // We should probably support an API for saying whether the ratings // should or shouldn't support half stars...but our only consumer at @@ -99,8 +99,8 @@ nux::Geometry const& geo = GetGeometry(); nux::Geometry geo_star(geo); - geo_star.width = star_size_; - geo_star.height = star_size_; + geo_star.width = star_size_.CP(scale); + geo_star.height = star_size_.CP(scale); gPainter.PaintBackground(GfxContext, geo); // set up our texture mode @@ -123,10 +123,10 @@ geo.height, col); - for (int index = 0; index < num_stars; ++index) + for (int index = 0; index < NUM_STARS; ++index) { dash::Style& style = dash::Style::Instance(); - nux::BaseTexture* texture = style.GetStarSelectedIcon(); + auto texture = style.GetStarSelectedIcon(); if (index < total_full_stars) { if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL) @@ -165,7 +165,7 @@ nux::Color(1.0f, 1.0f, 1.0f, 0.5f)); } - geo_star.x += geo_star.width + star_gap_; + geo_star.x += geo_star.width + star_gap_.CP(scale); } @@ -175,11 +175,11 @@ void RatingsButton::UpdateRatingToMouse(int x) { - int width = num_stars*star_size_ + (num_stars-1)*star_gap_; + int width = NUM_STARS*star_size_.CP(scale) + (NUM_STARS-1)*star_gap_.CP(scale); float new_rating = (static_cast(x) / width); // FIXME: change to * 2 once we decide to support also half-stars - new_rating = ceil((num_stars * 1) * new_rating) / (num_stars * 1); + new_rating = ceil((NUM_STARS * 1) * new_rating) / (NUM_STARS * 1); new_rating = (new_rating > 1) ? 1 : ((new_rating < 0) ? 0 : new_rating); SetRating(new_rating); @@ -210,8 +210,8 @@ if (!editable_) return; - int width = num_stars*star_size_+ (num_stars-1)*star_gap_; - focused_star_ = std::max(0, std::min(static_cast(ceil((static_cast(x) / width) * num_stars) - 1), num_stars - 1)); + int width = NUM_STARS*star_size_.CP(scale)+ (NUM_STARS-1)*star_gap_.CP(scale); + focused_star_ = std::max(0, std::min(static_cast(ceil((static_cast(x) / width) * NUM_STARS) - 1), NUM_STARS - 1)); if (!HasKeyFocus()) nux::GetWindowCompositor().SetKeyFocusArea(this); @@ -240,7 +240,7 @@ return false; else if (direction == nux::KEY_NAV_LEFT && (focused_star_ <= 0)) return false; - else if (direction == nux::KEY_NAV_RIGHT && (focused_star_ >= num_stars - 1)) + else if (direction == nux::KEY_NAV_RIGHT && (focused_star_ >= NUM_STARS - 1)) return false; else return true; @@ -283,7 +283,7 @@ { introspection .add(GetAbsoluteGeometry()) - .add("rating", rating_) + .add("rating", GetRating()) .add("focused-star", focused_star_) .add("editable", editable_); } diff -Nru unity-7.2.2+14.04.20140714/unity-shared/RatingsButton.h unity-7.2.3+14.04.20140826/unity-shared/RatingsButton.h --- unity-7.2.2+14.04.20140714/unity-shared/RatingsButton.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/RatingsButton.h 2014-08-26 15:48:28.000000000 +0200 @@ -27,6 +27,7 @@ #include #include #include "unity-shared/Introspectable.h" +#include "unity-shared/RawPixel.h" namespace unity { @@ -35,7 +36,8 @@ { public: RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_PROTO); - virtual ~RatingsButton(); + + nux::Property scale; void SetEditable(bool editable); virtual void SetRating(float rating); @@ -62,13 +64,12 @@ void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); void UpdateRatingToMouse(int x); - protected: + RawPixel star_size_; + RawPixel star_gap_; bool editable_; float rating_; int focused_star_; - int star_size_; - int star_gap_; }; } // namespace unity diff -Nru unity-7.2.2+14.04.20140714/unity-shared/RawPixel.h unity-7.2.3+14.04.20140826/unity-shared/RawPixel.h --- unity-7.2.2+14.04.20140714/unity-shared/RawPixel.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/RawPixel.h 2014-08-26 15:48:28.000000000 +0200 @@ -28,7 +28,7 @@ class RawPixel { public: - RawPixel(double raw_pixel); + RawPixel(double raw_pixel = 0); int CP(EMConverter::Ptr const&) const; int CP(double scale) const; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/SearchBar.cpp unity-7.2.3+14.04.20140826/unity-shared/SearchBar.cpp --- unity-7.2.2+14.04.20140714/unity-shared/SearchBar.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/SearchBar.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -42,6 +42,7 @@ const float DEFAULT_ICON_OPACITY = 1.0f; const int DEFAULT_LIVE_SEARCH_TIMEOUT = 40; const int SPINNER_TIMEOUT = 100; +const int CORNER_RADIUS = 5; const RawPixel SPACE_BETWEEN_SPINNER_AND_TEXT = 5_em; const RawPixel SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10_em; @@ -61,6 +62,8 @@ const RawPixel BOT_ARROW_MIN_HEIGHT = 8_em; const RawPixel BOT_ARROW_MAX_HEIGHT = 8_em; +const RawPixel FILTER_HORIZONTAL_MARGIN = 8_em; + // Fonts const std::string HINT_LABEL_FONT_SIZE = "20px"; const std::string HINT_LABEL_FONT_STYLE = "Italic"; @@ -150,12 +153,13 @@ layout_->AddLayout(entry_layout_); spinner_ = new SearchBarSpinner(); + spinner_->scale = scale(); spinner_->mouse_click.connect(sigc::mem_fun(this, &SearchBar::OnClearClicked)); entry_layout_->AddView(spinner_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); nux::HLayout* hint_layout = new nux::HLayout(NUX_TRACKER_LOCATION); - hint_ = new StaticCairoText(" "); + hint_ = new StaticCairoText(""); hint_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 0.5f)); hint_->SetFont(HINT_LABEL_DEFAULT_FONT.c_str()); hint_layout->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); @@ -190,21 +194,15 @@ show_filters_->SetFont(SHOW_FILTERS_LABEL_DEFAULT_FONT.c_str()); show_filters_->SetTextColor(nux::color::White); show_filters_->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); + show_filters_->SetScale(scale); show_filters_->SetLines(-1); - nux::BaseTexture* arrow; - arrow = style.GetGroupExpandIcon(); - expand_icon_ = new IconTexture(arrow, - arrow->GetWidth(), - arrow->GetHeight()); + expand_icon_ = new IconTexture(style.GetGroupExpandIcon()); expand_icon_->SetOpacity(DEFAULT_ICON_OPACITY); - expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); + expand_icon_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT); expand_icon_->SetVisible(false); filter_layout_ = new nux::HLayout(); - filter_layout_->SetHorizontalInternalMargin(8); - filter_layout_->SetLeftAndRightPadding(style.GetFilterResultsHighlightLeftPadding(), - style.GetFilterResultsHighlightRightPadding()); filter_layout_->SetContentDistribution(nux::MAJOR_POSITION_END); filter_layout_->AddView(show_filters_, 0, nux::MINOR_POSITION_CENTER); @@ -230,14 +228,6 @@ expander_view_->SetLayout(filter_layout_); layout_->AddView(expander_view_, 0, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FULL); - int width = style.GetFilterBarWidth() + - style.GetFilterResultsHighlightLeftPadding() + - style.GetFilterResultsHighlightRightPadding(); - - expander_view_->SetMaximumWidth(width); - expander_view_->SetMinimumWidth(width); - show_filters_->SetMaximumWidth(style.GetFilterBarWidth() - arrow_layout_->GetBaseWidth() - 8); - // Lambda functions auto mouse_expand = [this](int, int, unsigned long, unsigned long) { @@ -288,10 +278,7 @@ void SearchBar::UpdateSearchBarSize() { - dash::Style& style = dash::Style::Instance(); - nux::BaseTexture* icon = style.GetSearchMagnifyIcon(); - RawPixel const icon_width = icon->GetWidth(); - RawPixel const icon_height = icon->GetHeight(); + auto& style = dash::Style::Instance(); layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING.CP(scale()), SEARCH_ENTRY_RIGHT_BORDER.CP(scale())); @@ -300,7 +287,6 @@ entry_layout_->SetLeftAndRightPadding(LEFT_PADDING.CP(scale()), RIGHT_PADDING.CP(scale())); - spinner_->SetMinMaxSize(icon_width.CP(scale()), icon_height.CP(scale())); entry_layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_SPINNER_AND_TEXT.CP(scale())); pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE.CP(scale())); @@ -316,6 +302,21 @@ BOT_ARROW_MIN_HEIGHT.CP(scale())); arrow_bottom_space_->SetMaximumSize(ARROW_MAX_WIDTH.CP(scale()), BOT_ARROW_MAX_HEIGHT.CP(scale())); + + int highlight_left_padding = style.GetFilterResultsHighlightLeftPadding().CP(scale); + int highlight_right_padding = style.GetFilterResultsHighlightRightPadding().CP(scale); + int filter_bar_width = style.GetFilterBarWidth().CP(scale); + + filter_layout_->SetHorizontalInternalMargin(FILTER_HORIZONTAL_MARGIN.CP(scale)); + filter_layout_->SetLeftAndRightPadding(highlight_left_padding, highlight_right_padding); + show_filters_->SetMaximumWidth(filter_bar_width - arrow_layout_->GetBaseWidth() - (8_em).CP(scale)); + + int width = filter_bar_width + highlight_right_padding + highlight_right_padding; + expander_view_->SetMaximumWidth(width); + expander_view_->SetMinimumWidth(width); + + auto const& arrow = expand_icon_->texture(); + expand_icon_->SetMinMaxSize(RawPixel(arrow->GetWidth()).CP(scale), RawPixel(arrow->GetHeight()).CP(scale)); } // Based on the Font size, the MinHeight is changing in TextEntry. From there the @@ -327,13 +328,20 @@ pango_entry_->SetMaximumHeight(entry_min); layered_layout_->SetMinimumHeight(entry_min); layered_layout_->SetMaximumHeight(entry_min); + + int search_bar_height = style.GetSearchBarHeight().CP(scale); + SetMinimumHeight(search_bar_height); + SetMaximumHeight(search_bar_height); } void SearchBar::UpdateScale(double scale) { + hint_->SetMinimumSize(nux::AREA_MIN_WIDTH, nux::AREA_MIN_HEIGHT); + hint_->SetMaximumSize(nux::AREA_MAX_WIDTH, nux::AREA_MAX_HEIGHT); hint_->SetScale(scale); + spinner_->scale = scale; - if (show_filters_) + if (show_filter_hint_) show_filters_->SetScale(scale); UpdateSearchBarSize(); @@ -371,11 +379,7 @@ void SearchBar::OnSearchHintChanged() { - gchar* tmp = g_markup_escape_text(search_hint().c_str(), -1); - - hint_->SetText(tmp); - - g_free(tmp); + hint_->SetText(glib::String(g_markup_escape_text(search_hint().c_str(), -1)).Str()); } void SearchBar::OnSearchChanged(nux::TextEntry* text_entry) @@ -422,6 +426,9 @@ expand_icon_->SetTexture(style.GetGroupUnexpandIcon()); else expand_icon_->SetTexture(style.GetGroupExpandIcon()); + + auto const& arrow = expand_icon_->texture(); + expand_icon_->SetMinMaxSize(RawPixel(arrow->GetWidth()).CP(scale), RawPixel(arrow->GetHeight()).CP(scale)); } } @@ -541,7 +548,6 @@ void SearchBar::UpdateBackground(bool force) { - RawPixel const RADIUS = 5; nux::Geometry geo(GetGeometry()); geo.width = layered_layout_->GetAbsoluteX() + layered_layout_->GetAbsoluteWidth() - @@ -564,12 +570,13 @@ nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, last_width_, last_height_); cairo_t* cr = cairo_graphics.GetInternalContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_graphics.DrawRoundedRectangle(cr, 1.0f, 0.5, 0.5, - RADIUS.CP(scale()), - last_width_ - 1, last_height_ - 1, + CORNER_RADIUS, + (last_width_/scale) - 1, (last_height_/scale) - 1, false); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/SearchBarSpinner.cpp unity-7.2.3+14.04.20140826/unity-shared/SearchBarSpinner.cpp --- unity-7.2.2+14.04.20140714/unity-shared/SearchBarSpinner.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/SearchBarSpinner.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -22,6 +22,7 @@ #include #include "unity-shared/DashStyle.h" +#include "unity-shared/RawPixel.h" namespace unity { @@ -29,24 +30,33 @@ NUX_IMPLEMENT_OBJECT_TYPE(SearchBarSpinner); SearchBarSpinner::SearchBarSpinner() - : nux::View(NUX_TRACKER_LOCATION), - state_(STATE_READY), - search_timeout_(-1), - rotation_(0.0f) + : nux::View(NUX_TRACKER_LOCATION) + , scale(1.0) + , state_(STATE_READY) + , search_timeout_(-1) + , rotation_(0.0f) { - dash::Style& style = dash::Style::Instance(); - - magnify_ = style.GetSearchMagnifyIcon(); - circle_ = style.GetSearchCircleIcon(); - close_ = style.GetSearchCloseIcon(); - spin_ = style.GetSearchSpinIcon(); - rotate_.Identity(); rotate_.Rotate_z(0.0); + UpdateScale(scale); + + scale.changed.connect(sigc::mem_fun(this, &SearchBarSpinner::UpdateScale)); } -void -SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) +void SearchBarSpinner::UpdateScale(double scale) +{ + auto& style = dash::Style::Instance(); + + magnify_ = style.GetSearchMagnifyIcon(scale); + circle_ = style.GetSearchCircleIcon(scale); + close_ = style.GetSearchCloseIcon(scale); + spin_ = style.GetSearchSpinIcon(scale); + + SetMinMaxSize(magnify_->GetWidth(), magnify_->GetHeight()); + QueueDraw(); +} + +void SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::Geometry const& geo = GetGeometry(); nux::TexCoordXForm texxform; @@ -56,9 +66,8 @@ nux::GetPainter().PaintBackground(GfxContext, geo); texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); - texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); - texxform.min_filter = nux::TEXFILTER_LINEAR; - texxform.mag_filter = nux::TEXFILTER_LINEAR; + texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); + texxform.SetFilter(nux::TEXFILTER_LINEAR, nux::TEXFILTER_LINEAR); unsigned int current_alpha_blend; unsigned int current_src_blend_factor; @@ -68,20 +77,23 @@ if (state_ == STATE_READY) { - GfxContext.QRP_1Tex(geo.x + ((geo.width - magnify_->GetWidth()) / 2), - geo.y + ((geo.height - magnify_->GetHeight()) / 2), - magnify_->GetWidth(), - magnify_->GetHeight(), + nux::Size magnifier_size(magnify_->GetWidth(), magnify_->GetHeight()); + + GfxContext.QRP_1Tex(geo.x + ((geo.width - magnifier_size.width) / 2), + geo.y + ((geo.height - magnifier_size.height) / 2), + magnifier_size.width, + magnifier_size.height, magnify_->GetDeviceTexture(), texxform, nux::color::White); } else if (state_ == STATE_SEARCHING) { - nux::Geometry spin_geo(geo.x + ((geo.width - spin_->GetWidth()) / 2), - geo.y + ((geo.height - spin_->GetHeight()) / 2), - spin_->GetWidth(), - spin_->GetHeight()); + nux::Size spin_size(spin_->GetWidth(), spin_->GetHeight()); + nux::Geometry spin_geo(geo.x + ((geo.width - spin_size.width) / 2), + geo.y + ((geo.height - spin_size.height) / 2), + spin_size.width, + spin_size.height); // Geometry (== Rect) uses integers which were rounded above, // hence an extra 0.5 offset for odd sizes is needed // because pure floating point is not being used. @@ -110,18 +122,20 @@ } else { - GfxContext.QRP_1Tex(geo.x + ((geo.width - circle_->GetWidth()) / 2), - geo.y + ((geo.height - circle_->GetHeight()) / 2), - circle_->GetWidth(), - circle_->GetHeight(), + nux::Size circle_size(circle_->GetWidth(), circle_->GetHeight()); + GfxContext.QRP_1Tex(geo.x + ((geo.width - circle_size.width) / 2), + geo.y + ((geo.height - circle_size.height) / 2), + circle_size.width, + circle_size.height, circle_->GetDeviceTexture(), texxform, nux::color::White); - GfxContext.QRP_1Tex(geo.x + ((geo.width - close_->GetWidth()) / 2), - geo.y + ((geo.height - close_->GetHeight()) / 2), - close_->GetWidth(), - close_->GetHeight(), + nux::Size close_size(close_->GetWidth(), close_->GetHeight()); + GfxContext.QRP_1Tex(geo.x + ((geo.width - close_size.width) / 2), + geo.y + ((geo.height - close_size.height) / 2), + close_size.width, + close_size.height, close_->GetDeviceTexture(), texxform, nux::color::White); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/SearchBarSpinner.h unity-7.2.3+14.04.20140826/unity-shared/SearchBarSpinner.h --- unity-7.2.2+14.04.20140714/unity-shared/SearchBarSpinner.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/SearchBarSpinner.h 2014-08-26 15:48:28.000000000 +0200 @@ -44,6 +44,8 @@ public: SearchBarSpinner(); + nux::Property scale; + void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); @@ -62,13 +64,14 @@ private: bool OnFrameTimeout(); + void UpdateScale(double); SpinnerState state_; - nux::BaseTexture* magnify_; - nux::BaseTexture* circle_; - nux::BaseTexture* close_; - nux::BaseTexture* spin_; + nux::ObjectPtr magnify_; + nux::ObjectPtr circle_; + nux::ObjectPtr close_; + nux::ObjectPtr spin_; glib::Source::UniquePtr spinner_timeout_; glib::Source::UniquePtr frame_timeout_; diff -Nru unity-7.2.2+14.04.20140714/unity-shared/SpreadFilter.cpp unity-7.2.3+14.04.20140826/unity-shared/SpreadFilter.cpp --- unity-7.2.2+14.04.20140714/unity-shared/SpreadFilter.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/SpreadFilter.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -38,7 +38,6 @@ const RawPixel OFFSET_X = 10_em; const RawPixel OFFSET_Y = 15_em; const RawPixel WIDTH = 620_em; -const RawPixel HEIGHT = 42_em; // For some reason std::to_lower or boost::to_lower_copy doesn't seem to handle well utf8 std::string casefold_copy(std::string const& str) @@ -58,7 +57,8 @@ auto const& cv = settings.em(monitor); search_bar_ = SearchBar::Ptr(new SearchBar()); - search_bar_->SetMinMaxSize(WIDTH.CP(cv), HEIGHT.CP(cv)); + search_bar_->SetMinimumWidth(WIDTH.CP(cv)); + search_bar_->SetMaximumWidth(WIDTH.CP(cv)); search_bar_->scale = cv->DPIScale(); search_bar_->live_search_wait = DEFAULT_SEARCH_WAIT; text.SetGetterFunction([this] { return search_bar_->search_string(); }); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/TextInput.cpp unity-7.2.3+14.04.20140826/unity-shared/TextInput.cpp --- unity-7.2.2+14.04.20140714/unity-shared/TextInput.cpp 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/TextInput.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -23,8 +23,6 @@ #include "unity-shared/RawPixel.h" #include "unity-shared/PreviewStyle.h" -#include - namespace unity { @@ -42,9 +40,6 @@ const RawPixel TOOLTIP_OFFSET = 10_em; const RawPixel DEFAULT_ICON_SIZE = 22_em; -// Caps is on 0x1, couldn't find any #define in /usr/include/X11 -const int CAPS_STATE_ON = 0x1; - std::string WARNING_ICON = "dialog-warning-symbolic"; // Fonts const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu"; @@ -114,7 +109,6 @@ pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE); pango_entry_->cursor_moved.connect([this](int i) { QueueDraw(); }); pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown)); - pango_entry_->key_up.connect(sigc::mem_fun(this, &TextInput::OnKeyUp)); pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus)); pango_entry_->text_changed.connect([this](nux::TextEntry*) { hint_->SetVisible(input_string().empty()); @@ -155,6 +149,10 @@ "notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged)); OnFontChanged(gtk_settings_get_default()); + sig_manager_.Add(gdk_keymap_get_default(), "state-changed", [this](GdkKeymap*) { + CheckIfCapsLockOn(); + }); + input_string.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_input_string)); input_string.SetSetterFunction(sigc::mem_fun(this, &TextInput::set_input_string)); im_active.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_active)); @@ -174,14 +172,8 @@ void TextInput::CheckIfCapsLockOn() { - Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); - unsigned int state = 0; - XkbGetIndicatorState(dpy, XkbUseCoreKbd, &state); - - if ((state & CAPS_STATE_ON) == 1) - caps_lock_on = true; - else - caps_lock_on = false; + GdkKeymap* keymap = gdk_keymap_get_default(); + caps_lock_on = gdk_keymap_get_caps_lock_state(keymap) == FALSE ? false : true; } void TextInput::SetSpinnerVisible(bool visible) @@ -418,16 +410,6 @@ texture2D->UnReference(); } -void TextInput::OnKeyUp(unsigned keysym, - unsigned long keycode, - unsigned long state) -{ - if (!caps_lock_on && keysym == NUX_VK_CAPITAL) - caps_lock_on = true; - else if (caps_lock_on && keysym == NUX_VK_CAPITAL) - caps_lock_on = false; -} - void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) { hint_->SetVisible(false); diff -Nru unity-7.2.2+14.04.20140714/unity-shared/TextInput.h unity-7.2.3+14.04.20140826/unity-shared/TextInput.h --- unity-7.2.2+14.04.20140714/unity-shared/TextInput.h 2014-07-14 16:30:31.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/TextInput.h 2014-08-26 15:48:28.000000000 +0200 @@ -99,7 +99,6 @@ protected: void OnInputHintChanged(); void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags); - void OnKeyUp(unsigned keysym, unsigned long keycode, unsigned long state); void OnEndKeyFocus(); // getters & setters diff -Nru unity-7.2.2+14.04.20140714/unity-shared/TextureCache.cpp unity-7.2.3+14.04.20140826/unity-shared/TextureCache.cpp --- unity-7.2.2+14.04.20140714/unity-shared/TextureCache.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/TextureCache.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -27,6 +27,15 @@ namespace unity { DECLARE_LOGGER(logger, "unity.internal.texturecache"); +namespace +{ +// Stolen from boost +template +inline std::size_t hash_combine(std::size_t seed, T const& v) +{ + return seed ^ (std::hash()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); +} +} TextureCache& TextureCache::GetDefault() { @@ -42,9 +51,7 @@ std::size_t TextureCache::Hash(std::string const& id, int width, int height) { - return ((std::hash()(id) - ^ (std::hash()(width) << 1)) >> 1) - ^ (std::hash()(height) << 1); + return hash_combine(hash_combine(std::hash()(id), width), height); } TextureCache::BaseTexturePtr TextureCache::FindTexture(std::string const& texture_id, diff -Nru unity-7.2.2+14.04.20140714/unity-shared/UnitySettings.cpp unity-7.2.3+14.04.20140826/unity-shared/UnitySettings.cpp --- unity-7.2.2+14.04.20140714/unity-shared/UnitySettings.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/UnitySettings.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -59,6 +59,7 @@ const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor"; const int DEFAULT_LAUNCHER_WIDTH = 64; +const int MINIMUM_DESKTOP_HEIGHT = 800; const double DEFAULT_DPI = 96.0f; } @@ -89,9 +90,6 @@ for (unsigned i = 0; i < monitors::MAX; ++i) em_converters_.emplace_back(std::make_shared()); - CacheFormFactor(); - CacheDoubleClickActivate(); - // The order is important here, DPI is the last thing to be updated UpdateLimSetting(); UpdateTextScaleFactor(); @@ -99,6 +97,9 @@ UpdateFontSize(); UpdateDPI(); + CacheFormFactor(); + CacheDoubleClickActivate(); + UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI)))); signals_.Add(usettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, const gchar*) { @@ -162,10 +163,11 @@ if (raw_from_factor == 0) //Automatic { auto uscreen = UScreen::GetDefault(); - int primary_monitor = uscreen->GetMonitorWithMouse(); + int primary_monitor = uscreen->GetPrimaryMonitor(); auto const& geo = uscreen->GetMonitorGeometry(primary_monitor); + double monitor_scaling = em(primary_monitor)->DPIScale(); - new_form_factor = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK; + new_form_factor = (geo.height * monitor_scaling) >= MINIMUM_DESKTOP_HEIGHT ? FormFactor::DESKTOP : FormFactor::NETBOOK; } else { @@ -239,6 +241,17 @@ cursor_scale_ = g_settings_get_double(ui_settings_, CURSOR_SCALE_FACTOR.c_str()); } + EMConverter::Ptr const& em(int monitor) const + { + if (monitor < 0 || monitor >= (int)monitors::MAX) + { + LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Returning index 0 monitor instead."; + return em_converters_[0]; + } + + return em_converters_[monitor]; + } + void UpdateDPI() { auto* uscreen = UScreen::GetDefault(); @@ -361,13 +374,7 @@ EMConverter::Ptr const& Settings::em(int monitor) const { - if (monitor < 0 || monitor >= (int)monitors::MAX) - { - LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Returning index 0 monitor instead."; - return pimpl->em_converters_[0]; - } - - return pimpl->em_converters_[monitor]; + return pimpl->em(monitor); } void Settings::SetLauncherWidth(int launcher_width, int monitor) diff -Nru unity-7.2.2+14.04.20140714/unity-shared/VScrollBarOverlayWindow.cpp unity-7.2.3+14.04.20140826/unity-shared/VScrollBarOverlayWindow.cpp --- unity-7.2.2+14.04.20140714/unity-shared/VScrollBarOverlayWindow.cpp 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/VScrollBarOverlayWindow.cpp 2014-08-26 15:48:28.000000000 +0200 @@ -31,15 +31,15 @@ namespace { - int const THUMB_WIDTH = 21; - int const THUMB_HEIGHT = 68; - int const THUMB_RADIUS = 3; - int const ANIMATION_DURATION = 90; + const RawPixel THUMB_WIDTH = 21_em; + const RawPixel THUMB_HEIGHT = 68_em; + const int THUMB_RADIUS = 3; + const int ANIMATION_DURATION = 90; } - VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) : nux::BaseWindow("") + , scale(1.0) , content_size_(geo) , content_offset_x_(0) , mouse_offset_y_(0) @@ -47,8 +47,9 @@ , current_action_(ThumbAction::NONE) , show_animator_(ANIMATION_DURATION) { - Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH, content_size_.height); + Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); SetBackgroundColor(nux::color::Transparent); + SetAcceptMouseWheelEvent(true); show_animator_.updated.connect(sigc::mem_fun(this, &BaseWindow::SetOpacity)); show_animator_.finished.connect([this] { @@ -58,6 +59,17 @@ SetOpacity(0.0f); UpdateTexture(); + + scale.changed.connect([this] (double scale) { + UpdateContentGeometry(); + UpdateTexture(); + }); +} + +void VScrollBarOverlayWindow::UpdateContentGeometry() +{ + UpdateMouseOffsetX(); + Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); } void VScrollBarOverlayWindow::UpdateGeometry(nux::Geometry const& geo) @@ -67,9 +79,7 @@ content_size_.height != geo.height) { content_size_ = geo; - UpdateMouseOffsetX(); - - Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH, content_size_.height); + UpdateContentGeometry(); } } @@ -91,8 +101,8 @@ { if (new_offset < 0) return 0; - else if (new_offset > content_size_.height - THUMB_HEIGHT) - return content_size_.height - THUMB_HEIGHT; + else if (new_offset > content_size_.height - THUMB_HEIGHT.CP(scale)) + return content_size_.height - THUMB_HEIGHT.CP(scale); return new_offset; } @@ -102,15 +112,15 @@ int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse(); nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor); - if (content_size_.x + THUMB_WIDTH > geo.x + geo.width) - content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH); + if (content_size_.x + THUMB_WIDTH.CP(scale) > geo.x + geo.width) + content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH.CP(scale)); else content_offset_x_ = 0; } bool VScrollBarOverlayWindow::IsMouseInsideThumb(int y) const { - nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); + nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); return thumb.IsPointInside(0,y); } @@ -121,7 +131,7 @@ int VScrollBarOverlayWindow::GetThumbHeight() const { - return THUMB_HEIGHT; + return THUMB_HEIGHT.CP(scale); } int VScrollBarOverlayWindow::GetThumbOffsetY() const @@ -133,7 +143,7 @@ { return nux::Geometry(content_size_.x + content_offset_x_, content_size_.y + mouse_offset_y_, - THUMB_WIDTH, THUMB_HEIGHT); + THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); } void VScrollBarOverlayWindow::MouseDown() @@ -267,7 +277,7 @@ if (!thumb_texture_) return; - nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); + nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); nux::TexCoordXForm texxform; graphics_engine.QRP_1Tex(base.x, @@ -372,7 +382,7 @@ } -void DrawArrow (cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) +void DrawArrow(cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) { cairo_save (cr); @@ -417,37 +427,30 @@ { int width = THUMB_WIDTH; int height = THUMB_HEIGHT; - int radius = THUMB_RADIUS; float const aspect = 1.0f; float current_x = 0.0f; float current_y = 0.0f; - cairo_t* cr = NULL; - cairo_pattern_t* pat = NULL; - - nux::color::RedGreenBlue const& bg = nux::color::WhiteSmoke; - nux::color::RedGreenBlue const& bg_selected = nux::color::White; - nux::color::RedGreenBlue const& bg_active = nux::color::Gray; - nux::color::RedGreenBlue const& arrow_color = nux::color::DarkSlateGray; - - nux::color::RedGreenBlue const& bg_arrow_up = ProduceColorShade(bg, 0.86); - nux::color::RedGreenBlue const& bg_arrow_down = ProduceColorShade(bg, 1.1); - nux::color::RedGreenBlue const& bg_shadow = ProduceColorShade(bg, 0.2); - - nux::color::RedGreenBlue const& bg_dark_line = ProduceColorShade(bg, 0.4); - nux::color::RedGreenBlue const& bg_bright_line = ProduceColorShade(bg, 1.2); - - nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics.GetInternalContext(); - - cairo_save(cr); + auto const& bg = nux::color::WhiteSmoke; + auto const& bg_selected = nux::color::White; + auto const& bg_active = nux::color::Gray; + auto const& arrow_color = nux::color::DarkSlateGray; + + auto const& bg_arrow_up = ProduceColorShade(bg, 0.86); + auto const& bg_arrow_down = ProduceColorShade(bg, 1.1); + auto const& bg_shadow = ProduceColorShade(bg, 0.2); + + auto const& bg_dark_line = ProduceColorShade(bg, 0.4); + auto const& bg_bright_line = ProduceColorShade(bg, 1.2); + + nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); + cairo_t* cr = cairoGraphics.GetInternalContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); - cairo_save(cr); - cairo_translate (cr, 0.5, 0.5); width--; height--; @@ -455,15 +458,14 @@ cairo_set_line_width (cr, 1.0); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_save(cr); // Draw backgound SetSourceRGB(cr, bg, 1.0); - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width, height); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width, height); cairo_fill_preserve(cr); // Draw shaded background - pat = cairo_pattern_create_linear(0, 0, 0, height); + cairo_pattern_t* pat = cairo_pattern_create_linear(0, 0, 0, height); PatternAddRGBStop(pat, bg_arrow_up, 0.0, 0.8); PatternAddRGBStop(pat, bg_arrow_down, 1.0, 0.8); @@ -502,7 +504,7 @@ current_x += 0.5; current_y += 0.5; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 1, height - 1); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 1, height - 1); if (HasState(ThumbState::INSIDE_SLIDER)) SetSourceRGB(cr, bg_selected, 1.0); @@ -545,12 +547,12 @@ current_x += 0.5; current_y += 0.5; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width- 2, height - 2); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width- 2, height - 2); cairo_stroke(cr); current_x += 1.0; current_y += 1.0; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 4, height- 4); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 4, height- 4); SetSourceRGB(cr, bg_bright_line, 0.6); cairo_stroke(cr); @@ -558,7 +560,7 @@ DrawLineSeperator(cr, bg_dark_line, bg_bright_line, width, height); DrawBothArrows(cr, arrow_color, width, height); - thumb_texture_.Adopt(unity::texture_from_cairo_graphics(cairoGraphics)); + thumb_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); QueueDraw(); } diff -Nru unity-7.2.2+14.04.20140714/unity-shared/VScrollBarOverlayWindow.h unity-7.2.3+14.04.20140826/unity-shared/VScrollBarOverlayWindow.h --- unity-7.2.2+14.04.20140714/unity-shared/VScrollBarOverlayWindow.h 2014-07-14 16:29:52.000000000 +0200 +++ unity-7.2.3+14.04.20140826/unity-shared/VScrollBarOverlayWindow.h 2014-08-26 15:48:28.000000000 +0200 @@ -32,7 +32,8 @@ { public: VScrollBarOverlayWindow(nux::Geometry const& geo); - virtual ~VScrollBarOverlayWindow() {} + + nux::Property scale; void UpdateGeometry(nux::Geometry const& geo); void SetThumbOffsetY(int y); @@ -85,6 +86,7 @@ void MouseDragging(); void UpdateMouseOffsetX(); + void UpdateContentGeometry(); int GetValidOffsetYValue(int y) const; void ShouldShow();