expandable rsx
This commit is contained in:
+31
-9
@@ -1,9 +1,39 @@
|
||||
use osui::{elements::div::Div, rsx, state::use_state, style::Transform, Screen};
|
||||
use osui::{
|
||||
elements::{div::Div, flex::FlexRow},
|
||||
frontend::Rsx,
|
||||
rsx,
|
||||
state::use_state,
|
||||
style::Transform,
|
||||
Screen,
|
||||
};
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let screen = Screen::new();
|
||||
|
||||
app().draw(&screen);
|
||||
|
||||
screen.run()
|
||||
}
|
||||
|
||||
fn app() -> Rsx {
|
||||
rsx! {
|
||||
FlexRow {
|
||||
counter()
|
||||
} (0x00000, 1)
|
||||
}
|
||||
}
|
||||
|
||||
fn counter() -> Rsx {
|
||||
let count = use_state(0);
|
||||
|
||||
std::thread::spawn({
|
||||
let count = count.clone();
|
||||
move || loop {
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
**count.get() += 1;
|
||||
}
|
||||
});
|
||||
|
||||
rsx! {
|
||||
@Transform::new().dimensions(40, 3);
|
||||
Div {
|
||||
@@ -15,12 +45,4 @@ fn main() -> std::io::Result<()> {
|
||||
"{count}"
|
||||
} (0xff0000)
|
||||
}
|
||||
.draw(&screen);
|
||||
|
||||
std::thread::spawn(move || loop {
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
**count.get() += 1;
|
||||
});
|
||||
|
||||
screen.run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user