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

add unary minus for ImVec2 #6368

Closed
wants to merge 1 commit into from
Closed

Conversation

koostosh
Copy link

Unary minus can be declared as non-member, so no reason to not expose it. Adds potentially missing functionality for ImVec2 to reduce usage of IM_VEC2_CLASS_EXTRA, especially that other math operators can be now easily esposed with IMGUI_DEFINE_MATH_OPERATORS.

@ocornut
Copy link
Owner

ocornut commented Apr 25, 2023

I’ll reinvestigate this because I don’t recall the exact reason for that comment.

But “to reduce usage of IM_VEC2_CLASS_EXTRA” seems like a misunderstanding. The point of this is that people prefer using their own types, so this system isn’t to avoid implementing functions on our end, it is to allow people to use their type and their function more naturally.

@koostosh
Copy link
Author

I (and I guess many others) don't have 'own' vector class they really want or need to use to handle UI coordinates. If all basic math functionality can be provided by imgui then I don't have any reason to use IM_VEC2_CLASS_EXTRA for custom casts or anything else. That's why I think this will remove some usecases of this macro, and unless you want to force people to use their types instead ImVec2 I think it is an argument for this change.

ocornut pushed a commit that referenced this pull request Apr 25, 2023
@ocornut
Copy link
Owner

ocornut commented Apr 25, 2023

This makes senses. It looks like it was my mistake/overlook to think this could only be overloaded as a member, it looks like it was never the case. Merged, thank you!

Recap https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Arithmetic_operators

@koostosh
Copy link
Author

thanks man, keep up the good work!

kjblanchard pushed a commit to kjblanchard/imgui that referenced this pull request May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants