Skip to content
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

Implement Rect as position and size vectors #2972

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

kimci86
Copy link
Contributor

@kimci86 kimci86 commented May 4, 2024

This groups sf::Rect members left, top, width, height into two vectors: position and size.

This makes sf::Rect more aligned with all SFML API working with Vector2 instead of separate values.
Related: #2055, #2248

@kimci86 kimci86 changed the title Impement Rect as position and size vectors Implement Rect as position and size vectors May 4, 2024
@coveralls
Copy link
Collaborator

coveralls commented May 4, 2024

Pull Request Test Coverage Report for Build 8990773841

Details

  • 104 of 109 (95.41%) changed or added relevant lines in 11 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-4.8%) to 51.903%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/SFML/Graphics/RenderTarget.cpp 9 11 81.82%
src/SFML/Graphics/Font.cpp 16 19 84.21%
Files with Coverage Reduction New Missed Lines %
src/SFML/Graphics/Text.cpp 2 86.46%
Totals Coverage Status
Change from base Build 8989395986: -4.8%
Covered Lines: 10428
Relevant Lines: 18957

💛 - Coveralls

Copy link
Member

@vittorioromeo vittorioromeo left a comment

Choose a reason for hiding this comment

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

Not sure how I feel about this yet, just a few random comments after a first skim.

examples/island/Island.cpp Show resolved Hide resolved
include/SFML/Graphics/Rect.hpp Show resolved Hide resolved
include/SFML/Graphics/Rect.inl Outdated Show resolved Hide resolved
include/SFML/Graphics/Transform.inl Show resolved Hide resolved
src/SFML/Graphics/Font.cpp Outdated Show resolved Hide resolved
src/SFML/Graphics/Shape.cpp Outdated Show resolved Hide resolved
src/SFML/Graphics/Sprite.cpp Show resolved Hide resolved
src/SFML/Graphics/Text.cpp Outdated Show resolved Hide resolved
src/SFML/Graphics/Text.cpp Outdated Show resolved Hide resolved
@ChrisThrasher
Copy link
Member

I really like this idea. Conceptually a Rect has always been a position and a size. For a long time we've agreed it's better to represent positions and sizes as vectors since that is more expressive and lends itself to better composition with other APIs that return and accept vectors for positions and sizes. I see no reason that Rect ought to be recused from that same precedent.

Any ergonomic issues introduced by this refactor can be fixed by adding the right new member functions.

src/SFML/Graphics/Font.cpp Outdated Show resolved Hide resolved
@kimci86 kimci86 force-pushed the feature/rect_as_two_vectors branch from 046e3c7 to a9c95ed Compare May 5, 2024 09:36
@kimci86 kimci86 requested a review from vittorioromeo May 5, 2024 09:37
examples/island/Island.cpp Show resolved Hide resolved
src/SFML/Graphics/Font.cpp Show resolved Hide resolved
@kimci86
Copy link
Contributor Author

kimci86 commented May 6, 2024

Note that I'm keeping separate commits for the review but I'll squash related commits once we are ready to merge.

@kimci86 kimci86 force-pushed the feature/rect_as_two_vectors branch from bc1cdf4 to f46705c Compare May 7, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Discussion
Development

Successfully merging this pull request may close these issues.

None yet

5 participants