From 1fd2324399c359c419b810f78b73b00cef180470 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 2 Feb 2024 09:46:43 +0100 Subject: [PATCH] Make trait PlotItem public --- crates/egui_plot/src/items/mod.rs | 4 ++-- crates/egui_plot/src/items/values.rs | 4 ++-- crates/egui_plot/src/lib.rs | 16 ++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index d84a38c4496..d3b50222493 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -23,7 +23,7 @@ mod values; const DEFAULT_FILL_ALPHA: f32 = 0.05; /// Container to pass-through several parameters related to plot visualization -pub(super) struct PlotConfig<'a> { +pub struct PlotConfig<'a> { pub ui: &'a Ui, pub transform: &'a PlotTransform, pub show_x: bool, @@ -31,7 +31,7 @@ pub(super) struct PlotConfig<'a> { } /// Trait shared by things that can be drawn in the plot. -pub(super) trait PlotItem { +pub trait PlotItem { fn shapes(&self, ui: &Ui, transform: &PlotTransform, shapes: &mut Vec); /// For plot-items which are generated based on x values (plotting functions). diff --git a/crates/egui_plot/src/items/values.rs b/crates/egui_plot/src/items/values.rs index d05fdab36e7..8ed6d38f333 100644 --- a/crates/egui_plot/src/items/values.rs +++ b/crates/egui_plot/src/items/values.rs @@ -357,7 +357,7 @@ impl MarkerShape { // ---------------------------------------------------------------------------- /// Query the points of the plot, for geometric relations like closest checks -pub(crate) enum PlotGeometry<'a> { +pub enum PlotGeometry<'a> { /// No geometry based on single elements (examples: text, image, horizontal/vertical line) None, @@ -425,7 +425,7 @@ impl ExplicitGenerator { // ---------------------------------------------------------------------------- /// Result of [`super::PlotItem::find_closest()`] search, identifies an element inside the item for immediate use -pub(crate) struct ClosestElem { +pub struct ClosestElem { /// Position of hovered-over value (or bar/box-plot/...) in PlotItem pub index: usize, diff --git a/crates/egui_plot/src/lib.rs b/crates/egui_plot/src/lib.rs index f5067d277d1..fbe79d42a6a 100644 --- a/crates/egui_plot/src/lib.rs +++ b/crates/egui_plot/src/lib.rs @@ -16,20 +16,14 @@ mod transform; use std::{ops::RangeInclusive, sync::Arc}; use egui::ahash::HashMap; -use epaint::util::FloatOrd; -use epaint::Hsva; - -use axis::AxisWidget; -use items::PlotItem; -use legend::LegendWidget; - use egui::*; +use epaint::{util::FloatOrd, Hsva}; pub use crate::{ axis::{Axis, AxisHints, HPlacement, Placement, VPlacement}, items::{ Arrows, Bar, BarChart, BoxElem, BoxPlot, BoxSpread, HLine, Line, LineStyle, MarkerShape, - Orientation, PlotImage, PlotPoint, PlotPoints, Points, Polygon, Text, VLine, + Orientation, PlotImage, PlotItem, PlotPoint, PlotPoints, Points, Polygon, Text, VLine, }, legend::{Corner, Legend}, memory::PlotMemory, @@ -37,10 +31,12 @@ pub use crate::{ transform::{PlotBounds, PlotTransform}, }; +use axis::AxisWidget; use items::{horizontal_line, rulers_color, vertical_line}; +use legend::LegendWidget; type LabelFormatterFn = dyn Fn(&str, &PlotPoint) -> String; -type LabelFormatter = Option>; +pub type LabelFormatter = Option>; type GridSpacerFn = dyn Fn(GridInput) -> Vec; type GridSpacer = Box; @@ -84,7 +80,7 @@ impl Default for CoordinatesFormatter { /// Indicates a vertical or horizontal cursor line in plot coordinates. #[derive(Copy, Clone, PartialEq)] -enum Cursor { +pub enum Cursor { Horizontal { y: f64 }, Vertical { x: f64 }, }