# Node-based interface

**URL:** <https://forum.juce.com/t/node-based-interface/15471>\
**Category:** General JUCE discussion\
**Created:** [September 4, 2015, 9:43am UTC](https://forum.juce.com/t/node-based-interface/15471 "2015-09-04T09:43:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cubic\_disaster](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@cubic\_disaster](https://forum.juce.com/u/cubic_disaster)\
**Post date:** [September 4, 2015, 9:43am UTC](https://forum.juce.com/t/node-based-interface/15471/1 "2015-09-04T09:43:48Z")

</div>

Hello, everyone!

I'm thinking over use JUCE as a backbone for a new application we want to deliver within&nbsp;the next year. The application is supposed to have a node-based interface where you have an endless viewport and you can put nodes and connect them with wires in a way very similar to what Magic VJ software has. I'm wondering if it's something that in a way can be&nbsp;done with a "ready-made" components&nbsp;or it's something that should be heavily coded over an empty base component?&nbsp;

It would be super nice if someone could outline the best way to do that in JUCE, just point a direction to correct place in API reference.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 4, 2015, 10:37am UTC](https://forum.juce.com/t/node-based-interface/15471/2 "2015-09-04T10:37:16Z")

</div>

Have you looked at the plugin host demo?

But it's not a trivial thing to do, and isn't something where you're going to find any&nbsp;ready-made code that would magically do most of the work for you. Not sure what high level advice to give, other than to use a ValueTree to store your data model.

---

<div class="post-metadata">

**Author:** ![jimh](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@jimh](https://forum.juce.com/u/jimh)\
**Post date:** [September 6, 2015, 4:48pm UTC](https://forum.juce.com/t/node-based-interface/15471/3 "2015-09-06T16:48:00Z")

</div>

I was thinking the same thing a while ago. I could imagine more than one program I'd want to write that involved connecting nodes with wires. So I wondered if it would make sense to have some basic node framework first. Then you could more quickly put such programs together. In fact I did start to make one.  
  
But in the end I decided---at least for one program---that it wouldn't be appropriate. The problem was that the way I wanted to make the nodes work was too specific to the application, and so there wasn't much to be gained out of some general node/edge framework. At least I couldn't think of a way. Maybe someone else could.  
  
One program I'm working on is an editor for one of my synths, which has very modular capabilities. I think you can get to a screenshot here:  
  
http://forums.johnbowen.com/viewtopic.php?f=1&t=16379  
  
The nodes just derive from Component and override the paint() function to paint themselves. The nodes contain child components that are the controls on each node, which in my case are mostly sliders. The connectors (wires) are also derived from the Component class. JUCE makes these easy because of the drawing tools available. I use the Path class to draw them, specifically the Path::quadraticTo() function. I can also easily select the connectors with the mouse---for example, to delete them---by overriding the Component::hitTest() function. In that function I use Path::getNearestPoint() to see if the mouse click is close to the connector. I was able to easily zoom (scale) the entire scene in and out. All nodes and connectors are children of a "surface" which is also derived from Component. I just make one call to the surface's Component::setTransform() function and everything scales.  
  
There are other, newer languages I'd rather use than C++ (for example, D or C#). But I don't know of any other GUI library that let's me do this kind of stuff _and_ is cross-platform. So I stick with C++ for this reason.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 6, 2015, 5:47pm UTC](https://forum.juce.com/t/node-based-interface/15471/4 "2015-09-06T17:47:30Z")

</div>

Yeah, people have asked before for&nbsp;library classes for this kind of thing, but I just don't think it's&nbsp;possible to write something that's both generic enough for people to customise, and also&nbsp;high-level enough to actually be useful.
