mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
788 B
41 lines
788 B
3 years ago
|
use gui::Draw;
|
||
|
|
||
|
struct SelectBox {
|
||
|
width: u32,
|
||
|
height: u32,
|
||
|
options: Vec<String>,
|
||
|
}
|
||
|
|
||
|
impl Draw for SelectBox {
|
||
|
fn draw(&self) {
|
||
|
// code to actually draw a select box
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ANCHOR: here
|
||
|
use gui::{Button, Screen};
|
||
|
|
||
|
fn main() {
|
||
|
let screen = Screen {
|
||
|
components: vec![
|
||
|
Box::new(SelectBox {
|
||
|
width: 75,
|
||
|
height: 10,
|
||
|
options: vec![
|
||
|
String::from("Yes"),
|
||
|
String::from("Maybe"),
|
||
|
String::from("No"),
|
||
|
],
|
||
|
}),
|
||
|
Box::new(Button {
|
||
|
width: 50,
|
||
|
height: 10,
|
||
|
label: String::from("OK"),
|
||
|
}),
|
||
|
],
|
||
|
};
|
||
|
|
||
|
screen.run();
|
||
|
}
|
||
|
// ANCHOR_END: here
|