From 96153a86e5dbfcde8047e0d91759a70f317b9893 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 31 Aug 2020 22:56:24 +0200 Subject: [PATCH] [refactor] Remove Option wrappers around colors and line styles Just use transparency instead of None --- egui/src/containers/collapsing_header.rs | 8 +++--- egui/src/containers/frame.rs | 22 +++++++-------- egui/src/containers/resize.rs | 4 +-- egui/src/containers/scroll_area.rs | 6 ++-- egui/src/containers/window.rs | 7 ++--- egui/src/demos/app.rs | 8 +++--- egui/src/demos/fractal_clock.rs | 6 ++-- egui/src/demos/toggle_switch.rs | 6 ++-- egui/src/lib.rs | 2 +- egui/src/menu.rs | 26 +++++++++--------- egui/src/paint/command.rs | 18 +++++++----- egui/src/paint/tessellator.rs | 35 ++++++++++-------------- egui/src/painter.rs | 20 +++++++------- egui/src/style.rs | 26 +++++++++--------- egui/src/widgets.rs | 18 +++++------- egui/src/widgets/slider.rs | 10 +++---- egui/src/widgets/text_edit.rs | 2 +- 17 files changed, 108 insertions(+), 116 deletions(-) diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index 1a98dbc3..599f1440 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -123,8 +123,8 @@ pub fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) { ui.painter().add(PaintCmd::Path { path: Path::from_point_loop(&points), closed: true, - fill: None, - outline: Some(LineStyle::new(stroke_width, stroke_color)), + fill: Default::default(), + outline: LineStyle::new(stroke_width, stroke_color), }); } @@ -229,10 +229,10 @@ impl CollapsingHeader { painter.set( bg_index, PaintCmd::Rect { + rect: response.rect, corner_radius: ui.style().interact(&response).corner_radius, fill: ui.style().interact(&response).bg_fill, - outline: None, - rect: response.rect, + outline: Default::default(), }, ); diff --git a/egui/src/containers/frame.rs b/egui/src/containers/frame.rs index 41567fa0..f7b7c6d4 100644 --- a/egui/src/containers/frame.rs +++ b/egui/src/containers/frame.rs @@ -8,8 +8,8 @@ pub struct Frame { // On each side pub margin: Vec2, pub corner_radius: f32, - pub fill: Option, - pub outline: Option, + pub fill: Srgba, + pub outline: LineStyle, } impl Frame { @@ -17,7 +17,7 @@ impl Frame { Self { margin: style.spacing.window_padding, corner_radius: style.visuals.window_corner_radius, - fill: Some(style.visuals.background_fill), + fill: style.visuals.background_fill, outline: style.visuals.interacted.inactive.bg_outline, // because we can resize windows } } @@ -26,8 +26,8 @@ impl Frame { Self { margin: Vec2::splat(1.0), corner_radius: 0.0, - fill: None, - outline: Some(LineStyle::new(0.5, Srgba::gray(128))), + fill: Default::default(), + outline: LineStyle::new(0.5, Srgba::gray(128)), } } @@ -35,8 +35,8 @@ impl Frame { Self { margin: Vec2::splat(1.0), corner_radius: 2.0, - fill: Some(style.visuals.background_fill), - outline: Some(LineStyle::new(1.0, Srgba::gray(128))), + fill: style.visuals.background_fill, + outline: LineStyle::new(1.0, Srgba::gray(128)), } } @@ -44,17 +44,17 @@ impl Frame { Self { margin: style.spacing.window_padding, corner_radius: 5.0, - fill: Some(style.visuals.background_fill), - outline: Some(LineStyle::new(1.0, Srgba::gray(128))), + fill: style.visuals.background_fill, + outline: LineStyle::new(1.0, Srgba::gray(128)), } } - pub fn fill(mut self, fill: Option) -> Self { + pub fn fill(mut self, fill: Srgba) -> Self { self.fill = fill; self } - pub fn outline(mut self, outline: Option) -> Self { + pub fn outline(mut self, outline: LineStyle) -> Self { self.outline = outline; self } diff --git a/egui/src/containers/resize.rs b/egui/src/containers/resize.rs index cd90f80d..f0fdd227 100644 --- a/egui/src/containers/resize.rs +++ b/egui/src/containers/resize.rs @@ -237,8 +237,8 @@ impl Resize { ui.painter().add(paint::PaintCmd::Rect { rect, corner_radius: 3.0, - fill: None, - outline: Some(ui.style().visuals.thin_outline), + fill: Default::default(), + outline: ui.style().visuals.thin_outline, }); } diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index b7f34a5a..5467af9e 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -243,14 +243,14 @@ impl Prepared { ui.painter().add(paint::PaintCmd::Rect { rect: outer_scroll_rect, corner_radius, - fill: Some(ui.style().visuals.dark_bg_color), - outline: None, + fill: ui.style().visuals.dark_bg_color, + outline: Default::default(), }); ui.painter().add(paint::PaintCmd::Rect { rect: handle_rect.expand(-2.0), corner_radius, - fill: Some(handle_fill), + fill: handle_fill, outline: handle_outline, }); } diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 4eaa91d2..9b232d64 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -311,12 +311,11 @@ impl<'open> Window<'open> { } } -fn paint_resize_corner(ui: &mut Ui, outer_rect: Rect, frame_outline: Option) { +fn paint_resize_corner(ui: &mut Ui, outer_rect: Rect, outline: LineStyle) { let corner_size = Vec2::splat(ui.style().visuals.resize_corner_size); let handle_offset = -Vec2::splat(2.0); let corner_rect = Rect::from_min_size(outer_rect.max - corner_size + handle_offset, corner_size); - let outline = frame_outline.unwrap_or_else(|| LineStyle::new(1.0, color::GRAY)); crate::resize::paint_resize_corner_with_style(ui, &corner_rect, outline); } @@ -566,7 +565,7 @@ fn paint_frame_interaction( ui.painter().add(PaintCmd::Path { path, closed: false, - fill: None, + fill: Default::default(), outline: visuals.bg_outline, }); } @@ -671,7 +670,7 @@ impl TitleBar { let y = content_rect.top() + ui.style().spacing.item_spacing.y * 0.5; ui.painter().line_segment( [pos2(left, y), pos2(right, y)], - ui.style().visuals.interacted.inactive.bg_outline.unwrap(), + ui.style().visuals.interacted.inactive.bg_outline, ); } diff --git a/egui/src/demos/app.rs b/egui/src/demos/app.rs index 78c06dbb..7fc7e612 100644 --- a/egui/src/demos/app.rs +++ b/egui/src/demos/app.rs @@ -579,12 +579,12 @@ impl BoxPainting { for i in 0..self.num_boxes { cmds.push(PaintCmd::Rect { corner_radius: self.corner_radius, - fill: Some(Srgba::gray(64)), + fill: Srgba::gray(64), rect: Rect::from_min_size( pos2(10.0 + pos.x + (i as f32) * (self.size.x * 1.1), pos.y), self.size, ), - outline: Some(LineStyle::new(self.stroke_width, WHITE)), + outline: LineStyle::new(self.stroke_width, WHITE), }); } ui.painter().extend(cmds); @@ -655,8 +655,8 @@ impl Painting { painter.add(PaintCmd::Path { path: Path::from_open_points(&points), closed: false, - outline: Some(LineStyle::new(self.line_width, LIGHT_GRAY)), - fill: None, + outline: LineStyle::new(self.line_width, LIGHT_GRAY), + fill: Default::default(), }); } } diff --git a/egui/src/demos/fractal_clock.rs b/egui/src/demos/fractal_clock.rs index 37178c50..566ad9dc 100644 --- a/egui/src/demos/fractal_clock.rs +++ b/egui/src/demos/fractal_clock.rs @@ -37,7 +37,7 @@ impl FractalClock { .default_rect(ctx.rect().expand(-42.0)) .scroll(false) // Dark background frame to make it pop: - .frame(Frame::window(&ctx.style()).fill(Some(Srgba::black_alpha(250)))) + .frame(Frame::window(&ctx.style()).fill(Srgba::black_alpha(250))) .show(ctx, |ui| self.ui(ui)); } @@ -54,8 +54,8 @@ impl FractalClock { self.fractal_ui(&painter); Frame::popup(ui.style()) - .fill(Some(Rgba::luminance_alpha(0.02, 0.5).into())) - .outline(None) + .fill(Rgba::luminance_alpha(0.02, 0.5).into()) + .outline(LineStyle::none()) .show(&mut ui.left_column(320.0), |ui| { CollapsingHeader::new("Settings").show(ui, |ui| self.options_ui(ui)); }); diff --git a/egui/src/demos/toggle_switch.rs b/egui/src/demos/toggle_switch.rs index 65b0fc47..5c51029b 100644 --- a/egui/src/demos/toggle_switch.rs +++ b/egui/src/demos/toggle_switch.rs @@ -36,16 +36,16 @@ pub fn toggle(ui: &mut Ui, on: &mut bool) -> Response { ui.painter().add(PaintCmd::Rect { rect, corner_radius: radius, + fill: lerp(off_color..=on_color, how_on).into(), outline: style.bg_outline, - fill: Some(lerp(off_color..=on_color, how_on).into()), }); // Animate the circle from left to right: let circle_x = lerp((rect.left() + radius)..=(rect.right() - radius), how_on); ui.painter().add(PaintCmd::Circle { center: pos2(circle_x, rect.center().y), radius: 0.75 * radius, - outline: Some(style.line_style()), - fill: Some(style.main_fill), + fill: style.main_fill, + outline: style.line_style(), }); // All done! Return the response so the user can check what happened diff --git a/egui/src/lib.rs b/egui/src/lib.rs index 364cd113..459fa814 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -74,7 +74,7 @@ pub use { layout::*, math::*, memory::Memory, - paint::{color, PaintJobs, Rgba, Srgba, TextStyle, Texture}, + paint::{color, LineStyle, PaintJobs, Rgba, Srgba, TextStyle, Texture}, painter::Painter, style::Style, types::*, diff --git a/egui/src/menu.rs b/egui/src/menu.rs index 96b4ad54..afd60c82 100644 --- a/egui/src/menu.rs +++ b/egui/src/menu.rs @@ -15,7 +15,7 @@ //! } //! ``` -use crate::{widgets::*, *}; +use crate::{color::TRANSPARENT, paint::LineStyle, widgets::*, *}; /// What is saved between frames. #[derive(Clone, Copy, Debug)] @@ -62,12 +62,12 @@ pub fn bar(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Rect) Frame::menu_bar(ui.style()).show(ui, |ui| { let mut style = ui.style().clone(); style.spacing.button_padding = vec2(2.0, 0.0); - // style.visuals.interacted.active.bg_fill = None; - style.visuals.interacted.active.bg_outline = None; - // style.visuals.interacted.hovered.bg_fill = None; - style.visuals.interacted.hovered.bg_outline = None; - style.visuals.interacted.inactive.bg_fill = None; - style.visuals.interacted.inactive.bg_outline = None; + // style.visuals.interacted.active.bg_fill = TRANSPARENT; + style.visuals.interacted.active.bg_outline = LineStyle::none(); + // style.visuals.interacted.hovered.bg_fill = TRANSPARENT; + style.visuals.interacted.hovered.bg_outline = LineStyle::none(); + style.visuals.interacted.inactive.bg_fill = TRANSPARENT; + style.visuals.interacted.inactive.bg_outline = LineStyle::none(); ui.set_style(style); // Take full width and fixed height: @@ -128,12 +128,12 @@ fn menu_impl<'c>( resize.show(ui, |ui| { let mut style = ui.style().clone(); style.spacing.button_padding = vec2(2.0, 0.0); - // style.visuals.interacted.active.bg_fill = None; - style.visuals.interacted.active.bg_outline = None; - // style.visuals.interacted.hovered.bg_fill = None; - style.visuals.interacted.hovered.bg_outline = None; - style.visuals.interacted.inactive.bg_fill = None; - style.visuals.interacted.inactive.bg_outline = None; + // style.visuals.interacted.active.bg_fill = TRANSPARENT; + style.visuals.interacted.active.bg_outline = LineStyle::none(); + // style.visuals.interacted.hovered.bg_fill = TRANSPARENT; + style.visuals.interacted.hovered.bg_outline = LineStyle::none(); + style.visuals.interacted.inactive.bg_fill = TRANSPARENT; + style.visuals.interacted.inactive.bg_outline = LineStyle::none(); ui.set_style(style); ui.set_layout(Layout::justified(Direction::Vertical)); add_contents(ui) diff --git a/egui/src/paint/command.rs b/egui/src/paint/command.rs index 27cf2983..1af01e4f 100644 --- a/egui/src/paint/command.rs +++ b/egui/src/paint/command.rs @@ -11,8 +11,8 @@ pub enum PaintCmd { Circle { center: Pos2, radius: f32, - fill: Option, - outline: Option, + fill: Srgba, + outline: LineStyle, }, LineSegment { points: [Pos2; 2], @@ -21,14 +21,14 @@ pub enum PaintCmd { Path { path: Path, closed: bool, - fill: Option, - outline: Option, + fill: Srgba, + outline: LineStyle, }, Rect { rect: Rect, corner_radius: f32, - fill: Option, - outline: Option, + fill: Srgba, + outline: LineStyle, }, Text { /// Top left corner of the first character. @@ -41,7 +41,7 @@ pub enum PaintCmd { Triangles(Triangles), } -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct LineStyle { pub width: f32, @@ -49,6 +49,10 @@ pub struct LineStyle { } impl LineStyle { + pub fn none() -> Self { + Self::new(0.0, crate::color::TRANSPARENT) + } + pub fn new(width: impl Into, color: impl Into) -> Self { Self { width: width.into(), diff --git a/egui/src/paint/tessellator.rs b/egui/src/paint/tessellator.rs index 7a856fbe..1f8d05b6 100644 --- a/egui/src/paint/tessellator.rs +++ b/egui/src/paint/tessellator.rs @@ -7,7 +7,7 @@ use { super::{ - color::{self, srgba, Rgba, Srgba}, + color::{self, srgba, Rgba, Srgba, TRANSPARENT}, fonts::Fonts, LineStyle, PaintCmd, }, @@ -427,7 +427,7 @@ pub fn paint_path_outline( options: PaintOptions, out: &mut Triangles, ) { - if style.color == color::TRANSPARENT { + if style.width <= 0.0 || style.color == color::TRANSPARENT { return; } @@ -604,12 +604,8 @@ pub fn tessellate_paint_command( } => { if radius > 0.0 { path.add_circle(center, radius); - if let Some(fill) = fill { - fill_closed_path(&path.0, fill, options, out); - } - if let Some(line_style) = outline { - paint_path_outline(&path.0, Closed, line_style, options, out); - } + fill_closed_path(&path.0, fill, options, out); + paint_path_outline(&path.0, Closed, outline, options, out); } } PaintCmd::Triangles(triangles) => { @@ -626,17 +622,15 @@ pub fn tessellate_paint_command( outline, } => { if path.len() >= 2 { - if let Some(fill) = fill { + if fill != TRANSPARENT { debug_assert!( closed, "You asked to fill a path that is not closed. That makes no sense." ); fill_closed_path(&path.0, fill, options, out); } - if let Some(line_style) = outline { - let typ = if closed { Closed } else { Open }; - paint_path_outline(&path.0, typ, line_style, options, out); - } + let typ = if closed { Closed } else { Open }; + paint_path_outline(&path.0, typ, outline, options, out); } } PaintCmd::Rect { @@ -652,12 +646,8 @@ pub fn tessellate_paint_command( rect.max = rect.max.min(pos2(1e7, 1e7)); path.add_rounded_rectangle(rect, corner_radius); - if let Some(fill) = fill { - fill_closed_path(&path.0, fill, options, out); - } - if let Some(line_style) = outline { - paint_path_outline(&path.0, Closed, line_style, options, out); - } + fill_closed_path(&path.0, fill, options, out); + paint_path_outline(&path.0, Closed, outline, options, out); } } PaintCmd::Text { @@ -666,6 +656,9 @@ pub fn tessellate_paint_command( text_style, color, } => { + if color == TRANSPARENT { + return; + } galley.sanity_check(); let num_chars = galley.text.chars().count(); @@ -737,8 +730,8 @@ pub fn tessellate_paint_commands( PaintCmd::Rect { rect: *clip_rect, corner_radius: 0.0, - fill: None, - outline: Some(LineStyle::new(2.0, srgba(150, 255, 150, 255))), + fill: Default::default(), + outline: LineStyle::new(2.0, srgba(150, 255, 150, 255)), }, options, fonts, diff --git a/egui/src/painter.rs b/egui/src/painter.rs index b8283146..a6aed48f 100644 --- a/egui/src/painter.rs +++ b/egui/src/painter.rs @@ -131,8 +131,8 @@ impl Painter { self.add(PaintCmd::Rect { rect: rect.expand(2.0), corner_radius: 0.0, - fill: Some(Srgba::black_alpha(240)), - outline: Some(LineStyle::new(1.0, color::RED)), + fill: Srgba::black_alpha(240), + outline: LineStyle::new(1.0, color::RED), }); self.galley(rect.min, galley, text_style, color::RED); } @@ -151,8 +151,8 @@ impl Painter { self.add(PaintCmd::Circle { center, radius, - fill: Some(fill_color.into()), - outline: None, + fill: fill_color.into(), + outline: Default::default(), }); } @@ -160,8 +160,8 @@ impl Painter { self.add(PaintCmd::Circle { center, radius, - fill: None, - outline: Some(outline.into()), + fill: Default::default(), + outline: outline.into(), }); } @@ -169,8 +169,8 @@ impl Painter { self.add(PaintCmd::Rect { rect, corner_radius, - fill: Some(fill_color.into()), - outline: None, + fill: fill_color.into(), + outline: Default::default(), }); } @@ -178,8 +178,8 @@ impl Painter { self.add(PaintCmd::Rect { rect, corner_radius, - fill: None, - outline: Some(outline.into()), + fill: Default::default(), + outline: outline.into(), }); } } diff --git a/egui/src/style.rs b/egui/src/style.rs index b1af7f28..bf2889a0 100644 --- a/egui/src/style.rs +++ b/egui/src/style.rs @@ -139,11 +139,11 @@ impl Interacted { #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct WidgetVisuals { /// Background color of widget - pub bg_fill: Option, + pub bg_fill: Srgba, /// For surrounding rectangle of things that need it, /// like buttons, the box of the checkbox, etc. - pub bg_outline: Option, + pub bg_outline: LineStyle, /// Button frames etc pub corner_radius: f32, @@ -226,32 +226,32 @@ impl Default for Interacted { fn default() -> Self { Self { active: WidgetVisuals { - bg_fill: Some(Srgba::black_alpha(128)), - bg_outline: Some(LineStyle::new(2.0, WHITE)), + bg_fill: Srgba::black_alpha(128), + bg_outline: LineStyle::new(2.0, WHITE), corner_radius: 0.0, main_fill: srgba(120, 120, 200, 255), stroke_color: WHITE, stroke_width: 2.0, }, hovered: WidgetVisuals { - bg_fill: None, - bg_outline: Some(LineStyle::new(1.0, WHITE)), + bg_fill: TRANSPARENT, + bg_outline: LineStyle::new(1.0, WHITE), corner_radius: 2.0, main_fill: srgba(100, 100, 150, 255), stroke_color: Srgba::gray(240), stroke_width: 1.5, }, inactive: WidgetVisuals { - bg_fill: None, - bg_outline: Some(LineStyle::new(1.0, Srgba::gray(128))), + bg_fill: TRANSPARENT, + bg_outline: LineStyle::new(1.0, Srgba::gray(128)), corner_radius: 4.0, main_fill: srgba(60, 60, 80, 255), stroke_color: Srgba::gray(200), // Mustn't look grayed out! stroke_width: 1.0, }, disabled: WidgetVisuals { - bg_fill: None, - bg_outline: Some(LineStyle::new(0.5, Srgba::gray(128))), + bg_fill: TRANSPARENT, + bg_outline: LineStyle::new(0.5, Srgba::gray(128)), corner_radius: 4.0, main_fill: srgba(50, 50, 50, 255), stroke_color: Srgba::gray(128), // Should look grayed out @@ -361,8 +361,8 @@ impl WidgetVisuals { stroke_width, } = self; - let _ = bg_fill; // ui_color(ui, bg_fill, "bg_fill"); // TODO - let _ = bg_outline; // bg_outline.ui(ui, "bg_outline");// TODO + ui_color(ui, bg_fill, "bg_fill"); + bg_outline.ui(ui, "bg_outline"); ui.add(Slider::f32(corner_radius, 0.0..=10.0).text("corner_radius")); ui_color(ui, main_fill, "main_fill"); ui_color(ui, stroke_color, "stroke_color"); @@ -417,7 +417,7 @@ impl LineStyle { let Self { width, color } = self; ui.horizontal_centered(|ui| { ui.label(format!("{}: ", text)); - ui.add(Slider::f32(width, 0.0..=10.0)); + ui.add(Slider::f32(width, 0.0..=10.0).text("width")); ui_color(ui, color, "color"); }); } diff --git a/egui/src/widgets.rs b/egui/src/widgets.rs index 9d9213c3..123f219f 100644 --- a/egui/src/widgets.rs +++ b/egui/src/widgets.rs @@ -233,7 +233,7 @@ impl Button { text: text.into(), text_color: None, text_style: TextStyle::Button, - fill: None, + fill: Default::default(), sense: Sense::click(), } } @@ -289,11 +289,11 @@ impl Widget for Button { let rect = ui.allocate_space(size); let response = ui.interact(rect, id, sense); let text_cursor = response.rect.left_center() + vec2(padding.x, -0.5 * galley.size.y); - let bg_fill = fill.or(ui.style().interact(&response).bg_fill); + let fill = fill.unwrap_or(ui.style().interact(&response).bg_fill); ui.painter().add(PaintCmd::Rect { rect: response.rect, corner_radius: ui.style().interact(&response).corner_radius, - fill: bg_fill, + fill, outline: ui.style().interact(&response).bg_outline, }); let stroke_color = ui.style().interact(&response).stroke_color; @@ -372,8 +372,8 @@ impl<'a> Widget for Checkbox<'a> { pos2(small_icon_rect.right(), small_icon_rect.top()), ]), closed: false, - outline: Some(LineStyle::new(ui.style().visuals.line_width, stroke_color)), - fill: None, + outline: LineStyle::new(ui.style().visuals.line_width, stroke_color), + fill: Default::default(), }); } @@ -448,8 +448,8 @@ impl Widget for RadioButton { painter.add(PaintCmd::Circle { center: small_icon_rect.center(), radius: small_icon_rect.width() / 3.0, - fill: Some(stroke_color), - outline: None, + fill: stroke_color, + outline: Default::default(), }); } @@ -515,10 +515,6 @@ impl Widget for Separator { let available_space = ui.available_finite().size(); - // TODO: only allocate `spacing`, but not our full width/height - // as that would make the false impression that we *need* all that space, - // which would prevent regions from auto-shrinking - let (points, rect) = match ui.layout().dir() { Direction::Horizontal => { let rect = ui.allocate_space(vec2(spacing, available_space.y)); diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index d82dfe0a..ea2e0a50 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -164,18 +164,18 @@ impl<'a> Slider<'a> { ui.painter().add(PaintCmd::Rect { rect: rail_rect, corner_radius: rail_radius, - fill: Some(ui.style().visuals.background_fill), - outline: Some(LineStyle::new(1.0, Srgba::gray(200))), // TODO + fill: ui.style().visuals.background_fill, + outline: LineStyle::new(1.0, Srgba::gray(200)), // TODO }); ui.painter().add(PaintCmd::Circle { center: pos2(marker_center_x, rail_rect.center().y), radius: handle_radius(rect), - fill: Some(ui.style().interact(response).main_fill), - outline: Some(LineStyle::new( + fill: ui.style().interact(response).main_fill, + outline: LineStyle::new( ui.style().interact(response).stroke_width, ui.style().interact(response).stroke_color, - )), + ), }); } } diff --git a/egui/src/widgets/text_edit.rs b/egui/src/widgets/text_edit.rs index 1bbf7263..9f080d47 100644 --- a/egui/src/widgets/text_edit.rs +++ b/egui/src/widgets/text_edit.rs @@ -183,7 +183,7 @@ impl<'t> Widget for TextEdit<'t> { painter.add(PaintCmd::Rect { rect: bg_rect, corner_radius: ui.style().interact(&response).corner_radius, - fill: Some(ui.style().visuals.dark_bg_color), + fill: ui.style().visuals.dark_bg_color, outline: ui.style().interact(&response).bg_outline, }); }