Skip to content

Commit

Permalink
Merge branch 'main' into feat/improve-input
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Nov 1, 2023
2 parents cc18b23 + dacf9fc commit e4df661
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ freya-node-state = { workspace = true }
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.189"
tracing-subscriber = "0.3.17"
dioxus-std = { version = "0.4", features = ["utils", "i18n"] }
dioxus-std = { version = "0.4", features = ["i18n"] }
rand = "0.8.5"
dioxus-router = { workspace = true }
itertools = "0.11.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn process_layers(
let text_group = layers
.paragraph_elements
.entry(cursor_ref.text_id)
.or_insert_with(Vec::default);
.or_default();

text_group.push(node.id());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/layout/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Layers {

/// Insert a Node into a layer
pub fn add_element(&mut self, node_id: NodeId, node_layer: i16) {
let layer = self.layers.entry(node_layer).or_insert_with(Vec::default);
let layer = self.layers.entry(node_layer).or_default();

layer.push(node_id);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/torin/src/measure_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ impl<'a> MeasureMode<'a> {
},
MeasureMode::ParentIsNotCached { area, inner_area } => {
OwnedMeasureMode::ParentIsNotCached {
area: **area.clone(),
inner_area: **inner_area.clone(),
area: **area,
inner_area: **inner_area,
}
}
}
Expand Down
26 changes: 12 additions & 14 deletions examples/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

use std::{
sync::{Arc, Mutex},
time::{Duration, Instant},
time::Instant,
};

use dioxus_std::utils::channel::{use_channel, use_listen_channel};
use freya::{common::EventMessage, prelude::*};
use freya::prelude::*;
use skia_safe::{Color, Data, Paint, Rect, RuntimeEffect};
use tokio::time::sleep;

fn main() {
launch(app);
Expand All @@ -36,22 +34,24 @@ const SHADER: &str = "

fn app(cx: Scope) -> Element {
let platform = use_platform(cx);
let render_channel = use_channel::<()>(cx, 1);

use_listen_channel(cx, &render_channel, move |_| {
to_owned![platform];
async move {
sleep(Duration::from_millis(25)).await;
platform.send(EventMessage::RequestRerender).unwrap();
}
cx.use_hook(|| {
let mut ticker = platform.new_ticker();

cx.spawn(async move {
loop {
ticker.tick().await;
platform.request_animation_frame();
}
});
});

let canvas = use_canvas(cx, (), |_| {
let shader = RuntimeEffect::make_for_shader(SHADER, None).unwrap();
let shader_wrapper = Arc::new(Mutex::new(ShaderWrapper(shader)));
let instant = Instant::now();

to_owned![render_channel, shader_wrapper];
to_owned![shader_wrapper];
Box::new(move |canvas, _, region| {
let shader = shader_wrapper.lock().unwrap();

Expand Down Expand Up @@ -83,8 +83,6 @@ fn app(cx: Scope) -> Element {
),
&paint,
);

render_channel.try_send(()).ok();
})
});

Expand Down
2 changes: 1 addition & 1 deletion examples/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn app(cx: Scope) -> Element {
divider: n > 0,
label {
width: "100%",
align: "right",
text_align: "right",
"{item}"
}
}
Expand Down

0 comments on commit e4df661

Please sign in to comment.