From a89062d215e7fe3e7606282238e26959ce00dc01 Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Tue, 17 Dec 2024 00:32:09 +0100 Subject: [PATCH] custom colors --- Source/Effect/GlobalEffectManager.cpp | 175 +++++++++++++------------- Source/Object/Group/Group.cpp | 141 ++++++++++----------- Source/Object/Object.cpp | 1 + 3 files changed, 160 insertions(+), 157 deletions(-) diff --git a/Source/Effect/GlobalEffectManager.cpp b/Source/Effect/GlobalEffectManager.cpp index fd12ec9..e378091 100644 --- a/Source/Effect/GlobalEffectManager.cpp +++ b/Source/Effect/GlobalEffectManager.cpp @@ -1,87 +1,88 @@ -/* - ============================================================================== - - GlobalEffectManager.cpp - Created: 30 Sep 2020 12:38:46pm - Author: bkupe - - ============================================================================== -*/ - -#include "Effect/EffectIncludes.h" - -juce_ImplementSingleton(GlobalEffectManager) - -GlobalEffectManager::GlobalEffectManager() : - BaseManager("Global Effects") -{ - itemDataType = EffectGroup::getTypeStringStatic(); -} - -GlobalEffectManager::~GlobalEffectManager() -{ - -} - -Array GlobalEffectManager::getChainVizTargetsForObjectAndComponent(Object* o, ComponentType c) -{ - Array result; - for (auto& g : items) result.addArray(g->effectManager.getChainVizTargetsForObjectAndComponent(o, c)); - return result; -} - -void GlobalEffectManager::processComponent(Object* o, ObjectComponent* c, HashMap& values) -{ - for (auto& i : items) - { - if (!i->enabled->boolValue()) continue; - i->effectManager.processComponent(o, c, values); - } -} - -var GlobalEffectManager::getSceneData() -{ - var data(new DynamicObject()); - for (auto& i : items) data.getDynamicObject()->setProperty(i->shortName, i->getSceneData()); - return data; -} - -void GlobalEffectManager::updateSceneData(var& sceneData) -{ -} - -void GlobalEffectManager::lerpFromSceneData(var startData, var endData, float weight) -{ - for (auto& i : items) i->lerpFromSceneData(startData.getProperty(i->shortName, var()), endData.getProperty(i->shortName, var()), weight); -} - -EffectGroup::EffectGroup() : - BaseItem("Effect Group") -{ - saveAndLoadRecursiveData = true; - addChildControllableContainer(&effectManager); - - excludeFromScenes = addBoolParameter("Exclude From Scenes", "If checked, this effect won't be saved in scenes", false); -} - -EffectGroup::~EffectGroup() -{ -} - -var EffectGroup::getSceneData() -{ - var data(new DynamicObject()); - if (excludeFromScenes->boolValue()) return data; - data.getDynamicObject()->setProperty(effectManager.shortName, effectManager.getSceneData()); - return data; -} - -void EffectGroup::updateSceneData(var& sceneData) -{ -} - -void EffectGroup::lerpFromSceneData(var startData, var endData, float weight) -{ - if (excludeFromScenes->boolValue()) return; - effectManager.lerpFromSceneData(startData.getProperty(effectManager.shortName, var()), endData.getProperty(effectManager.shortName, var()), weight); -} +/* + ============================================================================== + + GlobalEffectManager.cpp + Created: 30 Sep 2020 12:38:46pm + Author: bkupe + + ============================================================================== +*/ + +#include "Effect/EffectIncludes.h" + +juce_ImplementSingleton(GlobalEffectManager) + +GlobalEffectManager::GlobalEffectManager() : + BaseManager("Global Effects") +{ + itemDataType = EffectGroup::getTypeStringStatic(); +} + +GlobalEffectManager::~GlobalEffectManager() +{ + +} + +Array GlobalEffectManager::getChainVizTargetsForObjectAndComponent(Object* o, ComponentType c) +{ + Array result; + for (auto& g : items) result.addArray(g->effectManager.getChainVizTargetsForObjectAndComponent(o, c)); + return result; +} + +void GlobalEffectManager::processComponent(Object* o, ObjectComponent* c, HashMap& values) +{ + for (auto& i : items) + { + if (!i->enabled->boolValue()) continue; + i->effectManager.processComponent(o, c, values); + } +} + +var GlobalEffectManager::getSceneData() +{ + var data(new DynamicObject()); + for (auto& i : items) data.getDynamicObject()->setProperty(i->shortName, i->getSceneData()); + return data; +} + +void GlobalEffectManager::updateSceneData(var& sceneData) +{ +} + +void GlobalEffectManager::lerpFromSceneData(var startData, var endData, float weight) +{ + for (auto& i : items) i->lerpFromSceneData(startData.getProperty(i->shortName, var()), endData.getProperty(i->shortName, var()), weight); +} + +EffectGroup::EffectGroup() : + BaseItem("Effect Group") +{ + setHasCustomColor(true); + saveAndLoadRecursiveData = true; + addChildControllableContainer(&effectManager); + + excludeFromScenes = addBoolParameter("Exclude From Scenes", "If checked, this effect won't be saved in scenes", false); +} + +EffectGroup::~EffectGroup() +{ +} + +var EffectGroup::getSceneData() +{ + var data(new DynamicObject()); + if (excludeFromScenes->boolValue()) return data; + data.getDynamicObject()->setProperty(effectManager.shortName, effectManager.getSceneData()); + return data; +} + +void EffectGroup::updateSceneData(var& sceneData) +{ +} + +void EffectGroup::lerpFromSceneData(var startData, var endData, float weight) +{ + if (excludeFromScenes->boolValue()) return; + effectManager.lerpFromSceneData(startData.getProperty(effectManager.shortName, var()), endData.getProperty(effectManager.shortName, var()), weight); +} diff --git a/Source/Object/Group/Group.cpp b/Source/Object/Group/Group.cpp index 0128d93..5af4ceb 100644 --- a/Source/Object/Group/Group.cpp +++ b/Source/Object/Group/Group.cpp @@ -1,70 +1,71 @@ -/* - ============================================================================== - - Group.cpp - Created: 29 Sep 2020 9:46:51pm - Author: bkupe - - ============================================================================== -*/ - - -#include - -Group::Group(String name) : - BaseItem(name) -{ - saveAndLoadRecursiveData = true; - - effectManager.reset(new EffectManager(this)); - addChildControllableContainer(effectManager.get()); -} - -Group::~Group() -{ - -} - -void Group::generateRandomIDs() -{ - randomIDs.resize(getNumObjects()); - for (int i = 0; i < randomIDs.size(); i++) randomIDs.set(i, i); - - shuffle(randomIDs.begin(), randomIDs.end(), std::default_random_engine(Time::currentTimeMillis())); -} - -bool Group::containsObject(Object* o) -{ - return false; -} - -int Group::getLocalIDForObject(Object* o) -{ - return -1; -} - -int Group::getRandomIDForObject(Object* o) -{ - return -1; -} - -void Group::processComponent(Object* o, ObjectComponent* c, HashMap& values) -{ - effectManager->processComponent(o, c, values, 1, getLocalIDForObject(o)); -} - -var Group::getSceneData() -{ - var data(new DynamicObject()); - data.getDynamicObject()->setProperty(effectManager->shortName,effectManager->getSceneData()); - return data; -} - -void Group::updateSceneData(var& sceneData) -{ -} - -void Group::lerpFromSceneData(var startData, var endData, float weight) -{ - effectManager->lerpFromSceneData(startData.getProperty(effectManager->shortName, var()), endData.getProperty(effectManager->shortName, var()), weight); -} +/* + ============================================================================== + + Group.cpp + Created: 29 Sep 2020 9:46:51pm + Author: bkupe + + ============================================================================== +*/ + + +#include + +Group::Group(String name) : + BaseItem(name) +{ + saveAndLoadRecursiveData = true; + setHasCustomColor(true); + + effectManager.reset(new EffectManager(this)); + addChildControllableContainer(effectManager.get()); +} + +Group::~Group() +{ + +} + +void Group::generateRandomIDs() +{ + randomIDs.resize(getNumObjects()); + for (int i = 0; i < randomIDs.size(); i++) randomIDs.set(i, i); + + shuffle(randomIDs.begin(), randomIDs.end(), std::default_random_engine(Time::currentTimeMillis())); +} + +bool Group::containsObject(Object* o) +{ + return false; +} + +int Group::getLocalIDForObject(Object* o) +{ + return -1; +} + +int Group::getRandomIDForObject(Object* o) +{ + return -1; +} + +void Group::processComponent(Object* o, ObjectComponent* c, HashMap& values) +{ + effectManager->processComponent(o, c, values, 1, getLocalIDForObject(o)); +} + +var Group::getSceneData() +{ + var data(new DynamicObject()); + data.getDynamicObject()->setProperty(effectManager->shortName,effectManager->getSceneData()); + return data; +} + +void Group::updateSceneData(var& sceneData) +{ +} + +void Group::lerpFromSceneData(var startData, var endData, float weight) +{ + effectManager->lerpFromSceneData(startData.getProperty(effectManager->shortName, var()), endData.getProperty(effectManager->shortName, var()), weight); +} diff --git a/Source/Object/Object.cpp b/Source/Object/Object.cpp index d626f50..f3c9365 100644 --- a/Source/Object/Object.cpp +++ b/Source/Object/Object.cpp @@ -21,6 +21,7 @@ Object::Object(var params) : previousID(-1), slideManipParameter(nullptr) { + setHasCustomColor(true); showWarningInUI = true; saveAndLoadRecursiveData = true;