summaryrefslogtreecommitdiff
path: root/plugins/unityshell
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2012-04-11 05:32:41 -0400
committerTarmac <>2012-04-11 05:32:41 -0400
commit2266bfaff07d3ace53c6522baeb19f13af8752d7 (patch)
treef97ec9e5920f7dfcd9c683112c35088566dc8592 /plugins/unityshell
parent307f7ed7a1ad92cc10c30eac76a018ea8cb71e6a (diff)
parente840b67535ddc3efd33be55b186093d0761dc56e (diff)
Lens selection should work when clicking in the rectangle outside of the icon.. Fixes: https://bugs.launchpad.net/bugs/937193. Approved by .
(bzr r2271)
Diffstat (limited to 'plugins/unityshell')
-rw-r--r--plugins/unityshell/src/LensBar.cpp44
-rw-r--r--plugins/unityshell/src/LensBar.h2
-rw-r--r--plugins/unityshell/src/LensBarIcon.cpp45
-rw-r--r--plugins/unityshell/src/LensBarIcon.h7
4 files changed, 49 insertions, 49 deletions
diff --git a/plugins/unityshell/src/LensBar.cpp b/plugins/unityshell/src/LensBar.cpp
index 07d0e828e..6c27a4e7e 100644
--- a/plugins/unityshell/src/LensBar.cpp
+++ b/plugins/unityshell/src/LensBar.cpp
@@ -20,7 +20,6 @@
#include "config.h"
#include "CairoTexture.h"
-#include "DashStyle.h"
#include "LensBar.h"
#include "UBusMessages.h"
#include "UBusWrapper.h"
@@ -34,8 +33,6 @@ namespace
nux::logging::Logger logger("unity.dash.lensbar");
-const int FOCUS_OVERLAY_WIDTH = 60;
-const int FOCUS_OVERLAY_HEIGHT = 44;
const int LENSBAR_HEIGHT = 44;
}
@@ -45,20 +42,11 @@ NUX_IMPLEMENT_OBJECT_TYPE(LensBar);
LensBar::LensBar()
: nux::View(NUX_TRACKER_LOCATION)
{
- InitTheme();
SetupBackground();
SetupLayout();
SetupHomeLens();
}
-void LensBar::InitTheme()
-{
- if (!focus_layer_)
- {
- focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH, FOCUS_OVERLAY_HEIGHT));
- }
-}
-
void LensBar::SetupBackground()
{
nux::ROPConfig rop;
@@ -72,7 +60,6 @@ void LensBar::SetupLayout()
{
layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
- layout_->SetSpaceBetweenChildren(40);
SetLayout(layout_);
SetMinimumHeight(LENSBAR_HEIGHT);
@@ -86,6 +73,7 @@ void LensBar::SetupHomeLens()
icon->active = true;
icons_.push_back(icon);
layout_->AddView(icon, 0, nux::eCenter, nux::MINOR_SIZE_FULL);
+ AddChild(icon);
icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); QueueDraw(); });
icon->mouse_down.connect([&] (int x, int y, unsigned long button, unsigned long keyboard) { QueueDraw(); });
@@ -100,6 +88,7 @@ void LensBar::AddLens(Lens::Ptr& lens)
lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } );
icons_.push_back(icon);
layout_->AddView(icon, 0, nux::eCenter, nux::eFix);
+ AddChild(icon);
icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); QueueDraw(); });
icon->mouse_down.connect([&] (int x, int y, unsigned long button, unsigned long keyboard) { QueueDraw(); });
@@ -129,25 +118,6 @@ void LensBar::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
bg_layer_->SetGeometry(base);
nux::GetPainter().RenderSinglePaintLayer(gfx_context, base, bg_layer_.get());
- for (auto icon : icons_)
- {
- if (icon->HasKeyFocus() && focus_layer_)
- {
- nux::Geometry geo(icon->GetGeometry());
-
- // Center it
- geo.x -= (FOCUS_OVERLAY_WIDTH - geo.width) / 2;
- geo.y -= (FOCUS_OVERLAY_HEIGHT - geo.height) / 2;
- geo.width = FOCUS_OVERLAY_WIDTH;
- geo.height = FOCUS_OVERLAY_HEIGHT;
-
- nux::AbstractPaintLayer* layer = focus_layer_.get();
-
- layer->SetGeometry(geo);
- layer->Renderlayer(gfx_context);
- }
- }
-
gfx_context.PopClippingRectangle();
// trigger a redraw of the decoration, as the special masking of the
@@ -166,16 +136,6 @@ void LensBar::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw)
if (!IsFullRedraw())
nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get());
- for (auto icon: icons_)
- {
- if (icon->HasKeyFocus() && !IsFullRedraw() && focus_layer_)
- {
- nux::AbstractPaintLayer* layer = focus_layer_.get();
-
- nux::GetPainter().PushLayer(gfx_context, focus_layer_->GetGeometry(), layer);
- }
- }
-
layout_->ProcessDraw(gfx_context, force_draw);
if (!IsFullRedraw())
diff --git a/plugins/unityshell/src/LensBar.h b/plugins/unityshell/src/LensBar.h
index e8bb74fa1..e1c2ae1f7 100644
--- a/plugins/unityshell/src/LensBar.h
+++ b/plugins/unityshell/src/LensBar.h
@@ -59,7 +59,6 @@ public:
sigc::signal<void, std::string const&> lens_activated;
private:
- void InitTheme();
void SetupBackground();
void SetupLayout();
void SetupHomeLens();
@@ -81,7 +80,6 @@ private:
nux::HLayout* layout_;
LayerPtr bg_layer_;
- LayerPtr focus_layer_;
};
} // namespace dash
diff --git a/plugins/unityshell/src/LensBarIcon.cpp b/plugins/unityshell/src/LensBarIcon.cpp
index 946b40686..8c62b84ec 100644
--- a/plugins/unityshell/src/LensBarIcon.cpp
+++ b/plugins/unityshell/src/LensBarIcon.cpp
@@ -16,6 +16,9 @@
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
*/
+#include <UnityCore/Variant.h>
+
+#include "DashStyle.h"
#include "LensBarIcon.h"
#include "config.h"
@@ -24,6 +27,13 @@ namespace unity
{
namespace dash
{
+namespace
+{
+
+const int FOCUS_OVERLAY_HEIGHT = 44;
+const int FOCUS_OVERLAY_WIDTH = 60;
+
+}
NUX_IMPLEMENT_OBJECT_TYPE(LensBarIcon);
@@ -33,10 +43,13 @@ LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint)
, active(false)
, inactive_opacity_(0.4f)
{
- SetMinimumWidth(24);
- SetMaximumWidth(24);
- SetMinimumHeight(24);
- SetMaximumHeight(24);
+ SetMinimumWidth(FOCUS_OVERLAY_WIDTH);
+ SetMaximumWidth(FOCUS_OVERLAY_WIDTH);
+ SetMinimumHeight(FOCUS_OVERLAY_HEIGHT);
+ SetMaximumHeight(FOCUS_OVERLAY_HEIGHT);
+
+ focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH, FOCUS_OVERLAY_HEIGHT));
+
SetOpacity(inactive_opacity_);
SetAcceptKeyNavFocus(true);
@@ -54,7 +67,6 @@ void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
nux::Geometry const& geo = GetGeometry();
gfx_context.PushClippingRectangle(geo);
-
nux::GetPainter().PaintBackground(gfx_context, geo);
if (!texture())
@@ -63,6 +75,15 @@ void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
return;
}
+ if (HasKeyFocus() && focus_layer_)
+ {
+ nux::Geometry geo(GetGeometry());
+ nux::AbstractPaintLayer* layer = focus_layer_.get();
+
+ layer->SetGeometry(geo);
+ layer->Renderlayer(gfx_context);
+ }
+
float opacity = active ? 1.0f : inactive_opacity_;
int width = 0, height = 0;
GetTextureSize(&width, &height);
@@ -88,5 +109,19 @@ void LensBarIcon::OnActiveChanged(bool is_active)
QueueDraw();
}
+// Introspectable
+std::string LensBarIcon::GetName() const
+{
+ return "LensBarIcon";
+}
+
+void LensBarIcon::AddProperties(GVariantBuilder* builder)
+{
+ unity::variant::BuilderWrapper wrapper(builder);
+
+ wrapper.add(GetAbsoluteGeometry());
+ wrapper.add("name", id);
+}
+
}
}
diff --git a/plugins/unityshell/src/LensBarIcon.h b/plugins/unityshell/src/LensBarIcon.h
index 0c85b0ce3..207515663 100644
--- a/plugins/unityshell/src/LensBarIcon.h
+++ b/plugins/unityshell/src/LensBarIcon.h
@@ -47,8 +47,15 @@ private:
void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
void OnActiveChanged(bool is_active);
+ // Introspectable
+ std::string GetName() const;
+ void AddProperties(GVariantBuilder* builder);
+
private:
+ typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr;
+
const float inactive_opacity_;
+ LayerPtr focus_layer_;
};
}