[xiph-cvs] r6520 - trunk/postfish

xiphmont at xiph.org xiphmont at xiph.org
Fri Apr 16 22:28:34 PDT 2004



Author: xiphmont
Date: 2004-04-17 01:28:34 -0400 (Sat, 17 Apr 2004)
New Revision: 6520

Modified:
   trunk/postfish/clippanel.c
   trunk/postfish/multibar.c
   trunk/postfish/subpanel.c
   trunk/postfish/subpanel.h
   trunk/postfish/version.h
Log:
Some UI drawing code cleanup

<p>Modified: trunk/postfish/clippanel.c
===================================================================
--- trunk/postfish/clippanel.c	2004-04-17 03:10:40 UTC (rev 6519)
+++ trunk/postfish/clippanel.c	2004-04-17 05:28:34 UTC (rev 6520)
@@ -107,6 +107,11 @@
   declip_setiterations(percent*.01);
 }
 
+static void active_callback(gpointer in,int activenum){
+  int active=declip_active[activenum];
+  gtk_widget_set_sensitive(feedback_bars[activenum],active);
+}
+
 void clippanel_create(postfish_mainpanel *mp,
                       GtkWidget **windowbutton,
                       GtkWidget **activebutton){
@@ -130,6 +135,8 @@
   GtkWidget *limit_box=gtk_vbox_new(0,0);
   GtkWidget *channel_table=gtk_table_new(input_ch,5,0);
 
+  subpanel_set_active_callback(panel,0,active_callback);
+
   gtk_widget_set_name(blocksize_box,"choiceframe");
   gtk_widget_set_name(converge_box,"choiceframe");
   gtk_widget_set_name(limit_box,"choiceframe");
@@ -298,6 +305,7 @@
     multibar_callback(MULTIBAR(slider),trigger_slider_change,(gpointer)cs);
 
     trigger_slider_change(NULL,cs);
+    active_callback(0,i);
   }
 
   gtk_container_add(GTK_CONTAINER(converge_frame),converge_box);

Modified: trunk/postfish/multibar.c
===================================================================
--- trunk/postfish/multibar.c	2004-04-17 03:10:40 UTC (rev 6519)
+++ trunk/postfish/multibar.c	2004-04-17 05:28:34 UTC (rev 6520)
@@ -66,10 +66,11 @@
 
   /* figure out the x padding */
   if(m->thumbs<1){
-    xpad=2;
+    xpad=1;
   }else{
-    xpad=((height+1)/2)+(height/2-3)*3/2+1;
+    xpad=height;
   }
+
   m->xpad=xpad;
 
   if(m->readout){
@@ -126,7 +127,7 @@
           if(lowvals[i]>=m->levels[j]){
             if(lowvals[i]<=m->levels[j+1]){
               float del=(lowvals[i]-m->levels[j])/(m->levels[j+1]-m->levels[j]);
-	      pixlo[i]=(j+del)/m->labels*(widget->allocation.width-xpad*2)-xpad;
+	      pixlo[i]=(j+del)/m->labels*(widget->allocation.width-xpad*2-1)-xpad;
               break;
             }else if(j==m->labels){
               pixlo[i]=widget->allocation.width-xpad+1;
@@ -139,7 +140,7 @@
           if(highvals[i]>=m->levels[j]){
             if(highvals[i]<=m->levels[j+1]){
               float del=(highvals[i]-m->levels[j])/(m->levels[j+1]-m->levels[j]);
-	      pixhi[i]=(j+del)/m->labels*(widget->allocation.width-xpad*2)+xpad;
+	      pixhi[i]=(j+del)/m->labels*(widget->allocation.width-xpad*2-1)+xpad;
               break;
             }else if(j==m->labels){
               pixhi[i]=widget->allocation.width-xpad+1;
@@ -158,7 +159,7 @@
         float dello=m->bartrackers[i].pixeldeltalo;
         
         /* hi */
-	delhi = compute_dampening(width-xpad*2,pixhi[i],trackhi,delhi,m->dampen_flags & ZERO_DAMP);
+	delhi = compute_dampening(width-xpad*2-1,pixhi[i],trackhi,delhi,m->dampen_flags & ZERO_DAMP);
         
         if(pixhi[i]>trackhi){
           if(m->dampen_flags & HI_ATTACK)pixhi[i]=trackhi+delhi;
@@ -169,7 +170,7 @@
         m->bartrackers[i].pixeldeltahi=delhi;
         
         /* lo */
-	dello = compute_dampening(width-xpad*2,pixlo[i],tracklo,dello,m->dampen_flags & ZERO_DAMP);
+	dello = compute_dampening(width-xpad*2-1,pixlo[i],tracklo,dello,m->dampen_flags & ZERO_DAMP);
         if(pixlo[i]>tracklo){
           if(m->dampen_flags & LO_ATTACK)pixlo[i]=tracklo+dello;
         }else{
@@ -204,7 +205,7 @@
     gdk_gc_copy(m->boxcolor,widget->style->black_gc);
   }
     
-  if(m->readout){
+  if(m->readout && widget->state!=GTK_STATE_INSENSITIVE){
     /* draw the pixel positions */
     while(x<widget->allocation.width){
       int r=0xffff,g=0xffff,b=0xffff;
@@ -308,7 +309,7 @@
         if(m->peak>=m->levels[j]){
           if(m->peak<=m->levels[j+1]){
             float del=(m->peak-m->levels[j])/(m->levels[j+1]-m->levels[j]);
-	    x=(j+del)/m->labels*(widget->allocation.width-xpad*2)+xpad;
+	    x=(j+del)/m->labels*(widget->allocation.width-xpad*2-1)+xpad;
             break;
           }else if (j==m->labels){
             x=widget->allocation.width-xpad+1;
@@ -352,7 +353,7 @@
   }
 
   for(i=0;i<m->labels+1;i++){
-    int x=rint(((float)i)/m->labels*(widget->allocation.width-xpad*2))+xpad;
+    int x=rint(((float)i)/m->labels*(widget->allocation.width-xpad*2-1))+xpad;
     int y=widget->allocation.height-lpad-upad;
     int px,py;
     int gc=0;
@@ -385,7 +386,6 @@
   {
     int width=widget->allocation.width;
     int height=widget->allocation.height;
-    int apad=3-xpad;
     GdkGC *gc=parent->style->bg_gc[0];
     GdkGC *light_gc=parent->style->light_gc[0];
     GdkGC *dark_gc=parent->style->dark_gc[0];
@@ -393,29 +393,32 @@
 
     /* blank side padding to bg of parent */
     gdk_draw_rectangle(m->backing,gc,1,0,0,xpad,height);
-    gdk_draw_rectangle(m->backing,gc,1,width-xpad+1,0,xpad-1,height);
+    gdk_draw_rectangle(m->backing,gc,1,width-xpad,0,xpad,height);
 
-
     /* blank sides of trough */
     gdk_draw_rectangle(m->backing,gc,1,
-		       0,height-lpad,
-		       m->thumblo_x+xpad+apad-1,lpad);
+		       0,
+		       height-lpad,
+		       m->thumblo_x,
+		       lpad);
     gdk_draw_rectangle(m->backing,gc,1,
-		       m->thumbhi_x+xpad-apad,height-lpad,
-		       width-xpad+apad-m->thumbhi_x,lpad);
+		       m->thumbhi_x+xpad+xpad,
+		       height-lpad,
+		       width-xpad-xpad-m->thumbhi_x,
+		       lpad);
     
     /* frame */
     if(m->readout){
-      gdk_draw_line(m->backing,dark_gc,xpad-1,0,width-xpad,0);
-      gdk_draw_line(m->backing,dark_gc,xpad-1,0,xpad-1,height-lpad);
-      gdk_draw_line(m->backing,dark_gc,xpad,height-lpad,width-xpad,height-lpad);
-      gdk_draw_line(m->backing,dark_gc,width-xpad,height-lpad,width-xpad,1);
+      gdk_draw_line(m->backing,dark_gc,0,0,width-2,0);
+      gdk_draw_line(m->backing,dark_gc,0,0,0,height-lpad);
+      gdk_draw_line(m->backing,dark_gc,1,height-lpad,width-2,height-lpad);
+      gdk_draw_line(m->backing,dark_gc,width-2,height-lpad,width-2,1);
       
-      gdk_draw_line(m->backing,light_gc,xpad-1,height-lpad+1,
-		    width-xpad+1,height-lpad+1);
-      gdk_draw_line(m->backing,light_gc,width-xpad+1,0,width-xpad+1,height-lpad+1);
-      gdk_draw_line(m->backing,light_gc,xpad,1,width-xpad-1,1);
-      gdk_draw_line(m->backing,light_gc,xpad,1,xpad,height-lpad-1);
+      gdk_draw_line(m->backing,light_gc,0,height-lpad+1,
+		    width-1,height-lpad+1);
+      gdk_draw_line(m->backing,light_gc,width-1,0,width-1,height-lpad+1);
+      gdk_draw_line(m->backing,light_gc,1,1,width-3,1);
+      gdk_draw_line(m->backing,light_gc,1,1,1,height-lpad-1);
     }
 
 
@@ -423,32 +426,35 @@
     if(lpad>2 || m->readout==0){
       if(lpad>2){
         gdk_draw_rectangle(m->backing,mid_gc,1,
-			   xpad+m->thumblo_x+apad,height-lpad+1,
-			   m->thumbhi_x-m->thumblo_x-apad*2+1,lpad-1);
+			   m->thumblo_x+1,height-lpad+1,
+			   m->thumbhi_x-m->thumblo_x+xpad*2,lpad-1);
         
         gdk_draw_line(m->backing,dark_gc,
-		      m->thumblo_x+xpad+apad-1,height-lpad,
-		      m->thumblo_x+xpad+apad-1,height-1);
+		      m->thumblo_x,height-lpad,
+		      m->thumblo_x,height-1);
         
       }
 
       gdk_draw_line(m->backing,light_gc,
-		    m->thumblo_x+xpad+apad-1,height-1,
-		    m->thumbhi_x+xpad-apad+1,height-1);
+		    m->thumblo_x,height-1,
+		    m->thumbhi_x+xpad*2,height-1);
 
       dark_gc=widget->style->dark_gc[GTK_STATE_ACTIVE];
 
       gdk_draw_line(m->backing,dark_gc,
-		    m->thumblo_x+xpad+apad-1,height-lpad,
-		    m->thumbhi_x+xpad-apad+1,height-lpad);
+		    m->thumblo_x,height-lpad,
+		    m->thumbhi_x+xpad*2-1,height-lpad);
       
       if(lpad>2)
         gdk_draw_line(m->backing,light_gc,
-		      m->thumbhi_x+xpad-apad+1,height-1,
-		      m->thumbhi_x+xpad-apad+1,height-lpad);
+		      m->thumbhi_x+xpad*2,height-1,
+		      m->thumbhi_x+xpad*2,height-lpad+1);
 
 
+      if(m->readout==0)
+	gdk_draw_point(m->backing,light_gc,width-1,height-lpad);
     }
+      
 
   }
 
@@ -460,7 +466,7 @@
     int y0=height/3-1;
     int y1=height-3;
 
-    int outer=(y1-y-2)+y*3/2;
+    int outer=height-1;
     int inner=(y1+y0)/2-y0;
 
     int A[3]={outer,outer,outer};
@@ -606,10 +612,10 @@
   maxy+=4;
 
   if(m->thumbs==0){
-    xpad=2;
+    xpad=1;
   }else{
     maxy+=3;
-    xpad=((maxy+1)/2)+(maxy/2-3)*3/2+1;
+    xpad=maxy;
   }
 
   requisition->width = (maxx*1.5+2)*m->labels+xpad*2;
@@ -715,8 +721,8 @@
 static int pixel_bound(Multibar *m,int x){
   GtkWidget *w=GTK_WIDGET(m);
   if(x<0)return 0;
-  if(x>w->allocation.width-m->xpad*2)
-    return w->allocation.width-m->xpad*2;
+  if(x>w->allocation.width-m->xpad*2-1)
+    return w->allocation.width-m->xpad*2-1;
   return x;
 }
 
@@ -725,8 +731,8 @@
   int j;
 
   for(j=0;j<=m->labels;j++){
-    int pixlo=rint((float)j/m->labels*(w->allocation.width-m->xpad*2));
-    int pixhi=rint((float)(j+1)/m->labels*(w->allocation.width-m->xpad*2));
+    int pixlo=rint((float)j/m->labels*(w->allocation.width-m->xpad*2-1));
+    int pixhi=rint((float)(j+1)/m->labels*(w->allocation.width-m->xpad*2-1));
 
     if(x>=pixlo && x<=pixhi){
       if(pixlo==pixhi)return m->levels[j];
@@ -744,13 +750,13 @@
   if(v<m->levels[0]){
     ret=0;
   }else if(v>m->levels[m->labels]){
-    ret=w->allocation.width-m->xpad*2;
+    ret=w->allocation.width-m->xpad*2-1;
   }else{
     for(j=0;j<=m->labels;j++){
       if(v>=m->levels[j] && v<=m->levels[j+1]){
         float del=(v-m->levels[j])/(m->levels[j+1]-m->levels[j]);
-	int pixlo=rint((float)j/m->labels*(w->allocation.width-m->xpad*2));
-	int pixhi=rint((float)(j+1)/m->labels*(w->allocation.width-m->xpad*2));
+	int pixlo=rint((float)j/m->labels*(w->allocation.width-m->xpad*2-1));
+	int pixhi=rint((float)(j+1)/m->labels*(w->allocation.width-m->xpad*2-1));
         ret=rint(pixlo*(1.-del)+pixhi*del);
         break;
       }
@@ -1012,6 +1018,11 @@
 
 static GtkDrawingAreaClass *parent_class = NULL;
 
+
+static void state_changed(GtkWidget *w,GtkStateType ps){
+  draw_and_expose(w);
+}
+
 static void multibar_class_init (MultibarClass *class){
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
   parent_class = g_type_class_peek_parent (class);
@@ -1027,6 +1038,7 @@
   widget_class->motion_notify_event = multibar_motion;
   widget_class->focus_out_event = unfocus;
   widget_class->focus_in_event = refocus;
+  widget_class->state_changed = state_changed;
 
   stipple=gdk_bitmap_create_from_data(NULL,"\125\352",2,2);
   stippleB=gdk_bitmap_create_from_data(NULL,"\352\125",2,2);

Modified: trunk/postfish/subpanel.c
===================================================================
--- trunk/postfish/subpanel.c	2004-04-17 03:10:40 UTC (rev 6519)
+++ trunk/postfish/subpanel.c	2004-04-17 05:28:34 UTC (rev 6520)
@@ -70,6 +70,7 @@
       active=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p->subpanel_activebutton[i]));
       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->mainpanel_activebutton[i]),active);
       p->activevar[i]=active;
+      if(p->callback)p->callback(p->callback_pointer,i);
       break;
     }
     if(widget==p->mainpanel_activebutton[i]){
@@ -246,3 +247,9 @@
   return panel;
 }
 
+void subpanel_set_active_callback(subpanel_generic *s,
+				  gpointer in,
+				  void (*callback)(gpointer in,int)){
+  s->callback_pointer=in;
+  s->callback=callback;
+}

Modified: trunk/postfish/subpanel.h
===================================================================
--- trunk/postfish/subpanel.h	2004-04-17 03:10:40 UTC (rev 6519)
+++ trunk/postfish/subpanel.h	2004-04-17 05:28:34 UTC (rev 6520)
@@ -33,11 +33,13 @@
 
   int active_button_count; /* silliness around the rotating non-alt-shortcut */
   int active_button_start; /* silliness around the rotating non-alt-shortcut */
-  int rotation[10];
+  int rotation[10];        /* silliness around the rotating non-alt-shortcut */
 
   sig_atomic_t *mappedvar;
 
   postfish_mainpanel *mainpanel;
+  void (*callback)(gpointer in,int);
+  gpointer callback_pointer;
 } subpanel_generic;
 
 extern subpanel_generic *subpanel_create(postfish_mainpanel *mp,
@@ -49,3 +51,5 @@
                                          int start,int num);
 
 extern void subpanel_show_all_but_toplevel(subpanel_generic *s);
+
+extern void subpanel_set_active_callback(subpanel_generic *s,gpointer in,void (*callback)(gpointer in,int));

Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h	2004-04-17 03:10:40 UTC (rev 6519)
+++ trunk/postfish/version.h	2004-04-17 05:28:34 UTC (rev 6520)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Fri Apr 16 23:09:46 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Sat Apr 17 01:27:16 EDT 2004] */

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list