Created
April 27, 2021 22:39
-
-
Save FranchuFranchu/b5fd9b8ebf877a8d3459f7007fed19bf to your computer and use it in GitHub Desktop.
Example code for conrod List in rust.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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