Skip to content

Commit

Permalink
Make trait PlotItem public
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Feb 2, 2024
1 parent e044109 commit 1fd2324
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crates/egui_plot/src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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,
pub show_y: bool,
}

/// 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<Shape>);

/// For plot-items which are generated based on x values (plotting functions).
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_plot/src/items/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down
16 changes: 6 additions & 10 deletions crates/egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,27 @@ 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,
plot_ui::PlotUi,
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<Box<LabelFormatterFn>>;
pub type LabelFormatter = Option<Box<LabelFormatterFn>>;

type GridSpacerFn = dyn Fn(GridInput) -> Vec<GridMark>;
type GridSpacer = Box<GridSpacerFn>;
Expand Down Expand Up @@ -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 },
}
Expand Down

0 comments on commit 1fd2324

Please sign in to comment.