-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added getSize() to FlexibleLayout #77
base: master
Are you sure you want to change the base?
Conversation
Unlike for example SequentialLayout, FlexibleLayout did not have a getSize() method. This causes trouble when using a FlexibleLayout in a Scrollview or another FlexibleLayout.
SequentialLayout is managing a collection of things with a size and therefore should have a size. FlexibleLayout is for cutting up useable space and the size is really a property of some other component / piece of state. I don't think it should have a size personally but am willing to be further convinced. |
Okay @michaelobriena - let me make a case for I learn from your response that However, throughout Famo.us, To complicate things further, It seems as if there are two different ways to understand getSize:
This causes two issues:
These issues are all being solved by defining However, making such change may have one unexpected side-effect. I've read somewhere that you can exploit the difference between defined and actual size to manipulate layout. For example, you could create gaps between items in a Scrollview if the defined size is larger than the (css-styled) size of the element. I would argue, however, that this is an odd way to do things and should not be possible in the first place. So, in the bigger scope of things I would say:
|
@michaelobriena thoughts? |
@markmarijnissen Great points. We are making Surface getSize return the actual size instead of the defined size which is going to be a big improvement in terms of usability. I still believe the issue with giving FlexibleLayout getSize is that it gives the illusion that the FlexibleLayout is in control of it's own size. It is hard for me to not put it in because I think it could be useful and is practically already there but something really gnarly about faking people out about who controls the size of a FlexibleLayout. I think the actual vs defined is a really strong argument in favor of including it. I think my hesitations are mostly for purity reasons which is kind of weak in regards to small matters of usability. I will run it by a few people but this will probably get in. |
So what would it take to be explicit and add an actualSize() method, that is aliased to getSize unless otherwise needed? It would make all the code using it a lot more readable, and be fewer things about the internals to have to keep in mind. |
oh man. i should have read the issue before commenting. i just saw the last response in my email. 😊 |
@michaelobriena Let's see if we can understand your hesitations better, in the hope it will improve architecture and design decisions about famous. I'll have a wild guess. Do you make a seperation between "define-time" and "run-time"? Let me explain:
Things get messy because So a broader and completely different angle to this problem might be to strictly seperate runtime logic and definition logic. In other words, constrain runtime logic to In practical terms, you could create private functions for runtime logic (actual size), which is only to be used in I vote for |
Guys, could we please avoid private functions. I think the developer community has already proven that they need this information to do what they need to do, and I think that trying to keep them away from it is missing the forrest for the trees. I don't think it's our job to try and stop people from doing stupid things. You can warn them and tell them why not do it, but at the end of the day they are just going to fork your code and do it anyway. Having a convention of underscore prefixed means private and unreliable, is more than enough to send the right message. Instead we should probably think about why people need the getSize to point to the computed size, and figure out the best way to help them accomplish their goal. related: Famous/famous#71 |
Yes I agree Vertice - I just realized it is very wrong to use private (underscored) functions for actual public API. I think underscored functions should tell: "private, unreliable, might change". The Perhaps a more clear name would be |
hey @markmarijnissen can you move this to famous/famous referencing this issue? |
Unlike for example SequentialLayout, FlexibleLayout did not have a getSize() method. This causes trouble when using a FlexibleLayout in a Scrollview or another FlexibleLayout.