diff --git a/src/ui/Util.cpp b/src/ui/Util.cpp index ecf4f0b..b150fae 100644 --- a/src/ui/Util.cpp +++ b/src/ui/Util.cpp @@ -86,3 +86,24 @@ int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata) { return 0; } + +int32_t StringToOrientation(const char* string, SLIDER_ORIENTATION& orientation) { + struct OrientationEntry { + SLIDER_ORIENTATION value; + const char* string; + }; + + static OrientationEntry orientationMap[] = { + { SLIDER_HORIZONTAL, "HORIZONTAL" }, + { SLIDER_VERTICAL, "VERTICAL" }, + }; + + for (auto& entry : orientationMap) { + if (!SStrCmpI(entry.string, string)) { + orientation = entry.value; + return 1; + } + } + + return 0; +} diff --git a/src/ui/Util.hpp b/src/ui/Util.hpp index c7f813b..5582be7 100644 --- a/src/ui/Util.hpp +++ b/src/ui/Util.hpp @@ -13,4 +13,6 @@ int32_t StringToFramePoint(const char* string, FRAMEPOINT& point); int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata); +int32_t StringToOrientation(const char* string, SLIDER_ORIENTATION& orientation); + #endif