From 928151444d2f9111d1b79b85dad2d26af0c2083d Mon Sep 17 00:00:00 2001 From: xcentaurix Date: Fri, 5 Jun 2026 12:14:48 +0000 Subject: [PATCH] [enigma2] fix text cutoff in templated lists with RT_HALIGN_RIGHT --- lib/gdi/grc.cpp | 20 ++++++++++++++++++++ lib/gui/elistbox.cpp | 21 ++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 3255ac511a1..e9829d267eb 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -919,6 +919,24 @@ void gDC::exec(const gOpcode *o) } para->setBlend(flags & gPainter::RT_BLEND); + + // For RT_HALIGN_RIGHT, precisely expand the DC clip to prevent the last + // glyph's right-side bearing from being clipped by the render area boundary. + gRegion savedClip; + bool clipExpanded = false; + if (flags & gPainter::RT_HALIGN_RIGHT) + { + const eRect &bbox = para->getBoundBox(); + int areaRight = o->parm.renderText->area.right() + offset.x(); + int overflow = bbox.right() + offset.x() - areaRight; + if (overflow > 0) + { + savedClip = m_current_clip; + clipExpanded = true; + m_current_clip |= gRegion(eRect(areaRight, o->parm.renderText->area.top() + offset.y(), + overflow + 1, o->parm.renderText->area.height())); + } + } if (o->parm.renderText->border) { @@ -929,6 +947,8 @@ void gDC::exec(const gOpcode *o) { para->blit(*this, offset, m_background_color_rgb, m_foreground_color_rgb); } + if (clipExpanded) + m_current_clip = savedClip; delete o->parm.renderText; break; } diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index 91838902054..b25f20addc7 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -733,11 +733,22 @@ void eListbox::updateScrollBar() } else { - if (m_orientation == orVertical) - m_content->setSize(eSize(width, m_itemheight)); - else if (m_orientation == orHorizontal) - m_content->setSize(eSize(m_itemwidth, height)); - else + // showOnDemand with no scrollbar needed: still reserve scrollbar space + // so item width stays constant if scrollbar later appears (avoids + // clipping fixed-position template content when scrollbar toggles). + if (m_orientation == orVertical) { + if (m_scrollbar_mode == showOnDemand) { + m_content->setSize(eSize(width-m_scrollbar_width-5, m_itemheight)); + } else { + m_content->setSize(eSize(width, m_itemheight)); + } + } else if (m_orientation == orHorizontal) { + if (m_scrollbar_mode == showOnDemand) { + m_content->setSize(eSize(m_itemwidth, height-m_scrollbar_height-5)); + } else { + m_content->setSize(eSize(m_itemwidth, height)); + } + } else m_content->setSize(eSize(m_itemwidth, m_itemwidth)); m_scrollbar->hide();