31 lines
607 B
C++
31 lines
607 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 (window()) {
|
|
fit_text(text);
|
|
}
|
|
}
|
|
|
|
void Label::on_init() {
|
|
set_style(&default_label_style);
|
|
fit_text(m_text);
|
|
set_did_init(true);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
}
|