Permalink
Browse files

Disallow deactivating widget actions containing open functions

Don't suggest to the user she can reinitialize open functions once they
have been deactivated

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information...
nuss committed Dec 12, 2017
1 parent 992fca1 commit bae668c736fd3930c0efa3d5ed218016d0935127
Showing with 135 additions and 99 deletions.
  1. +67 −50 CVCenter/CVWidgetEditor.sc
  2. +68 −49 CVCenter/CVWidgetMSEditor.sc
View
@@ -40,6 +40,7 @@ CVWidgetEditor : AbstractCVWidgetEditor {
var connectIP, connectPort;
var mouseOverFunc;
var modsDict, arrModsDict, arrowKeys;
var funcString;
buildCheckbox = { |active, view, props, font|
var cBox;
@@ -931,41 +932,47 @@ CVWidgetEditor : AbstractCVWidgetEditor {
});
wdgtActions.pairsDo({ |name, action|
funcString = action.asArray[0][0];
actionsUIs = actionsUIs.put(name, ());
flow3.shift(0, 5);
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15))
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15)) }, {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-110, 15))
});
actionsUIs[name].nameField
.font_(staticTextFont)
.background_(Color(1.0, 1.0, 1.0, 0.5))
.string_(""+name.asString)
;
flow3.shift(5, 0);
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
if (funcString != "{ \"open Function\" }", {
flow3.shift(5, 0);
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
switch(action.asArray[0][1],
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
switch(action.asArray[0][1],
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
});
flow3.shift(5, 0);
@@ -984,7 +991,7 @@ CVWidgetEditor : AbstractCVWidgetEditor {
actionsUIs[name].actionView = TextView(cTabView3, Point(flow3.bounds.width-35, 50))
.background_(Color(1.0, 1.0, 1.0, 0.5))
.font_(textFieldFont)
.string_(action.asArray[0][0].replace("\t", " "))
.string_(funcString.replace("\t", " "))
.syntaxColorize
.editable_(false)
;
@@ -1076,46 +1083,56 @@ CVWidgetEditor : AbstractCVWidgetEditor {
var staticTextFont = Font(Font.available("Arial") ? Font.defaultSansFace, 9.4);
var textFieldFont = Font(Font.available("Courier New") ? Font.defaultSansFace, 9);
var actTop;
var funcString;
if(widget.class != CVWidgetMS, {
switch(addRemove,
\add, {
actionsUIs[name] ?? {
actionsUIs.put(name, ());
cTabView3.bounds = Point(cTabView3.bounds.width, cTabView3.bounds.height+76);
funcString = action.asArray[0][0];
flow3.shift(0, 5);
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15))
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15))
}, {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-110, 15))
});
actionsUIs[name].nameField
.font_(staticTextFont)
.background_(Color(1.0, 1.0, 1.0, 0.5))
.string_(""+name.asString)
;
flow3.shift(5, 0);
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
switch(active,
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
switch(active,
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
});
flow3.shift(0, 0);
@@ -1131,7 +1148,7 @@ CVWidgetEditor : AbstractCVWidgetEditor {
actionsUIs[name].actionView = TextView(cTabView3, Point(flow3.bounds.width-35, 50))
.background_(Color(1.0, 1.0, 1.0, 0.5))
.font_(textFieldFont)
.string_(action.asArray[0][0])
.string_(funcString)
.syntaxColorize
.editable_(false)
;
@@ -55,7 +55,8 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
var connectWarning;
var mouseOverFunc;
var numCalibActive;
var modsDict, arrModsDict, arrowKeys ;
var modsDict, arrModsDict, arrowKeys;
var funcString;
buildCheckbox = { |active, view, props, font|
var cBox;
@@ -1333,41 +1334,49 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
// "widgetActions: %\n".postf(wdgtActions.cs);
wdgtActions.pairsDo({ |name, action|
funcString = action.asArray[0][0];
actionsUIs = actionsUIs.put(name, ());
flow3.shift(0, 5);
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15))
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15));
}, {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-110, 15));
});
actionsUIs[name].nameField
.font_(staticTextFont)
.background_(Color(1.0, 1.0, 1.0, 0.5))
.string_(""+name.asString)
;
flow3.shift(5, 0);
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false) },
1, { widget.activateAction(name, true) }
)
})
;
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false) },
1, { widget.activateAction(name, true) }
)
})
;
switch(action.asArray[0][1],
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
switch(action.asArray[0][1],
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
});
flow3.shift(5, 0);
@@ -1386,7 +1395,7 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
actionsUIs[name].actionView = TextView(cTabView3, Point(flow3.bounds.width-35, 50))
.background_(Color(1.0, 1.0, 1.0, 0.5))
.font_(textFieldFont)
.string_(action.asArray[0][0].replace("\t", " "))
.string_(funcString.replace("\t", " "))
.syntaxColorize
.editable_(false)
;
@@ -1473,45 +1482,55 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
var staticTextFont = Font(Font.available("Arial") ? Font.defaultSansFace, 9.4);
var textFieldFont = Font(Font.available("Courier New") ? Font.defaultSansFace, 9);
var actTop;
var funcString;
switch(addRemove,
\add, {
actionsUIs[name] ?? {
actionsUIs.put(name, ());
funcString = action.asArray[0][0];
// tabView3.bounds = Point(tabView3.bounds.width, tabView3.bounds.height+76);
flow3.shift(0, 5);
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15))
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-173, 15));
}, {
actionsUIs[name].nameField = StaticText(cTabView3, Point(flow3.bounds.width-110, 15));
});
actionsUIs[name].nameField
.font_(staticTextFont)
.background_(Color(1.0, 1.0, 1.0, 0.5))
.string_(""+name.asString)
;
flow3.shift(5, 0);
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
switch(active,
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
if (funcString != "{ \"open Function\" }", {
actionsUIs[name].activate = Button(cTabView3, Point(60, 15))
.font_(staticTextFont)
.states_([
["activate", Color(0.1, 0.3, 0.15), Color(0.99, 0.77, 0.11)],
["deactivate", Color.white, Color(0.1, 0.30, 0.15)],
])
.action_({ |rb|
switch(rb.value,
0, { widget.activateAction(name, false, slot) },
1, { widget.activateAction(name, true, slot) }
)
})
;
switch(active,
true, {
actionsUIs[name].activate.value_(1);
},
false, {
actionsUIs[name].activate.value_(0);
}
);
});
flow3.shift(5, 0);
@@ -1530,7 +1549,7 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
actionsUIs[name].actionView = TextView(cTabView3, Point(flow3.bounds.width-35, 50))
.background_(Color(1.0, 1.0, 1.0, 0.5))
.font_(textFieldFont)
.string_(action.asArray[0][0])
.string_(funcString)
.syntaxColorize
.editable_(false)
;

0 comments on commit bae668c

Please sign in to comment.