[xiph-commits] r12512 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Feb 22 03:57:59 PST 2007


Author: xiphmont
Date: 2007-02-22 03:57:57 -0800 (Thu, 22 Feb 2007)
New Revision: 12512

Modified:
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-1d.h
   trunk/sushivision/slider.c
Log:
unflipped 1d panels now use a vertical slider to the left of the panel
to adjust range



Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-02-22 06:45:57 UTC (rev 12511)
+++ trunk/sushivision/panel-1d.c	2007-02-22 11:57:57 UTC (rev 12512)
@@ -1191,32 +1191,39 @@
 void _sushiv_realize_panel1d(sushiv_panel_t *p){
   sushiv_panel1d_t *p1 = p->subtype->p1;
   int i;
-
   _sushiv_panel_undo_suspend(p);
 
   p->private->toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
 			    G_CALLBACK (_sushiv_clean_exit), (void *)SIGINT);
  
-  p1->top_table = gtk_table_new(5,3,0);
+  p1->top_table = gtk_table_new(4,1,0);
 
   gtk_container_add (GTK_CONTAINER (p->private->toplevel), p1->top_table);
   gtk_container_set_border_width (GTK_CONTAINER (p->private->toplevel), 1);
-  
+ 
+  gtk_table_set_col_spacing(GTK_TABLE(p1->top_table),0,4);
+ 
+  p1->graph_table = gtk_table_new(2,2,0);
+  gtk_table_attach(GTK_TABLE(p1->top_table),p1->graph_table,0,1,1,2,
+		   GTK_EXPAND|GTK_FILL,0,4,1);
+  gtk_table_set_row_spacing(GTK_TABLE(p1->top_table),1,4);
+
+
   p1->obj_table = gtk_table_new(p->objectives,5,0);
-  gtk_table_attach(GTK_TABLE(p1->top_table),p1->obj_table,0,3,3,4,
-		   GTK_EXPAND|GTK_FILL,0,0,5);
+  gtk_table_attach(GTK_TABLE(p1->top_table),p1->obj_table,0,1,2,3,
+		   GTK_EXPAND|GTK_FILL,0,4,0);
 
   /* spinner, top bar */
   {
     GtkWidget *hbox = gtk_hbox_new(0,0);
-    gtk_table_attach(GTK_TABLE(p1->top_table),hbox,0,4,0,1,GTK_EXPAND|GTK_FILL,0,4,0);
+    gtk_table_attach(GTK_TABLE(p1->top_table),hbox,0,1,0,1,GTK_EXPAND|GTK_FILL,0,4,0);
     gtk_box_pack_end(GTK_BOX(hbox),GTK_WIDGET(p->private->spinner),0,0,0);
   }
 
   /* dim table */
   p1->dim_table = gtk_table_new(p->dimensions,3,0);
-  gtk_table_attach(GTK_TABLE(p1->top_table),p1->dim_table,0,4,4,5,
+  gtk_table_attach(GTK_TABLE(p1->top_table),p1->dim_table,0,1,3,4,
 		   GTK_EXPAND|GTK_FILL,0,4,4);
   
   /* graph */
@@ -1229,42 +1236,45 @@
     p->private->graph = GTK_WIDGET(plot_new(recompute_callback_1d,p,
 					    (void *)(void *)crosshair_callback,p,
 					    box_callback,p,flags)); 
-    gtk_table_attach(GTK_TABLE(p1->top_table),p->private->graph,0,4,1,2,
-		     GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,4,1);
-    gtk_table_set_row_spacing(GTK_TABLE(p1->top_table),0,1);
-    gtk_table_set_row_spacing(GTK_TABLE(p1->top_table),1,4);
-    gtk_table_set_col_spacing(GTK_TABLE(p1->top_table),2,4);
-
+    if(p1->flip){
+      gtk_table_attach(GTK_TABLE(p1->graph_table),p->private->graph,0,2,0,1,
+		       GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,1);
+    }else{
+      gtk_table_attach(GTK_TABLE(p1->graph_table),p->private->graph,1,2,0,2,
+		       GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,1);
+    }
   }
 
   /* range slider */
+  /* may be vertical to the left of the plot or along the bottom if the plot is flipped */
   {
     GtkWidget **sl = calloc(2,sizeof(*sl));
 
     int lo = p1->range_scale->val_list[0];
     int hi = p1->range_scale->val_list[p1->range_scale->vals-1];
 
-    /* label */
-    {
-      GtkWidget *label = gtk_label_new("range");
-      gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
-      gtk_table_attach(GTK_TABLE(p1->top_table),label,0,1,2,3,
-		       GTK_FILL,0,10,0);
-    }
-
     /* the range slices/slider */ 
     sl[0] = slice_new(map_callback_1d,p);
     sl[1] = slice_new(map_callback_1d,p);
 
-    gtk_table_attach(GTK_TABLE(p1->top_table),sl[0],1,2,2,3,
-		     GTK_EXPAND|GTK_FILL,0,0,0);
-    gtk_table_attach(GTK_TABLE(p1->top_table),sl[1],2,3,2,3,
-		     GTK_EXPAND|GTK_FILL,0,0,0);
+    if(p1->flip){
+      gtk_table_attach(GTK_TABLE(p1->graph_table),sl[0],0,1,1,2,
+		       GTK_EXPAND|GTK_FILL,0,0,0);
+      gtk_table_attach(GTK_TABLE(p1->graph_table),sl[1],1,2,1,2,
+		       GTK_EXPAND|GTK_FILL,0,0,0);
+    }else{
+      gtk_table_attach(GTK_TABLE(p1->graph_table),sl[0],0,1,1,2,
+		       GTK_SHRINK,GTK_EXPAND|GTK_FILL,0,0);
+      gtk_table_attach(GTK_TABLE(p1->graph_table),sl[1],0,1,0,1,
+		       GTK_SHRINK,GTK_EXPAND|GTK_FILL,0,0);
+      gtk_table_set_col_spacing(GTK_TABLE(p1->graph_table),0,4);
+    }
+
     p1->range_slider = slider_new((Slice **)sl,2,
 				  p1->range_scale->label_list,
 				  p1->range_scale->val_list,
 				  p1->range_scale->vals,
-				  SLIDER_FLAG_INDEPENDENT_MIDDLE);
+				  (p1->flip?0:SLIDER_FLAG_VERTICAL));
 
     slice_thumb_set((Slice *)sl[0],lo);
     slice_thumb_set((Slice *)sl[1],hi);

Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h	2007-02-22 06:45:57 UTC (rev 12511)
+++ trunk/sushivision/panel-1d.h	2007-02-22 11:57:57 UTC (rev 12512)
@@ -25,6 +25,7 @@
   sushiv_panel_t *link_y;
 
   GtkWidget *top_table;
+  GtkWidget *graph_table;
   GtkWidget *obj_table;
   GtkWidget *dim_table;
 

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2007-02-22 06:45:57 UTC (rev 12511)
+++ trunk/sushivision/slider.c	2007-02-22 11:57:57 UTC (rev 12512)
@@ -138,11 +138,6 @@
   // prepare background 
   cairo_t *c = cairo_create(s->background);
   
-  if(s->flip){
-    cairo_matrix_t m = {0.,-1., 1.,0.,  0.,h};
-    cairo_set_matrix(c,&m);
-  }
-
   // Fill with bg color
   gdk_cairo_set_source_color(c,bg); 
   cairo_rectangle(c,0,0,w,h);
@@ -157,25 +152,14 @@
   if(s->gradient){
     // background map gradient 
     // this happens 'under' cairo
-    if(s->flip){
-      u_int32_t *pixel=s->backdata+ty;
-      
-      for(i=tx+tw-1;i>=tx;i--){
-	*pixel=mapping_calc(s->gradient,slider_pixel_to_del(s,i), *pixel);
-	for(i=1;i<th;i++)
-	  pixel[i] = pixel[0];
-	pixel+=s->w;
-      }
-    }else{
-      u_int32_t *pixel=s->backdata+ty*s->w;
-      
-      for(i=tx;i<tx+tw;i++)
-	pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,i), pixel[i]);
-      
-      for(i=ty+1;i<ty+th;i++){
-	memcpy(pixel+w,pixel,w*4);
-	pixel+=s->w;
-      }
+    u_int32_t *pixel=s->backdata+ty*s->w;
+    
+    for(i=tx;i<tx+tw;i++)
+      pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,i), pixel[i]);
+    
+    for(i=ty+1;i<ty+th;i++){
+      memcpy(pixel+w,pixel,w*4);
+      pixel+=s->w;
     }
   }else{
     // normal background
@@ -260,16 +244,13 @@
 
     s->backdata = calloc(w*h,4);
 
-    if(s->flip){
       s->background = cairo_image_surface_create_for_data ((unsigned char *)s->backdata,
 							   CAIRO_FORMAT_RGB24,
-							   h,w,w*4);
+							   w,h,w*4);
+    if(s->flip){
       s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
 						  h,w);
     }else{
-      s->background = cairo_image_surface_create_for_data ((unsigned char *)s->backdata,
-							   CAIRO_FORMAT_RGB24,
-							   w,h,w*4);
       s->foreground = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
 						  w,h);
     }
@@ -335,16 +316,17 @@
   cairo_t *c;
   //int w=s->w;
   int h=s->h;
+  int w=s->w;
 
   c = cairo_create(s->foreground);
 
   if(s->flip){
-    cairo_matrix_t m = {0.,-1., 1.,0.,  0.,h};
+    cairo_matrix_t m = {0.,-1., 1.,0.,  0.,w};
     cairo_set_matrix(c,&m);
   }
 
   cairo_set_source_surface(c,s->background,0,0);
-  cairo_rectangle(c,0,0,s->w,s->h);
+  cairo_rectangle(c,0,0,w,h);
   cairo_fill(c);
 
   // thumbs
@@ -508,7 +490,7 @@
 
     slider_realize(s);
     if(s->flip){
-      cairo_set_source_surface(c,s->foreground,0,-slice_width(s,slicenum));
+      cairo_set_source_surface(c,s->foreground,0,slice_width(s,slicenum)-w->allocation.height);
     }else{
       cairo_set_source_surface(c,s->foreground,-slice_width(s,slicenum),0);
     }
@@ -663,8 +645,9 @@
   int n = s->num_slices;
 
   if(s->flip){
+    Slice *sl = SLICE(s->slices[slicenum]);
     int temp = x;
-    x = s->h - y -1;
+    x = sl->widget.allocation.height - y -1;
     y = temp;
   }
 
@@ -770,16 +753,17 @@
 void slider_motion(Slider *s,int slicenum,int x,int y){
   double altered[s->num_slices];
   int i, grabflag=0;
-  int px = (s->flip?s->h-y-1 : x);
+  Slice *sl = SLICE(s->slices[slicenum]);
+  int px = (s->flip?sl->widget.allocation.height-y-1 : x);
 
   for(i=0;i<s->num_slices;i++){
-    Slice *sl = SLICE(s->slices[i]);
+    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]);
+    sl = SLICE(s->slices[i]);
     if(sl->thumb_grab){      
       sl->thumb_val=
 	slider_pixel_to_val(s,slice_adjust_pixel(s,slicenum,px));



More information about the commits mailing list