[xiph-commits] r12516 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Fri Feb 23 22:10:39 PST 2007
Author: xiphmont
Date: 2007-02-23 22:10:35 -0800 (Fri, 23 Feb 2007)
New Revision: 12516
Modified:
trunk/sushivision/dimension.c
trunk/sushivision/dimension.h
trunk/sushivision/internal.h
trunk/sushivision/main.c
trunk/sushivision/panel-2d.c
trunk/sushivision/panel-2d.h
trunk/sushivision/plot.c
trunk/sushivision/plot.h
trunk/sushivision/slice.c
trunk/sushivision/slice.h
trunk/sushivision/sushi-gtkrc.in
Log:
Implement expanders for text entry of numeric dimension values; 1d
panels have not been restructured for correct expansion yet, but
otherwise the infrastruture is centralized.
Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/dimension.c 2007-02-24 06:10:35 UTC (rev 12516)
@@ -65,7 +65,6 @@
dimneg = 1;
}
-
switch(d->type){
case SUSHIV_DIM_CONTINUOUS:
{
@@ -226,6 +225,7 @@
sushiv_dimension_t *d = dw->dl->d;
sushiv_panel_t *p = dw->dl->p;
double val = slider_get_value(dw->scale,1);
+ char buffer[80];
val = discrete_quantize_val(d,val);
dw->center_updating = 1;
@@ -235,11 +235,18 @@
_sushiv_panel_undo_suspend(p);
}
+ snprintf(buffer,80,"%.10g",d->bracket[0]);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[0]),buffer);
+ snprintf(buffer,80,"%.10g",val);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[1]),buffer);
+ snprintf(buffer,80,"%.10g",d->bracket[1]);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[2]),buffer);
+
if(d->val != val){
int i;
-
+
d->val = val;
-
+
/* dims can be shared amongst multiple widgets; all must be updated */
for(i=0;i<d->private->widgets;i++){
sushiv_dim_widget_t *w = d->private->widget_list[i];
@@ -272,7 +279,8 @@
sushiv_panel_t *p = dw->dl->p;
double lo = slider_get_value(dw->scale,0);
double hi = slider_get_value(dw->scale,2);
-
+ char buffer[80];
+
hi = discrete_quantize_val(d,hi);
lo = discrete_quantize_val(d,lo);
@@ -282,6 +290,13 @@
_sushiv_panel_undo_push(p);
_sushiv_panel_undo_suspend(p);
}
+
+ snprintf(buffer,80,"%.10g",lo);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[0]),buffer);
+ snprintf(buffer,80,"%.10g",d->val);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[1]),buffer);
+ snprintf(buffer,80,"%.10g",hi);
+ gtk_entry_set_text(GTK_ENTRY(dw->entry[2]),buffer);
if(d->bracket[0] != lo || d->bracket[1] != hi){
int i;
@@ -437,6 +452,83 @@
slider_set_thumb_active(dw->scale,thumb,active);
}
+static int expander_level = 0; // avoid races due to calling main_loop internally
+static int expander_loop = 0;
+
+static void expander_callback (GtkExpander *expander, sushiv_dim_widget_t *dw){
+ expander_level++;
+ if(expander_level==1){
+
+ // do not allow the Plot to resize
+ plot_resizable(PLOT(dw->dl->p->private->graph),0);
+
+ do{
+ expander_loop = 0;
+
+ // Prevent the resizing algorithm from frobbing the plot's box
+ gtk_box_freeze_child (GTK_BOX(dw->dl->p->private->topbox),
+ dw->dl->p->private->plotbox);
+
+ // allow the toplevel to resize automatically
+ gtk_window_set_policy (GTK_WINDOW (dw->dl->p->private->toplevel), FALSE, FALSE, TRUE);
+
+ if (gtk_expander_get_expanded (expander)){
+ gtk_widget_show(dw->entry[0]);
+ gtk_widget_show(dw->entry[1]);
+ gtk_widget_show(dw->entry[2]);
+ }else{
+ gtk_widget_hide(dw->entry[0]);
+ gtk_widget_hide(dw->entry[1]);
+ gtk_widget_hide(dw->entry[2]);
+ }
+
+ // process this change
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+ gdk_flush();
+ }
+
+ // revert toplevel to user-resizing
+ gtk_window_set_policy (GTK_WINDOW (dw->dl->p->private->toplevel), FALSE, TRUE, FALSE);
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+ gdk_flush();
+ }
+
+ // revert plot box to autofilling if user alters window size
+ gtk_box_unfreeze_child(GTK_BOX(dw->dl->p->private->topbox),
+ dw->dl->p->private->plotbox);
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+ gdk_flush();
+ }
+
+ } while(expander_loop);
+
+ // lastly, allow plot to resize again
+ plot_resizable(PLOT(dw->dl->p->private->graph),1);
+
+ }else
+ expander_loop=1;
+
+ expander_level--;
+}
+
+static void entry_callback (GtkEntry *entry, Slice *s){
+ slice_thumb_set(s, atof(gtk_entry_get_text(entry)));
+}
+
+static gboolean entry_refresh_callback (GtkEntry *entry, GdkEventFocus *event, Slice *s){
+ char buffer[80];
+ snprintf(buffer,80,"%.10g",s->thumb_val);
+ gtk_entry_set_text(entry,buffer);
+ return FALSE;
+}
+
+static void entry_active_callback(void *e, int active){
+ gtk_widget_set_sensitive(GTK_WIDGET(e),active);
+}
+
sushiv_dim_widget_t *_sushiv_new_dimension_widget(sushiv_dimension_list_t *dl,
void (*center_callback)(sushiv_dimension_list_t *),
void (*bracket_callback)(sushiv_dimension_list_t *)){
@@ -455,7 +547,9 @@
{
double v[3];
GtkWidget **sl = calloc(3,sizeof(*sl));
- dw->t = GTK_TABLE(gtk_table_new(1,3,0));
+ GtkWidget *exp = gtk_expander_new(NULL);
+ GtkTable *st = GTK_TABLE(gtk_table_new(2,4,0));
+
v[0]=d->bracket[0];
v[1]=d->val;
v[2]=d->bracket[1];
@@ -463,14 +557,34 @@
sl[0] = slice_new(_sushiv_dimension_bracket_callback,dw);
sl[1] = slice_new(_sushiv_dimension_center_callback,dw);
sl[2] = slice_new(_sushiv_dimension_bracket_callback,dw);
-
- gtk_table_attach(dw->t,sl[0],0,1,0,1,
+ dw->entry[0] = gtk_entry_new();
+ dw->entry[1] = gtk_entry_new();
+ dw->entry[2] = gtk_entry_new();
+
+ gtk_entry_set_width_chars(GTK_ENTRY(dw->entry[0]),0);
+ gtk_entry_set_width_chars(GTK_ENTRY(dw->entry[1]),0);
+ gtk_entry_set_width_chars(GTK_ENTRY(dw->entry[2]),0);
+
+ gtk_table_attach(st,exp,0,1,0,1,
+ GTK_SHRINK,0,0,0);
+
+ gtk_table_attach(st,sl[0],1,2,0,1,
GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(dw->t,sl[1],1,2,0,1,
+ gtk_table_attach(st,sl[1],2,3,0,1,
GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(dw->t,sl[2],2,3,0,1,
+ gtk_table_attach(st,sl[2],3,4,0,1,
GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_widget_set_no_show_all(dw->entry[0], TRUE);
+ gtk_widget_set_no_show_all(dw->entry[1], TRUE);
+ gtk_widget_set_no_show_all(dw->entry[2], TRUE);
+ gtk_table_attach(st,dw->entry[0],1,2,1,2,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(st,dw->entry[1],2,3,1,2,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(st,dw->entry[2],3,4,1,2,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+
dw->scale = slider_new((Slice **)sl,3,d->scale->label_list,d->scale->val_list,
d->scale->vals,0);
if(d->type == SUSHIV_DIM_DISCRETE)
@@ -479,11 +593,34 @@
slice_thumb_set((Slice *)sl[0],v[0]);
slice_thumb_set((Slice *)sl[1],v[1]);
slice_thumb_set((Slice *)sl[2],v[2]);
+
+ g_signal_connect_after (G_OBJECT (exp), "activate",
+ G_CALLBACK (expander_callback), dw);
+
+ g_signal_connect (G_OBJECT (dw->entry[0]), "activate",
+ G_CALLBACK (entry_callback), sl[0]);
+ g_signal_connect (G_OBJECT (dw->entry[1]), "activate",
+ G_CALLBACK (entry_callback), sl[1]);
+ g_signal_connect (G_OBJECT (dw->entry[2]), "activate",
+ G_CALLBACK (entry_callback), sl[2]);
+
+ g_signal_connect (G_OBJECT (dw->entry[0]), "focus-out-event",
+ G_CALLBACK (entry_refresh_callback), sl[0]);
+ g_signal_connect (G_OBJECT (dw->entry[1]), "focus-out-event",
+ G_CALLBACK (entry_refresh_callback), sl[1]);
+ g_signal_connect (G_OBJECT (dw->entry[2]), "focus-out-event",
+ G_CALLBACK (entry_refresh_callback), sl[2]);
+
+ slice_set_active_callback((Slice *)sl[0], entry_active_callback, dw->entry[0]);
+ slice_set_active_callback((Slice *)sl[1], entry_active_callback, dw->entry[1]);
+ slice_set_active_callback((Slice *)sl[2], entry_active_callback, dw->entry[2]);
+
+ dw->t = GTK_WIDGET(st);
}
break;
case SUSHIV_DIM_PICKLIST:
/* picklist dimensions get a wide dropdown */
- dw->t = GTK_TABLE(gtk_table_new(1,1,0));
+ dw->t = gtk_table_new(1,1,0);
{
int j;
@@ -494,8 +631,8 @@
g_signal_connect (G_OBJECT (dw->menu), "changed",
G_CALLBACK (_sushiv_dimension_dropdown_callback), dw);
- gtk_table_attach(dw->t,dw->menu,0,1,0,1,
- GTK_EXPAND|GTK_FILL,GTK_SHRINK,0,0);
+ gtk_table_attach(GTK_TABLE(dw->t),dw->menu,0,1,0,1,
+ GTK_EXPAND|GTK_FILL,GTK_SHRINK,0,2);
_sushiv_dimension_set_value(dw,1,d->val);
//gtk_combo_box_set_active(GTK_COMBO_BOX(dw->menu),0);
}
Modified: trunk/sushivision/dimension.h
===================================================================
--- trunk/sushivision/dimension.h 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/dimension.h 2007-02-24 06:10:35 UTC (rev 12516)
@@ -22,11 +22,12 @@
typedef struct {
sushiv_dimension_list_t *dl;
- GtkTable *t;
+ GtkWidget *t;
/* one or the other */
Slider *scale;
GtkWidget *menu;
+ GtkWidget *entry[3];
/* don't rely on intuited state; that could be fragile. If we don't
want updates to recurse, be explicit about it! */
Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/internal.h 2007-02-24 06:10:35 UTC (rev 12516)
@@ -63,6 +63,8 @@
struct sushiv_panel_internal {
GtkWidget *toplevel;
+ GtkWidget *topbox;
+ GtkWidget *plotbox;
GtkWidget *graph;
Spinner *spinner;
GtkWidget *popmenu;
Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/main.c 2007-02-24 06:10:35 UTC (rev 12516)
@@ -212,6 +212,7 @@
ret = sushiv_submain(argc,argv);
if(ret)return ret;
+ gdk_threads_enter();
sushiv_realize_all();
gtk_button3_fixup();
@@ -225,7 +226,6 @@
signal(SIGINT,_sushiv_clean_exit);
//signal(SIGSEGV,_sushiv_clean_exit);
- gdk_threads_enter();
gtk_main ();
gdk_threads_leave();
Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/panel-2d.c 2007-02-24 06:10:35 UTC (rev 12516)
@@ -1574,32 +1574,72 @@
sushiv_panel_t *p = (sushiv_panel_t *)in;
// sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+ // check if the widget with focus is an Entry
+ GtkWidget *focused = gtk_window_get_focus(GTK_WINDOW(widget));
+ int entryp = (focused?GTK_IS_ENTRY(focused):0);
+
+ // don't swallow modified keypresses
if(event->state&GDK_MOD1_MASK) return FALSE;
if(event->state&GDK_CONTROL_MASK)return FALSE;
-
- /* non-control keypresses */
- switch(event->keyval){
-
- case GDK_Q:
- case GDK_q:
- // quit
- _sushiv_clean_exit(SIGINT);
- return TRUE;
- case GDK_BackSpace:
- // undo
- _sushiv_panel_undo_down(p);
+ if(entryp){
+ // we still filter, but differently
+ switch(event->keyval){
+ case GDK_BackSpace:
+ case GDK_Home:case GDK_KP_Begin:
+ case GDK_End:case GDK_KP_End:
+ case GDK_Up:case GDK_KP_Up:
+ case GDK_Down:case GDK_KP_Down:
+ case GDK_Left:case GDK_KP_Left:
+ case GDK_Right:case GDK_KP_Right:
+ case GDK_minus:case GDK_KP_Subtract:
+ case GDK_plus:case GDK_KP_Add:
+ case GDK_period:case GDK_KP_Decimal:
+ case GDK_0:case GDK_KP_0:
+ case GDK_1:case GDK_KP_1:
+ case GDK_2:case GDK_KP_2:
+ case GDK_3:case GDK_KP_3:
+ case GDK_4:case GDK_KP_4:
+ case GDK_5:case GDK_KP_5:
+ case GDK_6:case GDK_KP_6:
+ case GDK_7:case GDK_KP_7:
+ case GDK_8:case GDK_KP_8:
+ case GDK_9:case GDK_KP_9:
+ case GDK_Tab:case GDK_KP_Tab:
+ case GDK_ISO_Left_Tab:
+ case GDK_Delete:case GDK_KP_Delete:
+ case GDK_Return:case GDK_ISO_Enter:
+ case GDK_Insert:case GDK_KP_Insert:
+ case GDK_e:case GDK_E:
+ return FALSE;
+ }
return TRUE;
- case GDK_r:
- case GDK_space:
- // redo/forward
- _sushiv_panel_undo_up(p);
+ }else{
+
+ /* non-control keypresses */
+ switch(event->keyval){
+
+ case GDK_Q:
+ case GDK_q:
+ // quit
+ _sushiv_clean_exit(SIGINT);
return TRUE;
-
+
+ case GDK_BackSpace:
+ // undo
+ _sushiv_panel_undo_down(p);
+ return TRUE;
+
+ case GDK_r:
+ case GDK_space:
+ // redo/forward
+ _sushiv_panel_undo_up(p);
+ return TRUE;
+
+ }
+ return FALSE;
}
-
- return FALSE;
}
static void _sushiv_realize_panel2d(sushiv_panel_t *p){
@@ -1612,141 +1652,154 @@
g_signal_connect_swapped (G_OBJECT (p->private->toplevel), "delete-event",
G_CALLBACK (_sushiv_clean_exit), (void *)SIGINT);
- p2->top_table = gtk_table_new(3 + p->objectives,5,0);
- gtk_container_add (GTK_CONTAINER (p->private->toplevel), p2->top_table);
+ // add border to sides with hbox/padding
+ GtkWidget *borderbox = gtk_hbox_new(0,0);
+ gtk_container_add (GTK_CONTAINER (p->private->toplevel), borderbox);
+
+ // main layout vbox
+ p->private->topbox = gtk_vbox_new(0,0);
+ gtk_box_pack_start(GTK_BOX(borderbox), p->private->topbox, 0,0,4);
gtk_container_set_border_width (GTK_CONTAINER (p->private->toplevel), 1);
/* spinner, top bar */
{
GtkWidget *hbox = gtk_hbox_new(0,0);
- gtk_table_attach(GTK_TABLE(p2->top_table),hbox,0,5,0,1,GTK_EXPAND|GTK_FILL,0,4,0);
+ gtk_box_pack_start(GTK_BOX(p->private->topbox), hbox, 0,0,0);
gtk_box_pack_end(GTK_BOX(hbox),GTK_WIDGET(p->private->spinner),0,0,0);
}
- /* dims */
- p2->dim_table = gtk_table_new(p->dimensions,4,0);
- gtk_table_attach(GTK_TABLE(p2->top_table),p2->dim_table,0,5,2+p->objectives,3+p->objectives,
- GTK_EXPAND|GTK_FILL,0,4,5);
-
- /* graph */
- p->private->graph = GTK_WIDGET(plot_new(recompute_callback_2d,p,
- (void *)(void *)_sushiv_panel2d_crosshairs_callback,p,
- 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);
+ /* plotbox, graph */
+ {
+ p->private->graph = GTK_WIDGET(plot_new(recompute_callback_2d,p,
+ (void *)(void *)_sushiv_panel2d_crosshairs_callback,p,
+ box_callback,p,0));
+ p->private->plotbox = p->private->graph;
+ gtk_box_pack_start(GTK_BOX(p->private->topbox), p->private->plotbox, 1,1,2);
+ }
- /* objective sliders */
- p2->range_scales = calloc(p->objectives,sizeof(*p2->range_scales));
- p2->range_pulldowns = calloc(p->objectives,sizeof(*p2->range_pulldowns));
- p2->alphadel = calloc(p->objectives,sizeof(*p2->alphadel));
- p2->mappings = calloc(p->objectives,sizeof(*p2->mappings));
- for(i=0;i<p->objectives;i++){
- GtkWidget **sl = calloc(3,sizeof(*sl));
- sushiv_objective_t *o = p->objective_list[i].o;
- int lo = o->scale->val_list[0];
- int hi = o->scale->val_list[o->scale->vals-1];
+ /* obj box */
+ {
+ p2->obj_table = gtk_table_new(p->objectives, 5, 0);
+ gtk_box_pack_start(GTK_BOX(p->private->topbox), p2->obj_table, 0,0,1);
- /* label */
- GtkWidget *label = gtk_label_new(o->name);
- gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
- gtk_table_attach(GTK_TABLE(p2->top_table),label,0,1,i+2,i+3,
- GTK_FILL,0,10,0);
-
- /* mapping pulldown */
- {
- GtkWidget *menu=gtk_combo_box_new_markup();
- int j;
- for(j=0;j<num_mappings();j++)
- gtk_combo_box_append_text (GTK_COMBO_BOX (menu), mapping_name(j));
- gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
- g_signal_connect (G_OBJECT (menu), "changed",
- G_CALLBACK (mapchange_callback_2d), p->objective_list+i);
- gtk_table_attach(GTK_TABLE(p2->top_table),menu,4,5,i+2,i+3,
- GTK_SHRINK,GTK_SHRINK,4,0);
- p2->range_pulldowns[i] = menu;
- }
+ /* objective sliders */
+ p2->range_scales = calloc(p->objectives,sizeof(*p2->range_scales));
+ p2->range_pulldowns = calloc(p->objectives,sizeof(*p2->range_pulldowns));
+ p2->alphadel = calloc(p->objectives,sizeof(*p2->alphadel));
+ p2->mappings = calloc(p->objectives,sizeof(*p2->mappings));
+ for(i=0;i<p->objectives;i++){
+ GtkWidget **sl = calloc(3,sizeof(*sl));
+ sushiv_objective_t *o = p->objective_list[i].o;
+ int lo = o->scale->val_list[0];
+ int hi = o->scale->val_list[o->scale->vals-1];
+
+ /* label */
+ GtkWidget *label = gtk_label_new(o->name);
+ gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
+ gtk_table_attach(GTK_TABLE(p2->obj_table),label,0,1,i,i+1,
+ GTK_FILL,0,10,0);
+
+ /* mapping pulldown */
+ {
+ GtkWidget *menu=gtk_combo_box_new_markup();
+ int j;
+ for(j=0;j<num_mappings();j++)
+ gtk_combo_box_append_text (GTK_COMBO_BOX (menu), mapping_name(j));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+ g_signal_connect (G_OBJECT (menu), "changed",
+ G_CALLBACK (mapchange_callback_2d), p->objective_list+i);
+ gtk_table_attach(GTK_TABLE(p2->obj_table),menu,4,5,i,i+1,
+ GTK_SHRINK,GTK_SHRINK,0,0);
+ p2->range_pulldowns[i] = menu;
+ }
/* the range mapping slices/slider */
- sl[0] = slice_new(map_callback_2d,p->objective_list+i);
- sl[1] = slice_new(map_callback_2d,p->objective_list+i);
- sl[2] = slice_new(map_callback_2d,p->objective_list+i);
+ sl[0] = slice_new(map_callback_2d,p->objective_list+i);
+ sl[1] = slice_new(map_callback_2d,p->objective_list+i);
+ sl[2] = slice_new(map_callback_2d,p->objective_list+i);
+
+ gtk_table_attach(GTK_TABLE(p2->obj_table),sl[0],1,2,i,i+1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(GTK_TABLE(p2->obj_table),sl[1],2,3,i,i+1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ gtk_table_attach(GTK_TABLE(p2->obj_table),sl[2],3,4,i,i+1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+ p2->range_scales[i] = slider_new((Slice **)sl,3,o->scale->label_list,o->scale->val_list,
+ o->scale->vals,SLIDER_FLAG_INDEPENDENT_MIDDLE);
- gtk_table_attach(GTK_TABLE(p2->top_table),sl[0],1,2,i+2,i+3,
- GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p2->top_table),sl[1],2,3,i+2,i+3,
- GTK_EXPAND|GTK_FILL,0,0,0);
- gtk_table_attach(GTK_TABLE(p2->top_table),sl[2],3,4,i+2,i+3,
- GTK_EXPAND|GTK_FILL,0,0,0);
- p2->range_scales[i] = slider_new((Slice **)sl,3,o->scale->label_list,o->scale->val_list,
- o->scale->vals,SLIDER_FLAG_INDEPENDENT_MIDDLE);
-
- slice_thumb_set((Slice *)sl[0],lo);
- slice_thumb_set((Slice *)sl[1],lo);
- slice_thumb_set((Slice *)sl[2],hi);
- mapping_setup(&p2->mappings[i],0.,1.,0);
- slider_set_gradient(p2->range_scales[i], &p2->mappings[i]);
+ slice_thumb_set((Slice *)sl[0],lo);
+ slice_thumb_set((Slice *)sl[1],lo);
+ slice_thumb_set((Slice *)sl[2],hi);
+ mapping_setup(&p2->mappings[i],0.,1.,0);
+ slider_set_gradient(p2->range_scales[i], &p2->mappings[i]);
+ }
}
- GtkWidget *first_x = NULL;
- GtkWidget *first_y = NULL;
- GtkWidget *pressed_y = NULL;
- p->private->dim_scales = calloc(p->dimensions,sizeof(*p->private->dim_scales));
- p2->dim_xb = calloc(p->dimensions,sizeof(*p2->dim_xb));
- p2->dim_yb = calloc(p->dimensions,sizeof(*p2->dim_yb));
-
- for(i=0;i<p->dimensions;i++){
- sushiv_dimension_t *d = p->dimension_list[i].d;
-
- /* label */
- GtkWidget *label = gtk_label_new(d->name);
- gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
- gtk_table_attach(GTK_TABLE(p2->dim_table),label,0,1,i,i+1,
- GTK_FILL,0,10,0);
+ /* dims */
+ {
+ p2->dim_table = gtk_table_new(p->dimensions,4,0);
+ gtk_box_pack_start(GTK_BOX(p->private->topbox), p2->dim_table, 0,0,4);
- /* x/y radio buttons */
- if(!(d->flags & SUSHIV_DIM_NO_X)){
- if(first_x)
- p2->dim_xb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_x),"X");
- else{
- first_x = p2->dim_xb[i] = gtk_radio_button_new_with_label(NULL,"X");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_xb[i]),TRUE);
- }
- gtk_table_attach(GTK_TABLE(p2->dim_table),p2->dim_xb[i],1,2,i,i+1,
- 0,0,10,0);
- }
+ GtkWidget *first_x = NULL;
+ GtkWidget *first_y = NULL;
+ GtkWidget *pressed_y = NULL;
+ p->private->dim_scales = calloc(p->dimensions,sizeof(*p->private->dim_scales));
+ p2->dim_xb = calloc(p->dimensions,sizeof(*p2->dim_xb));
+ p2->dim_yb = calloc(p->dimensions,sizeof(*p2->dim_yb));
- if(!(d->flags & SUSHIV_DIM_NO_Y)){
- if(first_y)
- p2->dim_yb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_y),"Y");
- else
- first_y = p2->dim_yb[i] = gtk_radio_button_new_with_label(NULL,"Y");
- if(!pressed_y && p2->dim_xb[i]!=first_x){
- pressed_y = p2->dim_yb[i];
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_yb[i]),TRUE);
+ for(i=0;i<p->dimensions;i++){
+ sushiv_dimension_t *d = p->dimension_list[i].d;
+
+ /* label */
+ GtkWidget *label = gtk_label_new(d->name);
+ gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
+ gtk_table_attach(GTK_TABLE(p2->dim_table),label,0,1,i,i+1,
+ GTK_FILL,0,5,0);
+
+ /* x/y radio buttons */
+ if(!(d->flags & SUSHIV_DIM_NO_X)){
+ if(first_x)
+ p2->dim_xb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_x),"X");
+ else{
+ first_x = p2->dim_xb[i] = gtk_radio_button_new_with_label(NULL,"X");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_xb[i]),TRUE);
+ }
+ gtk_table_attach(GTK_TABLE(p2->dim_table),p2->dim_xb[i],1,2,i,i+1,
+ GTK_SHRINK,0,3,0);
}
- gtk_table_attach(GTK_TABLE(p2->dim_table),p2->dim_yb[i],2,3,i,i+1,
- 0,0,10,0);
+
+ if(!(d->flags & SUSHIV_DIM_NO_Y)){
+ if(first_y)
+ p2->dim_yb[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_y),"Y");
+ else
+ first_y = p2->dim_yb[i] = gtk_radio_button_new_with_label(NULL,"Y");
+ if(!pressed_y && p2->dim_xb[i]!=first_x){
+ pressed_y = p2->dim_yb[i];
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p2->dim_yb[i]),TRUE);
+ }
+ gtk_table_attach(GTK_TABLE(p2->dim_table),p2->dim_yb[i],2,3,i,i+1,
+ GTK_SHRINK,0,3,0);
+ }
+
+ p->private->dim_scales[i] =
+ _sushiv_new_dimension_widget(p->dimension_list+i,center_callback_2d,bracket_callback_2d);
+
+ gtk_table_attach(GTK_TABLE(p2->dim_table),
+ p->private->dim_scales[i]->t,
+ 3,4,i,i+1,
+ GTK_EXPAND|GTK_FILL,0,0,0);
+
}
-
- p->private->dim_scales[i] =
- _sushiv_new_dimension_widget(p->dimension_list+i,center_callback_2d,bracket_callback_2d);
-
- gtk_table_attach(GTK_TABLE(p2->dim_table),
- GTK_WIDGET(p->private->dim_scales[i]->t),
- 3,4,i,i+1,
- GTK_EXPAND|GTK_FILL,0,0,0);
-
- }
- for(i=0;i<p->dimensions;i++){
- if(p2->dim_xb[i])
- g_signal_connect (G_OBJECT (p2->dim_xb[i]), "toggled",
+ for(i=0;i<p->dimensions;i++){
+ if(p2->dim_xb[i])
+ g_signal_connect (G_OBJECT (p2->dim_xb[i]), "toggled",
G_CALLBACK (dimchange_callback_2d), p);
- if(p2->dim_yb[i])
- g_signal_connect (G_OBJECT (p2->dim_yb[i]), "toggled",
- G_CALLBACK (dimchange_callback_2d), p);
+ if(p2->dim_yb[i])
+ g_signal_connect (G_OBJECT (p2->dim_yb[i]), "toggled",
+ G_CALLBACK (dimchange_callback_2d), p);
+ }
}
+
update_xy_availability(p);
g_signal_connect (G_OBJECT (p->private->toplevel), "key-press-event",
Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/panel-2d.h 2007-02-24 06:10:35 UTC (rev 12516)
@@ -21,7 +21,7 @@
typedef struct sushiv_panel2d {
- GtkWidget *top_table;
+ GtkWidget *obj_table;
GtkWidget *dim_table;
/* only run those functions used by this panel */
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/plot.c 2007-02-24 06:10:35 UTC (rev 12516)
@@ -521,8 +521,14 @@
static void plot_size_request (GtkWidget *widget,
GtkRequisition *requisition){
- requisition->width = 400; // XXX
- requisition->height = 200; // XXX
+ Plot *p = PLOT (widget);
+ if(p->resizable || !p->wc){
+ requisition->width = 400;
+ requisition->height = 200;
+ }else{
+ requisition->width = widget->allocation.width;
+ requisition->height = widget->allocation.height;
+ }
}
static void plot_realize (GtkWidget *widget){
@@ -564,9 +570,11 @@
static void plot_size_allocate (GtkWidget *widget,
GtkAllocation *allocation){
Plot *p = PLOT (widget);
-
+
if (GTK_WIDGET_REALIZED (widget)){
+ if(p->wc && !p->resizable)return;
+
if(p->wc)
cairo_destroy(p->wc);
if (p->fore)
@@ -944,6 +952,7 @@
p->box_data = box_data;
p->flags = flags;
p->grid_mode = PLOT_GRID_NORMAL;
+ p->resizable = 1;
return p;
}
@@ -1106,3 +1115,23 @@
p->legend_list[p->legend_entries-1] = strdup("");
p->legend_colors[p->legend_entries-1] = color;
}
+
+void plot_resizable(Plot *p, int rp){
+ GtkWidget *widget = GTK_WIDGET(p);
+ if(!rp){
+
+ p->resizable = 0;
+ gtk_widget_set_size_request(widget,
+ widget->allocation.width,
+ widget->allocation.height);
+
+ }else{
+ gtk_widget_set_size_request(widget,400,200);
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+ gdk_flush();
+ }
+ p->resizable = 1;
+ }
+}
+
Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/plot.h 2007-02-24 06:10:35 UTC (rev 12516)
@@ -46,6 +46,7 @@
int widgetfocus;
int bg_inv;
int grid_mode;
+ int resizable;
int scalespacing;
scalespace x;
@@ -121,6 +122,8 @@
void plot_do_enter(Plot *p);
void plot_do_escape(Plot *p);
+void plot_resizable(Plot *p, int rp);
+
#define PLOT_NO_X_CROSS 1
#define PLOT_NO_Y_CROSS 2
Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/slice.c 2007-02-24 06:10:35 UTC (rev 12516)
@@ -236,6 +236,8 @@
void slice_set_active(Slice *s, int activep){
s->thumb_active = activep;
+ if(s->active_callback)
+ s->active_callback(s->active_callback_data, activep);
draw_and_expose(GTK_WIDGET(s));
}
@@ -250,3 +252,8 @@
draw_and_expose(w);
}
}
+
+void slice_set_active_callback(Slice *s, void (*callback)(void *,int), void *data){
+ s->active_callback = callback;
+ s->active_callback_data = data;
+}
Modified: trunk/sushivision/slice.h
===================================================================
--- trunk/sushivision/slice.h 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/slice.h 2007-02-24 06:10:35 UTC (rev 12516)
@@ -57,6 +57,9 @@
void (*callback)(void *,int);
void *callback_data;
+ void (*active_callback)(void *, int);
+ void *active_callback_data;
+
};
struct _SliceClass{
@@ -68,6 +71,6 @@
extern GtkWidget* slice_new (void (*callback)(void *,int), void *data);
extern void slice_set_active(Slice *s, int activep);
extern void slice_thumb_set(Slice *s,double v);
-
+extern void slice_set_active_callback(Slice *s, void (*callback)(void *,int), void *data);
G_END_DECLS
#endif
Modified: trunk/sushivision/sushi-gtkrc.in
===================================================================
--- trunk/sushivision/sushi-gtkrc.in 2007-02-23 11:01:12 UTC (rev 12515)
+++ trunk/sushivision/sushi-gtkrc.in 2007-02-24 06:10:35 UTC (rev 12516)
@@ -79,6 +79,20 @@
}
+style "entry-poppy" {
+ base[NORMAL]="#ffffff"
+ base[ACTIVE]="#ffffff"
+ base[PRELIGHT]="#ffffff"
+ base[INSENSITIVE]="#c0c0c0"
+
+ text[NORMAL]="#000000"
+ text[ACTIVE]="#000000"
+ text[PRELIGHT]="#000000"
+
+ font_name = "sans 7"
+
+}
+
style "panel" {
bg[NORMAL]="#a0a0a0"
bg[ACTIVE]="#c0f0ff"
@@ -117,4 +131,5 @@
widget "*.GtkToggleButton*" style "button-poppy"
widget "*.GtkButton*" style "button-poppy"
widget "*.GtkExpander" style "exp-poppy"
+widget "*.GtkEntry" style "entry-poppy"
widget "*.Slider" style "slider-poppy"
More information about the commits
mailing list