diff --git a/dependencies/subprojects/animationwindow/include/widgets/Slider.h b/dependencies/subprojects/animationwindow/include/widgets/Slider.h index 97d7e6deeb8ea7cac1b687f9421c57d0c6365f47..280f07115fcf7ca75f8c581be64b3c5535fb45a9 100644 --- a/dependencies/subprojects/animationwindow/include/widgets/Slider.h +++ b/dependencies/subprojects/animationwindow/include/widgets/Slider.h @@ -7,9 +7,10 @@ namespace TDT4102 { class Slider : public TDT4102::Widget { private: - int value = 0; - int minValue = 0; - int maxValue = 100; + int value; + int minValue; + int maxValue; + int stepValue; nk_color sliderBarColor = nk_rgba(100, 100, 100, 255); nk_color sliderBarColorActive = nk_rgba(100, 100, 100, 255); nk_color sliderBarColorHover = nk_rgba(100, 100, 100, 255); @@ -20,7 +21,7 @@ namespace TDT4102 { protected: void update(nk_context* context) override; public: - explicit Slider(TDT4102::Point location, unsigned int width, unsigned int height, int min, int max, int initialValue); + explicit Slider(TDT4102::Point location, unsigned int width, unsigned int height, int min = 0, int max = 100, int initialValue = 0, int step = 1); int getValue() const; void setSliderBarColor(Color newColor) {sliderBarColor = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};}; void setSliderBarColorActive(Color newColor) {sliderBarColorActive = nk_color{(nk_byte)newColor.redChannel, (nk_byte)newColor.greenChannel, (nk_byte)newColor.blueChannel, (nk_byte)newColor.alphaChannel};} diff --git a/dependencies/subprojects/animationwindow/src/widgets/Slider.cpp b/dependencies/subprojects/animationwindow/src/widgets/Slider.cpp index 227b06fff014440673c624e376b043176fbcafeb..2a80404ae0d37242e888645cfd0ce4edc6499f9b 100644 --- a/dependencies/subprojects/animationwindow/src/widgets/Slider.cpp +++ b/dependencies/subprojects/animationwindow/src/widgets/Slider.cpp @@ -1,10 +1,11 @@ #include "widgets/Slider.h" -TDT4102::Slider::Slider(TDT4102::Point location, unsigned int width, unsigned int height, int min, int max, int initialValue) +TDT4102::Slider::Slider(TDT4102::Point location, unsigned int width, unsigned int height, int min, int max, int initialValue, int step) : TDT4102::Widget(location, width, height) { minValue = min; maxValue = max; value = initialValue; + stepValue = step; } int TDT4102::Slider::getValue() const { @@ -22,7 +23,7 @@ void TDT4102::Slider::update(nk_context *context) { nk_style_push_style_item(context, &s->slider.cursor_hover, nk_style_item_color(sliderCursorColorHover)); nk_style_push_style_item(context, &s->slider.cursor_active, nk_style_item_color(sliderCursorColorActive)); - if (nk_slider_int(context, minValue, &value, maxValue, 1)) { + if (nk_slider_int(context, minValue, &value, maxValue, stepValue)) { fire(); }