From 0299663cdd1da6b716bb62083bd1e212fb7e4abe Mon Sep 17 00:00:00 2001 From: dwuertz Date: Thu, 21 Mar 2024 12:27:18 +0100 Subject: [PATCH] Expose `PlotGeometry` in public API (#4193) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose `egui_plot::items::values::PlotGeometry` in public API so that `PlotItem`, which is already public, can actually be implemented by applications. Fixes #3464. --------- Co-authored-by: Dominique Würtz --- crates/egui_plot/src/items/mod.rs | 4 ++-- crates/egui_plot/src/lib.rs | 3 ++- crates/egui_plot/src/plot_ui.rs | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index 122189d2..3df3b798 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -9,11 +9,11 @@ use crate::*; use super::{Cursor, LabelFormatter, PlotBounds, PlotTransform}; use rect_elem::*; -use values::{ClosestElem, PlotGeometry}; +use values::ClosestElem; pub use bar::Bar; pub use box_elem::{BoxElem, BoxSpread}; -pub use values::{LineStyle, MarkerShape, Orientation, PlotPoint, PlotPoints}; +pub use values::{LineStyle, MarkerShape, Orientation, PlotGeometry, PlotPoint, PlotPoints}; mod bar; mod box_elem; diff --git a/crates/egui_plot/src/lib.rs b/crates/egui_plot/src/lib.rs index 4238c7b3..ed133d7e 100644 --- a/crates/egui_plot/src/lib.rs +++ b/crates/egui_plot/src/lib.rs @@ -23,7 +23,8 @@ pub use crate::{ axis::{Axis, AxisHints, HPlacement, Placement, VPlacement}, items::{ Arrows, Bar, BarChart, BoxElem, BoxPlot, BoxSpread, HLine, Line, LineStyle, MarkerShape, - Orientation, PlotImage, PlotItem, PlotPoint, PlotPoints, Points, Polygon, Text, VLine, + Orientation, PlotGeometry, PlotImage, PlotItem, PlotPoint, PlotPoints, Points, Polygon, + Text, VLine, }, legend::{Corner, Legend}, memory::PlotMemory, diff --git a/crates/egui_plot/src/plot_ui.rs b/crates/egui_plot/src/plot_ui.rs index fb126298..c4a39a6d 100644 --- a/crates/egui_plot/src/plot_ui.rs +++ b/crates/egui_plot/src/plot_ui.rs @@ -116,6 +116,11 @@ impl PlotUi { self.last_plot_transform.value_from_position(position) } + /// Add an arbitrary item. + pub fn add(&mut self, item: impl PlotItem + 'static) { + self.items.push(Box::new(item)); + } + /// Add a data line. pub fn line(&mut self, mut line: Line) { if line.series.is_empty() {