RibirX / Ribir

Non-intrusive GUI framework for Rust

Home Page:https://ribir.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aling items doesn't work

Fidius-jko opened this issue · comments

Problem

Steps To Reproduce
write this code and run:

use ribir::prelude::*;

fn main() {
    App::run(fn_widget! {
    rdl!{
      Row {
        align_items: Align::Center,
        rdl!{ FilledButton {
          rdl!{ Label::new("Increment") }
        }}
        rdl!{ H1 { text: "0" } }
      }
    }
  });
}

Expected behavior
Button and H1 are at center

Screenshots
image

Environment:

  • Ribir version: [0.2.0-beta.1]
  • Rust version: [nightly]
  • OS, if relevant: [Win10]
commented

Hi, @Fidius-jko

The align_items property determines the placement of child widgets along the cross axis in a flex layout.

In your scenario, it positions the two child widgets of the Row widget at the vertical center of the Row widget. Since the Row is expanded by the Button and the H1, the H1 is positioned at the vertical center of the Row, which is the expected behavior.

If you wish to center the entire Row relative to its parent widget (in this case, the window), you can use the built-in properties h_align and v_align.