pango_cache[i] = null;
// Defaults for properties
- focus_size = 20;
+ focus_size = 21;
label_column = 0;
cur_el = 0;
focus_end = 0;
focus_starts[0] = 0;
} else {
- focus_first = cur_el > _focus_size/2 ? cur_el-_focus_size/2 : 0;
- focus_end = focus_first + _focus_size;
- if (focus_end >= label_cache.length) focus_end = label_cache.length;
+ if (_focus_size >= label_cache.length)
+ {
+ focus_first = 0;
+ focus_end = label_cache.length;
+ } else {
+ focus_first = cur_el -_focus_size/2;
+ if (focus_first < 0) focus_first = 0;
+
+ focus_end = focus_first + _focus_size;
+ if (focus_end > label_cache.length)
+ {
+ focus_end = label_cache.length;
+ focus_first = focus_end - _focus_size;
+ }
+ }
// Compute starting positions for all items in focus
for (int idx = focus_first; idx <= focus_end; ++idx)
- {
focus_starts[idx - focus_first] = el_y(idx);
- }
}
focus_layout_needed = false;
}
// Focus lock area
drawable.draw_rectangle(style.bg_gc[Gtk.StateType.ACTIVE], true,
- 0, focus_starts[0], allocation.width/2, focus_starts[focus_end - focus_first]);
+ 0, focus_starts[0], allocation.width/2, focus_starts[focus_end - focus_first]-focus_starts[0]);
// Focus movement area
drawable.draw_rectangle(style.bg_gc[Gtk.StateType.INSENSITIVE], true,
allocation.width/2, 0, allocation.width, allocation.height);
- // Create a Cairo context
- //var context = Gdk.cairo_create (drawable);
-
// Paint items around focus
- //context.select_font_face(style.font_desc.get_family(), Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL);
- for (int idx = focus_first; idx < focus_end; ++idx)
+ for (int idx = 0; idx < focus_end-focus_first; ++idx)
{
- int y0 = focus_starts[idx - focus_first];
- int y1 = focus_starts[idx - focus_first + 1];
+ int y0 = focus_starts[idx];
+ int y1 = focus_starts[idx + 1];
Gtk.StateType itemState = Gtk.StateType.NORMAL;
- if (idx == cur_el)
+ if (idx + focus_first == cur_el)
{
itemState = Gtk.StateType.SELECTED;
drawable.draw_rectangle(style.bg_gc[itemState], true,
}
- // TODO: cache pango contexts instead of fontdescs
int size = (y1-y0)*80/100;
if (size <= 0) size = 1;
if (size >= pango_cache.length) size = pango_cache.length - 1;
pc.set_font_description(fd);
pango_cache[size] = new Pango.Layout(pc);
}
- pango_cache[size].set_text(label_cache[idx], -1);
+ pango_cache[size].set_text(label_cache[idx + focus_first], -1);
var layout = pango_cache[size];
- //stderr.printf("AZAZA %p\n", layout.get_attributes());
- //var attrlist = layout.get_attributes().copy();
- //stderr.printf("AL %p\n", attrlist);
- //var attrlist = new Pango.AttrList();
- //stderr.printf("SIZE %d\n", y1-y0);
- //attrlist.insert(new Pango.AttrSize(y1-y0));
- //var attrlist = layout.get_attributes();
- //attrlist.change(new Pango.AttrSize(y1-y0));
- //layout.set_attributes(attrlist);
- //layout.set_height(y1-y0);
- //int w, h;
- //layout.get_pixel_size(out w, out h);
Gdk.draw_layout(drawable, style.fg_gc[itemState], 0, y0, layout);
+
+ //Gdk.draw_line(drawable, style.fg_gc[itemState], 0, y0, allocation.width, y0);
}
}