Skip to content
Merged
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
3 changes: 1 addition & 2 deletions masonry/examples/custom_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ use masonry::core::{
TextEvent, Widget, WidgetId,
};
use masonry::kurbo::{Affine, BezPath, Point, Rect, Size, Stroke};
use masonry::palette;
use masonry::parley::style::{FontFamily, FontStack, GenericFamily, StyleProperty};
use masonry::peniko::{Color, Fill, ImageBrush, ImageFormat};
use masonry::properties::ObjectFit;
use masonry::theme::default_property_set;
use masonry::vello::Scene;
use masonry::{TextAlign, TextAlignOptions};
use masonry::{TextAlign, TextAlignOptions, palette};
use masonry_winit::app::{AppDriver, DriverCtx, NewWindow, WindowId};
use masonry_winit::winit::window::Window;
use tracing::{Span, trace_span};
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ use crate::properties::{
};
use crate::theme;
use crate::util::{fill, include_screenshot, stroke};

use super::Label;
use crate::widgets::Label;

/// A button with a child widget.
///
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use accesskit::{Node, Role, Toggled};
use masonry_core::core::HasProperty;
use tracing::{Span, trace, trace_span};
use vello::Scene;
use vello::kurbo::Rect;
use vello::kurbo::{Affine, BezPath, Cap, Dashes, Join, Size, Stroke};
use vello::kurbo::{Affine, BezPath, Cap, Dashes, Join, Rect, Size, Stroke};

use crate::core::keyboard::Key;
use crate::core::{
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::core::{
AccessCtx, Axis, BoxConstraints, ChildrenIds, LayoutCtx, NewWidget, NoAction, PaintCtx,
PropertiesMut, PropertiesRef, RegisterCtx, UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
};
use crate::properties::types::Length;
use crate::properties::types::{CrossAxisAlignment, MainAxisAlignment};
use crate::properties::types::{CrossAxisAlignment, Length, MainAxisAlignment};
use crate::properties::{Background, BorderColor, BorderWidth, CornerRadius, Padding};
use crate::theme::DEFAULT_GAP;
use crate::util::{debug_panic, fill, include_screenshot, stroke};
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ mod tests {

use super::*;
use crate::core::Properties;
use crate::properties::types::CrossAxisAlignment;
use crate::properties::types::{AsUnit, Length};
use crate::properties::types::{AsUnit, CrossAxisAlignment, Length};
use crate::testing::{TestHarness, assert_render_snapshot};
use crate::theme::{ACCENT_COLOR, test_property_set};
use crate::widgets::{Flex, SizedBox};
Expand Down
3 changes: 2 additions & 1 deletion masonry/src/widgets/passthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ impl Widget for Passthrough {
// --- MARK: TESTS
#[cfg(test)]
mod tests {
use vello::kurbo::Size;

use super::*;
use crate::testing::{TestHarness, assert_render_snapshot};
use crate::theme::test_property_set;
use crate::widgets::Label;
use vello::kurbo::Size;

#[test]
fn passthrough_replaces_child() {
Expand Down
8 changes: 5 additions & 3 deletions masonry/src/widgets/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use crate::core::{
AccessCtx, ArcStr, BoxConstraints, ChildrenIds, LayoutCtx, NoAction, PaintCtx, PropertiesMut,
PropertiesRef, RegisterCtx, Update, UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
};
use crate::properties::LineBreaking;
use crate::properties::{Background, BarColor, BorderColor, BorderWidth, CornerRadius};
use crate::properties::{
Background, BarColor, BorderColor, BorderWidth, CornerRadius, LineBreaking,
};
use crate::util::{fill, include_screenshot, stroke};
use crate::widgets::Label;

Expand Down Expand Up @@ -208,9 +209,10 @@ mod tests {
use masonry_core::core::NewWidget;

use super::*;
use crate::core::Properties;
use crate::palette;
use crate::testing::{TestHarness, assert_render_snapshot};
use crate::theme::test_property_set;
use crate::{core::Properties, palette};

#[test]
fn indeterminate_progressbar() {
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/prose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ mod tests {

use super::*;
use crate::TextAlign;
use crate::properties::types::CrossAxisAlignment;
use crate::properties::types::{AsUnit, Length};
use crate::properties::types::{AsUnit, CrossAxisAlignment, Length};
use crate::testing::{TestHarness, assert_render_snapshot};
use crate::theme::test_property_set;
use crate::widgets::{Flex, SizedBox, TextArea};
Expand Down
8 changes: 3 additions & 5 deletions masonry/src/widgets/resize_observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ mod tests {
use masonry_testing::TestHarness;
use vello::kurbo::Size;

use crate::{
properties::types::AsUnit,
theme::default_property_set,
widgets::{Flex, LayoutChanged, ResizeObserver, SizedBox},
};
use crate::properties::types::AsUnit;
use crate::theme::default_property_set;
use crate::widgets::{Flex, LayoutChanged, ResizeObserver, SizedBox};

#[test]
fn detects_inner_resizing() {
Expand Down
3 changes: 1 addition & 2 deletions masonry/src/widgets/virtual_scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,14 +1049,13 @@ mod tests {
use kurbo::{Size, Vec2};
use parley::StyleProperty;

use super::opt_iter_difference;
use crate::core::{NewWidget, Widget, WidgetId, WidgetMut};
use crate::testing::{TestHarness, assert_render_snapshot};
use crate::theme::test_property_set;
use crate::vello::kurbo;
use crate::widgets::{Label, VirtualScroll, VirtualScrollAction};

use super::opt_iter_difference;

#[test]
#[expect(
clippy::reversed_empty_ranges,
Expand Down
3 changes: 2 additions & 1 deletion masonry/tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ pub mod others {

#[cfg(test)]
mod tests {
use super::*;
use masonry::core::Widget;
use masonry::kurbo::Size;
use masonry::theme::default_property_set;
use masonry_testing::{TestHarness, TestHarnessParams};

use super::*;

// A series of tests to check that various widgets (the ones used in examples)
// can handle being laid out and painted with a size of zero.

Expand Down
1 change: 1 addition & 0 deletions masonry_core/src/core/widget_pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use std::any::TypeId;

use vello::kurbo::Affine;

use crate::core::{Properties, Widget, WidgetId, WidgetTag};
Expand Down
6 changes: 3 additions & 3 deletions masonry_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
#![expect(clippy::cast_possible_truncation, reason = "Deferred: Noisy")]
// TODO - Add logo

pub use anymore;
pub use vello::{kurbo, peniko, peniko::color::palette};
pub use {accesskit, dpi, parley, ui_events, vello};
pub use vello::peniko::color::palette;
pub use vello::{kurbo, peniko};
pub use {accesskit, anymore, dpi, parley, ui_events, vello};

// TODO - re-add #[doc(hidden)]
pub mod doc;
Expand Down
9 changes: 5 additions & 4 deletions masonry_core/src/passes/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use tracing::{info_span, trace};
use tree_arena::ArenaMut;
use vello::kurbo::{Point, Rect, Size};

use crate::app::RenderRootState;
use crate::app::{RenderRoot, RenderRootSignal, WindowSizePolicy};
use crate::core::{BoxConstraints, ChildrenIds, LayoutCtx, PropertiesMut, WidgetState};
use crate::core::{DefaultProperties, WidgetArenaNode};
use crate::app::{RenderRoot, RenderRootSignal, RenderRootState, WindowSizePolicy};
use crate::core::{
BoxConstraints, ChildrenIds, DefaultProperties, LayoutCtx, PropertiesMut, WidgetArenaNode,
WidgetState,
};
use crate::debug_panic;
use crate::passes::{enter_span_if, recurse_on_children};

Expand Down
8 changes: 4 additions & 4 deletions masonry_testing/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ use std::path::PathBuf;
use std::sync::{Arc, mpsc};

use image::{DynamicImage, ImageFormat, ImageReader, Rgba, RgbaImage};
use masonry_core::accesskit::{Action, ActionRequest, Node, Role, Tree, TreeUpdate};
use masonry_core::anymore::AnyDebug;
use masonry_core::core::keyboard::{Code, Key, KeyState, NamedKey};
use masonry_core::vello::peniko::Fill;
use oxipng::{Options, optimize_from_memory};
use tracing::debug;

use masonry_core::accesskit::{Action, ActionRequest, Node, Role, Tree, TreeUpdate};
use masonry_core::anymore::AnyDebug;
use masonry_core::app::{
RenderRoot, RenderRootOptions, RenderRootSignal, WindowSizePolicy, try_init_test_tracing,
};
use masonry_core::core::keyboard::{Code, Key, KeyState, NamedKey};
use masonry_core::core::{
CursorIcon, DefaultProperties, ErasedAction, FromDynWidget, Handled, Ime, KeyboardEvent,
Modifiers, NewWidget, PointerButton, PointerButtonEvent, PointerEvent, PointerId, PointerInfo,
Expand All @@ -32,6 +31,7 @@ use masonry_core::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, Physical
use masonry_core::kurbo::{Affine, Point, Rect, Size, Vec2};
use masonry_core::peniko::{Blob, Color};
use masonry_core::util::Duration;
use masonry_core::vello::peniko::Fill;
use masonry_core::vello::util::{RenderContext, block_on_wgpu};
use masonry_core::vello::wgpu::{
BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, MapMode,
Expand Down
3 changes: 1 addition & 2 deletions masonry_testing/src/modular_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

use std::any::TypeId;

use tracing::trace_span;

use masonry_core::accesskit::{Node, Role};
use masonry_core::core::{
AccessCtx, AccessEvent, BoxConstraints, ChildrenIds, ComposeCtx, CursorIcon, EventCtx,
Expand All @@ -14,6 +12,7 @@ use masonry_core::core::{
};
use masonry_core::kurbo::{Point, Size};
use masonry_core::vello::Scene;
use tracing::trace_span;

pub(crate) type PointerEventFn<S> =
dyn FnMut(&mut S, &mut EventCtx<'_>, &mut PropertiesMut<'_>, &PointerEvent);
Expand Down
5 changes: 3 additions & 2 deletions masonry_winit/src/event_loop_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use masonry_core::core::{
use masonry_core::kurbo::Affine;
use masonry_core::peniko::Color;
use masonry_core::util::Instant;
use masonry_core::vello::wgpu;
use masonry_core::vello::{AaConfig, AaSupport, RenderParams, Renderer, RendererOptions, Scene};
use masonry_core::vello::{
AaConfig, AaSupport, RenderParams, Renderer, RendererOptions, Scene, wgpu,
};
use tracing::{debug, info, info_span};
use ui_events_winit::{WindowEventReducer, WindowEventTranslation};
use winit::application::ApplicationHandler;
Expand Down
8 changes: 3 additions & 5 deletions masonry_winit/src/vello_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
//! This module is based on [`vello::util`](masonry_core::vello::util) module
//! with modifications for transparent surfaces.

use masonry_core::vello::{
Error,
wgpu::{self, MemoryBudgetThresholds, MemoryHints},
};
use masonry_core::vello::Error;
use masonry_core::vello::wgpu::{self, MemoryBudgetThresholds, MemoryHints};
use wgpu::util::{TextureBlitter, TextureBlitterBuilder};
use wgpu::{
BlendComponent, BlendFactor, BlendState, CompositeAlphaMode, Device, Instance, PresentMode,
Surface, SurfaceConfiguration, Texture, TextureFormat, TextureUsages, TextureView,
util::{TextureBlitter, TextureBlitterBuilder},
};

/// Simple render context that maintains wgpu state for rendering the pipeline.
Expand Down
3 changes: 1 addition & 2 deletions xilem/examples/external_event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
//! accessing raw events from winit.
//! Support for more custom embeddings would be welcome, but needs more design work

use masonry::properties::types::AsUnit;
use masonry::properties::types::{CrossAxisAlignment, MainAxisAlignment};
use masonry::properties::types::{AsUnit, CrossAxisAlignment, MainAxisAlignment};
use masonry::theme::default_property_set;
use masonry_winit::app::{AppDriver, MasonryUserEvent};
use winit::application::ApplicationHandler;
Expand Down
3 changes: 1 addition & 2 deletions xilem/examples/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

//! Flex properties can be set in Xilem.

use masonry::properties::types::AsUnit;
use masonry::properties::types::{CrossAxisAlignment, MainAxisAlignment};
use masonry::properties::types::{AsUnit, CrossAxisAlignment, MainAxisAlignment};
use winit::error::EventLoopError;
use xilem::view::{FlexExt as _, FlexSpacer, Label, button, flex_row, label, sized_box};
use xilem::{EventLoop, WidgetView, WindowOptions, Xilem};
Expand Down
6 changes: 2 additions & 4 deletions xilem/examples/slider_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

use masonry::core::Axis;
use masonry::peniko::Color;
use masonry::properties::{
Background, BarColor, ThumbColor, ThumbRadius,
types::{AsUnit, CrossAxisAlignment},
};
use masonry::properties::types::{AsUnit, CrossAxisAlignment};
use masonry::properties::{Background, BarColor, ThumbColor, ThumbRadius};
use winit::dpi::LogicalSize;
use winit::error::EventLoopError;
use xilem::style::Style;
Expand Down
4 changes: 3 additions & 1 deletion xilem/examples/transparent_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

use masonry::properties::types::AsUnit;
use winit::error::EventLoopError;
use xilem::{Color, EventLoop, WindowId, WindowView, Xilem, style::Style, view::*};
use xilem::style::Style;
use xilem::view::*;
use xilem::{Color, EventLoop, WindowId, WindowView, Xilem};

#[derive(Debug, Clone)]
struct AppState {
Expand Down
12 changes: 8 additions & 4 deletions xilem_core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@

//! Values accessible throughout the Xilem view tree.

use alloc::boxed::Box;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::any::TypeId;
use core::marker::PhantomData;

use anymore::AnyDebug;
use hashbrown::{HashMap, hash_map::Entry};
use hashbrown::HashMap;
use hashbrown::hash_map::Entry;

use crate::{
Arg, MessageCtx, MessageResult, Mut, View, ViewArgument, ViewId, ViewMarker, ViewPathTracker,
};

use alloc::{boxed::Box, sync::Arc, vec::Vec};
use core::{any::TypeId, marker::PhantomData};

#[derive(Debug)]
/// A message sent to Views to instruct them to rebuild themselves.
///
Expand Down
4 changes: 2 additions & 2 deletions xilem_core/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

//! Message routing and type erasure primitives.

use anymore::AnyDebug;

use alloc::boxed::Box;
use core::fmt::Debug;

use anymore::AnyDebug;

/// The possible outcomes from a [`View::message`]
///
/// [`View::message`]: crate::View::message
Expand Down
7 changes: 5 additions & 2 deletions xilem_core/src/message_context.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright 2025 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{DynMessage, Environment, ViewId};
use alloc::{boxed::Box, vec::Vec};
use alloc::boxed::Box;
use alloc::vec::Vec;

use anymore::AnyDebug;

use crate::{DynMessage, Environment, ViewId};

/// The `MessageCtx` is used in [`View::message`](crate::View::message).
///
/// It contains the full current "target" path for message routing, along with
Expand Down
4 changes: 2 additions & 2 deletions xilem_core/src/message_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use anymore::AnyDebug;

use alloc::boxed::Box;
use alloc::sync::Arc;
use core::fmt::{Debug, Display};
use core::marker::PhantomData;

use anymore::AnyDebug;

use crate::{SendMessage, ViewId};

/// A handle to a Xilem driver which can be used to queue a message for a View.
Expand Down
5 changes: 2 additions & 3 deletions xilem_masonry/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
//! Traits used to set custom styles on views.
use masonry::core::HasProperty;
use masonry::properties::{ContentColor, DisabledContentColor, FocusedBorderColor, LineBreaking};
use vello::peniko::Color;

pub use masonry::properties::types::{Gradient, GradientShape};
pub use masonry::properties::{
ActiveBackground, Background, BorderColor, BorderWidth, BoxShadow, CornerRadius,
DisabledBackground, HoveredBorderColor, Padding,
};
use masonry::properties::{ContentColor, DisabledContentColor, FocusedBorderColor, LineBreaking};
use vello::peniko::Color;

use crate::WidgetView;
use crate::core::ViewArgument;
Expand Down
Loading