#include "Label.hpp" #include "Window.hpp" #include "pango/pango-layout.h" #include "Styles.hpp" #include 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(); auto geometry = rect().max_geometry(); painter.source_rgb(style()->foreground()); painter.text(geometry, m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_END, style()->font_description()); painter.fill(); } }