[PD-dev] much better scrolling algorithm (pd-extended 0.42.5)

Ivica Ico Bukvic ico at vt.edu
Sat Nov 28 06:15:12 CET 2009


On Fri, 2009-11-27 at 22:15 -0500, Mathieu Bouchard wrote:
> On Fri, 27 Nov 2009, Hans-Christoph Steiner wrote:
> 
> > FYI, it doesn't work on Mac OS X because it requires 8.5 and ttk, so this 
> > couldn't be included in vanilla since Miller wants to continue to support 
> > 8.3, and it couldn't be included in Pd-extended until 0.43 since 0.42 doesn't 
> > work on Mac OS X with 8.5
> 
> if {$::tk_version >= 8.5} ?

Actually, it's even simpler than that. Most of the ttk calls in my
version of pd.tk are ctually old tk calls that are run through
match_linux_wm function which checks for proper pd_nt variable and tk
version and if necessary renames the call to comparable ttk call and
adds customization options. I used the term most instead of all due to
errors Hans has reported which suggest that somewhere along the way I
obviously forgot to do apply the wrapper to all ttk calls.

So, original line in pd.tk looking like:
list frame $name.buttonframe

is converted to:
match_linux_wm [list frame $name.buttonframe]

with the match_linux_wm being:
proc match_linux_wm {list} {
	global pd_nt linux_wm_bgcolor linux_wm_hlcolor
	if { [info tclversion] >= 8.5 && $pd_nt == 0 } {
		if {[lsearch -regexp $list ::] == -1} {
			if {[lindex $list 0] != "button" \
				&& [lindex $list 0] != "checkbutton" \
				&& [lindex $list 0] != "radiobutton" \
				&& [lindex $list 0] != "entry" \
				&& [lindex $list 0] != "scrollbar"} { 
					lappend list -bg $linux_wm_bgcolor
			}
			if {[lindex $list 0] == "listbox" \
				|| [lindex $list 0] == "text"} {

				lappend list -bg white -highlightcolor $linux_wm_hlcolor
			}
			if {[lindex $list 0] == "menu"} {
	
				lappend list -activebackground $linux_wm_hlcolor -bd 0
			}
			#convert non-ttk objects to ttk objects
			if {[lindex $list 0] == "button" \
				|| [lindex $list 0] == "checkbutton" \
				|| [lindex $list 0] == "radiobutton" \
				|| [lindex $list 0] == "entry" \
				|| [lindex $list 0] == "scrollbar"} { 
				set newlist [lreplace $list 0 0 ttk::[lindex $list 0]]
			}
		}
	}
	if {[info exists newlist]} {
		eval $newlist
	} else {
		eval $list
	}
}

So, theoretically once all calls are properly wrapped this is the only
place that the checks need to be done properly and you're done.
Consequently, the new pd.tk should in theory visually affect only linux
users while making no difference whatsoever on other platforms (apart
from scrolling algorithm and other logic-oriented fixes I've made along
the way).

Ico





More information about the Pd-dev mailing list