[PD-cvs] externals/bbogart/popup popup-gop-test.pd,1.1,1.2 popup-help.pd,1.3,1.4 popup.c,1.5,1.6

B. Bogart bbogart at users.sourceforge.net
Sun Oct 17 03:24:26 CEST 2004


Update of /cvsroot/pure-data/externals/bbogart/popup
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25215

Modified Files:
	popup-gop-test.pd popup-help.pd popup.c 
Log Message:
Fixed disapearing widget on minimzation bug (as per entry)
Added a height argument to specify widget height. Example patches changed.


Index: popup.c
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** popup.c	16 Oct 2004 20:31:50 -0000	1.5
--- popup.c	17 Oct 2004 01:24:23 -0000	1.6
***************
*** 6,15 ****
   * License                                                               *
  
!  * popup is free software; you can redistribute it and/or modify           *
   * it under the terms of the GNU General Public License as published by  *
   * the Free Software Foundation; either version 2 of the License, or     *
   * (at your option) any later version.                                   *
  
!  * popup is distributed in the hope that it will be useful,                *
   * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
--- 6,15 ----
   * License                                                               *
  
!  * popup is free software; you can redistribute it and/or modify         *
   * it under the terms of the GNU General Public License as published by  *
   * the Free Software Foundation; either version 2 of the License, or     *
   * (at your option) any later version.                                   *
  
!  * popup is distributed in the hope that it will be useful,              *
   * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
***************
*** 24,28 ****
  
  
- 
  #ifdef NT
  #pragma warning( disable : 4244 )
--- 24,27 ----
***************
*** 45,49 ****
  
       t_glist * x_glist;
! 	 t_outlet* out2;
       int x_rect_width;
       int x_rect_height;
--- 44,48 ----
  
       t_glist * x_glist;
!      t_outlet* out2;
       int x_rect_width;
       int x_rect_height;
***************
*** 53,61 ****
       int x_width;
  	 
! 	 int x_num_options;	 
! 	 t_symbol* x_colour;
       t_symbol* x_name;
  	
! 	 t_symbol* x_options[MAX_OPTIONS];
  
  } t_popup;
--- 52,60 ----
       int x_width;
  	 
!      int x_num_options;	 
!      t_symbol* x_colour;
       t_symbol* x_name;
  	
!      t_symbol* x_options[MAX_OPTIONS];
  
  } t_popup;
***************
*** 63,66 ****
--- 62,66 ----
  /* widget helper functions */
  
+ /* Append " x " to the following line to show debugging messages */
  #define DEBUG(x)
  
***************
*** 112,118 ****
  
  static void draw_handle(t_popup *x, t_glist *glist, int firsttime) {
-   int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2);
  
!   if (firsttime)
      sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xhandle\n",
  	     glist_getcanvas(glist),
--- 112,120 ----
  
  static void draw_handle(t_popup *x, t_glist *glist, int firsttime) {
  
!   DEBUG(post("draw_handle start");)
!   int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH);
! 
!   if (firsttime) {
      sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xhandle\n",
  	     glist_getcanvas(glist),
***************
*** 120,132 ****
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4,
  	     x);
!   else
      sys_vgui(".x%x.c coords %xhandle %d %d %d %d\n",
  	     glist_getcanvas(glist), x, 
  	     onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
  }
  
  static void create_widget(t_popup *x, t_glist *glist)
  {
    char text[MAXPDSTRING];
    int len,i;
--- 122,139 ----
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4,
  	     x);
!   } 
!   else {
      sys_vgui(".x%x.c coords %xhandle %d %d %d %d\n",
  	     glist_getcanvas(glist), x, 
  	     onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
+   }
+   DEBUG(post("draw_handle end");)
  }
  
  static void create_widget(t_popup *x, t_glist *glist)
  {
+   DEBUG(post("create_widget start");)
+ 
    char text[MAXPDSTRING];
    int len,i;
***************
*** 136,141 ****
    
    /* Create menubutton and empty menu widget -- maybe the menu should be created elseware?*/
!   /* Seems we have to delete the widget in case it already exists */
    sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
    sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
  		x,canvas,x,x,x->x_colour->s_name,x->x_name->s_name,x,x);
--- 143,150 ----
    
    /* Create menubutton and empty menu widget -- maybe the menu should be created elseware?*/
! 
!   /* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
    sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
+ 
    sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
  		x,canvas,x,x,x->x_colour->s_name,x->x_name->s_name,x,x);
***************
*** 148,151 ****
--- 157,161 ----
    
    DEBUG(post("id: .x%x.c.s%x", canvas, x);)
+   DEBUG(post("create_widget end");)
  }
  
***************
*** 153,156 ****
--- 163,167 ----
  {
    t_canvas *canvas=glist_getcanvas(glist);
+   DEBUG(post("drawme start");)
    DEBUG(post("drawme %d",firsttime);)
       if (firsttime) {
***************
*** 158,163 ****
         create_widget(x,glist);	       
         x->x_glist = canvas;
!        sys_vgui(".x%x.c create window %d %d -width %d -height 25 -anchor nw -window .x%x.c.s%x -tags %xS\n", 
! 		canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), x->x_width, x->x_glist,x,x);
                
       }     
--- 169,174 ----
         create_widget(x,glist);	       
         x->x_glist = canvas;
!        sys_vgui(".x%x.c create window %d %d -width %d -height %d -anchor nw -window .x%x.c.s%x -tags %xS\n", 
! 		canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), x->x_width, x->x_height, x->x_glist,x,x);
                
       }     
***************
*** 171,174 ****
--- 182,186 ----
       //     draw_handle(x, glist, firsttime);
  
+   DEBUG(post("drawme end");)
  }
  
***************
*** 178,182 ****
       int n;
  
!      DEBUG(post("erase");)
       sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
  
--- 190,194 ----
       int n;
  
!      DEBUG(post("erase start");)
       sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
  
***************
*** 188,191 ****
--- 200,205 ----
       sys_vgui(".x%x.c delete %xo\n",glist_getcanvas(glist),x); /* Added tag for all outlets of one instance */
       sys_vgui(".x%x.c delete  %xhandle\n",glist_getcanvas(glist),x,0);
+ 
+     DEBUG(post("erase end");)
  }
  	
***************
*** 198,201 ****
--- 212,217 ----
      int *xp1, int *yp1, int *xp2, int *yp2)
  {
+     DEBUG(post("getrect start");)
+ 
      int width, height;
      t_popup* s = (t_popup*)z;
***************
*** 207,210 ****
--- 223,228 ----
      *xp2 = text_xpix(&s->x_obj, owner) + width;
      *yp2 = text_ypix(&s->x_obj, owner) + height;
+   
+     DEBUG(post("getrect end");)
  }
  
***************
*** 213,217 ****
  {
      t_popup *x = (t_popup *)z;
!     DEBUG(post("displace");)
      x->x_obj.te_xpix += dx;
      x->x_obj.te_ypix += dy;
--- 231,235 ----
  {
      t_popup *x = (t_popup *)z;
!     DEBUG(post("displace start");)
      x->x_obj.te_xpix += dx;
      x->x_obj.te_ypix += dy;
***************
*** 231,234 ****
--- 249,254 ----
  static void popup_select(t_gobj *z, t_glist *glist, int state)
  {
+      DEBUG(post("select start");)
+ 
       t_popup *x = (t_popup *)z;
       if (state) {
***************
*** 244,251 ****
--- 264,275 ----
  		   glist_getcanvas(glist), x);
       }
+ 
+      DEBUG(post("select end");)
  }
  
  static void popup_activate(t_gobj *z, t_glist *glist, int state)
  {
+     DEBUG(post("activate commented out!");)
+   
  /* What does this do, why commented out? 
      t_text *x = (t_text *)z;
***************
*** 256,261 ****
--- 280,289 ----
  static void popup_delete(t_gobj *z, t_glist *glist)
  {
+     DEBUG(post("delete start");)
+ 
      t_text *x = (t_text *)z;
      canvas_deletelinesfor(glist_getcanvas(glist), x);
+ 
+     DEBUG(post("delete end");)
  }
  
***************
*** 265,268 ****
--- 293,297 ----
      t_popup* s = (t_popup*)z;
      t_rtext *y;
+     DEBUG(post("vis start");)
      DEBUG(post("vis: %d",vis);)
      if (vis) {
***************
*** 279,282 ****
--- 308,313 ----
  	rtext_free(y);
      }
+ 
+     DEBUG(post("vis end");)
  }
  
***************
*** 297,304 ****
--- 328,338 ----
    w_propertiesfn: NULL,
  #endif
+ 
  }; 
  
  static void popup_output(t_popup* x, t_floatarg popup_index)
  {
+   DEBUG(post("output start");)
+ 
    outlet_symbol(x->out2, x->x_options[(int)popup_index]);
    outlet_float(x->x_obj.ob_outlet, popup_index); 
***************
*** 308,317 ****
  static void popup_save(t_gobj *z, t_binbuf *b)
  {
  	int i;
      t_popup *x = (t_popup *)z;
  
!     binbuf_addv(b, "ssiisiss", gensym("#X"),gensym("obj"),
  		x->x_obj.te_xpix, x->x_obj.te_ypix ,  
! 		gensym("popup"), x->x_width, x->x_colour, x->x_name);
  	/* Loop for menu items */
  	for(i=0 ; i<x->x_num_options ; i++)
--- 342,353 ----
  static void popup_save(t_gobj *z, t_binbuf *b)
  {
+         DEBUG(post("save start");)
+     
  	int i;
      t_popup *x = (t_popup *)z;
  
!     binbuf_addv(b, "ssiisiiss", gensym("#X"),gensym("obj"),
  		x->x_obj.te_xpix, x->x_obj.te_ypix ,  
! 		gensym("popup"), x->x_width, x->x_height, x->x_colour, x->x_name);
  	/* Loop for menu items */
  	for(i=0 ; i<x->x_num_options ; i++)
***************
*** 320,323 ****
--- 356,361 ----
  	}
      binbuf_addv(b, ";");
+ 
+     DEBUG(post("vis end");)
  }
  
***************
*** 325,328 ****
--- 363,368 ----
  void popup_options(t_popup* x, t_symbol *s, int argc, t_atom *argv)
  {
+ 	DEBUG(post("options start");)
+ 	
  	int i;
  
***************
*** 338,341 ****
--- 378,383 ----
  			x->x_glist, x, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
  	}
+ 
+ 	DEBUG(post("options end");)
  }
  
***************
*** 343,346 ****
--- 385,390 ----
  void popup_bgcolour(t_popup* x, t_symbol* col)
  {
+ 	DEBUG(post("bgcolour start");)
+ 
  	x->x_colour->s_name = col->s_name;
  	sys_vgui(".x%x.c.s%x configure -background \"%s\"\n", x->x_glist, x, col->s_name);
***************
*** 350,353 ****
--- 394,399 ----
  static void popup_name(t_popup* x, t_symbol *name)
  {
+ 	DEBUG(post("name start");)
+ 
  	x->x_name->s_name = name->s_name;
  	sys_vgui(".x%x.c.s%x configure -text \"%s\"\n", x->x_glist, x, name->s_name);
***************
*** 357,360 ****
--- 403,408 ----
  static void popup_iselect(t_popup* x, t_floatarg item)
  {
+ 	DEBUG(post("iselect start");)
+ 
  	int i=(int)item;
  	if( i<x->x_num_options && i>=0)
***************
*** 365,368 ****
--- 413,418 ----
  		post("popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options, i);
  	}
+ 
+ 	DEBUG(post("iselect end");)
  }
  
***************
*** 372,375 ****
--- 422,427 ----
  static void *popup_new(t_symbol *s, int argc, t_atom *argv)
  {
+     DEBUG(post("popup new start");)
+ 
      t_popup *x = (t_popup *)pd_new(popup_class);
      int i;
***************
*** 385,388 ****
--- 437,441 ----
  		post("popup: You must enter at least 4 arguments. Default values used.");
  		x->x_width = 124;
+ 		x->x_height = 25;
  		x->x_num_options = 1; 
  		x->x_colour = gensym("#ffffff");
***************
*** 394,405 ****
  		/* Copy args into structure */
  		x->x_width = atom_getint(argv);
! 		x->x_colour = atom_getsymbol(argv+1);
! 		x->x_name = atom_getsymbol(argv+2);
  		
! 		x->x_num_options = argc-3;
  		
  		for(i=0 ; i<x->x_num_options ; i++)
  		{
! 			x->x_options[i] = atom_getsymbol( argv+(i+3) );
  		}
  	}	
--- 447,459 ----
  		/* Copy args into structure */
  		x->x_width = atom_getint(argv);
! 		x->x_height = atom_getint(argv+1);
! 		x->x_colour = atom_getsymbol(argv+2);
! 		x->x_name = atom_getsymbol(argv+3);
  		
! 		x->x_num_options = argc-4;
  		
  		for(i=0 ; i<x->x_num_options ; i++)
  		{
! 			x->x_options[i] = atom_getsymbol( argv+(i+4) );
  		}
  	}	
***************
*** 416,422 ****
--- 470,481 ----
  	x->out2 = outlet_new(&x->x_obj, &s_symbol);
      return (x);
+ 
+     DEBUG(post("popup new end");)
  }
  
  void popup_setup(void) {
+ 
+     DEBUG(post("setup start");)
+ 
      popup_class = class_new(gensym("popup"), (t_newmethod)popup_new, 0,
  				sizeof(t_popup),0,A_GIMME,0);

Index: popup-gop-test.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup-gop-test.pd,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** popup-gop-test.pd	18 May 2004 23:16:15 -0000	1.1
--- popup-gop-test.pd	17 Oct 2004 01:24:23 -0000	1.2
***************
*** 1,4 ****
  #N canvas 441 293 131 47 10;
! #X obj 0 5 popup 124 grey90 1024x512 opt1;
  #X obj 0 0 cnv 15 128 40 empty empty empty 20 12 0 14 -233017 -66577
  0;
--- 1,4 ----
  #N canvas 441 293 131 47 10;
! #X obj 0 5 popup 124 25 grey90 1024x512 opt1;
  #X obj 0 0 cnv 15 128 40 empty empty empty 20 12 0 14 -233017 -66577
  0;

Index: popup-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup-help.pd,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** popup-help.pd	20 Mar 2004 23:52:48 -0000	1.3
--- popup-help.pd	17 Oct 2004 01:24:23 -0000	1.4
***************
*** 1,4 ****
  #N canvas 154 131 631 317 10;
! #X obj 66 220 popup 124 white duh! one two three four five six seven
  eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21
  i22 i23 i24 i25 i26 i26 i27 i28 i29 i30;
--- 1,4 ----
  #N canvas 154 131 631 317 10;
! #X obj 66 220 popup 124 25 white duh! one two three four five six seven
  eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21
  i22 i23 i24 i25 i26 i26 i27 i28 i29 i30;





More information about the Pd-cvs mailing list