From 7cfbb8bfb1c4689dc78115931bab96d657be88be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Mon, 17 Apr 2017 12:48:41 +0200 Subject: Add version number to GUI. --- plugingui/label.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'plugingui/label.cc') diff --git a/plugingui/label.cc b/plugingui/label.cc index 781dbca..dc5fe23 100644 --- a/plugingui/label.cc +++ b/plugingui/label.cc @@ -29,6 +29,8 @@ #include "painter.h" #include "guievent.h" +#include + namespace GUI { Label::Label(Widget *parent) @@ -47,6 +49,16 @@ void Label::setAlignment(TextAlignment alignment) this->alignment = alignment; } +void Label::setColour(Colour colour) +{ + this->colour = std::make_unique(colour); +} + +void Label::resetColour() +{ + colour.release(); +} + void Label::resizeToText() { resize(font.textWidth(_text) + border, font.textHeight()); @@ -55,11 +67,8 @@ void Label::resizeToText() void Label::repaintEvent(RepaintEvent* repaintEvent) { Painter p(*this); - p.clear(); - p.setColour(Colour(1)); - int offset = 0; switch(alignment) { case TextAlignment::left: @@ -73,7 +82,13 @@ void Label::repaintEvent(RepaintEvent* repaintEvent) break; } - p.drawText(offset, (height() + font.textHeight()) / 2, font, _text, true); + if (colour) { + p.setColour(*colour); + p.drawText(offset, (height() + font.textHeight()) / 2, font, _text); + } + else { + p.drawText(offset, (height() + font.textHeight()) / 2, font, _text, true); + } } } // GUI:: -- cgit v1.2.3