You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using edit variables to add variables that represent the width and height of the UI viewport. I am thinking these should probably be of REQUIRED strength, but the solver doesn't seem to accept this strength on edit variables.
If the size of the viewport is not required, I think I might sometimes get strange results where the solver decides to change the viewport size. This isn't supposed to happen. Do you have any ideas what I might do here?
The text was updated successfully, but these errors were encountered:
I had the same issue recently. According to this, (which is for a different implementation, but I assume has the same limitations), edit variables can't be used in checking satisfiability, they can only be a suggestion. This seems to hold for every cassowary implementation I've looked at, it's not clear why but it probably makes changing edit variables more efficient by avoiding the cost of checking satisfiability.
Anyway, you have two choices, you can remove and re-add width and height constraints every time the viewport changes, which is the approach suggested here.
Or, do what I'm doing which is just setting the window size strength to REQUIRED - 1.0. This way it will still take priority over every other variable, and only be broken if it conflicts with the REQUIRED constraints, so if you don't always have control over the window size, you won't have to have a satisfiable layout for every possible window size. If you don't do this, and it's possible for your window size to have a size of 0x0, you won't be able to set a REQUIRED size or minimum size for any UI element. Obviously there are trade offs to both, but this seems to work pretty well so far. Better to catch more UnsatisfiableConstraint errors while designing the layout, than have them be possible while resizing your window.
I suppose the best case would be to catch the UnsatisfiableConstraint errors while resizing and prevent the window from resizing, but it might not always be possible or easy depending on what your viewport is, if it's managed by a window manager for instance.
I am using edit variables to add variables that represent the width and height of the UI viewport. I am thinking these should probably be of REQUIRED strength, but the solver doesn't seem to accept this strength on edit variables.
If the size of the viewport is not required, I think I might sometimes get strange results where the solver decides to change the viewport size. This isn't supposed to happen. Do you have any ideas what I might do here?
The text was updated successfully, but these errors were encountered: