Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Add functionality to keep the aspect ratio when stretching a UiTransform #1480

Merged
merged 3 commits into from Mar 26, 2019

Conversation

0x6273
Copy link
Contributor

@0x6273 0x6273 commented Mar 24, 2019

Description

Makes it possible for UiTransforms to keep their aspect ratio when stretched to fit their parent.
This is a breaking change, because it adds a new field to the Stretch::XY struct.

Modifications

  • Changed the Stretch::XY enum variant struct, adding a new keep_aspect_ratio field.
  • Updated the UiTransform system to use this new field when stretching transforms.
  • Updated all the places where Stretch::XY is instantiated, with this new field set to false.

PR Checklist

By placing an x in the boxes I certify that I have:

  • Ran cargo test --all locally if this modified any rs files.
  • Ran cargo +stable fmt --all locally if this modified any rs files.
  • Updated the content of the book if this PR would make the book outdated.
  • Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
  • Added unit tests for new APIs if any were added in this PR. Not sure how to add a test for this since it involves running a system with entities.
  • Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.

Copy link
Contributor

@AnneKitsune AnneKitsune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add documentation explaining that margins are ignored if you are forcing the aspect ratio? Alternatively, you could add a new enum variant on Stretch for this purpose, which would be clearer.

Add a new field to the Stretch::XY enum variant that allows for keeping the
aspect ratio when stretching.
@0x6273
Copy link
Contributor Author

0x6273 commented Mar 25, 2019

Thanks! Can you add documentation explaining that margins are ignored if you are forcing the aspect ratio? Alternatively, you could add a new enum variant on Stretch for this purpose, which would be clearer.

The x/y_margin values are not ignored, but treated as the minimum amount of margin rather than the absolute amount . More margin will be added to either the horizontal or vertical axis when necessary to keep the aspect ratio. I have changed the doc comment to clarify this.

Copy link
Member

@happenslol happenslol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like it!

Copy link
Contributor

@AnneKitsune AnneKitsune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

bors r+

bors bot added a commit that referenced this pull request Mar 26, 2019
1480: Add functionality to keep the aspect ratio when stretching a UiTransform r=jojolepro a=0x6273

## Description

Makes it possible for `UiTransform`s to keep their aspect ratio when stretched to fit their parent. 
This is a breaking change, because it adds a new field to the `Stretch::XY` struct.

## Modifications

- Changed the `Stretch::XY` enum variant struct, adding a new `keep_aspect_ratio` field.
- Updated the `UiTransform` system to use this new field when stretching transforms.
- Updated all the places where `Stretch::XY` is instantiated, with this new field set to false.

## PR Checklist

By placing an x in the boxes I certify that I have:

- [x] Ran `cargo test --all` locally if this modified any rs files.
- [x] Ran `cargo +stable fmt --all` locally if this modified any rs files.
- [x] Updated the content of the book if this PR would make the book outdated.
- [x] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
- [ ] Added unit tests for new APIs if any were added in this PR. **Not sure how to add a test for this since it involves running a system with entities.**
- [x] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.


Co-authored-by: 0x40 <0x40@keemail.me>
@bors
Copy link
Contributor

bors bot commented Mar 26, 2019

Build succeeded

@bors bors bot merged commit 6e359f0 into amethyst:master Mar 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants