From c20d6ded1fbd2f2900cb6d5ab9e6642421ebf477 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:22:33 +0900 Subject: [PATCH 1/3] Update style.rs --- crates/egui/src/style.rs | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 6b77e8a14ec..dcf78cc17e0 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -281,6 +281,9 @@ pub struct Spacing { /// Default width of a [`Slider`]. pub slider_width: f32, + /// Default rail height of a [`Slider`]. + pub slider_rail_height: f32, + /// Default (minimum) width of a [`ComboBox`](crate::ComboBox). pub combo_width: f32, @@ -941,6 +944,9 @@ pub struct Widgets { /// The style of an interactive widget, such as a button, at rest. pub inactive: WidgetVisuals, + /// The style of a unhovered widget. + pub unhovered: WidgetVisuals, + /// The style of an interactive widget while you hover it, or when it is highlighted. /// /// See [`Response::hovered`], [`Response::highlighted`] and [`Response::highlight`]. @@ -1114,6 +1120,7 @@ impl Default for Spacing { indent: 18.0, // match checkbox/radio-button with `button_padding.x + icon_width + icon_spacing` interact_size: vec2(40.0, 18.0), slider_width: 100.0, + slider_rail_height: 9.6, combo_width: 100.0, text_edit_width: 280.0, icon_width: 14.0, @@ -1262,6 +1269,14 @@ impl Widgets { rounding: Rounding::same(2.0), expansion: 0.0, }, + unhovered: WidgetVisuals { + weak_bg_fill: Color32::from_gray(27), + bg_fill: Color32::from_gray(27), + bg_stroke: Stroke::new(1.0, Color32::from_gray(60)), + fg_stroke: Stroke::new(1.0, Color32::from_gray(140)), + rounding: Rounding::same(2.0), + expansion: 0.0, + }, hovered: WidgetVisuals { weak_bg_fill: Color32::from_gray(70), bg_fill: Color32::from_gray(70), @@ -1307,6 +1322,14 @@ impl Widgets { rounding: Rounding::same(2.0), expansion: 0.0, }, + unhovered: WidgetVisuals { + weak_bg_fill: Color32::from_gray(248), + bg_fill: Color32::from_gray(248), + bg_stroke: Stroke::new(1.0, Color32::from_gray(190)), + fg_stroke: Stroke::new(1.0, Color32::from_gray(80)), + rounding: Rounding::same(2.0), + expansion: 0.0, + }, hovered: WidgetVisuals { weak_bg_fill: Color32::from_gray(220), bg_fill: Color32::from_gray(220), @@ -1463,6 +1486,7 @@ impl Spacing { indent, interact_size, slider_width, + slider_rail_height, combo_width, text_edit_width, icon_width, @@ -1491,6 +1515,10 @@ impl Spacing { ui.add(DragValue::new(slider_width).clamp_range(0.0..=1000.0)); ui.label("Slider width"); }); + ui.horizontal(|ui| { + ui.add(DragValue::new(slider_rail_height).clamp_range(0.0..=50.0)); + ui.label("Slider rail height"); + }); ui.horizontal(|ui| { ui.add(DragValue::new(combo_width).clamp_range(0.0..=1000.0)); ui.label("ComboBox width"); @@ -1637,10 +1665,11 @@ impl Interaction { impl Widgets { pub fn ui(&mut self, ui: &mut crate::Ui) { let Self { - active, - hovered, - inactive, noninteractive, + inactive, + unhovered, + hovered, + active, open, } = self; @@ -1654,6 +1683,10 @@ impl Widgets { ui.label("The style of an interactive widget, such as a button, at rest."); inactive.ui(ui); }); + ui.collapsing("Interactive and unhovered", |ui| { + ui.label("The style of an interactive widget while you unhover it."); + unhovered.ui(ui); + }); ui.collapsing("Interactive and hovered", |ui| { ui.label("The style of an interactive widget while you hover it."); hovered.ui(ui); From 9fdb824ac1d0eb861b16c21b65c308b7ab3e3581 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:23:16 +0900 Subject: [PATCH 2/3] Update builder.rs --- crates/egui/src/widgets/text_edit/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 22a5623f077..c761f7e77c8 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -413,7 +413,7 @@ impl<'t> TextEdit<'t> { frame_rect, visuals.rounding, ui.visuals().extreme_bg_color, - visuals.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop". + ui.visuals().widgets.unhovered.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop". ) } } else { From fa2f235334c338179d4353890df945ae4a6e3db6 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 10 Mar 2024 00:28:50 +0900 Subject: [PATCH 3/3] Update builder.rs --- crates/egui/src/widgets/text_edit/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 8b163c22f89..9c67333645b 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -421,7 +421,7 @@ impl<'t> TextEdit<'t> { epaint::RectShape::stroke( frame_rect, visuals.rounding, - visuals.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop". + ui.visuals().widgets.unhovered.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop". ) };