summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2012-02-07 09:32:20 -0500
committerTarmac <>2012-02-07 09:32:20 -0500
commitdd7be1c7c4c9f1f954831e784bb95df94fd0bb97 (patch)
tree54d79b5a75a1dd45bdb225ea2a14e4e7313aa5a4
parent8e738ebe857d06b11dde25003a93f850034f6f59 (diff)
parent890ceafc7d7e987cbcc3c382cf4d8254c2bb8f72 (diff)
Some updates to tooltips and quicklist... New visuals, positioning (Cimi, already signed-off by design), padding, some code refactoring by Marco including a standalone test program and fixes to StaticCairoText that now can use a pango_layout with a size different of the text extents (this allows to both draw cut text and to position it as requested).
Also added CairoBaseWindow class that is used by both tooltip and quicklists to draw their cairo items avoiding code duplication.. Fixes: . Approved by Andrea Azzarone, Andrea Cimitan. Original authors: - Marco Trevisan (Treviño) <mail@3v1n0.net> - Andrea Cimitan <andrea.cimitan@canonical.com> (bzr r1910)
-rw-r--r--plugins/unityshell/src/CairoBaseWindow.cpp170
-rw-r--r--plugins/unityshell/src/CairoBaseWindow.h51
-rw-r--r--plugins/unityshell/src/Launcher.h2
-rw-r--r--plugins/unityshell/src/LauncherIcon.cpp32
-rw-r--r--plugins/unityshell/src/LauncherIcon.h7
-rw-r--r--plugins/unityshell/src/QuicklistManager.cpp6
-rw-r--r--plugins/unityshell/src/QuicklistManager.h6
-rw-r--r--plugins/unityshell/src/QuicklistMenuItem.cpp33
-rw-r--r--plugins/unityshell/src/QuicklistMenuItem.h24
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp48
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemCheckmark.h5
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemLabel.cpp35
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemLabel.h5
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemRadio.cpp53
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemRadio.h5
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemSeparator.cpp13
-rw-r--r--plugins/unityshell/src/QuicklistMenuItemSeparator.h4
-rw-r--r--plugins/unityshell/src/QuicklistView.cpp191
-rw-r--r--plugins/unityshell/src/QuicklistView.h42
-rw-r--r--plugins/unityshell/src/StaticCairoText.cpp18
-rw-r--r--plugins/unityshell/src/StaticCairoText.h6
-rw-r--r--plugins/unityshell/src/Tooltip.cpp389
-rw-r--r--plugins/unityshell/src/Tooltip.h73
-rw-r--r--plugins/unityshell/src/unity-quicklist-accessible.cpp1
-rw-r--r--plugins/unityshell/src/unity-quicklist-menu-accessible.cpp2
-rw-r--r--plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp3
-rw-r--r--plugins/unityshell/src/unitya11ytests.cpp8
-rw-r--r--standalone-clients/CMakeLists.txt33
-rw-r--r--standalone-clients/ui/TestQuicklist.cpp2
-rw-r--r--standalone-clients/ui/TestQuicklistVisuals.cpp2
-rw-r--r--standalone-clients/ui/TestTooltip.cpp64
-rw-r--r--tests/CMakeLists.txt12
-rw-r--r--tests/unit/TestQuicklistMenuitems.cpp15
33 files changed, 676 insertions, 684 deletions
diff --git a/plugins/unityshell/src/CairoBaseWindow.cpp b/plugins/unityshell/src/CairoBaseWindow.cpp
new file mode 100644
index 000000000..e9370e691
--- /dev/null
+++ b/plugins/unityshell/src/CairoBaseWindow.cpp
@@ -0,0 +1,170 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <3v1n0@ubuntu.com>
+ */
+
+
+#include <Nux/Nux.h>
+
+#include "CairoTexture.h"
+#include "CairoBaseWindow.h"
+
+namespace unity
+{
+namespace
+{
+ const int ANCHOR_WIDTH = 14;
+ const int ANCHOR_HEIGHT = 18;
+ const int CORNER_RADIUS = 4;
+ const int PADDING = 15;
+ const int TEXT_PADDING = 8;
+ const int MINIMUM_TEXT_WIDTH = 100;
+ const int TOP_SIZE = 0;
+}
+
+NUX_IMPLEMENT_OBJECT_TYPE(CairoBaseWindow);
+
+CairoBaseWindow::CairoBaseWindow() :
+ _use_blurred_background(false),
+ _compute_blur_bkg(false)
+{
+ SetWindowSizeMatchLayout(true);
+}
+
+CairoBaseWindow::~CairoBaseWindow()
+{
+ // nothing to do
+}
+
+void CairoBaseWindow::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
+{
+ nux::Geometry base(GetGeometry());
+
+ // Get the background and apply some blur
+ if (_use_blurred_background && _compute_blur_bkg)
+ {
+ auto current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
+ nux::GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();
+
+ gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
+ gfxContext.SetScissor(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
+ gfxContext.GetRenderStates().EnableScissor(false);
+
+ nux::ObjectPtr <nux::IOpenGLBaseTexture> bkg_texture = gfxContext.CreateTextureFromBackBuffer(base.x, base.y, base.width, base.height);
+
+ nux::TexCoordXForm texxform_bkg;
+ bg_blur_texture_ = gfxContext.QRP_GetBlurTexture(0, 0, base.width, base.height, bkg_texture, texxform_bkg, nux::color::White, 1.0f, 3);
+
+ if (current_fbo.IsValid())
+ {
+ current_fbo->Activate(true);
+ gfxContext.Push2DWindow(current_fbo->GetWidth(), current_fbo->GetHeight());
+ }
+ else
+ {
+ gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
+ gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
+ gfxContext.ApplyClippingRectangle();
+ }
+ _compute_blur_bkg = false;
+ }
+
+ // the elements position inside the window are referenced to top-left window
+ // corner. So bring base to (0, 0).
+ base.SetX(0);
+ base.SetY(0);
+
+ gfxContext.PushClippingRectangle(base);
+
+ /* "Clear" out the background */
+ nux::ROPConfig rop;
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+
+ nux::ColorLayer layer(nux::Color(0x00000000), true, rop);
+ nux::GetPainter().PushDrawLayer(gfxContext, base, &layer);
+
+ nux::TexCoordXForm texxform_bg;
+ texxform_bg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
+ texxform_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+
+ nux::TexCoordXForm texxform_mask;
+ texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
+ texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+
+ if (bg_blur_texture_.IsValid() && texture_mask_.IsValid())
+ {
+ nux::TexCoordXForm texxform_blur_bkg;
+
+ nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
+ nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+
+ gfxContext.QRP_2TexMod(
+ base.x,
+ base.y,
+ base.width,
+ base.height,
+ bg_blur_texture_,
+ texxform_blur_bkg,
+ nux::color::White,
+ texture_mask_->GetDeviceTexture(),
+ texxform_mask,
+ nux::color::White);
+ }
+
+ if (texture_bg_.IsValid() && texture_mask_.IsValid())
+ {
+ nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
+ nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+
+ gfxContext.QRP_2TexMod(base.x,
+ base.y,
+ base.width,
+ base.height,
+ texture_bg_->GetDeviceTexture(),
+ texxform_bg,
+ nux::color::White,
+ texture_mask_->GetDeviceTexture(),
+ texxform_mask,
+ nux::color::White);
+ }
+
+ if (texture_outline_.IsValid())
+ {
+ nux::TexCoordXForm texxform;
+ texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+
+ nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetBlend(true);
+ nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+
+ gfxContext.QRP_1Tex(base.x,
+ base.y,
+ base.width,
+ base.height,
+ texture_outline_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+ }
+
+ nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetBlend(false);
+ nux::GetPainter().PopBackground();
+ gfxContext.PopClippingRectangle();
+}
+
+} // namespace nux
diff --git a/plugins/unityshell/src/CairoBaseWindow.h b/plugins/unityshell/src/CairoBaseWindow.h
new file mode 100644
index 000000000..8aabdfa6a
--- /dev/null
+++ b/plugins/unityshell/src/CairoBaseWindow.h
@@ -0,0 +1,51 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <3v1n0@ubuntu.com>
+ */
+
+#ifndef CAIRO_BASEWINDOW_H
+#define CAIRO_BASEWINDOW_H
+
+#include <Nux/Nux.h>
+#include <Nux/BaseWindow.h>
+
+namespace unity
+{
+class CairoBaseWindow : public nux::BaseWindow
+{
+ NUX_DECLARE_OBJECT_TYPE(CairoBaseWindow, nux::BaseWindow);
+public:
+ CairoBaseWindow();
+ virtual ~CairoBaseWindow();
+
+protected:
+ void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
+
+ nux::ObjectPtr<nux::BaseTexture> texture_bg_;
+ nux::ObjectPtr<nux::BaseTexture> texture_mask_;
+ nux::ObjectPtr<nux::BaseTexture> texture_outline_;
+
+ bool _use_blurred_background;
+ bool _compute_blur_bkg;
+
+private:
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;
+};
+}
+
+#endif // CAIRO_BASEWINDOW_H
+
diff --git a/plugins/unityshell/src/Launcher.h b/plugins/unityshell/src/Launcher.h
index 56021053b..9235dae76 100644
--- a/plugins/unityshell/src/Launcher.h
+++ b/plugins/unityshell/src/Launcher.h
@@ -50,8 +50,6 @@
#define START_DRAGICON_DURATION 250
-class QuicklistView;
-
namespace unity
{
namespace launcher
diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp
index b45557595..b1888e432 100644
--- a/plugins/unityshell/src/LauncherIcon.cpp
+++ b/plugins/unityshell/src/LauncherIcon.cpp
@@ -66,9 +66,6 @@ nux::logging::Logger logger("unity.launcher");
NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);
-nux::Tooltip* LauncherIcon::_current_tooltip = 0;
-QuicklistView* LauncherIcon::_current_quicklist = 0;
-
int LauncherIcon::_current_theme_is_mono = -1;
GtkIconTheme* LauncherIcon::_unity_theme = NULL;
@@ -100,22 +97,20 @@ LauncherIcon::LauncherIcon()
_quirk_times[i].tv_nsec = 0;
}
- _tooltip = new nux::Tooltip();
- _tooltip->SinkReference();
+ _tooltip = new Tooltip();
tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));
tooltip_text = "blank";
_quicklist = new QuicklistView();
- _quicklist->SinkReference();
// FIXME: the abstraction is already broken, should be fixed for O
// right now, hooking the dynamic quicklist the less ugly possible way
- QuicklistManager::Default()->RegisterQuicklist(_quicklist);
+ QuicklistManager::Default()->RegisterQuicklist(_quicklist.GetPointer());
// Add to introspection
- AddChild(_quicklist);
- AddChild(_tooltip);
+ AddChild(_quicklist.GetPointer());
+ AddChild(_tooltip.GetPointer());
mouse_enter.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter));
mouse_leave.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave));
@@ -129,8 +124,8 @@ LauncherIcon::~LauncherIcon()
SetQuirk(QUIRK_URGENT, false);
// Remove from introspection
- RemoveChild(_quicklist);
- RemoveChild(_tooltip);
+ RemoveChild(_quicklist.GetPointer());
+ RemoveChild(_tooltip.GetPointer());
if (_present_time_handle)
g_source_remove(_present_time_handle);
@@ -157,9 +152,6 @@ LauncherIcon::~LauncherIcon()
if (on_order_changed_connection.connected())
on_order_changed_connection.disconnect();
- _quicklist->UnReference();
- _tooltip->UnReference();
-
if (_unity_theme)
{
g_object_unref(_unity_theme);
@@ -493,7 +485,7 @@ LauncherIcon::ShowTooltip()
if (_last_monitor >= 0)
{
nux::Geometry geo = _parent_geo[_last_monitor];
- tip_x = geo.x + geo.width + 1;
+ tip_x = geo.x + geo.width - 4 * geo.width / 48;
tip_y = geo.y + _center[_last_monitor].y;
}
@@ -575,7 +567,7 @@ bool LauncherIcon::OpenQuicklist(bool default_to_first_item, int monitor)
}
nux::Geometry geo = _parent_geo[monitor];
- int tip_x = geo.x + geo.width + 1;
+ int tip_x = geo.x + geo.width - 4 * geo.width / 48;
int tip_y = geo.y + _center[monitor].y;
auto win_manager = WindowManager::Default();
@@ -588,13 +580,13 @@ bool LauncherIcon::OpenQuicklist(bool default_to_first_item, int monitor)
if (win_manager->IsExpoActive())
{
on_expo_terminated_connection = win_manager->terminate_expo.connect([&, tip_x, tip_y]() {
- QuicklistManager::Default()->ShowQuicklist(_quicklist, tip_x, tip_y);
+ QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y);
on_expo_terminated_connection.disconnect();
});
}
else
{
- QuicklistManager::Default()->ShowQuicklist(_quicklist, tip_x, tip_y);
+ QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y);
}
return true;
@@ -655,11 +647,11 @@ LauncherIcon::SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)
if (monitor == _last_monitor)
{
int tip_x, tip_y;
- tip_x = geo.x + geo.width + 1;
+ tip_x = geo.x + geo.width - 4 * geo.width / 48;
tip_y = geo.y + _center[monitor].y;
if (_quicklist->IsVisible())
- QuicklistManager::Default()->ShowQuicklist(_quicklist, tip_x, tip_y);
+ QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y);
else if (_tooltip->IsVisible())
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
}
diff --git a/plugins/unityshell/src/LauncherIcon.h b/plugins/unityshell/src/LauncherIcon.h
index 09db019a1..235948991 100644
--- a/plugins/unityshell/src/LauncherIcon.h
+++ b/plugins/unityshell/src/LauncherIcon.h
@@ -263,11 +263,8 @@ protected:
void OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote);
- nux::Tooltip* _tooltip;
- QuicklistView* _quicklist;
-
- static nux::Tooltip* _current_tooltip;
- static QuicklistView* _current_quicklist;
+ nux::ObjectPtr<Tooltip> _tooltip;
+ nux::ObjectPtr<QuicklistView> _quicklist;
// This looks like a case for boost::logical::tribool
static int _current_theme_is_mono;
diff --git a/plugins/unityshell/src/QuicklistManager.cpp b/plugins/unityshell/src/QuicklistManager.cpp
index c0af78bb8..29cfb63ec 100644
--- a/plugins/unityshell/src/QuicklistManager.cpp
+++ b/plugins/unityshell/src/QuicklistManager.cpp
@@ -28,6 +28,9 @@
#include "ubus-server.h"
#include "UBusMessages.h"
+namespace unity
+{
+
QuicklistManager* QuicklistManager::_default = 0;
/* static */
@@ -51,6 +54,8 @@ QuicklistManager::QuicklistManager()
QuicklistManager::~QuicklistManager()
{
+ if (_default == this)
+ Destroy();
}
QuicklistView* QuicklistManager::Current()
@@ -122,3 +127,4 @@ void QuicklistManager::RecvHideQuicklist(nux::BaseWindow* window)
quicklist_closed.emit(quicklist);
}
+} // NAMESPACE
diff --git a/plugins/unityshell/src/QuicklistManager.h b/plugins/unityshell/src/QuicklistManager.h
index 58001d1d9..a6d979967 100644
--- a/plugins/unityshell/src/QuicklistManager.h
+++ b/plugins/unityshell/src/QuicklistManager.h
@@ -20,14 +20,14 @@
#ifndef QUICKLISTMANAGER_H
#define QUICKLISTMANAGER_H
+namespace unity {
+
class QuicklistManager : public sigc::trackable
{
public:
static QuicklistManager* Default();
static void Destroy();
- QuicklistManager();
-
~QuicklistManager();
QuicklistView* Current();
@@ -43,6 +43,7 @@ public:
sigc::signal<void, QuicklistView*> quicklist_closed;
private:
+ QuicklistManager();
static QuicklistManager* _default;
std::list<QuicklistView*> _quicklist_list;
@@ -50,5 +51,6 @@ private:
};
+} // NAMESPACE
#endif
diff --git a/plugins/unityshell/src/QuicklistMenuItem.cpp b/plugins/unityshell/src/QuicklistMenuItem.cpp
index fe0d544ef..39b74a60a 100644
--- a/plugins/unityshell/src/QuicklistMenuItem.cpp
+++ b/plugins/unityshell/src/QuicklistMenuItem.cpp
@@ -15,7 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Mirco Müller <mirco.mueller@canonical.com>
- * Authored by: Jay Taoko <jay.taoko@canonical.com>
+ * Jay Taoko <jay.taoko@canonical.com>
+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
*/
#include <gdk/gdk.h>
@@ -28,6 +29,9 @@
#include <X11/Xlib.h>
+namespace unity
+{
+
NUX_IMPLEMENT_OBJECT_TYPE(QuicklistMenuItem);
static void
@@ -370,15 +374,12 @@ void QuicklistMenuItem::RecvMouseLeave(int x, int y, unsigned long button_flags,
sigMouseLeave.emit(this);
}
-void
-QuicklistMenuItem::DrawText(cairo_t* cr,
- int width,
- int height,
- nux::Color color)
+void QuicklistMenuItem::DrawText(nux::CairoGraphics* cairo, int width, int height, nux::Color const& color)
{
- if (_text == NULL)
+ if (_text == nullptr || cairo == nullptr)
return;
+ cairo_t* cr = cairo->GetContext();
int textWidth = 0;
int textHeight = 0;
PangoLayout* layout = NULL;
@@ -392,6 +393,8 @@ QuicklistMenuItem::DrawText(cairo_t* cr,
g_object_get(settings, "gtk-font-name", &fontName, NULL);
GetTextExtents(fontName, textWidth, textHeight);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba(cr, color.red, color.blue, color.green, color.alpha);
cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
layout = pango_cairo_create_layout(cr);
desc = pango_font_description_from_string(fontName);
@@ -427,6 +430,20 @@ QuicklistMenuItem::DrawText(cairo_t* cr,
g_object_unref(layout);
}
+void QuicklistMenuItem::DrawPrelight(nux::CairoGraphics* cairo, int width, int height, nux::Color const& color)
+{
+ if (!cairo)
+ return;
+
+ cairo_t* cr = cairo->GetContext();
+
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba(cr, color.red, color.blue, color.green, color.alpha);
+ cairo->DrawRoundedRectangle(cr, 1.0f, 0.5f, 0.5f, ITEM_CORNER_RADIUS_ABS,
+ width - 1.0f, height - 1.0f);
+ cairo_fill(cr);
+}
+
void
QuicklistMenuItem::EnableLabelMarkup(bool enabled)
{
@@ -475,3 +492,5 @@ void QuicklistMenuItem::AddProperties(GVariantBuilder* builder)
.add("active", GetActive())
.add("visible", GetVisible());
}
+
+} //NAMESPACE
diff --git a/plugins/unityshell/src/QuicklistMenuItem.h b/plugins/unityshell/src/QuicklistMenuItem.h
index dd420a4a4..1d8615bde 100644
--- a/plugins/unityshell/src/QuicklistMenuItem.h
+++ b/plugins/unityshell/src/QuicklistMenuItem.h
@@ -33,20 +33,19 @@
#include "Introspectable.h"
-#define ITEM_INDENT_ABS 16
-#define ITEM_CORNER_RADIUS_ABS 3
-#define ITEM_MARGIN 4
+namespace unity
+{
-typedef enum
+enum QuicklistMenuItemType
{
- MENUITEM_TYPE_UNKNOWN = 0,
+ MENUITEM_TYPE_UNKNOWN = 0,
MENUITEM_TYPE_LABEL,
MENUITEM_TYPE_SEPARATOR,
MENUITEM_TYPE_CHECK,
MENUITEM_TYPE_RADIO,
-} QuicklistMenuItemType;
+};
-class QuicklistMenuItem : public nux::View, public unity::debug::Introspectable
+class QuicklistMenuItem : public nux::View, public debug::Introspectable
{
NUX_DECLARE_OBJECT_TYPE(QuicklistMenuItem, nux::View);
public:
@@ -91,6 +90,9 @@ public:
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
protected:
+ static const int ITEM_INDENT_ABS = 16;
+ static const int ITEM_CORNER_RADIUS_ABS = 3;
+ static const int ITEM_MARGIN = 4;
gchar* _text;
nux::Color _textColor;
@@ -135,10 +137,8 @@ protected:
bool _prelight; //!< True when the mouse is over the item.
- void DrawText(cairo_t* cr,
- int width,
- int height,
- nux::Color color);
+ void DrawText(nux::CairoGraphics* cairo, int width, int height, nux::Color const& color);
+ void DrawPrelight(nux::CairoGraphics* cairo, int width, int height, nux::Color const& color);
// Introspection
std::string _name;
@@ -146,4 +146,6 @@ protected:
friend class QuicklistView;
};
+} // NAMESPACE
+
#endif // QUICKLISTMENUITEM_H
diff --git a/plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp b/plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp
index 3b2686b25..0ee867d08 100644
--- a/plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp
+++ b/plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp
@@ -26,7 +26,8 @@
#include "CairoTexture.h"
#include "QuicklistMenuItemCheckmark.h"
-using unity::texture_from_cairo_graphics;
+namespace unity
+{
static double
_align(double val)
@@ -140,7 +141,7 @@ QuicklistMenuItemCheckmark::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw
texture = _prelightTexture[texture_idx]->GetDeviceTexture();
}
- _color = GetEnabled() ? nux::color::White : nux::Color(0.8f, 0.8f, 0.8f, 1.0f);
+ _color = GetEnabled() ? nux::color::White : nux::color::White * 0.35;
gfxContext.QRP_1Tex(base.x,
base.y,
@@ -168,7 +169,6 @@ void QuicklistMenuItemCheckmark::PostDraw(nux::GraphicsEngine& gfxContext,
void
QuicklistMenuItemCheckmark::UpdateTexture()
{
- nux::Color transparent = nux::Color(0.0f, 0.0f, 0.0f, 0.0f);
int width = GetBaseWidth();
int height = GetBaseHeight();
@@ -184,7 +184,7 @@ QuicklistMenuItemCheckmark::UpdateTexture()
cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
cairo_set_line_width(cr, 1.0f);
- DrawText(cr, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White);
if (_normalTexture[0])
_normalTexture[0]->UnReference();
@@ -221,7 +221,7 @@ QuicklistMenuItemCheckmark::UpdateTexture()
cairo_restore(cr);
- DrawText(cr, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White);
if (_normalTexture[1])
_normalTexture[1]->UnReference();
@@ -232,23 +232,8 @@ QuicklistMenuItemCheckmark::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- _cairoGraphics->DrawRoundedRectangle(cr,
- 1.0f,
- 0.5f,
- 0.5f,
- ITEM_CORNER_RADIUS_ABS,
- width - 1.0f,
- height - 1.0f);
- cairo_fill(cr);
-
- cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
-
- DrawText(cr, width, height, transparent);
+ DrawPrelight(_cairoGraphics, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White * 0.0f);
if (_prelightTexture[0])
_prelightTexture[0]->UnReference();
@@ -259,19 +244,7 @@ QuicklistMenuItemCheckmark::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- _cairoGraphics->DrawRoundedRectangle(cr,
- 1.0f,
- 0.5f,
- 0.5f,
- ITEM_CORNER_RADIUS_ABS,
- width - 1.0f,
- height - 1.0f);
- cairo_fill(cr);
+ DrawPrelight(_cairoGraphics, width, height, nux::color::White);
cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
@@ -295,7 +268,7 @@ QuicklistMenuItemCheckmark::UpdateTexture()
cairo_restore(cr);
- DrawText(cr, width, height, transparent);
+ DrawText(_cairoGraphics, width, height, nux::color::White * 0.0f);
if (_prelightTexture[1])
_prelightTexture[1]->UnReference();
@@ -303,6 +276,7 @@ QuicklistMenuItemCheckmark::UpdateTexture()
_prelightTexture[1] = texture_from_cairo_graphics(*_cairoGraphics);
// finally clean up
+ cairo_destroy(cr);
delete _cairoGraphics;
}
@@ -313,3 +287,5 @@ int QuicklistMenuItemCheckmark::CairoSurfaceWidth()
return 0;
}
+
+}
diff --git a/plugins/unityshell/src/QuicklistMenuItemCheckmark.h b/plugins/unityshell/src/QuicklistMenuItemCheckmark.h
index b87a5d99c..39a31f334 100644
--- a/plugins/unityshell/src/QuicklistMenuItemCheckmark.h
+++ b/plugins/unityshell/src/QuicklistMenuItemCheckmark.h
@@ -29,6 +29,9 @@
#include <X11/Xlib.h>
+namespace unity
+{
+
class QuicklistMenuItemCheckmark : public QuicklistMenuItem
{
public:
@@ -59,4 +62,6 @@ protected:
virtual int CairoSurfaceWidth();
};
+} // NAMESPACE
+
#endif // QUICKLISTMENUITEMCHECKMARK_H
diff --git a/plugins/unityshell/src/QuicklistMenuItemLabel.cpp b/plugins/unityshell/src/QuicklistMenuItemLabel.cpp
index fedd55415..b100a0ea1 100644
--- a/plugins/unityshell/src/QuicklistMenuItemLabel.cpp
+++ b/plugins/unityshell/src/QuicklistMenuItemLabel.cpp
@@ -26,7 +26,8 @@
#include "CairoTexture.h"
#include "QuicklistMenuItemLabel.h"
-using unity::texture_from_cairo_graphics;
+namespace unity
+{
QuicklistMenuItemLabel::QuicklistMenuItemLabel(DbusmenuMenuitem* item,
NUX_FILE_LINE_DECL) :
@@ -134,7 +135,7 @@ QuicklistMenuItemLabel::Draw(nux::GraphicsEngine& gfxContext,
else
{
texture = _normalTexture[0]->GetDeviceTexture();
- _color = nux::Color(0.8f, 0.8f, 0.8f, 1.0f);
+ _color = nux::color::White * 0.35;
}
gfxContext.QRP_1Tex(base.x,
@@ -165,7 +166,6 @@ QuicklistMenuItemLabel::PostDraw(nux::GraphicsEngine& gfxContext,
void
QuicklistMenuItemLabel::UpdateTexture()
{
- nux::Color transparent = nux::Color(0.0f, 0.0f, 0.0f, 0.0f);
int width = GetBaseWidth();
int height = GetBaseHeight();
@@ -176,12 +176,7 @@ QuicklistMenuItemLabel::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- DrawText(cr, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White);
if (_normalTexture[0])
_normalTexture[0]->UnReference();
@@ -192,23 +187,8 @@ QuicklistMenuItemLabel::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- _cairoGraphics->DrawRoundedRectangle(cr,
- 1.0f,
- 0.5f,
- 0.5f,
- ITEM_CORNER_RADIUS_ABS,
- width - 1.0f,
- height - 1.0f);
- cairo_fill(cr);
-
- cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
-
- DrawText(cr, width, height, transparent);
+ DrawPrelight(_cairoGraphics, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White * 0.0f);
if (_prelightTexture[0])
_prelightTexture[0]->UnReference();
@@ -216,6 +196,7 @@ QuicklistMenuItemLabel::UpdateTexture()
_prelightTexture[0] = texture_from_cairo_graphics(*_cairoGraphics);
// finally clean up
+ cairo_destroy(cr);
delete _cairoGraphics;
}
@@ -226,3 +207,5 @@ int QuicklistMenuItemLabel::CairoSurfaceWidth()
return 0;
}
+
+} // NAMESPACE
diff --git a/plugins/unityshell/src/QuicklistMenuItemLabel.h b/plugins/unityshell/src/QuicklistMenuItemLabel.h
index 68365fd8d..421c9ac64 100644
--- a/plugins/unityshell/src/QuicklistMenuItemLabel.h
+++ b/plugins/unityshell/src/QuicklistMenuItemLabel.h
@@ -29,6 +29,9 @@
#include <X11/Xlib.h>
+namespace unity
+{
+
class QuicklistMenuItemLabel : public QuicklistMenuItem
{
public:
@@ -59,4 +62,6 @@ protected:
virtual int CairoSurfaceWidth();
};
+} // NAMESPACE
+
#endif // QUICKLISTMENUITEMLABEL_H
diff --git a/plugins/unityshell/src/QuicklistMenuItemRadio.cpp b/plugins/unityshell/src/QuicklistMenuItemRadio.cpp
index 2092c40d5..3d7932886 100644
--- a/plugins/unityshell/src/QuicklistMenuItemRadio.cpp
+++ b/plugins/unityshell/src/QuicklistMenuItemRadio.cpp
@@ -25,7 +25,8 @@
#include "CairoTexture.h"
#include "QuicklistMenuItemRadio.h"
-using unity::texture_from_cairo_graphics;
+namespace unity
+{
static double
_align(double val)
@@ -139,7 +140,7 @@ QuicklistMenuItemRadio::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
texture = _prelightTexture[texture_idx]->GetDeviceTexture();
}
- _color = GetEnabled() ? nux::color::White : nux::Color(0.8f, 0.8f, 0.8f, 1.0f);
+ _color = GetEnabled() ? nux::color::White : nux::color::White * 0.35;
gfxContext.QRP_1Tex(base.x,
base.y,
@@ -169,7 +170,6 @@ QuicklistMenuItemRadio::PostDraw(nux::GraphicsEngine& gfxContext,
void
QuicklistMenuItemRadio::UpdateTexture()
{
- nux::Color transparent = nux::Color(0.0f, 0.0f, 0.0f, 0.0f);
int width = GetBaseWidth();
int height = GetBaseHeight();
@@ -180,12 +180,7 @@ QuicklistMenuItemRadio::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- DrawText(cr, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White);
if (_normalTexture[0])
_normalTexture[0]->UnReference();
@@ -209,8 +204,7 @@ QuicklistMenuItemRadio::UpdateTexture()
cairo_arc(cr, x, y, radius, 0.0f * (G_PI / 180.0f), 360.0f * (G_PI / 180.0f));
cairo_fill(cr);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- DrawText(cr, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White);
if (_normalTexture[1])
_normalTexture[1]->UnReference();
@@ -221,23 +215,8 @@ QuicklistMenuItemRadio::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- _cairoGraphics->DrawRoundedRectangle(cr,
- 1.0f,
- 0.5f,
- 0.5f,
- ITEM_CORNER_RADIUS_ABS,
- width - 1.0f,
- height - 1.0f);
- cairo_fill(cr);
-
- cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
-
- DrawText(cr, width, height, transparent);
+ DrawPrelight(_cairoGraphics, width, height, nux::color::White);
+ DrawText(_cairoGraphics, width, height, nux::color::White * 0.0f);
if (_prelightTexture[0])
_prelightTexture[0]->UnReference();
@@ -248,26 +227,14 @@ QuicklistMenuItemRadio::UpdateTexture()
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_scale(cr, 1.0f, 1.0f);
- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_set_line_width(cr, 1.0f);
-
- _cairoGraphics->DrawRoundedRectangle(cr,
- 1.0f,
- 0.5f,
- 0.5f,
- ITEM_CORNER_RADIUS_ABS,
- width - 1.0f,
- height - 1.0f);
- cairo_fill(cr);
+ DrawPrelight(_cairoGraphics, width, height, nux::color::White);
cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
cairo_arc(cr, x, y, radius, 0.0f * (G_PI / 180.0f), 360.0f * (G_PI / 180.0f));
cairo_fill(cr);
- DrawText(cr, width, height, transparent);
+ DrawText(_cairoGraphics, width, height, nux::color::White * 0.0f);
if (_prelightTexture[1])
_prelightTexture[1]->UnReference();
@@ -275,6 +242,7 @@ QuicklistMenuItemRadio::UpdateTexture()
_prelightTexture[1] = texture_from_cairo_graphics(*_cairoGraphics);
// finally clean up
+ cairo_destroy(cr);
delete _cairoGraphics;
}
@@ -286,3 +254,4 @@ int QuicklistMenuItemRadio::CairoSurfaceWidth()
return 0;
}
+} // NAMESPACE
diff --git a/plugins/unityshell/src/QuicklistMenuItemRadio.h b/plugins/unityshell/src/QuicklistMenuItemRadio.h
index 2361e7509..e75a17ad5 100644
--- a/plugins/unityshell/src/QuicklistMenuItemRadio.h
+++ b/plugins/unityshell/src/QuicklistMenuItemRadio.h
@@ -28,6 +28,9 @@
#include <X11/Xlib.h>
+namespace unity
+{
+
class QuicklistMenuItemRadio : public QuicklistMenuItem
{
public:
@@ -60,4 +63,6 @@ protected:
virtual int CairoSurfaceWidth();
};
+} //NAMESPACE
+
#endif // QUICKLISTMENUITEMRADIO_H
diff --git a/plugins/unityshell/src/QuicklistMenuItemSeparator.cpp b/plugins/unityshell/src/QuicklistMenuItemSeparator.cpp
index 7bb2f97ba..69e56cd7e 100644
--- a/plugins/unityshell/src/QuicklistMenuItemSeparator.cpp
+++ b/plugins/unityshell/src/QuicklistMenuItemSeparator.cpp
@@ -22,7 +22,8 @@
#include "CairoTexture.h"
#include "QuicklistMenuItemSeparator.h"
-using unity::texture_from_cairo_graphics;
+namespace unity
+{
QuicklistMenuItemSeparator::QuicklistMenuItemSeparator(DbusmenuMenuitem* item,
NUX_FILE_LINE_DECL) :
@@ -32,7 +33,7 @@ QuicklistMenuItemSeparator::QuicklistMenuItemSeparator(DbusmenuMenuitem* item,
_name = "QuicklistMenuItemSeparator";
SetMinimumHeight(5);
SetBaseSize(64, 5);
- //_normalTexture = NULL;
+
_color = nux::Color(1.0f, 1.0f, 1.0f, 0.5f);
_premultiplied_color = nux::Color(0.5f, 0.5f, 0.5f, 0.5f);
_item_type = MENUITEM_TYPE_SEPARATOR;
@@ -145,10 +146,9 @@ void
QuicklistMenuItemSeparator::UpdateTexture()
{
int width = GetBaseWidth();
+ int height = GetBaseHeight();
- _cairoGraphics = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32,
- GetBaseWidth(),
- GetBaseHeight());
+ _cairoGraphics = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height);
cairo_t* cr = _cairoGraphics->GetContext();
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
@@ -165,6 +165,7 @@ QuicklistMenuItemSeparator::UpdateTexture()
_normalTexture[0] = texture_from_cairo_graphics(*_cairoGraphics);
+ cairo_destroy(cr);
delete _cairoGraphics;
}
@@ -175,3 +176,5 @@ int QuicklistMenuItemSeparator::CairoSurfaceWidth()
return 0;
}
+
+}
diff --git a/plugins/unityshell/src/QuicklistMenuItemSeparator.h b/plugins/unityshell/src/QuicklistMenuItemSeparator.h
index e882e67d2..708460381 100644
--- a/plugins/unityshell/src/QuicklistMenuItemSeparator.h
+++ b/plugins/unityshell/src/QuicklistMenuItemSeparator.h
@@ -28,6 +28,9 @@
#include <X11/Xlib.h>
+namespace unity
+{
+
class QuicklistMenuItemSeparator : public QuicklistMenuItem
{
public:
@@ -64,4 +67,5 @@ private:
nux::Color _premultiplied_color;
};
+}
#endif // QUICKLISTMENUITEMSEPARATOR_H
diff --git a/plugins/unityshell/src/QuicklistView.cpp b/plugins/unityshell/src/QuicklistView.cpp
index 4003b1a06..779485810 100644
--- a/plugins/unityshell/src/QuicklistView.cpp
+++ b/plugins/unityshell/src/QuicklistView.cpp
@@ -50,7 +50,12 @@
#define NUX_KP_LEFT 0xFF96
#define NUX_KP_RIGHT 0xFF98
-using unity::texture_from_cairo_graphics;
+namespace unity
+{
+namespace
+{
+ const int ANCHOR_WIDTH = 10.0f;
+}
NUX_IMPLEMENT_OBJECT_TYPE(QuicklistView);
@@ -61,9 +66,6 @@ QuicklistView::QuicklistView()
, _top_size(4)
, _mouse_down(false)
, _enable_quicklist_for_testing(false)
- , _texture_bg(nullptr)
- , _texture_mask(nullptr)
- , _texture_outline(nullptr)
, _anchor_width(10)
, _anchor_height(18)
, _corner_radius(4)
@@ -73,11 +75,13 @@ QuicklistView::QuicklistView()
, _bottom_padding_correction_single_item(-4)
, _offset_correction(-1)
, _cairo_text_has_changed(true)
- , _compute_blur_bkg(true)
, _current_item_index(0)
{
SetGeometry(nux::Geometry(0, 0, 1, 1));
+ _use_blurred_background = true;
+ _compute_blur_bkg = true;
+
_left_space = new nux::SpaceLayout(_padding +
_anchor_width +
_corner_radius +
@@ -106,6 +110,7 @@ QuicklistView::QuicklistView()
_default_item_layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
_vlayout->AddLayout(_default_item_layout, 0);
_vlayout->AddLayout(_bottom_space, 0);
+ _vlayout->SetMinimumWidth(140);
_hlayout = new nux::HLayout(TEXT(""), NUX_TRACKER_LOCATION);
_hlayout->AddLayout(_left_space, 0);
@@ -272,15 +277,6 @@ QuicklistView::RecvKeyPressed(unsigned long eventType,
QuicklistView::~QuicklistView()
{
- if (_texture_bg)
- _texture_bg->UnReference();
-
- if (_texture_outline)
- _texture_outline->UnReference();
-
- if (_texture_mask)
- _texture_mask->UnReference();
-
std::list<QuicklistMenuItem*>::iterator it;
for (it = _item_list.begin(); it != _item_list.end(); it++)
{
@@ -346,7 +342,7 @@ void QuicklistView::ShowQuicklistWithTipAt(int anchor_tip_x, int anchor_tip_y)
void QuicklistView::ShowWindow(bool b, bool start_modal)
{
- BaseWindow::ShowWindow(b, start_modal);
+ unity::CairoBaseWindow::ShowWindow(b, start_modal);
}
void QuicklistView::Show()
@@ -380,101 +376,14 @@ void QuicklistView::Hide()
void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
{
- // Get the geometry of the QuicklistView on the display
- nux::Geometry base = GetGeometry();
-
- // Get the background of the QuicklistView and apply some
- if (_compute_blur_bkg /* Refresh the blurred background*/)
- {
- nux::ObjectPtr<nux::IOpenGLFrameBufferObject> current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
- nux::GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();
-
- gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
- gfxContext.SetScissor(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
- gfxContext.GetRenderStates().EnableScissor(false);
-
- nux::ObjectPtr <nux::IOpenGLBaseTexture> bkg_texture = gfxContext.CreateTextureFromBackBuffer(base.x, base.y, base.width, base.height);
-
- nux::TexCoordXForm texxform_bkg;
- bkg_blur_texture = gfxContext.QRP_GetBlurTexture(0, 0, base.width, base.height, bkg_texture, texxform_bkg, nux::color::White, 1.0f, 3);
+ CairoBaseWindow::Draw(gfxContext, forceDraw);
- if (current_fbo.IsValid())
- {
- current_fbo->Activate(true);
- gfxContext.Push2DWindow(current_fbo->GetWidth(), current_fbo->GetHeight());
- }
- else
- {
- gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
- gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
- gfxContext.ApplyClippingRectangle();
- }
- _compute_blur_bkg = false;
- }
+ nux::Geometry base(GetGeometry());
+ base.x = 0;
+ base.y = 0;
- // the elements position inside the window are referenced to top-left window
- // corner. So bring base to (0, 0).
- base.SetX(0);
- base.SetY(0);
gfxContext.PushClippingRectangle(base);
- nux::TexCoordXForm texxform_blur_bkg;
- //texxform_blur_bkg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
- //texxform_blur_bkg.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
-
- nux::TexCoordXForm texxform_bg;
- texxform_bg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
- texxform_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
-
- nux::TexCoordXForm texxform_mask;
- texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
- texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
-
- if (bkg_blur_texture.IsValid())
- {
- gfxContext.QRP_2TexMod(
- base.x,
- base.y,
- base.width,
- base.height,
- bkg_blur_texture,
- texxform_blur_bkg,
- nux::color::White,
- _texture_mask->GetDeviceTexture(),
- texxform_mask,
- nux::color::White);
- }
-
- nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
- nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
- gfxContext.QRP_2TexMod(base.x,
- base.y,
- base.width,
- base.height,
- _texture_bg->GetDeviceTexture(),
- texxform_bg,
- nux::Color(1.0f, 1.0f, 1.0f, 1.0f),
- _texture_mask->GetDeviceTexture(),
- texxform_mask,
- nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
-
-
- nux::TexCoordXForm texxform;
- texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
- texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
-
- nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
- nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
- gfxContext.QRP_1Tex(base.x,
- base.y,
- base.width,
- base.height,
- _texture_outline->GetDeviceTexture(),
- texxform,
- nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
-
- nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(false);
-
std::list<QuicklistMenuItem*>::iterator it;
for (it = _item_list.begin(); it != _item_list.end(); it++)
{
@@ -492,9 +401,7 @@ void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
}
void QuicklistView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
-{
-
-}
+{}
void QuicklistView::PreLayoutManagement()
{
@@ -1283,9 +1190,8 @@ ql_compute_full_outline_shadow(
padding_size);
ql_draw(cr, TRUE, line_width, rgba_shadow, FALSE, FALSE);
- nux::CairoGraphics* dummy = new nux::CairoGraphics(CAIRO_FORMAT_A1, 1, 1);
- dummy->BlurSurface(blur_coeff, surf);
- delete dummy;
+ nux::CairoGraphics dummy(CAIRO_FORMAT_A1, 1, 1);
+ dummy.BlurSurface(blur_coeff, surf);
ql_compute_mask(cr);
ql_compute_outline(cr, line_width, rgba_line, width);
}
@@ -1324,13 +1230,15 @@ void QuicklistView::UpdateTexture()
return;
int size_above_anchor = -1; // equal to size below
+ int width = GetBaseWidth();
+ int height = GetBaseHeight();
if (!_enable_quicklist_for_testing)
{
if (!_item_list.empty() || !_default_item_list.empty())
{
int offscreen_size = GetBaseY() +
- GetBaseHeight() -
+ height -
nux::GetWindowThread()->GetGraphicsDisplay().GetWindowHeight();
if (offscreen_size > 0)
@@ -1359,29 +1267,29 @@ void QuicklistView::UpdateTexture()
float blur_coef = 6.0f;
- nux::CairoGraphics* cairo_bg = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
- nux::CairoGraphics* cairo_mask = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
- nux::CairoGraphics* cairo_outline = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
+ nux::CairoGraphics cairo_bg(CAIRO_FORMAT_ARGB32, width, height);
+ nux::CairoGraphics cairo_mask(CAIRO_FORMAT_ARGB32, width, height);
+ nux::CairoGraphics cairo_outline(CAIRO_FORMAT_ARGB32, width, height);
- cairo_t* cr_bg = cairo_bg->GetContext();
- cairo_t* cr_mask = cairo_mask->GetContext();
- cairo_t* cr_outline = cairo_outline->GetContext();
+ cairo_t* cr_bg = cairo_bg.GetContext();
+ cairo_t* cr_mask = cairo_mask.GetContext();
+ cairo_t* cr_outline = cairo_outline.GetContext();
float tint_color[4] = {0.0f, 0.0f, 0.0f, 0.60f};
- float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.65f};
- float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.10f};
+ float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.35f};
+ float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.03f};
float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
- float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.65f};
+ float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.40f};
float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
// float anchor_width = 10;
// float anchor_height = 18;
ql_tint_dot_hl(cr_bg,
- GetBaseWidth(),
- GetBaseHeight(),
- GetBaseWidth() / 2.0f,
+ width,
+ height,
+ width / 2.0f,
0,
- nux::Max<float>(GetBaseWidth() / 1.3f, GetBaseHeight() / 1.3f),
+ nux::Max<float>(width / 1.6f, height / 1.6f),
tint_color,
hl_color,
dot_color);
@@ -1389,9 +1297,9 @@ void QuicklistView::UpdateTexture()
ql_compute_full_outline_shadow
(
cr_outline,
- cairo_outline->GetSurface(),
- GetBaseWidth(),
- GetBaseHeight(),
+ cairo_outline.GetSurface(),
+ width,
+ height,
_anchor_width,
_anchor_height,
size_above_anchor,
@@ -1404,9 +1312,9 @@ void QuicklistView::UpdateTexture()
ql_compute_full_mask(
cr_mask,
- cairo_mask->GetSurface(),
- GetBaseWidth(),
- GetBaseHeight(),
+ cairo_mask.GetSurface(),
+ width,
+ height,
_corner_radius, // radius,
16, // shadow_radius,
_anchor_width, // anchor_width,
@@ -1422,21 +1330,10 @@ void QuicklistView::UpdateTexture()
cairo_destroy(cr_outline);
cairo_destroy(cr_mask);
- if (_texture_bg)
- _texture_bg->UnReference();
- _texture_bg = texture_from_cairo_graphics(*cairo_bg);
-
- if (_texture_mask)
- _texture_mask->UnReference();
- _texture_mask = texture_from_cairo_graphics(*cairo_mask);
+ texture_bg_ = texture_from_cairo_graphics(cairo_bg);
+ texture_mask_ = texture_from_cairo_graphics(cairo_mask);
+ texture_outline_ = texture_from_cairo_graphics(cairo_outline);
- if (_texture_outline)
- _texture_outline->UnReference();
- _texture_outline = texture_from_cairo_graphics(*cairo_outline);
-
- delete cairo_bg;
- delete cairo_mask;
- delete cairo_outline;
_cairo_text_has_changed = false;
// Request a redraw, so this area will be added to Compiz list of dirty areas.
@@ -1533,3 +1430,5 @@ QuicklistView::GetSelectedMenuItem()
{
return GetNthItems(_current_item_index);
}
+
+} // NAMESPACE
diff --git a/plugins/unityshell/src/QuicklistView.h b/plugins/unityshell/src/QuicklistView.h
index f26d419af..72518685e 100644
--- a/plugins/unityshell/src/QuicklistView.h
+++ b/plugins/unityshell/src/QuicklistView.h
@@ -30,40 +30,21 @@
#include <pango/pango.h>
#include <pango/pangocairo.h>
+#include "CairoBaseWindow.h"
#include "QuicklistMenuItem.h"
#include "Introspectable.h"
-#define ANCHOR_WIDTH 10.0f
-#define ANCHOR_HEIGHT 18.0f
-#define HIGH_LIGHT_Y -30.0f
-#define HIGH_LIGHT_MIN_WIDTH 200.0f
-#define RADIUS 5.0f
-#define BLUR_INTENSITY 8
-#define LINE_WIDTH 1.0f
-#define PADDING_SIZE 1
-#define H_MARGIN 30
-#define V_MARGIN 4
-#define FONT_FACE "Ubuntu 13"
-
-
-class QuicklistMenuItem;
-class QuicklistMenuItemLabel;
+namespace unity
+{
-class QuicklistView : public nux::BaseWindow, public unity::debug::Introspectable
+class QuicklistView : public CairoBaseWindow, public debug::Introspectable
{
- NUX_DECLARE_OBJECT_TYPE(QuicklistView, nux::BaseWindow);
+ NUX_DECLARE_OBJECT_TYPE(QuicklistView, unity::CairoBaseWindow);
public:
QuicklistView();
-
~QuicklistView();
- void Draw(nux::GraphicsEngine& gfxContext,
- bool forceDraw);
-
- void DrawContent(nux::GraphicsEngine& gfxContext,
- bool forceDraw);
-
void SetText(nux::NString text);
void RemoveAllMenuItem();
@@ -101,6 +82,10 @@ public:
QuicklistMenuItem* GetSelectedMenuItem();
sigc::signal<void> selection_change;
+protected:
+ void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
+ void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
+
private:
void RecvCairoTextChanged(QuicklistMenuItem* item);
void RecvCairoTextColorChanged(QuicklistMenuItem* item);
@@ -158,10 +143,6 @@ private:
// Keep the Quicklist on screen for testing and automation.
bool _enable_quicklist_for_testing;
- nux::BaseTexture* _texture_bg;
- nux::BaseTexture* _texture_mask;
- nux::BaseTexture* _texture_outline;
-
float _anchor_width;
float _anchor_height;
float _corner_radius;
@@ -184,12 +165,9 @@ private:
std::list<QuicklistMenuItem*> _item_list;
std::list<QuicklistMenuItem*> _default_item_list;
- bool _compute_blur_bkg; //!< If true, compute the blurred background
- nux::ObjectPtr <nux::IOpenGLBaseTexture> bkg_blur_texture; // Texture holding a blurred copy of the background behind the QuicklistView
-
// used by keyboard/a11y-navigation
int _current_item_index;
};
+} // NAMESPACE
#endif // QUICKLISTVIEW_H
-
diff --git a/plugins/unityshell/src/StaticCairoText.cpp b/plugins/unityshell/src/StaticCairoText.cpp
index 1bb375e14..23fe8ca3d 100644
--- a/plugins/unityshell/src/StaticCairoText.cpp
+++ b/plugins/unityshell/src/StaticCairoText.cpp
@@ -167,8 +167,12 @@ StaticCairoText::Draw(GraphicsEngine& gfxContext,
{
Geometry base = GetGeometry();
- if (_texture2D == 0)
+ if (!_texture2D || _cached_base_width != base.width || _cached_base_height != base.height)
+ {
+ _cached_base_width = base.width;
+ _cached_base_height = base.height;
UpdateTexture();
+ }
gfxContext.PushClippingRectangle(base);
@@ -219,7 +223,7 @@ StaticCairoText::PostDraw(GraphicsEngine& gfxContext,
}
void
-StaticCairoText::SetText(NString text)
+StaticCairoText::SetText(NString const& text)
{
if (_text != text)
{
@@ -240,7 +244,7 @@ StaticCairoText::GetText()
}
void
-StaticCairoText::SetTextColor(Color textColor)
+StaticCairoText::SetTextColor(Color const& textColor)
{
if (_textColor != textColor)
{
@@ -380,8 +384,6 @@ void StaticCairoText::DrawText(cairo_t* cr,
int height,
Color color)
{
- int textWidth = 0;
- int textHeight = 0;
PangoLayout* layout = NULL;
PangoFontDescription* desc = NULL;
PangoContext* pangoCtx = NULL;
@@ -395,8 +397,6 @@ void StaticCairoText::DrawText(cairo_t* cr,
else
fontName = g_strdup(_fontstring);
- GetTextExtents(fontName, textWidth, textHeight);
-
cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
layout = pango_cairo_create_layout(cr);
desc = pango_font_description_from_string(fontName);
@@ -421,7 +421,8 @@ void StaticCairoText::DrawText(cairo_t* cr,
pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT);
pango_layout_set_markup(layout, _text.GetTCharPtr(), -1);
- pango_layout_set_width(layout, textWidth * PANGO_SCALE);
+ pango_layout_set_width(layout, width * PANGO_SCALE);
+ pango_layout_set_height(layout, height * PANGO_SCALE);
pango_layout_set_height(layout, _lines);
pangoCtx = pango_layout_get_context(layout); // is not ref'ed
@@ -463,7 +464,6 @@ void StaticCairoText::UpdateTexture()
int width = 0;
int height = 0;
GetTextExtents(width, height);
-
SetBaseSize(width, height);
_cairoGraphics = new CairoGraphics(CAIRO_FORMAT_ARGB32,
diff --git a/plugins/unityshell/src/StaticCairoText.h b/plugins/unityshell/src/StaticCairoText.h
index 29e332347..b39103d3b 100644
--- a/plugins/unityshell/src/StaticCairoText.h
+++ b/plugins/unityshell/src/StaticCairoText.h
@@ -77,8 +77,8 @@ public:
bool forceDraw);
// public API
- void SetText(NString text);
- void SetTextColor(Color textColor);
+ void SetText(NString const& text);
+ void SetTextColor(Color const& textColor);
void SetTextEllipsize(EllipsizeState state);
void SetTextAlignment(AlignState state);
void SetTextVerticalAlignment(AlignState state);
@@ -105,6 +105,8 @@ private:
int _cached_extent_width;
int _cached_extent_height;
bool _need_new_extent_cache;
+ int _cached_base_width;
+ int _cached_base_height;
NString _text;
Color _textColor;
diff --git a/plugins/unityshell/src/Tooltip.cpp b/plugins/unityshell/src/Tooltip.cpp
index d951e8148..c7f3256dd 100644
--- a/plugins/unityshell/src/Tooltip.cpp
+++ b/plugins/unityshell/src/Tooltip.cpp
@@ -1,6 +1,6 @@
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
- * Copyright (C) 2010 Canonical Ltd
+ * Copyright (C) 2010-2012 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,92 +15,77 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Jay Taoko <jay.taoko@canonical.com>
- * Authored by: Mirco Müller <mirco.mueller@canonical.com
+ * Mirco Müller <mirco.mueller@canonical.com
+ * Andrea Cimitan <andrea.cimitan@canonical.com>
+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
*/
#include <Nux/Nux.h>
-#include <Nux/VLayout.h>
-#include <Nux/HLayout.h>
-#include <Nux/WindowThread.h>
-#include <Nux/WindowCompositor.h>
-#include <Nux/BaseWindow.h>
-#include <Nux/Button.h>
-#include <NuxGraphics/GraphicsEngine.h>
-#include <Nux/TextureArea.h>
-#include <NuxImage/CairoGraphics.h>
#include "CairoTexture.h"
-#include "QuicklistMenuItem.h"
#include "ubus-server.h"
#include "UBusMessages.h"
#include "Tooltip.h"
-using unity::texture_from_cairo_graphics;
-
-namespace nux
+namespace unity
{
-NUX_IMPLEMENT_OBJECT_TYPE(Tooltip);
-
-Tooltip::Tooltip()
+namespace
{
- _texture_bg = 0;
- _texture_mask = 0;
- _texture_outline = 0;
- _cairo_text_has_changed = true;
-
- _anchorX = 0;
- _anchorY = 0;
- _labelText = TEXT("Unity");
+ const int ANCHOR_WIDTH = 14;
+ const int ANCHOR_HEIGHT = 18;
+ const int CORNER_RADIUS = 4;
+ const int PADDING = 15;
+ const int TEXT_PADDING = 8;
+ const int MINIMUM_TEXT_WIDTH = 100;
+ const int TOP_SIZE = 0;
+}
- _anchor_width = 10;
- _anchor_height = 18;
- _corner_radius = 4;
- _padding = 15;
- _top_size = 4;
+NUX_IMPLEMENT_OBJECT_TYPE(Tooltip);
+Tooltip::Tooltip() :
+ _anchorX(0),
+ _anchorY(0),
+ _labelText(TEXT("Unity")),
+ _cairo_text_has_changed(true)
+{
+ _use_blurred_background = true;
+ _compute_blur_bkg = true;
- _hlayout = new nux::HLayout(TEXT(""), NUX_TRACKER_LOCATION);
- _vlayout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
+ _hlayout = new nux::HLayout(TEXT(""), NUX_TRACKER_LOCATION);
+ _vlayout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
- _left_space = new nux::SpaceLayout(_padding + _anchor_width + _corner_radius, _padding + _anchor_width + _corner_radius, 1, 1000);
- _right_space = new nux::SpaceLayout(_padding + _corner_radius, _padding + _corner_radius, 1, 1000);
+ _left_space = new nux::SpaceLayout(PADDING + ANCHOR_WIDTH, PADDING + ANCHOR_WIDTH, 1, 1000);
+ _right_space = new nux::SpaceLayout(PADDING + CORNER_RADIUS, PADDING + CORNER_RADIUS, 1, 1000);
- _top_space = new nux::SpaceLayout(1, 1000, _padding + _corner_radius, _padding + _corner_radius);
- _bottom_space = new nux::SpaceLayout(1, 1000, _padding + _corner_radius, _padding + _corner_radius);
+ _top_space = new nux::SpaceLayout(1, 1000, PADDING, PADDING);
+ _bottom_space = new nux::SpaceLayout(1, 1000, PADDING, PADDING);
_vlayout->AddLayout(_top_space, 0);
_tooltip_text = new nux::StaticCairoText(_labelText.GetTCharPtr(), NUX_TRACKER_LOCATION);
+ _tooltip_text->SetTextAlignment(nux::StaticCairoText::AlignState::NUX_ALIGN_CENTRE);
+ _tooltip_text->SetTextVerticalAlignment(nux::StaticCairoText::AlignState::NUX_ALIGN_CENTRE);
+ _tooltip_text->SetMinimumWidth(MINIMUM_TEXT_WIDTH);
+
_tooltip_text->sigTextChanged.connect(sigc::mem_fun(this, &Tooltip::RecvCairoTextChanged));
_tooltip_text->sigFontChanged.connect(sigc::mem_fun(this, &Tooltip::RecvCairoTextChanged));
- _tooltip_text->Reference();
- _vlayout->AddView(_tooltip_text, 1, eCenter, eFull);
+ _vlayout->AddView(_tooltip_text.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
_vlayout->AddLayout(_bottom_space, 0);
_hlayout->AddLayout(_left_space, 0);
- _hlayout->AddLayout(_vlayout, 1, eCenter, eFull);
+ _hlayout->AddLayout(_vlayout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
_hlayout->AddLayout(_right_space, 0);
SetWindowSizeMatchLayout(true);
SetLayout(_hlayout);
-
}
-Tooltip::~Tooltip()
-{
- _tooltip_text->UnReference();
-
- if (_texture_bg) _texture_bg->UnReference();
- if (_texture_mask) _texture_mask->UnReference();
- if (_texture_outline) _texture_outline->UnReference();
-}
-
-Area* Tooltip::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
+nux::Area* Tooltip::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
{
// No area under mouse to allow click through to entities below
- return 0;
+ return nullptr;
}
void Tooltip::ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y)
@@ -108,8 +93,10 @@ void Tooltip::ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y)
_anchorX = anchor_tip_x;
_anchorY = anchor_tip_y;
- int x = _anchorX - _padding;
- int y = anchor_tip_y - _anchor_height / 2 - _top_size - _corner_radius - _padding;
+ int x = _anchorX - PADDING;
+ int y = anchor_tip_y - ANCHOR_HEIGHT / 2 - TOP_SIZE - CORNER_RADIUS - PADDING;
+
+ _compute_blur_bkg = true;
SetBaseX(x);
SetBaseY(y);
@@ -121,97 +108,54 @@ void Tooltip::ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y)
ubus_server_send_message(ubus, UBUS_TOOLTIP_SHOWN, NULL);
}
-void Tooltip::Draw(GraphicsEngine& gfxContext, bool forceDraw)
+void Tooltip::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
{
- Geometry base = GetGeometry();
+ CairoBaseWindow::Draw(gfxContext, forceDraw);
- // the elements position inside the window are referenced to top-left window
- // corner. So bring base to (0, 0).
- base.SetX(0);
- base.SetY(0);
+ nux::Geometry const& base = GetGeometry();
gfxContext.PushClippingRectangle(base);
- nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetBlend(false);
-
- TexCoordXForm texxform_bg;
- texxform_bg.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP);
- texxform_bg.SetTexCoordType(TexCoordXForm::OFFSET_COORD);
-
- TexCoordXForm texxform_mask;
- texxform_mask.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP);
- texxform_mask.SetTexCoordType(TexCoordXForm::OFFSET_COORD);
-
-
- gfxContext.QRP_2TexMod(base.x,
- base.y,
- base.width,
- base.height,
- _texture_bg->GetDeviceTexture(),
- texxform_bg,
- Color(1.0f, 1.0f, 1.0f, 1.0f),
- _texture_mask->GetDeviceTexture(),
- texxform_mask,
- Color(1.0f, 1.0f, 1.0f, 1.0f));
-
-
- TexCoordXForm texxform;
- texxform.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP);
- texxform.SetTexCoordType(TexCoordXForm::OFFSET_COORD);
-
- nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetBlend(true);
- nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
- gfxContext.QRP_1Tex(base.x,
- base.y,
- base.width,
- base.height,
- _texture_outline->GetDeviceTexture(),
- texxform,
- Color(1.0f, 1.0f, 1.0f, 1.0f));
-
- nux::GetWindowThread()->GetGraphicsDisplay().GetGraphicsEngine()->GetRenderStates().SetBlend(false);
-
_tooltip_text->ProcessDraw(gfxContext, forceDraw);
gfxContext.PopClippingRectangle();
}
-void Tooltip::DrawContent(GraphicsEngine& GfxContext, bool force_draw)
-{
-
-}
+void Tooltip::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
+{}
void Tooltip::PreLayoutManagement()
{
- int MaxItemWidth = 0;
- int TotalItemHeight = 0;
- int textWidth = 0;
- int textHeight = 0;
+ int text_width;
+ int text_height;
+ int text_min_width = MINIMUM_TEXT_WIDTH;
- _tooltip_text->GetTextExtents(textWidth, textHeight);
+ _tooltip_text->GetTextExtents(text_width, text_height);
- if (textWidth > MaxItemWidth)
- MaxItemWidth = textWidth;
- TotalItemHeight += textHeight;
+ if (text_width + TEXT_PADDING * 2 > text_min_width)
+ {
+ text_min_width = text_width + TEXT_PADDING * 2;
+ }
+ _tooltip_text->SetMinimumWidth(text_min_width);
- if (TotalItemHeight < _anchor_height)
+ if (text_height < ANCHOR_HEIGHT)
{
- _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + _padding + _corner_radius);
- _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + 1 + _padding + _corner_radius);
+ _top_space->SetMinMaxSize(1, (ANCHOR_HEIGHT - text_height) / 2 + PADDING + CORNER_RADIUS);
+ _bottom_space->SetMinMaxSize(1, (ANCHOR_HEIGHT - text_height) / 2 + 1 + PADDING + CORNER_RADIUS);
}
- BaseWindow::PreLayoutManagement();
+ nux::BaseWindow::PreLayoutManagement();
}
long Tooltip::PostLayoutManagement(long LayoutResult)
{
- long result = BaseWindow::PostLayoutManagement(LayoutResult);
+ long result = nux::BaseWindow::PostLayoutManagement(LayoutResult);
UpdateTexture();
return result;
}
-void Tooltip::RecvCairoTextChanged(StaticCairoText* cairo_text)
+void Tooltip::RecvCairoTextChanged(nux::StaticCairoText* cairo_text)
{
_cairo_text_has_changed = true;
}
@@ -230,6 +174,8 @@ void tint_dot_hl(cairo_t* cr,
gfloat* rgba_hl,
gfloat* rgba_dot)
{
+ cairo_pattern_t* hl_pattern = NULL;
+
// clear normal context
cairo_scale(cr, 1.0f, 1.0f);
cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
@@ -248,7 +194,25 @@ void tint_dot_hl(cairo_t* cr,
rgba_tint[1],
rgba_tint[2],
rgba_tint[3]);
+ cairo_fill_preserve(cr);
+
+ // draw glow
+ hl_pattern = cairo_pattern_create_radial(hl_x,
+ hl_y - hl_size / 1.4f,
+ 0.0f,
+ hl_x,
+ hl_y - hl_size / 1.4f,
+ hl_size);
+ cairo_pattern_add_color_stop_rgba(hl_pattern,
+ 0.0f,
+ rgba_hl[0],
+ rgba_hl[1],
+ rgba_hl[2],
+ rgba_hl[3]);
+ cairo_pattern_add_color_stop_rgba(hl_pattern, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
+ cairo_set_source(cr, hl_pattern);
cairo_fill(cr);
+ cairo_pattern_destroy(hl_pattern);
}
void _setup(cairo_surface_t** surf,
@@ -285,105 +249,46 @@ void _compute_full_mask_path(cairo_t* cr,
gfloat radius,
guint pad)
{
- // 0 1 2 3
- // +--+--------+--+
- // | |
- // + 14 + 4
- // | |
- // | |
- // | |
- // + 13 |
- // / |
+
+ // 0 1 2
+ // +------------+-+
+ // / + 3
// / |
- // + 12 |
+ // + 8 |
// \ |
- // \ |
- // 11 + |
- // | |
- // | |
- // | |
- // 10 + + 5
- // | |
- // +--+--------+--+ 6
- // 9 8 7
-
-
- gfloat padding = pad;
- int ZEROPOINT5 = 0.0f;
-
- gfloat HeightToAnchor = 0.0f;
- HeightToAnchor = ((gfloat) height - 2.0f * radius - anchor_height - 2 * padding) / 2.0f;
- if (HeightToAnchor < 0.0f)
- {
- g_warning("Anchor-height and corner-radius a higher than whole texture!");
- return;
- }
+ // \ + 4
+ // +------------+-+
+ // 7 6 5
- if (upper_size >= 0)
- {
- if (upper_size > height - 2.0f * radius - anchor_height - 2 * padding)
- {
- //g_warning ("[_compute_full_mask_path] incorrect upper_size value");
- HeightToAnchor = 0;
- }
- else
- {
- HeightToAnchor = height - 2.0f * radius - anchor_height - 2 * padding - upper_size;
- }
- }
- else
- {
- HeightToAnchor = (height - 2.0f * radius - anchor_height - 2 * padding) / 2.0f;
- }
+ gfloat padding = pad;
cairo_translate(cr, -0.5f, -0.5f);
// create path
- cairo_move_to(cr, padding + anchor_width + radius + ZEROPOINT5, padding + ZEROPOINT5); // Point 1
- cairo_line_to(cr, width - padding - radius, padding + ZEROPOINT5); // Point 2
+ cairo_move_to(cr, padding + anchor_width, padding); // Point 0
+ cairo_line_to(cr, width - padding - radius, padding); // Point 1
cairo_arc(cr,
- width - padding - radius + ZEROPOINT5,
- padding + radius + ZEROPOINT5,
+ width - padding - radius,
+ padding + radius,
radius,
-90.0f * G_PI / 180.0f,
- 0.0f * G_PI / 180.0f); // Point 4
+ 0.0f * G_PI / 180.0f); // Point 3
cairo_line_to(cr,
- (gdouble) width - padding + ZEROPOINT5,
- (gdouble) height - radius - padding + ZEROPOINT5); // Point 5
+ (gdouble) width - padding,
+ (gdouble) height - radius - padding); // Point 4
cairo_arc(cr,
- (gdouble) width - padding - radius + ZEROPOINT5,
- (gdouble) height - padding - radius + ZEROPOINT5,
+ (gdouble) width - padding - radius,
+ (gdouble) height - padding - radius,
radius,
0.0f * G_PI / 180.0f,
- 90.0f * G_PI / 180.0f); // Point 7
+ 90.0f * G_PI / 180.0f); // Point 6
cairo_line_to(cr,
- anchor_width + padding + radius + ZEROPOINT5,
- (gdouble) height - padding + ZEROPOINT5); // Point 8
-
- cairo_arc(cr,
- anchor_width + padding + radius + ZEROPOINT5,
- (gdouble) height - padding - radius,
- radius,
- 90.0f * G_PI / 180.0f,
- 180.0f * G_PI / 180.0f); // Point 10
+ anchor_width + padding,
+ (gdouble) height - padding); // Point 7
cairo_line_to(cr,
- padding + anchor_width + ZEROPOINT5,
- (gdouble) height - padding - radius - HeightToAnchor + ZEROPOINT5); // Point 11
- cairo_line_to(cr,
- padding + ZEROPOINT5,
- (gdouble) height - padding - radius - HeightToAnchor - anchor_height / 2.0f + ZEROPOINT5); // Point 12
- cairo_line_to(cr,
- padding + anchor_width + ZEROPOINT5,
- (gdouble) height - padding - radius - HeightToAnchor - anchor_height + ZEROPOINT5); // Point 13
-
- cairo_line_to(cr, padding + anchor_width + ZEROPOINT5, padding + radius + ZEROPOINT5); // Point 14
- cairo_arc(cr,
- padding + anchor_width + radius + ZEROPOINT5,
- padding + radius + ZEROPOINT5,
- radius,
- 180.0f * G_PI / 180.0f,
- 270.0f * G_PI / 180.0f);
+ padding,
+ (gdouble) height / 2.0f); // Point 8
cairo_close_path(cr);
}
@@ -497,10 +402,10 @@ compute_full_outline_shadow(
padding_size);
_draw(cr, TRUE, line_width, rgba_shadow, FALSE, FALSE);
- CairoGraphics* dummy = new CairoGraphics(CAIRO_FORMAT_A1, 1, 1);
- dummy->BlurSurface(blur_coeff, surf);
- delete dummy;
+ nux::CairoGraphics dummy(CAIRO_FORMAT_A1, 1, 1);
+ dummy.BlurSurface(blur_coeff, surf);
compute_mask(cr);
+ compute_outline(cr, line_width, rgba_line);
}
void compute_full_mask(
@@ -536,38 +441,38 @@ void Tooltip::UpdateTexture()
if (_cairo_text_has_changed == false)
return;
+ int width = GetBaseWidth();
int height = GetBaseHeight();
- _top_size = 0;
- int x = _anchorX - _padding;
+ int x = _anchorX - PADDING;
int y = _anchorY - height / 2;
+ float blur_coef = 6.0f;
+
SetBaseX(x);
SetBaseY(y);
- float blur_coef = 6.0f;
-
- CairoGraphics* cairo_bg = new CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
- CairoGraphics* cairo_mask = new CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
- CairoGraphics* cairo_outline = new CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
+ nux::CairoGraphics cairo_bg(CAIRO_FORMAT_ARGB32, width, height);
+ nux::CairoGraphics cairo_mask(CAIRO_FORMAT_ARGB32, width, height);
+ nux::CairoGraphics cairo_outline(CAIRO_FORMAT_ARGB32, width, height);
- cairo_t* cr_bg = cairo_bg->GetContext();
- cairo_t* cr_mask = cairo_mask->GetContext();
- cairo_t* cr_outline = cairo_outline->GetContext();
+ cairo_t* cr_bg = cairo_bg.GetContext();
+ cairo_t* cr_mask = cairo_mask.GetContext();
+ cairo_t* cr_outline = cairo_outline.GetContext();
float tint_color[4] = {0.074f, 0.074f, 0.074f, 0.80f};
- float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.15f};
+ float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.8f};
float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.20f};
float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
- float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.75f};
+ float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.15f};
float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
tint_dot_hl(cr_bg,
- GetBaseWidth(),
- GetBaseHeight(),
- GetBaseWidth() / 2.0f,
+ width,
+ height,
+ width / 2.0f,
0,
- Max<float>(GetBaseWidth() / 1.3f, GetBaseHeight() / 1.3f),
+ nux::Max<float>(width / 1.3f, height / 1.3f),
tint_color,
hl_color,
dot_color);
@@ -575,54 +480,43 @@ void Tooltip::UpdateTexture()
compute_full_outline_shadow
(
cr_outline,
- cairo_outline->GetSurface(),
- GetBaseWidth(),
- GetBaseHeight(),
- _anchor_width,
- _anchor_height,
+ cairo_outline.GetSurface(),
+ width,
+ height,
+ ANCHOR_WIDTH,
+ ANCHOR_HEIGHT,
-1,
- _corner_radius,
+ CORNER_RADIUS,
blur_coef,
shadow_color,
1.0f,
- _padding,
+ PADDING,
outline_color);
compute_full_mask(
cr_mask,
- cairo_mask->GetSurface(),
- GetBaseWidth(),
- GetBaseHeight(),
- _corner_radius, // radius,
+ cairo_mask.GetSurface(),
+ width,
+ height,
+ CORNER_RADIUS, // radius,
16, // shadow_radius,
- _anchor_width, // anchor_width,
- _anchor_height, // anchor_height,
+ ANCHOR_WIDTH, // anchor_width,
+ ANCHOR_HEIGHT, // anchor_height,
-1, // upper_size,
true, // negative,
false, // outline,
1.0, // line_width,
- _padding, // padding_size,
+ PADDING, // padding_size,
mask_color);
cairo_destroy(cr_bg);
cairo_destroy(cr_outline);
cairo_destroy(cr_mask);
- if (_texture_bg)
- _texture_bg->UnReference();
- _texture_bg = texture_from_cairo_graphics(*cairo_bg);
+ texture_bg_ = texture_from_cairo_graphics(cairo_bg);
+ texture_mask_ = texture_from_cairo_graphics(cairo_mask);
+ texture_outline_ = texture_from_cairo_graphics(cairo_outline);
- if (_texture_mask)
- _texture_mask->UnReference();
- _texture_mask = texture_from_cairo_graphics(*cairo_mask);
-
- if (_texture_outline)
- _texture_outline->UnReference();
- _texture_outline = texture_from_cairo_graphics(*cairo_outline);
-
- delete cairo_bg;
- delete cairo_mask;
- delete cairo_outline;
_cairo_text_has_changed = false;
}
@@ -640,13 +534,14 @@ void Tooltip::NotifyConfigurationChange(int width,
{
}
-void Tooltip::SetText(NString text)
+void Tooltip::SetText(nux::NString const& text)
{
if (_labelText == text)
return;
_labelText = text;
_tooltip_text->SetText(_labelText);
+
QueueRelayout();
}
diff --git a/plugins/unityshell/src/Tooltip.h b/plugins/unityshell/src/Tooltip.h
index c59002f2a..3c6433830 100644
--- a/plugins/unityshell/src/Tooltip.h
+++ b/plugins/unityshell/src/Tooltip.h
@@ -1,6 +1,6 @@
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
- * Copyright (C) 2010 Canonical Ltd
+ * Copyright (C) 2010-2012 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,64 +15,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Jay Taoko <jay.taoko@canonical.com>
- * Authored by: Mirco Müller <mirco.mueller@canonical.com
+ * Mirco Müller <mirco.mueller@canonical.com
+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
*/
#ifndef TOOLTIP_H
#define TOOLTIP_H
-
#include <Nux/Nux.h>
#include <Nux/BaseWindow.h>
-#include <NuxGraphics/GraphicsEngine.h>
-#include <Nux/TextureArea.h>
-#include <NuxImage/CairoGraphics.h>
-#include "StaticCairoText.h"
-
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
+#include <Nux/HLayout.h>
+#include <Nux/VLayout.h>
+#include "CairoBaseWindow.h"
+#include "StaticCairoText.h"
#include "Introspectable.h"
-#if defined(NUX_OS_LINUX)
-#include <X11/Xlib.h>
-#endif
-
-#define ANCHOR_WIDTH 10.0f
-#define ANCHOR_HEIGHT 18.0f
-#define HIGH_LIGHT_Y -30.0f
-#define HIGH_LIGHT_MIN_WIDTH 200.0f
-#define RADIUS 5.0f
-#define BLUR_INTENSITY 8
-#define LINE_WIDTH 1.0f
-#define PADDING_SIZE 1
-#define H_MARGIN 30
-#define V_MARGIN 4
-#define FONT_FACE "Ubuntu 13"
-
-class QuicklistMenuItem;
-
-namespace nux
+namespace unity
{
-class VLayout;
-class HLayout;
-class SpaceLayout;
-
-class Tooltip : public BaseWindow, public unity::debug::Introspectable
+class Tooltip : public CairoBaseWindow, public debug::Introspectable
{
- NUX_DECLARE_OBJECT_TYPE(Tooltip, BaseWindow);
+ NUX_DECLARE_OBJECT_TYPE(Tooltip, CairoBaseWindow);
public:
Tooltip();
- ~Tooltip();
-
- void Draw(GraphicsEngine& gfxContext,
- bool forceDraw);
-
- void DrawContent(GraphicsEngine& gfxContext,
- bool forceDraw);
+ void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
+ void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
- void SetText(NString text);
+ void SetText(nux::NString const& text);
void ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y);
@@ -80,10 +50,10 @@ public:
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
- virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
+ virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);
private:
- void RecvCairoTextChanged(StaticCairoText* cairo_text);
+ void RecvCairoTextChanged(nux::StaticCairoText* cairo_text);
void PreLayoutManagement();
@@ -97,23 +67,14 @@ private:
void NotifyConfigurationChange(int width,
int height);
- //nux::CairoGraphics* _cairo_graphics;
int _anchorX;
int _anchorY;
nux::NString _labelText;
- int _top_size; // size of the segment from point 13 to 14. See figure in _compute_full_mask_path.
- nux::StaticCairoText* _tooltip_text;
- nux::BaseTexture* _texture_bg;
- nux::BaseTexture* _texture_mask;
- nux::BaseTexture* _texture_outline;
+ nux::ObjectPtr<nux::StaticCairoText> _tooltip_text;
- float _anchor_width;
- float _anchor_height;
- float _corner_radius;
- float _padding;
nux::HLayout* _hlayout;
- VLayout* _vlayout;
+ nux::VLayout* _vlayout;
nux::SpaceLayout* _left_space; //!< Space from the left of the widget to the left of the text.
nux::SpaceLayout* _right_space; //!< Space from the right of the text to the right of the widget.
nux::SpaceLayout* _top_space; //!< Space from the left of the widget to the left of the text.
diff --git a/plugins/unityshell/src/unity-quicklist-accessible.cpp b/plugins/unityshell/src/unity-quicklist-accessible.cpp
index 1840f4acc..eaebd8bf4 100644
--- a/plugins/unityshell/src/unity-quicklist-accessible.cpp
+++ b/plugins/unityshell/src/unity-quicklist-accessible.cpp
@@ -78,6 +78,7 @@ struct _UnityQuicklistAccessiblePrivate
AtkObject* menu_accessible;
};
+using unity::QuicklistView;
static void
unity_quicklist_accessible_class_init(UnityQuicklistAccessibleClass* klass)
diff --git a/plugins/unityshell/src/unity-quicklist-menu-accessible.cpp b/plugins/unityshell/src/unity-quicklist-menu-accessible.cpp
index c15cee1e7..4865c8484 100644
--- a/plugins/unityshell/src/unity-quicklist-menu-accessible.cpp
+++ b/plugins/unityshell/src/unity-quicklist-menu-accessible.cpp
@@ -102,6 +102,8 @@ struct _UnityQuicklistMenuAccessiblePrivate
guint on_parent_activate_change_id;
};
+using unity::QuicklistView;
+using unity::QuicklistMenuItem;
static void
unity_quicklist_menu_accessible_class_init(UnityQuicklistMenuAccessibleClass* klass)
diff --git a/plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp b/plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp
index 16e0b217f..4d0258492 100644
--- a/plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp
+++ b/plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp
@@ -67,6 +67,9 @@ struct _UnityQuicklistMenuItemAccessiblePrivate
guint on_parent_change_id;
};
+using unity::QuicklistMenuItem;
+using unity::QuicklistMenuItemLabel;
+using unity::QuicklistMenuItemSeparator;
static void
unity_quicklist_menu_item_accessible_class_init(UnityQuicklistMenuItemAccessibleClass* klass)
diff --git a/plugins/unityshell/src/unitya11ytests.cpp b/plugins/unityshell/src/unitya11ytests.cpp
index 70bf6bb7b..84623f4d7 100644
--- a/plugins/unityshell/src/unitya11ytests.cpp
+++ b/plugins/unityshell/src/unitya11ytests.cpp
@@ -54,12 +54,12 @@ using unity::launcher::SimpleLauncherIcon;
static gboolean
a11y_unit_test_destroy_management(void)
{
- QuicklistView* quicklist = NULL;
+ unity::QuicklistView* quicklist = NULL;
AtkObject* accessible = NULL;
nux::Object* base_object = NULL;
AtkStateSet* state_set = NULL;
- quicklist = new QuicklistView();
+ quicklist = new unity::QuicklistView();
quicklist->SinkReference();
accessible = unity_a11y_get_accessible(quicklist);
@@ -108,7 +108,7 @@ a11y_unit_test_destroy_management(void)
static gboolean
a11y_unit_test_hash_table_destroy_management(void)
{
- QuicklistView* quicklist = NULL;
+ unity::QuicklistView* quicklist = NULL;
nux::Layout* layout = NULL;
AtkObject* accessible = NULL;
guint prev_hash_size = 0;
@@ -157,7 +157,7 @@ a11y_unit_test_hash_table_destroy_management(void)
prev_hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());
- quicklist = new QuicklistView();
+ quicklist = new unity::QuicklistView();
quicklist->SinkReference();
accessible = unity_a11y_get_accessible(quicklist);
diff --git a/standalone-clients/CMakeLists.txt b/standalone-clients/CMakeLists.txt
index 3345dc4e3..f8eaf8bcc 100644
--- a/standalone-clients/CMakeLists.txt
+++ b/standalone-clients/CMakeLists.txt
@@ -197,6 +197,7 @@ add_dependencies (switcher unity-core-${UNITY_API_VERSION})
add_executable (launcher
TestLauncher.cpp
+ ${UNITY_SRC}/CairoBaseWindow.cpp
${UNITY_SRC}/AbstractLauncherIcon.h
${UNITY_SRC}/AbstractIconRenderer.h
${UNITY_SRC}/LauncherIcon.cpp
@@ -298,22 +299,15 @@ add_executable (quicklist
nux_test_framework.h
nux_automated_test_framework.cpp
nux_automated_test_framework.h
+ ${UNITY_SRC}/CairoBaseWindow.cpp
${UNITY_SRC}/Introspectable.cpp
- ${UNITY_SRC}/Introspectable.h
${UNITY_SRC}/QuicklistMenuItem.cpp
- ${UNITY_SRC}/QuicklistMenuItem.h
${UNITY_SRC}/QuicklistMenuItemCheckmark.cpp
- ${UNITY_SRC}/QuicklistMenuItemCheckmark.h
${UNITY_SRC}/QuicklistMenuItemLabel.cpp
- ${UNITY_SRC}/QuicklistMenuItemLabel.h
${UNITY_SRC}/QuicklistMenuItemRadio.cpp
- ${UNITY_SRC}/QuicklistMenuItemRadio.h
${UNITY_SRC}/QuicklistMenuItemSeparator.cpp
- ${UNITY_SRC}/QuicklistMenuItemSeparator.h
${UNITY_SRC}/QuicklistView.cpp
- ${UNITY_SRC}/QuicklistView.h
${UNITY_SRC}/ubus-server.cpp
- ${UNITY_SRC}/ubus-server.h
)
add_dependencies(quicklist unity-core-${UNITY_API_VERSION})
@@ -321,22 +315,15 @@ add_executable (quicklist-visuals
ui/TestQuicklistVisuals.cpp
ui/EventFaker.cpp
ui/EventFaker.h
+ ${UNITY_SRC}/CairoBaseWindow.cpp
${UNITY_SRC}/Introspectable.cpp
- ${UNITY_SRC}/Introspectable.h
${UNITY_SRC}/QuicklistMenuItem.cpp
- ${UNITY_SRC}/QuicklistMenuItem.h
${UNITY_SRC}/QuicklistMenuItemCheckmark.cpp
- ${UNITY_SRC}/QuicklistMenuItemCheckmark.h
${UNITY_SRC}/QuicklistMenuItemLabel.cpp
- ${UNITY_SRC}/QuicklistMenuItemLabel.h
${UNITY_SRC}/QuicklistMenuItemRadio.cpp
- ${UNITY_SRC}/QuicklistMenuItemRadio.h
${UNITY_SRC}/QuicklistMenuItemSeparator.cpp
- ${UNITY_SRC}/QuicklistMenuItemSeparator.h
${UNITY_SRC}/QuicklistView.cpp
- ${UNITY_SRC}/QuicklistView.h
${UNITY_SRC}/ubus-server.cpp
- ${UNITY_SRC}/ubus-server.h
)
add_dependencies(quicklist-visuals unity-core-${UNITY_API_VERSION})
@@ -524,7 +511,17 @@ add_executable (test-shortcut
${UNITY_SRC}/UBusMessages.h
${UNITY_SRC}/ubus-server.cpp
${UNITY_SRC}/ubus-server.h
- )
+ )
+
+add_executable (tooltip
+ ui/TestTooltip.cpp
+ ${UNITY_SRC}/Introspectable.cpp
+ ${UNITY_SRC}/CairoBaseWindow.cpp
+ ${UNITY_SRC}/StaticCairoText.cpp
+ ${UNITY_SRC}/Tooltip.cpp
+ ${UNITY_SRC}/ubus-server.cpp
+ )
+add_dependencies(quicklist unity-core-${UNITY_API_VERSION})
find_package (OpenGL)
include_directories (${OPENGL_gl_INCDIRS})
@@ -541,7 +538,7 @@ target_link_libraries (screen-effect-fbo glfuncloader ${OPENGL_gl_LIBRARY})
add_dependencies (screen-effect-fbo ${UNITY_API_VERSION})
# Custom target to make all the other targets here, add your test to this list
-add_custom_target(standalone-clients DEPENDS dash panel launcher switcher keyutil quicklist quicklist-visuals filters filter-bar preview-applicaiton preview-generic preview-music result-view dash-style bg-hash shortcut-view)
+add_custom_target(standalone-clients DEPENDS dash panel launcher switcher keyutil quicklist quicklist-visuals filters filter-bar preview-applicaiton preview-generic preview-music result-view dash-style bg-hash shortcut-view tooltip)
diff --git a/standalone-clients/ui/TestQuicklist.cpp b/standalone-clients/ui/TestQuicklist.cpp
index 75ac309fc..cbcff0a07 100644
--- a/standalone-clients/ui/TestQuicklist.cpp
+++ b/standalone-clients/ui/TestQuicklist.cpp
@@ -37,6 +37,8 @@
#define WIN_WIDTH 400
#define WIN_HEIGHT 400
+using namespace unity;
+
class TestQuicklist: public NuxTestFramework
{
public:
diff --git a/standalone-clients/ui/TestQuicklistVisuals.cpp b/standalone-clients/ui/TestQuicklistVisuals.cpp
index 107412668..3715c28d3 100644
--- a/standalone-clients/ui/TestQuicklistVisuals.cpp
+++ b/standalone-clients/ui/TestQuicklistVisuals.cpp
@@ -35,6 +35,8 @@
#define WIN_WIDTH 1024
#define WIN_HEIGHT 600
+using namespace unity;
+
QuicklistView* gQuicklists[3] = {NULL, NULL, NULL};
QuicklistMenuItemRadio*
diff --git a/standalone-clients/ui/TestTooltip.cpp b/standalone-clients/ui/TestTooltip.cpp
new file mode 100644
index 000000000..9bc2153e9
--- /dev/null
+++ b/standalone-clients/ui/TestTooltip.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "Nux/Nux.h"
+#include "Nux/VLayout.h"
+#include "Nux/WindowThread.h"
+
+#include "Tooltip.h"
+
+#define WIN_WIDTH 200
+#define WIN_HEIGHT 75
+
+using namespace unity;
+
+void
+ThreadWidgetInit (nux::NThread* thread,
+ void* initData)
+{
+ Tooltip* ttip = new Tooltip();
+ ttip->SetText("Unity Tooltip");
+ ttip->ShowTooltipWithTipAt(15, 30);
+
+ nux::ColorLayer background(nux::Color (0x772953));
+ static_cast<nux::WindowThread*>(thread)->SetWindowBackgroundPaintLayer(&background);
+}
+
+int
+main (int argc, char **argv)
+{
+ nux::WindowThread* wt = NULL;
+
+ gtk_init(&argc, &argv);
+ nux::NuxInitialize(0);
+
+ wt = nux::CreateGUIThread(TEXT ("Unity visual Tooltip test"),
+ WIN_WIDTH,
+ WIN_HEIGHT,
+ 0,
+ &ThreadWidgetInit,
+ NULL);
+
+ wt->Run(NULL);
+ delete wt;
+
+ return 0;
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index a849a1023..5f8dded5c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -50,24 +50,16 @@ add_executable (test-unit
unit/TestMain.cpp
unit/TestUBus.cpp
unit/TestStaticCairoText.cpp
- ${UNITY_SRC}/ubus-server.cpp
- ${UNITY_SRC}/ubus-server.h
+ ${UNITY_SRC}/CairoBaseWindow.cpp
${UNITY_SRC}/Introspectable.cpp
${UNITY_SRC}/QuicklistMenuItem.cpp
- ${UNITY_SRC}/QuicklistMenuItem.h
${UNITY_SRC}/QuicklistMenuItemCheckmark.cpp
- ${UNITY_SRC}/QuicklistMenuItemCheckmark.h
${UNITY_SRC}/QuicklistMenuItemLabel.cpp
- ${UNITY_SRC}/QuicklistMenuItemLabel.h
${UNITY_SRC}/QuicklistMenuItemRadio.cpp
- ${UNITY_SRC}/QuicklistMenuItemRadio.h
${UNITY_SRC}/QuicklistMenuItemSeparator.cpp
- ${UNITY_SRC}/QuicklistMenuItemSeparator.h
${UNITY_SRC}/QuicklistView.cpp
- ${UNITY_SRC}/QuicklistView.h
${UNITY_SRC}/StaticCairoText.cpp
- ${UNITY_SRC}/StaticCairoText.h
- ${UNITY_SRC}/
+ ${UNITY_SRC}/ubus-server.cpp
)
add_dependencies (test-unit unity-core-${UNITY_API_VERSION})
add_subdirectory (test-input-remover)
diff --git a/tests/unit/TestQuicklistMenuitems.cpp b/tests/unit/TestQuicklistMenuitems.cpp
index 716e0dc03..4f9132df8 100644
--- a/tests/unit/TestQuicklistMenuitems.cpp
+++ b/tests/unit/TestQuicklistMenuitems.cpp
@@ -36,6 +36,13 @@
#include "QuicklistView.h"
#include "TestThreadHelper.h"
+using unity::QuicklistView;
+using unity::QuicklistMenuItem;
+using unity::QuicklistMenuItemCheckmark;
+using unity::QuicklistMenuItemLabel;
+using unity::QuicklistMenuItemRadio;
+using unity::QuicklistMenuItemSeparator;
+
static void TestMenuItemCheckmark(void);
static void TestMenuItemLabel(void);
static void TestMenuItemRadio(void);
@@ -232,10 +239,10 @@ TestQuicklistMenuItem()
quicklist->TestMenuItems(root);
g_assert_cmpint(quicklist->GetNumItems(), == , 4);
- g_assert_cmpint(quicklist->GetNthType(0), == , MENUITEM_TYPE_LABEL);
- g_assert_cmpint(quicklist->GetNthType(1), == , MENUITEM_TYPE_SEPARATOR);
- g_assert_cmpint(quicklist->GetNthType(2), == , MENUITEM_TYPE_LABEL);
- g_assert_cmpint(quicklist->GetNthType(3), == , MENUITEM_TYPE_CHECK);
+ g_assert_cmpint(quicklist->GetNthType(0), == , unity::MENUITEM_TYPE_LABEL);
+ g_assert_cmpint(quicklist->GetNthType(1), == , unity::MENUITEM_TYPE_SEPARATOR);
+ g_assert_cmpint(quicklist->GetNthType(2), == , unity::MENUITEM_TYPE_LABEL);
+ g_assert_cmpint(quicklist->GetNthType(3), == , unity::MENUITEM_TYPE_CHECK);
g_assert_cmpstr(quicklist->GetNthItems(0)->GetLabel(), == , "label 0");
g_assert_cmpstr(quicklist->GetNthItems(2)->GetLabel(), == , "label 1");