Skip to content
Snippets Groups Projects
grid.rs 2.34 KiB
Newer Older
use orbtk::*;

struct MainView;

// todo: check running by each system

// todo: use ParentType::Single as default

impl Widget for MainView {
    fn create() -> Template {
        Template::default().debug_name("MainView").child(
            Grid::create()
                .selector("green")
                .property(
                    Columns::create()
                        .column("*")
                        .column("Auto")
                        .column(50.0)
                        .build(),
                )
                .property(Rows::create().row("*").row("*").build())
                .child(
                    Grid::create()
                        .selector("blue")
                        .property(GridColumn(0))
                        .child(TextBlock::create().property(Label::from("(0,0)"))),
                )
                .child(
                    Grid::create()
                        .selector("yellow")
                        .property(GridColumn(1))
                        .child(
                            TextBlock::create()
                                .property(Label::from("(1,0)"))
                                .horizontal_alignment("Center")
                                .vertical_alignment("Center")
                        ),
                )
                .child(
                    Grid::create()
                        .selector("red")
                        .property(GridColumn(2))
                        .child(TextBlock::create().property(Label::from("(1,1)"))),
                )
                .child(
                    Grid::create()
                        .selector("olive")
                        .property(GridColumn(1))
                        .property(GridRow(1))
                        .property(ColumnSpan(2))
                        .child(TextBlock::create().property(Label::from("(1,1)"))),
                ),
        )
    }
}

fn main() {
    let mut application = Application::default();
    application
        .create_window()
Florian Blasius's avatar
Florian Blasius committed
        .bounds(Bounds::new(100.0, 100.0, 420.0, 730.0))
        .title("OrbTk - grid example")
        .root(MainView::create())
        .theme(
Florian Blasius's avatar
Florian Blasius committed
                .extenstion_path("examples/res/grid.css")
Florian Blasius's avatar
Florian Blasius committed
        .resizable(true)
        .debug_flag(true)
        .build();
    application.run();
}