Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions examples/webgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,22 @@ pub fn app_view() -> impl IntoView {
// Create a vertical layout
(
// The counter value updates automatically, thanks to reactivity
Label::derived(move || format!("Value: {}", counter.get())),
Label::derived(move || format!("Value: {}", counter.get()))
.style(|s| s.font_family("Fira Sans".to_owned())),
// Create a horizontal layout
(
"Increment".class(ButtonClass).action(move || {
counter.update(|value| *value += 1);
}),
"Decrement".class(ButtonClass).action(move || {
counter.update(|value| *value -= 1);
}),
"Increment"
.class(ButtonClass)
.style(|s| s.font_family("Fira Sans".to_owned()))
.action(move || {
counter.update(|value| *value += 1);
}),
"Decrement"
.class(ButtonClass)
.style(|s| s.font_family("Fira Sans".to_owned()))
.action(move || {
counter.update(|value| *value -= 1);
}),
),
)
.style(|s| s.flex_col())
Expand Down
3 changes: 2 additions & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::{
action::{Timer, TimerToken},
inspector::{Capture, profiler::Profile},
platform::clipboard::Clipboard,
platform::menu_types::Menu,
view::IntoView,
window::{WindowConfig, WindowCreation},
};
Expand Down Expand Up @@ -107,7 +108,7 @@ pub enum AppEvent {
Reopen { has_visible_windows: bool },
}

pub(crate) struct MenuWrapper(pub(crate) muda::Menu);
pub(crate) struct MenuWrapper(pub(crate) Menu);
// SAFETY: these unsafe wappers are needed so that we can send the muda memu.
// The muda menu internally uses RC on a String ID and it's Vec of children.
// This unsafe wrapper is memory safe but the race condition could potentially (unlikely)
Expand Down
3 changes: 2 additions & 1 deletion src/event/dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Event dispatch logic for handling events through the view tree.

use std::{rc::Rc, sync::LazyLock, time::Instant};
use std::{rc::Rc, sync::LazyLock};

use peniko::kurbo::{Affine, Point, Rect};
use smallvec::SmallVec;
Expand All @@ -25,6 +25,7 @@ use crate::{
DragEvent, DragToken, Event, FocusEvent, InteractionEvent, Phase, PointerCaptureEvent,
WindowEvent, drag_state::DragEventDispatch, dropped_file::FileDragEvent, path::hit_test,
},
platform::time::Instant,
style::{StyleSelector, StyleSelectors, recalc::StyleReason},
view::{VIEW_STORAGE, View},
window::WindowState,
Expand Down
5 changes: 3 additions & 2 deletions src/window/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ impl WindowHandle {
// Capture a single timestamp for the entire style pass.
// All views in this frame see the same `now`, which is both cheaper
// (avoids per-view syscall) and more correct (no sub-frame jitter).
self.window_state.frame_start = std::time::Instant::now();
self.window_state.frame_start = Instant::now();

// Loop until no more views need styling
// This handles the case where styling a parent marks children dirty
Expand Down Expand Up @@ -790,8 +790,8 @@ impl WindowHandle {
if self.window_state.request_paint && renderer_ready {
self.window_state.request_paint = false;
self.paint();
self.last_presented_at = Instant::now();
}
self.last_presented_at = Instant::now();

if self.live_resize_active() {
self.window_state.schedule_paint(self.id);
Expand Down Expand Up @@ -1228,6 +1228,7 @@ impl WindowHandle {
pos,
});
}
#[cfg(not(target_arch = "wasm32"))]
UpdateMessage::WindowMenu { menu } => {
self.window_menu_actions.clear();
let (menu, registry) = menu.build();
Expand Down
3 changes: 2 additions & 1 deletion src/window/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cell::RefCell, collections::HashMap, time::Instant};
use std::{cell::RefCell, collections::HashMap};

use crate::{
action::exec_after_animation_frame,
Expand Down Expand Up @@ -27,6 +27,7 @@ use crate::{
event::{DragTracker, Event, WindowEvent, clear_hit_test_cache},
layout::responsive::{GridBreakpoints, ScreenSizeBp},
message::UpdateMessage,
platform::time::Instant,
style::{CursorStyle, Style, StyleSelector, theme::default_theme},
view::{LayoutNodeCx, MeasureCx, VIEW_STORAGE, ViewId},
};
Expand Down