Skip to content

Commit

Permalink
- fix #584
Browse files Browse the repository at this point in the history
- make goto button in connection list work with locked containers
  • Loading branch information
christoph-hart committed Oct 16, 2024
1 parent 66bdd1e commit 4572cb0
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 20 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f6a6c7169429983f39eb61d125468dd060fb2ed8
66bdd1eb58f13d0b2b742d79533176365f78a784
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 "f6a6c7169429983f39eb61d125468dd060fb2ed8"
#define PREVIOUS_HISE_COMMIT "66bdd1eb58f13d0b2b742d79533176365f78a784"
10 changes: 7 additions & 3 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ struct RootUndoAction: public UndoableAction
WeakReference<NodeBase> prev, current;
};

void DspNetworkGraph::setCurrentRootNode(NodeBase* newRoot, bool useUndo)
void DspNetworkGraph::setCurrentRootNode(NodeBase* newRoot, bool useUndo, bool allowAnimation)
{
if(newRoot == network->getRootNode())
newRoot = nullptr;
Expand Down Expand Up @@ -611,7 +611,8 @@ void DspNetworkGraph::setCurrentRootNode(NodeBase* newRoot, bool useUndo)

auto zoomFactor = zoomIn ? 1.008f : JUCE_LIVE_CONSTANT_OFF(0.993f);

parent->makeSwapSnapshot(zoomFactor);
if(allowAnimation)
parent->makeSwapSnapshot(zoomFactor);

auto g = this;

Expand All @@ -626,7 +627,10 @@ void DspNetworkGraph::setCurrentRootNode(NodeBase* newRoot, bool useUndo)
g->grabKeyboardFocus();
};

Timer::callAfterDelay(JUCE_LIVE_CONSTANT_OFF(350), f);
if(allowAnimation)
Timer::callAfterDelay(JUCE_LIVE_CONSTANT_OFF(350), f);
else
f();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class DspNetworkGraph : public ComponentWithMiddleMouseDrag,

UndoManager rootUndoManager;

void setCurrentRootNode(NodeBase* newRoot, bool useUndo=true);
void setCurrentRootNode(NodeBase* newRoot, bool useUndo=true, bool allowAnimation=true);

NodeBase* getCurrentRootNode() const { return currentRootNode != nullptr ? currentRootNode.get() : network->getRootNode(); }

Expand Down
68 changes: 63 additions & 5 deletions hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,21 +1295,79 @@ void MacroPropertyEditor::ConnectionEditor::buttonClicked(Button* b)
}
else if (b == &gotoButton)
{
if (auto targetNode = node->getRootNetwork()->getNodeWithId(data[PropertyIds::NodeId].toString()))
auto nodeToShow = node.get();

if(showSource)
{
nodeToShow = node->getRootNetwork()->getNodeForValueTree(valuetree::Helpers::findParentWithType(data, PropertyIds::Node));
}
else
{
auto nodeId = data[PropertyIds::NodeId].toString();
nodeToShow = node->getRootNetwork()->getNodeWithId(nodeId);
}

if (nodeToShow != nullptr)
{
auto sp = findParentComponentOfClass<ZoomableViewport>();

auto gotoNode = [sp, targetNode]()
auto gotoNode = [sp, nodeToShow]()
{
auto nv = nodeToShow->getValueTree();
auto um = nodeToShow->getUndoManager();

ValueTree lockedContainer;





valuetree::Helpers::forEachParent(nv, [&](ValueTree& v)
{
if(v.getType() == PropertyIds::Node)
{
v.setProperty(PropertyIds::Folded, false, um);

if(v[PropertyIds::Locked])
{
lockedContainer = v;
return true;
}

}

return false;
});

sp->setCurrentModalWindow(nullptr, {});

if (auto nc = sp->getContent<DspNetworkGraph>()->getComponent(targetNode))
auto currentRootTree = sp->getContent<DspNetworkGraph>()->getCurrentRootNode()->getValueTree();

if(!lockedContainer.isValid() && !nodeToShow->getValueTree().isAChildOf(currentRootTree))
{
lockedContainer = nodeToShow->getValueTree();

if(lockedContainer.getParent().getType() == PropertyIds::Nodes)
lockedContainer = lockedContainer.getParent().getParent();
}

if(lockedContainer.isValid())
{
if(auto newRoot = nodeToShow->getRootNetwork()->getNodeForValueTree(lockedContainer, false))
{
sp->getContent<DspNetworkGraph>()->setCurrentRootNode(newRoot, true, false);
}
}



if (auto nc = sp->getContent<DspNetworkGraph>()->getComponent(nodeToShow))
{
nc->grabKeyboardFocus();
}

targetNode->getRootNetwork()->deselectAll();
targetNode->getRootNetwork()->addToSelection(targetNode, ModifierKeys());
nodeToShow->getRootNetwork()->deselectAll();
nodeToShow->getRootNetwork()->addToSelection(nodeToShow, ModifierKeys());
};

MessageManager::callAsync(gotoNode);
Expand Down
35 changes: 26 additions & 9 deletions hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,24 @@ struct MacroPropertyEditor : public Component,
addAndMakeVisible(connectionViewport);
connectionViewport.setViewedComponent(&connectionContent, false);

if(parameter != nullptr)
{
if(parameter->data[PropertyIds::Automated])
{
connectionArray.addIfNotAlreadyThere(parameter->getConnectionSourceTree(false));
}
else
{
addAndMakeVisible(connectionButton);
connectionButton.setLookAndFeel(&blaf);
connectionButton.addListener(this);
}
}

int height = jmin(700, connectionArray.isEmpty() ? 10 : (100 + (connectionArray.size() * 110)));

if (!containerMode)
{
if(connectionButton.isVisible())
height += 32;
addAndMakeVisible(connectionButton);
connectionButton.setLookAndFeel(&blaf);
connectionButton.addListener(this);
}

setSize(parameterProperties.getWidth() + connectionViewport.getScrollBarThickness(), parameterProperties.getHeight() + height);

Expand Down Expand Up @@ -331,7 +340,7 @@ struct MacroPropertyEditor : public Component,
auto b = getLocalBounds();
b.removeFromTop(y);

if(!containerMode)
if(connectionButton.isVisible())
connectionButton.setBounds(b.removeFromBottom(32));

connectionViewport.setBounds(b);
Expand All @@ -340,7 +349,7 @@ struct MacroPropertyEditor : public Component,
resizer.setBounds(getLocalBounds().removeFromRight(s).removeFromBottom(s));
}

static String getPathFromNode(bool showSource, ValueTree& data)
static String getPathFromNode(bool showSource, const ValueTree& data)
{
String text;

Expand Down Expand Up @@ -396,7 +405,15 @@ struct MacroPropertyEditor : public Component,
continue;
}

auto newEditor = new ConnectionEditor(node, c, !containerMode);
auto isSource = true;

if(parameter != nullptr && c.isAChildOf(parameter->data))
isSource = false;

if(parameter == nullptr)
isSource = false;

auto newEditor = new ConnectionEditor(node, c, isSource);
connectionContent.addAndMakeVisible(newEditor);
connectionEditors.add(newEditor);
}
Expand Down

0 comments on commit 4572cb0

Please sign in to comment.