Re: [sc-users] Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [sc-users] Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Scott Wilson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Moving to dev.

This works:

+ Object {

*classRedirect { ^this }


}

+ ViewRedirect {

*classRedirect { ^this.implClass }


}

Then in Process:

openCodeFile {
var string, class, method, words;
string = interpreter.cmdLine;
if (string.includes($:), {
words = string.delimit({ arg c; c == $: });
class = words.at(0).asSymbol.asClass;
if (class.notNil, {
method = class.findMethod(words.at(1).asSymbol);
if (method.notNil, {
method.filenameSymbol.asString.openTextFile(method.charPos, -1);
});
});
},{
class = string.asSymbol.asClass.classRedirect;
if (class.notNil, {
class.filenameSymbol.asString.openTextFile(class.charPos, -1);
});
});
}

I suspect the Cmd-J method business should stay as is.

So assuming this works in Linux, we would just need a classvar in ViewRedirect to check if this is desired. Default = true?

Again not so much a new feature as refinement of an existing one. Okay to commit?

S.

On 19 Apr 2009, at 12:02, Scott Wilson wrote:

Or maybe better just a *classRedirect method which does nothing in the default case, but which ViewRedirects could check a switch.

S.

On 19 Apr 2009, at 11:58, Scott Wilson wrote:

This could be solved pretty easily by changing Process:openCodeFile and openWinCodeFile. The only issue is scel, as I don't know if it goes through this method. (marije?)

Maybe the thing to do would be have a Dictionary in Process where classes could register an openCodeFile redirect and then check there. Need to be careful about kit changes of course.

S.

On 19 Apr 2009, at 10:59, jostM wrote:

I agree that this is a pain. It takes many successive cmd-j's before you
actually have the class. I hope we can add a cmd-j redirection to the
redirect class at some point, so that it leads you to the correct
referred to class.  If it helps at all for now, the gui docs are now
complete enough that you can get the interface using cmd-d, which will
take you to the redirect stub, which has a link to the class docs. That
still means two steps, but is clearly better than cmd-J.

Jost

Michael Cox wrote:

Speaking of which...

Although I appreciate the cross-platform syntax,
as a mac coder I find it a total pain it the ass to use Button
over SCButton for the simple reason that I habitually
cmd-J for interface reference.

Cmd-J on Button yields:

Button : ViewRedirect { *key { ^\button }}

which I can't Cmd-J on
to get to my platform's unique Button class.

Is there some startup code that I can run so that
when I Cmd-J on 'Button' it opens my platform's
version of 'Button' instead of the above?

mgc


On Apr 19, 2009, at 1:33 AM, thor wrote:

Neels the GUI. syntax is old style now.

this would work :


(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = Window.new.front;

Button(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

Button(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)

On 19 Apr 2009, at 02:34, Neels Janosch Hofmeyr wrote:

And if you use the GUI wrapper instead of the direct class names,
your code
is also runnable on non-OSX machines, as they use e.g. JSCButton
instead of
SCButton:

(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = GUI.window.new.front;

GUI.button.new(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

GUI.button.new(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)



Michael G. Cox wrote:
or if you don't want to use an envelope you can
stop and start the synth with the same button:

(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = Window.new.front;

SCButton(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

SCButton(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)




_______________________________________________
sc-users mailing list

info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


Re: Re: [sc-users] Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 19 April 2009 07:54:16 Scott Wilson wrote:

> Moving to dev.
>
> This works:
>
> + Object {
>
> *classRedirect { ^this }
>
> }
>
> + ViewRedirect {
>
> *classRedirect { ^this.implClass }
>
> }
>
> Then in Process:
>
> openCodeFile {
> var string, class, method, words;
> string = interpreter.cmdLine;
> if (string.includes($:), {
> words = string.delimit({ arg c; c == $: });
> class = words.at(0).asSymbol.asClass;
> if (class.notNil, {
> method = class.findMethod(words.at(1).asSymbol);
> if (method.notNil, {
> method.filenameSymbol.asString.openTextFile(method.charPos, -1);
> });
> });
> },{
> class = string.asSymbol.asClass.classRedirect;
> if (class.notNil, {
> class.filenameSymbol.asString.openTextFile(class.charPos, -1);
> });
> });
> }
>
> I suspect the Cmd-J method business should stay as is.
>
> So assuming this works in Linux, we would just need a classvar in
> ViewRedirect to check if this is desired. Default = true?

More an editor issue than platform....

I'm not exactly sure how the interaction between SC and emacs goes in this
case... There is some autocompletion magic going so you only have to type a
partial classname or method and can use tab in the minibuffer to find
possible completions.
I'm not sure if then emacs opens the file by itself, or gives control back to
SC to do that.

But in any case, I don't think this will break it.

sincerely,
Marije

_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/

Re: Re: [sc-users] Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Scott Wilson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 19 Apr 2009, at 15:19, nescivi wrote:

>
> More an editor issue than platform....
>
> I'm not exactly sure how the interaction between SC and emacs goes  
> in this
> case... There is some autocompletion magic going so you only have to  
> type a
> partial classname or method and can use tab in the minibuffer to find
> possible completions.
> I'm not sure if then emacs opens the file by itself, or gives  
> control back to
> SC to do that.
>
> But in any case, I don't think this will break it.

Okay, I'll commit this then.

ViewRedirect.redirectQueries = true means you get the current  
implementation class. Default is false (least surprise, if perhaps  
most annoyance).

S.

_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/

Re: Re: [sc-users] Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Scott Wilson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This could also be adapted to work the same way for help, but that  
would require more serious cross-[platform, editor] coordination, so I  
think it should wait.

S.

On 20 Apr 2009, at 18:32, Scott Wilson wrote:

>
> On 19 Apr 2009, at 15:19, nescivi wrote:
>
>>
>> More an editor issue than platform....
>>
>> I'm not exactly sure how the interaction between SC and emacs goes  
>> in this
>> case... There is some autocompletion magic going so you only have  
>> to type a
>> partial classname or method and can use tab in the minibuffer to find
>> possible completions.
>> I'm not sure if then emacs opens the file by itself, or gives  
>> control back to
>> SC to do that.
>>
>> But in any case, I don't think this will break it.
>
> Okay, I'll commit this then.
>
> ViewRedirect.redirectQueries = true means you get the current  
> implementation class. Default is false (least surprise, if perhaps  
> most annoyance).
>
> S.
>
> _______________________________________________
> sc-dev mailing list
>
> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/