From 989af3d264191576b2bc187cbcc04bc98c2eed7f Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 8 Jan 2023 14:38:11 +0100 Subject: [PATCH 01/13] Plot Item allow_hover --- CHANGELOG.md | 1 + crates/egui/src/widgets/plot/items/mod.rs | 122 ++++++++++++++++++++++ crates/egui/src/widgets/plot/mod.rs | 4 +- 3 files changed, 126 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3adff09a184..c1c0580b25e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ## Unreleased ### Added ⭐ +* Add `Plot::Item::allow_hover` give possibility to masked the interaction on hovered item. * `Event::Key` now has a `repeat` field that is set to `true` if the event was the result of a key-repeat ([#2435](https://github.com/emilk/egui/pull/2435)). * Add `Slider::drag_value_speed`, which lets you ask for finer precision when dragging the slider value rather than the actual slider. * Add `Memory::any_popup_open`, which returns true if any popup is currently open ([#2464](https://github.com/emilk/egui/pull/2464)). diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index 378f27eb35c..2fa106fb83b 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -45,6 +45,8 @@ pub(super) trait PlotItem { fn highlighted(&self) -> bool; + fn allow_hover(&self) -> bool; + fn geometry(&self) -> PlotGeometry<'_>; fn bounds(&self) -> PlotBounds; @@ -119,6 +121,7 @@ pub struct HLine { pub(super) stroke: Stroke, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) style: LineStyle, } @@ -129,6 +132,7 @@ impl HLine { stroke: Stroke::new(1.0, Color32::TRANSPARENT), name: String::default(), highlight: false, + allow_hover: true, style: LineStyle::Solid, } } @@ -139,6 +143,12 @@ impl HLine { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a stroke. pub fn stroke(mut self, stroke: impl Into) -> Self { self.stroke = stroke.into(); @@ -216,6 +226,10 @@ impl PlotItem for HLine { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::None } @@ -235,6 +249,7 @@ pub struct VLine { pub(super) stroke: Stroke, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) style: LineStyle, } @@ -245,6 +260,7 @@ impl VLine { stroke: Stroke::new(1.0, Color32::TRANSPARENT), name: String::default(), highlight: false, + allow_hover: true, style: LineStyle::Solid, } } @@ -255,6 +271,12 @@ impl VLine { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a stroke. pub fn stroke(mut self, stroke: impl Into) -> Self { self.stroke = stroke.into(); @@ -332,6 +354,10 @@ impl PlotItem for VLine { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::None } @@ -350,6 +376,7 @@ pub struct Line { pub(super) stroke: Stroke, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) fill: Option, pub(super) style: LineStyle, } @@ -361,6 +388,7 @@ impl Line { stroke: Stroke::new(1.0, Color32::TRANSPARENT), name: Default::default(), highlight: false, + allow_hover: true, fill: None, style: LineStyle::Solid, } @@ -372,6 +400,12 @@ impl Line { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a stroke. pub fn stroke(mut self, stroke: impl Into) -> Self { self.stroke = stroke.into(); @@ -502,6 +536,10 @@ impl PlotItem for Line { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Points(self.series.points()) } @@ -517,6 +555,7 @@ pub struct Polygon { pub(super) stroke: Stroke, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) fill_alpha: f32, pub(super) style: LineStyle, } @@ -528,6 +567,7 @@ impl Polygon { stroke: Stroke::new(1.0, Color32::TRANSPARENT), name: Default::default(), highlight: false, + allow_hover: true, fill_alpha: DEFAULT_FILL_ALPHA, style: LineStyle::Solid, } @@ -540,6 +580,12 @@ impl Polygon { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a custom stroke. pub fn stroke(mut self, stroke: impl Into) -> Self { self.stroke = stroke.into(); @@ -632,6 +678,10 @@ impl PlotItem for Polygon { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Points(self.series.points()) } @@ -648,6 +698,7 @@ pub struct Text { pub(super) position: PlotPoint, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) color: Color32, pub(super) anchor: Align2, } @@ -659,6 +710,7 @@ impl Text { position, name: Default::default(), highlight: false, + allow_hover: true, color: Color32::TRANSPARENT, anchor: Align2::CENTER_CENTER, } @@ -670,6 +722,12 @@ impl Text { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Text color. pub fn color(mut self, color: impl Into) -> Self { self.color = color.into(); @@ -746,6 +804,10 @@ impl PlotItem for Text { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::None } @@ -769,6 +831,7 @@ pub struct Points { pub(super) radius: f32, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) stems: Option, } @@ -782,6 +845,7 @@ impl Points { radius: 1.0, name: Default::default(), highlight: false, + allow_hover: true, stems: None, } } @@ -798,6 +862,12 @@ impl Points { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Set the marker's color. pub fn color(mut self, color: impl Into) -> Self { self.color = color.into(); @@ -984,6 +1054,10 @@ impl PlotItem for Points { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Points(self.series.points()) } @@ -1000,6 +1074,7 @@ pub struct Arrows { pub(super) color: Color32, pub(super) name: String, pub(super) highlight: bool, + pub(super) allow_hover: bool, } impl Arrows { @@ -1010,6 +1085,7 @@ impl Arrows { color: Color32::TRANSPARENT, name: Default::default(), highlight: false, + allow_hover: true, } } @@ -1019,6 +1095,12 @@ impl Arrows { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Set the arrows' color. pub fn color(mut self, color: impl Into) -> Self { self.color = color.into(); @@ -1099,6 +1181,10 @@ impl PlotItem for Arrows { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Points(self.origins.points()) } @@ -1118,6 +1204,7 @@ pub struct PlotImage { pub(super) bg_fill: Color32, pub(super) tint: Color32, pub(super) highlight: bool, + pub(super) allow_hover: bool, pub(super) name: String, } @@ -1132,6 +1219,7 @@ impl PlotImage { position: center_position, name: Default::default(), highlight: false, + allow_hover: true, texture_id: texture_id.into(), uv: Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), size: size.into(), @@ -1146,6 +1234,12 @@ impl PlotImage { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Select UV range. Default is (0,0) in top-left, (1,1) bottom right. pub fn uv(mut self, uv: impl Into) -> Self { self.uv = uv.into(); @@ -1234,6 +1328,10 @@ impl PlotItem for PlotImage { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::None } @@ -1264,6 +1362,7 @@ pub struct BarChart { /// A custom element formatter pub(super) element_formatter: Option String>>, highlight: bool, + allow_hover: bool, } impl BarChart { @@ -1275,6 +1374,7 @@ impl BarChart { name: String::new(), element_formatter: None, highlight: false, + allow_hover: true, } } @@ -1336,6 +1436,12 @@ impl BarChart { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a custom way to format an element. /// Can be used to display a set number of decimals or custom labels. pub fn element_formatter(mut self, formatter: Box String>) -> Self { @@ -1395,6 +1501,10 @@ impl PlotItem for BarChart { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Rects } @@ -1434,6 +1544,7 @@ pub struct BoxPlot { /// A custom element formatter pub(super) element_formatter: Option String>>, highlight: bool, + allow_hover: bool, } impl BoxPlot { @@ -1445,6 +1556,7 @@ impl BoxPlot { name: String::new(), element_formatter: None, highlight: false, + allow_hover: true, } } @@ -1500,6 +1612,12 @@ impl BoxPlot { self } + // Allowed hovering this line in the plot. + pub fn allow_hover(mut self, hovering: bool) -> Self { + self.allow_hover = hovering; + self + } + /// Add a custom way to format an element. /// Can be used to display a set number of decimals or custom labels. pub fn element_formatter( @@ -1538,6 +1656,10 @@ impl PlotItem for BoxPlot { self.highlight } + fn allow_hover(&self) -> bool { + self.allow_hover + } + fn geometry(&self) -> PlotGeometry<'_> { PlotGeometry::Rects } diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index bbefe4b44b7..a83e1652fad 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1574,7 +1574,9 @@ impl PreparedPlot { let interact_radius_sq: f32 = (16.0f32).powi(2); - let candidates = items.iter().filter_map(|item| { + let candidates = items.iter() + .filter(|entry| entry.allow_hover() == true) + .filter_map(|item| { let item = &**item; let closest = item.find_closest(pointer, transform); From 48252e5c93e6a2eaa2e6bc411f23c3f449280e5f Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 8 Jan 2023 14:45:21 +0100 Subject: [PATCH 02/13] Update syntax --- CHANGELOG.md | 2 +- crates/egui/src/widgets/plot/mod.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c0580b25e..64ae6cddb92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ## Unreleased ### Added ⭐ -* Add `Plot::Item::allow_hover` give possibility to masked the interaction on hovered item. +* Add `Plot::Item::allow_hover` give possibility to masked the interaction on hovered item. * `Event::Key` now has a `repeat` field that is set to `true` if the event was the result of a key-repeat ([#2435](https://github.com/emilk/egui/pull/2435)). * Add `Slider::drag_value_speed`, which lets you ask for finer precision when dragging the slider value rather than the actual slider. * Add `Memory::any_popup_open`, which returns true if any popup is currently open ([#2464](https://github.com/emilk/egui/pull/2464)). diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index a83e1652fad..ac6978928b6 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1575,13 +1575,13 @@ impl PreparedPlot { let interact_radius_sq: f32 = (16.0f32).powi(2); let candidates = items.iter() - .filter(|entry| entry.allow_hover() == true) - .filter_map(|item| { - let item = &**item; - let closest = item.find_closest(pointer, transform); + .filter(|entry| entry.allow_hover() == true) + .filter_map(|item| { + let item = &**item; + let closest = item.find_closest(pointer, transform); - Some(item).zip(closest) - }); + Some(item).zip(closest) + }); let closest = candidates .min_by_key(|(_, elem)| elem.dist_sq.ord()) From b00cc84378fb4b25f31d48c1f3f54a5a0c09950e Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 8 Jan 2023 14:47:18 +0100 Subject: [PATCH 03/13] Update syntax --- crates/egui/src/widgets/plot/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index ac6978928b6..9bd2506a88c 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1580,8 +1580,8 @@ impl PreparedPlot { let item = &**item; let closest = item.find_closest(pointer, transform); - Some(item).zip(closest) - }); + Some(item).zip(closest) + }); let closest = candidates .min_by_key(|(_, elem)| elem.dist_sq.ord()) From c7c93387c9d2e3728c77412eefc8f17382ffc3c5 Mon Sep 17 00:00:00 2001 From: Nicolas PASCAL Date: Mon, 23 Jan 2023 13:14:01 +0100 Subject: [PATCH 04/13] plot/mod.rs: syntax not optimised corrected Co-authored-by: Emil Ernerfeldt --- crates/egui/src/widgets/plot/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 9bd2506a88c..873de30d4f8 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1575,7 +1575,7 @@ impl PreparedPlot { let interact_radius_sq: f32 = (16.0f32).powi(2); let candidates = items.iter() - .filter(|entry| entry.allow_hover() == true) + .filter(|entry| entry.allow_hover()) .filter_map(|item| { let item = &**item; let closest = item.find_closest(pointer, transform); From f937bf95a3a49cc27fb77aa7593563db18f1a3e9 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 23 Jan 2023 13:20:31 +0100 Subject: [PATCH 05/13] Update documentation of allow hover --- crates/egui/src/widgets/plot/items/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index 2fa106fb83b..7beadd74fec 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -143,7 +143,7 @@ impl HLine { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -271,7 +271,7 @@ impl VLine { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -400,7 +400,7 @@ impl Line { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -580,7 +580,7 @@ impl Polygon { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -722,7 +722,7 @@ impl Text { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -862,7 +862,7 @@ impl Points { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1095,7 +1095,7 @@ impl Arrows { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1234,7 +1234,7 @@ impl PlotImage { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1436,7 +1436,7 @@ impl BarChart { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1612,7 +1612,7 @@ impl BoxPlot { self } - // Allowed hovering this line in the plot. + // Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self From a8f25c6c31be56c47f322c752265889893a3bdeb Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 23 Jan 2023 13:32:07 +0100 Subject: [PATCH 06/13] Add missing slash for doc allow_hover --- crates/egui/src/widgets/plot/items/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index 7beadd74fec..426ac8399f3 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -143,7 +143,7 @@ impl HLine { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -271,7 +271,7 @@ impl VLine { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -400,7 +400,7 @@ impl Line { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -580,7 +580,7 @@ impl Polygon { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -722,7 +722,7 @@ impl Text { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -862,7 +862,7 @@ impl Points { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1095,7 +1095,7 @@ impl Arrows { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1234,7 +1234,7 @@ impl PlotImage { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1436,7 +1436,7 @@ impl BarChart { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1612,7 +1612,7 @@ impl BoxPlot { self } - // Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self From f8b7046675c47d262bc4e8846a3b7b8f09cb5986 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 14 Aug 2023 18:24:13 +0200 Subject: [PATCH 07/13] remove line from CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64ae6cddb92..3adff09a184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ## Unreleased ### Added ⭐ -* Add `Plot::Item::allow_hover` give possibility to masked the interaction on hovered item. * `Event::Key` now has a `repeat` field that is set to `true` if the event was the result of a key-repeat ([#2435](https://github.com/emilk/egui/pull/2435)). * Add `Slider::drag_value_speed`, which lets you ask for finer precision when dragging the slider value rather than the actual slider. * Add `Memory::any_popup_open`, which returns true if any popup is currently open ([#2464](https://github.com/emilk/egui/pull/2464)). From 519edd41d8de501e6c2e72e05313daf61b223570 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 14 Aug 2023 18:24:22 +0200 Subject: [PATCH 08/13] Add docstring --- crates/egui/src/widgets/plot/items/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index 426ac8399f3..47c2d62abc6 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -45,6 +45,7 @@ pub(super) trait PlotItem { fn highlighted(&self) -> bool; + /// Can the user hover this is item? fn allow_hover(&self) -> bool; fn geometry(&self) -> PlotGeometry<'_>; From f0df61e97165be0ad2d0b3d8bfb2965cf3d51ded Mon Sep 17 00:00:00 2001 From: Nicolas PASCAL Date: Mon, 14 Aug 2023 23:32:28 +0200 Subject: [PATCH 09/13] Update formatting --- crates/egui/src/widgets/plot/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index dc599b2464c..7bd0f015fa9 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1805,8 +1805,8 @@ impl PreparedPlot { let item = &**item; let closest = item.find_closest(pointer, transform); - Some(item).zip(closest) - }); + Some(item).zip(closest) + }); let closest = candidates .min_by_key(|(_, elem)| elem.dist_sq.ord()) From d70da236e8a097f4a0c26a163b8d0c819ab02d47 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 17 Aug 2023 10:08:51 +0200 Subject: [PATCH 10/13] Update foramting --- crates/egui/src/widgets/plot/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 7bd0f015fa9..488dd0efe0b 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1799,7 +1799,8 @@ impl PreparedPlot { let interact_radius_sq: f32 = (16.0f32).powi(2); - let candidates = items.iter() + let candidates = items + .iter() .filter(|entry| entry.allow_hover()) .filter_map(|item| { let item = &**item; From cb61f701b044a2e6755bda9757717e110844ef9d Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 26 Mar 2024 12:24:53 +0100 Subject: [PATCH 11/13] Fixed CI Lint --- crates/egui_plot/src/items/mod.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index cc7a9453c9e..e62ec50dce6 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -149,7 +149,8 @@ impl HLine { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -296,7 +297,8 @@ impl VLine { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -444,7 +446,8 @@ impl Line { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -646,7 +649,8 @@ impl Polygon { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -797,7 +801,8 @@ impl Text { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -957,7 +962,8 @@ impl Points { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1211,7 +1217,8 @@ impl Arrows { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1380,7 +1387,8 @@ impl PlotImage { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1627,7 +1635,8 @@ impl BarChart { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self @@ -1825,7 +1834,8 @@ impl BoxPlot { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. + #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; self From 8ea9277ca0ff52822958d6daa9880170197ae19c Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 26 Mar 2024 12:30:39 +0100 Subject: [PATCH 12/13] Update formatting white space --- crates/egui_plot/src/items/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index e62ec50dce6..70bf227623b 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -149,7 +149,7 @@ impl HLine { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -297,7 +297,7 @@ impl VLine { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -446,7 +446,7 @@ impl Line { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -649,7 +649,7 @@ impl Polygon { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -801,7 +801,7 @@ impl Text { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -962,7 +962,7 @@ impl Points { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -1217,7 +1217,7 @@ impl Arrows { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -1387,7 +1387,7 @@ impl PlotImage { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -1635,7 +1635,7 @@ impl BarChart { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; @@ -1834,7 +1834,7 @@ impl BoxPlot { self } - /// Allowed hovering this item in the plot. Default: `true`. + /// Allowed hovering this item in the plot. Default: `true`. #[inline] pub fn allow_hover(mut self, hovering: bool) -> Self { self.allow_hover = hovering; From aa5c8978f90f466c7b4f418e2ddf6f1a88ce58a0 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 27 Mar 2024 12:26:48 +0100 Subject: [PATCH 13/13] Fix merge field fill_color --- crates/egui_plot/src/items/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index 70bf227623b..78f4560c6d3 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -620,7 +620,6 @@ pub struct Polygon { pub(super) name: String, pub(super) highlight: bool, pub(super) allow_hover: bool, - pub(super) fill_alpha: f32, pub(super) fill_color: Option, pub(super) style: LineStyle, id: Option, @@ -634,7 +633,6 @@ impl Polygon { name: Default::default(), highlight: false, allow_hover: true, - fill_alpha: DEFAULT_FILL_ALPHA, fill_color: None, style: LineStyle::Solid, id: None,