From be6d23eed1bfd6851686b065e86527472a35b2fb Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 5 Dec 2022 12:59:02 +0100 Subject: [PATCH] Replace `Stroke::none()` with `Stroke::NONE` --- crates/egui/src/containers/panel.rs | 4 ++-- crates/egui/src/menu.rs | 6 +++--- crates/egui/src/widget_text.rs | 4 ++-- crates/egui/src/widgets/hyperlink.rs | 2 +- crates/egui/src/widgets/label.rs | 2 +- crates/egui/src/widgets/plot/items/mod.rs | 2 +- crates/egui/src/widgets/progress_bar.rs | 10 +++------- crates/egui_demo_app/src/apps/fractal_clock.rs | 2 +- .../src/easy_mark/easy_mark_highlighter.rs | 4 ++-- crates/egui_demo_lib/src/syntax_highlighting.rs | 2 +- crates/epaint/src/shape.rs | 2 +- crates/epaint/src/stroke.rs | 6 ++++++ crates/epaint/src/tessellator.rs | 2 +- crates/epaint/src/text/text_layout.rs | 6 +++--- crates/epaint/src/text/text_layout_types.rs | 4 ++-- 15 files changed, 30 insertions(+), 28 deletions(-) diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index 206a4bbf..bdea5e5e 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -303,7 +303,7 @@ impl SidePanel { // TOOD(emilk): distinguish resizable from non-resizable ui.style().visuals.widgets.noninteractive.bg_stroke } else { - Stroke::none() + Stroke::NONE }; // TODO(emilk): draw line on top of all panels in this ui when https://github.com/emilk/egui/issues/1516 is done let resize_x = side.opposite().side_x(rect); @@ -752,7 +752,7 @@ impl TopBottomPanel { // TOOD(emilk): distinguish resizable from non-resizable ui.style().visuals.widgets.noninteractive.bg_stroke } else { - Stroke::none() + Stroke::NONE }; // TODO(emilk): draw line on top of all panels in this ui when https://github.com/emilk/egui/issues/1516 is done let resize_y = side.opposite().side_y(rect); diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index db32d14c..59c15348 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -66,10 +66,10 @@ impl std::ops::DerefMut for BarState { fn set_menu_style(style: &mut Style) { style.spacing.button_padding = vec2(2.0, 0.0); - style.visuals.widgets.active.bg_stroke = Stroke::none(); - style.visuals.widgets.hovered.bg_stroke = Stroke::none(); + style.visuals.widgets.active.bg_stroke = Stroke::NONE; + style.visuals.widgets.hovered.bg_stroke = Stroke::NONE; style.visuals.widgets.inactive.bg_fill = Color32::TRANSPARENT; - style.visuals.widgets.inactive.bg_stroke = Stroke::none(); + style.visuals.widgets.inactive.bg_stroke = Stroke::NONE; } /// The menu bar goes well in a [`TopBottomPanel::top`], diff --git a/crates/egui/src/widget_text.rs b/crates/egui/src/widget_text.rs index df535684..95b59acb 100644 --- a/crates/egui/src/widget_text.rs +++ b/crates/egui/src/widget_text.rs @@ -293,12 +293,12 @@ impl RichText { let underline = if underline { crate::Stroke::new(1.0, line_color) } else { - crate::Stroke::none() + crate::Stroke::NONE }; let strikethrough = if strikethrough { crate::Stroke::new(1.0, line_color) } else { - crate::Stroke::none() + crate::Stroke::NONE }; let valign = if raised { diff --git a/crates/egui/src/widgets/hyperlink.rs b/crates/egui/src/widgets/hyperlink.rs index 47994451..2776ce8b 100644 --- a/crates/egui/src/widgets/hyperlink.rs +++ b/crates/egui/src/widgets/hyperlink.rs @@ -48,7 +48,7 @@ impl Widget for Link { let underline = if response.hovered() || response.has_focus() { Stroke::new(visuals.fg_stroke.width, color) } else { - Stroke::none() + Stroke::NONE }; ui.painter().add(epaint::TextShape { diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 4eb06758..4e52126c 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -176,7 +176,7 @@ impl Widget for Label { let underline = if response.has_focus() { Stroke::new(1.0, response_color) } else { - Stroke::none() + Stroke::NONE }; let override_text_color = if text_galley.galley_has_color { diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index 3be7e9f1..f869032a 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -605,7 +605,7 @@ impl PlotItem for Polygon { let fill = Rgba::from(stroke.color).to_opaque().multiply(fill_alpha); - let shape = Shape::convex_polygon(values_tf.clone(), fill, Stroke::none()); + let shape = Shape::convex_polygon(values_tf.clone(), fill, Stroke::NONE); shapes.push(shape); values_tf.push(*values_tf.first().unwrap()); style.style_line(values_tf, *stroke, *highlight, shapes); diff --git a/crates/egui/src/widgets/progress_bar.rs b/crates/egui/src/widgets/progress_bar.rs index 417dafb0..7a10dd40 100644 --- a/crates/egui/src/widgets/progress_bar.rs +++ b/crates/egui/src/widgets/progress_bar.rs @@ -78,12 +78,8 @@ impl Widget for ProgressBar { let visuals = ui.style().visuals.clone(); let rounding = outer_rect.height() / 2.0; - ui.painter().rect( - outer_rect, - rounding, - visuals.extreme_bg_color, - Stroke::none(), - ); + ui.painter() + .rect(outer_rect, rounding, visuals.extreme_bg_color, Stroke::NONE); let inner_rect = Rect::from_min_size( outer_rect.min, vec2( @@ -103,7 +99,7 @@ impl Widget for ProgressBar { inner_rect, rounding, Color32::from(Rgba::from(visuals.selection.bg_fill) * color_factor as f32), - Stroke::none(), + Stroke::NONE, ); if animate { diff --git a/crates/egui_demo_app/src/apps/fractal_clock.rs b/crates/egui_demo_app/src/apps/fractal_clock.rs index fc2af9a2..d1279e7a 100644 --- a/crates/egui_demo_app/src/apps/fractal_clock.rs +++ b/crates/egui_demo_app/src/apps/fractal_clock.rs @@ -49,7 +49,7 @@ impl FractalClock { ui.expand_to_include_rect(painter.clip_rect()); Frame::popup(ui.style()) - .stroke(Stroke::none()) + .stroke(Stroke::NONE) .show(ui, |ui| { ui.set_max_width(270.0); CollapsingHeader::new("Settings") diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs index e946750c..c15a285b 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs @@ -165,13 +165,13 @@ fn format_from_style( let underline = if emark_style.underline { Stroke::new(1.0, color) } else { - Stroke::none() + Stroke::NONE }; let strikethrough = if emark_style.strikethrough { Stroke::new(1.0, color) } else { - Stroke::none() + Stroke::NONE }; let valign = if emark_style.raised { diff --git a/crates/egui_demo_lib/src/syntax_highlighting.rs b/crates/egui_demo_lib/src/syntax_highlighting.rs index 550e5c98..e308c462 100644 --- a/crates/egui_demo_lib/src/syntax_highlighting.rs +++ b/crates/egui_demo_lib/src/syntax_highlighting.rs @@ -358,7 +358,7 @@ impl Highlighter { let underline = if underline { egui::Stroke::new(1.0, text_color) } else { - egui::Stroke::none() + egui::Stroke::NONE }; job.sections.push(LayoutSection { leading_space: 0.0, diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index a12788c5..3771296d 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -648,7 +648,7 @@ impl TextShape { Self { pos, galley, - underline: Stroke::none(), + underline: Stroke::NONE, override_text_color: None, angle: 0.0, } diff --git a/crates/epaint/src/stroke.rs b/crates/epaint/src/stroke.rs index 04a1efb9..acfa4ef1 100644 --- a/crates/epaint/src/stroke.rs +++ b/crates/epaint/src/stroke.rs @@ -14,6 +14,12 @@ pub struct Stroke { impl Stroke { /// Same as [`Stroke::default`]. + pub const NONE: Stroke = Stroke { + width: 0.0, + color: Color32::TRANSPARENT, + }; + + #[deprecated = "Use Stroke::NONE instead"] #[inline(always)] pub fn none() -> Self { Self::new(0.0, Color32::TRANSPARENT) diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index e6182ee6..a15a8c79 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -1412,7 +1412,7 @@ impl Tessellator { }), ); - if *underline != Stroke::none() { + if *underline != Stroke::NONE { self.scratchpad_path.clear(); self.scratchpad_path .add_line_segment([row_rect.left_bottom(), row_rect.right_bottom()]); diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index e436db97..bbf677d1 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -493,8 +493,8 @@ fn format_summary(job: &LayoutJob) -> FormatSummary { let mut format_summary = FormatSummary::default(); for section in &job.sections { format_summary.any_background |= section.format.background != Color32::TRANSPARENT; - format_summary.any_underline |= section.format.underline != Stroke::none(); - format_summary.any_strikethrough |= section.format.strikethrough != Stroke::none(); + format_summary.any_underline |= section.format.underline != Stroke::NONE; + format_summary.any_strikethrough |= section.format.strikethrough != Stroke::NONE; } format_summary } @@ -665,7 +665,7 @@ fn add_row_hline( for glyph in &row.glyphs { let (stroke, y) = stroke_and_y(glyph); - if stroke == Stroke::none() { + if stroke == Stroke::NONE { end_line(line_start.take(), last_right_x); } else if let Some((existing_stroke, start)) = line_start { if existing_stroke == stroke && start.y == y { diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index 14ed82f3..99a1da05 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -238,8 +238,8 @@ impl Default for TextFormat { color: Color32::GRAY, background: Color32::TRANSPARENT, italics: false, - underline: Stroke::none(), - strikethrough: Stroke::none(), + underline: Stroke::NONE, + strikethrough: Stroke::NONE, valign: Align::BOTTOM, } }