mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2025-12-20 16:50: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;
|
||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GOOD;
|
||||
cairo_hint_style_t hintStyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
bool ellipsize = false;
|
||||
bool wrap = true;
|
||||
};
|
||||
|
||||
CTextResource(STextResourceData&& data);
|
||||
|
|
|
|||
|
|
@ -66,13 +66,14 @@ void CTextResource::render() {
|
|||
if (m_data.maxSize) {
|
||||
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;
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
if (m_data.ellipsize)
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
if (m_data.maxSize->x >= 0)
|
||||
pango_layout_set_width(layout, layoutWidth);
|
||||
if (m_data.maxSize->y >= 0)
|
||||
pango_layout_set_height(layout, layoutHeight);
|
||||
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||
if (m_data.wrap)
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||
}
|
||||
|
||||
// TODO: avoid this?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue