raven/src/Label.cpp

26 lines
785 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"
namespace Raven {
void Label::on_init() {
// the label will inherit the background color properties from the parent
if (Widget *parent = get_parent()) {
set_do_background_fill(parent->get_do_background_fill());
set_background_fill_color(parent->get_background_fill_color());
}
set_did_init(true);
}
void Label::on_paint() {
auto painter = get_window()->get_painter();
auto text_color = get_styles()->get_label_text_color();
painter.source_rgb(text_color);
painter.set_pango_font_description(get_styles()->get_controls_font_description());
2022-03-30 16:12:25 +03:00
painter.text(get_current_geometry(), m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE);
painter.fill();
}
}