forked from funkey/gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextView.cpp
54 lines (35 loc) · 933 Bytes
/
TextView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <string>
#include <util/Logger.h>
#include "TextView.h"
logger::LogChannel textviewlog("textviewlog", "[TextView] ");
namespace gui {
TextView::TextView(std::string text) :
_text(text),
_dirty(true) {
registerOutput(_painter, "painter");
_painter.registerForwardCallback(&TextView::onUpdate, this);
_painter.registerForwardSlot(_modified);
_painter.registerForwardSlot(_sizeChanged);
}
void
TextView::setText(std::string text) {
_text = text;
_dirty = true;
_modified();
}
const std::string&
TextView::getText() {
return _text;
}
void
TextView::onUpdate(const pipeline::Update& signal) {
LOG_ALL(textviewlog) << "got an update signal" << std::endl;
if (_dirty) {
LOG_ALL(textviewlog) << "I'm dirty, resetting my text" << std::endl;
_painter->setText(_text);
_dirty = false;
LOG_ALL(textviewlog) << "sending size changed signal" << std::endl;
_sizeChanged();
}
}
} // namespace gui