[xiph-commits] r12238 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Dec 25 12:22:51 PST 2006


Author: xiphmont
Date: 2006-12-25 12:22:50 -0800 (Mon, 25 Dec 2006)
New Revision: 12238

Modified:
   trunk/sushivision/slider.c
Log:
Correct slider abstraction to call callbacks on all slice thumbs that
may be modified, not just the grabbed thumb.



Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2006-12-25 02:31:47 UTC (rev 12237)
+++ trunk/sushivision/slider.c	2006-12-25 20:22:50 UTC (rev 12238)
@@ -677,9 +677,14 @@
 }
 
 void slider_motion(Slider *s,int slicenum,int x,int y){
-  int altered=0;
-  int i;
+  double altered[s->num_slices];
+  int i, grabflag=0;
   
+  for(i=0;i<s->num_slices;i++){
+    Slice *sl = SLICE(s->slices[i]);
+    altered[i] = sl->thumb_val;
+  }
+
   /* is a thumb already grabbed? */
   for(i=0;i<s->num_slices;i++){
     Slice *sl = SLICE(s->slices[i]);
@@ -687,19 +692,27 @@
       sl->thumb_val=
 	slider_pixel_to_val(s,slice_adjust_pixel(s,slicenum,x));
       slider_vals_bound(s,i);
-      altered=i+1;
+      grabflag = 1;
     }
   }
 
   // did a gradient get altered?
   update_gradient(s);
 
-  if(altered){
-    Slice *sl = SLICE(s->slices[altered-1]);
-    
-    if(sl->callback)sl->callback(sl->callback_data,1);
+  if(grabflag){
     slider_draw(s);
     slider_expose(s);
+
+    // call slice callbacks on all slices that were altered; value
+    // bounding might have affected slices other than the grabbed one.
+
+    for(i=0;i<s->num_slices;i++){
+      Slice *sl = SLICE(s->slices[i]);
+    
+      if(sl->thumb_val != altered[i])
+	if(sl->callback)sl->callback(sl->callback_data,1);
+    }
+
   }else{
     /* nothing grabbed right now; determine if we're in a a thumb's area */
     if(slider_lightme(s,slicenum,x,y)){



More information about the commits mailing list