From 2fba6413bc91e1ef49b611c158be82f83fe889a9 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 23 Dec 2025 11:40:24 -0600 Subject: [PATCH] feat(ui): add CSimpleRegion::SetVertexGradient --- src/ui/simple/CSimpleRegion.cpp | 34 +++++++++++++++++++++++++++++++++ src/ui/simple/CSimpleRegion.hpp | 1 + 2 files changed, 35 insertions(+) diff --git a/src/ui/simple/CSimpleRegion.cpp b/src/ui/simple/CSimpleRegion.cpp index 90e328f..aa82007 100644 --- a/src/ui/simple/CSimpleRegion.cpp +++ b/src/ui/simple/CSimpleRegion.cpp @@ -143,6 +143,40 @@ void CSimpleRegion::SetVertexColor(const CImVector& color) { this->OnColorChanged(b1); } +void CSimpleRegion::SetVertexGradient(ORIENTATION orientation, const CImVector& minColor, const CImVector& maxColor) { + bool b1 = false; + + if (this->m_colorCount != 4) { + this->m_alphaCount = 4; + this->m_colorCount = 4; + b1 = true; + } + + if (orientation == ORIENTATION_VERTICAL) { + this->m_alpha[1] = minColor.a; + this->m_color[1] = minColor; + this->m_alpha[3] = minColor.a; + this->m_color[3] = minColor; + + this->m_alpha[0] = maxColor.a; + this->m_color[0] = maxColor; + this->m_alpha[2] = maxColor.a; + this->m_color[2] = maxColor; + } else { + this->m_alpha[0] = minColor.a; + this->m_color[0] = minColor; + this->m_alpha[1] = minColor.a; + this->m_color[1] = minColor; + + this->m_alpha[2] = maxColor.a; + this->m_color[2] = maxColor; + this->m_alpha[3] = maxColor.a; + this->m_color[3] = maxColor; + } + + this->OnColorChanged(b1); +} + void CSimpleRegion::SetFrame(CSimpleFrame* frame, uint32_t drawlayer, int32_t show) { if (this->m_parent == frame) { if (this->m_drawlayer == drawlayer) { diff --git a/src/ui/simple/CSimpleRegion.hpp b/src/ui/simple/CSimpleRegion.hpp index 3d6bc42..6c56534 100644 --- a/src/ui/simple/CSimpleRegion.hpp +++ b/src/ui/simple/CSimpleRegion.hpp @@ -34,6 +34,7 @@ class CSimpleRegion : public CScriptRegion { bool IsShown(); void OnRegionChanged(); void SetVertexColor(const CImVector& color); + void SetVertexGradient(ORIENTATION orientation, const CImVector& minColor, const CImVector& maxColor); void SetFrame(CSimpleFrame* frame, uint32_t drawlayer, int32_t show); void Show(); void ShowThis();