Fix animated hue not working even though the checkbox was checked after

restarting the interface.
This commit is contained in:
Artur Gomes 2017-08-08 20:04:51 +01:00
parent 981e935b61
commit 0017e29e60
2 changed files with 10 additions and 36 deletions

View file

@ -946,12 +946,13 @@
case "switchAnimatedBrush":
var animatedBrushes = Settings.getValue("currentAnimatedBrushes", []);
var brushSettingsIndex = animatedBrushes.indexOf(event.animatedBrushID);
if (brushSettingsIndex > -1) { //already exists so we are disabling it
if (!event.enabled && brushSettingsIndex > -1) { //already exists so we are disabling it
animatedBrushes.splice(brushSettingsIndex, 1);
} else { //doesn't exist yet so we are just adding it
} else if (event.enabled && brushSettingsIndex == -1) { //doesn't exist yet so we are just adding it
animatedBrushes.push(event.animatedBrushID);
}
Settings.setValue("currentAnimatedBrushes", animatedBrushes);
print("Setting animated brushes: " + JSON.stringify(animatedBrushes));
AnimatedBrushesInfo[event.animatedBrushName].isEnabled = event.enabled;
AnimatedBrushesInfo[event.animatedBrushName].settings = event.settings;
break;

View file

@ -140,7 +140,7 @@
</div>
<div class="behavior-group property checkbox animationBrush">
<input onchange="setAnimatedBrush(this)" animationType="animatedHueBrush" type="checkbox" id="animatedBrush"></input>
<input onchange="setAnimatedBrush(this)" type="checkbox" id="animatedBrush"></input>
<label for="animatedBrush">Use Hue Animation</label>
</div>
@ -410,34 +410,6 @@
EventBridge.emitWebEvent(JSON.stringify(changedBrushEvent));
}
function calculateAnimatedAxis(checkbox) {
if (checkbox.getAttribute("animationType") == "animatedRotationBrush") {
return {
axis: {
x: document.getElementById("pitchRotationBrush").checked ? 1 : 0,
y: document.getElementById("rollRotationBrush").checked ? 1 : 0,
z: document.getElementById("yawRotationBrush").checked ? 1 : 0
}
}
}
if (checkbox.getAttribute("animationType") == "animatedTranslationBrush") {
return {
axis: {
x: document.getElementById("xTranslationBrush").checked ? 1 : 0,
y: document.getElementById("yTranslationBrush").checked ? 1 : 0,
z: document.getElementById("zTranslationBrush").checked ? 1 : 0
}
}
} else return null;
}
function calculateEnabledStatus(checkbox, settings) {
if (checkbox.getAttribute("animationType") == "animatedHueBrush") {
return checkbox.checked;
}
return settings.axis.x == 1 || settings.axis.y == 1 || settings.axis.z == 1;
}
function switchDynamicBrushEnabledStatus(checkbox) {
var isAnyAnimatedChecked = false;
$(".animationBrush").each(function( index ) {
@ -460,12 +432,11 @@
function setAnimatedBrush(checkbox) {
switchDynamicBrushEnabledStatus();
var settings = calculateAnimatedAxis(checkbox);
var switchAnimatedBrushEvent = {
"type" : "switchAnimatedBrush",
"animatedBrushName": checkbox.getAttribute("animationType"),
"enabled" : calculateEnabledStatus(checkbox, settings),
"settings" : settings,
"type" : "switchAnimatedBrush",
"animatedBrushName": "animatedHueBrush",
"enabled" : checkbox.checked,
"settings" : null,
"animatedBrushID" : checkbox.id
};
EventBridge.emitWebEvent(JSON.stringify(switchAnimatedBrushEvent));
@ -533,6 +504,8 @@
var animatedBrushes = brushData.currentAnimatedBrushes;
for (var i = 0; i < animatedBrushes.length; i++) {
document.getElementById(animatedBrushes[i]).checked = true;
//Fix for onchange not being called (this appears to be the only checkbox where this happens)
$("#" + animatedBrushes[i]).trigger("change");
}
switchDynamicBrushEnabledStatus();
}