-
-
Notifications
You must be signed in to change notification settings - Fork 905
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: Callbacks in HudButtonComponent
constructor and ViewportMargin
mixin to avoid code duplication
#1685
Conversation
position: position, | ||
onPressed: onPressed, | ||
onReleased: onReleased, |
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.
Shouldnt this be part of a separate PR? For the sake of clear commits
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.
It was the other way around really, I wanted the button components to be the same and to do that I introduced the mixin, I can change the title to reflect on that.
HudButtonComponent
constructor and ViewportMargin
mixin to avoid code duplication
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.
LGTM, just one small, optional comment.
/// If you set the position of the component instead of a margin when | ||
/// initializing the component, the margin to the edge of the screen from that | ||
/// position will be used. | ||
mixin ComponentViewportMargin on PositionComponent, HasGameRef { |
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.
Idk if hud button or button component have tests, but if they don't this would be a good opportunity to introduce a test suite that would end up testing both things.
37ea2a4
to
85f3bb8
Compare
Description
Created a mixin to handle the margin to the viewport, mostly to remove the code duplication in
ButtonComponent
andHudButtonComponent
, but it can also be useful in other cases when you don't want to wrap your component inHudMarginComponent
.Once the new camera system is in place this will of course have to be replaced.
Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues