34 lines
646 B
C++
34 lines
646 B
C++
#include "Label.hpp"
|
|
#include "Window.hpp"
|
|
#include "pango/pango-layout.h"
|
|
#include "Styles.hpp"
|
|
#include <iostream>
|
|
|
|
namespace Raven {
|
|
|
|
void Label::set_text(std::string text) {
|
|
m_text = text;
|
|
|
|
if (!fit_text(text)) {
|
|
repaint();
|
|
}
|
|
}
|
|
|
|
void Label::on_init() {
|
|
set_style_pure(&default_label_style);
|
|
|
|
set_did_init(true);
|
|
if (!fit_text(m_text)) {
|
|
reflow();
|
|
}
|
|
}
|
|
|
|
void Label::on_paint() {
|
|
auto painter = window()->painter();
|
|
|
|
painter.source_rgb(style()->foreground());
|
|
painter.text(rect(), m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE, style()->font_description());
|
|
painter.fill();
|
|
}
|
|
|
|
}
|