Complex docking system

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: