From 203e2e5f1c4cdc411faec783c6802410c82b7fc6 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sun, 10 Aug 2025 22:53:53 +0200 Subject: [PATCH] Base: Allow constexpr Color This changes Base::Color class so it can be used as constexpr, useful for defining various defaults. --- src/Base/Color.cpp | 7 ------- src/Base/Color.h | 7 ++++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Base/Color.cpp b/src/Base/Color.cpp index b5619d1e36..0d63b76339 100644 --- a/src/Base/Color.cpp +++ b/src/Base/Color.cpp @@ -34,13 +34,6 @@ using namespace Base; // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -Color::Color(float red, float green, float blue, float alpha) - : r(red) - , g(green) - , b(blue) - , a(alpha) -{} - Color::Color(uint32_t rgba) : Color {} { diff --git a/src/Base/Color.h b/src/Base/Color.h index 09cc698cd4..cd537acb89 100644 --- a/src/Base/Color.h +++ b/src/Base/Color.h @@ -93,7 +93,12 @@ public: * Defines the color as (R,G,B,A) whereas all values are in the range [0,1]. * \a A defines the alpha value. */ - explicit Color(float R = 0.0, float G = 0.0, float B = 0.0, float A = 1.0); + constexpr explicit Color(float R = 0.0, float G = 0.0, float B = 0.0, float A = 1.0) + : r(R) + , g(G) + , b(B) + , a(A) + {} /** * Does basically the same as the constructor above unless that (R,G,B,A) is