From 55ad2c9998808c7b85095e593a616ccc79d2e33f Mon Sep 17 00:00:00 2001 From: Nishan Date: Thu, 24 Aug 2023 21:40:05 +0530 Subject: [PATCH 1/2] add value unit struct --- .../react/renderer/graphics/ValueUnit.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h b/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h new file mode 100644 index 00000000000000..170aa989b9984d --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h @@ -0,0 +1,26 @@ +#pragma once + +namespace facebook::react { + +enum class UnitType { + UNDEFINED, + POINT, + PERCENT +}; + +struct ValueUnit { + float value; + UnitType unit; + + ValueUnit() : value(0.0f), unit(UnitType::UNDEFINED) {} + + ValueUnit(float v, UnitType u) : value(v), unit(u) {} + + bool operator==(const ValueUnit& other) const { + return value == other.value && unit == other.unit; + } + bool operator!=(const ValueUnit& other) const { + return !(*this == other); + } +}; +} From 696621e6f571a9a86163781e03d3ea3988de66a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nishan=20=28o=5E=E2=96=BD=5Eo=29?= Date: Fri, 25 Aug 2023 03:24:38 +0530 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Nick Gerleman --- .../ReactCommon/react/renderer/graphics/ValueUnit.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h b/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h index 170aa989b9984d..f0a9b376f6f415 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/ValueUnit.h @@ -3,16 +3,14 @@ namespace facebook::react { enum class UnitType { - UNDEFINED, - POINT, - PERCENT + Undefined, + Point, + Percent, }; struct ValueUnit { - float value; - UnitType unit; - - ValueUnit() : value(0.0f), unit(UnitType::UNDEFINED) {} + float value{0.0f}; + UnitType unit{UnitType::Undefined}; ValueUnit(float v, UnitType u) : value(v), unit(u) {}