PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 296 forks source link

List with multiple widgets as items. #1431

Open kohlten opened 2 years ago

kohlten commented 2 years ago

Hello,

I'm currently looking for a way to have a List store multiple widgets on each item of the list. A simple example would be a piece of text and a button. Is this possible with conrod?

I'm having an issue when you instantiate the List widget, you "set" to one node. If this node could have children, how would you access the Id to set the parent?

Here's a simple example of what I'm trying.

let values = vec![0, 1, 2, 3];
let (mut items, scrollbar) = widget::List::flow_down(items.len())
    .item_size(10.0)
    .scrollbar_on_top()
    .set(ids.list_id, ui);

while let Some(item) = items.next(ui) {
    let canvas = widget::Canvas::new();
    item.set(canvas, ui);
    widget::Text::new(&format!("{}", values[item.i]))
        .parent(<INSERT CANVAS ID HERE>);
    widget::Text::new(&format!("{:X}", values[item.i]))
        .parent(<INSERT CANVAS ID HERE>);
}

Any help would be appreciated.