diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-20 05:05:39 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-20 05:05:39 +0100 |
| commit | 12e58e7ee80d7cc920edbefac49bc4cbf4245077 (patch) | |
| tree | 10d54be035d472dfc933d320eb8cc0fdea5428ef /dash | |
| parent | 7f2517160f6154a2fb650c50f7de311d68d2dc7d (diff) | |
Dash: use nux::Property for scale
(bzr r3725.6.2)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/DashView.cpp | 10 | ||||
| -rw-r--r-- | dash/FilterBar.cpp | 15 | ||||
| -rw-r--r-- | dash/FilterBar.h | 7 | ||||
| -rw-r--r-- | dash/FilterExpanderLabel.cpp | 9 | ||||
| -rw-r--r-- | dash/FilterExpanderLabel.h | 6 | ||||
| -rwxr-xr-x | dash/PlacesGroup.cpp | 65 | ||||
| -rw-r--r-- | dash/PlacesGroup.h | 7 | ||||
| -rw-r--r-- | dash/ResultRenderer.cpp | 7 | ||||
| -rw-r--r-- | dash/ResultRenderer.h | 6 | ||||
| -rw-r--r-- | dash/ResultRendererHorizontalTile.cpp | 77 | ||||
| -rw-r--r-- | dash/ResultRendererHorizontalTile.h | 2 | ||||
| -rw-r--r-- | dash/ResultRendererTile.cpp | 55 | ||||
| -rw-r--r-- | dash/ResultRendererTile.h | 2 | ||||
| -rw-r--r-- | dash/ResultView.cpp | 20 | ||||
| -rw-r--r-- | dash/ResultView.h | 7 | ||||
| -rw-r--r-- | dash/ResultViewGrid.cpp | 4 | ||||
| -rw-r--r-- | dash/ResultViewGrid.h | 6 | ||||
| -rw-r--r-- | dash/ScopeBar.cpp | 28 | ||||
| -rw-r--r-- | dash/ScopeBar.h | 8 | ||||
| -rw-r--r-- | dash/ScopeBarIcon.cpp | 26 | ||||
| -rw-r--r-- | dash/ScopeBarIcon.h | 7 | ||||
| -rwxr-xr-x | dash/ScopeView.cpp | 37 | ||||
| -rw-r--r-- | dash/ScopeView.h | 10 |
23 files changed, 174 insertions, 247 deletions
diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 89e7717e8..e8451b77d 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -547,7 +547,7 @@ void DashView::SetupViews() content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); search_bar_ = new SearchBar(true); - search_bar_->UpdateScale(cv_->DPIScale()); + search_bar_->scale = cv_->DPIScale(); AddChild(search_bar_); search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); @@ -581,10 +581,10 @@ void DashView::OnDPIChanged() UpdateDashViewSize(); for (auto& scope : scope_views_) - scope.second->UpdateScale(scale); + scope.second->scale = scale; - search_bar_->UpdateScale(scale); - scope_bar_->UpdateScale(cv_->DPIScale()); + search_bar_->scale = scale; + scope_bar_->scale = scale; } void DashView::UpdateDashViewSize() @@ -1282,7 +1282,7 @@ void DashView::OnScopeAdded(Scope::Ptr const& scope, int position) nux::ObjectPtr<ScopeView> view(new ScopeView(scope, search_bar_->show_filters())); AddChild(view.GetPointer()); - view->UpdateScale(cv_->DPIScale()); + view->scale = cv_->DPIScale(); view->SetVisible(false); view->result_activated.connect(sigc::mem_fun(this, &DashView::OnResultActivated)); diff --git a/dash/FilterBar.cpp b/dash/FilterBar.cpp index 82bb4d51b..1f477486c 100644 --- a/dash/FilterBar.cpp +++ b/dash/FilterBar.cpp @@ -45,7 +45,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(FilterBar); FilterBar::FilterBar(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) - , scale_(DEFAULT_SCALE) + , scale(DEFAULT_SCALE) { Init(); } @@ -61,19 +61,14 @@ void FilterBar::Init() nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding()); layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding()); + scale.changed.connect(sigc::mem_fun(this, &FilterBar::UpdateScale)); SetLayout(layout); } void FilterBar::UpdateScale(double scale) { - if (scale_ != scale) - { - scale_ = scale; - for (auto& filters : filter_map_) - { - filters.second->UpdateScale(scale_); - } - } + for (auto& filters : filter_map_) + filters.second->scale = scale; } void FilterBar::SetFilters(Filters::Ptr const& filters) @@ -90,7 +85,7 @@ void FilterBar::AddFilter(Filter::Ptr const& filter) } FilterExpanderLabel* filter_view = factory_.WidgetForFilter(filter); - filter_view->UpdateScale(scale_); + filter_view->scale = scale(); AddChild(filter_view); filter_map_[filter] = filter_view; GetLayout()->AddView(filter_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL); diff --git a/dash/FilterBar.h b/dash/FilterBar.h index 9508d6871..9c3112b60 100644 --- a/dash/FilterBar.h +++ b/dash/FilterBar.h @@ -44,9 +44,9 @@ public: FilterBar(NUX_FILE_LINE_PROTO); ~FilterBar(); - void SetFilters(Filters::Ptr const& filters); + nux::Property<double> scale; - void UpdateScale(double scale); + void SetFilters(Filters::Ptr const& filters); void AddFilter(Filter::Ptr const& filter); void RemoveFilter(Filter::Ptr const& filter); @@ -63,12 +63,11 @@ protected: private: void Init(); + void UpdateScale(double scale); FilterFactory factory_; Filters::Ptr filters_; std::map<Filter::Ptr, FilterExpanderLabel*> filter_map_; - - double scale_; }; } // namespace dash diff --git a/dash/FilterExpanderLabel.cpp b/dash/FilterExpanderLabel.cpp index a46600ad9..11d7be456 100644 --- a/dash/FilterExpanderLabel.cpp +++ b/dash/FilterExpanderLabel.cpp @@ -86,6 +86,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel); FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL) : nux::View(NUX_FILE_LINE_PARAM) + , scale(DEFAULT_SCALE) , expanded(true) , layout_(nullptr) , top_bar_layout_(nullptr) @@ -95,8 +96,8 @@ FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE , cairo_label_(nullptr) , raw_label_(label) , label_("label") - , scale_(DEFAULT_SCALE) { + scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale)); expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange)); BuildLayout(); } @@ -110,11 +111,7 @@ void FilterExpanderLabel::SetLabel(std::string const& label) void FilterExpanderLabel::UpdateScale(double scale) { - if (scale_ != scale) - { - scale_ = scale; - cairo_label_->SetScale(scale); - } + cairo_label_->SetScale(scale); } void FilterExpanderLabel::SetRightHandView(nux::View* view) diff --git a/dash/FilterExpanderLabel.h b/dash/FilterExpanderLabel.h index 62c0d43a0..74d7c0d32 100644 --- a/dash/FilterExpanderLabel.h +++ b/dash/FilterExpanderLabel.h @@ -59,13 +59,12 @@ public: void SetLabel(std::string const& label); void SetContents(nux::Layout* layout); - void UpdateScale(double scale); - virtual void SetFilter(Filter::Ptr const& filter) = 0; virtual std::string GetFilterType() = 0; nux::View* expander_view() const { return expander_view_; } + nux::Property<double> scale; nux::Property<bool> expanded; protected: @@ -83,6 +82,7 @@ private: void BuildLayout(); void DoExpandChange(bool change); bool ShouldBeHighlighted(); + void UpdateScale(double scale); nux::LinearLayout* layout_; nux::LinearLayout* top_bar_layout_; @@ -99,8 +99,6 @@ private: nux::ObjectPtr<nux::Layout> contents_; std::unique_ptr<nux::AbstractPaintLayer> focus_layer_; - - double scale_; }; } // namespace dash diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp index 414b07e0d..d61f142d9 100755 --- a/dash/PlacesGroup.cpp +++ b/dash/PlacesGroup.cpp @@ -117,6 +117,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(PlacesGroup); PlacesGroup::PlacesGroup(dash::StyleInterface& style) : nux::View(NUX_TRACKER_LOCATION), + scale(DEFAULT_SCALE), _style(style), _child_layout(nullptr), _child_view(nullptr), @@ -126,14 +127,14 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style) _n_visible_items_in_unexpand_mode(0), _n_total_items(0), _coverflow_enabled(false), - _disabled_header_count(false), - _scale(DEFAULT_SCALE) + _disabled_header_count(false) { SetAcceptKeyNavFocusOnMouseDown(false); SetAcceptKeyNavFocusOnMouseEnter(false); + scale.changed.connect(sigc::mem_fun(this, &PlacesGroup::UpdateScale)); nux::BaseTexture* arrow = _style.GetGroupExpandIcon(); - + _background = _style.GetCategoryBackground(); _background_nofilters = _style.GetCategoryBackgroundNoFilters(); @@ -163,7 +164,7 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style) _header_view->SetLayout(_header_layout); RawPixel const icon_size = _style.GetCategoryIconSize(); - _icon = new IconTexture("", icon_size.CP(_scale)); + _icon = new IconTexture("", icon_size.CP(scale())); _header_layout->AddView(_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); _text_layout = new nux::HLayout(NUX_TRACKER_LOCATION); @@ -225,43 +226,37 @@ PlacesGroup::UpdatePlacesGroupSize() RawPixel const icon_size = _style.GetCategoryIconSize(); RawPixel const group_top = _style.GetPlacesGroupTopSpace(); - int top_space = group_top.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->SetSpaceBetweenChildren(SPACE_BETWEEN_CHILDREN.CP(scale())); - _icon->SetMinMaxSize(icon_size.CP(_scale), icon_size.CP(_scale)); + _icon->SetMinMaxSize(icon_size.CP(scale()), icon_size.CP(scale())); - _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(_scale)); - _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(_scale)); + _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(scale())); + _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(scale())); } void PlacesGroup::UpdateScale(double scale) { - if (_scale != scale) - { - RawPixel const icon_size = _style.GetCategoryIconSize(); + RawPixel const icon_size = _style.GetCategoryIconSize(); - _scale = scale; - _name->SetScale(_scale); - _expand_label->SetScale(_scale); + _name->SetScale(scale); + _expand_label->SetScale(scale); - _icon->SetSize(icon_size.CP(_scale)); - _icon->ReLoadIcon(); + _icon->SetSize(icon_size.CP(scale)); + _icon->ReLoadIcon(); - // FIXME _expand_icon, needs some work here. Not as easy as _icon + // FIXME _expand_icon, needs some work here. Not as easy as _icon - if (_child_view) - { - _child_view->UpdateScale(scale); - } + if (_child_view) + _child_view->scale = scale; - ComputeContentSize(); - UpdatePlacesGroupSize(); - UpdateResultViewPadding(); - } + ComputeContentSize(); + UpdatePlacesGroupSize(); + UpdateResultViewPadding(); } void @@ -326,8 +321,8 @@ PlacesGroup::UpdateResultViewPadding() 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(result_top_padding.CP(scale()), 0); + _child_layout->SetLeftAndRightPadding(result_left_padding.CP(scale()), 0); } } @@ -345,7 +340,7 @@ PlacesGroup::SetChildView(dash::ResultView* view) AddChild(view); _child_view = view; - _child_view->UpdateScale(_scale); + _child_view->scale = scale(); _child_layout = new nux::VLayout(); _child_layout->AddView(_child_view, 0); @@ -468,9 +463,9 @@ long PlacesGroup::ComputeContentSize() if (_cached_geometry.GetWidth() != geo.GetWidth()) { _focus_layer.reset(_style.FocusOverlay(geo.width - - kHighlightLeftPadding.CP(_scale) - - kHighlightRightPadding.CP(_scale), - kHighlightHeight.CP(_scale))); + kHighlightLeftPadding.CP(scale()) - + kHighlightRightPadding.CP(scale()), + kHighlightHeight.CP(scale()))); _cached_geometry = geo; } return ret; @@ -489,10 +484,10 @@ void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine, { nux::Geometry geo(_header_layout->GetGeometry()); geo.width = base.width - - kHighlightRightPadding.CP(_scale) - - kHighlightLeftPadding.CP(_scale); + kHighlightRightPadding.CP(scale()) - + kHighlightLeftPadding.CP(scale()); - geo.x += kHighlightLeftPadding.CP(_scale); + geo.x += kHighlightLeftPadding.CP(scale()); _focus_layer->SetGeometry(geo); _focus_layer->Renderlayer(graphics_engine); diff --git a/dash/PlacesGroup.h b/dash/PlacesGroup.h index 536be4fc1..d99883703 100644 --- a/dash/PlacesGroup.h +++ b/dash/PlacesGroup.h @@ -59,6 +59,8 @@ public: PlacesGroup(dash::StyleInterface& style); + nux::Property<double> scale; + void SetIcon(std::string const& icon); void SetName(std::string const& name); void SetHeaderCountVisible(bool disable); @@ -94,8 +96,6 @@ public: glib::Variant GetCurrentFocus() const; void SetCurrentFocus(glib::Variant const& variant); - void UpdateScale(double scale); - protected: long ComputeContentSize(); @@ -126,6 +126,7 @@ private: void UpdatePlacesGroupSize(); void UpdateResultViewPadding(); + void UpdateScale(double scale); private: std::string _category_id; @@ -166,8 +167,6 @@ private: glib::Source::UniquePtr _relayout_idle; UBusManager _ubus; - double _scale; - friend class TestScopeView; }; diff --git a/dash/ResultRenderer.cpp b/dash/ResultRenderer.cpp index ed8d567e1..c0566b3ba 100644 --- a/dash/ResultRenderer.cpp +++ b/dash/ResultRenderer.cpp @@ -118,7 +118,7 @@ ResultRenderer::ResultRenderer(NUX_FILE_LINE_DECL) : InitiallyUnownedObject(NUX_FILE_LINE_PARAM) , width(50) , height(50) - , scale_(DEFAULT_SCALE) + , scale(DEFAULT_SCALE) {} void ResultRenderer::Render(nux::GraphicsEngine& GfxContext, @@ -147,11 +147,6 @@ nux::NBitmapData* ResultRenderer::GetDndImage(Result const& row) const return graphics.GetBitmap(); } -void ResultRenderer::UpdateScale(double scale) -{ - scale_ = scale; -} - } } diff --git a/dash/ResultRenderer.h b/dash/ResultRenderer.h index b53ad5398..26b47f7e6 100644 --- a/dash/ResultRenderer.h +++ b/dash/ResultRenderer.h @@ -70,15 +70,11 @@ public: // get a image to drag virtual nux::NBitmapData* GetDndImage(Result const& row) const; - virtual void UpdateScale(double scale); - nux::Property<int> width; nux::Property<int> height; + nux::Property<double> scale; sigc::signal<void> NeedsRedraw; - -protected: - double scale_; }; } diff --git a/dash/ResultRendererHorizontalTile.cpp b/dash/ResultRendererHorizontalTile.cpp index 77f6a8624..8b2fb9175 100644 --- a/dash/ResultRendererHorizontalTile.cpp +++ b/dash/ResultRendererHorizontalTile.cpp @@ -90,18 +90,13 @@ ResultRendererHorizontalTile::ResultRendererHorizontalTile(NUX_FILE_LINE_DECL) : ResultRendererTile(NUX_FILE_LINE_PARAM) { ReloadTextures(); -} - -void ResultRendererHorizontalTile::UpdateScale(double scale) -{ - ResultRenderer::UpdateScale(scale); - ReloadTextures(); + scale.changed.connect([this] (double) { ReloadTextures(); }); } void ResultRendererHorizontalTile::ReloadTextures() { - width = CARD_VIEW_WIDTH.CP(scale_); - height = CARD_VIEW_HEIGHT.CP(scale_); + width = CARD_VIEW_WIDTH.CP(scale()); + height = CARD_VIEW_HEIGHT.CP(scale()); // pre-load the highlight texture // try and get a texture from the texture cache @@ -134,15 +129,15 @@ void ResultRendererHorizontalTile::Render(nux::GraphicsEngine& GfxContext, nux::TexCoordXForm texxform; int icon_left_hand_side = geometry.x + Padding(); - int icon_top_side = geometry.y + ((geometry.height - CARD_VIEW_ICON_SIZE.CP(scale_)) / 2); + int icon_top_side = geometry.y + ((geometry.height - CARD_VIEW_ICON_SIZE.CP(scale())) / 2); // render overall tile background "rectangle" if (state == ResultRendererState::RESULT_RENDERER_NORMAL) { int x = icon_left_hand_side; int y = icon_top_side; - int w = CARD_VIEW_WIDTH.CP(scale_); - int h = CARD_VIEW_HEIGHT.CP(scale_); + int w = CARD_VIEW_WIDTH.CP(scale()); + int h = CARD_VIEW_HEIGHT.CP(scale()); unsigned int alpha = 0; unsigned int src = 0; @@ -168,8 +163,8 @@ void ResultRendererHorizontalTile::Render(nux::GraphicsEngine& GfxContext, { int x = icon_left_hand_side; int y = icon_top_side; - int w = CARD_VIEW_WIDTH.CP(scale_); - int h = CARD_VIEW_HEIGHT.CP(scale_); + int w = CARD_VIEW_WIDTH.CP(scale()); + int h = CARD_VIEW_HEIGHT.CP(scale()); RenderTexture(GfxContext, x, @@ -185,15 +180,15 @@ void ResultRendererHorizontalTile::Render(nux::GraphicsEngine& GfxContext, // draw the icon if (container->icon) { - int x = icon_left_hand_side + CARD_VIEW_PADDING.CP(scale_) + CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_); - int y = icon_top_side + CARD_VIEW_PADDING.CP(scale_) + CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_); - int w = CARD_VIEW_ICON_SIZE.CP(scale_); - int h = CARD_VIEW_ICON_SIZE.CP(scale_); + int x = icon_left_hand_side + CARD_VIEW_PADDING.CP(scale()) + CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()); + int y = icon_top_side + CARD_VIEW_PADDING.CP(scale()) + CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()); + int w = CARD_VIEW_ICON_SIZE.CP(scale()); + int h = CARD_VIEW_ICON_SIZE.CP(scale()); gPainter.Paint2DQuadColor(GfxContext, - x - CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_), - y - CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_), - w + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_), - h + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_), + x - CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()), + y - CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()), + w + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()), + h + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()), nux::color::Black); RenderTexture(GfxContext, x, @@ -209,12 +204,12 @@ void ResultRendererHorizontalTile::Render(nux::GraphicsEngine& GfxContext, if (container->text) { int x = icon_left_hand_side + - CARD_VIEW_PADDING.CP(scale_) + - 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_) + - CARD_VIEW_ICON_SIZE.CP(scale_) + - CARD_VIEW_ICON_TEXT_GAP.CP(scale_); + CARD_VIEW_PADDING.CP(scale()) + + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()) + + CARD_VIEW_ICON_SIZE.CP(scale()) + + CARD_VIEW_ICON_TEXT_GAP.CP(scale()); - int y = icon_top_side + CARD_VIEW_PADDING.CP(scale_); + int y = icon_top_side + CARD_VIEW_PADDING.CP(scale()); int w = container->text->GetWidth(); int h = container->text->GetHeight(); @@ -234,7 +229,7 @@ nux::BaseTexture* ResultRendererHorizontalTile::DrawHighlight(std::string const& int width, int height) { nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height); - cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale_, scale_); + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale(), scale()); cairo_t* cr = cairo_graphics.GetInternalContext(); cairo_scale(cr, 1.0f, 1.0f); @@ -263,7 +258,7 @@ nux::BaseTexture* ResultRendererHorizontalTile::DrawNormal(std::string const& te int width, int height) { nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height); - cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale_, scale_); + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale(), scale()); cairo_t* cr = cairo_graphics.GetInternalContext(); cairo_scale(cr, 1.0f, 1.0f); @@ -280,8 +275,8 @@ nux::BaseTexture* ResultRendererHorizontalTile::DrawNormal(std::string const& te 0.0f, 0.0f, CARD_VIEW_HIGHLIGHT_CORNER_RADIUS, - width/scale_, - height/scale_, + width/scale(), + height/scale(), false); cairo_fill(cr); @@ -303,14 +298,14 @@ void ResultRendererHorizontalTile::LoadText(Result const& row) g_free(comment); nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32, - CARD_VIEW_WIDTH.CP(scale_) - - CARD_VIEW_ICON_SIZE.CP(scale_) - - 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale_) - - 2 * CARD_VIEW_PADDING.CP(scale_) - - CARD_VIEW_ICON_TEXT_GAP.CP(scale_), - CARD_VIEW_HEIGHT.CP(scale_) - - 2 * CARD_VIEW_PADDING.CP(scale_)); - cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale_, scale_); + CARD_VIEW_WIDTH.CP(scale()) - + CARD_VIEW_ICON_SIZE.CP(scale()) - + 2 * CARD_VIEW_ICON_OUTLINE_WIDTH.CP(scale()) - + 2 * CARD_VIEW_PADDING.CP(scale()) - + CARD_VIEW_ICON_TEXT_GAP.CP(scale()), + CARD_VIEW_HEIGHT.CP(scale()) - + 2 * CARD_VIEW_PADDING.CP(scale())); + cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale()); cairo_t* cr = _cairoGraphics.GetInternalContext(); @@ -382,11 +377,11 @@ nux::NBitmapData* ResultRendererHorizontalTile::GetDndImage(Result const& row) c int width = gdk_pixbuf_get_width(container->drag_icon); int height = gdk_pixbuf_get_height(container->drag_icon); - if (width != CARD_VIEW_ICON_SIZE.CP(scale_) || height != CARD_VIEW_ICON_SIZE.CP(scale_)) + if (width != CARD_VIEW_ICON_SIZE.CP(scale()) || height != CARD_VIEW_ICON_SIZE.CP(scale())) { nux::GdkGraphics graphics(gdk_pixbuf_scale_simple(container->drag_icon, - CARD_VIEW_ICON_SIZE.CP(scale_), - CARD_VIEW_ICON_SIZE.CP(scale_), + CARD_VIEW_ICON_SIZE.CP(scale()), + CARD_VIEW_ICON_SIZE.CP(scale()), GDK_INTERP_BILINEAR)); bitmap = graphics.GetBitmap(); } diff --git a/dash/ResultRendererHorizontalTile.h b/dash/ResultRendererHorizontalTile.h index 1fdf2e259..e6cd48894 100644 --- a/dash/ResultRendererHorizontalTile.h +++ b/dash/ResultRendererHorizontalTile.h @@ -51,8 +51,6 @@ public: virtual nux::NBitmapData* GetDndImage(Result const& row) const; - void UpdateScale(double scale); - protected: virtual void LoadText(Result const& row); diff --git a/dash/ResultRendererTile.cpp b/dash/ResultRendererTile.cpp index b6181edcf..afc5b2935 100644 --- a/dash/ResultRendererTile.cpp +++ b/dash/ResultRendererTile.cpp @@ -93,6 +93,7 @@ ResultRendererTile::ResultRendererTile(NUX_FILE_LINE_DECL) : ResultRenderer(NUX_FILE_LINE_PARAM) { UpdateWidthHeight(); + scale.changed.connect([this] (double) { UpdateWidthHeight(); }); } void ResultRendererTile::UpdateWidthHeight() @@ -101,14 +102,8 @@ void ResultRendererTile::UpdateWidthHeight() RawPixel tile_width = style.GetTileWidth(); RawPixel tile_height = style.GetTileHeight(); - width = tile_width.CP(scale_); - height = tile_height.CP(scale_); -} - -void ResultRendererTile::UpdateScale(double scale) -{ - ResultRenderer::UpdateScale(scale); - UpdateWidthHeight(); + width = tile_width.CP(scale()); + height = tile_height.CP(scale()); } void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, @@ -130,7 +125,7 @@ void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, 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 = tile_size.CP(scale()); // set up our texture mode nux::TexCoordXForm texxform; @@ -147,13 +142,13 @@ void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, } int icon_left_hand_side = geometry.x + (geometry.width - icon_width) / 2; - int icon_top_side = geometry.y + PADDING.CP(scale_) + (tile_icon_size - icon_height) / 2; + int icon_top_side = geometry.y + PADDING.CP(scale()) + (tile_icon_size - icon_height) / 2; // 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) - tile_highlight_width.CP(scale())/2; + int highlight_y = (geometry.y + PADDING.CP(scale()) + tile_icon_size / 2) - tile_highlight_height.CP(scale())/2; RenderTexture(GfxContext, highlight_x, @@ -183,10 +178,10 @@ void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, 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()), + tile_width.CP(scale()) - (PADDING.CP(scale()) * 2), + tile_height.CP(scale()) - tile_icon_size - SPACING.CP(scale()), container->text->GetDeviceTexture(), texxform, color, @@ -197,7 +192,7 @@ void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, nux::BaseTexture* ResultRendererTile::DrawHighlight(std::string const& texid, int width, int height) { nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height); - cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale_, scale_); + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale(), scale()); cairo_t* cr = cairo_graphics.GetInternalContext(); cairo_scale(cr, 1.0f, 1.0f); @@ -214,8 +209,8 @@ nux::BaseTexture* ResultRendererTile::DrawHighlight(std::string const& texid, in 0.0f, 0.0f, CORNER_HIGHTLIGHT_RADIUS, - width/scale_, - height/scale_, + width/scale(), + height/scale(), false); cairo_fill(cr); @@ -224,7 +219,7 @@ nux::BaseTexture* ResultRendererTile::DrawHighlight(std::string const& texid, in int ResultRendererTile::Padding() const { - return PADDING.CP(scale_); + return PADDING.CP(scale()); } void ResultRendererTile::Preload(Result const& row) @@ -292,8 +287,8 @@ void ResultRendererTile::LoadIcon(Result const& row) { TextureCache& cache = TextureCache::GetDefault(); BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", - tile_highlight_width.CP(scale_), - tile_highlight_height.CP(scale_), + tile_highlight_width.CP(scale()), + tile_highlight_height.CP(scale()), sigc::mem_fun(this, &ResultRendererTile::DrawHighlight))); container->prelight = texture_prelight; } @@ -304,13 +299,13 @@ void ResultRendererTile::LoadIcon(Result const& row) { 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.CP(scale()), use_large_icon ? - tile_size.CP(scale_) : tile_gsize.CP(scale_), slot); + tile_size.CP(scale()) : tile_gsize.CP(scale()), 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.CP(scale()), slot); } } @@ -345,7 +340,7 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t float aspect = static_cast<float>(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 = tile_size.CP(scale()); pixbuf_height = pixbuf_width * aspect; if (pixbuf_height > height) @@ -368,7 +363,7 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t } nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height); - cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale_, scale_); + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale(), scale()); cairo_t* cr = cairo_graphics.GetInternalContext(); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); @@ -479,9 +474,9 @@ void ResultRendererTile::LoadText(Result const& row) 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_)); - cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale_, scale_); + tile_width.CP(scale()) - (PADDING.CP(scale()) * 2), + tile_height.CP(scale()) - tile_size.CP(scale()) - SPACING.CP(scale())); + cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale()); cairo_t* cr = _cairoGraphics.GetInternalContext(); diff --git a/dash/ResultRendererTile.h b/dash/ResultRendererTile.h index 5c41c1419..fab30fae4 100644 --- a/dash/ResultRendererTile.h +++ b/dash/ResultRendererTile.h @@ -72,11 +72,9 @@ public: virtual void Preload(Result const& row); virtual void Unload(Result const& row); - virtual nux::NBitmapData* GetDndImage(Result const& row) const; void ReloadResult(Result const& row); - void UpdateScale(double scale) override; int Padding() const; diff --git a/dash/ResultView.cpp b/dash/ResultView.cpp index d0b9cd193..f098212d5 100644 --- a/dash/ResultView.cpp +++ b/dash/ResultView.cpp @@ -45,8 +45,8 @@ ResultView::ResultView(NUX_FILE_LINE_DECL) , expanded(true) , desaturation_progress(0.0) , enable_texture_render(false) + , scale(DEFAULT_SCALE) , renderer_(NULL) - , scale_(DEFAULT_SCALE) , cached_result_(nullptr, nullptr, nullptr) { expanded.changed.connect([this](bool value) @@ -61,6 +61,7 @@ ResultView::ResultView(NUX_FILE_LINE_DECL) }); enable_texture_render.changed.connect(sigc::mem_fun(this, &ResultView::OnEnableRenderToTexture)); + scale.changed.connect(sigc::mem_fun(this, &ResultView::UpdateScale)); } ResultView::~ResultView() @@ -81,21 +82,14 @@ ResultView::~ResultView() void ResultView::UpdateScale(double scale) { - if (scale_ != scale) + if (renderer_) { - scale_ = scale; + renderer_->scale = scale; - if (renderer_) - { - renderer_->UpdateScale(scale_); + for (auto const& result : *result_model_) + renderer_->ReloadResult(result); - for (auto it = result_model_->begin(); it != result_model_->end(); ++it) - { - renderer_->ReloadResult(*it); - } - - NeedRedraw(); - } + QueueDraw(); } } diff --git a/dash/ResultView.h b/dash/ResultView.h index 0abbb5f91..d91fa6316 100644 --- a/dash/ResultView.h +++ b/dash/ResultView.h @@ -81,6 +81,8 @@ public: nux::Property<std::string> unique_id; nux::Property<float> desaturation_progress; nux::Property<bool> enable_texture_render; + nux::Property<double> scale; + sigc::signal<void, LocalResult const&, ActivateType, GVariant*> ResultActivated; std::string GetName() const; @@ -88,8 +90,6 @@ public: void AddProperties(debug::IntrospectionData&); IntrospectableList GetIntrospectableChildren(); - virtual void UpdateScale(double scale); - virtual int GetSelectedIndex() const; virtual void SetSelectedIndex(int index); @@ -123,11 +123,10 @@ protected: std::vector<ResultViewTexture::Ptr> result_textures_; - double scale_; - private: void OnRowAdded(DeeModel* model, DeeModelIter* iter); void OnRowRemoved(DeeModel* model, DeeModelIter* iter); + void UpdateScale(double scale); Result cached_result_; connection::Manager result_connections_; diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index ffe47d12f..70872e449 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -91,6 +91,7 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) selected_index_.changed.connect(needredraw_lambda); expanded.changed.connect([this](bool value) { if (value) all_results_preloaded_ = false; }); results_per_row.changed.connect([this](int value) { if (value > 0) all_results_preloaded_ = false; }); + scale.changed.connect(sigc::mem_fun(this, &ResultViewGrid::UpdateScale)); key_nav_focus_change.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyNavFocusChange)); key_nav_focus_activate.connect([this] (nux::Area *area) @@ -351,7 +352,7 @@ void ResultViewGrid::SizeReallocate() int width = (items_per_row * renderer_->width) + (padding*2) + ((items_per_row - 1) * horizontal_spacing); int geo_width = GetBaseWidth(); - int extra_width = geo_width - (width + WIDTH_PADDING.CP(scale_) - SCROLLBAR_WIDTH.CP(scale_)); + int extra_width = geo_width - (width + WIDTH_PADDING.CP(scale()) - SCROLLBAR_WIDTH.CP(scale())); if (items_per_row != 1) extra_horizontal_spacing_ = extra_width / (items_per_row - 1); @@ -1013,7 +1014,6 @@ ResultViewGrid::SetSelectedIndex(int index) void ResultViewGrid::UpdateScale(double scale) { - ResultView::UpdateScale(scale); UpdateRenderTextures(); } diff --git a/dash/ResultViewGrid.h b/dash/ResultViewGrid.h index c039c2337..34a854b58 100644 --- a/dash/ResultViewGrid.h +++ b/dash/ResultViewGrid.h @@ -51,7 +51,7 @@ public: virtual int GetSelectedIndex() const; virtual void SetSelectedIndex(int index); - + virtual unsigned GetIndexAtPosition(int x, int y); virtual void Activate(LocalResult const& local_result, int index, ActivateType type); @@ -60,8 +60,6 @@ public: virtual void GetResultDimensions(int& rows, int& columns); - void UpdateScale(double scale); - protected: void MouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); void MouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags); @@ -101,6 +99,7 @@ private: void QueueLazyLoad(); void QueueResultsChanged(); bool DoLazyLoad(); + void UpdateScale(double scale); int GetItemsPerRow(); void SizeReallocate(); @@ -132,7 +131,6 @@ private: UBusManager ubus_; glib::Source::UniquePtr lazy_load_source_; glib::Source::UniquePtr results_changed_idle_; - glib::Source::UniquePtr activate_timer_; }; diff --git a/dash/ScopeBar.cpp b/dash/ScopeBar.cpp index 13ab67bc6..ebe9d82ea 100644 --- a/dash/ScopeBar.cpp +++ b/dash/ScopeBar.cpp @@ -48,16 +48,13 @@ NUX_IMPLEMENT_OBJECT_TYPE(ScopeBar); ScopeBar::ScopeBar() : nux::View(NUX_TRACKER_LOCATION) - , scale_(1.0) + , scale(1.0) { + scale.changed.connect(sigc::mem_fun(this, &ScopeBar::UpdateScale)); SetupBackground(); SetupLayout(); } -ScopeBar::~ScopeBar() -{ -} - void ScopeBar::SetupBackground() { nux::ROPConfig rop; @@ -69,16 +66,11 @@ void ScopeBar::SetupBackground() void ScopeBar::UpdateScale(double scale) { - if (scale_ != scale) - { - scale_ = scale; + SetMinimumHeight(SCOPEBAR_HEIGHT.CP(scale)); + SetMaximumHeight(SCOPEBAR_HEIGHT.CP(scale)); - SetMinimumHeight(SCOPEBAR_HEIGHT.CP(scale_)); - SetMaximumHeight(SCOPEBAR_HEIGHT.CP(scale_)); - - for (auto icon : icons_) - icon->UpdateScale(scale_); - } + for (auto icon : icons_) + icon->scale = scale; } void ScopeBar::SetupLayout() @@ -87,8 +79,8 @@ void ScopeBar::SetupLayout() layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER); SetLayout(layout_); - SetMinimumHeight(SCOPEBAR_HEIGHT.CP(scale_)); - SetMaximumHeight(SCOPEBAR_HEIGHT.CP(scale_)); + SetMinimumHeight(SCOPEBAR_HEIGHT.CP(scale())); + SetMaximumHeight(SCOPEBAR_HEIGHT.CP(scale())); } void ScopeBar::AddScope(Scope::Ptr const& scope) @@ -96,7 +88,7 @@ void ScopeBar::AddScope(Scope::Ptr const& scope) ScopeBarIcon* icon = new ScopeBarIcon(scope->id, scope->icon_hint); icon->SetVisible(scope->visible); - icon->UpdateScale(scale_); + icon->scale = scale(); scope->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } ); icons_.push_back(icon); layout_->AddView(icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); @@ -184,7 +176,7 @@ void ScopeBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw int middle = geo.x + geo.width/2; // Nux doesn't draw too well the small triangles, so let's draw a // bigger one and clip part of them using the "-1". - int size = TRIANGLE_SIZE.CP(scale_); + int size = TRIANGLE_SIZE.CP(scale()); int y = base.y - 1; nux::GetPainter().Draw2DTriangleColor(graphics_engine, diff --git a/dash/ScopeBar.h b/dash/ScopeBar.h index bdc2477c7..26b88a235 100644 --- a/dash/ScopeBar.h +++ b/dash/ScopeBar.h @@ -56,15 +56,14 @@ class ScopeBar : public nux::View, public unity::debug::Introspectable public: ScopeBar(); - ~ScopeBar(); + + nux::Property<double> scale; void AddScope(Scope::Ptr const& scope); void Activate(std::string id); void ActivateNext(); void ActivatePrevious(); - void UpdateScale(double scale); - std::string GetActiveScopeId() const; sigc::signal<void, std::string const&> scope_activated; @@ -77,6 +76,7 @@ private: void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw); void SetActive(ScopeBarIcon* icon); + void UpdateScale(double scale); bool AcceptKeyNavFocus(); std::string GetName() const; @@ -89,8 +89,6 @@ private: nux::HLayout* layout_; LayerPtr bg_layer_; - double scale_; - friend class TestScopeBar; }; diff --git a/dash/ScopeBarIcon.cpp b/dash/ScopeBarIcon.cpp index 4cb81b7f5..79597e5b2 100644 --- a/dash/ScopeBarIcon.cpp +++ b/dash/ScopeBarIcon.cpp @@ -42,12 +42,12 @@ ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint) : IconTexture(icon_hint, TEXTURE_SIZE) , id(id_) , active(false) + , scale(DEFAULT_SCALE) , inactive_opacity_(0.4f) - , scale_(DEFAULT_SCALE) { - SetMinMaxSize(FOCUS_OVERLAY_WIDTH.CP(scale_), FOCUS_OVERLAY_HEIGHT.CP(scale_)); + SetMinMaxSize(FOCUS_OVERLAY_WIDTH.CP(scale()), FOCUS_OVERLAY_HEIGHT.CP(scale())); - focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH.CP(scale_), FOCUS_OVERLAY_HEIGHT.CP(scale_))); + focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH.CP(scale()), FOCUS_OVERLAY_HEIGHT.CP(scale()))); SetOpacity(inactive_opacity_); @@ -56,26 +56,20 @@ ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint) SetAcceptKeyNavFocusOnMouseEnter(true); active.changed.connect(sigc::mem_fun(this, &ScopeBarIcon::OnActiveChanged)); + scale.changed.connect(sigc::mem_fun(this, &ScopeBarIcon::UpdateScale)); key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection){ QueueDraw(); }); } -ScopeBarIcon::~ScopeBarIcon() -{} - void ScopeBarIcon::UpdateScale(double scale) { - if (scale_ != scale) - { - scale_ = scale; - int overlay_width = FOCUS_OVERLAY_WIDTH.CP(scale_); - int overlay_height = FOCUS_OVERLAY_HEIGHT.CP(scale_); + int overlay_width = FOCUS_OVERLAY_WIDTH.CP(scale); + int overlay_height = FOCUS_OVERLAY_HEIGHT.CP(scale); - SetMinMaxSize(overlay_width, overlay_height); - focus_layer_.reset(Style::Instance().FocusOverlay(overlay_width, overlay_height)); + SetMinMaxSize(overlay_width, overlay_height); + focus_layer_.reset(Style::Instance().FocusOverlay(overlay_width, overlay_height)); - SetSize(TEXTURE_SIZE.CP(scale_)); - ReLoadIcon(); - } + SetSize(TEXTURE_SIZE.CP(scale)); + ReLoadIcon(); } void ScopeBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) diff --git a/dash/ScopeBarIcon.h b/dash/ScopeBarIcon.h index f83afd73e..a9825d168 100644 --- a/dash/ScopeBarIcon.h +++ b/dash/ScopeBarIcon.h @@ -38,16 +38,15 @@ class ScopeBarIcon : public IconTexture NUX_DECLARE_OBJECT_TYPE(ScopeBarIcon, IconTexture); public: ScopeBarIcon(std::string id, std::string icon_hint); - ~ScopeBarIcon(); - - void UpdateScale(double scale); nux::Property<std::string> id; nux::Property<bool> active; + nux::Property<double> scale; private: void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); void OnActiveChanged(bool is_active); + void UpdateScale(double scale); // Introspectable std::string GetName() const; @@ -58,8 +57,6 @@ private: const float inactive_opacity_; LayerPtr focus_layer_; - - double scale_; }; } diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp index d765d8b2e..d249ab4ef 100755 --- a/dash/ScopeView.cpp +++ b/dash/ScopeView.cpp @@ -153,6 +153,7 @@ ScopeView::ScopeView(Scope::Ptr const& scope, nux::Area* show_filters) : nux::View(NUX_TRACKER_LOCATION) , filters_expanded(false) , can_refine_search(false) +, scale(DEFAULT_SCALE) , scope_(scope) , no_results_active_(false) , last_good_filter_model_(-1) @@ -160,13 +161,13 @@ ScopeView::ScopeView(Scope::Ptr const& scope, nux::Area* show_filters) , scope_connected_(scope ? scope->connected : false) , search_on_next_connect_(false) , current_focus_category_position_(-1) -, scale_(DEFAULT_SCALE) { SetupViews(show_filters); search_string.SetGetterFunction(sigc::mem_fun(this, &ScopeView::get_search_string)); filters_expanded.changed.connect(sigc::mem_fun(this, &ScopeView::OnScopeFilterExpanded)); view_type.changed.connect(sigc::mem_fun(this, &ScopeView::OnViewTypeChanged)); + scale.changed.connect(sigc::mem_fun(this, &ScopeView::UpdateScale)); auto conn = nux::GetWindowCompositor().key_nav_focus_change.connect(sigc::mem_fun(this, &ScopeView::OnCompositorKeyNavFocusChanged)); key_nav_focus_connection_ = conn_manager_.Add(conn); @@ -215,8 +216,8 @@ ScopeView::ScopeView(Scope::Ptr const& scope, nux::Area* show_filters) (expand_label && expand_label->HasKeyFocus())) { focused_pos.x += child->GetGeometry().x; - focused_pos.y += child->GetGeometry().y - FOCUSED_OFFSET.CP(scale_); - focused_pos.height += FOCUSED_OFFSET.CP(scale_); + focused_pos.y += child->GetGeometry().y - FOCUSED_OFFSET.CP(scale()); + focused_pos.height += FOCUSED_OFFSET.CP(scale()); scroll_view_->ScrollToPosition(focused_pos); break; } @@ -281,27 +282,23 @@ void ScopeView::UpdateScopeViewSize() style.GetFilterBarLeftPadding() + style.GetFilterBarRightPadding(); - layout_->SetSpaceBetweenChildren(scope_filter_space.CP(scale_)); + 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_)); + 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)); } void ScopeView::UpdateScale(double scale) { - if (scale_ != scale) - { - scale_ = scale; - - UpdateScopeViewSize(); + UpdateScopeViewSize(); - for (auto& group : category_views_) - group->UpdateScale(scale_); + for (auto& group : category_views_) + group->scale = scale; - filter_bar_->UpdateScale(scale_); - } + filter_bar_->scale = scale; } void ScopeView::SetupCategories(Categories::Ptr const& categories) @@ -464,7 +461,7 @@ void ScopeView::OnCategoryAdded(Category const& category) group->SetIcon(icon_hint); group->SetExpanded(false); group->SetVisible(false); - group->UpdateScale(scale_); + group->scale = scale(); int view_index = category_order_.size(); auto find_view_index = std::find(category_order_.begin(), category_order_.end(), index); @@ -489,8 +486,8 @@ void ScopeView::OnCategoryAdded(Category const& category) { results_view = new ResultViewGrid(NUX_TRACKER_LOCATION); results_view->SetModelRenderer(new ResultRendererHorizontalTile(NUX_TRACKER_LOCATION)); - static_cast<ResultViewGrid*> (results_view)->horizontal_spacing = CARD_VIEW_GAP_HORIZ.CP(scale_); - static_cast<ResultViewGrid*> (results_view)->vertical_spacing = CARD_VIEW_GAP_VERT.CP(scale_); + static_cast<ResultViewGrid*> (results_view)->horizontal_spacing = CARD_VIEW_GAP_HORIZ.CP(scale()); + static_cast<ResultViewGrid*> (results_view)->vertical_spacing = CARD_VIEW_GAP_VERT.CP(scale()); } else { diff --git a/dash/ScopeView.h b/dash/ScopeView.h index 2cebd1a86..ac0659a43 100644 --- a/dash/ScopeView.h +++ b/dash/ScopeView.h @@ -69,6 +69,7 @@ public: nux::Property<bool> filters_expanded; nux::Property<ScopeViewType> view_type; nux::Property<bool> can_refine_search; + nux::Property<double> scale; sigc::signal<void, ResultView::ActivateType, LocalResult const&, GVariant*, std::string const&> result_activated; @@ -86,8 +87,6 @@ public: std::vector<ResultViewTexture::Ptr> GetResultTextureContainers(); void RenderResultTexture(ResultViewTexture::Ptr const& result_texture); - void UpdateScale(double scale); - private: void SetupViews(nux::Area* show_filters); void SetupCategories(Categories::Ptr const& categories); @@ -102,7 +101,7 @@ private: void OnResultRemoved(Result const& result); void OnSearchComplete(std::string const& search_string, glib::HintsMap const& hints, glib::Error const& err); - + void OnGroupExpanded(PlacesGroup* group); void CheckScrollBarState(); void OnColumnsChanged(); @@ -131,10 +130,11 @@ private: void BuildPreview(std::string const& uri, Preview::Ptr model); void UpdateScopeViewSize(); + void UpdateScale(double scale); virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw); - + virtual bool AcceptKeyNavFocus(); virtual std::string GetName() const; virtual void AddProperties(debug::IntrospectionData&); @@ -190,8 +190,6 @@ private: int current_focus_category_position_; glib::Variant current_focus_variant_; - double scale_; - friend class TestScopeView; }; |
