[hyena/canvas] [Hyena.Gui] Fix TextBlock width issue



commit 09d17e85aa99e594df9a63b94a546ed30d8d8ccc
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Oct 26 17:45:19 2010 -0500

    [Hyena.Gui] Fix TextBlock width issue

 Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
index db72054..2ce97c3 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
@@ -74,7 +74,7 @@ namespace Hyena.Gui.Canvas
             int text_w, text_h;
 
             TextWrap wrap = TextWrap;
-            layout.Width = wrap == TextWrap.None ? -1 : (int)(Pango.Scale.PangoScale * available.Width);
+            layout.Width = wrap == TextWrap.None ? -1 : (int)(Pango.Scale.PangoScale * (available.Width - Margin.X));
             layout.Wrap = GetPangoWrapMode (wrap);
             layout.FontDescription.Weight = GetPangoFontWeight (FontWeight);
             layout.SingleParagraphMode = wrap == TextWrap.None;
@@ -136,15 +136,16 @@ namespace Hyena.Gui.Canvas
                 return;
             }
 
-            int layout_width = TextWrap == TextWrap.None
-                ? -1
-                : (int)(Pango.Scale.PangoScale * ContentAllocation.Width);
+            //int layout_width = TextWrap == TextWrap.None ? -1 : (int)(Pango.Scale.PangoScale * RenderSize.Width);
+            int layout_width = (int)(Pango.Scale.PangoScale * RenderSize.Width);
             if (layout.Width != layout_width) {
                 layout.Width = layout_width;
             }
 
             int text_width, text_height;
-            layout.SetHeight ((int)(Pango.Scale.PangoScale * RenderSize.Height));
+            if (TextWrap != TextWrap.None) {
+                layout.SetHeight ((int)(Pango.Scale.PangoScale * RenderSize.Height));
+            }
             layout.GetPixelSize (out text_width, out text_height);
 
             if (layout.IsEllipsized || text_width > RenderSize.Width || text_height > RenderSize.Height) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]