[hyena] [Hyena.Gui] Lazy create ListView's PangoLayout (bgo#636828)



commit fb142927329c2d784b10d9b22693a30b0ca9b555
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Dec 8 19:04:40 2010 -0600

    [Hyena.Gui] Lazy create ListView's PangoLayout (bgo#636828)
    
    Previously it wasn't created until the Expose event was called, but
    that's too late for TextBlock's which are getting measured/arranaged as
    soon as the ListView has its SizeAllocated.

 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 08cd773..78bf70c 100644
--- a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -48,7 +48,16 @@ namespace Hyena.Data.Gui
         private Pango.Layout pango_layout;
 
         public override Pango.Layout PangoLayout {
-            get { return cell_context.Layout; }
+            get {
+                if (pango_layout == null && GdkWindow != null && IsRealized) {
+                    using (var cr = Gdk.CairoHelper.Create (GdkWindow)) {
+                        pango_layout = CairoExtensions.CreateLayout (this, cr);
+                        cell_context.FontDescription = pango_layout.FontDescription;
+                        cell_context.Layout = pango_layout;
+                    }
+                }
+                return pango_layout;
+            }
         }
 
         public override Pango.FontDescription FontDescription {
@@ -97,6 +106,8 @@ namespace Hyena.Data.Gui
                 cell_context.FontDescription.Dispose ();
                 pango_layout.Dispose ();
                 pango_layout = null;
+                cell_context.Layout = null;
+                cell_context.FontDescription = null;
             }
 
             cell_context = new CellContext ();
@@ -131,12 +142,7 @@ namespace Hyena.Data.Gui
 
             cairo_context = CairoHelper.Create (evnt.Window);
 
-            if (pango_layout == null) {
-                pango_layout = CairoExtensions.CreateLayout (this, cairo_context);
-                cell_context.FontDescription = pango_layout.FontDescription;
-                cell_context.Layout = pango_layout;
-            }
-
+            cell_context.Layout = PangoLayout;
             cell_context.Context = cairo_context;
 
             // FIXME: legacy list foo



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