chore(ui): make ORIENTATION enum generic

This commit is contained in:
fallenoak committed 2025-12-23 11:21:38 -06:00
1 parent 32b5d6402b
commit a6e93122a7
5 files changed
+14 -14

No files matched your search

+4 -4
View File
@@ -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) {
+2 -2
View File
@@ -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);