[RFC] adding height to the measure function #154
Reference in New Issue
Block a user
No description provided.
Delete Branch "width"
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?
The flexbox algorithm is considering text as only thing that does its own layout. Since text usually flows horizontally, the important information for laying it out is the width of its enclosing container (we are assuming its height is unbounded).
In my case I plan to use nodes that do their own layout too, but they are not constrained in same way as text is. (You can imagine this node as a view provided by a different layout engine.)
That means they can be provided height and be unbounded in width. In order to achieve this I need to pass information about height to the measure function as well.
This PR does that and adds some tests too.
Few things to note:
My changes were made mostly im mechanical copy-paste fashion to mimick what's happening with width, since I believe there shouldn't be any differences based on the flex direction.
Looking forward to comments and suggestions!
This sounds good to me. If you port the changes to C and Java I'll gladly merge the pull request :)
I've fixed all three C, java and C# flavors and their tests, each of them is in a sperate commit.
There are two more things (not directly related to adding the width) I've added:
I'm not sure why, but they seem to be run by Travis. ¯_(ツ)_/¯
I can submit both of these improvements as a separate PRs if you wish.
@majak What probably happened is that
nunit-console
is an older version that can not pick up the tests. Try to see if its version is >= 2.6 by by running it without any arguments.I could reproduce this on CentOS7. There are two packages,
NUnit
, which installsnunit-console-2.6
, working just fine, andmono-nunit
, which installsnunit-console
version 2.4 but fails to pick up the tests.@pragmatrix You are right. I have
NUnit version 2.4.8
.Since I don't know much about C# do you suggest I drop commit 8af0b2869017ee05e95956a1ee71f89a13166483 that makes it compile with the old NUnit? (as I've learned it has incorrect commit message)
@majak No need to, these new Assert methods are supported by NUnit 2.6 and your branch compiles in Visual Studio 2015 just fine, nice work!
This is looking good overall, thanks! I'd be more confident about these changes if it contained a more thorough set of unit tests.
@lucasr I've did changes you asked for. There is a commit for each of them, but I also had to fix issues in existing commits' titles, so I had to force push and all of your inlines are gone...
ping :)
Looks good to me! @vjeux any objections? Otherwise we can merge this.
(Personally, I'd prefer all these commits to be merged into a single atomic change before merging.)
lgtm
I've squashed everything into a single commit and modified one last place where the
maxHeight
computation didn't properly mirrormaxWidth
computation (Layout.js:696-704).Thanks a lot @majak!
@paramaggarwal one caveat: If your node has set both width and height its measure function won't be called.
Yes, makes sense. @majak, but if the measure function does get called, it will still continue to layout the children right? Specifically, if I have a box which has a measure function on it, and then two boxes inside it both with
flex: 1
, then the inner boxes will layout as per flex (half-half)?@paramaggarwal To be honest I'm not really sure. We didn't care about that in our use-case, so I didn't even try. However based on some chats we had internally, my impression is that it wouldn't work as you'd like :(
Anyway I believe this would be a valuable addition.