-
-
Notifications
You must be signed in to change notification settings - Fork 949
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
Row and Column for Flame Components #1944
Comments
Sgtm, do you want to work on this? |
@spydon I don't have that much spare time at the moment, therefore rather no, sorry. |
I've a few things on my queue, but I could try tackling this after clear some space on it |
Here are my first attempts:
It can be used like this:
I'm sure there are lots of things i didn't think of and which need to be considered. |
Now supports a constant gap between the children which can be changed dynamically.
To be used like this:
|
Can we rename the Component to be RowComponent instead of ComponentRow? That way it follows the current naming convention. |
@alestiago Done |
In order to get notified about a change in a parent's children this new function will be called now. This feature will help simplifying e.g. the implementation of issue #1944 (Row and Column components).
Is this feature available? |
@mrbeardad Not really. At the moment there's only AlignComponent available, where additional layout components shall be added later. |
Waiting for use now.... |
interesting... +1 |
Hi all! I'd like take a crack at this if you don't mind. I'm taking a look at the old PR #1971 Before I start working on this, may I ask if @spydon and @st-pasha have changed their minds regarding the sizing question? Specifically this question: #1971 (review) Especially considering the implementation part of #2302
|
Of course!
I think that we can do like Pasha said, that the first version can just have a fixed size. What do you think? |
I've actually implemented something similar in the project I'm working on. Started out trying to make the size respond to the children's size. It got so messy, I gave up😅 I guess what I'm trying to say is: I agree that the initial version should have an explicitly defined size. I do, however, think there is value in having a convenience method for returning the theoretical size of the component, if it were to grow (or shrink) to accommodate its children. i.e. the size of the rectangle if you called |
@livtanong you can listen to the transforms of the children and size accordingly, I don't think it's worth providing a manual way for the user to do it. But as I said, we can implement this feature in a later PR and just have a static size to begin with. :) |
@spydon alrighty, I'll remove the convenience method. I'm not sure what you mean by listening to the transforms of the children, but we can discuss that when the time comes to implement shrink-wrapping the layout component. |
@livtanong basically: for (child in children) {
child.transform.addListenener( // or child.size.addListener
() => // Do changes
);
} |
Problem to solve
With
Row
andColumn
classes childrenComponent
s could be placed and layouted correctly without overlapping and without having to care about repeating size and position calculations.In my games i often have
Component
s (Sprites, buttons, etc.) which have to be placed either in rows or columns, where it's always quite an effort to calculate their positions and sizes.The goal of the suggested two classes would be to make these calculations transparent for the developer.
Proposal
Flutter-like
Row
andColumn
classes with alignment options for both axes (i.e.mainAxisAlignment
andcrossAxisAlignment
).Some ideas:
PositionComponent
themselvesPositionComponent
extending classes (since getting their size is important)Row
orColumn
would need to re-layout the componentSizedBox
) - ok this can be accomplished by just adding aPositionComponent
with asize
definedThe text was updated successfully, but these errors were encountered: