[xiph-commits] r12499 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Feb 21 00:27:33 PST 2007


Author: xiphmont
Date: 2007-02-21 00:27:29 -0800 (Wed, 21 Feb 2007)
New Revision: 12499

Modified:
   trunk/sushivision/example_discrete.c
   trunk/sushivision/gtksucks.c
   trunk/sushivision/gtksucks.h
   trunk/sushivision/internal.h
   trunk/sushivision/mapping.c
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-1d.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel-2d.h
   trunk/sushivision/panel.c
   trunk/sushivision/plot.c
   trunk/sushivision/plot.h
   trunk/sushivision/slider.c
   trunk/sushivision/sushi-gtkrc.in
   trunk/sushivision/sushivision.h
   trunk/sushivision/undo.c
Log:
Implement submenus on right-click menus
Centralize right-click menus in panel infrastructure
Add configurable background
Add configurable scale/legend text color



Modified: trunk/sushivision/example_discrete.c
===================================================================
--- trunk/sushivision/example_discrete.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/example_discrete.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -32,9 +32,9 @@
   int Y = rint(d[1]);
 
   if(!(X%100) && !(Y%100)) 
+    ret[0]=0.;
+  else
     ret[0]=1.;
-  else
-    ret[0]=0.;
 }
 
 int sushiv_submain(int argc, char *argv[]){

Modified: trunk/sushivision/gtksucks.c
===================================================================
--- trunk/sushivision/gtksucks.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/gtksucks.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -248,58 +248,53 @@
 }
 
 GtkWidget *gtk_menu_new_twocol(GtkWidget *bind, 
-			       char **menu_list, 
-			       char **shortcuts,
-			       void (*callbacks[])(void *),
+			       menuitem **items,
 			       void *callback_data){
-
-  char **ptr = menu_list;
-  char **sptr = shortcuts;
+  
+  menuitem *ptr = *items++;
   GtkWidget *ret = gtk_menu_new();
    
   /* create packable boxes for labels, put left labels in */
-  while(*ptr){
+  while(ptr->left){
     GtkWidget *item;
-    if(!strcmp(*ptr,"")){
+    if(!strcmp(ptr->left,"")){
       // seperator, not item
       item = gtk_separator_menu_item_new();
       gtk_menu_shell_append(GTK_MENU_SHELL(ret),item);
     }else{
       GtkWidget *box = gtk_hbox_new(0,10);
-      GtkWidget *left = gtk_label_new(*ptr);
+      GtkWidget *left = gtk_label_new(NULL);
       GtkWidget *right = NULL;
 
+      gtk_label_set_markup (GTK_LABEL (left), ptr->left);
+
       item = gtk_menu_item_new();
       gtk_container_add(GTK_CONTAINER(item),box);
       gtk_box_pack_start(GTK_BOX(box),left,0,0,5);
       
-      if(sptr && *sptr){
-	char *markup = g_markup_printf_escaped ("<i>%s</i>", *sptr);
-	right = gtk_label_new(NULL);
-	
-	gtk_label_set_markup (GTK_LABEL (right), markup);
-	g_free (markup);
-	
+      if(ptr->right){
+	right = gtk_label_new(NULL);	
+	gtk_label_set_markup (GTK_LABEL (right), ptr->right);
 	gtk_box_pack_end(GTK_BOX(box),right,0,0,5);
       }
 
       gtk_menu_shell_append(GTK_MENU_SHELL(ret),item);
-      if(callbacks && *callbacks)
+      if(ptr->callback)
 	g_signal_connect_swapped (G_OBJECT (item), "activate",
-				  G_CALLBACK (*callbacks), callback_data);
+				  G_CALLBACK (ptr->callback), callback_data);
+      if(ptr->submenu)
+	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),ptr->submenu);
     }
     gtk_widget_show_all(item);
     
-    ptr++;
-    if(sptr)
-      sptr++;
-    if(callbacks)
-      callbacks++;
+    ptr = *items++;
   }
 
-  gtk_widget_add_events(bind, GDK_BUTTON_PRESS_MASK);
-  g_signal_connect_swapped (bind, "button-press-event",
-			    G_CALLBACK (popup_callback), ret);
+  if(bind){
+    gtk_widget_add_events(bind, GDK_BUTTON_PRESS_MASK);
+    g_signal_connect_swapped (bind, "button-press-event",
+			      G_CALLBACK (popup_callback), ret);
+  }
 
   return ret;
 }
@@ -341,9 +336,32 @@
 
   if(!label)return;
 
-  gtk_label_set_label(GTK_LABEL(label),text);
+  gtk_label_set_markup(GTK_LABEL(label),text);
 }
 
+void gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text){
+  GList *l;
+  GtkWidget *box=NULL;
+  GtkWidget *label=NULL;
+  GtkWidget *item = gtk_menu_get_item(m, pos);
+  if(!item)return;
+
+  l=gtk_container_get_children (GTK_CONTAINER(item));    
+  box = l->data;
+  g_list_free(l);
+
+  if(!box)return;
+
+  l=gtk_container_get_children (GTK_CONTAINER(box));    
+  if(l && l->next)
+    label = l->next->data;
+  g_list_free(l);
+
+  if(!label)return;
+
+  gtk_label_set_markup(GTK_LABEL(label),text);
+}
+
 /**********************************************************************/
 /* unlock text combo boxes to support markup as well as straight text */
 

Modified: trunk/sushivision/gtksucks.h
===================================================================
--- trunk/sushivision/gtksucks.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/gtksucks.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -22,18 +22,24 @@
 #ifndef _GTK_SUCKS_H_
 #define _GTK_SUCKS_H_
 
+typedef struct {
+  char *left;
+  char *right;
+  GtkWidget *submenu;
+  void (*callback)(sushiv_panel_t *);
+} menuitem;
+
 extern void gtk_widget_set_sensitive_fixup(GtkWidget *w, gboolean state);
 extern void gtk_widget_remove_events (GtkWidget *widget, gint events);
 extern void gtk_button3_fixup();
 extern void gtk_mutex_fixup();
 extern pthread_mutex_t *gtk_get_mutex();
 extern GtkWidget *gtk_menu_new_twocol(GtkWidget *bind, 
-				      char **menu_list, 
-				      char **shortcuts,
-				      void (*callbacks[])(void *),
+				      menuitem **items,
 				      void *callback_data);
 extern GtkWidget *gtk_menu_get_item(GtkMenu *m, int pos);
 extern void gtk_menu_alter_item_label(GtkMenu *m, int pos, char *text);
+extern void gtk_menu_alter_item_right(GtkMenu *m, int pos, char *text);
 extern GtkWidget * gtk_combo_box_new_markup (void);
 
 #endif

Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/internal.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -65,7 +65,11 @@
   GtkWidget *toplevel;
   GtkWidget *graph;
   Spinner *spinner;
+  GtkWidget *popmenu;
+
+  enum sushiv_background bg_type;
   sushiv_dim_widget_t **dim_scales;
+  int oldbox_active;
 
   int realized;
 
@@ -99,7 +103,6 @@
 
   void (*undo_log)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
   void (*undo_restore)(sushiv_panel_undo_t *u, sushiv_panel_t *p);
-  void (*update_menus)(sushiv_panel_t *p);
 };
 
 struct sushiv_instance_internal {
@@ -139,5 +142,8 @@
 
 extern void _sushiv_panel1d_mark_recompute_linked(sushiv_panel_t *p); 
 extern void _sushiv_panel1d_update_linked_crosshairs(sushiv_panel_t *p, int xflag, int yflag); 
+extern void _sushiv_panel_update_menus(sushiv_panel_t *p);
 
+extern void render_checks(ucolor *c, int w, int y);
+
 extern sig_atomic_t _sushiv_exiting;

Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/mapping.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -150,6 +150,11 @@
   r->b += val;
 }
  
+static void black_a(int val, int mul, lcolor *r){
+  if(val<0)return;
+  val = (val*mul)>>16;
+  r->a += val;
+}
 
 static void white_a(int val, int mul, lcolor *r){
   if(val<0)return;
@@ -397,7 +402,7 @@
 }
 
 static void (*mapsolid[])(int, int, lcolor *)={
-  white_a,
+  black_a,
   red_a,
   green_a,
   blue_a,
@@ -405,6 +410,7 @@
   cyan_a,
   purple_a,
   gray_a,
+  white_a,
   inactive
 };
 
@@ -417,11 +423,12 @@
   normal_mix,
   normal_mix,
   normal_mix,
+  normal_mix,
   inactive_mix
 };
 
 static char *solidnames[]={
-  "<span foreground=\"white\">white</span>",
+  "<span foreground=\"black\">black</span>",
   "<span foreground=\"red\">red</span>",
   "<span foreground=\"green\">green</span>",
   "<span foreground=\"blue\">blue</span>",
@@ -429,6 +436,7 @@
   "<span foreground=\"cyan\">cyan</span>",
   "<span foreground=\"purple\">purple</span>",
   "<span foreground=\"gray\">gray</span>",
+  "<span foreground=\"white\">white</span>",
   "inactive",
   0
 };

Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/panel-1d.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -58,8 +58,6 @@
   NULL
 };
 
-static void update_context_menus(sushiv_panel_t *p);
-
 // called internally, assumes we hold lock
 // redraws the data, does not compute the data
 static void _sushiv_panel1d_remap(sushiv_panel_t *p){
@@ -70,13 +68,26 @@
 
   if(plot){
     int xi,i,j;
-    //double h = p1->panel_h;
+    int pw = plot->x.pixels;
+    int ph = plot->y.pixels;
     int dw = p1->data_size;
     double r = (p1->flip?p1->panel_w:p1->panel_h);
     
-    /* blank frame to black */
-    cairo_set_source_rgb (c, 0,0,0);
-    cairo_paint(c);
+    /* blank frame to selected bg */
+    switch(p->private->bg_type){
+    case SUSHIV_BG_WHITE:
+      cairo_set_source_rgb (c, 1.,1.,1.);
+      cairo_paint(c);
+      break;
+    case SUSHIV_BG_BLACK:
+      cairo_set_source_rgb (c, 0,0,0);
+      cairo_paint(c);
+      break;
+    case SUSHIV_BG_CHECKS:
+      for(i=0;i<ph;i++)
+	render_checks((ucolor *)plot->datarect+pw*i, pw, i);
+      break;
+    }
 
     if(p1->data_vec){
 
@@ -282,7 +293,10 @@
 		}
 
 		if(pointtype>0){
-		  cairo_set_source_rgba(c,1.,1.,1.,alpha);
+		  if(p->private->bg_type == SUSHIV_BG_WHITE)
+		    cairo_set_source_rgba(c,0.,0.,0.,alpha);
+		  else
+		    cairo_set_source_rgba(c,1.,1.,1.,alpha);
 		  cairo_stroke(c);
 		}
 	      }
@@ -842,7 +856,7 @@
       if(d == p1->x_d)
 	_sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
 	            
-      p1->oldbox_active = 0;
+      p->private->oldbox_active = 0;
     }
     _sushiv_panel_undo_resume(p);
   }
@@ -857,7 +871,7 @@
   case 0: // box set
     _sushiv_panel_undo_push(p);
     plot_box_vals(plot,p1->oldbox);
-    p1->oldbox_active = plot->box_active;
+    p->private->oldbox_active = plot->box_active;
     break;
   case 1: // box activate
     _sushiv_panel_undo_push(p);
@@ -867,11 +881,11 @@
     
     _sushiv_dimension_set_value(p1->x_scale,0,p1->oldbox[0]);
     _sushiv_dimension_set_value(p1->x_scale,2,p1->oldbox[1]);
-    p1->oldbox_active = 0;
+    p->private->oldbox_active = 0;
     _sushiv_panel_undo_resume(p);
     break;
   }
-  update_context_menus(p);
+  _sushiv_panel_update_menus(p);
 }
 
 void _maintain_cache_1d(sushiv_panel_t *p, _sushiv_bythread_cache_1d *c, int w){
@@ -927,6 +941,7 @@
   update_legend(p);
   _sushiv_panel_clean_legend(p);
   plot_draw_scales(plot);
+  plot_expose_request(plot);
   return 1;
 }
 
@@ -1053,7 +1068,7 @@
   u->x_d = p1->x_dnum;
   u->box[0] = p1->oldbox[0];
   u->box[1] = p1->oldbox[1];
-  u->box_active = p1->oldbox_active;
+  u->box_active = p->private->oldbox_active;
   
 }
 
@@ -1097,10 +1112,10 @@
 
   if(u->box_active){
     plot_box_set(plot,u->box);
-    p1->oldbox_active = 1;
+    p->private->oldbox_active = 1;
   }else{
     plot_unset_box(plot);
-    p1->oldbox_active = 0;
+    p->private->oldbox_active = 0;
   }
 }
 
@@ -1137,109 +1152,6 @@
   return FALSE;
 }
 
-static void update_context_menus(sushiv_panel_t *p){
-  sushiv_panel1d_t *p1 = p->subtype->p1;
-
-  // is undo active?
-  if(!p->sushi->private->undo_stack ||
-     !p->sushi->private->undo_level){
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->popmenu),0),FALSE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->graphmenu),0),FALSE);
-  }else{
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->popmenu),0),TRUE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->graphmenu),0),TRUE);
-  }
-
-  // is redo active?
-  if(!p->sushi->private->undo_stack ||
-     !p->sushi->private->undo_stack[p->sushi->private->undo_level] ||
-     !p->sushi->private->undo_stack[p->sushi->private->undo_level+1]){
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->popmenu),1),FALSE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->graphmenu),1),FALSE);
-  }else{
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->popmenu),1),TRUE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p1->graphmenu),1),TRUE);
-  }
-
-  // are we starting or enacting a zoom box?
-  if(p1->oldbox_active){ 
-    gtk_menu_alter_item_label(GTK_MENU(p1->graphmenu),3,"Zoom to selection");
-  }else{
-    gtk_menu_alter_item_label(GTK_MENU(p1->graphmenu),3,"Start zoom selection");
-  }
-
-}
-
-void wrap_exit(sushiv_panel_t *dummy){
-  _sushiv_clean_exit(SIGINT);
-}
-
-static char *panel_menulist[]={
-  "Undo",
-  "Redo",
-  "",
-  "Quit",
-  NULL
-};
-
-static char *panel_shortlist[]={
-  "Backspace",
-  "Space",
-  NULL,
-  "q",
-  NULL
-};
-
-static void (*panel_calllist[])(sushiv_panel_t *)={
-  &_sushiv_panel_undo_down,
-  &_sushiv_panel_undo_up,
-  NULL,
-  &wrap_exit,
-  NULL,
-};
-
-void wrap_enter(sushiv_panel_t *p){
-  plot_do_enter(PLOT(p->private->graph));
-}
-
-void wrap_escape(sushiv_panel_t *p){
-  plot_do_escape(PLOT(p->private->graph));
-}
-
-static char *graph_menulist[]={
-  "Undo",
-  "Redo",
-  "",
-  "Start zoom selection",
-  "Clear readouts",
-  "",
-  "Quit",
-  NULL
-};
-
-static char *graph_shortlist[]={
-  "Backspace",
-  "Space",
-  NULL,
-  "Enter",
-  "Escape",
-  NULL,
-  "q",
-  NULL
-};
-
-static void (*graph_calllist[])(sushiv_panel_t *)={
-  &_sushiv_panel_undo_down,
-  &_sushiv_panel_undo_up,
-  NULL,
-
-  &wrap_enter,
-  &wrap_escape,
-  NULL,
-  &wrap_exit,
-  NULL,
-};
-
 void _sushiv_realize_panel1d(sushiv_panel_t *p){
   sushiv_panel1d_t *p1 = p->subtype->p1;
   int i;
@@ -1283,6 +1195,7 @@
 					    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);
 
@@ -1445,19 +1358,6 @@
     update_x_sel(p);
   }
 
-  p1->popmenu = gtk_menu_new_twocol(p->private->toplevel,
-				    panel_menulist,
-				    panel_shortlist,
-				    (void *)(void *)panel_calllist,
-				    p);
-  p1->graphmenu = gtk_menu_new_twocol(p->private->graph,
-				      graph_menulist,
-				      graph_shortlist,
-				      (void *)(void *)graph_calllist,
-				      p);
-
-  update_context_menus(p);
-
   g_signal_connect (G_OBJECT (p->private->toplevel), "key-press-event",
                     G_CALLBACK (panel1d_keypress), p);
   gtk_window_set_title (GTK_WINDOW (p->private->toplevel), p->name);
@@ -1494,13 +1394,12 @@
   if(ret<0)return ret;
   p = s->panel_list[number];
   p1 = calloc(1, sizeof(*p1));
-  p->subtype = 
-    calloc(1, sizeof(*p->subtype)); /* the union is alloced not
-				       embedded as its internal
-				       structure must be hidden */
+  p->subtype = calloc(1, sizeof(*p->subtype));
+
   p->subtype->p1 = p1;
   p->type = SUSHIV_PANEL_1D;
   p1->range_scale = scale;
+  p->private->bg_type = SUSHIV_BG_WHITE;
 
   if(flags && SUSHIV_PANEL_LINK_Y)
     p1->link_y = p2;
@@ -1519,7 +1418,6 @@
 
   p->private->undo_log = panel1d_undo_log;
   p->private->undo_restore = panel1d_undo_restore;
-  p->private->update_menus = update_context_menus;
   
   return 0;
 }

Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/panel-1d.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -27,8 +27,6 @@
   GtkWidget *top_table;
   GtkWidget *obj_table;
   GtkWidget *dim_table;
-  GtkWidget *popmenu;
-  GtkWidget *graphmenu;
 
   int panel_w;
   int panel_h;
@@ -43,7 +41,6 @@
 
   int scales_init;
   double oldbox[4];
-  int oldbox_active;
 
   int flip;
   sushiv_scale_t *range_scale;

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/panel-2d.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -218,21 +218,6 @@
 
 /* functions that perform actual graphical rendering */
 
-static void render_checks(ucolor *c, int w, int y){
-  /* default checked background */
-  /* 16x16 'mid-checks' */ 
-  int x,j;
-  
-  int phase = (y>>4)&1;
-  for(x=0;x<w;){
-    u_int32_t phaseval = 0xff505050UL;
-    if(phase) phaseval = 0xff808080UL;
-    for(j=0;j<16 && x<w;j++,x++)
-      c[x].u = phaseval;
-    phase=!phase;
-  }
-}
-
 static float resample_helpers_init(scalespace *to, scalespace *from,
 				   unsigned char *delA, unsigned char *delB, 
 				   int *posA, int *posB,
@@ -540,6 +525,7 @@
   int i = p2->bg_next_line,j;
   ucolor work_bg[pw];
   ucolor work_pl[pw];
+  int bgmode = p->private->bg_type;
 
   /* find a row that needs to be updated */
   while(i<ph && !todo[i]){
@@ -558,8 +544,21 @@
 
   /* gray background checks */
   gdk_threads_leave();
-  render_checks(work_bg,pw,i);
 
+  switch(bgmode){
+  case SUSHIV_BG_WHITE:
+    for(j=0;j<pw;j++)
+      work_bg[j].u = 0xffffffffU;
+    break;
+  case SUSHIV_BG_BLACK:
+    for(j=0;j<pw;j++)
+      work_bg[j].u = 0xff000000U;
+    break;
+  default:
+    render_checks(work_bg,pw,i);
+    break;
+  }
+
   /* by objective */
   for(j=0;j<p->objectives;j++){
     int o_ynum = p2->y_obj_from_panel[j];
@@ -609,6 +608,7 @@
   return 0;
 }
 
+static void _dirty_map_full(sushiv_panel_t *p);
 // enter with lock; returns zero if thread should sleep / get distracted
 static int _sushiv_panel2d_remap(sushiv_panel_t *p, _sushiv_bythread_cache_2d *thread_cache){
   sushiv_panel2d_t *p2 = p->subtype->p2;
@@ -634,6 +634,9 @@
     p2->bg_next_line = 0;
     p2->bg_first_line = ph;
     p2->bg_last_line = 0;
+
+    if(!p2->partial_remap)
+      _dirty_map_full(p);
   }
 
   /* by plane, by line; each plane renders independently */
@@ -688,6 +691,7 @@
   memset(p2->bg_todo,0,ph*sizeof(*p2->bg_todo));
 
   // clear 'panel in progress' flag
+  p2->partial_remap = 0;
   _sushiv_panel_clean_map(p);
   return 0;
 
@@ -708,6 +712,7 @@
     if(y_no>=0 && p2->y_planetodo[y_no])
       memset(p2->y_planetodo[y_no],1,ph * sizeof(**p2->y_planetodo));
   }
+  p2->partial_remap = 1;
 }
 
 // call while locked 
@@ -720,6 +725,8 @@
   int dh = p2->y_v.pixels;
   int i,j;
 
+  p2->partial_remap = 1;
+
   if(ph!=dh || pw!=dw){
     /* resampled row computation; may involve multiple data rows */
     if(p2->y_planetodo){
@@ -749,6 +756,8 @@
   int ph = p2->y.pixels;
   int i,j;
 
+  p2->partial_remap = 1;
+
   if(p2->y_planetodo){
     for(j=0;j<p2->y_obj_num;j++){
       if(p2->y_planetodo[j]){
@@ -1180,7 +1189,7 @@
       _sushiv_dimension_set_value(p->private->dim_scales[i],1,y);
     }
     
-    p2->oldbox_active = 0;
+    p->private->oldbox_active = 0;
   }
 
   // dimension setting might have enforced granularity restrictions;
@@ -1203,7 +1212,7 @@
   case 0: // box set
     _sushiv_panel_undo_push(p);
     plot_box_vals(plot,p2->oldbox);
-    p2->oldbox_active = plot->box_active;
+    p->private->oldbox_active = plot->box_active;
     break;
   case 1: // box activate
     _sushiv_panel_undo_push(p);
@@ -1215,11 +1224,11 @@
     _sushiv_dimension_set_value(p2->x_scale,2,p2->oldbox[1]);
     _sushiv_dimension_set_value(p2->y_scale,0,p2->oldbox[2]);
     _sushiv_dimension_set_value(p2->y_scale,2,p2->oldbox[3]);
-    p2->oldbox_active = 0;
+    p->private->oldbox_active = 0;
     _sushiv_panel_undo_resume(p);
     break;
   }
-  p->private->update_menus(p);
+  _sushiv_panel_update_menus(p);
 }
 
 void _maintain_compute_cache_2d(sushiv_panel_t *p, _sushiv_bythread_cache_2d *c, int w){
@@ -1270,6 +1279,7 @@
   update_legend(p);
   _sushiv_panel_clean_legend(p);
   plot_draw_scales(plot);
+  plot_expose_request(plot);
   return 1;
 }
 
@@ -1516,7 +1526,7 @@
   u->box[1] = p2->oldbox[1];
   u->box[2] = p2->oldbox[2];
   u->box[3] = p2->oldbox[3];
-  u->box_active = p2->oldbox_active;
+  u->box_active = p->private->oldbox_active;
 }
 
 static void panel2d_undo_restore(sushiv_panel_undo_t *u, sushiv_panel_t *p){
@@ -1545,10 +1555,10 @@
 
   if(u->box_active){
     plot_box_set(plot,u->box);
-    p2->oldbox_active = 1;
+    p->private->oldbox_active = 1;
   }else{
     plot_unset_box(plot);
-    p2->oldbox_active = 0;
+    p->private->oldbox_active = 0;
   }
 }
 
@@ -1586,110 +1596,6 @@
   return FALSE;
 }
 
-static void update_context_menus(sushiv_panel_t *p){
-  sushiv_panel2d_t *p2 = p->subtype->p2;
-
-  // is undo active?
-  if(!p->sushi->private->undo_stack ||
-     !p->sushi->private->undo_level){
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->popmenu),0),FALSE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->graphmenu),0),FALSE);
-  }else{
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->popmenu),0),TRUE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->graphmenu),0),TRUE);
-  }
-
-  // is redo active?
-  if(!p->sushi->private->undo_stack ||
-     !p->sushi->private->undo_stack[p->sushi->private->undo_level] ||
-     !p->sushi->private->undo_stack[p->sushi->private->undo_level+1]){
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->popmenu),1),FALSE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->graphmenu),1),FALSE);
-  }else{
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->popmenu),1),TRUE);
-    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p2->graphmenu),1),TRUE);
-  }
-
-  // are we starting or enacting a zoom box?
-  if(p2->oldbox_active){ 
-    gtk_menu_alter_item_label(GTK_MENU(p2->popmenu),3,"Zoom to box");
-  }else{
-    gtk_menu_alter_item_label(GTK_MENU(p2->popmenu),3,"Start zoom box");
-  }
-
-}
-
-static void wrap_exit(sushiv_panel_t *dummy){
-  _sushiv_clean_exit(SIGINT);
-}
-
-static char *panel_menulist[]={
-  "Undo",
-  "Redo",
-  "",
-  "Quit",
-  NULL
-};
-
-static char *panel_shortlist[]={
-  "Backspace",
-  "Space",
-  NULL,
-  "q",
-  NULL
-};
-
-static void (*panel_calllist[])(sushiv_panel_t *)={
-  &_sushiv_panel_undo_down,
-  &_sushiv_panel_undo_up,
-  NULL,
-  &wrap_exit,
-  NULL,
-};
-
-static void wrap_enter(sushiv_panel_t *p){
-  plot_do_enter(PLOT(p->private->graph));
-}
-
-static void wrap_escape(sushiv_panel_t *p){
-  plot_do_escape(PLOT(p->private->graph));
-}
-
-static char *graph_menulist[]={
-  "Undo",
-  "Redo",
-  "",
-  "Start zoom box",
-  "Clear readouts",
-  "",
-  "Quit",
-  NULL
-};
-
-static char *graph_shortlist[]={
-  "Backspace",
-  "Space",
-  NULL,
-  "Enter",
-  "Escape",
-  NULL,
-  "q",
-  NULL
-};
-
-static void (*graph_calllist[])(sushiv_panel_t *)={
-  &_sushiv_panel_undo_down,
-  &_sushiv_panel_undo_up,
-  NULL,
-
-  &wrap_enter,
-  &wrap_escape,
-  NULL,
-  &wrap_exit,
-  NULL,
-};
-
-
 static void _sushiv_realize_panel2d(sushiv_panel_t *p){
   sushiv_panel2d_t *p2 = p->subtype->p2;
   int i;
@@ -1722,6 +1628,7 @@
 				  box_callback,p,0)); 
   gtk_table_attach(GTK_TABLE(p2->top_table),p->private->graph,0,5,1,2,
 		   GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,4,1);
+  gtk_table_set_row_spacing(GTK_TABLE(p2->top_table),0,1);
   gtk_table_set_row_spacing(GTK_TABLE(p2->top_table),1,4);
 
   /* objective sliders */
@@ -1836,19 +1743,6 @@
   }
   update_xy_availability(p);
 
-  p2->popmenu = gtk_menu_new_twocol(p->private->toplevel,
-				    panel_menulist,
-				    panel_shortlist,
-				    (void *)(void *)panel_calllist,
-				    p);
-  p2->graphmenu = gtk_menu_new_twocol(p->private->graph,
-				      graph_menulist,
-				      graph_shortlist,
-				      (void *)(void *)graph_calllist,
-				      p);
-
-  update_context_menus(p);
-
   g_signal_connect (G_OBJECT (p->private->toplevel), "key-press-event",
                     G_CALLBACK (panel2d_keypress), p);
   gtk_window_set_title (GTK_WINDOW (p->private->toplevel), p->name);
@@ -1888,6 +1782,7 @@
   
   p->subtype->p2 = p2;
   p->type = SUSHIV_PANEL_2D;
+  p->private->bg_type = SUSHIV_BG_CHECKS;
 
   // verify all the objectives have scales
   for(i=0;i<p->objectives;i++){
@@ -1906,7 +1801,6 @@
 
   p->private->undo_log = panel2d_undo_log;
   p->private->undo_restore = panel2d_undo_restore;
-  p->private->update_menus = update_context_menus;
 
   /* set up helper data structures for rendering */
 

Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/panel-2d.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -23,8 +23,6 @@
 
   GtkWidget *top_table;
   GtkWidget *dim_table;
-  GtkWidget *popmenu;
-  GtkWidget *graphmenu;
 
   /* only run those functions used by this panel */
   int used_functions;
@@ -40,6 +38,7 @@
   int **y_map; // indirected, dw*dh
   ucolor **y_planes; // indirected, dw*dh
   unsigned char **y_planetodo; // indirected, dh
+  int partial_remap;
 
   int y_next_plane; // which y plane to issue next render
   int y_next_line; // incremented when a line is claimed, per plane [0-ph)
@@ -67,7 +66,6 @@
 
   int scales_init;
   double oldbox[4];
-  int oldbox_active;
 
   mapping    *mappings;
   Slider    **range_scales;

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/panel.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -35,10 +35,222 @@
 
 extern void _sushiv_wake_workers(void);
 
+static void decide_text_inv(sushiv_panel_t *p){
+  if(p->private->graph){
+    Plot *plot = PLOT(p->private->graph);
+    if(p->private->bg_type == SUSHIV_BG_WHITE)
+      plot_set_bg_invert(plot,0);
+    else
+      plot_set_bg_invert(plot,1);
+  }
+}
+
+static void recompute_if_running(sushiv_panel_t *p){
+  if(p->private->realized && p->private->graph)
+    _sushiv_panel_dirty_plot(p);
+}
+
+static void redraw_if_running(sushiv_panel_t *p){
+  if(p->private->realized && p->private->graph){
+    plot_draw_scales(PLOT(p->private->graph));
+    _sushiv_panel_dirty_map(p);
+    _sushiv_panel_dirty_legend(p);
+  }
+}
+
+static void refg_if_running(sushiv_panel_t *p){
+  if(p->private->realized && p->private->graph){
+    plot_draw_scales(PLOT(p->private->graph));
+    _sushiv_panel_dirty_legend(p);
+  }
+}
+
+static void wrap_exit(sushiv_panel_t *dummy){
+  _sushiv_clean_exit(SIGINT);
+}
+
+static void wrap_enter(sushiv_panel_t *p){
+  plot_do_enter(PLOT(p->private->graph));
+}
+
+static void wrap_escape(sushiv_panel_t *p){
+  plot_do_escape(PLOT(p->private->graph));
+}
+
+static int _sushiv_panel_background_i(sushiv_panel_t *p,
+				      enum sushiv_background bg){
+  
+  sushiv_panel_internal_t *pi = p->private;
+  
+  pi->bg_type = bg;
+  
+  decide_text_inv(p);
+  redraw_if_running(p);
+  _sushiv_panel_update_menus(p);
+  return 0;
+}
+
+static void white_bg(sushiv_panel_t *p){
+  _sushiv_panel_background_i(p,SUSHIV_BG_WHITE);
+}
+static void black_bg(sushiv_panel_t *p){
+  _sushiv_panel_background_i(p,SUSHIV_BG_BLACK);
+}
+static void checked_bg(sushiv_panel_t *p){
+  _sushiv_panel_background_i(p,SUSHIV_BG_CHECKS);
+}
+static void black_text(sushiv_panel_t *p){
+  plot_set_bg_invert(PLOT(p->private->graph),0);
+  _sushiv_panel_update_menus(p);
+  refg_if_running(p);
+}
+static void white_text(sushiv_panel_t *p){
+  plot_set_bg_invert(PLOT(p->private->graph),1);
+  _sushiv_panel_update_menus(p);
+  refg_if_running(p);
+}
+static void grid_scale(sushiv_panel_t *p){
+  plot_set_grid(PLOT(p->private->graph),PLOT_GRID_NORMAL);
+  _sushiv_panel_update_menus(p);
+  refg_if_running(p);
+}
+static void tic_scale(sushiv_panel_t *p){
+  plot_set_grid(PLOT(p->private->graph),PLOT_GRID_TICS);
+  _sushiv_panel_update_menus(p);
+  refg_if_running(p);
+}
+static void no_scale(sushiv_panel_t *p){
+  plot_set_grid(PLOT(p->private->graph),0);
+  _sushiv_panel_update_menus(p);
+  refg_if_running(p);
+}
+
+static menuitem *menu[]={
+  &(menuitem){"Undo","[<i>bksp</i>]",NULL,&_sushiv_panel_undo_down},
+  &(menuitem){"Redo","[<i>space</i>]",NULL,&_sushiv_panel_undo_up},
+
+  &(menuitem){"",NULL,NULL,NULL},
+
+  &(menuitem){"Start zoom box","[<i>enter</i>]",NULL,&wrap_enter},
+  &(menuitem){"Clear readout","[<i>escape</i>]",NULL,&wrap_escape},
+
+  &(menuitem){"",NULL,NULL,NULL},
+
+  &(menuitem){"Background","...",NULL,NULL},
+  &(menuitem){"Text color","...",NULL,NULL},
+  &(menuitem){"Scales","...",NULL,NULL},
+
+  &(menuitem){"",NULL,NULL,NULL},
+
+  &(menuitem){"Quit","[<i>q</i>]",NULL,&wrap_exit},
+
+  &(menuitem){NULL,NULL,NULL,NULL}
+};
+
+static menuitem *menu_bg[]={
+  &(menuitem){"<span foreground=\"white\">white</span>",NULL,NULL,&white_bg},
+  &(menuitem){"<span foreground=\"black\">black</span>",NULL,NULL,&black_bg},
+  &(menuitem){"checks",NULL,NULL,&checked_bg},
+  &(menuitem){NULL,NULL,NULL,NULL}
+};
+
+static menuitem *menu_text[]={
+  &(menuitem){"<span foreground=\"black\">black</span>",NULL,NULL,&black_text},
+  &(menuitem){"<span foreground=\"white\">white</span>",NULL,NULL,&white_text},
+  &(menuitem){NULL,NULL,NULL,NULL}
+};
+
+static menuitem *menu_scales[]={
+  &(menuitem){"grid",NULL,NULL,grid_scale},
+  &(menuitem){"tics",NULL,NULL,tic_scale},
+  &(menuitem){"none",NULL,NULL,no_scale},
+  &(menuitem){NULL,NULL,NULL,NULL}
+};
+
+void _sushiv_panel_update_menus(sushiv_panel_t *p){
+
+  // is undo active?
+  if(!p->sushi->private->undo_stack ||
+     !p->sushi->private->undo_level){
+    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),0),FALSE);
+  }else{
+    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),0),TRUE);
+  }
+
+  // is redo active?
+  if(!p->sushi->private->undo_stack ||
+     !p->sushi->private->undo_stack[p->sushi->private->undo_level] ||
+     !p->sushi->private->undo_stack[p->sushi->private->undo_level+1]){
+    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),1),FALSE);
+  }else{
+    gtk_widget_set_sensitive(gtk_menu_get_item(GTK_MENU(p->private->popmenu),1),TRUE);
+  }
+
+  // are we starting or enacting a zoom box?
+  if(p->private->oldbox_active){ 
+    gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),3,"Zoom to box");
+  }else{
+    gtk_menu_alter_item_label(GTK_MENU(p->private->popmenu),3,"Start zoom box");
+  }
+
+  // make sure menu reflects plot configuration
+  switch(p->private->bg_type){ 
+  case SUSHIV_BG_WHITE:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),6,menu_bg[0]->left);
+    break;
+  case SUSHIV_BG_BLACK:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),6,menu_bg[1]->left);
+    break;
+  default:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),6,menu_bg[2]->left);
+    break;
+  }
+
+  switch(PLOT(p->private->graph)->bg_inv){ 
+  case 0:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),7,menu_text[0]->left);
+    break;
+  default:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),7,menu_text[1]->left);
+    break;
+  }
+
+  switch(PLOT(p->private->graph)->grid_mode){ 
+  case PLOT_GRID_NORMAL:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),8,menu_scales[0]->left);
+    break;
+  case PLOT_GRID_TICS:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),8,menu_scales[1]->left);
+    break;
+  default:
+    gtk_menu_alter_item_right(GTK_MENU(p->private->popmenu),8,menu_scales[2]->left);
+    break;
+  }
+}
+
 void _sushiv_realize_panel(sushiv_panel_t *p){
   if(!p->private->realized){
     p->private->realize(p);
     p->private->realized=1;
+
+    // generic things that happen in all panel realizations...
+
+    // text black or white in the plot?
+    decide_text_inv(p);
+
+    // panel right-click menus
+    GtkWidget *bgmenu = gtk_menu_new_twocol(NULL,menu_bg,p);
+    GtkWidget *textmenu = gtk_menu_new_twocol(NULL,menu_text,p);
+    GtkWidget *scalemenu = gtk_menu_new_twocol(NULL,menu_scales,p);
+
+    // not thread safe, we're not threading yet
+    menu[6]->submenu = bgmenu;
+    menu[7]->submenu = textmenu;
+    menu[8]->submenu = scalemenu;
+
+    p->private->popmenu = gtk_menu_new_twocol(p->private->toplevel, menu, p);
+    _sushiv_panel_update_menus(p);
+
   }
 }
 
@@ -147,21 +359,68 @@
   gdk_threads_leave ();
 }
 
-extern int sushiv_panel_oversample(sushiv_instance_t *s,
-				   int number,
-				   int numer,
-				   int denom){
+int sushiv_panel_oversample(sushiv_instance_t *s,
+			    int number,
+			    int numer,
+			    int denom){
+  
+  if(number<0){
+    fprintf(stderr,"sushiv_panel_background: Panel number must be >= 0\n");
+    return -EINVAL;
+  }
 
+  if(number>s->panels || !s->panel_list[number]){
+    fprintf(stderr,"sushiv_panel_background: Panel number %d does not exist\n",number);
+    return -EINVAL;
+  }
+  
   sushiv_panel_t *p = s->panel_list[number];
   sushiv_panel_internal_t *pi = p->private;
 
-  if(denom == 0)return -EINVAL;
+  if(denom == 0){
+    fprintf(stderr,"sushiv_panel_oversample: A denominator of zero is invalid\n");
+    return -EINVAL;
+  }
 
   pi->oversample_n = numer;
   pi->oversample_d = denom;
+  recompute_if_running(p);
   return 0;
 }
 
+void render_checks(ucolor *c, int w, int y){
+  /* default checked background */
+  /* 16x16 'mid-checks' */ 
+  int x,j;
+  
+  int phase = (y>>4)&1;
+  for(x=0;x<w;){
+    u_int32_t phaseval = 0xff505050UL;
+    if(phase) phaseval = 0xff808080UL;
+    for(j=0;j<16 && x<w;j++,x++)
+      c[x].u = phaseval;
+    phase=!phase;
+  }
+}
+
+int sushiv_panel_background(sushiv_instance_t *s,
+			    int number,
+			    enum sushiv_background bg){
+
+  if(number<0){
+    fprintf(stderr,"sushiv_panel_background: Panel number must be >= 0\n");
+    return -EINVAL;
+  }
+
+  if(number>s->panels || !s->panel_list[number]){
+    fprintf(stderr,"sushiv_panel_background: Panel number %d does not exist\n",number);
+    return -EINVAL;
+  }
+  
+  sushiv_panel_t *p = s->panel_list[number];
+  return _sushiv_panel_background_i(p,bg);
+}
+
 int _sushiv_new_panel(sushiv_instance_t *s,
 		      int number,
 		      const char *name, 

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/plot.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -50,7 +50,29 @@
   }
 }
 
-static void draw_scales_work(cairo_surface_t *s, 
+void plot_set_bg_invert(Plot *p, int setp){
+  p->bg_inv = setp;
+}
+
+void plot_set_grid(Plot *p, int mode){
+  p->grid_mode = mode;
+}
+
+static void set_text(int inv, cairo_t *c){
+  if(inv)
+    cairo_set_source_rgba(c,1.,1.,1.,1.);
+  else
+    cairo_set_source_rgba(c,0.,0.,0.,1.);
+}
+
+static void set_shadow(int inv, cairo_t *c){
+  if(inv)
+    cairo_set_source_rgba(c,0.,0.,0.,.5);
+  else
+    cairo_set_source_rgba(c,1.,1.,1.,.5);
+}
+
+static void draw_scales_work(cairo_surface_t *s, int inv_text,
 			     scalespace xs, scalespace ys,
 			     scalespace xs_v, scalespace ys_v){
 
@@ -73,7 +95,7 @@
   cairo_set_operator(c,CAIRO_OPERATOR_XOR); 
 
   cairo_set_line_width(c,1.);
-  cairo_set_source_rgba(c,.7,.7,1.,.3);
+  cairo_set_source_rgba(c,.5,.5,7.,.5);
 
   i=0;
   x = scale_demark(&xs, &xs_v, i++, NULL);
@@ -114,11 +136,11 @@
       double yy = y+.5-(extents.height/2 + extents.y_bearing);
 
       cairo_move_to(c,2, yy);
-      cairo_set_source_rgba(c,0,0,0,.5);
+      set_shadow(inv_text,c);
       cairo_text_path (c, buffer);  
       cairo_stroke(c);
       
-      cairo_set_source_rgba(c,1.,1.,1.,1.);
+      set_text(inv_text,c);
       cairo_move_to(c,2, yy);
       cairo_show_text (c, buffer);
     }
@@ -137,12 +159,12 @@
     cairo_text_extents (c, ys.legend, &extents);
     
     cairo_move_to(c,h/2 - extents.width/2+extents.x_bearing, y_width-extents.y_bearing+5);
-    cairo_set_source_rgba(c,0,0,0,.5);
+    set_shadow(inv_text,c);
     cairo_text_path (c, ys.legend);  
     cairo_stroke(c);
     
     cairo_move_to(c,h/2 - extents.width/2+extents.x_bearing, y_width-extents.y_bearing+5);
-    cairo_set_source_rgba(c,1.,1.,1.,1.);
+    set_text(inv_text,c);
     cairo_show_text (c, ys.legend);
   }
 
@@ -158,12 +180,12 @@
     if(x - extents.height > y_width+5 ){
 
       cairo_move_to(c,2, x+.5-(extents.height/2 + extents.y_bearing));
-      cairo_set_source_rgba(c,0,0,0,.5);
+      set_shadow(inv_text,c);
       cairo_text_path (c, buffer);  
       cairo_stroke(c);
       
       cairo_move_to(c,2, x+.5-(extents.height/2 + extents.y_bearing));
-      cairo_set_source_rgba(c,1.,1.,1.,1.);
+      set_text(inv_text,c);
       cairo_show_text (c, buffer);
     }
 
@@ -177,12 +199,14 @@
     cairo_text_extents (c, xs.legend, &extents);
     
     cairo_move_to(c,w/2 - extents.width/2+extents.x_bearing, h - x_height+ extents.y_bearing-5);
-    cairo_set_source_rgba(c,0,0,0,.5);
+    set_shadow(inv_text,c);
+    cairo_set_source_rgba(c,1,1,1,.5);
     cairo_text_path (c, xs.legend);  
     cairo_stroke(c);
     
     cairo_move_to(c,w/2 - extents.width/2+extents.x_bearing, h - x_height+ extents.y_bearing-5);
-    cairo_set_source_rgba(c,1.,1.,1.,1.);
+    set_text(inv_text,c);
+    cairo_set_source_rgba(c,0.,0.,0.,1.);
     cairo_show_text (c, xs.legend);
   }
 
@@ -201,6 +225,7 @@
     cairo_text_extents_t extents;
     
     gdk_threads_enter();
+    int inv = p->bg_inv;
     int n = p->legend_entries;
     char *buffer[n];
     u_int32_t colors[n];
@@ -239,15 +264,19 @@
       cairo_move_to(c,x, y);
       cairo_text_path (c, buffer[i]); 
 
-      cairo_set_source_rgba(c,0,0,0,.5);
+      set_shadow(inv,c);
       cairo_set_line_width(c,3);
       cairo_stroke(c);
 
-      cairo_set_source_rgba(c,
-			    ((colors[i]>>16)&0xff)/255.,
-			    ((colors[i]>>8)&0xff)/255.,
-			    ((colors[i])&0xff)/255.,
-			    ((colors[i]>>24)&0xff)/255.);
+      if(colors[i] == 0xffffffffUL){
+	set_text(inv,c);
+      }else{
+	cairo_set_source_rgba(c,
+			      ((colors[i]>>16)&0xff)/255.,
+			      ((colors[i]>>8)&0xff)/255.,
+			      ((colors[i])&0xff)/255.,
+			      ((colors[i]>>24)&0xff)/255.);
+      }
       cairo_move_to(c,x, y);
       cairo_show_text (c, buffer[i]);
 
@@ -272,9 +301,10 @@
   int w = GTK_WIDGET(p)->allocation.width;
   int h = GTK_WIDGET(p)->allocation.height;
   cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,w,h);
+  int inv = p->bg_inv;
   gdk_threads_leave();
   
-  draw_scales_work(s,x,y,xv,yv);
+  draw_scales_work(s,inv,x,y,xv,yv);
   draw_legend_work(p,s);
   
   gdk_threads_enter();
@@ -373,7 +403,8 @@
     if(p->cross_active){
       double sx = plot_get_crosshair_xpixel(p);
       double sy = plot_get_crosshair_ypixel(p);
-      cairo_set_source_rgba(c,1.,1.,1.,.8);
+
+      cairo_set_source_rgba(c,.7,.7,.0,.9);
       cairo_set_line_width(c,1.);
 
       if(! (p->flags & PLOT_NO_Y_CROSS)){
@@ -395,15 +426,15 @@
 
       cairo_rectangle(c,vals[0],vals[1],vals[2]+1,vals[3]+1);	
       if(p->box_active>1)
-	cairo_set_source_rgba(c,1.,1.,.6,.4);
+	cairo_set_source_rgba(c,.8,.8,.2,.5);
       else
-	cairo_set_source_rgba(c,1.,1.,1.,.3);
+	cairo_set_source_rgba(c,.7,.7,.5,.4);
       cairo_fill(c);
       cairo_rectangle(c,vals[0]+.5,vals[1]+.5,vals[2],vals[3]);
       if(p->box_active>1)
-	cairo_set_source_rgba(c,1.,1.,.6,.9);
+	cairo_set_source_rgba(c,.8,.8,.2,.9);
       else
-	cairo_set_source_rgba(c,1.,1.,1.,.8);
+	cairo_set_source_rgba(c,.8,.8,.2,.8);
       cairo_stroke(c);
     }
 
@@ -686,6 +717,7 @@
   p->cross_active=0;
   plot_legend_clear(p);
   plot_draw_scales(p);
+  plot_expose_request(p);
 }
 
 static gboolean key_press(GtkWidget *widget,
@@ -873,6 +905,7 @@
   p->box_callback = box_callback;
   p->box_data = box_data;
   p->flags = flags;
+  p->grid_mode = PLOT_GRID_NORMAL;
 
   return p;
 }
@@ -1035,22 +1068,3 @@
     p->legend_list[p->legend_entries-1] = strdup("");
   p->legend_colors[p->legend_entries-1] = color;
 }
-
-void plot_replace_data(Plot *p, u_int32_t *data){
-  gdk_threads_enter();
-  GtkWidget *widget = GTK_WIDGET(p);
-
-  if (p->back)
-    cairo_surface_destroy(p->back);
-  if(p->datarect)
-    free(p->datarect);
-  
-  p->datarect = data;  
-  p->back = cairo_image_surface_create_for_data ((unsigned char *)p->datarect,
-						 CAIRO_FORMAT_RGB24,
-						 widget->allocation.width,
-						 widget->allocation.height,
-						 widget->allocation.width*4);
-  gdk_threads_leave();
-}
-

Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/plot.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -44,6 +44,8 @@
   cairo_surface_t *fore;
   cairo_surface_t *stage;
   int widgetfocus;
+  int bg_inv;
+  int grid_mode;
 
   int scalespacing;
   scalespace x;
@@ -93,6 +95,7 @@
 G_END_DECLS
 
 // the widget subclass half
+void plot_set_bg_invert(Plot *p, int setp);
 void plot_expose_request(Plot *p);
 void plot_expose_request_partial(Plot *p,int x, int y, int w, int h);
 void plot_set_x_scale(Plot *p, scalespace x);
@@ -113,10 +116,13 @@
 void plot_legend_clear(Plot *p);
 int plot_get_crosshair_xpixel(Plot *p);
 int plot_get_crosshair_ypixel(Plot *p);
-void plot_replace_data(Plot *p, u_int32_t *d);
+void plot_set_grid(Plot *p, int mode);
 
 void plot_do_enter(Plot *p);
 void plot_do_escape(Plot *p);
 
 #define PLOT_NO_X_CROSS 1
 #define PLOT_NO_Y_CROSS 2
+
+#define PLOT_GRID_NORMAL 4
+#define PLOT_GRID_TICS   8

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/slider.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -70,16 +70,26 @@
 
 double shades[] = {1.15, 0.95, 0.896, 0.82, 0.7, 0.665, 0.5, 0.45, 0.4};
 
-static void set_shade(GtkWidget *w, cairo_t *c, int shade){
+static void bg_set(GtkWidget *w, cairo_t *c){
   Slice *sl = SLICE(w);
   GdkColor *bg = &w->style->bg[sl->thumb_state?GTK_STATE_ACTIVE:GTK_STATE_NORMAL];
-  double shade_r=bg->red*shades[shade]/65535;
-  double shade_g=bg->green*shades[shade]/65535;
-  double shade_b=bg->blue*shades[shade]/65535;
+  double shade_r=bg->red/65535.;
+  double shade_g=bg->green/65535.;
+  double shade_b=bg->blue/65535.;
 
   cairo_set_source_rgb (c, shade_r,shade_g,shade_b);
 }
 
+static void fg_shade(GtkWidget *w, cairo_t *c, int shade){
+  Slice *sl = SLICE(w);
+  GdkColor *fg = &w->style->fg[sl->thumb_state?GTK_STATE_ACTIVE:GTK_STATE_NORMAL];
+  double shade_r=fg->red*shades[shade]/65535;
+  double shade_g=fg->green*shades[shade]/65535;
+  double shade_b=fg->blue*shades[shade]/65535;
+
+  cairo_set_source_rgb (c, shade_r,shade_g,shade_b);
+}
+
 static void parent_shade(Slider *s, cairo_t *c, int shade){
   GtkWidget *parent=gtk_widget_get_parent(s->slices[0]);
   GdkColor *bg = &parent->style->bg[GTK_STATE_NORMAL];
@@ -93,12 +103,12 @@
 void slider_draw_background(Slider *s){
   int i;
   GtkWidget *parent=gtk_widget_get_parent(s->slices[0]);
-  GdkColor *fg = &s->slices[0]->style->fg[0];
+  GdkColor *text = &s->slices[0]->style->text[0];
   GdkColor *bg = &parent->style->bg[0];
   int textborder=1;
-  double textr=1.;
-  double textg=1.;
-  double textb=1.;
+  double textr=text->red;
+  double textg=text->green;
+  double textb=text->blue;
 
   int x=0;
   int y=0;
@@ -120,7 +130,7 @@
   cairo_fill(c);
 
   cairo_rectangle (c, x+1, ty, w-2, th);
-  parent_shade(s,c,3);
+  bg_set(s->slices[0],c);
   cairo_fill (c);
   cairo_surface_flush(s->background);
 
@@ -139,9 +149,6 @@
  
   }else{
     // normal background
-    textr=fg->red;
-    textg=fg->green;
-    textb=fg->blue;
     textborder=0;
   }
 
@@ -186,14 +193,14 @@
     }
 
     if(textborder){
-      cairo_set_source_rgba(c,0,0,0,.8);
-      cairo_set_line_width(c,2);
+      cairo_set_source_rgba(c,1.,1.,1.,.5);
+      cairo_set_line_width(c,2.5);
       cairo_move_to (c, x,y);
       cairo_text_path (c, s->label[i]); 
       cairo_stroke(c);
     }
 
-    cairo_set_source_rgba(c,textr,textg,textb,.8);
+    cairo_set_source_rgba(c,textr,textg,textb,1.);
     cairo_move_to (c, x,y);
     cairo_show_text (c, s->label[i]); 
   }
@@ -316,11 +323,11 @@
 	cairo_arc_negative(c, x-xd+rx, rad+.5, rad, 270.*(M_PI/180.), 150.*(M_PI/180.));
 	cairo_close_path(c);
 	
-	set_shade(sl,c,2);
+	fg_shade(sl,c,2);
 	cairo_fill_preserve(c);
 
 	cairo_set_line_width(c,1);
-	set_shade(sl,c,7);
+	fg_shade(sl,c,7);
       
 	if(((Slice *)s->slices[i])->thumb_focus)
 	  cairo_set_source_rgba(c,0,0,0,1);
@@ -369,10 +376,10 @@
 	  cairo_line_to(c, x, h-.5);
 	  cairo_close_path(c);
 	
-	  set_shade(sl,c,2);
+	  fg_shade(sl,c,2);
 	  cairo_set_line_width(c,1);
 	  cairo_fill_preserve(c);
-	  set_shade(sl,c,7);
+	  fg_shade(sl,c,7);
 	  if(((Slice *)s->slices[i])->thumb_focus)
 	    cairo_set_source_rgba(c,0,0,0,1);
 	  cairo_stroke_preserve(c);
@@ -403,10 +410,10 @@
 	  cairo_line_to(c, x, h-.5);
 	  cairo_close_path(c);
 	
-	  set_shade(sl,c,2);
+	  fg_shade(sl,c,2);
 	  cairo_set_line_width(c,1);
 	  cairo_fill_preserve(c);
-	  set_shade(sl,c,7);
+	  fg_shade(sl,c,7);
 	  if(((Slice *)s->slices[i])->thumb_focus)
 	    cairo_set_source_rgba(c,0,0,0,1);
 	  cairo_stroke_preserve(c);
@@ -492,6 +499,7 @@
   if(x0+x1*1.2 > maxx)maxx=(x0+x1)*1.2;
 
   w = (maxx+2)*s->labels+4;
+  if(w<200)w=200;
   requisition->width = (w+s->num_slices-1)/s->num_slices;
   requisition->height = maxy+4+s->ypad*2;
 

Modified: trunk/sushivision/sushi-gtkrc.in
===================================================================
--- trunk/sushivision/sushi-gtkrc.in	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/sushi-gtkrc.in	2007-02-21 08:27:29 UTC (rev 12499)
@@ -20,6 +20,39 @@
 
 }
 
+style "slider-poppy" {
+	bg[NORMAL]="#c0c0c0" 
+	bg[ACTIVE]="#c0c0c0" 
+	bg[PRELIGHT]="#c0c0c0" 
+
+	fg[NORMAL]="#80a0ff" 
+	fg[ACTIVE]="#c0f0ff" 
+	fg[PRELIGHT]="#c0f0ff" 
+
+	text[NORMAL]="#000000"
+	text[ACTIVE]="#000000"
+	text[PRELIGHT]="#000000" 
+
+	font_name = "sans 8"
+
+	GtkWidget::focus_line_width = 1
+	GtkWidget::focus_padding = 0 
+	GtkWidget::interior_focus = 0 
+	GtkWidget::internal_padding = 0 
+
+}
+
+style "panel" {
+	bg[NORMAL]="#a0a0a0" 
+	bg[ACTIVE]="#c0f0ff" 
+	bg[PRELIGHT]="#c0f0ff" 
+
+	text[INSENSITIVE]="#606060"
+	text[NORMAL]="#000000"
+	text[ACTIVE]="#000000"
+	text[PRELIGHT]="#000000" 
+}
+
 style "panel-text" {
 	font_name = "sans 9"
 }
@@ -37,6 +70,7 @@
 	font_name = "Fixed, Nimbus Mono L, Courier, Monospace 10"	
 }
 
+widget "*" style "panel"
 widget "*.GtkLabel" style "panel-text"
 widget "*.GtkFrame.GtkLabel" style "frame-label"
 widget "*.GtkFrame.GtkHBox.GtkLabel" style "frame-label"
@@ -45,4 +79,4 @@
 widget "*.GtkComboBox*" style "button-poppy"
 widget "*.GtkToggleButton*" style "button-poppy"
 widget "*.GtkButton*" style "button-poppy"
-widget "*.Slider" style "button-poppy"
+widget "*.Slider" style "slider-poppy"

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/sushivision.h	2007-02-21 08:27:29 UTC (rev 12499)
@@ -128,6 +128,9 @@
 enum sushiv_panel_type { SUSHIV_PANEL_1D, 
 			 SUSHIV_PANEL_2D, 
 			 SUSHIV_PANEL_XY };
+enum sushiv_background { SUSHIV_BG_WHITE, 
+			 SUSHIV_BG_BLACK, 
+			 SUSHIV_BG_CHECKS };
 typedef union sushiv_panel_subtype sushiv_panel_subtype_t;
 
 typedef struct {
@@ -252,6 +255,10 @@
 				   int numer,
 				   int denom);
 
+extern int sushiv_panel_background(sushiv_instance_t *s,
+				   int number,
+				   enum sushiv_background bg);
+
 extern int sushiv_submain(int argc, char *argv[]);
 extern int sushiv_atexit(void);
 

Modified: trunk/sushivision/undo.c
===================================================================
--- trunk/sushivision/undo.c	2007-02-20 10:17:02 UTC (rev 12498)
+++ trunk/sushivision/undo.c	2007-02-21 08:27:29 UTC (rev 12499)
@@ -33,7 +33,7 @@
   if(s->panel_list){
     for(i=0;i<s->panels;i++)
       if(s->panel_list[i])
-	s->panel_list[i]->private->update_menus(s->panel_list[i]);
+	_sushiv_panel_update_menus(s->panel_list[i]);
   }
 }
 



More information about the commits mailing list