diff --git a/src/app_handle.rs b/src/app_handle.rs index 6b1b9790..391d5872 100644 --- a/src/app_handle.rs +++ b/src/app_handle.rs @@ -159,7 +159,7 @@ impl ApplicationHandle { window_handle.menu_action(id); } WindowEvent::RedrawRequested => { - window_handle.paint(); + window_handle.render_frame(); } } } diff --git a/src/context.rs b/src/context.rs index d06f7333..dc016ba8 100644 --- a/src/context.rs +++ b/src/context.rs @@ -6,12 +6,9 @@ use std::{ time::{Duration, Instant}, }; -use floem_renderer::{ - cosmic_text::{LineHeightValue, Style as FontStyle, Weight}, - Renderer as FloemRenderer, -}; +use bitflags::bitflags; +use floem_renderer::Renderer as FloemRenderer; use kurbo::{Affine, Insets, Point, Rect, RoundedRect, Shape, Size, Vec2}; -use peniko::Color; use taffy::{ prelude::{Layout, Node}, style::{AvailableSpace, Display}, @@ -34,7 +31,7 @@ use crate::{ StyleSelector, StyleSelectors, ZIndex, }, unit::PxPct, - view::{paint_bg, paint_border, paint_outline, ChangeFlags, View}, + view::{paint_bg, paint_border, paint_outline, View}, }; pub type EventCallback = dyn Fn(&Event) -> bool; @@ -65,11 +62,19 @@ prop_extracter! { } } +bitflags! { + #[derive(Default, Copy, Clone, Debug)] + #[must_use] + pub(crate) struct ChangeFlags: u8 { + const STYLE = 1; + const LAYOUT = 1 << 1; + } +} + pub struct ViewState { pub(crate) node: Node, pub(crate) children_nodes: Vec, - pub(crate) request_layout: bool, - pub(crate) request_style: bool, + pub(crate) requested_changes: ChangeFlags, /// Layout is requested on all direct and indirect children. pub(crate) request_style_recursive: bool, pub(crate) has_style_selectors: StyleSelectors, @@ -101,8 +106,7 @@ impl ViewState { layout_rect: Rect::ZERO, layout_props: Default::default(), view_style_props: Default::default(), - request_layout: true, - request_style: true, + requested_changes: ChangeFlags::all(), request_style_recursive: false, has_style_selectors: StyleSelectors::default(), animation: None, @@ -123,6 +127,7 @@ impl ViewState { } } + /// Returns `true` if a new frame is requested. pub(crate) fn compute_style( &mut self, view_style: Option