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
2 changes: 1 addition & 1 deletion masonry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn make_widget_tree() -> NewWidget<impl Widget> {
let list = Flex::column()
.with_fixed(
NewWidget::new(Flex::row().with(text_input, 1.0).with_fixed(button))
.with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING.get()))),
.with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING))),
)
.with_fixed_spacer(WIDGET_SPACING);

Expand Down
6 changes: 3 additions & 3 deletions masonry/examples/calc_masonry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn build_calc() -> NewWidget<impl Widget> {
NewWidget::new(root_widget).with_props(
PropertySet::new()
.with(Background::Color(AlphaColor::from_str("#794869").unwrap()))
.with(Padding::all(2.0))
.with(Padding::all(2.px()))
.with(Gap::new(1.px())),
)
}
Expand All @@ -274,7 +274,7 @@ fn custom_property_set() -> DefaultProperties {
PropertySet::new()
.with(Background::Color(BLUE))
.with(BorderColor::new(Color::TRANSPARENT))
.with(BorderWidth::all(2.0)),
.with(BorderWidth::all(2.px())),
);
stack.push(
Selector::classes(&["op_button"]).with_active(true),
Expand All @@ -285,7 +285,7 @@ fn custom_property_set() -> DefaultProperties {
PropertySet::new()
.with(Background::Color(GRAY))
.with(BorderColor::new(Color::TRANSPARENT))
.with(BorderWidth::all(2.0)),
.with(BorderWidth::all(2.px())),
);
stack.push(
Selector::classes(&["digit_button"]).with_active(true),
Expand Down
14 changes: 7 additions & 7 deletions masonry/examples/gallery/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use masonry::core::{
ErasedAction, Handled, NewWidget, PropertySet, StyleProperty, Widget, WidgetId, WidgetTag,
};
use masonry::kurbo::Vec2;
use masonry::layout::Length;
use masonry::layout::{AsUnit, Length};
use masonry::parley::style::FontWeight;
use masonry::peniko::Color;
use masonry::properties::types::CrossAxisAlignment;
Expand Down Expand Up @@ -93,7 +93,7 @@ impl DemoPage for BadgeDemo {
let outline_badge = NewWidget::new(Badge::with_text("99+")).with_props(
PropertySet::new()
.with(Background::Color(Color::TRANSPARENT))
.with(BorderWidth { width: 1.0 })
.with(BorderWidth { width: 1.px() })
.with(BorderColor {
color: Color::from_rgb8(0x71, 0x71, 0x7a),
}),
Expand Down Expand Up @@ -155,8 +155,8 @@ impl DemoPage for BadgeDemo {
.with_props(
PropertySet::new()
.with(Background::Color(Color::from_rgb8(0x3f, 0x3f, 0x46)))
.with(CornerRadius { radius: 999.0 })
.with(Padding::all(0.0)),
.with(CornerRadius { radius: 999.px() })
.with(Padding::ZERO),
);

let online_dot = NewWidget::new(Badge::new(
Expand All @@ -166,9 +166,9 @@ impl DemoPage for BadgeDemo {
))
.with_props(
PropertySet::new()
.with(Padding::all(0.0))
.with(CornerRadius { radius: 999.0 })
.with(BorderWidth { width: 0.0 })
.with(Padding::ZERO)
.with(CornerRadius { radius: 999.px() })
.with(BorderWidth { width: 0.px() })
.with(Background::Color(Color::from_rgb8(0x22, 0xc5, 0x5e))),
);

Expand Down
4 changes: 2 additions & 2 deletions masonry/examples/gallery/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use masonry::core::{NewWidget, PropertySet, StyleProperty, Widget};
use masonry::layout::AsUnit as _;
use masonry::layout::AsUnit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's essentially fallout from a search-replace of me "fixing" some new Rust Analyzer imports. I prefer the more compact AsUnit as the name doesn't cause any conflicts being in scope. Both end up in the same result.

use masonry::peniko::{ImageAlphaType, ImageData, ImageFormat};
use masonry::properties::ObjectFit;
use masonry::properties::types::CrossAxisAlignment;
Expand Down Expand Up @@ -54,7 +54,7 @@ impl DemoPage for ImageDemo {
.prepare(),
)
.with_fixed_spacer(CONTENT_GAP)
.with_fixed(SizedBox::new(image).size(420.0.px(), 280.0.px()).prepare());
.with_fixed(SizedBox::new(image).size(420.px(), 280.px()).prepare());

wrap_in_shell(self.shell, NewWidget::new(body).erased())
}
Expand Down
6 changes: 3 additions & 3 deletions masonry/examples/gallery/kitchen_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use masonry::core::{NewWidget, PropertySet, StyleProperty, Widget};
use masonry::layout::{AsUnit as _, UnitPoint};
use masonry::layout::{AsUnit, UnitPoint};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

use masonry::peniko::Color;
use masonry::properties::types::CrossAxisAlignment;
use masonry::properties::{Background, Padding};
Expand Down Expand Up @@ -43,10 +43,10 @@ impl DemoPage for KitchenSinkDemo {
let grid = NewWidget::new(SizedBox::new(grid.prepare())).with_props(
PropertySet::new()
.with(Background::Color(Color::from_rgb8(0x24, 0x24, 0x24)))
.with(Padding::all(12.0)),
.with(Padding::all(12.px())),
);

let bg = NewWidget::new(SizedBox::empty().size(220.0.px(), 120.0.px())).with_props(
let bg = NewWidget::new(SizedBox::empty().size(220.px(), 120.px())).with_props(
PropertySet::one(Background::Color(Color::from_rgb8(0x44, 0x22, 0x66))),
);

Expand Down
13 changes: 7 additions & 6 deletions masonry/examples/gallery/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod transforms;

use masonry::core::{ErasedAction, NewWidget, StyleProperty, Widget as _, WidgetId, WidgetTag};
use masonry::dpi::LogicalSize;
use masonry::layout::Length;
use masonry::parley::style::FontWeight;
use masonry::properties::Padding;
use masonry::properties::types::CrossAxisAlignment;
Expand All @@ -45,11 +46,11 @@ use masonry_winit::winit::window::Window;
use crate::demo::{DemoPage, new_demo_shell_tags};
use crate::switch::SwitchDemo;

const SIDEBAR_WIDTH: masonry::layout::Length = masonry::layout::Length::const_px(240.0);
const SIDEBAR_SCROLLBAR_INSET: f64 = 12.0;
const LEFT_PANE_TOP_PADDING: f64 = 12.0;
const LEFT_PANE_LEFT_PADDING: f64 = 12.0;
const RIGHT_PANE_PADDING: f64 = 12.0;
const SIDEBAR_WIDTH: Length = Length::const_px(240.0);
const SIDEBAR_SCROLLBAR_INSET: Length = Length::const_px(12.0);
const LEFT_PANE_TOP_PADDING: Length = Length::const_px(12.0);
const LEFT_PANE_LEFT_PADDING: Length = Length::const_px(12.0);
const RIGHT_PANE_PADDING: Length = Length::const_px(12.0);

const DEMO_TITLE_FONT_SIZE: f32 = 20.0;

Expand Down Expand Up @@ -222,7 +223,7 @@ fn main() {
// scrollbar doesn't sit on top of the buttons.
let list = NewWidget::new(SizedBox::new(list.prepare())).with_props(Padding {
top: LEFT_PANE_TOP_PADDING,
bottom: 0.0,
bottom: Length::ZERO,
left: LEFT_PANE_LEFT_PADDING,
right: SIDEBAR_SCROLLBAR_INSET,
});
Expand Down
4 changes: 2 additions & 2 deletions masonry/examples/gallery/spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use masonry::core::{NewWidget, Widget};
use masonry::layout::AsUnit as _;
use masonry::layout::AsUnit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

use masonry::properties::types::CrossAxisAlignment;
use masonry::widgets::{Flex, SizedBox, Spinner};

Expand Down Expand Up @@ -32,7 +32,7 @@ impl DemoPage for SpinnerDemo {
.cross_axis_alignment(CrossAxisAlignment::Center)
.with_fixed(
SizedBox::new(Spinner::new().prepare())
.size(80.0.px(), 80.0.px())
.size(80.px(), 80.px())
.prepare(),
);

Expand Down
10 changes: 5 additions & 5 deletions masonry/examples/gallery/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use masonry::core::{NewWidget, PropertySet, StyleProperty, Widget};
use masonry::layout::AsUnit as _;
use masonry::layout::AsUnit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

use masonry::peniko::Color;
use masonry::properties::{Background, Padding};
use masonry::widgets::{Label, SizedBox, Split};
Expand Down Expand Up @@ -37,7 +37,7 @@ impl DemoPage for SplitDemo {
.with_props(
PropertySet::new()
.with(Background::Color(Color::from_rgb8(0x1f, 0x2a, 0x44)))
.with(Padding::all(12.0)),
.with(Padding::all(12.px())),
);

let right = NewWidget::new(SizedBox::new(
Expand All @@ -48,11 +48,11 @@ impl DemoPage for SplitDemo {
.with_props(
PropertySet::new()
.with(Background::Color(Color::from_rgb8(0x2b, 0x3c, 0x2f)))
.with(Padding::all(12.0)),
.with(Padding::all(12.px())),
);

let body = SizedBox::new(Split::new(left, right).split_fraction(0.33).prepare())
.height(260.0.px());
let body =
SizedBox::new(Split::new(left, right).split_fraction(0.33).prepare()).height(260.px());

wrap_in_shell(self.shell, NewWidget::new(body).erased())
}
Expand Down
2 changes: 1 addition & 1 deletion masonry/examples/gallery/step_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl DemoPage for StepInputDemo {

stack.push(
Selector::new(),
(BorderWidth::all(2.), CornerRadius::all(20.)),
(BorderWidth::all(2.px()), CornerRadius::all(20.px())),
);

stack.push(
Expand Down
6 changes: 3 additions & 3 deletions masonry/examples/gallery/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use masonry::core::{
ErasedAction, Handled, NewWidget, PropertySet, StyleProperty, Widget, WidgetId, WidgetTag,
};
use masonry::kurbo::{Affine, Vec2};
use masonry::layout::AsUnit as _;
use masonry::layout::AsUnit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

use masonry::peniko::Color;
use masonry::properties::types::CrossAxisAlignment;
use masonry::properties::{Background, Padding};
Expand Down Expand Up @@ -108,13 +108,13 @@ impl DemoPage for TransformsDemo {
.with_style(StyleProperty::FontSize(14.0))
.prepare(),
)
.size(160.0.px(), 160.0.px()),
.size(160.px(), 160.px()),
)
.with_tag(self.target)
.with_props(
PropertySet::new()
.with(Background::Color(Color::from_rgb8(0x35, 0x35, 0x35)))
.with(Padding::all(12.0)),
.with(Padding::all(12.px())),
);

let body = Flex::column()
Expand Down
4 changes: 2 additions & 2 deletions masonry/examples/grid_masonry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use masonry::core::{
ErasedAction, NewWidget, PointerButton, PropertySet, StyleProperty, Widget as _, WidgetId,
};
use masonry::dpi::LogicalSize;
use masonry::layout::Length;
use masonry::layout::{AsUnit, Length};
use masonry::peniko::Color;
use masonry::properties::{BorderColor, BorderWidth, Gap};
use masonry::theme::default_property_set;
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn make_grid(grid_gap: f64) -> NewWidget<Grid> {

let props = PropertySet::new()
.with(BorderColor::new(Color::from_rgb8(40, 40, 80)))
.with(BorderWidth::all(1.0));
.with(BorderWidth::all(1.px()));
let label = SizedBox::new(NewWidget::new(label).with_props(props));

let button_inputs = vec![
Expand Down
2 changes: 1 addition & 1 deletion masonry/examples/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn main() {
.with_props(PropertySet::one(ContentColor::new(Color::BLACK))),
))
.with_props(PropertySet::from((
BorderWidth::all(1.),
BorderWidth::all(1.px()),
BorderColor::new(Color::BLACK),
Background::Color(Color::WHITE),
)))
Expand Down
2 changes: 1 addition & 1 deletion masonry/examples/to_do_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn make_widget_tree() -> NewWidget<impl Widget> {
let root = Flex::column()
.with_fixed(
NewWidget::new(Flex::row().with(text_input, 1.0).with_fixed(button))
.with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING.get()))),
.with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING))),
)
.with_fixed_spacer(WIDGET_SPACING)
.with(portal, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
//! let list = Flex::column()
//! .with_fixed(
//! NewWidget::new(Flex::row().with(text_input, 1.0).with_fixed(button))
//! .with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING.get()))),
//! .with_props(PropertySet::new().with(Padding::all(WIDGET_SPACING))),
//! )
//! .with_fixed_spacer(WIDGET_SPACING);
//!
Expand Down
13 changes: 7 additions & 6 deletions masonry/src/properties/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
use std::any::TypeId;

use crate::core::{Property, UpdateCtx};
use crate::layout::Length;
use crate::peniko::Color;
use crate::theme;

/// The thickness of a slider's track, in logical pixels.
/// The thickness of a slider's track.
#[derive(Default, Clone, Copy, Debug, PartialEq)]
pub struct TrackThickness(pub f64);
pub struct TrackThickness(pub Length);

impl Property for TrackThickness {
fn static_default() -> &'static Self {
static DEFAULT: TrackThickness = TrackThickness(4.);
static DEFAULT: TrackThickness = TrackThickness(Length::const_px(4.));
&DEFAULT
}
}
Expand All @@ -27,13 +28,13 @@ impl TrackThickness {
}
}

/// The radius of a slider's thumb, in logical pixels.
/// The radius of a slider's thumb.
#[derive(Default, Clone, Copy, Debug, PartialEq)]
pub struct ThumbRadius(pub f64);
pub struct ThumbRadius(pub Length);

impl Property for ThumbRadius {
fn static_default() -> &'static Self {
static DEFAULT: ThumbRadius = ThumbRadius(6.);
static DEFAULT: ThumbRadius = ThumbRadius(Length::const_px(6.));
&DEFAULT
}
}
Expand Down
10 changes: 5 additions & 5 deletions masonry/src/tests/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ fn content_box() {
let props = (
Dimensions::fixed(100.px(), 100.px()),
Padding {
left: 1.,
right: 2.,
top: 3.,
bottom: 4.,
left: 1.px(),
right: 2.px(),
top: 3.px(),
bottom: 4.px(),
},
BorderWidth::all(1.),
BorderWidth::all(1.px()),
);

let hero = NewWidget::new(Button::with_text("Hero"))
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/tests/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn paint_transparency() {
GridParams::new(13, 0, 3, 1),
);

let props = (Padding::all(20.), Gap::new(10.px()));
let props = (Padding::all(20.px()), Gap::new(10.px()));
let grid_a = grid_a.prepare().with_props(props);
let grid_b = grid_b.prepare().with_props(props);

Expand Down
2 changes: 1 addition & 1 deletion masonry/src/tests/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::core::Widget as _;
use crate::layout::AsUnit as _;
use crate::layout::AsUnit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

use crate::palette::css::BLUE;
use crate::properties::{ContentColor, Dimensions, Gap};
use crate::widgets::Button;
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/tests/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn blue_box(inner: impl Widget) -> impl Widget {
let mut box_props = PropertySet::new();
box_props.insert(Background::Color(palette::css::BLUE));
box_props.insert(BorderColor::new(palette::css::TEAL));
box_props.insert(BorderWidth::all(2.0));
box_props.insert(BorderWidth::all(2.px()));

WrapperWidget::new(
SizedBox::new(inner.prepare())
Expand Down
Loading
Loading