Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Martín Lucas Golini
2026-05-01 18:52:57 -03:00
4 changed files with 139 additions and 29 deletions

View File

@@ -407,7 +407,7 @@ Redémarrez ecode pour voir les changements.</string>
<string name="indent">Indenter</string>
<string name="indent_tab_alignment">Alignement de l'indentation</string>
<string name="indent_tab_character">Caractère à utiliser pour l'indentation</string>
<string name="indent_width">Largeur d'indentation</string>
<string name="indent_width">Taille d'indentation</string>
<string name="indentation_type">Type d'indentation</string>
<string name="inode">Nœud-i</string>
<string name="insert_search_query">Insérer la requête de recherche</string>
@@ -775,8 +775,8 @@ La valeur minimale est 1 et le maximum est 6. Nécessite un redémarrage.</strin
dans l'arborescence du répertoire.</string>
<string name="syntax_color_scheme">Schéma de couleurs syntaxique</string>
<string name="system">Système</string>
<string name="tab_width">Largeur des onglets</string>
<string name="tabs">Onglets</string>
<string name="tab_width">Taille des tabulations</string>
<string name="tabs">Tabulations</string>
<string name="terminal">Terminal</string>
<string name="terminal_color_scheme">Schéma de couleurs du terminal</string>
<string name="terminal_color_scheme_set">Schéma de couleurs du terminal : %s</string>
@@ -881,7 +881,7 @@ dans l'arborescence de répertoires ainsi que dans les boites de dialogues de s
<string name="variable_name">Nom de la variable</string>
<string name="variables">Variables</string>
<string name="view">Vue</string>
<string name="viewport">Viewport</string>
<string name="viewport">Fenêtre d'affichage</string>
<string name="vsync">VSync</string>
<string name="vsync_changed">Vsync : configuration mise à jour.
Redémarrer ecode pour voir les changements.</string>
@@ -894,10 +894,10 @@ Redémarrer ecode pour voir les changements.</string>
<string name="working_dir_at">Répertoire de travail %s
</string>
<string name="workspace_symbol_find_ellipsis">Rechercher les symboles dans l'espace de travail...</string>
<string name="wrap_letter">Letter wrap</string>
<string name="wrap_mode">Wrap Mode</string>
<string name="wrap_type">Wrap Against</string>
<string name="wrap_word">Word wrap</string>
<string name="wrap_letter">Au caractère</string>
<string name="wrap_mode">Mode de retour à la ligne</string>
<string name="wrap_type">Retour à la ligne</string>
<string name="wrap_word">Au mot</string>
<string name="write_unicode_bom">Écrire le BOM Unicode</string>
<string name="you_have_not_yet_opened_a_folder">Vous n'avez pas encore ouvert de dossier.</string>
<string name="zoom_in">Zoomer</string>

View File

@@ -129,11 +129,6 @@ center {
text-align: center;
}
ul > li,
ol > li {
padding-left: 2em;
}
ul {
list-style-type: disc;
}
@@ -178,7 +173,7 @@ MarkdownView blockquote {
MarkdownView ul,
MarkdownView ol {
padding-left: 0;
padding-left: 21dp;
}
MarkdownView ul ul,

View File

@@ -50,7 +50,8 @@ void UIHTMLWidget::setDisplay( CSSDisplay display ) {
if ( getLayoutWidthPolicy() == SizePolicy::MatchParent )
setLayoutWidthPolicy( SizePolicy::WrapContent );
} else if ( mDisplay == CSSDisplay::Block || mDisplay == CSSDisplay::ListItem ) {
if ( getLayoutWidthPolicy() == SizePolicy::WrapContent )
if ( getLayoutWidthPolicy() == SizePolicy::WrapContent &&
mPosition != CSSPosition::Absolute && mPosition != CSSPosition::Fixed )
setLayoutWidthPolicy( SizePolicy::MatchParent );
}
onDisplayChange();
@@ -60,6 +61,10 @@ void UIHTMLWidget::setDisplay( CSSDisplay display ) {
void UIHTMLWidget::setCSSPosition( CSSPosition position ) {
if ( mPosition != position ) {
mPosition = position;
if ( position == CSSPosition::Absolute || position == CSSPosition::Fixed ) {
if ( getLayoutWidthPolicy() == SizePolicy::MatchParent )
setLayoutWidthPolicy( SizePolicy::WrapContent );
}
onPositionChange();
}
}
@@ -203,22 +208,51 @@ void UIHTMLWidget::positionOutOfFlowChildren() {
if ( pos == CSSPosition::Absolute || pos == CSSPosition::Fixed ) {
UIWidget* cb = htmlChild->getContainingBlock();
if ( cb ) {
Float top = htmlChild->mTopEq == "auto"
? 0
: htmlChild->lengthFromValue(
htmlChild->mTopEq,
CSS::PropertyRelativeTarget::ContainingBlockHeight, 0 );
Float left = htmlChild->mLeftEq == "auto"
? 0
: htmlChild->lengthFromValue(
htmlChild->mLeftEq,
CSS::PropertyRelativeTarget::ContainingBlockWidth, 0 );
Rectf cbContentOffset = cb->getPixelsContentOffset();
Float cbContentWidth = cb->getPixelsSize().getWidth() - cbContentOffset.Left -
cbContentOffset.Right;
Float cbContentHeight = cb->getPixelsSize().getHeight() - cbContentOffset.Top -
cbContentOffset.Bottom;
top += htmlChild->getLayoutPixelsMargin().Top;
left += htmlChild->getLayoutPixelsMargin().Left;
Rectf margin = htmlChild->getLayoutPixelsMargin();
Float childWidth = htmlChild->getPixelsSize().getWidth();
Float childHeight = htmlChild->getPixelsSize().getHeight();
Vector2f cbPos( cb->getPixelsContentOffset().Left,
cb->getPixelsContentOffset().Top );
Float top = 0;
Float left = 0;
bool useTop = htmlChild->mTopEq != "auto";
bool useBottom = htmlChild->mBottomEq != "auto";
bool useLeft = htmlChild->mLeftEq != "auto";
bool useRight = htmlChild->mRightEq != "auto";
if ( useLeft ) {
left = htmlChild->lengthFromValue(
htmlChild->mLeftEq, CSS::PropertyRelativeTarget::ContainingBlockWidth,
0 );
} else if ( useRight ) {
Float rightVal = htmlChild->lengthFromValue(
htmlChild->mRightEq, CSS::PropertyRelativeTarget::ContainingBlockWidth,
0 );
left = cbContentWidth - childWidth - margin.Left - margin.Right - rightVal;
}
if ( useTop ) {
top = htmlChild->lengthFromValue(
htmlChild->mTopEq, CSS::PropertyRelativeTarget::ContainingBlockHeight,
0 );
} else if ( useBottom ) {
Float bottomVal = htmlChild->lengthFromValue(
htmlChild->mBottomEq,
CSS::PropertyRelativeTarget::ContainingBlockHeight, 0 );
top =
cbContentHeight - childHeight - margin.Top - margin.Bottom - bottomVal;
}
top += margin.Top;
left += margin.Left;
Vector2f cbPos( cbContentOffset.Left, cbContentOffset.Top );
cbPos.x += left;
cbPos.y += top;

View File

@@ -270,3 +270,84 @@ UTEST( UIHTMLWidget, positionOutOfFlow_ComplexHTML ) {
Engine::destroySingleton();
}
UTEST( UIHTMLWidget, positionOutOfFlow_ShrinkToFit ) {
init_ui_test();
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
UIRichText* relContainer = UIRichText::New();
relContainer->setParent( sceneNode->getRoot() );
relContainer->setCSSPosition( CSSPosition::Relative );
relContainer->setPixelsSize( 800, 600 );
relContainer->setPixelsPosition( 0, 0 );
UIRichText* absoluteChild = UIRichText::New();
absoluteChild->setParent( relContainer );
absoluteChild->applyProperty( StyleSheetProperty( "position", "absolute" ) );
absoluteChild->applyProperty( StyleSheetProperty( "display", "block" ) );
absoluteChild->applyProperty( StyleSheetProperty( "padding", "4px" ) );
sceneNode->updateDirtyLayouts();
EXPECT_EQ( SizePolicy::WrapContent, absoluteChild->getLayoutWidthPolicy() );
// With no text content, the element should shrink to just padding
Float childWidth = absoluteChild->getPixelsSize().getWidth();
EXPECT_LT( childWidth, 20.f );
Engine::destroySingleton();
}
UTEST( UIHTMLWidget, positionOutOfFlow_RightBottomPositioning ) {
init_ui_test();
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
UIHTMLWidget* relContainer = UIHTMLWidget::New();
relContainer->setParent( sceneNode->getRoot() );
relContainer->setCSSPosition( CSSPosition::Relative );
relContainer->setPixelsSize( 800, 600 );
relContainer->setPixelsPosition( 0, 0 );
UIHTMLWidget* absoluteChild = UIHTMLWidget::New();
absoluteChild->setParent( relContainer );
absoluteChild->setPixelsSize( 100, 50 );
absoluteChild->applyProperty( StyleSheetProperty( "position", "absolute" ) );
absoluteChild->applyProperty( StyleSheetProperty( "right", "0px" ) );
absoluteChild->applyProperty( StyleSheetProperty( "bottom", "0px" ) );
sceneNode->updateDirtyLayouts();
Vector2f worldPos = absoluteChild->convertToWorldSpace( { 0, 0 } );
EXPECT_NEAR( 700.f, worldPos.x, 1.f );
EXPECT_NEAR( 550.f, worldPos.y, 1.f );
Engine::destroySingleton();
}
UTEST( UIHTMLWidget, positionOutOfFlow_RightBottomWithMargin ) {
init_ui_test();
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
UIHTMLWidget* relContainer = UIHTMLWidget::New();
relContainer->setParent( sceneNode->getRoot() );
relContainer->setCSSPosition( CSSPosition::Relative );
relContainer->setPixelsSize( 800, 600 );
relContainer->setPixelsPosition( 0, 0 );
UIHTMLWidget* absoluteChild = UIHTMLWidget::New();
absoluteChild->setParent( relContainer );
absoluteChild->setPixelsSize( 100, 50 );
absoluteChild->applyProperty( StyleSheetProperty( "position", "absolute" ) );
absoluteChild->applyProperty( StyleSheetProperty( "right", "10px" ) );
absoluteChild->applyProperty( StyleSheetProperty( "bottom", "20px" ) );
absoluteChild->applyProperty( StyleSheetProperty( "margin-right", "5px" ) );
absoluteChild->applyProperty( StyleSheetProperty( "margin-bottom", "5px" ) );
sceneNode->updateDirtyLayouts();
Vector2f worldPos = absoluteChild->convertToWorldSpace( { 0, 0 } );
EXPECT_NEAR( 685.f, worldPos.x, 1.f );
EXPECT_NEAR( 525.f, worldPos.y, 1.f );
Engine::destroySingleton();
}