summaryrefslogtreecommitdiff
path: root/plugingui/tabbutton.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-16 13:42:02 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-16 13:42:02 +0200
commite3f5b7c84f95b2a16d5921a0e0bc17d6cf63e0d6 (patch)
treeb6e4d7c252cef8458a653c8ae66bb9976b1dc72b /plugingui/tabbutton.cc
parent4317e7371e0acd39fe2ef76fc20a902f5cabdd42 (diff)
Fix drawing bug of TabButton.
Diffstat (limited to 'plugingui/tabbutton.cc')
-rw-r--r--plugingui/tabbutton.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/plugingui/tabbutton.cc b/plugingui/tabbutton.cc
index 1fc4619..27588da 100644
--- a/plugingui/tabbutton.cc
+++ b/plugingui/tabbutton.cc
@@ -65,6 +65,8 @@ std::size_t TabButton::getMinimalHeight() const
void TabButton::setActive(bool active)
{
+ this->active = active;
+
if (active) {
draw_state = State::Down;
}
@@ -91,25 +93,19 @@ void TabButton::repaintEvent(RepaintEvent* e)
return;
}
- switch(draw_state)
- {
- case State::Up:
+ if (draw_state == State::Up && !active) {
tab_passive.setSize(w - padLeft, h - padTop);
p.drawImage(padLeft, padTop, tab_passive);
- break;
-
- case State::Down:
+ }
+ else {
tab_active.setSize(w - padLeft, h - padTop);
p.drawImage(padLeft, padTop, tab_active);
- break;
}
p.setColour(Colour(0.1));
// FIXME: fix all the magic values here
- auto x = (width() / 2) - (3 * text.length()) +
- (draw_state == State::Up ? 0 : 1) + (padLeft / 2);
- auto y = (height() / 2) + 5 + 1 + (draw_state == State::Up ? 0 : 1) +
- (padTop / 2);
+ auto x = (width() / 2) - (3 * text.length()) + (padLeft / 2);
+ auto y = (height() / 2) + 5 + 1 + (padTop / 2);
p.drawText(x, y + 4, font, text, true);
}