Skip to content

Commit

Permalink
custom colors
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Dec 16, 2024
1 parent d1c9c14 commit a89062d
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 157 deletions.
175 changes: 88 additions & 87 deletions Source/Effect/GlobalEffectManager.cpp
Original file line number Diff line number Diff line change
@@ -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<ChainVizTarget*> GlobalEffectManager::getChainVizTargetsForObjectAndComponent(Object* o, ComponentType c)
{
Array<ChainVizTarget*> result;
for (auto& g : items) result.addArray(g->effectManager.getChainVizTargetsForObjectAndComponent(o, c));
return result;
}

void GlobalEffectManager::processComponent(Object* o, ObjectComponent* c, HashMap<Parameter*, var>& 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<ChainVizTarget*> GlobalEffectManager::getChainVizTargetsForObjectAndComponent(Object* o, ComponentType c)
{
Array<ChainVizTarget*> result;
for (auto& g : items) result.addArray(g->effectManager.getChainVizTargetsForObjectAndComponent(o, c));
return result;
}

void GlobalEffectManager::processComponent(Object* o, ObjectComponent* c, HashMap<Parameter*, var>& 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);
}
141 changes: 71 additions & 70 deletions Source/Object/Group/Group.cpp
Original file line number Diff line number Diff line change
@@ -1,70 +1,71 @@
/*
==============================================================================
Group.cpp
Created: 29 Sep 2020 9:46:51pm
Author: bkupe
==============================================================================
*/


#include <algorithm>

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<Parameter*, var>& 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 <algorithm>

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<Parameter*, var>& 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);
}
1 change: 1 addition & 0 deletions Source/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Object::Object(var params) :
previousID(-1),
slideManipParameter(nullptr)
{
setHasCustomColor(true);
showWarningInUI = true;
saveAndLoadRecursiveData = true;

Expand Down

0 comments on commit a89062d

Please sign in to comment.