Return infinity instead of -1 as a default value for max sizes
This was a bit inconsistent, because in the case of a Rectangle its
Layout.maximumWidth would return -1 by default (which was supposed to
be interpreted as infinity) However, since the maximumWidth propagated
up to the layout, the layout.Layout.maximumWidth would return
1000000000. Adding two Rectangles to the layout would make
layout.Layout.maximumWidth return 2000000000, and adding a third item
with Layout.maximumWidth:1 would make layout.Layout.maximumWidth
return 2000000001
With this change, since infinity + number = infinity, everything
that can grow to infinity will just return infinity.
In addition a developer can now more intuitively do comparisons
like this:
if (value > Layout.minimumWidth && value < Layout.maximumWidth)
instead of
if ((value == -1 || value > Layout.minimumWidth) &&
(value != -1 && value < Layout.maximumWidth))
Now, as a bonus, it becomes less consistent to set an attached
(min,max) property to -1 in order to reset it to its implicit value.
This also fixes a documentation issue with regards to the attached
Layout.{min|max}imum{Width|Height} properties. It only told the story
correct if the item was not a layout, and updates the docs for the max
sizes to mention that it returns Number.POSITIVE_INFINITY
Change-Id: Ia638064fd3ed5614d7e496a9b5e4aa8fcb7307f7
Reviewed-by:
Richard Moe Gustavsen <richard.gustavsen@digia.com>
Showing
Please register or sign in to comment