Skip to content

Commit

Permalink
- scriptnode UX crusade pt. II: added container lock, custom template…
Browse files Browse the repository at this point in the history
…s, root node navigation

- fixed regression from last commit that resetted root parameters
  • Loading branch information
christoph-hart committed Oct 12, 2024
1 parent 3735ffd commit c74524c
Show file tree
Hide file tree
Showing 32 changed files with 1,510 additions and 271 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23229250a6528f0d5891992b2979b7ee6fb990ae
3735ffd29ed66c01805992b4fe0e574e29d00c5c
2 changes: 1 addition & 1 deletion hi_backend/backend/CompileExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ CompileExporter::ErrorCodes CompileExporter::exportInternal(TargetTypes type, Bu

String codeCommit = hisePath.getChildFile("currentGitHash.txt").loadFileAsString().trim();

if(buildCommit != codeCommit)
if(buildCommit != codeCommit && !isUsingCIMode())
{
auto confirmation = PresetHandler::getCustomName("", "The source code has a different commit hash than the HISE build. This will likely lead to undefined behaviour including compile errors or undetected errors. In order to proceed with the compilation, type in \"I know\" and click OK");

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 "bc6a0cd141f7087ae277432dde42aacc604abc22"
#define PREVIOUS_HISE_COMMIT "3735ffd29ed66c01805992b4fe0e574e29d00c5c"
5 changes: 2 additions & 3 deletions hi_backend/backend/debug_components/ApiBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ void DspNodeList::NodeItem::paint(Graphics& g)
{
if (node != nullptr)
{
bool selected = node->getRootNetwork()->isSelected(node);


bool selected = node->getRootNetwork()->isSelected(node);

auto ca = area.withWidth(4);


Expand Down
95 changes: 93 additions & 2 deletions hi_backend/backend/debug_components/ApiBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,23 @@ class DspNodeList : public SearchableListComponent,
dragListener(&dragButton, [parameterIndex](DspNetworkGraph* g){ return DspNetworkListeners::MacroParameterDragListener::findSliderComponent(g, parameterIndex); })
{
pname.getTextValue().referTo(ptree.getPropertyAsValue(PropertyIds::ID, parent->getUndoManager()));

auto value = (double)ptree[PropertyIds::Value];
valueSlider.setValue(value, dontSendNotification);

valueSlider.getValueObject().referTo(ptree.getPropertyAsValue(PropertyIds::Value, parent->getUndoManager()));

addAndMakeVisible(valueSlider);
addAndMakeVisible(dragButton);
addAndMakeVisible(pname);



valueSlider.setSliderStyle(juce::Slider::SliderStyle::LinearHorizontal);
valueSlider.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 0, 0);

valueSlider.setLookAndFeel(&laf);
valueSlider.setValue(ptree[PropertyIds::Value], dontSendNotification);


pname.setFont(GLOBAL_BOLD_FONT());
pname.setEditable(false, true);
Expand Down Expand Up @@ -554,6 +560,9 @@ class DspNodeList : public SearchableListComponent,

void mouseUp(const MouseEvent& event) override
{
if(!isEnabled())
return;

if(event.mods.isShiftDown())
label.showEditor();
else if (node != nullptr)
Expand All @@ -573,6 +582,8 @@ class DspNodeList : public SearchableListComponent,
HiseShapeButton powerButton;
HiseShapeButton dragButton;

bool currentlyVisible = true;

Rectangle<int> area;

ScopedPointer<DspNetworkListeners::MacroParameterDragListener> dragListener;
Expand Down Expand Up @@ -674,16 +685,96 @@ class DspNodeList : public SearchableListComponent,
String getSearchTermForCollection() const override { return "LocalCables"; }
};

struct UsedNodes : public NodeCollection
struct UsedNodes : public NodeCollection,
public DspNetworkListeners::DspNetworkGraphRootListener
{
UsedNodes(DspNetwork* network) :
NodeCollection(network, 1)
{
setName("Used Nodes");
addItems(network->getListOfUsedNodeIds(), false);
currentRoot = network->getRootNode();
refreshAlpha(false);

lockListener.setCallback(network->getValueTree(), { PropertyIds::Locked }, valuetree::AsyncMode::Asynchronously, [this](ValueTree v, const Identifier&)
{
this->refreshAlpha(true);
});
}

void refreshAlpha(bool fade)
{
auto vt = currentRoot->getValueTree();

callRecursive<NodeItem>(this, [vt, fade](NodeItem* ni)
{
auto nt = ni->node->getValueTree();
auto isVisible = nt == vt || nt.isAChildOf(vt);

ValueTree lockedParent;

valuetree::Helpers::forEachParent(nt, [&](const ValueTree& v)
{
if(v.getType() == PropertyIds::Node)
{
if(v[PropertyIds::Locked])
{
lockedParent = v;
return true;
}
}

return false;
});

if(lockedParent.isValid() && lockedParent != nt)
isVisible &= (vt == lockedParent || vt.isAChildOf(lockedParent));

auto alpha = isVisible ? 1.0f : 0.2f;

if(fade)
Desktop::getInstance().getAnimator().animateComponent(ni, ni->getBoundsInParent(), alpha, 500.0, false, 1.5, 1.0);
else
ni->setAlpha(alpha);

ni->setEnabled(alpha > 0.5f);

return false;
});
}

WeakReference<NodeBase> currentRoot;

void onRootChange(NodeBase* newRoot) override
{
if(currentRoot != newRoot)
{
currentRoot = newRoot;
refreshAlpha(true);
}
}

static void onRootChange(Component& c, NodeBase* n)
{
jassertfalse;
}

void resized() override
{
NodeCollection::resized();

if(!initialised)
{
DspNetworkListeners::initRootListener(this);
initialised = true;
}
}

bool initialised = false;

String getSearchTermForCollection() const override { return "UsedNodes"; }

valuetree::RecursivePropertyListener lockListener;
};

struct UnusedNodes : public NodeCollection
Expand Down
35 changes: 35 additions & 0 deletions hi_backend/backend/dialog_library/dialog_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,41 @@ struct WelcomeScreen: public multipage::EncodedDialogBase
Array<File> fileList;
};

struct ScriptnodeTemplateExporter: public EncodedDialogBase
{
ScriptnodeTemplateExporter(BackendRootWindow* bpe, scriptnode::NodeBase* n):
EncodedDialogBase(bpe),
node(n)
{
loadFrom("897.sNB..D...............35H...oi...UM.........J09R+fIsAcoA.lrVfl.tzniLwvJeGajdMaHDyvtUbuc0f4YTAhcBXdU3KQESTMhwnxL3b9Afb.LG.7Dthf6CiiV7DCJUtTICBWfYKOh6GHpJUYpnjb1xdX30VcIikKGjASUlJVx7k3+BBYtXIyG8CVgoxBBX1vYN1AUpprTQASEKRNG5bztnlfgBGxyZAQOIaUvrWKExf9FBljKjSisP8eAMoZl91eXRUUkHhpYZ+sCC6dqIUkHR.plu4ucruD2AzizgRfauUMcKLNeYenNjHcn4jkZtLV.be+CffoHWzq.tY9y7Hqmy6VPSXwXCv8xgPLocxseanlPMgR6uojynq23lyoShschGi8Pa29LA+2ewYw+Bia7qyU4Lu0W5wRNL42K4nKqXZDUkDw2C41ztKMimbJeo8ho+S8oJ4LnKRcv5iGUiIsSEBefbQDxd57o8+41L0gZ+8KlWhufgwsm07wwtK1fkYv2HNTT+HsG6ghpZzm8zPyg6qCCQc9F8Jl5u98Bhx4cp2YNYI3oC4rIehZlS9ROBB+xP.lzZIP.vHR3HgRQJJpl3pwwHsqQSmI9rQj21EmUSgl1Sdw2LIG3eYIGrl6gO9jXykzFwimbrbpDzgAcxUd8.wYNGCleHcPddh3rSGM2.8ahz6sCBWtd2zMIKZ1q7YR6nrd0M9mcS30BeKoU6fsqrb04uuOgtvjYTYX.njnFRmx3PJ0LkP..DP..jQ.XLipIHJUr.IUJqBpIyB.QjVejCv.hLcr3rADDVtawtHJEc6PFDSFDXlFZwkeYetmqttN7BArpkJdLolMZDl93Peki8rNALClo0C1RVk9eJTFyZbMxCn9nvdmgpB1GcyPQjaOsX8ZDs4dYEB4wLl248O.3r06wnQKTVBEAw17n8AOxnHi+o8+J4KKRPeitpLXq.BY62kwMsAwIAD.FnumFHgx0H1.XHsWTD2pehVnKAxnIgEGHuA3n+dufq+SGFwLxlzf73CurcPUcxa3VbNKWm.ZZ8novmexiRbZ+SPydVz8lBqtAjpu8fnjeTeWdRDxui7Xt1lph1OU0P1TQ9k+nHKZnODXREj+EoUhRDnQos1CtmTna.ho+AcK.z4gnfhQ9bmmHWI9kyJLfeY9C8hety6kNB..X5H...qi...");
}

void bindCallbacks() override
{
MULTIPAGE_BIND_CPP(ScriptnodeTemplateExporter, onCreate);
}

var onCreate(const var::NativeFunctionArgs& args)
{
auto isLocal = (bool)this->state->globalState["Location"];

zstd::ZDefaultCompressor comp;
MemoryBlock mb;

auto copy = node->getValueTree().createCopy();

DspNetworkListeners::PatchAutosaver::stripValueTree(copy);

auto t = isLocal ? BackendDllManager::FolderSubType::ProjectNodeTemplates : BackendDllManager::FolderSubType::GlobalNodeTemplates;
auto root = BackendDllManager::getSubFolder(getMainController(), t);
auto xml = copy.createXml();
root.getChildFile(node->getName()).withFileExtension("xml").replaceWithText(xml->createDocument(""));
return var();
}

NodeBase::Ptr node;
};

struct AboutWindow: public multipage::EncodedDialogBase
{
AboutWindow(BackendRootWindow* bpe):
Expand Down
4 changes: 4 additions & 0 deletions hi_core/hi_components/floating_layout/FloatingIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ namespace ColumnIcons
81,79,66,109,103,93,66,147,24,226,65,109,103,170,66,84,227,179,65,99,109,143,194,227,66,246,40,180,65,98,150,163,15,67,242,210,226,65,76,23,39,67,25,132,79,66,229,208,44,67,172,92,163,66,108,20,46,29,67,90,164,160,66,98,45,178,23,67,68,139,111,66,150,
163,7,67,68,11,47,66,231,123,230,66,70,182,24,66,108,143,194,227,66,246,40,180,65,99,101,0,0 };

static const unsigned char nextIcon[] = { 110,109,142,210,42,68,248,64,73,67,108,143,98,29,68,248,64,73,67,108,0,128,7,68,130,95,215,67,108,254,239,20,68,130,95,215,67,108,142,210,42,68,248,64,73,67,99,109,0,128,69,68,248,64,73,67,108,228,15,56,68,248,64,73,67,108,107,45,34,68,130,95,215,67,
108,136,157,47,68,130,95,215,67,108,0,128,69,68,248,64,73,67,99,101,0,0 };


};


Expand Down
44 changes: 44 additions & 0 deletions hi_dsp_library/dsp_nodes/CableNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,50 @@ namespace control
}
};

template <typename ParameterClass> struct locked_mod: public mothernode,
public pimpl::parameter_node_base<ParameterClass>,
public pimpl::no_processing
{
SN_NODE_ID("locked_mod");
SN_GET_SELF_AS_OBJECT(locked_mod);
SN_DESCRIPTION("Adds a scaled modulation dragger to its immediate locked node container parent");
SN_ADD_SET_VALUE(locked_mod);

locked_mod() :
pimpl::parameter_node_base<ParameterClass>(getStaticId())
{};

void setValue(double input)
{
if (this->getParameter().isConnected())
this->getParameter().call(input);
}
};

template <typename ParameterClass> struct locked_mod_unscaled: public mothernode,
public pimpl::parameter_node_base<ParameterClass>,
public pimpl::no_processing,
public pimpl::no_mod_normalisation
{
SN_NODE_ID("locked_mod_unscaled");
SN_GET_SELF_AS_OBJECT(locked_mod_unscaled);
SN_DESCRIPTION("Adds a unscaled modulation dragger to its immediate locked node container parent");
SN_ADD_SET_VALUE(locked_mod_unscaled);

locked_mod_unscaled() :
pimpl::parameter_node_base<ParameterClass>(getStaticId()),
pimpl::no_mod_normalisation(getStaticId(), { "Value" })
{};

static constexpr bool isNormalisedModulation() { return false; }

void setValue(double input)
{
if (this->getParameter().isConnected())
this->getParameter().call(input);
}
};

template <typename ParameterClass, typename ConverterClass>
struct converter : public mothernode,
public pimpl::templated_mode,
Expand Down
1 change: 1 addition & 0 deletions hi_dsp_library/node_api/helpers/node_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ DECLARE_ID(LocalId);
DECLARE_ID(ParameterId);
DECLARE_ID(Type);
DECLARE_ID(Folded);
DECLARE_ID(Locked);
DECLARE_ID(FactoryPath);
DECLARE_ID(Frozen);
DECLARE_ID(EmbeddedData);
Expand Down
64 changes: 52 additions & 12 deletions hi_scripting/scripting/scriptnode/api/DspNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,10 @@ NodeBase* DspNetwork::createFromValueTree(bool createPolyIfAvailable, ValueTree
StringArray sa;
auto newId = getNonExistentId(id, sa);
newNode->setValueTreeProperty(PropertyIds::ID, newId);
nodes.add(newNode);
nodes.addIfNotAlreadyThere(newNode);
}
else
currentNodeHolder->nodes.add(newNode);
currentNodeHolder->nodes.addIfNotAlreadyThere(newNode);

return newNode.get();
}
Expand Down Expand Up @@ -2438,6 +2438,12 @@ void HostHelpers::setNumDataObjectsFromValueTree(OpaqueNode& on, const ValueTree
});
}

void DspNetworkListeners::DspNetworkGraphRootListener::onChangeStatic(DspNetworkGraphRootListener& l, NodeBase* n)
{
if(n != nullptr)
l.onRootChange(n);
}

bool OpaqueNetworkHolder::isPolyphonic() const
{ return false; }

Expand Down Expand Up @@ -2569,7 +2575,30 @@ void ScriptnodeExceptionHandler::validateMidiProcessingContext(NodeBase* b)


#if USE_BACKEND
DspNetworkListeners::MacroParameterDragListener::MacroParameterDragListener(Component* c_, const std::function<Component*(DspNetworkGraph*)>& initFunction_):
void DspNetworkListeners::initRootListener(DspNetworkGraphRootListener* l)
{
auto asComponent = dynamic_cast<Component*>(l);
jassert(asComponent != nullptr);

Component::callRecursive<DspNetworkGraph>(asComponent->getTopLevelComponent(), [l](DspNetworkGraph* g)
{
g->rootBroadcaster.addListener(*l, DspNetworkGraphRootListener::onChangeStatic);
return true;
});
}

WeakReference<NodeBase> DspNetworkListeners::getSourceNodeFromComponentDrag(Component* component)
{
if(auto nc = component->findParentComponentOfClass<NodeComponent>())
return nc->node.get();

if(auto bc = dynamic_cast<DspNetworkGraph::BreadcrumbButton*>(component))
return bc->node;

return nullptr;
}

DspNetworkListeners::MacroParameterDragListener::MacroParameterDragListener(Component* c_, const std::function<Component*(DspNetworkGraph*)>& initFunction_):
c(c_),
initFunction(initFunction_)
{
Expand Down Expand Up @@ -2628,8 +2657,7 @@ void DspNetworkListeners::MacroParameterDragListener::mouseUp(const MouseEvent&

void DspNetworkListeners::MacroParameterDragListener::mouseDown(const MouseEvent& event)
{
if(sliderToDrag == nullptr)
initialise();
initialise();

if(auto hb = dynamic_cast<HiseShapeButton*>(this->c.getComponent()))
{
Expand Down Expand Up @@ -2680,17 +2708,29 @@ Component* DspNetworkListeners::MacroParameterDragListener::findModulationDragCo

Component* DspNetworkListeners::MacroParameterDragListener::findSliderComponent(DspNetworkGraph* g, int parameterIndex)
{
g->root->node->getValueTree().setProperty(PropertyIds::ShowParameters, true, g->network->getUndoManager());
if(g->isShowingRootNode())
{
g->root->node->getValueTree().setProperty(PropertyIds::ShowParameters, true, g->network->getUndoManager());

Array<MacroParameterSlider*> sliders;
Array<MacroParameterSlider*> sliders;

Component::callRecursive<MacroParameterSlider>(g, [&](MacroParameterSlider* s)
Component::callRecursive<MacroParameterSlider>(g, [&](MacroParameterSlider* s)
{
sliders.addIfNotAlreadyThere(s);
return false;
});

return sliders[parameterIndex]->getDragComponent();
}
else
{
sliders.addIfNotAlreadyThere(s);
return false;
});
auto bc = g->breadcrumbs.getLast();

return sliders[parameterIndex]->getDragComponent();
bc->setIsDraggingParameter(parameterIndex);
return bc;
}


}


Expand Down
Loading

0 comments on commit c74524c

Please sign in to comment.