summaryrefslogtreecommitdiff
diff options
-rw-r--r--plugins/unityshell/src/DashStyle.h2
-rw-r--r--plugins/unityshell/src/DashView.cpp2
-rw-r--r--plugins/unityshell/src/FilterBar.cpp4
-rw-r--r--plugins/unityshell/src/FilterExpanderLabel.cpp113
-rw-r--r--plugins/unityshell/src/FilterExpanderLabel.h11
-rw-r--r--plugins/unityshell/src/FilterGenreWidget.cpp16
-rw-r--r--plugins/unityshell/src/FilterGenreWidget.h3
-rw-r--r--plugins/unityshell/src/FilterMultiRangeWidget.cpp17
-rw-r--r--plugins/unityshell/src/FilterMultiRangeWidget.h3
-rw-r--r--plugins/unityshell/src/FilterRatingsWidget.cpp16
-rw-r--r--plugins/unityshell/src/FilterRatingsWidget.h5
-rw-r--r--plugins/unityshell/src/LensView.cpp8
12 files changed, 115 insertions, 85 deletions
diff --git a/plugins/unityshell/src/DashStyle.h b/plugins/unityshell/src/DashStyle.h
index ae57c2c7e..5c29a7680 100644
--- a/plugins/unityshell/src/DashStyle.h
+++ b/plugins/unityshell/src/DashStyle.h
@@ -194,7 +194,7 @@ public:
// Paddings
static const int FILTERS_LEFT_PADDING = 0;
- static const int FILTERS_RIGHT_PADDING = 8;
+ static const int FILTERS_RIGHT_PADDING = 0;
sigc::signal<void> changed;
diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp
index 67713ceb3..12a3e8b6c 100644
--- a/plugins/unityshell/src/DashView.cpp
+++ b/plugins/unityshell/src/DashView.cpp
@@ -220,7 +220,7 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)
width = MAX(width, tile_width * 6);
- width += 19 + 32 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding
+ width += 19 + 32 + 8 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding
height = search_bar_->GetGeometry().height;
height += tile_height * 3;
diff --git a/plugins/unityshell/src/FilterBar.cpp b/plugins/unityshell/src/FilterBar.cpp
index c1aedfdd9..ecfc3241b 100644
--- a/plugins/unityshell/src/FilterBar.cpp
+++ b/plugins/unityshell/src/FilterBar.cpp
@@ -126,8 +126,8 @@ void FilterBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
GfxContext.GetRenderStates().SetColorMask(true, true, true, false);
nux::GetPainter().Draw2DLine(GfxContext,
- geom.x , geom.y + geom.height - 1,
- geom.x + geom.width, geom.y + geom.height - 1,
+ geom.x + 5, geom.y + geom.height - 1,
+ geom.x + geom.width - 9, geom.y + geom.height - 1,
col);
GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
}
diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp
index be4da93e6..ecffa2112 100644
--- a/plugins/unityshell/src/FilterExpanderLabel.cpp
+++ b/plugins/unityshell/src/FilterExpanderLabel.cpp
@@ -34,6 +34,30 @@ namespace unity
namespace dash
{
+class ExpanderView : public nux::View
+{
+public:
+ ExpanderView(NUX_FILE_LINE_DECL)
+ : nux::View(NUX_FILE_LINE_PARAM)
+ {
+ }
+
+protected:
+ void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
+ {
+ };
+
+ void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
+ {
+ if (GetLayout())
+ GetLayout()->ProcessDraw(graphics_engine, force_draw);
+ }
+
+ bool AcceptKeyNavFocus()
+ {
+ return false;
+ }
+};
NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
@@ -43,6 +67,8 @@ FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE
, expanded(true)
, layout_(nullptr)
, top_bar_layout_(nullptr)
+ , expander_view_(nullptr)
+ , expander_layout_(nullptr)
, right_hand_contents_(nullptr)
, cairo_label_(nullptr)
, raw_label_(label)
@@ -68,7 +94,7 @@ void FilterExpanderLabel::SetLabel(std::string const& label)
void FilterExpanderLabel::SetRightHandView(nux::View* view)
{
- view->SetMaximumHeight(30);
+ view->SetMinimumHeight(33);
right_hand_contents_ = view;
top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
@@ -88,20 +114,24 @@ void FilterExpanderLabel::SetContents(nux::Layout* contents)
void FilterExpanderLabel::BuildLayout()
{
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
+ layout_->SetLeftAndRightPadding(3, 1);
+
top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- top_bar_layout_->SetHorizontalInternalMargin(8);
+ top_bar_layout_->SetLeftAndRightPadding(2, 0);
+
+ expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
+ expander_layout_->SetSpaceBetweenChildren(8);
+
+
+ expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
+ expander_view_->SetLayout(expander_layout_);
+ top_bar_layout_->AddView(expander_view_, 0);
cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION);
cairo_label_->SetFontName("Ubuntu 10");
cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
cairo_label_->SetAcceptKeyNavFocusOnMouseDown(false);
- cairo_label_->mouse_down.connect(
- [&](int x, int y, unsigned long button_flags, unsigned long key_flag)
- {
- expanded = !expanded;
- });
-
nux::BaseTexture* arrow;
arrow = dash::Style::Instance().GetGroupUnexpandIcon();
expand_icon_ = new IconTexture(arrow,
@@ -110,11 +140,6 @@ void FilterExpanderLabel::BuildLayout()
expand_icon_->SetOpacity(kExpandDefaultIconOpacity);
expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
expand_icon_->SetVisible(true);
- expand_icon_->mouse_click.connect(
- [&] (int x, int y, unsigned long b, unsigned long k)
- {
- expanded = !expanded;
- });
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);
@@ -122,17 +147,39 @@ void FilterExpanderLabel::BuildLayout()
arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER);
arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER);
- top_bar_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
- top_bar_layout_->AddView(arrow_layout_, 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);
top_bar_layout_->AddSpace(1, 1);
- top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 20);
+ top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 19);
layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT);
layout_->SetVerticalInternalMargin(0);
SetLayout(layout_);
+ // Lambda functions
+ auto mouse_redraw = [&](int x, int y, unsigned long b, unsigned long k)
+ {
+ QueueDraw();
+ };
+
+ auto mouse_expand = [&](int x, int y, unsigned long b, unsigned long k)
+ {
+ expanded = !expanded;
+ };
+
+ // Signals
+ expander_view_->mouse_click.connect(mouse_expand);
+ expander_view_->mouse_enter.connect(mouse_redraw);
+ expander_view_->mouse_leave.connect(mouse_redraw);
+ cairo_label_->mouse_click.connect(mouse_expand);
+ cairo_label_->mouse_enter.connect(mouse_redraw);
+ cairo_label_->mouse_leave.connect(mouse_redraw);
+ expand_icon_->mouse_click.connect(mouse_expand);
+ expand_icon_->mouse_enter.connect(mouse_redraw);
+ expand_icon_->mouse_leave.connect(mouse_redraw);
+
QueueRelayout();
NeedRedraw();
}
@@ -160,18 +207,46 @@ void FilterExpanderLabel::DoExpandChange(bool change)
QueueDraw();
}
+bool FilterExpanderLabel::ShouldBeHighlighted()
+{
+ return ((expander_view_ && expander_view_->IsMouseInside()) ||
+ (cairo_label_ && cairo_label_->IsMouseInside()) ||
+ (expand_icon_ && expand_icon_->IsMouseInside()));
+}
+
void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
{
- nux::Geometry const& geo = GetGeometry();
+ nux::Geometry const& base = GetGeometry();
+
+ GfxContext.PushClippingRectangle(base);
+ nux::GetPainter().PaintBackground(GfxContext, base);
+
+ if (ShouldBeHighlighted())
+ {
+ nux::Geometry geo(top_bar_layout_->GetGeometry());
+ geo.x = base.x;
+ geo.height = 34;
+ geo.width = base.width - 5;
+
+ if (!highlight_layer_)
+ highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height));
+
+ highlight_layer_->SetGeometry(geo);
+ highlight_layer_->Renderlayer(GfxContext);
+ }
- GfxContext.PushClippingRectangle(geo);
- nux::GetPainter().PaintBackground(GfxContext, geo);
GfxContext.PopClippingRectangle();
}
void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
{
GfxContext.PushClippingRectangle(GetGeometry());
+
+ if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw())
+ {
+ nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get());
+ }
+
GetLayout()->ProcessDraw(GfxContext, force_draw);
GfxContext.PopClippingRectangle();
}
diff --git a/plugins/unityshell/src/FilterExpanderLabel.h b/plugins/unityshell/src/FilterExpanderLabel.h
index ed409241b..5acc1cc2b 100644
--- a/plugins/unityshell/src/FilterExpanderLabel.h
+++ b/plugins/unityshell/src/FilterExpanderLabel.h
@@ -23,6 +23,8 @@
#ifndef UNITYSHELL_FILTEREXPANDERLABEL_H
#define UNITYSHELL_FILTEREXPANDERLABEL_H
+#include <memory>
+
#include <Nux/Nux.h>
#include <Nux/GridHLayout.h>
#include <Nux/HLayout.h>
@@ -32,6 +34,11 @@
#include "FilterWidget.h"
#include "IconTexture.h"
+namespace nux
+{
+class AbstractPaintLayer;
+}
+
namespace unity
{
namespace dash
@@ -57,9 +64,12 @@ protected:
private:
void BuildLayout();
void DoExpandChange(bool change);
+ bool ShouldBeHighlighted();
nux::LinearLayout* layout_;
nux::LinearLayout* top_bar_layout_;
+ nux::View* expander_view_;
+ nux::LinearLayout* expander_layout_;
nux::View* right_hand_contents_;
nux::StaticText* cairo_label_;
std::string raw_label_;
@@ -70,6 +80,7 @@ private:
IconTexture* expand_icon_;
nux::ObjectPtr<nux::Layout> contents_;
+ std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_;
};
} // namespace dash
diff --git a/plugins/unityshell/src/FilterGenreWidget.cpp b/plugins/unityshell/src/FilterGenreWidget.cpp
index 9ab2277eb..378718201 100644
--- a/plugins/unityshell/src/FilterGenreWidget.cpp
+++ b/plugins/unityshell/src/FilterGenreWidget.cpp
@@ -119,21 +119,5 @@ void FilterGenre::InitTheme()
//FIXME - build theme here - store images, cache them, fun fun fun
}
-void FilterGenre::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- nux::Geometry const& geo = GetGeometry();
-
- GfxContext.PushClippingRectangle(geo);
- nux::GetPainter().PaintBackground(GfxContext, geo);
- GfxContext.PopClippingRectangle();
-}
-
-void FilterGenre::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- GfxContext.PushClippingRectangle(GetGeometry());
- GetLayout()->ProcessDraw(GfxContext, force_draw);
- GfxContext.PopClippingRectangle();
-}
-
} // namespace dash
} // namespace unity
diff --git a/plugins/unityshell/src/FilterGenreWidget.h b/plugins/unityshell/src/FilterGenreWidget.h
index 9e344f4f3..84baa0ae0 100644
--- a/plugins/unityshell/src/FilterGenreWidget.h
+++ b/plugins/unityshell/src/FilterGenreWidget.h
@@ -52,9 +52,6 @@ public:
std::string GetFilterType();
protected:
- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
-
void InitTheme();
private:
diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.cpp b/plugins/unityshell/src/FilterMultiRangeWidget.cpp
index ef552d2ce..fe5448f6b 100644
--- a/plugins/unityshell/src/FilterMultiRangeWidget.cpp
+++ b/plugins/unityshell/src/FilterMultiRangeWidget.cpp
@@ -44,6 +44,7 @@ FilterMultiRange::FilterMultiRange(NUX_FILE_LINE_DECL)
all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION);
layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
+ layout_->SetLeftAndRightPadding(0, 8);
layout_->SetTopAndBottomPadding(9, 12);
SetRightHandView(all_button_);
@@ -155,21 +156,5 @@ void FilterMultiRange::InitTheme()
//FIXME - build theme here - store images, cache them, fun fun fun
}
-void FilterMultiRange::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- nux::Geometry const& geo = GetGeometry();
-
- GfxContext.PushClippingRectangle(geo);
- nux::GetPainter().PaintBackground(GfxContext, geo);
- GfxContext.PopClippingRectangle();
-}
-
-void FilterMultiRange::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- GfxContext.PushClippingRectangle(GetGeometry());
- GetLayout()->ProcessDraw(GfxContext, force_draw);
- GfxContext.PopClippingRectangle();
-}
-
} // namespace dash
} // namespace unity
diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.h b/plugins/unityshell/src/FilterMultiRangeWidget.h
index 638dd9649..1d4b9b8ca 100644
--- a/plugins/unityshell/src/FilterMultiRangeWidget.h
+++ b/plugins/unityshell/src/FilterMultiRangeWidget.h
@@ -50,9 +50,6 @@ public:
std::string GetFilterType();
protected:
- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
-
void InitTheme();
private:
diff --git a/plugins/unityshell/src/FilterRatingsWidget.cpp b/plugins/unityshell/src/FilterRatingsWidget.cpp
index 0b9129cc1..9c9749548 100644
--- a/plugins/unityshell/src/FilterRatingsWidget.cpp
+++ b/plugins/unityshell/src/FilterRatingsWidget.cpp
@@ -73,21 +73,5 @@ std::string FilterRatingsWidget::GetFilterType()
return "FilterRatingsWidget";
}
-void FilterRatingsWidget::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- nux::Geometry const& geo = GetGeometry();
-
- GfxContext.PushClippingRectangle(geo);
- nux::GetPainter().PaintBackground(GfxContext, geo);
- GfxContext.PopClippingRectangle();
-}
-
-void FilterRatingsWidget::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
- GfxContext.PushClippingRectangle(GetGeometry());
- GetLayout()->ProcessDraw(GfxContext, force_draw);
- GfxContext.PopClippingRectangle();
-}
-
} // namespace dash
} // namespace unity
diff --git a/plugins/unityshell/src/FilterRatingsWidget.h b/plugins/unityshell/src/FilterRatingsWidget.h
index 9db1c3d38..6d002eb7d 100644
--- a/plugins/unityshell/src/FilterRatingsWidget.h
+++ b/plugins/unityshell/src/FilterRatingsWidget.h
@@ -50,10 +50,7 @@ public:
void SetFilter(Filter::Ptr const& filter);
std::string GetFilterType();
-protected:
- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
-
+private:
FilterAllButton* all_button_;
FilterRatingsButton* ratings_;
RatingsFilter::Ptr filter_;
diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp
index 4e74d798f..6fb2657ff 100644
--- a/plugins/unityshell/src/LensView.cpp
+++ b/plugins/unityshell/src/LensView.cpp
@@ -346,8 +346,8 @@ void LensView::OnFilterAdded(Filter::Ptr filter)
filter_bar_->AddFilter(filter);
int width = dash::Style::Instance().GetTileWidth();
- fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING);
- fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING);
+ fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8);
+ fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8);
can_refine_search = true;
}
@@ -371,7 +371,7 @@ void LensView::OnViewTypeChanged(ViewType view_type)
void LensView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
{
- nux::Geometry geo = GetGeometry();
+ nux::Geometry const& geo = GetGeometry();
gfx_context.PushClippingRectangle(geo);
nux::GetPainter().PaintBackground(gfx_context, geo);
@@ -393,7 +393,7 @@ Lens::Ptr LensView::lens() const
}
int LensView::GetNumRows()
-{
+{
unsigned int columns = dash::Style::Instance().GetDefaultNColumns();
columns -= filters_expanded ? 2 : 0;