Skip to content

Commit

Permalink
customvaluescommandargumentmanager refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Oct 9, 2023
1 parent fdf6e3c commit 5c62d4d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,25 @@ void CustomValuesCommandArgumentManager::removeItemsInternal(Array<CustomValuesC
}


CustomValuesCommandArgument* CustomValuesCommandArgumentManager::createItemWithParam(Parameter* p, var data)
CustomValuesCommandArgument* CustomValuesCommandArgumentManager::createItemWithParam(Parameter* p)
{
CustomValuesCommandArgument* a = new CustomValuesCommandArgument("#" + String(items.size() + 1), p, mappingEnabled, templateMode, multiplex, enablePrecison);
return a;
}

CustomValuesCommandArgument* CustomValuesCommandArgumentManager::createItemFromType(Parameter::Type type, var data)
CustomValuesCommandArgument* CustomValuesCommandArgumentManager::createItemFromType(Parameter::Type type)
{
Parameter* p = createParameterFromType(type, data, items.size());
Parameter* p = createParameterFromType(type);
if (p == nullptr) return nullptr;

return createItemWithParam(p, data);
return createItemWithParam(p);
}

Parameter* CustomValuesCommandArgumentManager::createParameterFromType(Parameter::Type type, var data, int index)
Parameter* CustomValuesCommandArgumentManager::createParameterFromType(Parameter::Type type)
{
if (!linkedTemplateManagerRef.wasObjectDeleted() && linkedTemplateManager != nullptr) return linkedTemplateManager->createParameterFromType(type, data, index);
if (!linkedTemplateManagerRef.wasObjectDeleted() && linkedTemplateManager != nullptr) return linkedTemplateManager->createParameterFromType(type);

String id = String(index + 1);
String id = String(items.size() + 1);

Parameter* p = nullptr;

Expand Down Expand Up @@ -194,7 +194,7 @@ Parameter* CustomValuesCommandArgumentManager::createParameterFromType(Parameter

if (p != nullptr) p->isCustomizableByUser = true;

if (createParamCallbackFunc != nullptr) createParamCallbackFunc(p, data);
if (createParamCallbackFunc != nullptr) createParamCallbackFunc(p);

return p;
}
Expand All @@ -203,7 +203,7 @@ CustomValuesCommandArgument* CustomValuesCommandArgumentManager::addItemFromData
{

Controllable::Type t = (Controllable::Type)Controllable::typeNames.indexOf(data.getProperty("type", ""));
CustomValuesCommandArgument* item = createItemFromType(t, data);
CustomValuesCommandArgument* item = createItemFromType(t);
return addItem(item);

/*if (s.isEmpty()) return nullptr;
Expand All @@ -224,8 +224,8 @@ Array<CustomValuesCommandArgument*> CustomValuesCommandArgumentManager::addItems
Array<CustomValuesCommandArgument*> itemsToAdd;
for (int i = 0; i < data.size(); i++)
{
Controllable::Type t = (Controllable::Type)Controllable::typeNames.indexOf(data.getProperty("type", ""));
CustomValuesCommandArgument* item = createItemFromType(t, data);
Controllable::Type t = (Controllable::Type)Controllable::typeNames.indexOf(data[i].getProperty("type", ""));
CustomValuesCommandArgument* item = createItemFromType(t);
itemsToAdd.add(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CustomValuesCommandArgumentManager :
CustomValuesCommandArgumentManager* linkedTemplateManager;
WeakReference<Inspectable> linkedTemplateManagerRef;

std::function<void(Parameter*, var)> createParamCallbackFunc;
std::function<void(Parameter*)> createParamCallbackFunc;

StringArray inputNames;

Expand All @@ -41,9 +41,9 @@ class CustomValuesCommandArgumentManager :
void removeItemInternal(CustomValuesCommandArgument* i) override;
void removeItemsInternal(Array<CustomValuesCommandArgument*> items) override;

CustomValuesCommandArgument* createItemWithParam(Parameter* p, var data = var());
CustomValuesCommandArgument* createItemFromType(Parameter::Type type, var data = var());
Parameter* createParameterFromType(Parameter::Type type, var data = var(), int index = 0);
CustomValuesCommandArgument* createItemWithParam(Parameter* p);
CustomValuesCommandArgument* createItemFromType(Parameter::Type type);
Parameter* createParameterFromType(Parameter::Type type);
CustomValuesCommandArgument* addItemFromData(var data, bool fromUndoableAction = false) override;
Array<CustomValuesCommandArgument*> addItemsFromData(var data, bool fromUndoableAction = false) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void CustomValuesCommandArgumentManagerEditor::handleMenuSelectedID(int id)
{
switch (id)
{
case 1: aManager->addItem(aManager->createtemFromType(Parameter::INT)); break;
case 1: aManager->addItem(aManager->createItemFromType(Parameter::INT)); break;
case 2: aManager->addItem(aManager->createItemFromType(Parameter::FLOAT)); break;
case 3: aManager->addItem(aManager->createItemFromType(Parameter::STRING)); break;
case 4: aManager->addItem(aManager->createItemFromType(Parameter::BOOL)); break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SendStreamRawDataCommand::SendStreamRawDataCommand(StreamingModule* _module, Com
SendStreamValuesCommand(_module, context, params, multiplex)
{
customValuesManager->allowedTypes.add(Controllable::INT);
customValuesManager->createParamCallbackFunc = std::bind(&SendStreamRawDataCommand::customValueCreated, this, std::placeholders::_1, std::placeholders::_2);
customValuesManager->createParamCallbackFunc = std::bind(&SendStreamRawDataCommand::customValueCreated, this, std::placeholders::_1);
customValuesManager->enablePrecison = false;
}

Expand All @@ -31,7 +31,7 @@ void SendStreamRawDataCommand::triggerInternal(int multiplexIndex)
streamingModule->sendBytes(data, getCustomParams(multiplexIndex));
}

void SendStreamRawDataCommand::customValueCreated(Parameter * p, var data)
void SendStreamRawDataCommand::customValueCreated(Parameter * p)
{
if (IntParameter* ip = dynamic_cast<IntParameter*>(p))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SendStreamRawDataCommand :

void triggerInternal(int multiplexIndex) override;

void customValueCreated(Parameter * p, var data);
void customValueCreated(Parameter * p);

static SendStreamRawDataCommand * create(ControllableContainer * module, CommandContext context, var params, Multiplex * multiplex) { return new SendStreamRawDataCommand((StreamingModule *)module, context, params, multiplex); }
};

0 comments on commit 5c62d4d

Please sign in to comment.