Grokmoo / thyme

Themable Immediate Mode User Interface Toolkit in Rust
Apache License 2.0
97 stars 5 forks source link

Some examples do not work #31

Closed AlexEne closed 3 years ago

AlexEne commented 3 years ago

The code here: https://docs.rs/thyme/0.5.0/thyme/ mentions:

    ui.child("custom_widget")
    .align(Align::BotRight)
    .layout(Layout::Vertical)
    .children(|ui| {
      for i in 1..10 {
        ui.label("label", format!("Row #{}", i));
      }
    });

This errors out as align is not found in WidgetState

AlexEne commented 3 years ago

For reference, I'm trying to re-create this window layout in thyme: image

Grokmoo commented 3 years ago

You should be able to just insert

use thyme::{Align, Layout};

before that and it should work. You shouldn't have any issue recreating that layout with Thyme either in the code or using the YAML attributes.

AlexEne commented 3 years ago

The problem is that this line ui.child("custom_widget") returns WidgetState and that's an enum that doesn't have align or the other methods available.

It may seem that the intent was that add_child should return a Widget?

Grokmoo commented 3 years ago

Ah! Sorry about that, you should replace ui.child( with ui.start(

the child method is a shorthand that immediately finishes building the widget without any extra behavior. I'd recommend you check out the demo example.

AlexEne commented 3 years ago

Oh, ok I can raise a PR to fix the example and maybe enable doc tests.

Grokmoo commented 3 years ago

Fixed in 366ddbe28b39cab74cf7d7fd31f599ba6ea2450e