[hyena/gtk3] TextBlock: Fix text color when selected
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena/gtk3] TextBlock: Fix text color when selected
- Date: Mon, 25 Jul 2011 20:37:57 +0000 (UTC)
commit 24a68185d2d45e607598b4e8db64a6cfd146712c
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Mon Jul 25 22:14:12 2011 +0200
TextBlock: Fix text color when selected
Bring back the color selection that was dropped when updating to the new
theming API. Also remove a useless StyleContext.RenderLayout, as it's
already done by the PangoCairoHelper.ShowLayout call.
Hyena.Gui/Hyena.Gui.Canvas/Brush.cs | 4 ++++
Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs | 15 ++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/Brush.cs b/Hyena.Gui/Hyena.Gui.Canvas/Brush.cs
index 28df7b6..3b453c1 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/Brush.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/Brush.cs
@@ -53,6 +53,10 @@ namespace Hyena.Gui.Canvas
{
}
+ public Brush (Gdk.RGBA rgba) : this (CairoExtensions.GdkRGBAToCairoColor (rgba))
+ {
+ }
+
public Brush (Cairo.Color color)
{
this.color = color;
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
index 9024767..911aad9 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
@@ -179,7 +179,17 @@ namespace Hyena.Gui.Canvas
var cr = context.Context;
context.Theme.Widget.StyleContext.Save ();
- context.Theme.Widget.StyleContext.AddClass ("entry");
+ if (context.TextAsForeground) {
+ context.Theme.Widget.StyleContext.AddClass ("button");
+ } else {
+ context.Theme.Widget.StyleContext.AddClass ("entry");
+ }
+ Foreground = new Brush (context.Theme.Widget.StyleContext.GetColor (context.State));
+
+ Brush foreground = Foreground;
+ if (!foreground.IsValid) {
+ return;
+ }
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.Clip ();
@@ -190,6 +200,7 @@ namespace Hyena.Gui.Canvas
cr.PushGroup ();
}
+ Foreground.Apply (cr);
UpdateLayout (GetText (), RenderSize.Width, RenderSize.Height, true);
if (Hyena.PlatformDetection.IsWindows) {
// FIXME windows; working around some unknown issue with ShowLayout; bgo#644311
@@ -200,8 +211,6 @@ namespace Hyena.Gui.Canvas
PangoCairoHelper.ShowLayout (cr, layout);
}
- context.Theme.Widget.StyleContext.RenderLayout (cr, text_alloc.X, text_alloc.Y, layout);
-
TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;
if (fade) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]