Skip to content

Commit

Permalink
- added ability to connect modulation outputs to soft_bypass container
Browse files Browse the repository at this point in the history
- fix #636
  • Loading branch information
christoph-hart committed Jan 20, 2025
1 parent c593d9e commit 0a74ca9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
28 changes: 25 additions & 3 deletions hi_scripting/scripting/scriptnode/api/NodeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,18 +1237,26 @@ struct DragHelpers
void NodeBase::connectToBypass(var dragDetails)
{
auto sourceParameterTree = DragHelpers::getValueTreeOfSourceParameter(this, dragDetails);
auto modNode = DragHelpers::getModulationSource(this, dragDetails);

if (sourceParameterTree.isValid())
{
ValueTree newC(PropertyIds::Connection);
newC.setProperty(PropertyIds::NodeId, getId(), nullptr);
newC.setProperty(PropertyIds::ParameterId, PropertyIds::Bypassed.toString(), nullptr);

String connectionId = DragHelpers::getSourceNodeId(dragDetails) + "." +
DragHelpers::getSourceParameterId(dragDetails);

ValueTree connectionTree = sourceParameterTree.getChildWithName(PropertyIds::Connections);
connectionTree.addChild(newC, -1, getUndoManager());
return;
}
else if (modNode != nullptr)
{
ValueTree newC(PropertyIds::Connection);
newC.setProperty(PropertyIds::NodeId, getId(), nullptr);
newC.setProperty(PropertyIds::ParameterId, PropertyIds::Bypassed.toString(), nullptr);

modNode->getModulationTargetTree().addChild(newC, -1, getUndoManager());
return;
}
else
{
Expand Down Expand Up @@ -1288,6 +1296,20 @@ void NodeBase::connectToBypass(var dragDetails)
}
}
}
else
{
if (auto modNode = dynamic_cast<ModulationSourceNode*>(getRootNetwork()->getNodeWithId(src)))
{
for(auto c: modNode->getModulationTargetTree())
{
if (c[PropertyIds::NodeId] == getId() && c[PropertyIds::ParameterId].toString() == "Bypassed")
{
c.getParent().removeChild(c, getUndoManager());
return;
}
}
}
}
}
}

Expand Down
34 changes: 31 additions & 3 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,9 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)

if (connection.isNotEmpty())
{


if (connection.contains("["))
{
// Multi mod source
auto nodeId = connection.upToFirstOccurrenceOf("[", false, false);
auto slotIndex = connection.fromFirstOccurrenceOf("[", false, false).getIntValue();

Expand All @@ -1119,8 +1118,10 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
}
}
}
else
else if (connection.containsChar('.'))
{
// Parameter

auto nodeId = connection.upToFirstOccurrenceOf(".", false, false);
auto pId = connection.fromFirstOccurrenceOf(".", false, false);

Expand Down Expand Up @@ -1149,6 +1150,33 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
}
}
}
else
{
// Single Mod source

for(auto m: modSourceList)
{


if(auto mn = m->getSourceNodeFromParent())
{
if(mn->getId() == connection)
{
auto c = n->isBypassed() ? Colours::grey : Colour(SIGNAL_COLOUR).withAlpha(0.8f);

c = getSpecialColour(m, c);

auto start = getCircle(m, false);
auto end = getCircle(&b->powerButton).translated(0.0, -60.0f);

Colour hc = m->isMouseOver(true) ? Colours::red : Colour(0xFFAAAAAA);

GlobalHiseLookAndFeel::paintCable(g, start, end, c, alpha, hc);
break;
}
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion hi_scripting/scripting/scriptnode/ui/NodeComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ NodeComponent::Header::Header(NodeComponent& parent_) :
colourUpdater.setCallback(parent.node->getValueTree(), { PropertyIds::NodeColour }, valuetree::AsyncMode::Synchronously,
BIND_MEMBER_FUNCTION_2(NodeComponent::Header::updateColour));

dynamicPowerUpdater.setTypesToWatch({ PropertyIds::Nodes, PropertyIds::Connections });
dynamicPowerUpdater.setTypesToWatch({ PropertyIds::Nodes, PropertyIds::Connections, PropertyIds::ModulationTargets });

dynamicPowerUpdater.setCallback(parent.node->getRootNetwork()->getValueTree(), valuetree::AsyncMode::Asynchronously, [this](ValueTree v, bool wasAdded)
{
Expand Down

0 comments on commit 0a74ca9

Please sign in to comment.