Update of /cvsroot/pure-data/externals/tkwidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26612
Modified Files: text.c Log Message:
- fixed bug that caused the iolets to multiply whenever resizing, I forgot to add the ->s_name to a symbol used in the sys_vgui, so it was using the pointer value.
- moved standard key/mouse binding functions to tkwidgets.[ch]
- minor code cleanups for legibility
Index: text.c =================================================================== RCS file: /cvsroot/pure-data/externals/tkwidgets/text.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** text.c 22 Nov 2007 05:57:45 -0000 1.9 --- text.c 23 Nov 2007 22:44:03 -0000 1.10 *************** *** 31,36 **** /* TODO: window name "handle1376fc00" already exists in parent */ /* TODO: figure out window vs. text width/height */ ! /* TODO: move bind_* to tkwidgets.c */ ! /* TODO: erase iolets on resize, they are leaving old ones behind */
#define DEFAULT_COLOR "grey70" --- 31,35 ---- /* TODO: window name "handle1376fc00" already exists in parent */ /* TODO: figure out window vs. text width/height */ !
#define DEFAULT_COLOR "grey70" *************** *** 160,212 **** }
- static void bind_standard_keys(t_textwidget *x) - { - #ifdef __APPLE__ - sys_vgui("bind %s <Mod1-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n", - x->widget_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n", - x->widget_id->s_name, x->canvas_id->s_name); - #else - sys_vgui("bind %s <Control-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n", - x->widget_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Control-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n", - x->widget_id->s_name, x->canvas_id->s_name); - #endif - } - - static void bind_button_events(t_textwidget *x) - { - /* mouse buttons */ - sys_vgui("bind %s <Button> {pdtk_canvas_sendclick %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 0}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <ButtonRelease> {pdtk_canvas_mouseup %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Shift-Button> {pdtk_canvas_click %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 1}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Button-2> {pdtk_canvas_rightclick %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Button-3> {pdtk_canvas_rightclick %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - sys_vgui("bind %s <Control-Button> {pdtk_canvas_rightclick %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - /* mouse motion */ - sys_vgui("bind %s <Motion> {pdtk_canvas_motion %s \ - [expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] 0}\n", - x->widget_id->s_name, x->canvas_id->s_name, - x->canvas_id->s_name, x->canvas_id->s_name); - } - static void create_widget(t_textwidget *x) { --- 159,162 ---- *************** *** 226,231 **** sys_vgui("pack %s -side bottom -fill both -expand 1 \n", x->frame_id->s_name);
! bind_standard_keys(x); ! bind_button_events(x); sys_vgui("bind %s <KeyRelease> {+pd %s keyup %%N \;} \n", x->widget_id->s_name, x->receive_name->s_name); --- 176,182 ---- sys_vgui("pack %s -side bottom -fill both -expand 1 \n", x->frame_id->s_name);
! tkwidgets_bind_key_events(x->canvas_id, x->widget_id); ! tkwidgets_bind_mouse_events(x->canvas_id, x->widget_id); ! /* bind to KeyRelease events to send out right outlet one key at a time */ sys_vgui("bind %s <KeyRelease> {+pd %s keyup %%N \;} \n", x->widget_id->s_name, x->receive_name->s_name); *************** *** 331,334 **** --- 282,286 ---- /* sys_vgui("%s create line %d %d %d %d -fill black -tags RESIZE_LINES\n", */ /* x->handle_id->s_name, handle_x2, handle_y1, handle_x1, handle_y2); */ + /* TODO split out the handle and the handle binding into common functions */ sys_vgui("%s create window %d %d -anchor nw -width %d -height %d -window %s -tags RESIZE\n", x->canvas_id->s_name, handle_x1, handle_y1, *************** *** 646,651 **** { t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0); ! int newstate = (int)f; ! if (x->x_resizing && !newstate && canvas) { tkwidgets_draw_iolets((t_object*)x, canvas, --- 598,603 ---- { t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0); ! int button_state = (int)f; ! if (x->x_resizing && !button_state && canvas) { tkwidgets_draw_iolets((t_object*)x, canvas, *************** *** 654,662 **** canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } ! if (!x->x_resizing && newstate) { tkwidgets_erase_iolets(x->canvas_id, x->iolets_tag); } ! x->x_resizing = newstate; }
--- 606,614 ---- canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } ! if (!x->x_resizing && button_state) { tkwidgets_erase_iolets(x->canvas_id, x->iolets_tag); } ! x->x_resizing = button_state; }