From 65a389aa96f15ae7a3982b21dc42a2cf4e0388c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 23 Aug 2026 18:50:45 -0300 Subject: [PATCH] Fix two list-marker issues: - Decimal/text markers now inherit the current list-item font color. - Marker X/Y coordinates are pixel-snapped, eliminating blurry rendering. - The behavior is shared by
  • and textual markers. - Added focused tests for inherited color and integer positioning. --- include/eepp/ui/uihtmlliststyle.hpp | 9 +++++++++ src/eepp/ui/uihtmldetails.cpp | 12 ++++++------ src/eepp/ui/uihtmllistitem.cpp | 9 ++++----- src/eepp/ui/uihtmlliststyle.cpp | 12 ++++++++++++ src/tests/unit_tests/uihtml_tests.cpp | 20 ++++++++++++++++++++ 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/include/eepp/ui/uihtmlliststyle.hpp b/include/eepp/ui/uihtmlliststyle.hpp index f26cc9773..0df79a677 100644 --- a/include/eepp/ui/uihtmlliststyle.hpp +++ b/include/eepp/ui/uihtmlliststyle.hpp @@ -6,6 +6,10 @@ #include #include +namespace EE { namespace Graphics { +class Text; +}} // namespace EE::Graphics + namespace EE { namespace UI { class EE_API UIHTMLListStyle { @@ -16,6 +20,11 @@ class EE_API UIHTMLListStyle { static String getTextMarkerString( CSSListStyleType type, int index ); + static void syncTextMarkerColor( Graphics::Text& marker, const Color& color ); + + static Vector2f getTextMarkerPosition( const Vector2f& screenPos, const Rectf& paddingPx, + Float textWidth, Float fontSize ); + static void drawPrimitiveMarker( CSSListStyleType type, const Vector2f& screenPos, const Rectf& paddingPx, const Graphics::FontStyleConfig& style ); diff --git a/src/eepp/ui/uihtmldetails.cpp b/src/eepp/ui/uihtmldetails.cpp index dc28f8373..7a4c50fa2 100644 --- a/src/eepp/ui/uihtmldetails.cpp +++ b/src/eepp/ui/uihtmldetails.cpp @@ -225,12 +225,12 @@ void UIHTMLSummary::draw() { UIHTMLListStyle::drawPrimitiveMarker( markerType, mScreenPos, mPaddingPx, mRichText.getFontStyleConfig() ); } else if ( mListMarkerText && !mListMarkerText->getString().empty() ) { - const Float fontSize = mRichText.getFontStyleConfig().CharacterSize; - const Float offset = 0.25f * fontSize; - const Float markerX = - mScreenPos.x + mPaddingPx.Left - mListMarkerText->getTextWidth() - offset; - mListMarkerText->draw( markerX, mScreenPos.y + mPaddingPx.Top, Vector2f::One, 0.f, - getBlendMode() ); + const FontStyleConfig& style = mRichText.getFontStyleConfig(); + UIHTMLListStyle::syncTextMarkerColor( *mListMarkerText, style.FontColor ); + const Float fontSize = style.CharacterSize; + const Vector2f markerPos = UIHTMLListStyle::getTextMarkerPosition( + mScreenPos, mPaddingPx, mListMarkerText->getTextWidth(), fontSize ); + mListMarkerText->draw( markerPos.x, markerPos.y, Vector2f::One, 0.f, getBlendMode() ); } } } diff --git a/src/eepp/ui/uihtmllistitem.cpp b/src/eepp/ui/uihtmllistitem.cpp index 453abbd4c..b40fc7667 100644 --- a/src/eepp/ui/uihtmllistitem.cpp +++ b/src/eepp/ui/uihtmllistitem.cpp @@ -40,15 +40,14 @@ void UIHTMLListItem::draw() { if ( mVisible && 0.f != mAlpha && mDisplay == CSSDisplay::ListItem ) { const FontStyleConfig& style = mRichText.getFontStyleConfig(); Float fontSize = style.CharacterSize; - Float offset = 0.25f * fontSize; - Float lineTop = mScreenPos.y + mPaddingPx.Top; if ( UIHTMLListStyle::isPrimitiveMarker( mListStyleType ) ) { UIHTMLListStyle::drawPrimitiveMarker( mListStyleType, mScreenPos, mPaddingPx, style ); } else if ( mListMarkerText && !mListMarkerText->getString().empty() ) { - Float markerX = - mScreenPos.x + mPaddingPx.Left - mListMarkerText->getTextWidth() - offset; - mListMarkerText->draw( markerX, lineTop, Vector2f::One, 0.f, getBlendMode() ); + UIHTMLListStyle::syncTextMarkerColor( *mListMarkerText, style.FontColor ); + const Vector2f markerPos = UIHTMLListStyle::getTextMarkerPosition( + mScreenPos, mPaddingPx, mListMarkerText->getTextWidth(), fontSize ); + mListMarkerText->draw( markerPos.x, markerPos.y, Vector2f::One, 0.f, getBlendMode() ); } } } diff --git a/src/eepp/ui/uihtmlliststyle.cpp b/src/eepp/ui/uihtmlliststyle.cpp index 071af31ba..e132c9da4 100644 --- a/src/eepp/ui/uihtmlliststyle.cpp +++ b/src/eepp/ui/uihtmlliststyle.cpp @@ -1,5 +1,6 @@ #include #include +#include #include namespace EE { namespace UI { @@ -50,6 +51,17 @@ String UIHTMLListStyle::getTextMarkerString( CSSListStyleType type, int index ) } } +void UIHTMLListStyle::syncTextMarkerColor( Graphics::Text& marker, const Color& color ) { + if ( marker.getFillColor() != color ) + marker.setFillColor( color ); +} + +Vector2f UIHTMLListStyle::getTextMarkerPosition( const Vector2f& screenPos, const Rectf& paddingPx, + Float textWidth, Float fontSize ) { + return { std::floor( screenPos.x + paddingPx.Left - textWidth - 0.25f * fontSize ), + std::floor( screenPos.y + paddingPx.Top ) }; +} + void UIHTMLListStyle::drawPrimitiveMarker( CSSListStyleType type, const Vector2f& screenPos, const Rectf& paddingPx, const Graphics::FontStyleConfig& style ) { diff --git a/src/tests/unit_tests/uihtml_tests.cpp b/src/tests/unit_tests/uihtml_tests.cpp index b75095103..b2e1a9ea5 100644 --- a/src/tests/unit_tests/uihtml_tests.cpp +++ b/src/tests/unit_tests/uihtml_tests.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -2402,6 +2403,25 @@ UTEST( UILayout, listStyleTypeDecimal ) { Engine::destroySingleton(); } +UTEST( UILayout, textListMarkerTracksInheritedColor ) { + FontStyleConfig inheritedStyle; + inheritedStyle.FontColor = Color( 224, 230, 237 ); + inheritedStyle.CharacterSize = 19; + + Text marker; + marker.setString( "1." ); + UIHTMLListStyle::syncTextMarkerColor( marker, inheritedStyle.FontColor ); + + EXPECT_TRUE( marker.getFillColor() == inheritedStyle.FontColor ); +} + +UTEST( UILayout, textListMarkerPositionIsPixelAligned ) { + const Vector2f markerPos = UIHTMLListStyle::getTextMarkerPosition( + { 100.75f, 40.5f }, Rectf( 0.25f, 1.75f, 0.f, 0.f ), 12.4f, 17.f ); + + EXPECT_TRUE( markerPos == markerPos.floor() ); +} + UTEST( UILayout, listStyleTypeDisc ) { init_ui_test(); auto* sceneNode = SceneManager::instance()->getUISceneNode();