summaryrefslogtreecommitdiff
path: root/plugingui/led.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:08:12 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:08:12 +0100
commitaf9c9091ed69394171485aa4c4814504f86f2004 (patch)
tree070b911dc8faed486c8e8829f0f41aec7d5b4350 /plugingui/led.cc
parent5e4cb10f72ef69d73fbd2c1bc42465c9111a4c41 (diff)
Simple image blit. New slider class. New filenamelineedit. New pixelbuffer used for drawing everything but the root window - with alpha blending...
Diffstat (limited to 'plugingui/led.cc')
-rw-r--r--plugingui/led.cc50
1 files changed, 39 insertions, 11 deletions
diff --git a/plugingui/led.cc b/plugingui/led.cc
index a32dcb9..d26a0de 100644
--- a/plugingui/led.cc
+++ b/plugingui/led.cc
@@ -28,35 +28,63 @@
#include "painter.h"
-LED::LED(GlobalContext *gctx, Widget *parent)
- : Widget(gctx, parent)
+GUI::LED::LED(Widget *parent)
+ : GUI::Widget(parent)
{
- state = true;
+ state = off;
}
-void LED::setState(bool state)
+void GUI::LED::setState(GUI::LED::state_t state)
{
if(this->state != state) {
this->state = state;
- repaint(NULL);
+ repaintEvent(NULL);
}
}
-void LED::repaint(RepaintEvent *e)
+void GUI::LED::repaintEvent(GUI::RepaintEvent *e)
{
size_t h = height() - 1;
size_t w = width() - 1;
- Painter p(gctx, wctx);
-
- if(state) p.setColour(Colour(0,1,0));
- else p.setColour(Colour(1,0,0));
+ Painter p(this);
+ float alpha = 0.9;
+ switch(state) {
+ case red:
+ p.setColour(Colour(1, 0, 0,alpha));
+ break;
+ case green:
+ p.setColour(Colour(0, 1, 0, alpha));
+ break;
+ case blue:
+ p.setColour(Colour(0, 0, 1, alpha));
+ break;
+ case off:
+ p.setColour(Colour(0.2, 0.2, 0.2, alpha));
+ break;
+ }
size_t size = w / 2;
if(h / 2 < size) size = h / 2;
p.drawFilledCircle(w/2, h/2, size);
- p.setColour(Colour(1));
+ switch(state) {
+ case red:
+ p.setColour(Colour(0.4, 0, 0,alpha));
+ break;
+ case green:
+ p.setColour(Colour(0, 0.4, 0, alpha));
+ break;
+ case blue:
+ p.setColour(Colour(0, 0, 0.4, alpha));
+ break;
+ case off:
+ p.setColour(Colour(0.1, 0.1, 0.1, alpha));
+ break;
+ }
+ p.drawCircle(w/2, h/2, size);
+
+ p.setColour(Colour(1,alpha));
p.drawFilledCircle(w/3, h/3, size / 6);
}