summaryrefslogtreecommitdiff
path: root/plugingui/button.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-12-19 19:58:23 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2015-12-19 19:58:23 +0100
commit52aa0fb9a1745bd7919c42a37ba48f6bf77e2984 (patch)
tree978e0f57505fed237ebddcc174e084b1c596df50 /plugingui/button.cc
parentfde590274c9d99e2cabc5b5f9971f2051659f1aa (diff)
Make sure that the button is drawn in the center of it's client area.
Diffstat (limited to 'plugingui/button.cc')
-rw-r--r--plugingui/button.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugingui/button.cc b/plugingui/button.cc
index f547cba..a3dd435 100644
--- a/plugingui/button.cc
+++ b/plugingui/button.cc
@@ -110,6 +110,9 @@ void Button::repaintEvent(RepaintEvent* repaintEvent)
p.clear();
+ int padTop = 3;
+ int padLeft = 0;
+
int w = width();
int h = height();
if(w == 0 || h == 0)
@@ -119,16 +122,17 @@ void Button::repaintEvent(RepaintEvent* repaintEvent)
switch(draw_state) {
case up:
- p.drawBox(0, 0, box_up, w, h);
+ p.drawBox(padLeft, padTop, box_up, w - padLeft, h - padTop);
break;
case down:
- p.drawBox(0, 0, box_down, w, h);
+ p.drawBox(padLeft, padTop, box_down, w - padLeft, h - padTop);
break;
}
p.setColour(Colour(0.1));
- p.drawText(width()/2-(text.length()*3)+(draw_state==up?0:1),
- height()/2+5+1+(draw_state==up?0:1), font, text, true);
+ p.drawText(width()/2-(text.length()*3)+(draw_state==up?0:1) + (padLeft / 2),
+ height()/2+5+1+(draw_state==up?0:1) + (padTop / 2), font, text,
+ true);
}
void Button::setText(const std::string& text)