From bea5367653eaac9d992b284dbb81bc821cd29740 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Mon, 29 Jul 2013 23:04:43 -0400 Subject: [PATCH] optimizations to the scrolling algorithm including erroneous jumps in the scrollbar when pasting/cutting/duplicating things. --- pd/src/g_canvas.c | 2 +- pd/src/pd.tk | 57 ++++++++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 7188d7d78..e86730828 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -558,7 +558,7 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym, if (!menu) pd_pushsym(&x->gl_pd); glist_add(g, &x->gl_gobj); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(g)); + if (!do_not_redraw) sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(g)); return (x); } diff --git a/pd/src/pd.tk b/pd/src/pd.tk index c9b99c20e..2fb61c66f 100644 --- a/pd/src/pd.tk +++ b/pd/src/pd.tk @@ -1805,7 +1805,7 @@ proc menu_cut {name} { global copytexttocanvas if {![string match .gfxstub* $name] && ![string match .printout* $name] && ![string match *entry $name]} { pd [concat $name cut \;] - pdtk_canvas_getscroll $name.c + #pdtk_canvas_getscroll $name.c set copytexttocanvas 0 clipboard clear } else { @@ -1838,7 +1838,7 @@ proc menu_paste {name} { # pdtk_pastetext #} else { pd [concat $name paste \;] - pdtk_canvas_getscroll $name.c + #pdtk_canvas_getscroll $name.c #} } else { # puts stderr "pasting text..." @@ -1852,7 +1852,7 @@ bind . <$ctrl_key-Key-c> {global copytexttocanvas; tk_textCopy .printout.frame.t proc menu_duplicate {name} { pd [concat $name duplicate \;] - pdtk_canvas_getscroll $name.c + #pdtk_canvas_getscroll $name.c } proc menu_selectall {name} { @@ -3113,7 +3113,7 @@ proc pdtk_canvas_new {name width height geometry editable} { # bother with modifiers there. # We don't handle multiple clicks yet. - bind $name.c <Configure> {after 100 pdtk_canvas_getscroll %W} + bind $name.c <Configure> {pdtk_canvas_getscroll %W} #bind $name.c <Configure> {after 100 pdtk_canvas_getscroll_configure %W} bind $name.c <Button> {pdtk_canvas_click %W %x %y %b 0} bind $name.c <Shift-Button> {pdtk_canvas_click %W %x %y %b 1} @@ -3613,18 +3613,18 @@ proc pdtk_canvas_mouseup {name x y b} { [$name canvasy $y] $b \;] } -proc pdtk_canvas_getscroll_ping {name} { - set wname [string trimright $name .c] - if {![winfo exists $wname]} { - set ::update_tick($wname) 0 - return - } - if {$::update_tick($wname) == 2} { - set ::update_tick($wname) 3 - pdtk_canvas_getscroll $name - } - after 100 [list pdtk_canvas_getscroll_ping $name] -} +#proc pdtk_canvas_getscroll_ping {name} { +# set wname [string trimright $name .c] +# if {![winfo exists $wname]} { +# set ::update_tick($wname) 0 +# return +# } +# if {$::update_tick($wname) == 2} { +# set ::update_tick($wname) 3 +# pdtk_canvas_getscroll $name +# } +# after 100 [list pdtk_canvas_getscroll_ping $name] +#} proc pdtk_select_all_gop_widgets {name gop state} { #puts stderr "======================$name $gop $state" @@ -3678,24 +3678,31 @@ proc pdtk_canvas_getscroll {name} { global pdtk_canvas_mouseup_xmaxval global pdtk_canvas_mouseup_yminval global pdtk_canvas_mouseup_ymaxval + #global ::update_tick([winfo parent $name]) # kludge since this gets called sometimes after a canvas is destroyed if {![winfo exists $name]} {return} + if {$::update_tick([winfo parent $name]) == 1} {return} + + #set ::update_tick([winfo parent $name]) 1 + + after 100 set ::update_tick([winfo parent $name]) 0 + # waiting for refresh - if {$::update_tick([winfo parent $name]) == 2} {return} + #if {$::update_tick([winfo parent $name]) == 2} {return} # init - if {$::update_tick([winfo parent $name]) == 0} { - set ::update_tick([winfo parent $name]) 1 - pdtk_canvas_getscroll_ping $name - } + #if {$::update_tick([winfo parent $name]) == 0} { + # set ::update_tick([winfo parent $name]) 1 + # pdtk_canvas_getscroll_ping $name + #} # update - if {$::update_tick([winfo parent $name]) == 1} { - set ::update_tick([winfo parent $name]) 2 - return - } + #if {$::update_tick([winfo parent $name]) == 1} { + # set ::update_tick([winfo parent $name]) 2 + # return + #} #puts stderr getscroll -- GitLab