diff --git a/examples/webgpu/src/lib.rs b/examples/webgpu/src/lib.rs index c4e9fbabe..034248613 100644 --- a/examples/webgpu/src/lib.rs +++ b/examples/webgpu/src/lib.rs @@ -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()) diff --git a/src/app/mod.rs b/src/app/mod.rs index f21c58df8..d274d22e4 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -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}, }; @@ -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) diff --git a/src/event/dispatch.rs b/src/event/dispatch.rs index 243c999bb..51a49db85 100644 --- a/src/event/dispatch.rs +++ b/src/event/dispatch.rs @@ -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; @@ -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, diff --git a/src/window/handle.rs b/src/window/handle.rs index de5a87e4c..6c43516bf 100644 --- a/src/window/handle.rs +++ b/src/window/handle.rs @@ -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 @@ -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); @@ -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(); diff --git a/src/window/state.rs b/src/window/state.rs index bb95030b3..2a7156e4c 100644 --- a/src/window/state.rs +++ b/src/window/state.rs @@ -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, @@ -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}, };