frontend: update example widgets and linked in resources

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-06-16 02:48:37 +02:00
parent 43257dee99
commit d5f48dfed7
16 changed files with 978 additions and 422 deletions

View File

@@ -11,20 +11,30 @@ impl MainState {
fn show_window(&mut self) {
self.show_window = true;
}
fn disable_window(&mut self) {
self.show_window = false;
}
}
impl State for MainState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
if self.show_window {
ctx.child("button").set("enabled", false);
ctx.child("window1_button").set("enabled", false);
ctx.show_window(|ctx| {
Window::create()
Window::new()
.title("Dialog")
.position((120.0, 120.0))
.size(100.0, 75.0)
.size(120.0, 125.0)
.child(
Stack::create()
.child(TextBlock::create().text("New window").margin(4.0).build(ctx))
Stack::new()
.child(TextBlock::new().text("I'm the new window").margin(4.0).build(ctx))
.child(
Button::new()
.id("window3_button")
.margin(4.0)
.text("Disable me")
.build(ctx),
)
.build(ctx),
)
.build(ctx)
@@ -39,17 +49,17 @@ widget!(MainView<MainState>);
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.child(
Stack::create()
.child(TextBlock::create().text("Window 1").margin(4.0).build(ctx))
Stack::new()
.child(TextBlock::new().text("Window 1").margin(4.0).build(ctx))
.child(
Button::create()
.id("button")
Button::new()
.id("window1_button")
.on_click(move |states, _| {
states.get_mut::<MainState>(id).show_window();
true
})
.margin(4.0)
.text("Show window")
.text("Show new child window")
.build(ctx),
)
.build(ctx),
@@ -63,22 +73,22 @@ fn main() {
Application::new()
.window(|ctx| {
Window::create()
Window::new()
.title("OrbTk - multi window example window 1")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(MainView::create().build(ctx))
.child(MainView::new().build(ctx))
.build(ctx)
})
.window(|ctx| {
Window::create()
Window::new()
.title("OrbTk - multi window example window 2")
.position((600.0, 100.0))
.size(420.0, 730.0)
.child(
Stack::create()
.child(TextBlock::create().text("Window 2").margin(4.0).build(ctx))
.child(Button::create().margin(4.0).text("Click me").build(ctx))
Stack::new()
.child(TextBlock::new().text("Window 2").margin(4.0).build(ctx))
.child(Button::new().margin(4.0).text("Click me").build(ctx))
.build(ctx),
)
.build(ctx)