From 7d58f10c8034b779d752028ec3b5dcbce848c661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Mon, 17 Apr 2017 09:30:52 +0200 Subject: Make it possible to set the Slider colour via a public function. --- plugingui/slider.h | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'plugingui/slider.h') diff --git a/plugingui/slider.h b/plugingui/slider.h index 7e4037f..9620fd0 100644 --- a/plugingui/slider.h +++ b/plugingui/slider.h @@ -53,6 +53,10 @@ public: void setValue(float new_value); float value() const; + enum class Colour { Green, Red, Blue }; + // Changes the colour of the inner bar + void setColour(Colour colour); + Notifier<> clickNotifier; protected: @@ -73,31 +77,36 @@ private: State state; - TexturedBox bar{ - getImageCache(), ":slider.png", 0, 0, // atlas offset (x, y) - 7, 1, 7, // dx1, dx2, dx3 - 7, 1, 7 // dy1, dy2, dy3 + TexturedBox bar{getImageCache(), ":slider.png", + 0, 0, // atlas offset (x, y) + 7, 1, 7, // dx1, dx2, dx3 + 7, 1, 7 // dy1, dy2, dy3 + }; + TexturedBox inner_bar_green{getImageCache(), ":slider.png", + 30, 0, // atlas offset (x, y) + 2, 1, 2, // dx1, dx2, dx3 + 2, 1, 2 // dy1, dy2, dy3 + }; + TexturedBox inner_bar_red{getImageCache(), ":slider.png", + 30, 5, // atlas offset (x, y) + 2, 1, 2, // dx1, dx2, dx3 + 2, 1, 2 // dy1, dy2, dy3 }; - // TexturedBox inner_bar_green{ - // getImageCache(), ":slider.png", 30, 0, // atlas offset (x, y) - // 2, 1, 2, // dx1, dx2, dx3 - // 2, 1, 2 // dy1, dy2, dy3 - // }; - // TexturedBox inner_bar_red{getImageCache(), ":slider.png", - // 30, 5, // atlas offset (x, y) - // 2, 1, 2, // dx1, dx2, dx3 - // 2, 1, 2 // dy1, dy2, dy3 - // }; TexturedBox inner_bar_blue{getImageCache(), ":slider.png", 30, 10, // atlas offset (x, y) 2, 1, 2, // dx1, dx2, dx3 2, 1, 2 // dy1, dy2, dy3 }; + Texture button{ getImageCache(), ":slider.png", 15, 0, // atlas offset (x, y) 15, 15 // width, height }; + // This points to the inner_bar_* of the current color. + // It should never be a nullptr! + TexturedBox* inner_bar{&inner_bar_blue}; + std::size_t bar_boundary{5}; std::size_t button_offset{7}; -- cgit v1.2.3