#Align center a child Node to the parent Node

7 messages · Page 1 of 1 (latest)

lapis ridge
#
        // root
        Node {
            width: percent(100),
            height: percent(100),
            align_items: AlignItems::Center,
            justify_content: JustifyContent::Center,
            flex_direction: FlexDirection::Column,
            ..default()
        },
        children![(
            // child 1
            TextButton1,
            Node {
                position_type: PositionType::Absolute,
                top: px(8),
                left: px(8),
                width: px(210),
                height: px(30),
                ..default()
            },
            BackgroundColor(ORANGE.into()),
            children![(
                // child 2
                Node {
                    align_items: AlignItems::Center,
                    justify_self: JustifySelf::Center,
                    align_self: AlignSelf::Center,
                    position_type: PositionType::Absolute,
                    ..default()
                },
                TextFont {
                    font_size: 25.0,
                    ..default()
                },
                Text::new("Button A"),
                TextColor(BLACK.into()),
            )]
        ),],
    ));``` i would like to center the  text in the child 2 bundle to the center  of the child 1 Node how do we do that ?
little sandal
#

try adding align_content and justify_content to child 1 instead

lapis ridge
#

thanks , setting child2 to Node{..default} did the trick and align_items: AlignItems::Center, justify_self: JustifySelf::Center, to nod 1

little sandal
#

align_contents, align_items and align_self all have different meanings, i don't know them properly, so it is always a question of attempting all permutations, same thing for the 3 justify_ ones

lapis ridge
#
            enabled: true,
            line_width: 1.0,
            line_color_override: None,
            show_hidden: true,
            show_clipped: true,
        })``` is this how we configure the overlay ?
little sandal
#

i usually just set the enabled: true and the rest can be ..Default::default()