public class FisheyeList : Gtk.DrawingArea
{
+ protected Gtk.TreeModel model;
protected Gdk.Pixmap backing_store;
private string[] list;
// Number of items shown before and after the focus element
protected int focus_first;
protected int focus_end;
- protected int focus_size;
protected int[] focus_starts;
protected bool focus_locked;
protected int focus_centre;
+ protected bool focus_layout_needed;
+
+ protected int _focus_size;
+ public int focus_size {
+ get { return _focus_size; }
+ set {
+ _focus_size = value;
+ focus_starts = new int[value+1];
+ focus_layout_needed = true;
+ }
+ }
public FisheyeList()
{
+ model = null;
backing_store = null;
list = new string[300];
cur_el = 0;
focus_centre = 0;
focus_size = 20;
- focus_starts = new int[focus_size + 1];
focus_locked = false;
distortion_factor = 30;
- focus_layout();
add_events(Gdk.EventMask.POINTER_MOTION_MASK
| Gdk.EventMask.BUTTON_PRESS_MASK
| Gdk.EventMask.BUTTON_RELEASE_MASK);
}
+ public unowned Gtk.TreeModel get_model() { return model; }
+ public void set_model (Gtk.TreeModel? model)
+ {
+ this.model = model;
+ }
+
/* Mouse button got pressed over widget */
public override bool button_press_event(Gdk.EventButton event)
{
int x = (int)event.x;
int y = (int)event.y;
- focus_locked = x < allocation.width/2 && y >= focus_starts[0] && y < focus_starts[focus_end - focus_first];
+ focus_locked = !focus_layout_needed && x < allocation.width/2 && y >= focus_starts[0] && y < focus_starts[focus_end - focus_first];
if (focus_locked)
{
} else {
cur_el = y * list.length / allocation.height;
if (old_cur_el != cur_el)
- focus_layout();
+ focus_layout_needed = true;
}
//stderr.printf("MOTION %f %f CE %d\n", event.x, event.y, cur_el);
public override bool configure_event (Gdk.EventConfigure event)
{
backing_store = new Gdk.Pixmap(window, allocation.width, allocation.height, -1);
- focus_layout();
+ focus_layout_needed = true;
queue_draw();
return false;
}
focus_starts[idx - focus_first] = y0;
focus_starts[idx - focus_first + 1] = y1;
}
+ focus_layout_needed = false;
}
protected void draw(Gdk.Drawable drawable)
{
+ if (focus_layout_needed)
+ focus_layout();
+
Gtk.Style style = get_style();
// Background