Skip to content

Commit

Permalink
- fix #539
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Sep 30, 2024
1 parent 73072e0 commit ec69c81
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 11 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd3dbddf93bcd4c1f9edaacd9ccba7d398c6d0e0
73072e0f0f0cb10acde81852bca6877866ccf5f0
2 changes: 1 addition & 1 deletion hi_backend/backend/currentGit.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PREVIOUS_HISE_COMMIT "bd3dbddf93bcd4c1f9edaacd9ccba7d398c6d0e0"
#define PREVIOUS_HISE_COMMIT "73072e0f0f0cb10acde81852bca6877866ccf5f0"
87 changes: 84 additions & 3 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
float alpha = showCables ? 1.0f : 0.1f;

Array<ParameterSlider*> sliderList;
Array<ParameterSlider*> connectedSliders;

fillChildComponentList(sliderList, this);

Array<MultiOutputDragSource*> multiOutputList;
Expand Down Expand Up @@ -699,6 +701,8 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
auto start = getCircle(sourceSlider);
auto end = getCircle(targetSlider);

connectedSliders.add(targetSlider);

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

float thisAlpha = alpha;
Expand Down Expand Up @@ -757,6 +761,8 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
thisAlpha = HoverAlpha;
}

connectedSliders.add(s);

auto start = getCircle(multiSource->asComponent(), false);
auto end = getCircle(s);

Expand Down Expand Up @@ -829,6 +835,8 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
addModSource(s);
}

connectedSliders.add(s);

auto end = getCircle(s);

bool shouldPrintLabel = false;
Expand Down Expand Up @@ -956,7 +964,7 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
{
auto start = getCircle(sourceSlider);
auto end = getCircle(&b->powerButton).translated(0.0, -60.0f);

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

GlobalHiseLookAndFeel::paintCable(g, start, end, c, alpha, hc);
Expand All @@ -967,6 +975,80 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
}
}

for(auto s: sliderList)
{
if(!s->pTree[PropertyIds::Automated])
continue;

if(connectedSliders.contains(s))
continue;

auto area = getCircle(s);

auto hover = s->isMouseOver(true);

g.setColour(hover ? Colours::red : Colours::white);
g.fillEllipse(area);

if(hover)
{
auto ct = s->getConnectionSourceTree();

auto nt = valuetree::Helpers::findParentWithType(ct, PropertyIds::Node);

if(auto sn = network->getNodeForValueTree(nt))
{
for(auto b: bypassList)
{
if(b->parent.node == sn)
{
NodeComponent* nb = &b->parent;

auto notFolded = true;

while(notFolded)
{
auto nt = nb->node->getValueTree().getParent();

valuetree::Helpers::forEachParent(nt, [&](const ValueTree& p)
{
if(p.getType() == PropertyIds::Node)
{
notFolded &= !(bool)p[PropertyIds::Folded];
}

return false;
});

if(notFolded)
break;

nb = nb->findParentComponentOfClass<NodeComponent>();

if(nb == nullptr)
break;
}

if(nb != nullptr)
{
auto h = &nb->header;

auto sourceRect = getLocalArea(h, h->getLocalBounds());

g.setColour(Colours::red.withAlpha(0.2f));
g.fillRect(sourceRect);

}

break;
}
}
}
}


}

Array<cable::dynamic::editor*> sendList;
fillChildComponentList(sendList, this);

Expand Down Expand Up @@ -2465,13 +2547,12 @@ void KeyboardPopup::addNodeAndClose(String path)

newNode = network->createFromValueTree(true, newTree, true);

network->runPostInitFunctions();

auto as = dynamic_cast<AssignableObject*>(container);
as->assign(ap, newNode);

network->deselectAll();
network->addToSelection(dynamic_cast<NodeBase*>(newNode.getObject()), ModifierKeys());
network->runPostInitFunctions();
}

sp->setCurrentModalWindow(nullptr, {});
Expand Down
14 changes: 13 additions & 1 deletion hi_scripting/scripting/scriptnode/ui/NodeComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ NodeComponent::Header::Header(NodeComponent& parent_) :

freezeButton.setToggleModeWithColourChange(true);

auto isContainer = dynamic_cast<NodeContainer*>(parent.node.get()) != nullptr;

parameterButton.setToggleModeWithColourChange(true);
parameterButton.setToggleStateAndUpdateIcon(parent.dataReference[PropertyIds::ShowParameters]);
parameterButton.setVisible(dynamic_cast<NodeContainer*>(parent.node.get()) != nullptr);
parameterButton.setVisible(isContainer);

if(isContainer)
{
parameterUpdater.setCallback(parent.node->getValueTree(), {PropertyIds::ShowParameters}, valuetree::AsyncMode::Asynchronously, BIND_MEMBER_FUNCTION_2(Header::updateConnectionButton));
}

freezeButton.setEnabled(parent.node->getRootNetwork()->canBeFrozen());

Expand Down Expand Up @@ -142,6 +149,11 @@ void NodeComponent::Header::updatePowerButtonState(Identifier id, var newValue)
repaint();
}

void NodeComponent::Header::updateConnectionButton(Identifier id, var newValue)
{
parameterButton.setToggleStateAndUpdateIcon((bool)newValue);
}

void NodeComponent::Header::mouseDoubleClick(const MouseEvent& e)
{
if (powerButton.getBoundsInParent().expanded(2).contains(e.getPosition()))
Expand Down
2 changes: 2 additions & 0 deletions hi_scripting/scripting/scriptnode/ui/NodeComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class NodeComponent : public ComponentWithMiddleMouseDrag,
String getPowerButtonId(bool getOff) const;

void updatePowerButtonState(Identifier id, var newValue);
void updateConnectionButton(Identifier id, var newValue);

void paint(Graphics& g) override;
void resized() override;
Expand Down Expand Up @@ -151,6 +152,7 @@ class NodeComponent : public ComponentWithMiddleMouseDrag,
valuetree::RecursiveTypedChildListener dynamicPowerUpdater;

valuetree::PropertyListener powerButtonUpdater;
valuetree::PropertyListener parameterUpdater;
valuetree::PropertyListener colourUpdater;
HiseShapeButton powerButton;
HiseShapeButton deleteButton;
Expand Down
71 changes: 66 additions & 5 deletions hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,20 @@ void ParameterSlider::checkEnabledState()
modulationActive = parameterToControl != nullptr && parameterToControl->isModulated();
setEnabled(!modulationActive);

String tt;

tt << node->getId() + "." + getName();

if(modulationActive)
{
auto ct = getConnectionSourceTree();
auto nt = valuetree::Helpers::findParentWithType(ct, PropertyIds::Node);

tt << " - modulated by " << nt[PropertyIds::Name].toString();
}

setTooltip(tt);

if (modulationActive)
start();
else
Expand Down Expand Up @@ -1338,12 +1352,59 @@ void ParameterSlider::mouseDoubleClick(const MouseEvent&)
}
}

parameterToControl->addConnectionFrom({});
auto ct = getConnectionSourceTree();


auto v = parameterToControl->getValue();

setValue(v, dontSendNotification);
if(ct.isValid())
{


bool sourceIsVisible = true;

valuetree::Helpers::forEachParent(ct, [&](const ValueTree& p)
{
if(p.getType() == PropertyIds::Node)
{
sourceIsVisible &= !(bool)p[PropertyIds::Folded];
}

return false;
});

auto sourceNodeTree = valuetree::Helpers::findParentWithType(ct, PropertyIds::Node);

auto isConnectedToParentChain = pTree.isAChildOf(sourceNodeTree);

if(isConnectedToParentChain)
{
sourceIsVisible = (bool)sourceNodeTree[PropertyIds::ShowParameters];
}

if(sourceIsVisible)
{
parameterToControl->addConnectionFrom({});
auto v = parameterToControl->getValue();
setValue(v, dontSendNotification);
}
else
{
if(isConnectedToParentChain)
{
sourceNodeTree.setProperty(PropertyIds::ShowParameters, true, nullptr);
}
else
{
valuetree::Helpers::forEachParent(ct, [&](ValueTree& p)
{
if(p.getType() == PropertyIds::Node)
{
p.setProperty(PropertyIds::Folded, false, nullptr);
}

return false;
});
}
}
}
}
}

Expand Down

0 comments on commit ec69c81

Please sign in to comment.