summaryrefslogtreecommitdiff
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
parentfde590274c9d99e2cabc5b5f9971f2051659f1aa (diff)
Make sure that the button is drawn in the center of it's client area.
-rw-r--r--plugingui/button.cc12
-rw-r--r--plugingui/button.h6
2 files changed, 11 insertions, 7 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)
diff --git a/plugingui/button.h b/plugingui/button.h
index e5de6f1..f42dc99 100644
--- a/plugingui/button.h
+++ b/plugingui/button.h
@@ -58,7 +58,7 @@ protected:
virtual void mouseEnterEvent() override;
private:
- bool in_button;
+ bool in_button{false};
Painter::Box box_up;
Painter::Box box_down;
@@ -72,8 +72,8 @@ private:
Font font{":fontemboss.png"};
- state_t draw_state;
- state_t button_state;
+ state_t draw_state{up};
+ state_t button_state{up};
};
} // GUI::