ComponentBoundsConstrainer::setSizeLimits jassert

I need to disable a ComponentBoundsConstrainer size limits (and only size limits, I need on screen amount stay there), so I wrote:

ComponentBoundsConstrainer::setSizeLimits(0, 0…)

However that trigged an assert: jassert (minimumWidth > 0 && minimumHeight > 0);

“setMinimumWidth()” doesnt trig this assert, I know I can disable the minimun size with it, however, why cannot we disable it with setSizeLimits()? Maybe does this need a small fix?

Well, if setMinimumWidth doesn’t trigger an assertion, then I should add one! It would make no sense at all for it to allow zero-sized components.

If you want unrestrained sizing, just set a big range, e.g. 1 to 0x7fffffff

I know it seems it doesnt have sense, but I need resize a component to zero (and doesnt work making it invisible). If you add an assertions to these set funcions, I’m fckd. If you do that, could you please add something like a switch to turn on/off the ComponentBoundsConstrainer effect? Thanks you

If you’re struggling to make the constrainer class work in a context that it wasn’t designed for, then perhaps it’s the wrong class to be using…?

I’m using a class that inherits TopLevelWindow in two enviroments. One enviroment is a normal one, where ComponentBoundsConstrainer work as expected. The other enviroment use a custom and complex bounds constrainer with more variables and special rules. And I need when the TopLevelWindow works with the second enviroment it ignores the ComponentBoundsConstrainer.

Of course, I can rewrite a custom ComponentBoundsConstrainer that works on both enviroment, but I was trying to save some time using your CBC.

TopLevelWindow really isn’t designed to cope with a zero-size. The OS may not even support zero-size windows, so I try to avoid that happening.

How would you treat a TopLevelWindow that you want to switch between the Desktop and a StretchableLayoutManager which have a minimum size of zero?

The assert should be in the TopLevelWindow, not in the ComponentBoundsConstrainer, i think

I can’t think of a circumstance where I’d allow a TopLevelWindow to become so small. You should probably be using a completely different class. E.g. your component could be put inside a TopLevelWindow when it’s on the desktop, and inside something else when it’s not.

It makes sense to me. I’ll do that. Thanks for your time! :slight_smile: