Skip to content

Instantly share code, notes, and snippets.

@FranchuFranchu
Created April 27, 2021 22:39
Show Gist options
  • Save FranchuFranchu/b5fd9b8ebf877a8d3459f7007fed19bf to your computer and use it in GitHub Desktop.
Save FranchuFranchu/b5fd9b8ebf877a8d3459f7007fed19bf to your computer and use it in GitHub Desktop.
Example code for conrod List in rust.
// Make sure you've defined these
let mut ui: UiCell;
let ids: Ids; // struct defined in the widget_ids! macro
let strings = vec!["One", "Two", "Buckle my shoe", "Three", "Four", "Shut the door", "Five", "Six", "Pick up the sticks"];
let (mut items, mut scrollbar) = conrod_core::widget::List::flow_down(strings.len())
.x(0.).y(0.)
.w(200.).h(500.)
.scrollbar_next_to()
.scrollbar_thickness(10.)
.scrollbar_color(Color::Rgba(1., 1., 1., 1.))
.set(ids.my_list, ui);
while let Some(item) = items.next(ui) {
item.set(
conrod_core::widget::Button::new()
.rgba(1., 1., 0., 1.)
.w(180.).h(100.)
.label(strings[item.i]), ui);
}
if let Some(scrollbar) = scrollbar {
scrollbar.set(ui)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment