Skip to content

Commit 2b509fb

Browse files
authored
Remove casts to f32 for text sizes (#741)
The main change is that text sizes in Masonry::theme are now `f32`. The rest of the changes are autofixed.
1 parent 5c61ac1 commit 2b509fb

File tree

11 files changed

+11
-12
lines changed

11 files changed

+11
-12
lines changed

masonry/src/text/text_layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,6 @@ impl std::fmt::Debug for TextLayout {
607607

608608
impl Default for TextLayout {
609609
fn default() -> Self {
610-
Self::new(crate::theme::TEXT_SIZE_NORMAL as f32)
610+
Self::new(crate::theme::TEXT_SIZE_NORMAL)
611611
}
612612
}

masonry/src/theme.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub const SELECTED_TEXT_BACKGROUND_COLOR: Color = Color::rgb8(0x43, 0x70, 0xA8);
3737
pub const SELECTED_TEXT_INACTIVE_BACKGROUND_COLOR: Color = Color::rgb8(0x74, 0x74, 0x74);
3838
pub const SELECTION_TEXT_COLOR: Color = Color::rgb8(0x00, 0x00, 0x00);
3939
pub const CURSOR_COLOR: Color = Color::WHITE;
40-
pub const TEXT_SIZE_NORMAL: f64 = 15.0;
41-
pub const TEXT_SIZE_LARGE: f64 = 24.0;
40+
pub const TEXT_SIZE_NORMAL: f32 = 15.0;
41+
pub const TEXT_SIZE_LARGE: f32 = 24.0;
4242
pub const BASIC_WIDGET_HEIGHT: f64 = 18.0;
4343
pub const WIDE_WIDGET_WIDTH: f64 = 100.;
4444
pub const BORDERED_WIDGET_HEIGHT: f64 = 24.0;

masonry/src/widget/label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Label {
5555
Self {
5656
text: text.into(),
5757
text_changed: false,
58-
text_layout: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL as f32),
58+
text_layout: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL),
5959
line_break_mode: LineBreaking::Overflow,
6060
show_disabled: true,
6161
brush: crate::theme::TEXT_COLOR.into(),

masonry/src/widget/progress_bar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ProgressBar {
4343
Self {
4444
progress: None,
4545
progress_changed: false,
46-
label: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL as f32),
46+
label: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL),
4747
}
4848
}
4949

masonry/src/widget/prose.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct Prose {
3939
impl Prose {
4040
pub fn new(text: impl Into<ArcStr>) -> Self {
4141
Prose {
42-
text_layout: TextWithSelection::new(text.into(), crate::theme::TEXT_SIZE_NORMAL as f32),
42+
text_layout: TextWithSelection::new(text.into(), crate::theme::TEXT_SIZE_NORMAL),
4343
line_break_mode: LineBreaking::WordWrap,
4444
show_disabled: true,
4545
brush: crate::theme::TEXT_COLOR.into(),

masonry/src/widget/textbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct Textbox {
5050
impl Textbox {
5151
pub fn new(initial_text: impl Into<String>) -> Self {
5252
Textbox {
53-
editor: TextEditor::new(initial_text.into(), crate::theme::TEXT_SIZE_NORMAL as f32),
53+
editor: TextEditor::new(initial_text.into(), crate::theme::TEXT_SIZE_NORMAL),
5454
line_break_mode: LineBreaking::WordWrap,
5555
show_disabled: true,
5656
brush: crate::theme::TEXT_COLOR.into(),

masonry/src/widget/variable_label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl VariableLabel {
150150
Self {
151151
text: text.into(),
152152
text_changed: false,
153-
text_layout: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL as f32),
153+
text_layout: TextLayout::new(crate::theme::TEXT_SIZE_NORMAL),
154154
line_break_mode: LineBreaking::Overflow,
155155
show_disabled: true,
156156
brush: crate::theme::TEXT_COLOR.into(),

xilem/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![expect(unused_qualifications, reason = "Deferred: Noisy")]
2323
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
2424
#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
25-
#![expect(clippy::cast_possible_truncation, reason = "Deferred: Noisy")]
2625
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
2726
#![expect(clippy::return_self_not_must_use, reason = "Deferred: Noisy")]
2827
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]

xilem/src/view/label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn label(label: impl Into<ArcStr>) -> Label {
1212
label: label.into(),
1313
text_brush: Color::WHITE.into(),
1414
alignment: TextAlignment::default(),
15-
text_size: masonry::theme::TEXT_SIZE_NORMAL as f32,
15+
text_size: masonry::theme::TEXT_SIZE_NORMAL,
1616
weight: TextWeight::NORMAL,
1717
}
1818
}

xilem/src/view/prose.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn prose(content: impl Into<ArcStr>) -> Prose {
1212
content: content.into(),
1313
text_brush: Color::WHITE.into(),
1414
alignment: TextAlignment::default(),
15-
text_size: masonry::theme::TEXT_SIZE_NORMAL as f32,
15+
text_size: masonry::theme::TEXT_SIZE_NORMAL,
1616
line_break_mode: LineBreaking::WordWrap,
1717
}
1818
}

0 commit comments

Comments
 (0)