mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2025-12-20 15:40:03 +01:00
text: make wrap and ellipsize passed
This commit is contained in:
parent
d839c3f808
commit
72e6801f08
2 changed files with 6 additions and 3 deletions
|
|
@ -27,6 +27,8 @@ namespace Hyprgraphics {
|
||||||
std::optional<Hyprutils::Math::Vector2D> maxSize = std::nullopt;
|
std::optional<Hyprutils::Math::Vector2D> maxSize = std::nullopt;
|
||||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GOOD;
|
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GOOD;
|
||||||
cairo_hint_style_t hintStyle = CAIRO_HINT_STYLE_SLIGHT;
|
cairo_hint_style_t hintStyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||||
|
bool ellipsize = false;
|
||||||
|
bool wrap = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
CTextResource(STextResourceData&& data);
|
CTextResource(STextResourceData&& data);
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,13 @@ void CTextResource::render() {
|
||||||
if (m_data.maxSize) {
|
if (m_data.maxSize) {
|
||||||
layoutWidth = m_data.maxSize->x > 0 ? std::min(layoutWidth, sc<int>(m_data.maxSize->x * PANGO_SCALE)) : layoutWidth;
|
layoutWidth = m_data.maxSize->x > 0 ? std::min(layoutWidth, sc<int>(m_data.maxSize->x * PANGO_SCALE)) : layoutWidth;
|
||||||
layoutHeight = m_data.maxSize->y > 0 ? std::min(layoutHeight, sc<int>(m_data.maxSize->y * PANGO_SCALE)) : layoutHeight;
|
layoutHeight = m_data.maxSize->y > 0 ? std::min(layoutHeight, sc<int>(m_data.maxSize->y * PANGO_SCALE)) : layoutHeight;
|
||||||
|
if (m_data.ellipsize)
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||||
if (m_data.maxSize->x >= 0)
|
if (m_data.maxSize->x >= 0)
|
||||||
pango_layout_set_width(layout, layoutWidth);
|
pango_layout_set_width(layout, layoutWidth);
|
||||||
if (m_data.maxSize->y >= 0)
|
if (m_data.maxSize->y >= 0)
|
||||||
pango_layout_set_height(layout, layoutHeight);
|
pango_layout_set_height(layout, layoutHeight);
|
||||||
|
if (m_data.wrap)
|
||||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue