summaryrefslogtreecommitdiff
diff options
authorGord Allott <gord.allott@canonical.com>2012-09-11 14:57:19 +0100
committerGord Allott <gord.allott@canonical.com>2012-09-11 14:57:19 +0100
commit42835848c492504f0358cf0ab2b1af34a45686f2 (patch)
tree2ecee4c2bea66bea1270b1d4de8a902fab94f5b4
parentb6894da04e778c0a0cb96c688c3fc70a887d49e0 (diff)
panel gradient
(bzr r2637.8.10)
-rw-r--r--panel/PanelController.cpp14
-rw-r--r--panel/PanelController.h2
-rw-r--r--panel/PanelView.cpp102
-rw-r--r--panel/PanelView.h8
-rw-r--r--panel/StandalonePanel.cpp14
-rw-r--r--plugins/unityshell/resources/refine_gradient_panel.pngbin2253 -> 2169 bytes
-rw-r--r--plugins/unityshell/resources/refine_gradient_panel_single_column.pngbin0 -> 141 bytes
-rw-r--r--plugins/unityshell/src/unityshell.cpp1
-rw-r--r--unity-standalone/StandaloneUnity.cpp4
9 files changed, 136 insertions, 9 deletions
diff --git a/panel/PanelController.cpp b/panel/PanelController.cpp
index 1de0a530d..ef000b0ea 100644
--- a/panel/PanelController.cpp
+++ b/panel/PanelController.cpp
@@ -53,6 +53,7 @@ public:
std::vector<nux::Geometry> GetGeometries() const;
// NOTE: nux::Property maybe?
+ void SetLauncherWidth(int width);
void SetOpacity(float opacity);
void SetOpacityMaximizedToggle(bool enabled);
@@ -147,6 +148,14 @@ void Controller::Impl::SetOpacity(float opacity)
}
}
+void Controller::Impl::SetLauncherWidth(int width)
+{
+ for (auto window: windows_)
+ {
+ ViewForWindow(window)->SetLauncherWidth(width);
+ }
+}
+
void Controller::Impl::SetOpacityMaximizedToggle(bool enabled)
{
opacity_maximized_toggle_ = enabled;
@@ -297,6 +306,11 @@ Controller::Controller()
UScreen* screen = UScreen::GetDefault();
screen->changed.connect(sigc::mem_fun(this, &Controller::OnScreenChanged));
OnScreenChanged(screen->GetPrimaryMonitor(), screen->GetMonitors());
+
+ launcher_width.changed.connect([&] (int width)
+ {
+ pimpl->SetLauncherWidth(width);
+ });
}
Controller::~Controller()
diff --git a/panel/PanelController.h b/panel/PanelController.h
index 2c8a9c1bc..1b1caa736 100644
--- a/panel/PanelController.h
+++ b/panel/PanelController.h
@@ -44,6 +44,8 @@ public:
std::vector<nux::View*> GetPanelViews() const;
std::vector<nux::Geometry> GetGeometries() const;
+ nux::Property<int> launcher_width;
+
// NOTE: nux::Property maybe?
void SetOpacity(float opacity);
void SetOpacityMaximizedToggle(bool enabled);
diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp
index 27bbfc3a5..4eae7eca8 100644
--- a/panel/PanelView.cpp
+++ b/panel/PanelView.cpp
@@ -44,7 +44,8 @@
namespace
{
-nux::logging::Logger logger("unity.PanelView");
+nux::logging::Logger logger("unity.panel.view");
+const int refine_gradient_midpoint = 959;
}
namespace unity
@@ -61,6 +62,8 @@ PanelView::PanelView(NUX_FILE_LINE_DECL)
, _overlay_is_open(false)
, _opacity(1.0f)
, _monitor(0)
+ , _stored_dash_width(0)
+ , _launcher_width(0)
{
panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));
@@ -98,7 +101,13 @@ PanelView::PanelView(NUX_FILE_LINE_DECL)
_ubus_manager.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));
_ubus_manager.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden));
_ubus_manager.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown));
-
+ _ubus_manager.RegisterInterest(UBUS_DASH_SIZE_CHANGED, [&] (GVariant *data)
+ {
+ int width, height;
+ g_variant_get(data, "(ii)", &width, &height);
+ _stored_dash_width = width;
+ QueueDraw();
+ });
// request the latest colour from bghash
_ubus_manager.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
@@ -116,6 +125,49 @@ PanelView::PanelView(NUX_FILE_LINE_DECL)
{
_panel_sheen.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
}
+
+ //FIXME (gord) like 12 months later, still not async loading!
+ pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR "/refine_gradient_panel.png", &error);
+ if (error)
+ {
+ LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/refine_gradient_panel.png";
+ }
+ else
+ {
+ _bg_refine_tex.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
+ }
+
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+
+ nux::TexCoordXForm texxform;
+ _bg_refine_layer.reset(new nux::TextureLayer(_bg_refine_tex->GetDeviceTexture(),
+ texxform,
+ nux::color::White,
+ false,
+ rop));
+
+ //FIXME (gord) like 12 months later, still not async loading!
+ pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR "/refine_gradient_panel_single_column.png", &error);
+ if (error)
+ {
+ LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/refine_gradient_panel_single_column.png";
+ }
+ else
+ {
+ _bg_refine_single_column_tex.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
+ }
+
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+
+ _bg_refine_single_column_layer.reset(new nux::TextureLayer(_bg_refine_single_column_tex->GetDeviceTexture(),
+ texxform,
+ nux::color::White,
+ false,
+ rop));
}
PanelView::~PanelView()
@@ -138,6 +190,12 @@ Window PanelView::GetTrayXid() const
return _tray->xid();
}
+void PanelView::SetLauncherWidth(int width)
+{
+ _launcher_width = width;
+ QueueDraw();
+}
+
void PanelView::OnBackgroundUpdate(GVariant *data)
{
gdouble red, green, blue, alpha;
@@ -219,6 +277,7 @@ void PanelView::AddProperties(GVariantBuilder* builder)
void
PanelView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
{
+ LOG_DEBUG(logger) << "test";
nux::Geometry const& geo = GetGeometry();
UpdateBackground();
@@ -285,6 +344,28 @@ PanelView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
if (_overlay_is_open)
{
nux::GetPainter().RenderSinglePaintLayer(GfxContext, geo, _bg_darken_layer.get());
+
+ GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ nux::TexCoordXForm refine_texxform;
+
+ int refine_x_pos = geo.x + (_stored_dash_width - refine_gradient_midpoint);
+
+ refine_x_pos += _launcher_width;
+ GfxContext.QRP_1Tex(refine_x_pos,
+ geo.y,
+ _bg_refine_tex->GetWidth(),
+ _bg_refine_tex->GetHeight(),
+ _bg_refine_tex->GetDeviceTexture(),
+ refine_texxform,
+ nux::color::White);
+
+ GfxContext.QRP_1Tex(refine_x_pos + _bg_refine_tex->GetWidth(),
+ geo.y,
+ geo.width,
+ geo.height,
+ _bg_refine_single_column_tex->GetDeviceTexture(),
+ refine_texxform,
+ nux::color::White);
}
}
@@ -360,6 +441,23 @@ PanelView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
{
nux::GetPainter().PushLayer(GfxContext, geo, _bg_darken_layer.get());
bgs++;
+
+ nux::Geometry refine_geo = geo;
+
+ int refine_x_pos = geo.x + (_stored_dash_width - refine_gradient_midpoint);
+ refine_x_pos += _launcher_width;
+
+ refine_geo.x = refine_x_pos;
+ refine_geo.width = _bg_refine_tex->GetWidth();
+ refine_geo.height = _bg_refine_tex->GetHeight();
+
+ nux::GetPainter().PushLayer(GfxContext, refine_geo, _bg_refine_layer.get());
+
+ refine_geo.x += refine_geo.width;
+ refine_geo.width = geo.width;
+ refine_geo.height = geo.height;
+ nux::GetPainter().PushLayer(GfxContext, refine_geo, _bg_refine_single_column_layer.get());
+
}
}
diff --git a/panel/PanelView.h b/panel/PanelView.h
index 9dac92ea1..6d3475c14 100644
--- a/panel/PanelView.h
+++ b/panel/PanelView.h
@@ -64,6 +64,8 @@ public:
Window GetTrayXid() const;
+ void SetLauncherWidth(int width);
+
protected:
void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
@@ -105,6 +107,10 @@ private:
nux::ObjectPtr<nux::BaseTexture> _panel_sheen;
nux::HLayout* _layout;
+ nux::ObjectPtr <nux::BaseTexture> _bg_refine_tex;
+ std::unique_ptr<nux::AbstractPaintLayer> _bg_refine_layer;
+ nux::ObjectPtr <nux::BaseTexture> _bg_refine_single_column_tex;
+ std::unique_ptr<nux::AbstractPaintLayer> _bg_refine_single_column_layer;
nux::Geometry _last_geo;
nux::Color _bg_color;
@@ -115,6 +121,8 @@ private:
bool _overlay_is_open;
float _opacity;
int _monitor;
+ int _stored_dash_width;
+ int _launcher_width;
std::string _active_overlay;
diff --git a/panel/StandalonePanel.cpp b/panel/StandalonePanel.cpp
index 0ca26601f..88f9bbc7e 100644
--- a/panel/StandalonePanel.cpp
+++ b/panel/StandalonePanel.cpp
@@ -18,11 +18,12 @@
*
*/
-#include "Nux/Nux.h"
-#include "Nux/VLayout.h"
-#include "Nux/HLayout.h"
-#include "Nux/WindowThread.h"
-#include "NuxGraphics/GraphicsEngine.h"
+#include <Nux/Nux.h>
+#include <Nux/VLayout.h>
+#include <Nux/HLayout.h>
+#include <Nux/WindowThread.h>
+#include <NuxGraphics/GraphicsEngine.h>
+#include <NuxCore/Logger.h>
#include <gtk/gtk.h>
#include "unity-shared/UnitySettings.h"
@@ -47,7 +48,8 @@ int main(int argc, char** argv)
g_type_init();
gtk_init(&argc, &argv);
nux::NuxInitialize(0);
-
+ nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
+
// The instances for the pseudo-singletons.
unity::Settings settings;
unity::panel::Style panel_style;
diff --git a/plugins/unityshell/resources/refine_gradient_panel.png b/plugins/unityshell/resources/refine_gradient_panel.png
index 85d31625b..d8e9b8d2d 100644
--- a/plugins/unityshell/resources/refine_gradient_panel.png
+++ b/plugins/unityshell/resources/refine_gradient_panel.png
Binary files differ
diff --git a/plugins/unityshell/resources/refine_gradient_panel_single_column.png b/plugins/unityshell/resources/refine_gradient_panel_single_column.png
new file mode 100644
index 000000000..7ce0efa2f
--- /dev/null
+++ b/plugins/unityshell/resources/refine_gradient_panel_single_column.png
Binary files differ
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 0ec87f497..9622d3bbc 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -2770,6 +2770,7 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num)
* that must not be considered when drawing an overlay */
hud_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1;
dash_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1;
+ panel_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1;
if (p)
{
diff --git a/unity-standalone/StandaloneUnity.cpp b/unity-standalone/StandaloneUnity.cpp
index fa0662bed..a5dba677c 100644
--- a/unity-standalone/StandaloneUnity.cpp
+++ b/unity-standalone/StandaloneUnity.cpp
@@ -45,7 +45,7 @@
namespace
{
- static int display_width = 1280;
+ static int display_width = 1200;
static int display_height = 720;
static gboolean no_window_decorations = FALSE;
static gboolean force_tv = FALSE;
@@ -89,7 +89,9 @@ void UnityStandalone::Init ()
launcher_controller.reset(new launcher::Controller(0));
panel_controller.reset(new panel::Controller());
dash_controller.reset(new dash::Controller());
+
dash_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
+ panel_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
}
void UnityStandalone::InitWindowThread(nux::NThread* thread, void* InitData)