raven/src/Label.cpp

33 lines
692 B
C++
Raw Normal View History

#include "Label.hpp"
#include "Window.hpp"
2022-03-29 09:27:59 +03:00
#include "pango/pango-layout.h"
2022-05-08 19:31:31 +03:00
#include <iostream>
namespace Raven {
void Label::set_text(std::string text) {
m_text = text;
if (window()) {
fit_text(text);
}
}
void Label::on_init() {
fit_text(m_text);
set_did_init(true);
set_do_background_fill(false);
}
void Label::on_paint() {
2022-04-30 09:40:09 +03:00
auto painter = window()->painter();
auto text_color = styles()->label_text_color();
painter.source_rgb(text_color);
2022-04-30 09:40:09 +03:00
painter.set_pango_font_description(styles()->controls_font_description());
painter.text(current_geometry(), m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE, true);
painter.fill();
}
}