Split Window Component


I'm relatively new to Juce. It's a really nice library. I wanted to use a simple “splitter window” kind of component but the StretchableLayout didn't work quite like I wanted. So I wrote one for myself. I'm posting this SplitComponent (attached files) in case it's of any use to anyone else. There are some notes in the header file. I've only used it on Windows.

I debated whether to include “panel” components by default on each side, but ended up not. So if you want to add a child to the SplitComponent that tries to take up the whole area of its parent, you need to enclose it in a “dummy” component panel first. (I could have create a special PanelComponent for this, but a plain old Component seems to work fine.) Also, I borrowed the idea of gravity from the wxWidgets splitter window.

I imagine that this might work well by putting some sort a resizeable layout component on either side. For example, this one I came across: http://www.juce.com/forum/topic/resizablelayout . I haven't tried that yet but probably will.

The split bar in the middle paints itself using drawStretchableLayoutResizerBar() so it fits in with the standard look-and-feel. One thing I noticed is that if you want to create your own new component to extend Juce, it won't necessarily work with the look-and-feel because the look and feel class only knows about the standard components. I understand the reason for doing it that way---so that the look and feel author can have everything in one place to work with and add new ones. But it might be nice for an author of a new component to have a way to add on to that. (Perhaps extended components can register and then provide drawing functions for known standard look-and-feel types. Not that I have a need for it at the moment, though. Just a thought.)



This is nice. Thanks for sharing. One thing is that it doesn't seem to resize correctly when using it as a horizontal spilt window? The following:

    splitWindow = new SplitComponent(*textEditor, *outputComponent, false);

causes the component to resize with the horizontal split bar at the very top of the screen.

I also noticed that when I  drag the split window down it messes up my menubar?

I'll go through the code and see what I can see, perhaps I'm instantiating it incorrectly? Regardless of that, thanks again for sharing. I did find the JUCE layout resizer a little awkward to use, this seems much simpler. 


A quick read of your (extremely clear) documentation and things were soon put right!


but where is the attached file?


It’s an old thread. I guess the attachment got stripped off when they changed the forum. Here they are again:

SplitComponent.cpp (11.9 KB)
SplitComponent.h (10.7 KB)


thank you:slight_smile: