Refactored Slider to use an internal range of 0-1 and map it to a set range for the end-user.
This commit is contained in:
@@ -64,12 +64,13 @@ namespace JUI {
|
||||
|
||||
hue_slider = new JUI::Slider(row_layout);
|
||||
hue_slider->Size({100_percent, 28_px});
|
||||
hue_slider->Minimum(0.f); hue_slider->Maximum(1.f);
|
||||
hue_slider->Minimum(0.f); hue_slider->Maximum(360);
|
||||
hue_slider->Interval(1e-3f);
|
||||
hue_slider->ValueChanged += [this] (float val) mutable {
|
||||
hue_label->Content(std::format("Hue: {}", Math::FloorInt(val*360)));
|
||||
//val = val*360;
|
||||
hue_label->Content(std::format("Hue: {}", Math::FloorInt(val)));
|
||||
|
||||
hue = val * 360;
|
||||
hue = val;
|
||||
|
||||
hue_slider->ScrubberColor(Color4::FromHSV(hue, 1.f, 1.f));
|
||||
|
||||
|
@@ -25,6 +25,8 @@ namespace JUI
|
||||
return static_cast<T>(std::round(static_cast<double>(value)/static_cast<double>(multiple))*static_cast<double>(multiple));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// A slider is a widget with a handle which can be pulled back and forth to change the value.
|
||||
class Slider : public Rect, public Clickable, public Hoverable
|
||||
{
|
||||
@@ -47,12 +49,15 @@ namespace JUI
|
||||
void Maximum(float max);
|
||||
void Interval(float inter);
|
||||
void CurrentValue(float value);
|
||||
|
||||
float Percentage() const;
|
||||
|
||||
void Percentage(float value);
|
||||
|
||||
void ScrubberColor(const Color4& color);
|
||||
void ScrubberWidth(float width);
|
||||
void SetDragging(bool value);
|
||||
|
||||
|
||||
|
||||
void OnClick(const J3ML::LinearAlgebra::Vector2 &MousePos, const JUI::MouseButton &MouseButton) override;
|
||||
void OnRelease(const J3ML::LinearAlgebra::Vector2 &MousePos, const JUI::MouseButton &MouseButton, bool MouseStillOver) override;
|
||||
void OnHover(const J3ML::LinearAlgebra::Vector2 &MousePos) override;
|
||||
@@ -65,6 +70,7 @@ namespace JUI
|
||||
float maximum = 1;
|
||||
float interval = 0.1;
|
||||
float current;
|
||||
float percentage = 0.f;
|
||||
bool dragging = false;
|
||||
float scrubber_width = 20;
|
||||
Color4 scrubber_color = Colors::White;
|
||||
|
Reference in New Issue
Block a user