View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide


Home   How To   Code Pool   Public Library   Theory   Events
this utility class keeps track of documents in a folder. i use it like a 'quicklauncher' for patches and synthdefs.

// 050125-26, 050427 /f0
// bugfixes: 061206 asArray, 071216 guified, 080907 reveal was broken, 080909 listView height fix
// 081025 replaced Font with GUI.font, clear up colours
// 090705 using view redirect classes (sc3.3.1)
// based on two old classes called RedPatchListGUI and RedSynthDefsGUI

/* -keyboard shortcuts:

	'ctrl+u' = update list


	and put some documents in a folder called 'patches' in your main sc folder.
	with the GUI in focus, press 'ctrl+u' to scan the directory again.  your files should show.
	select and press 'enter' to open.
	you can set path, recursiveness and bounds...
		RedFolderGUI("Help", true, Rect(100, 200, 300, 400));
	warning... 'reveal' button only works on os x

RedFolderGUI {
	var <window, <path, <>recursive, <allPaths, <listView;
	*new {|path= "patches/", recursive= false, bounds|
		^, bounds);
	initRedFolderGUI {|argPath, bounds|
		var fnt= Font("Monaco", 9);
		var col=;
		var colBack= Color.grey(0.5, 0.8);
		path= PathName(argPath).asAbsolutePath;
		bounds= bounds ? Rect(1280-160, 41, 159, 769);//default bounds
		window= Window(path.basename, bounds, false).alpha_(0.9).front;
		window.view.background= colBack;
		Button(window, Rect(1, 1, bounds.width-2/3, 17))
			.states_([["loadThis", col, Color.clear]])
			.action_{if(allPaths.notEmpty, {allPaths[listView.value].load}); listView.focus};
		Button(window, Rect(bounds.width-2/3+1, 1, bounds.width-2/3, 17))
			.states_([["loadAll", col, Color.clear]])
			.action_{{|x| x.load}; listView.focus};
		Button(window, Rect((bounds.width-2/3*2)+1, 1, bounds.width-2/3, 17))
			.states_([["reveal", col, Color.clear]])
					\osx, {
						//fails if there is a ' in the filename
						var p= allPaths[listView.value];
						("osascript -e 'tell application \"Finder\" to (reveal item \""$/, $:)++"\" of startup disk) activate'").unixCmd;
					{"RedFolderGUI: reveal for osx only".postln}
		listView= ListView(window, Rect(0, 20, bounds.width, bounds.height-24))
			.keyDownAction_{|view, char, mod, unicode|
				//added ctrl+u for updating list
				if((mod&262144==262144)&&(unicode==21), {this.update});
				view.defaultKeyDownAction(char, mod, unicode);
				if(allPaths.notEmpty, {[view.value])})
	update {
		var func;
		if(recursive, {
			func= {|x|{|y|
					if(PathName(y).isFolder, {
					}, {
		}, {
				if(PathName(y).isFile, {
		defer{listView.items= allPaths.asArray.collect{|x| x.asString.basename}};
	font_ {|font|{|view| view.font= font};
	front {



Link to this Page