More int arithmetic
authorEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 22:42:50 +0000 (22:42 +0000)
committerEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 22:42:50 +0000 (22:42 +0000)
src/fisheye.vala

index 2eb6bd4f7166f10245c0377eca8b3f12764d6ad5..fd0e1c5c831f0e6d8b098cafca62cc9e6ba8037e 100644 (file)
@@ -34,7 +34,7 @@ public class FisheyeList : Gtk.DrawingArea
        protected int focus_size;
        protected int[] focus_starts;
        protected bool focus_locked;
        protected int focus_size;
        protected int[] focus_starts;
        protected bool focus_locked;
-       protected double focus_centre;
+       protected int focus_centre;
 
        public FisheyeList()
        {
 
        public FisheyeList()
        {
@@ -144,7 +144,7 @@ public class FisheyeList : Gtk.DrawingArea
        protected void focus_layout()
        {
                // Anchor point
        protected void focus_layout()
        {
                // Anchor point
-               focus_centre = (double)cur_el*allocation.height/list.length;
+               focus_centre = cur_el*allocation.height/list.length;
 
                focus_first = cur_el > focus_size/2 ? cur_el-focus_size/2 : 0;
                focus_end = focus_first + focus_size;
 
                focus_first = cur_el > focus_size/2 ? cur_el-focus_size/2 : 0;
                focus_end = focus_first + focus_size;
@@ -167,17 +167,6 @@ public class FisheyeList : Gtk.DrawingArea
        protected void draw(Gdk.Drawable drawable)
        {
                 Gtk.Style style = get_style();
        protected void draw(Gdk.Drawable drawable)
        {
                 Gtk.Style style = get_style();
-       /*
-       public enum StateType {
-               NORMAL,
-               ACTIVE,
-               PRELIGHT,
-               SELECTED,
-               INSENSITIVE
-       }
-               style.bg[Gtk.StateType.NORMAL];
-       */
-
 
                // Background
                drawable.draw_rectangle(style.bg_gc[Gtk.StateType.NORMAL], true, 0, 0, allocation.width, allocation.height);
 
                // Background
                drawable.draw_rectangle(style.bg_gc[Gtk.StateType.NORMAL], true, 0, 0, allocation.width, allocation.height);
@@ -212,7 +201,9 @@ public class FisheyeList : Gtk.DrawingArea
 
                        var fd = style.font_desc.copy();
                        //fd.set_size((y1-y0)*Pango.SCALE);
 
                        var fd = style.font_desc.copy();
                        //fd.set_size((y1-y0)*Pango.SCALE);
-                       fd.set_absolute_size((y1-y0)*Pango.SCALE*80/100);
+                       int size = (y1-y0)*Pango.SCALE*80/100;
+                       if (size <= 0) size = Pango.SCALE;
+                       fd.set_absolute_size(size);
                        layout.set_font_description(fd);
                        //stderr.printf("AZAZA %p\n", layout.get_attributes());
                        //var attrlist = layout.get_attributes().copy();
                        layout.set_font_description(fd);
                        //stderr.printf("AZAZA %p\n", layout.get_attributes());
                        //var attrlist = layout.get_attributes().copy();
@@ -251,12 +242,12 @@ public class FisheyeList : Gtk.DrawingArea
      * @param max the end of the display
      * @return the distorted coordinate
      */
      * @param max the end of the display
      * @return the distorted coordinate
      */
-    private double fisheye(double x, double a, double d, double min, double max)
+    private double fisheye(double x, int a, double d, int min, int max)
     {
         if ( d != 0 ) {
             bool left = x<a;
             double v;
     {
         if ( d != 0 ) {
             bool left = x<a;
             double v;
-           double m = (left ? a-min : max-a);
+           int m = (left ? a-min : max-a);
             if ( m == 0 ) m = max-min;
             v = Math.fabs(x - a) / m;
             v = (d+1)/(d+(1/v));
             if ( m == 0 ) m = max-min;
             v = Math.fabs(x - a) / m;
             v = (d+1)/(d+(1/v));