[PD-dev] improved scrolling algorithm

Ivica Ico Bukvic ico at vt.edu
Tue May 18 19:30:03 CEST 2010


All right, the following fixes scrolling on Linux once and for all. It
should be also wrapped in a way that does not disturb Win and OSX (even
though they are in a need of the same fix).

Please note the following applies to:
Linux/OSX/Windows
Pd 0.42.5 vanilla and extended
Tcl/Tk 8.4 & 8.5

Basically, text is incorrectly reported by bbox all call so it screws
scrollbars up. E.g. try the attached problem_1.pd patch and you'll
notice there are vertical scrollbars even though there shouldn't be any.
This makes tight GUI crafting a real pain. Also, please note that on
smaller font sizes the problem is less apparent but nonetheless still
there.

Solution: calculating text size separately from other objects to obtain
total box size. This, however, has to be done *per font* due to tcl/tk's
buggy implementation.

Attached patch also reinvokes getscrollbar after cut/paste/undo/redo
(undo/redo is patched in g_editor.c as otherwise it occurs out of sync
before undo/redo has been processed in g_editor.c, resulting in a
erroneous scroll position).

The current scrolling algorithm should to the best of my knowledge pass
all the existing test Hans has listed on his gui-rewrite page with one
notable difference:

This approach assumes that the canvas should always fit objects the best
it can to avoid using scrollbars (unlike traditional approach that has
an invisible center around 0 0). This does sometimes result in patch
shifting a bit off-center (but never outside the view unless the entire
patch is too large to fit the saved window size)--this is due to the
fact that currently Pd has no way of telling from the saved file where
the viewport should be. This can be easily circumvented using the cnv
object which still yields IMHO better results than the traditional
system.

Cheers!

Ico
-------------- next part --------------
#N canvas 2 50 553 380 10;
#X obj 173 -31563 nbx 1 300 -1e+37 1e+37 0 0 empty empty empty 0 -8
0 300 -262144 -1 -1 0 256;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g_editor.c_scrollbar_fix_100518
Type: text/x-patch
Size: 620 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20100518/ca0364c3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pd.tk_scroll_fix_100518
Type: text/x-patch
Size: 8113 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20100518/ca0364c3/attachment-0001.bin>


More information about the Pd-dev mailing list