diff --git a/src/Button.cpp b/src/Button.cpp index e26be46..6bfbfd8 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -31,10 +31,11 @@ void Button::on_paint() { auto painter = window()->painter(); auto text_color = styles()->button_text_color(); auto max_geometry = current_geometry().max_geometry(); + bool set_size = current_geometry().max_width() != -1 && current_geometry().max_height() != -1; painter.source_rgb(text_color); painter.set_pango_font_description(styles()->controls_font_description()); - auto point = painter.text(max_geometry, m_text, PaintTextAlign::Center, PANGO_ELLIPSIZE_END); + auto point = painter.text(max_geometry, m_text, PaintTextAlign::Center, PANGO_ELLIPSIZE_END, set_size); resize(point); painter.fill(); } diff --git a/src/Label.cpp b/src/Label.cpp index 7961fc6..91e537a 100644 --- a/src/Label.cpp +++ b/src/Label.cpp @@ -20,10 +20,11 @@ void Label::on_paint() { auto painter = window()->painter(); auto text_color = styles()->label_text_color(); auto text_geometry = current_geometry().max_geometry(); + bool set_size = current_geometry().max_width() != -1 && current_geometry().max_height() != -1; painter.source_rgb(text_color); painter.set_pango_font_description(styles()->controls_font_description()); - auto point = painter.text(text_geometry, m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE); + auto point = painter.text(text_geometry, m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE, set_size); resize(point); painter.fill(); } diff --git a/src/Painter.cpp b/src/Painter.cpp index 4c56834..a448a56 100644 --- a/src/Painter.cpp +++ b/src/Painter.cpp @@ -39,7 +39,7 @@ bool Painter::text(Point &where, std::string &text) { return true; } -Point Painter::text(Box &geometry, std::string &text, PaintTextAlign align, PangoEllipsizeMode ellipsize) { +Point Painter::text(Box &geometry, std::string &text, PaintTextAlign align, PangoEllipsizeMode ellipsize, bool set_size) { if (m_pango_font_description == nullptr) return {-1,-1}; @@ -51,9 +51,9 @@ Point Painter::text(Box &geometry, std::string &text, PaintTextAlign align, Pang int pango_height; pango_layout_set_font_description(layout, m_pango_font_description); - if (geometry.width() > 0) + if (geometry.width() > 0 && set_size) pango_layout_set_width(layout, pango_units_from_double(geometry.width())); - if (geometry.height() > 0) + if (geometry.height() > 0 && set_size) pango_layout_set_height(layout, pango_units_from_double(geometry.height())); pango_layout_set_ellipsize(layout, ellipsize); pango_layout_set_text(layout, text.c_str(), -1); diff --git a/src/Painter.hpp b/src/Painter.hpp index 9e6c097..ae2224b 100644 --- a/src/Painter.hpp +++ b/src/Painter.hpp @@ -29,7 +29,7 @@ public: void rounded_rectangle(Box &geometry, double border_radius); bool text(Point &where, std::string &text); - Point text(Box &geometry, std::string &text, PaintTextAlign align, PangoEllipsizeMode ellipsize); + Point text(Box &geometry, std::string &text, PaintTextAlign align, PangoEllipsizeMode ellipsize, bool set_size); bool can_paint() { if (m_cairo) return true; else return false; }