mirror of
https://github.com/whoahq/whoa.git
synced 2026-11-09 08:09:53 +03:00
feat(ui): implement CSimpleSlider::StepValue
This commit is contained in:
2 files changed
+15
-5
No files matched your search
@@ -287,7 +287,7 @@ void CSimpleSlider::SetValue(float value) {
|
||||
v4 = maxValue;
|
||||
}
|
||||
|
||||
auto newValue = this->Sub96BC10(v4);
|
||||
auto newValue = this->StepValue(v4);
|
||||
|
||||
// Clamp to max value
|
||||
if (newValue + this->m_valueStep >= maxValue) {
|
||||
@@ -322,9 +322,19 @@ void CSimpleSlider::SetValueStep(float valueStep) {
|
||||
}
|
||||
}
|
||||
|
||||
float CSimpleSlider::Sub96BC10(float value) {
|
||||
// TODO
|
||||
return value;
|
||||
float CSimpleSlider::StepValue(float value) {
|
||||
if (this->m_valueStep == 0.0f) {
|
||||
return value;
|
||||
}
|
||||
|
||||
auto valueOffset = value - this->m_baseValue;
|
||||
auto halfStep = this->m_valueStep / 2.0f;
|
||||
|
||||
if (valueOffset <= 0.0f) {
|
||||
return CMath::fint((valueOffset - halfStep) / this->m_valueStep) * this->m_valueStep + this->m_baseValue;
|
||||
}
|
||||
|
||||
return CMath::fint((valueOffset + halfStep) / this->m_valueStep) * this->m_valueStep + this->m_baseValue;
|
||||
}
|
||||
|
||||
void CSimpleSlider::UnregisterRegion(CSimpleRegion* region) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class CSimpleSlider : public CSimpleFrame {
|
||||
void SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer);
|
||||
void SetValue(float value);
|
||||
void SetValueStep(float valueStep);
|
||||
float Sub96BC10(float value);
|
||||
float StepValue(float value);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user