Complex docking system


#1

i’ve made a first example on how the docking system is coming along.
all is well commented and a simple example is provided to show how easy is building complex resizing guis with docking and components swapping capabilities.

there are still a lot of things to be done, and others to fix: especially in some cases it seems that the StretchableLayout class doesn’t determine the correct size of the sub components, and the last component of the layout sometimes gets resized smaller than the overall area ( maybe rounding errors ? jules take a look if i’m doing something silly ! ) . also the docking indicator is not painted over the correct component, as i’ve used the whole dock area, but this is easy to throw in.

i would like to work on this even more to let it drag subpanels in a glance and so modifying the layout structure with drag and drop; and letting the coder specify the docking constraints.

juce_Dockable.zip

any other interesting ideas i have to throw in ?


#2

hey jules, if you’ve got 5 minutes can you check the app and try resize some resizer bars ? you you try resize the last bar (from top or left) the last component get resized correctly. if you drag another (first or second from top or left) it seems that the last component in the stratchable layout doesn’t get resized correctly ?
could be a fault in the stretchable layout code ?


#3

yes, probably something wrong with the StretchableLayout thing, it always was a bugger to get it working, and I think I’ve seen the same accuracy problem before.


#4

for your notice, i’ve had a look into it and i’ve come up with this solution. not the best approach but it is working, even if it could make your last component to have different size from what you would expect from the layout manager size you set it up (should be a negligible amount of pixels, usually < 10).

to avoid the accuracy problem on the last component, i’ve just limited the placement on the first components only, then i treat the last component separately, making it to reach the remaining size even in case is smaller (and obviously should also when bigger).

//==============================================================================

void StretchableLayoutManager::layOutComponents (Component** const components,
                                                 int numComponents,
                                                 int x, int y, int w, int h,
                                                 const bool vertically,
                                                 const bool resizeOtherDimension)
{
    setTotalSize (vertically ? h : w);
    int pos = vertically ? y : x;

    for (int i = 0; i < numComponents - 1; ++i)
    {
        const ItemLayoutProperties* const layout = getInfoFor (i);

        if (layout != 0)
        {
            Component* const c = components[i];

            if (c != 0)
            {
                if (resizeOtherDimension)
                {
                    if (vertically)
                        c->setBounds (x, pos, w, layout->currentSize);
                    else
                        c->setBounds (pos, y, layout->currentSize, h);
                }
                else
                {
                    if (vertically)
                        c->setBounds (c->getX(), pos, c->getWidth(), layout->currentSize);
                    else
                        c->setBounds (pos, c->getY(), layout->currentSize, c->getHeight());
                }
            }

            pos += layout->currentSize;
        }
    }

    const int layoutItemIndex = numComponents - 1;
    const ItemLayoutProperties* const layout = getInfoFor (layoutItemIndex);


    if (layout != 0)
    {
        Component* const c = components[layoutItemIndex];

        if (c != 0)
        {
            if (resizeOtherDimension)
            {
                if (vertically)
                    c->setBounds (x, pos, w, jmax (layout->currentSize, h - pos));
                else
                    c->setBounds (pos, y, jmax (layout->currentSize, w - pos), h);
            }
            else
            {
                if (vertically)
                    c->setBounds (c->getX(), pos, c->getWidth(), jmax (layout->currentSize, h - pos));
                else
                    c->setBounds (pos, c->getY(), jmax (layout->currentSize, w - pos), c->getHeight());
            }
        }
    }

}

if it’s good for you, please apply something along the lines… i have some complex stretchable interfaces and it’s so bad to show those rounding errors when you resize things, it makes the gui looks less professional… you know :slight_smile:


#5

Ok, nice one. I’ve checked in a version that does this now - thanks!


#6