Updated examples with a few small changes to resolve warnings
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use osui::prelude::*;
|
||||
|
||||
pub fn app(screen: Arc<Screen>) -> Rsx {
|
||||
let count = use_state(0);
|
||||
|
||||
std::thread::spawn({
|
||||
let count = count.clone();
|
||||
move || loop {
|
||||
**count.get() += 1;
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
});
|
||||
|
||||
rsx! {
|
||||
@Handler::new({
|
||||
let screen = screen.clone();
|
||||
move |_, e: &crossterm::event::Event| {
|
||||
if let crossterm::event::Event::Key(crossterm::event::KeyEvent { code, .. }) = e {
|
||||
if *code == crossterm::event::KeyCode::Esc {
|
||||
screen.close();
|
||||
}
|
||||
}
|
||||
}});
|
||||
@AlwaysFocused;
|
||||
Paginator {
|
||||
FlexRow {
|
||||
Heading, smooth: false, { "OSUI" }
|
||||
"Welcome to the OSUI demo!"
|
||||
"Press tab to switch to the next page or shift+tab to the previous page"
|
||||
}
|
||||
|
||||
FlexCol, gap: 3, {
|
||||
@Transform::new().padding(2, 2);
|
||||
@Style { foreground: None, background: Background::RoundedOutline(0x00ff00) };
|
||||
Div {
|
||||
"This is text inside a div"
|
||||
}
|
||||
|
||||
@Transform::new().padding(2, 2);
|
||||
@Style { foreground: None, background: Background::Outline(0x00ff00) };
|
||||
Div {
|
||||
"This is text inside a div with square outlines"
|
||||
}
|
||||
|
||||
// TODO: div with width full
|
||||
}
|
||||
|
||||
FlexRow, gap: 1, {
|
||||
%count
|
||||
"This will increment every second: {count}"
|
||||
|
||||
FlexRow
|
||||
{
|
||||
"Username"
|
||||
@Transform::new().padding(1, 1).dimensions(40, 1);
|
||||
@Style { foreground: Some(0xffffff), background: Background::RoundedOutline(0xff0000) };
|
||||
@Focused;
|
||||
Input { }
|
||||
}
|
||||
|
||||
@Transform::new().margin(0, 1);
|
||||
FlexRow
|
||||
{
|
||||
"Password"
|
||||
@Transform::new().padding(1, 1).dimensions(40, 1);
|
||||
@Style { foreground: Some(0xffffff), background: Background::RoundedOutline(0xffff00) };
|
||||
Input { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_widgets(&self) -> MutexGuard<Vec<Arc<Widget>>> {
|
||||
pub fn get_widgets(&'_ self) -> MutexGuard<'_, Vec<Arc<Widget>>> {
|
||||
self.screen.widgets.lock().unwrap()
|
||||
}
|
||||
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
mod demos;
|
||||
use osui::prelude::*;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let screen = Screen::new();
|
||||
screen.extension(InputExtension);
|
||||
screen.extension(RelativeFocusExtension::new());
|
||||
|
||||
demos::app(screen.clone()).draw(&screen);
|
||||
|
||||
screen.run()
|
||||
}
|
||||
+3
-3
@@ -166,7 +166,7 @@ impl Widget {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_elem(&self) -> MutexGuard<BoxedElement> {
|
||||
pub fn get_elem(&'_ self) -> MutexGuard<'_, BoxedElement> {
|
||||
match self {
|
||||
Widget::Static(w) => w.get_elem(),
|
||||
Widget::Dynamic(w) => w.get_elem(),
|
||||
@@ -284,7 +284,7 @@ impl Widget {
|
||||
|
||||
impl StaticWidget {
|
||||
fn after_render(&self) {}
|
||||
fn get_elem(&self) -> MutexGuard<BoxedElement> {
|
||||
fn get_elem(&'_ self) -> MutexGuard<'_, BoxedElement> {
|
||||
self.element.lock().unwrap()
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ impl StaticWidget {
|
||||
|
||||
impl DynWidget {
|
||||
fn after_render(&self) {}
|
||||
fn get_elem(&self) -> MutexGuard<BoxedElement> {
|
||||
fn get_elem(&'_ self) -> MutexGuard<'_, BoxedElement> {
|
||||
self.element.lock().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user