[xiph-commits] r12047 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Nov 6 14:53:56 PST 2006


Author: xiphmont
Date: 2006-11-06 14:53:53 -0800 (Mon, 06 Nov 2006)
New Revision: 12047

Modified:
   trunk/sushivision/slice.c
   trunk/sushivision/slider.c
   trunk/sushivision/slider.h
Log:
Add arrow key bindings for key control of sliders



Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c	2006-11-06 22:06:17 UTC (rev 12046)
+++ trunk/sushivision/slice.c	2006-11-06 22:53:53 UTC (rev 12047)
@@ -125,7 +125,7 @@
 static gboolean slice_key_press(GtkWidget *widget,GdkEventKey *event){
   Slice *s=SLICE(widget);
 
-  return slider_key_press(s->slider,event);
+  return slider_key_press(s->slider,event,s->slicenum);
 }
 
 static void slice_state_changed(GtkWidget *w,GtkStateType ps){

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2006-11-06 22:06:17 UTC (rev 12046)
+++ trunk/sushivision/slider.c	2006-11-06 22:53:53 UTC (rev 12047)
@@ -512,7 +512,7 @@
 
   pixlo = tx;
   for(j=0;j<s->labels-1;j++){
-    double pixhi=rint((double)(j+1)/(s->labels-1)*(tw-1))+tx;
+    double pixhi=rint((double)(j+1)/(s->labels-1)*tw)+tx;
 
     if(x>=pixlo && x<=pixhi){
       double del=(double)(x-pixlo)/(pixhi-pixlo);
@@ -711,8 +711,54 @@
   }
 }
 
-gboolean slider_key_press(Slider *s,GdkEventKey *event){
+gboolean slider_key_press(Slider *s,GdkEventKey *event,int slicenum){
+  Slice *sl = (Slice *)(s->slices[slicenum]);
+  int shift = (event->state&GDK_SHIFT_MASK);
+  if(event->state&GDK_MOD1_MASK) return FALSE;
+  if(event->state&GDK_CONTROL_MASK)return FALSE;
+  
+  /* non-control keypresses */
+  switch(event->keyval){
+  case GDK_Left:
+    {
+      double x = val_to_pixel(s,sl->thumb_val)-1;
+      if(shift)
+	x-=9;
+      sl->thumb_val=slider_pixel_to_val(s,0,x);
+      slider_vals_bound(s,slicenum);
+      // did a gradient get altered?
+      update_gradient(s);
+      
+      if(sl->callback){
+	sl->callback(sl->callback_data,0);
+	sl->callback(sl->callback_data,2);
+      }
+      slider_draw(s);
+      slider_expose(s);
 
+    }
+    return TRUE;
+
+  case GDK_Right:
+    {
+      double x = val_to_pixel(s,sl->thumb_val)+1;
+      if(shift)
+	x+=9;
+      sl->thumb_val=slider_pixel_to_val(s,0,x);
+      slider_vals_bound(s,slicenum);
+      // did a gradient get altered?
+      update_gradient(s);
+      
+      if(sl->callback){
+	sl->callback(sl->callback_data,0);
+	sl->callback(sl->callback_data,2);
+      }
+      slider_draw(s);
+      slider_expose(s);
+    }
+    return TRUE;
+  }
+
   return FALSE; // keep processing
 }
 

Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h	2006-11-06 22:06:17 UTC (rev 12046)
+++ trunk/sushivision/slider.h	2006-11-06 22:53:53 UTC (rev 12047)
@@ -60,7 +60,7 @@
 extern void slider_button_press(Slider *slider,int slicenum,int x,int y);
 extern void slider_button_release(Slider *s,int slicenum,int x,int y);
 extern void slider_motion(Slider *s,int slicenum,int x,int y);
-extern gboolean slider_key_press(Slider *slider,GdkEventKey *event);
+extern gboolean slider_key_press(Slider *slider,GdkEventKey *event,int slicenum);
 extern Slider *slider_new(Slice **slices, int num_slices, 
 			  char **labels, double *label_vals, int num_labels,
 			  unsigned flags);



More information about the commits mailing list