"Labels" widget

This commit is contained in:
furrtek 2017-02-12 07:23:31 +00:00
parent 0102a34286
commit d12cd0d8af
11 changed files with 52 additions and 74 deletions

View file

@ -42,11 +42,14 @@ int Painter::draw_char(const Point p, const Style& style, const char c) {
return glyph.advance().x();
}
int Painter::draw_string(Point p, const Style& style, const std::string text) {
int Painter::draw_string(Point p, const Font& font, const Color foreground,
const Color background, const std::string text) {
size_t width = 0;
for(const auto c : text) {
const auto glyph = style.font.glyph(c);
display.draw_glyph(p, glyph, style.foreground, style.background);
const auto glyph = font.glyph(c);
display.draw_glyph(p, glyph, foreground, background);
const auto advance = glyph.advance();
p += advance;
width += advance.x();
@ -54,6 +57,10 @@ int Painter::draw_string(Point p, const Style& style, const std::string text) {
return width;
}
int Painter::draw_string(Point p, const Style& style, const std::string text) {
return draw_string(p, style.font, style.foreground, style.background, text);
}
void Painter::draw_bitmap(const Point p, const Bitmap& bitmap, const Color foreground, const Color background) {
display.draw_bitmap(p, bitmap.size, bitmap.data, foreground, background);
}