Permalink
Browse files

OSCCommands: don't open another window if the window is already present

some layout fixes

Signed-off-by: nuss <st9fan@gmail.com>
(cherry picked from commit 39e59e7)
  • Loading branch information...
nuss committed May 25, 2013
1 parent 30d4bef commit c16a588be52f05dea79176d4a9f1dfb76ec3ed31
Showing with 103 additions and 102 deletions.
  1. +103 −102 CVCenter/OSCCommands.sc
View
@@ -1,4 +1,4 @@
-/* (c) 2010-2012 Stefan Nussbaumer */
+/* (c) 2010-2013 Stefan Nussbaumer */
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
OSCCommands {
+ classvar <window;
classvar collectFunc, running=false, cmdList;
*initClass {
@@ -81,10 +82,10 @@ OSCCommands {
}
*makeWindow {
- var window, flow, fields = (), deviceNameField, saveBut;
+ var flow, fields = (), deviceNameField, saveBut;
var progress, progressStates, progressRoutine, collectRoutine, stopFunc;
var makeField, nextFields;
- var staticTextFont = Font("Arial", 9.4);
+ var staticTextFont = Font("Arial", 10);
var staticTextColor = Color(0.2, 0.2, 0.2);
var textFieldFont = Font("Andale Mono", 9);
var textFieldFontColor = Color.black;
@@ -97,124 +98,124 @@ OSCCommands {
nextFields = cmds.keys.difference(fields.keys);
nextFields.do({ |nf|
fields.put(nf, ());
- flow.shift(0, 0);
- fields[nf].cmdName = StaticText(window, Rect(0, 0, 400, 20))
+ fields[nf].cmdName = StaticText(window, 390@20)
.background_(Color(1.0, 1.0, 1.0, 0.5))
;
if(cmds[nf] == 1, {
fields[nf].cmdName.string_(nf.asString+"("++cmds[nf]+"slot)");
}, {
fields[nf].cmdName.string_(nf.asString+"("++cmds[nf]+"slots)");
});
- flow.shift(0, 0);
- fields[nf].removeBut = Button(window, Rect(0, 0, 70, 20))
+ // flow.shift(0, 0);
+ fields[nf].removeBut = Button(window, flow.indentedRemaining.width-20@20)
.states_([
["remove", Color.white, Color.blue],
["add", Color.white, Color.red],
])
;
+ flow.nextLine;
})
})
};
- window = Window("OSC-command-name collector", Rect(
- Window.screenBounds.width/2-250,
- Window.screenBounds.height/2-250,
- 500, 500
- ), scroll: true);
-
- window.onClose_({
- this.collect(false);
- [progressRoutine, collectRoutine].do(_.stop);
- cmdList.clear;
- });
+ if(window.isNil or:{ window.isClosed }, {
+ window = Window("OSC-command-name collector", Rect(
+ Window.screenBounds.width/2-250,
+ Window.screenBounds.height/2-250,
+ 500, 500
+ ), scroll: true);
+
+ window.onClose_({
+ this.collect(false);
+ [progressRoutine, collectRoutine].do(_.stop);
+ cmdList.clear;
+ });
- window.view.decorator = flow = FlowLayout(window.view.bounds, 7@7, 3@3);
-
- flow.shift(0, 0);
-
- progress = StaticText(window, Rect(0, 0, 470, 30)).font_(Font("Arial", 20, true));
-
- flow.shift(-470, 30);
-
- progressStates = Pseq([
- "collecting",
- "collecting .",
- "collecting . .",
- "collecting . . .",
- "collecting . . . .",
- "collecting . . . . .",
- "collecting . . . . . .",
- "collecting . . . . . . .",
- "collecting . . . . . . . .",
- "collecting . . . . . . . . .",
- "collecting . . . . . . . . . .",
- "collecting . . . . . . . . . . .",
- "collecting . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
- ], inf).asStream;
- progressRoutine = fork({
- loop({
- progress.string_(progressStates.next);
- 0.5.wait;
- })
- }, AppClock);
-
- StaticText(window, Rect(0, 0, 230, 40)).string_("Collecting command-names will stop as soon as you close this window or save the device's commands. You can only save the command-names after setting a device-name.").font_(staticTextFont);
-
- flow.shift(20, 0);
-
- deviceNameField = TextField(window, Rect(0, 0, 144, 40))
- .font_(Font(Font.defaultMonoFace, 15))
- .string_("< device-name >")
- ;
-
- flow.shift(0, 0);
-
- saveBut = Button(window, Rect(0, 0, 70, 40))
- .states_([["save", Color.white, Color(0.15, 0.5, 0.15)]])
- .font_(Font(Font.defaultSansFace, 15, true))
- .action_({ |b|
- if(deviceNameField.string != "< device-name >" and:{ deviceNameField.string.size > 0 }, {
- this.collect(false);
- [progressRoutine, collectRoutine].do(_.stop);
- fields.pairsDo({ |k, v|
- if(v.removeBut.value == 1, {
- cmdList.removeAt(k);
- })
- });
- this.saveCmdSet(deviceNameField.string.asSymbol);
- window.close;
+ window.view.decorator = flow = FlowLayout(window.view.bounds, 7@7, 3@3);
+
+ progress = StaticText(window, flow.indentedRemaining.width@30).font_(Font("Arial", 20, true));
+
+ flow.nextLine.shift(0, 0);
+
+ progressStates = Pseq([
+ "collecting",
+ "collecting .",
+ "collecting . .",
+ "collecting . . .",
+ "collecting . . . .",
+ "collecting . . . . .",
+ "collecting . . . . . .",
+ "collecting . . . . . . .",
+ "collecting . . . . . . . .",
+ "collecting . . . . . . . . .",
+ "collecting . . . . . . . . . .",
+ "collecting . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ "collecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .",
+ ], inf).asStream;
+ progressRoutine = fork({
+ loop({
+ progress.string_(progressStates.next);
+ 0.5.wait;
})
- })
- ;
+ }, AppClock);
+
+ StaticText(window, 260@40).string_("Collecting command-names will stop as soon as you close this window or save the device's commands. You can only save the command-names after setting a device-name.").font_(staticTextFont);
+
+ // flow.shift(0, 0);
+
+ deviceNameField = TextField(window, 144@40)
+ .font_(Font("Andale Mono", 15))
+ .string_("< device-name >")
+ ;
+
+ // flow.shift(0, 0);
+
+ saveBut = Button(window, flow.indentedRemaining.width-20@40)
+ .states_([["save", Color.white, Color(0.15, 0.5, 0.15)]])
+ .font_(Font("Arial", 15, true))
+ .action_({ |b|
+ if(deviceNameField.string != "< device-name >" and:{ deviceNameField.string.size > 0 }, {
+ this.collect(false);
+ [progressRoutine, collectRoutine].do(_.stop);
+ fields.pairsDo({ |k, v|
+ if(v.removeBut.value == 1, {
+ cmdList.removeAt(k);
+ })
+ });
+ this.saveCmdSet(deviceNameField.string.asSymbol);
+ window.close;
+ })
+ })
+ ;
- collectRoutine = fork({
- loop({
- 0.1.wait;
- makeField.(cmdList);
- })
- }, AppClock);
+ collectRoutine = fork({
+ loop({
+ 0.1.wait;
+ makeField.(cmdList);
+ })
+ }, AppClock);
+ });
window.front;
}

0 comments on commit c16a588

Please sign in to comment.