69 lines
1.9 KiB
Rust
69 lines
1.9 KiB
Rust
use orbtk::prelude::*;
|
|
|
|
widget!(MainView);
|
|
|
|
impl Template for MainView {
|
|
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
|
|
let container = Container::new()
|
|
.background("#dfebf5")
|
|
.width(200.0)
|
|
.height(200.0)
|
|
.child(
|
|
TextBlock::new()
|
|
.foreground("#3b434a")
|
|
.text("Overlay 1")
|
|
.element("h2")
|
|
.v_align("center")
|
|
.h_align("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx);
|
|
|
|
let container = Container::new()
|
|
.background("#dffff5")
|
|
.width(180.0)
|
|
.height(180.0)
|
|
.position((250.0, 250.0))
|
|
.child(
|
|
TextBlock::new()
|
|
.foreground("#3f3f3f")
|
|
.text("Overlay 2")
|
|
.v_align("center")
|
|
.h_align("center")
|
|
.build(ctx),
|
|
)
|
|
.build(ctx);
|
|
|
|
ctx.append_child_to_overlay(container).unwrap();
|
|
self.name("MainView").child(
|
|
Container::new()
|
|
.background("#e1bc21")
|
|
.child(
|
|
TextBlock::new()
|
|
.text("MainView")
|
|
.element("h1")
|
|
.v_align("center")
|
|
.h_align("center")
|
|
.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::new()
|
|
.title("OrbTk - overlay example")
|
|
.position((100.0, 100.0))
|
|
.size(420.0, 730.0)
|
|
.child(MainView::create().build(ctx))
|
|
.build(ctx)
|
|
})
|
|
.run();
|
|
}
|