From a6e93122a761c984b419a2c6b7f7de069256cd47 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 23 Dec 2025 11:21:38 -0600 Subject: [PATCH] chore(ui): make ORIENTATION enum generic --- src/ui/Types.hpp | 6 +++--- src/ui/Util.cpp | 8 ++++---- src/ui/Util.hpp | 2 +- src/ui/simple/CSimpleSlider.cpp | 8 ++++---- src/ui/simple/CSimpleSlider.hpp | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ui/Types.hpp b/src/ui/Types.hpp index 7dbb53c..23cf83e 100644 --- a/src/ui/Types.hpp +++ b/src/ui/Types.hpp @@ -88,9 +88,9 @@ enum PLURAL_RULE { PLURAL_RULE_2 = 2 }; -enum SLIDER_ORIENTATION { - SLIDER_HORIZONTAL = 0, - SLIDER_VERTICAL = 1, +enum ORIENTATION { + ORIENTATION_HORIZONTAL = 0, + ORIENTATION_VERTICAL = 1, }; enum TextureImageMode { diff --git a/src/ui/Util.cpp b/src/ui/Util.cpp index b150fae..5cc5204 100644 --- a/src/ui/Util.cpp +++ b/src/ui/Util.cpp @@ -87,15 +87,15 @@ int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata) { return 0; } -int32_t StringToOrientation(const char* string, SLIDER_ORIENTATION& orientation) { +int32_t StringToOrientation(const char* string, ORIENTATION& orientation) { struct OrientationEntry { - SLIDER_ORIENTATION value; + ORIENTATION value; const char* string; }; static OrientationEntry orientationMap[] = { - { SLIDER_HORIZONTAL, "HORIZONTAL" }, - { SLIDER_VERTICAL, "VERTICAL" }, + { ORIENTATION_HORIZONTAL, "HORIZONTAL" }, + { ORIENTATION_VERTICAL, "VERTICAL" }, }; for (auto& entry : orientationMap) { diff --git a/src/ui/Util.hpp b/src/ui/Util.hpp index 5582be7..c5e4dbc 100644 --- a/src/ui/Util.hpp +++ b/src/ui/Util.hpp @@ -13,6 +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); +int32_t StringToOrientation(const char* string, ORIENTATION& orientation); #endif diff --git a/src/ui/simple/CSimpleSlider.cpp b/src/ui/simple/CSimpleSlider.cpp index 97d2612..290833c 100644 --- a/src/ui/simple/CSimpleSlider.cpp +++ b/src/ui/simple/CSimpleSlider.cpp @@ -111,7 +111,7 @@ void CSimpleSlider::LoadXML(XMLNode* node, CStatus* status) { auto orientationStr = node->GetAttributeByName("orientation"); if (orientationStr && *orientationStr) { - SLIDER_ORIENTATION orientation; + ORIENTATION orientation; if (StringToOrientation(orientationStr, orientation)) { this->SetOrientation(orientation); @@ -163,7 +163,7 @@ int32_t CSimpleSlider::OnLayerTrackUpdate(const CMouseEvent& evt) { float area; float offset; - if (this->m_orientation == SLIDER_VERTICAL) { + if (this->m_orientation == ORIENTATION_VERTICAL) { area = this->m_rect.maxY - this->m_rect.minY - thumbTexture->GetHeight(); offset = this->m_rect.maxY - (thumbTexture->GetHeight() / 2.0f) - evt.y; } else { @@ -188,7 +188,7 @@ void CSimpleSlider::OnLayerUpdate(float elapsedSec) { ? 0.0f : (this->m_value - this->m_baseValue) / valueRange; - if (this->m_orientation == SLIDER_VERTICAL) { + if (this->m_orientation == ORIENTATION_VERTICAL) { auto rangeY = (this->m_rect.maxY - this->m_rect.minY) / this->m_layoutScale; auto offsetY = -((rangeY - this->m_thumbTexture->GetHeight()) * valueOffset); @@ -249,7 +249,7 @@ void CSimpleSlider::SetMinMaxValues(float min, float max) { } } -void CSimpleSlider::SetOrientation(SLIDER_ORIENTATION orientation) { +void CSimpleSlider::SetOrientation(ORIENTATION orientation) { this->m_orientation = orientation; if (this->m_thumbTexture) { diff --git a/src/ui/simple/CSimpleSlider.hpp b/src/ui/simple/CSimpleSlider.hpp index c7db193..3e51d5c 100644 --- a/src/ui/simple/CSimpleSlider.hpp +++ b/src/ui/simple/CSimpleSlider.hpp @@ -24,7 +24,7 @@ class CSimpleSlider : public CSimpleFrame { float m_value = 0.0f; float m_valueStep = 0.0f; CSimpleTexture* m_thumbTexture = nullptr; - SLIDER_ORIENTATION m_orientation = SLIDER_VERTICAL; + ORIENTATION m_orientation = ORIENTATION_VERTICAL; ScriptIx m_onValueChanged; ScriptIx m_onMinMaxChanged; @@ -54,7 +54,7 @@ class CSimpleSlider : public CSimpleFrame { void RunOnMinMaxChangedScript(); void RunOnValueChangedScript(); void SetMinMaxValues(float min, float max); - void SetOrientation(SLIDER_ORIENTATION orientation); + void SetOrientation(ORIENTATION orientation); void SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer); void SetValue(float value); void SetValueStep(float valueStep);