From fd943182bd9fe1d801e721a20a41dcde84be39d0 Mon Sep 17 00:00:00 2001 From: Koostosh Date: Tue, 25 Apr 2023 14:22:47 +0200 Subject: [PATCH] ImVec2: Added unary minus operator (#6368) --- docs/CHANGELOG.txt | 1 + imgui.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8fe22f063..bd6d3e6b7 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -52,6 +52,7 @@ Other changes: erroneously initializing default nav layer to menu layer. - Menus: Fixed an issue when opening a menu hierarchy in a given menu-bar would allow opening another via simple hovering. (#3496, #4797) +- Misc: Added ImVec2 unary minus operator. (#6368) [@Koostosh] - Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse hover hover when the identifier is at the end of the line. (#5855) - Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV] diff --git a/imgui.h b/imgui.h index e8b7e9eb3..a450ffe2a 100644 --- a/imgui.h +++ b/imgui.h @@ -2352,7 +2352,6 @@ struct ImGuiListClipper // - It is important that we are keeping those disabled by default so they don't leak in user space. // - This is in order to allow user enabling implicit cast operators between ImVec2/ImVec4 and their own types (using IM_VEC2_CLASS_EXTRA in imconfig.h) // - You can use '#define IMGUI_DEFINE_MATH_OPERATORS' to import our operators, provided as a courtesy. -// - We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself. #ifdef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED IM_MSVC_RUNTIME_CHECKS_OFF @@ -2362,6 +2361,7 @@ static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); } static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); } +static inline ImVec2 operator-(const ImVec2& lhs) { return ImVec2(-lhs.x, -lhs.y); } static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }