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

Patch Launcher Remix

This is a remix of Casey Basichis' Patch Launcher.
I added the possibility to open directories from inside the gui.

tom
 
// PatchLauncher remix
 ~directory = "/Users/df/scwork/patches/functions/" ;  // your function dir
Routine({
var patchArray, a, orig;
var window, fileNames, pathNames;
var top = 20, left = 25, rows = 0;

fileNames = Cocoa.getPathsInDirectory(~directory).select({| file | file.contains(".rtf") });
pathNames = Array.fill(fileNames.size, {arg i; ~directory++ Cocoa.getPathsInDirectory(~directory).select({| file | file.contains(".rtf") }).at(i) });

a = Array.fill(fileNames.size, {arg i; i});
orig = thisFunction;
patchArray = Array.fill(
				fileNames.size
				, { arg i; [
							fileNames.at(i).asString
							, pathNames.at(i) 
						]
				}
			);

window = SCWindow("Master"
				, Rect(0, 695, SCWindow.screenBounds.width, 130)
				, false
				, false
			).front;

window.view.background_(Color.rand);


SCButton(window, Rect(0, 112, 15, 15))
        .states_([["X"]])
        .action_({window.close});

SCButton(window, Rect(17, 112, 100, 15))
        .states_([["DiR=>DeFaulT"]])
        .action_({window.close; ~directory = nil; orig.value; });

SCButton(window, Rect(119, 112, 100, 15))
        .states_([["GeT=>NeWDiR"]])
        .action_({	CocoaDialog.getPaths({ arg paths;
									paths.do({ arg p;
										~directory = p.dirname++ "/";
										~directory.postln;
									})
								},{
									"cancelled".postln;
								});
							});

SCButton(window, Rect(221, 112, 100, 15))
        .states_([["LoaD=>NeWDiR"]])
        .action_({window.close; orig.value});


patchArray.do({
        arg item, i;

        b = SCButton(window
        			, Rect(
        				i*(SCWindow.screenBounds.width/fileNames.size)
        				, top
        				, SCWindow.screenBounds.width/fileNames.size
        				, 90))
        				
                .states_([[ item.at(0).basename, Color.black, Color.rand ]])
        		  .action_({ a[i] = item.at(1).loadPath });
}); 

patchArray.do({
        arg item, i;

        SCButton(window
        			, Rect(
        				i*(SCWindow.screenBounds.width/fileNames.size)+(SCWindow.screenBounds.width/fileNames.size/4)+2
        				, 4
        				, SCWindow.screenBounds.width/fileNames.size/4
        				, 15))
        				
                .states_([[ "||", Color.black, Color.rand ]])
                .action_({ a[i].free });
}); 

patchArray.do({
        arg item, i;

        SCButton(window
        			, Rect(
        				i*(SCWindow.screenBounds.width/fileNames.size)
        				, 4
        				, SCWindow.screenBounds.width/fileNames.size/4
        				, 15))
        				
                .states_([[ "/", Color.black, Color.rand ]])
                .action_({ Document.open(item.at(1)) });
}); 
}).run


***************
/*
authors so far:
tom tlalim
/f0 (typo fix 9lines from bottom)
*/


Link to this Page