Light current prefix
authorEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 17:53:35 +0000 (17:53 +0000)
committerEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 17:53:35 +0000 (17:53 +0000)
gtkfisheyelist/gtkfisheyelistview.vala

index 9599dbedf82c001ecf46a7e5ba9d9e0a03a277d1..c07b1e110094232f5f400018787bf52956ad4b7f 100644 (file)
@@ -79,8 +79,10 @@ public class FisheyeListView : Gtk.DrawingArea
 
        // Prefix information
        protected List<PrefixInfo> prefixes;
+       protected Pango.Layout prefix_layout;
 
        protected int cur_el;
+       protected weak PrefixInfo cur_pfx;
 
        // Layout information
        protected int focus_first;
@@ -127,12 +129,14 @@ public class FisheyeListView : Gtk.DrawingArea
 
                renderers = new Gtk.CellRendererText[steps];
                renderer_sizes = new int[steps];
+               prefix_layout = null;
 
                // Defaults for properties
                focus_size = 10;
                label_column = 0;
 
                cur_el = 0;
+               cur_pfx = null;
                focus_locked = false;
 
                add_events(Gdk.EventMask.POINTER_MOTION_MASK
@@ -215,6 +219,15 @@ public class FisheyeListView : Gtk.DrawingArea
                                                break;
                                        }
 
+                       if (prefixes != null)
+                       {
+                               cur_pfx = prefixes.data;
+                               for (weak List<PrefixInfo> i = prefixes; i != null && y > i.data.layout_pos; i = i.next)
+                                       cur_pfx = i.data;
+                       } else {
+                               cur_pfx = null;
+                       }
+
                        if (!focus_locked && old_cur_el != cur_el)
                                focus_layout_needed = true;
                } else {
@@ -481,14 +494,14 @@ public class FisheyeListView : Gtk.DrawingArea
                }
 
                // Draw prefix labels
-               Pango.Layout layout = create_pango_layout(null);
+               prefix_layout = create_pango_layout(null);
                Pango.Rectangle lr;
-               layout.get_extents(null, out lr);
+               prefix_layout.get_extents(null, out lr);
                int label_height = lr.height / Pango.SCALE;
-               layout.set_alignment(Pango.Alignment.RIGHT);
-               layout.set_width(allocation.width*Pango.SCALE/3);
-               layout.set_height(0);
-               layout.set_ellipsize(Pango.EllipsizeMode.END);
+               prefix_layout.set_alignment(Pango.Alignment.RIGHT);
+               prefix_layout.set_width(allocation.width*Pango.SCALE/3);
+               prefix_layout.set_height(0);
+               prefix_layout.set_ellipsize(Pango.EllipsizeMode.END);
 
                int last_covered = 0;
 
@@ -496,8 +509,8 @@ public class FisheyeListView : Gtk.DrawingArea
                {
                        if (i.data.layout_pos < last_covered)
                                i.data.layout_pos = last_covered;
-                       layout.set_text(i.data.prefix, int.max(10, (int)i.data.pfx_len));
-                       Gtk.paint_layout(style, (Gdk.Window*)drawable, Gtk.StateType.INSENSITIVE, true, null, this, null, allocation.width*2/3, i.data.layout_pos, layout);
+                       prefix_layout.set_text(i.data.prefix, (int)i.data.pfx_len);
+                       Gtk.paint_layout(style, (Gdk.Window*)drawable, Gtk.StateType.INSENSITIVE, true, null, this, null, allocation.width*2/3, i.data.layout_pos, prefix_layout);
                        last_covered = i.data.layout_pos + label_height;
                }
        }
@@ -525,6 +538,13 @@ public class FisheyeListView : Gtk.DrawingArea
 
                if (is_fisheye)
                {
+                       // Paint current prefix
+                       if (cur_pfx != null)
+                       {
+                               prefix_layout.set_text(cur_pfx.prefix, (int)cur_pfx.pfx_len);
+                               Gtk.paint_layout(style, (Gdk.Window*)drawable, Gtk.StateType.NORMAL, true, null, this, null, allocation.width*2/3, cur_pfx.layout_pos, prefix_layout);
+                       }
+
                        // Focus lock area
                        drawable.draw_rectangle(style.bg_gc[Gtk.StateType.ACTIVE], true,
                                0, focus_area_start + focus_info[0].y, allocation.width/3, focus_info[focus_end - focus_first].y);