summaryrefslogtreecommitdiff
path: root/plugingui/label.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-17 12:48:41 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-17 12:54:16 +0200
commit7cfbb8bfb1c4689dc78115931bab96d657be88be (patch)
tree2ddb893809114920bbc3f15f6592493bdd86d7cd /plugingui/label.cc
parentf0e8f4c95349bbc658bd73f885908b7c324dbb46 (diff)
Add version number to GUI.
Diffstat (limited to 'plugingui/label.cc')
-rw-r--r--plugingui/label.cc23
1 files changed, 19 insertions, 4 deletions
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 <cpp11fix.h>
+
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>(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::