diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2014-04-02 11:03:08 +0000 |
|---|---|---|
| committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-04-02 11:03:08 +0000 |
| commit | 51edb4317107a74a6edc83f76377b881e9e13bd9 (patch) | |
| tree | 66592b86b1efade231b3a0ff509b12b09cb04d23 /unity-shared | |
| parent | beb3497fabb724c203aaf5257a835b69761c1709 (diff) | |
| parent | 18b2fb6c9342853fe1efc4ce9a90a0db1ae1528a (diff) | |
Panel, Decorations: draw the background under the text glyphs before the text itself Fixes: 723167
(bzr r3750)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/DecorationStyle.cpp | 33 | ||||
| -rw-r--r-- | unity-shared/DecorationStyle.h | 7 | ||||
| -rw-r--r-- | unity-shared/UnitySettings.cpp | 2 |
3 files changed, 31 insertions, 11 deletions
diff --git a/unity-shared/DecorationStyle.cpp b/unity-shared/DecorationStyle.cpp index 6904796eb..6d3dbbec2 100644 --- a/unity-shared/DecorationStyle.cpp +++ b/unity-shared/DecorationStyle.cpp @@ -499,7 +499,25 @@ struct Style::Impl return extents; } - void DrawTitle(std::string const& text, WidgetState ws, cairo_t* cr, double w, double h) + void DrawTextBackground(GtkStyleContext* ctx, cairo_t* cr, glib::Object<PangoLayout> const& layout, nux::Rect const& bg_geo) + { + if (bg_geo.IsNull()) + return; + + // We need to render the background under the text glyphs, or the edge + // of the text won't be correctly anti-aliased. See bug #723167 + + cairo_push_group(cr); + gtk_render_layout(ctx, cr, 0, 0, layout); + std::shared_ptr<cairo_pattern_t> pat(cairo_pop_group(cr), cairo_pattern_destroy); + + cairo_push_group(cr); + gtk_render_background(ctx, cr, bg_geo.x, bg_geo.y, bg_geo.width, bg_geo.height); + cairo_pop_group_to_source(cr); + cairo_mask(cr, pat.get()); + } + + void DrawTitle(std::string const& text, WidgetState ws, cairo_t* cr, double w, double h, nux::Rect const& bg_geo) { gtk_style_context_save(ctx_); AddContextClasses(Side::TOP, ws); @@ -516,6 +534,7 @@ struct Style::Impl double fading_width = std::min<double>(title_fade_, out_pixels); cairo_push_group(cr); + DrawTextBackground(ctx_, cr, layout, bg_geo); gtk_render_layout(ctx_, cr, 0, 0, layout); cairo_pop_group_to_source(cr); @@ -529,6 +548,7 @@ struct Style::Impl else { pango_layout_set_width(layout, (w >= 0) ? w * PANGO_SCALE : -1); + DrawTextBackground(ctx_, cr, layout, bg_geo); gtk_render_layout(ctx_, cr, 0, 0, layout); } @@ -554,7 +574,7 @@ struct Style::Impl gtk_style_context_restore(ctx_); } - void DrawMenuItemEntry(std::string const& text, WidgetState ws, cairo_t* cr, double w, double h) + void DrawMenuItemEntry(std::string const& text, WidgetState ws, cairo_t* cr, double w, double h, nux::Rect const& bg_geo) { gtk_style_context_save(ctx_); AddContextClassesForMenuItem(ws); @@ -573,6 +593,7 @@ struct Style::Impl pango_layout_set_width(layout, (w >= 0) ? w * PANGO_SCALE : -1); pango_layout_set_height(layout, (h >= 0) ? h * PANGO_SCALE : -1); + DrawTextBackground(ctx_, cr, layout, bg_geo); gtk_render_layout(ctx_, cr, 0, 0, layout); gtk_style_context_restore(ctx_); @@ -659,9 +680,9 @@ void Style::DrawSide(Side s, WidgetState ws, cairo_t* cr, double w, double h) impl_->DrawSide(s, ws, cr, w, h); } -void Style::DrawTitle(std::string const& t, WidgetState ws, cairo_t* cr, double w, double h) +void Style::DrawTitle(std::string const& t, WidgetState ws, cairo_t* cr, double w, double h, nux::Rect const& bg_geo) { - impl_->DrawTitle(t, ws, cr, w, h); + impl_->DrawTitle(t, ws, cr, w, h, bg_geo); } void Style::DrawMenuItem(WidgetState ws, cairo_t* cr, double w, double h) @@ -669,9 +690,9 @@ void Style::DrawMenuItem(WidgetState ws, cairo_t* cr, double w, double h) impl_->DrawMenuItem(ws, cr, w, h); } -void Style::DrawMenuItemEntry(std::string const& t, WidgetState ws, cairo_t* cr, double w, double h) +void Style::DrawMenuItemEntry(std::string const& t, WidgetState ws, cairo_t* cr, double w, double h, nux::Rect const& bg_geo) { - impl_->DrawMenuItemEntry(t, ws, cr, w, h); + impl_->DrawMenuItemEntry(t, ws, cr, w, h, bg_geo); } void Style::DrawMenuItemIcon(std::string const& i, WidgetState ws, cairo_t* cr, int s) diff --git a/unity-shared/DecorationStyle.h b/unity-shared/DecorationStyle.h index 00c8b13f1..e71beb2f2 100644 --- a/unity-shared/DecorationStyle.h +++ b/unity-shared/DecorationStyle.h @@ -21,8 +21,7 @@ #define UNITY_DECORATION_STYLE #include <NuxCore/Property.h> -#include <NuxCore/Point.h> -#include <NuxCore/Size.h> +#include <NuxCore/Rect.h> #include <cairo/cairo.h> namespace unity @@ -130,9 +129,9 @@ public: int DoubleClickMaxTimeDelta() const; void DrawSide(Side, WidgetState, cairo_t*, double width, double height); - void DrawTitle(std::string const&, WidgetState, cairo_t*, double width, double height); + void DrawTitle(std::string const&, WidgetState, cairo_t*, double width, double height, nux::Rect const& bg_geo = nux::Rect()); void DrawMenuItem(WidgetState, cairo_t*, double width, double height); - void DrawMenuItemEntry(std::string const&, WidgetState, cairo_t*, double width, double height); + void DrawMenuItemEntry(std::string const&, WidgetState, cairo_t*, double width, double height, nux::Rect const& bg_geo = nux::Rect()); void DrawMenuItemIcon(std::string const&, WidgetState, cairo_t*, int size); private: diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp index 9ab201a5e..9b91786cc 100644 --- a/unity-shared/UnitySettings.cpp +++ b/unity-shared/UnitySettings.cpp @@ -262,7 +262,7 @@ public: double ui_scale = 1.0f; int value; - if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value)) + if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value) && value > 0) ui_scale = static_cast<double>(value)/8.0f; if (app_target_monitor.Str() == monitor_name) |
