vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ui_slider.h
1#pragma once
2
3#include <glm/common.hpp>
4
5#include "core/reflect.h"
6#include "ecs/entity.h"
7
8namespace Vkm::Engine {
9
20struct UISlider {
21 float value = 0.0f;
22 float minValue = 0.0f;
23 float maxValue = 1.0f;
24 float step = 0.0f;
25
28
34 float fraction() const {
35 const float range = maxValue - minValue;
36 if (!(range > 0.0f)) return 0.0f;
37 return glm::clamp((value - minValue) / range, 0.0f, 1.0f);
38 }
39};
40
41} // namespace Vkm::Engine
42
43VKM_REFLECT_BEGIN(::Vkm::Engine::UISlider)
44 VKM_F(value)
45 VKM_F(minValue)
46 VKM_F(maxValue)
47 VKM_F(step)
48VKM_REFLECT_END()
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
A value dragged along a UIButton's width: the button is the track.
Definition ui_slider.h:20
float minValue
At the track's left end.
Definition ui_slider.h:22
float value
Write it to set the slider; a drag keeps it within min..max.
Definition ui_slider.h:21
EntityId fill
Grown to the value; none for no fill.
Definition ui_slider.h:26
float maxValue
At its right end.
Definition ui_slider.h:23
EntityId knob
Stood at the value; none for no knob.
Definition ui_slider.h:27
float fraction() const
How far along the track the value is.
Definition ui_slider.h:34
float step
What a drag snaps to, from minValue; 0 is continuous.
Definition ui_slider.h:24