Merge branch 'upstream' into fix-non-str-attributes
This commit is contained in:
commit
044462876d
52 files changed
+3002
-2852
No files matched your search
@@ -10,22 +10,14 @@ fn tui_update(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("Update boxes");
|
||||
|
||||
// We can also use loops to define multiple benchmarks, even over multiple dimensions.
|
||||
for size in 1..=8u32 {
|
||||
for size in 1..=8usize {
|
||||
let parameter_string = format!("{}", (3 * size).pow(2));
|
||||
group.bench_with_input(
|
||||
BenchmarkId::new("size", parameter_string),
|
||||
&size,
|
||||
|b, size| {
|
||||
b.iter(|| match size {
|
||||
1 => dioxus_tui::launch_cfg(app3, Config::default().with_headless()),
|
||||
2 => dioxus_tui::launch_cfg(app6, Config::default().with_headless()),
|
||||
3 => dioxus_tui::launch_cfg(app9, Config::default().with_headless()),
|
||||
4 => dioxus_tui::launch_cfg(app12, Config::default().with_headless()),
|
||||
5 => dioxus_tui::launch_cfg(app15, Config::default().with_headless()),
|
||||
6 => dioxus_tui::launch_cfg(app18, Config::default().with_headless()),
|
||||
7 => dioxus_tui::launch_cfg(app21, Config::default().with_headless()),
|
||||
8 => dioxus_tui::launch_cfg(app24, Config::default().with_headless()),
|
||||
_ => (),
|
||||
b.iter(|| {
|
||||
dioxus_tui::launch_cfg_with_props(app, *size, Config::default().with_headless())
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -73,7 +65,7 @@ fn Grid(cx: Scope<GridProps>) -> Element {
|
||||
let count = use_state(cx, || 0);
|
||||
let counts = use_ref(cx, || vec![0; size * size]);
|
||||
|
||||
let ctx: &TuiContext = cx.consume_context().unwrap();
|
||||
let ctx: TuiContext = cx.consume_context().unwrap();
|
||||
if *count.get() + 1 >= (size * size) {
|
||||
ctx.quit();
|
||||
} else {
|
||||
@@ -123,97 +115,13 @@ fn Grid(cx: Scope<GridProps>) -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
fn app3(cx: Scope) -> Element {
|
||||
fn app(cx: Scope<usize>) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 3,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app6(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 6,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app9(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 9,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app12(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 12,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app15(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 15,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app18(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 18,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app21(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 21,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app24(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: 24,
|
||||
size: *cx.props,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -10,15 +10,15 @@ fn main() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
let hue = use_state(cx, || 0.0);
|
||||
let brightness = use_state(cx, || 0.0);
|
||||
let tui_query: &Query = cx.consume_context().unwrap();
|
||||
let tui_query: Query = cx.consume_context().unwrap();
|
||||
// disable templates so that every node has an id and can be queried
|
||||
cx.render(rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
background_color: "hsl({hue}, 70%, {brightness}%)",
|
||||
onmousemove: move |evt| {
|
||||
if let RenderReturn::Sync(Some(node)) = cx.root_node() {
|
||||
if let Some(id) = node.root_ids[0].get() {
|
||||
if let RenderReturn::Ready(node) = cx.root_node() {
|
||||
if let Some(id) = node.root_ids.get(0){
|
||||
let node = tui_query.get(id);
|
||||
let Size{width, height} = node.size().unwrap();
|
||||
let pos = evt.inner().element_coordinates();
|
||||
|
||||
@@ -75,7 +75,11 @@ pub fn launch(app: Component<()>) {
|
||||
}
|
||||
|
||||
pub fn launch_cfg(app: Component<()>, cfg: Config) {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
launch_cfg_with_props(app, (), cfg);
|
||||
}
|
||||
|
||||
pub fn launch_cfg_with_props<Props: 'static>(app: Component<Props>, props: Props, cfg: Config) {
|
||||
let mut dom = VirtualDom::new_with_props(app, props);
|
||||
|
||||
let (handler, state, register_event) = RinkInputHandler::new();
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ use dioxus_core::{ElementId, RenderReturn, Scope};
|
||||
pub use input::*;
|
||||
|
||||
pub(crate) fn get_root_id<T>(cx: Scope<T>) -> Option<ElementId> {
|
||||
if let RenderReturn::Sync(Some(sync)) = cx.root_node() {
|
||||
sync.root_ids.get(0).and_then(|id| id.get())
|
||||
if let RenderReturn::Ready(sync) = cx.root_node() {
|
||||
sync.root_ids.get(0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user