summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/slider.cc20
-rw-r--r--plugingui/slider.h37
2 files changed, 40 insertions, 17 deletions
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index 19343bc..6a764b8 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -55,6 +55,21 @@ float Slider::value() const
return current_value;
}
+void Slider::setColour(Colour colour)
+{
+ switch (colour) {
+ case Colour::Green:
+ inner_bar = &inner_bar_green;
+ break;
+ case Colour::Red:
+ inner_bar = &inner_bar_red;
+ break;
+ case Colour::Blue:
+ inner_bar = &inner_bar_blue;
+ break;
+ }
+}
+
void Slider::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
@@ -69,9 +84,8 @@ void Slider::repaintEvent(RepaintEvent* repaintEvent)
p.drawImage(0, 0, bar);
// draw inner bar
- inner_bar_blue.setSize(
- button_x - bar_boundary, height() - 2 * bar_boundary);
- p.drawImage(bar_boundary, bar_boundary, inner_bar_blue);
+ inner_bar->setSize(button_x - bar_boundary, height() - 2 * bar_boundary);
+ p.drawImage(bar_boundary, bar_boundary, *inner_bar);
// draw button
p.drawImage(button_x, button_y, button);
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};