Concept of max width/height for custom measure function #160
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When implementing a custom measure function there is currently no way of knowing of the width and height passed in refer to an exact height and width or a maximum value. For example when centering a node with a custom measure function it will be passed the width and height of its parent as this is the maximum size it can be measured at. The node being measured does not have this information however and will have to make a guess.
I suggest we add something along the lines of android's concept of measurement modes (MeasureSpec). so that nodes being measured know whether they must measure to a size exactly, at most, or if the can just ignore it totally (this is currently encoded in the size by looking for NaN).
@lucasr @vjeux
Just hit same problem today. I expected measure function to have both
width
andheight
asNaN
for centered element with no sizes. But onlyheight
isNaN
in this situation, whileweight
is the width of parent.Sounds more like a bug to me, does measure function really expects sizes of parent node?
For example this makes it impossible to implement measurement for text views, I have following algorithm in mind and it doesn't work: if dimension of node is set -- use it, else -- use size of contained text.
UPD: Okay, I can use
node.layout.dimensions
to get real metrics of node. What is the point ofwidth
andheight
arguments then?