From 52aa0fb9a1745bd7919c42a37ba48f6bf77e2984 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 19 Dec 2015 19:58:23 +0100 Subject: Make sure that the button is drawn in the center of it's client area. --- plugingui/button.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'plugingui/button.cc') 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) -- cgit v1.2.3