Skip to content

Commit

Permalink
- scriptnode UI: removed hover label & replaced with tooltip
Browse files Browse the repository at this point in the history
- scriptnode UI: fixed tooltip position when using zoom factor != 100%
- scriptnode UI: improved performance when using big patches with folded containers
  • Loading branch information
christoph-hart committed Sep 30, 2024
1 parent 575e7e2 commit 08a7dac
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 108 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ec69c814adffb911f800b32a8bef6d9d6924b252
575e7e2bb646d973ef0f257acae98ffd02526038
5 changes: 5 additions & 0 deletions hi_backend/backend/BackendRootWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class BackendRootWindow : public TopLevelWindowWithOptionalOpenGL,
TooltipWindow(nullptr, 900)
{};

float getDesktopScaleFactor() const override
{
return Component::getDesktopScaleFactor();
}

String getTipFor(Component&component) override;
};

Expand Down
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 "ec69c814adffb911f800b32a8bef6d9d6924b252"
#define PREVIOUS_HISE_COMMIT "575e7e2bb646d973ef0f257acae98ffd02526038"
2 changes: 1 addition & 1 deletion hi_scripting/scripting/scriptnode/api/NodeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ void HelpManager::render(Graphics& g, Rectangle<float> area)
void HelpManager::addHelpListener(Listener* l)
{
listeners.addIfNotAlreadyThere(l);
l->helpChanged(lastWidth + 30.0f, lastHeight + 20.0f);
//l->helpChanged(lastWidth + 30.0f, lastHeight + 20.0f);
}

void HelpManager::removeHelpListener(Listener* l)
Expand Down
144 changes: 63 additions & 81 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,7 @@ void drawBlockrateForCable(Graphics& g, Point<float> midPoint, Colour cableColou
void DspNetworkGraph::paintOverChildren(Graphics& g)
{
float HoverAlpha = 0.5f;

auto printLabel = [&g](const String& sourceName, Rectangle<float> end, Colour colourToUse)
{
g.setFont(GLOBAL_BOLD_FONT());

String text = "from " + sourceName;

auto ta = end.translated(0.0f, 20.0f).withSizeKeepingCentre(GLOBAL_BOLD_FONT().getStringWidthFloat(text) + 20.0f, 20.0f);

g.setColour(colourToUse);
g.fillRoundedRectangle(ta, 10.0f);

g.setColour(Colours::black.withAlpha(0.8f));
g.drawRoundedRectangle(ta, 10.0f, 2.0f);
g.drawText(text, ta, Justification::centred);
};


if (Component::isMouseButtonDownAnywhere())
HoverAlpha += 0.1f;

Expand Down Expand Up @@ -718,21 +702,10 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
addDragSource(targetSlider);
}

bool shouldPrintLabel = false;

if(!showCables && targetSlider->isMouseOverOrDragging(true))
{
thisAlpha = HoverAlpha;
shouldPrintLabel = true;
}

GlobalHiseLookAndFeel::paintCable(g, start, end, colourToUse, thisAlpha, hc);

if(shouldPrintLabel)
{
printLabel(sourceSlider->getTooltip(), end, colourToUse);

}
}
}
}
Expand Down Expand Up @@ -770,11 +743,8 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
auto numOutputs = multiSource->getNumOutputs();
auto c = MultiOutputDragSource::getFadeColour(index, numOutputs).withAlpha(1.0f);

bool shouldPrintLabel = false;

if(!showCables && s->isMouseOver(true))
{
shouldPrintLabel = true;
thisAlpha = HoverAlpha;
}

Expand All @@ -785,11 +755,6 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
{
drawBlockrateForCable(g, midPoint, c, thisAlpha, multiSource->getNode(), s->node);
}

if(shouldPrintLabel)
{
printLabel(multiSource->getNode()->getId() + "[" + String(index) + "]", end, c);
}
}
}
}
Expand Down Expand Up @@ -839,23 +804,15 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)

auto end = getCircle(s);

bool shouldPrintLabel = false;

if(!showCables && s->isMouseOver(true))
{
shouldPrintLabel = true;
thisAlpha = HoverAlpha;
}

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

auto midPoint = GlobalHiseLookAndFeel::paintCable(g, start, end, cableColour, thisAlpha, hc, network->getCpuProfileFlag());

if(shouldPrintLabel)
{
printLabel(sourceNode->getId(), end, cableColour);
}

if (!midPoint.isOrigin())
{
auto thisSource = ConnectionBase::Helpers::findRealSource(sourceNode);
Expand Down Expand Up @@ -998,50 +955,64 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)

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

while(nb == nullptr)
{
if(b->parent.node.get() == sn)
for(auto b: bypassList)
{
NodeComponent* nb = &b->parent;
if(b->parent.node.get() == sn)
{
nb = &b->parent;
break;
}
}

auto notFolded = true;
sn = sn->getParentNode();

while(notFolded)
{
auto nt = nb->node->getValueTree().getParent();
if(sn == nullptr)
break;
}

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

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

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

nb = nb->findParentComponentOfClass<NodeComponent>();
return false;
});

if(nb == nullptr)
break;
}
if(notFolded)
break;

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

auto sourceRect = getLocalArea(h, h->getLocalBounds());
if(nb == nullptr)
break;
}

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

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

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

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

}

break;
}
}
}
Expand Down Expand Up @@ -1761,15 +1732,23 @@ bool DspNetworkGraph::Actions::foldUnselectedNodes(DspNetworkGraph& g)
return true;
}


auto parent = g.findParentComponentOfClass<ZoomableViewport>();

parent->makeSwapSnapshot(JUCE_LIVE_CONSTANT_OFF(1.005f));
int counter = 0;

auto l = g.network->getListOfNodesWithType<NodeBase>(false);
auto skipAnimation = valuetree::Helpers::forEach(g.network->getValueTree(), [&](const ValueTree& v)
{
if(v.getType() == PropertyIds::Node)
counter++;


return counter > 30;
});

if(!skipAnimation)
parent->makeSwapSnapshot(JUCE_LIVE_CONSTANT_OFF(1.005f));

auto l = g.network->getListOfNodesWithType<NodeBase>(false);

auto isParentNode = [](NodeBase*n, NodeBase* possibleParent)
{
if (n == possibleParent)
Expand Down Expand Up @@ -1842,9 +1821,10 @@ bool DspNetworkGraph::Actions::foldUnselectedNodes(DspNetworkGraph& g)
g.grabKeyboardFocus();
};



Timer::callAfterDelay(JUCE_LIVE_CONSTANT_OFF(300), f);
if(skipAnimation)
f();
else
Timer::callAfterDelay(JUCE_LIVE_CONSTANT_OFF(300), f);

return true;
}
Expand Down Expand Up @@ -2034,6 +2014,7 @@ bool DspNetworkGraph::Actions::showKeyboardPopup(DspNetworkGraph& g, KeyboardPop
}
else
{
#if USE_BACKEND
auto bpe = g.findParentComponentOfClass<BackendRootWindow>();

struct PopupWrapper: public Component,
Expand Down Expand Up @@ -2073,6 +2054,7 @@ bool DspNetworkGraph::Actions::showKeyboardPopup(DspNetworkGraph& g, KeyboardPop
auto w = new PopupWrapper(newPopup);

bpe->setModalComponent(w);
#endif
}


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 @@ -163,7 +163,7 @@ void NodeComponent::Header::mouseDoubleClick(const MouseEvent& e)
return;
}

parent.dataReference.setProperty(PropertyIds::Folded, !parent.isFolded(), nullptr);
parent.dataReference.setProperty(PropertyIds::Folded, !parent.isFolded(), parent.node->getUndoManager());
parent.getParentComponent()->repaint();
}

Expand Down
41 changes: 22 additions & 19 deletions hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,32 +515,35 @@ void ContainerComponent::rebuildNodes()
duplicateDisplay = nullptr;
childNodeComponents.clear();

if (auto container = dynamic_cast<NodeContainer*>(node.get()))
if(!node->getValueTree()[PropertyIds::Folded])
{
int index = 0;
int numHidden = 0;

for (auto n : container->nodes)
if (auto container = dynamic_cast<NodeContainer*>(node.get()))
{
if (auto cn = dynamic_cast<CloneNode*>(container))
int index = 0;
int numHidden = 0;

for (auto n : container->nodes)
{
if (!cn->shouldCloneBeDisplayed(index++))
if (auto cn = dynamic_cast<CloneNode*>(container))
{
numHidden++;
continue;
if (!cn->shouldCloneBeDisplayed(index++))
{
numHidden++;
continue;
}
}
}

auto newNode = n->createComponent();

auto newNode = n->createComponent();

n->getHelpManager().addHelpListener(this);
addAndMakeVisible(newNode);
childNodeComponents.add(newNode);
}
n->getHelpManager().addHelpListener(this);
addAndMakeVisible(newNode);
childNodeComponents.add(newNode);
}

if (numHidden > 0 || (!node->getValueTree()[PropertyIds::ShowClones] && node->getValueTree().hasProperty(PropertyIds::DisplayedClones)))
{
addAndMakeVisible(duplicateDisplay = new DuplicateComponent(node.get(), numHidden));
if (numHidden > 0 || (!node->getValueTree()[PropertyIds::ShowClones] && node->getValueTree().hasProperty(PropertyIds::DisplayedClones)))
{
addAndMakeVisible(duplicateDisplay = new DuplicateComponent(node.get(), numHidden));
}
}
}

Expand Down
35 changes: 31 additions & 4 deletions hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,33 @@ void ParameterSlider::checkEnabledState()
{
auto ct = getConnectionSourceTree();
auto nt = valuetree::Helpers::findParentWithType(ct, PropertyIds::Node);

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

StringArray path;

valuetree::Helpers::forEachParent(ct, [&](const ValueTree& p)
{
if(pTree.isAChildOf(p))
return true;

if(p.getType() == PropertyIds::Parameter || p.getType() == PropertyIds::Node)
{
auto id = p[PropertyIds::ID].toString();
auto nid = p[PropertyIds::Name].toString();
path.add(nid.isNotEmpty() ? nid : id);
}

return false;
});

tt << " - connected to: ";

for(int i = path.size()-1; i >= 0; i--)
{
tt << path[i];

if(i != 0)
tt << ".";
}
}

setTooltip(tt);
Expand Down Expand Up @@ -1387,17 +1412,19 @@ void ParameterSlider::mouseDoubleClick(const MouseEvent&)
}
else
{
auto um = node->getRootNetwork()->getUndoManager();

if(isConnectedToParentChain)
{
sourceNodeTree.setProperty(PropertyIds::ShowParameters, true, nullptr);
sourceNodeTree.setProperty(PropertyIds::ShowParameters, true, um);
}
else
{
valuetree::Helpers::forEachParent(ct, [&](ValueTree& p)
{
if(p.getType() == PropertyIds::Node)
{
p.setProperty(PropertyIds::Folded, false, nullptr);
p.setProperty(PropertyIds::Folded, false, um);
}

return false;
Expand Down

0 comments on commit 08a7dac

Please sign in to comment.