155 lines
6.0 KiB
Plaintext
155 lines
6.0 KiB
Plaintext
use orbtk::prelude::*;
|
|
use orbtk::theme::DEFAULT_THEME_CSS;
|
|
|
|
static CSS_EXT: &'static str = include_str!("../resources/stylesheets/grid.css");
|
|
|
|
fn get_theme() -> ThemeValue {
|
|
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
|
.extension_css(CSS_EXT)
|
|
.build()
|
|
}
|
|
|
|
widget!(MainView);
|
|
|
|
impl Template for MainView {
|
|
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
|
|
self.name("MainView").child(
|
|
Grid::create()
|
|
.columns(
|
|
Columns::create()
|
|
.column("*")
|
|
.column("auto")
|
|
.column(90.0)
|
|
.build(),
|
|
)
|
|
.rows(Rows::create().row("*").row("*").row("*").build())
|
|
.child(
|
|
Grid::create()
|
|
.selector("hiedemann")
|
|
.margin((30.0, 25.0, 0.0, 20.0))
|
|
.constraint(Constraint::create().width(80.0).build())
|
|
.attach(Grid::column(0))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("Grid\n(0,0)")
|
|
.selector("hiedemann")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
.child(
|
|
Grid::create()
|
|
.selector("bluebayoux")
|
|
.margin(10.0)
|
|
.constraint(Constraint::create().width(150.0).build())
|
|
.attach(Grid::column(1))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("Grid\n(1,0)")
|
|
.selector("white")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
.child(
|
|
Grid::create()
|
|
.selector("linkwater")
|
|
.attach(Grid::column(2))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("Grid\n(2,0)")
|
|
.selector("linkwater")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
.child(
|
|
Grid::create()
|
|
.selector("goldendream")
|
|
.attach(Grid::column(0))
|
|
.attach(Grid::row(1))
|
|
.attach(Grid::column_span(3))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("Grid (0,1) - ColumnSpan 3")
|
|
.selector("goldendream")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
.child(
|
|
Grid::create()
|
|
.selector("bluebayoux")
|
|
.margin(10.0)
|
|
.constraint(Constraint::create().width(200.0).build())
|
|
.attach(Grid::column(0))
|
|
.attach(Grid::row(2))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("Row 2")
|
|
.selector("white")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.child(
|
|
TextBlock::create()
|
|
.text("(0,1)")
|
|
.selector("white")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
/*.child(
|
|
Grid::create()
|
|
.selector("hiedemann")
|
|
.attach(Grid::column(1))
|
|
.attach(Grid::row(2))
|
|
//.attach(Grid::column_span(2))
|
|
.margin((30.0, 25.0, 0.0, 20.0))
|
|
.attach(Grid::column(0))
|
|
.child(
|
|
TextBlock::create()
|
|
.text("(0,2)")
|
|
//.selector("light-text")
|
|
.selector("hiedemann")
|
|
.horizontal_alignment("center")
|
|
.vertical_alignment("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx),
|
|
)
|
|
*/
|
|
.build(ctx),
|
|
)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
// use this only if you want to run it as web application.
|
|
//orbtk::initialize();
|
|
|
|
Application::new()
|
|
.window(|ctx| {
|
|
Window::create()
|
|
.title("OrbTk - grid example")
|
|
.position((100.0, 10.0))
|
|
.size(420.0, 530.0)
|
|
.theme(get_theme())
|
|
.resizeable(true)
|
|
.child(MainView::create().build(ctx))
|
|
.build(ctx)
|
|
})
|
|
.run();
|
|
}
|