diff options
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/tabbutton.cc | 18 | ||||
-rw-r--r-- | plugingui/tabbutton.h | 2 |
2 files changed, 8 insertions, 12 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); } diff --git a/plugingui/tabbutton.h b/plugingui/tabbutton.h index 2f0dc10..a248335 100644 --- a/plugingui/tabbutton.h +++ b/plugingui/tabbutton.h @@ -57,7 +57,7 @@ private: void clickHandler(); Widget* tab_widget; - bool active; + bool active{false}; TexturedBox tab_active{getImageCache(), ":tab.png", 0, 0, // atlas offset (x, y) |