[PD-cvs] externals/bbogart/entry entry.c,1.27,1.28

Hans-Christoph Steiner eighthave at users.sourceforge.net
Tue Nov 13 09:07:10 CET 2007


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

Modified Files:
	entry.c 
Log Message:
got live resizing working, but the outline is lower than the text widget, despite my attempts to change that

Index: entry.c
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** entry.c	13 Nov 2007 07:22:47 -0000	1.27
--- entry.c	13 Nov 2007 08:07:08 -0000	1.28
***************
*** 28,32 ****
  /* TODO: complete inlet draw/erase logic */
  /* TODO: unbind text from all key events when selected */
! /* TODO try binding to FocusIn and FocusOut for making selection */
  
  #ifdef _MSC_VER
--- 28,33 ----
  /* TODO: complete inlet draw/erase logic */
  /* TODO: unbind text from all key events when selected */
! /* TODO: allow moving by clicking and draging */
! /* TODO: sort out x_height/x_width vs. x_rect_height/x_rect_width */
  
  #ifdef _MSC_VER
***************
*** 65,71 ****
      t_symbol*  x_receive_name;
  
!     int        h_dragon;
!     int        h_dragx;
!     int        h_dragy;
  
  /* TODO: these all should be settable by messages */
--- 66,72 ----
      t_symbol*  x_receive_name;
  
!     int        x_resizing;
!     int        x_resize_x;
!     int        x_resize_y;
  
  /* TODO: these all should be settable by messages */
***************
*** 94,98 ****
      char *window_tag;      
      char *all_tag;
-     char *outline_tag;      
      
      t_outlet* x_data_outlet;
--- 95,98 ----
***************
*** 411,427 ****
          entry_getrect(z, glist, &x1, &y1, &x2, &y2);
          sys_vgui("%s configure -bg #bdbddd -state disabled\n", x->text_id);
-         sys_vgui("canvas %s -width %d -height %d -bg #fedc00 -bd 0 -cursor top_left_arrow\n",
-                  x->handle_id, TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT);
-         sys_vgui("%s create window %f %f -anchor nw -width %d -height %d -window %s -tags %s\n",
-                  x->canvas_id, x2 - (TKW_HANDLE_WIDTH - SCOPE_SELBDWIDTH),
-                  y2 - (TKW_HANDLE_HEIGHT - SCOPE_SELBDWIDTH),
-                  TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT,
-                  x->handle_id, x->all_tag);
-         sys_vgui("bind %s <Button> {pd [concat %s resize_click 1 \\;]}\n",
-                  x->handle_id, x->x_receive_name->s_name);
-         sys_vgui("bind %s <ButtonRelease> {pd [concat %s resize_click 0 \\;]}\n",
-                  x->handle_id, x->x_receive_name->s_name);
-         sys_vgui("bind %s <Motion> {pd [concat %s resize_motion %%x %%y \\;]}\n",
-                  x->handle_id, x->x_receive_name->s_name);
  /* */
          sys_vgui("%s create rectangle %d %d %d %d -tags {%xSEL %s} -outline blue -width 2\n",
--- 411,414 ----
***************
*** 437,440 ****
--- 424,428 ----
          sys_vgui("%s configure -bg grey -state normal\n", x->text_id);
          sys_vgui("%s delete %xSEL\n", x->canvas_id, x);
+         /* activatefn never gets called with 0, so destroy here */
          sys_vgui("destroy %s\n", x->handle_id);
          x->x_selected = 0;
***************
*** 445,453 ****
  {
      DEBUG(post("entry_activate"););    
! /* this is currently unused
!    t_text *x = (t_text *)z;
!    t_rtext *y = glist_findrtext(glist, x);
!    if (z->g_pd != gatom_class) rtext_activate(y, state);
! */
  }
  
--- 433,460 ----
  {
      DEBUG(post("entry_activate"););    
!     t_entry *x = (t_entry *)z;
!  	int x1, y1, x2, y2;
! 
!     if(state)
!     {
!         entry_getrect(z, glist, &x1, &y1, &x2, &y2);
!         sys_vgui("canvas %s -width %d -height %d -bg #fedc00 -bd 0 -cursor top_left_arrow\n",
!                  x->handle_id, TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT);
!         sys_vgui("%s create window %f %f -anchor nw -width %d -height %d -window %s -tags {%s RSZ}\n",
!                  x->canvas_id, x2 - (TKW_HANDLE_WIDTH - SCOPE_SELBDWIDTH),
!                  y2 - (TKW_HANDLE_HEIGHT - SCOPE_SELBDWIDTH),
!                  TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT,
!                  x->handle_id, x->all_tag);
!         sys_vgui("%s raise RSZ\n", x->canvas_id);
!         sys_vgui("bind %s <Button> {pd [concat %s resize_click 1 \\;]}\n",
!                  x->handle_id, x->x_receive_name->s_name);
!         sys_vgui("bind %s <ButtonRelease> {pd [concat %s resize_click 0 \\;]}\n",
!                  x->handle_id, x->x_receive_name->s_name);
!         sys_vgui("bind %s <Motion> {pd [concat %s resize_motion %%x %%y \\;]}\n",
!                  x->handle_id, x->x_receive_name->s_name);
!     }
!     else
!     {
!     }
  }
  
***************
*** 713,716 ****
--- 720,725 ----
      sys_vgui("%s itemconfigure %s -width %d -height %d \n", 
               x->canvas_id, x->all_tag, (int)width, (int)height);
+     entry_vis(x, x->x_canvas, 0);
+     entry_vis(x, x->x_canvas, 1);
  }
  
***************
*** 725,745 ****
  static void entry_resize_click_callback(t_entry *x, t_floatarg f)
  {
- /*
      t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0);
      int newstate = (int)f;
!     if (x->h_dragon && newstate == 0)
      {
!         x->x_width += x->h_dragx;
!         x->x_height += x->h_dragy;
          if (canvas)
          {
!             sys_vgui(".x%x.c delete %s\n", canvas, x->outline_tag);
!             scope_revis(x, canvas);
              sys_vgui("destroy %s\n", x->handle_id);
              entry_select((t_gobj *)x, x->x_glist, 1);
              canvas_fixlinesfor(x->x_glist, (t_text *)x);  // 2nd inlet
          }
      }
!     else if (!x->h_dragon && newstate)
      {
          if (canvas)
--- 734,755 ----
  static void entry_resize_click_callback(t_entry *x, t_floatarg f)
  {
      t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0);
      int newstate = (int)f;
!     if (x->x_resizing && newstate == 0)
      {
!         x->x_width += x->x_resize_x;
!         x->x_height += x->x_resize_y;
          if (canvas)
          {
!             sys_vgui(".x%x.c delete RESIZE_OUTLINE\n", canvas);
!             entry_vis(x,canvas,0);
!             entry_vis(x,canvas,1);
              sys_vgui("destroy %s\n", x->handle_id);
              entry_select((t_gobj *)x, x->x_glist, 1);
+             entry_activate((t_gobj *)x, x->x_glist, 1);
              canvas_fixlinesfor(x->x_glist, (t_text *)x);  // 2nd inlet
          }
      }
!     else if (!x->x_resizing && newstate)
      {
          if (canvas)
***************
*** 747,765 ****
              int x1, y1, x2, y2;
              entry_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
!             sys_vgui("lower %s\n", x->handle_id);
!             sys_vgui(".x%x.c create rectangle %d %d %d %d -outline blue -width %f -tags %s\n",
!                      canvas, x1, y1, x2, y2, SCOPE_SELBDWIDTH, x->outline_tag);
          }
!         x->h_dragx = 0;
!         x->h_dragy = 0;
      }
!     x->h_dragon = newstate;
! */
  }
  
  static void entry_resize_motion_callback(t_entry *x, t_floatarg f1, t_floatarg f2)
  {
! /*
!     if (x->h_dragon)
      {
          int dx = (int)f1, dy = (int)f2;
--- 757,774 ----
              int x1, y1, x2, y2;
              entry_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
! //            sys_vgui("lower %s\n", x->handle_id);
!             sys_vgui(".x%x.c create rectangle %d %d %d %d -outline blue -width %f -tags RESIZE_OUTLINE\n",
!                      canvas, x1, y1, x2, y2, SCOPE_SELBDWIDTH);
!             sys_vgui("%s raise RESIZE_OUTLINE\n", canvas);
          }
!         x->x_resize_x = 0;
!         x->x_resize_y = 0;
      }
!     x->x_resizing = newstate;
  }
  
  static void entry_resize_motion_callback(t_entry *x, t_floatarg f1, t_floatarg f2)
  {
!     if (x->x_resizing)
      {
          int dx = (int)f1, dy = (int)f2;
***************
*** 772,782 ****
              t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0);
              if (canvas)
!                 sys_vgui(".x%x.c coords %s %d %d %d %d\n",
!                          canvas, x->outline_tag, x1, y1, newx, newy);
!             x->h_dragx = dx;
!             x->h_dragy = dy;
          }
      }
- */
  }
  
--- 781,790 ----
              t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0);
              if (canvas)
!                 sys_vgui(".x%x.c coords RESIZE_OUTLINE %d %d %d %d\n",
!                          canvas, x1, y1, newx, newy);
!             x->x_resize_x = dx;
!             x->x_resize_y = dy;
          }
      }
  }
  





More information about the Pd-cvs mailing list