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
feat: Customise grid of NineTileBox #2495
feat: Customise grid of NineTileBox #2495
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few comments.
Remember that you don't have to create a new PR to update it with new code, you can just continue to push to the same branch and it will automatically update.
examples/lib/stories/rendering/nine_tile_box_custom_grid_example.dart
Outdated
Show resolved
Hide resolved
Thanks for the review. Happy to make further changes/improvements. What's the policy with accepting conversations - do you prefer that the reviewer closes their own conversations, or the contributor closes them once they are addressed in a PR? I decided to close/redo the previous PR because I was already up to 5 commits. I did this because some repo owners really prefer clean PRs - even though the PR can be squashed before it is merged. |
Great! I'll ping the others in the team so that they can review too. :)
Usually the reviewer closes them when they have verified that they are done.
The amount of commits doesn't matter here because they are squashed into one commit when we merge. |
Co-authored-by: Erick <erickzanardoo@gmail.com>
…to feature/ninetilebox-set-grid
double leftColumnWidth = 0.0, | ||
double rightColumnWidth = 0.0, | ||
double topRowHeight = 0.0, | ||
double bottomRowHeight = 0.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about dropping Row
and Column
from the names? Would it be less clear what they mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I had just left, right, top, bottom
but that was confusing as the values here don't work the same as a regular Rect - but I think _Width, _Height
will be ok.
What is your preference?
leftWidth, rightWidth, topHeight, bottomHeight
leftSize, rightSize, topSize, bottomSize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the top one is slightly clearer, especially since we usually use size described by a Vector2 that represents both width and height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would border
work? columns and rows made me a little confused here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So leftBorderWidth
etc? Could work, hard do come up with something super clear here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, border is confusing to me because it suggests it is outside (or surrounds) the NineTileBox. I prefer leftWidth, topHeight etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with that then, I think those are fine.
Can you add them to the dartdocs too, explaining what each of them do and it'll be even clearer?
You can refer to arguments in the dartdoc with [leftBorderWidth]
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made one of our best APIs even better.
double leftColumnWidth = 0.0, | ||
double rightColumnWidth = 0.0, | ||
double topRowHeight = 0.0, | ||
double bottomRowHeight = 0.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would border
work? columns and rows made me a little confused here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, on minor suggestion
final sprite = Sprite(await loadImage('speech-bubble-1.png')); | ||
final nineTileBox = NineTileBox(sprite); | ||
|
||
expect(nineTileBox.tileSize, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use matchers here instead of just putting the raw values
expect(nineTileBox.tileSize, 30); | |
expect(nineTileBox.tileSize, equals(30)); |
The same suggestion to the other places in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
Just needs a formatting fix, you can run |
Description
Edit: Closed/re-created MR after rebase with latest changes on main.
The previous implementation of the NineTileBox calculates identically sized tiles in a 3x3 grid and does not allow the user to customise this. For example, a 60x60 pixel sprite will be cut into 20x20 pixel tiles. This MR allows the user to specify the sizes of the fixed-width and fixed-height rows and columns so that a completely custom grid is possible.
Example with the following sprite and custom grid sizes.
Note that the stretchable row and column are only 1 pixel wide/high in this example.
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Please note the visibility of
NineTileBox.center
(was private) for testing purposes. Added the@visibleForTesting
decorator.Breaking Change?
Related Issues
Closes #2490