Should I use view restrictions or the minimum window size?

I am creating an application for use in OS X, and I notice how useful the features of the new restrictions are in the Builder interface (which is now built into Xcode). It is so useful and dynamic that I wonder if I need to set a minimum window size or just rely on the limitations of my windows to set the minimum and maximum values ​​myself.

I have the feeling that OS X takes into account the minimum and maximum window sizes, taking into account issues other than window size limits, and that it may be useful to set the minimum and maximum values ​​for this, but it also seems to me that this might be a good style to rely on constraints to dynamically set minimum and maximum window heights due to their dynamic behavior and all. For example, if I decide to change the minimum width of a control with restrictions, I don’t have to worry about changing the minimum minimum width of the window.

Another more important example of the advantages of using restrictions to set the minimum and maximum window sizes is that if the user changes something like the size of the text, the affected controls in my application can dynamically change their size restrictions, but the statically set minimum and maximum sizes windows will destroy this dynamic behavior.

Again, all these advantages should also be taken into account, given the fact that OS X can take into account the minimum and maximum window sizes and that it may be useful to set the minimum and maximum values ​​for this reason; I'm just not sure if OS X takes them into account, and if they do , like , he uses them.

I looked through the Apple documentation and cannot find anything that will provide a satisfactory answer.

+6
source share
1 answer

It is best to try yourself in such a situation. It took no more than two minutes to create a new application with one window and several controls. You don’t need to add any code at all if you just want to play with resizable:

window 1

There is no minimum size and restrictions in this window, and the problem is immediately obvious. You can resize the window to look like this:

window 2

Adding some constraints between the buttons shows a promise that the constraints provide. Now this window looks at least:

window 3

A few more restrictions on the label finally gave the desired result:

window 4

This is great, but it took a bit of work. I did not add a full set of restrictions - a vertical restriction between two buttons of the right hand would be unnecessary, since there is already one between the buttons on the left. For a window with many controls, it’s enough to set limits to cover all kinds: a) very useful and useful, or b) pain in the butt and a little extra value. It depends on your situation. The simplest scheme is to simply add the heights of the controls that may overlap (two buttons and a label) and the required spaces between them, and then set this as the minimum height for the window.

I see that any strategy is useful, depending on the contents of the window. Actually, I don’t think that they are really two different strategies ... setting minimum window sizes is just another kind of constraint that you add. For example, there may be a size below which your window looks just silly or not very useful, so you can set a minimum window size for these sizes. At the same time, you can set restrictions between buttons to prevent controls from overlapping in localized versions (for example, German names tend to get quite long).

+2
source

Source: https://habr.com/ru/post/914967/


All Articles