Updated to newest available implot

This commit is contained in:
4bb4 2020-10-31 11:04:13 +01:00
parent b6a7cae830
commit af0996390a
6 changed files with 2507 additions and 200 deletions

View file

@ -4,8 +4,9 @@
Rust bindings for [ImPlot](https://github.com/epezent/implot), built by running Rust bindings for [ImPlot](https://github.com/epezent/implot), built by running
[bindgen](https://github.com/rust-lang/rust-bindgen) on [cimplot](https://github.com/cimgui/cimplot). [bindgen](https://github.com/rust-lang/rust-bindgen) on [cimplot](https://github.com/cimgui/cimplot).
The bindings are currently based on ImPlot version 0.7. See the status section below for The bindings are currently based on ImPlot version 0.8-WIP (see
detailed information on implementation status. [implot-sys/third_party](implot-sys/third_party) for the exact commit currently pointed to).
The status section below provides detailed information on implementation status.
[![Docs.rs documentation](https://docs.rs/implot/badge.svg)](https://docs.rs/implot/) [![Docs.rs documentation](https://docs.rs/implot/badge.svg)](https://docs.rs/implot/)
![Tests](https://github.com/4bb4/implot-rs/workflows/Tests/badge.svg) ![Tests](https://github.com/4bb4/implot-rs/workflows/Tests/badge.svg)
@ -46,6 +47,10 @@ is open to collaboration, if you'd like to help, feel free to reach out via a Gi
At this point, raw bindings are working in implot-sys, and more idiomatic interfaces At this point, raw bindings are working in implot-sys, and more idiomatic interfaces
for plot creation as well a subset of the functionality for plots are implemented. for plot creation as well a subset of the functionality for plots are implemented.
While the raw bindings have versions of most functions for different data types such as
32-bit or 64-bit floats and various integers, the higher-level bindings are currently only
created for 64-bit floats.
- [x] "BeginPlot" - [x] "BeginPlot"
- [x] Basic hello world - [x] Basic hello world
- [x] Plot flags - [x] Plot flags
@ -65,11 +70,16 @@ for plot creation as well a subset of the functionality for plots are implemente
- [ ] Heatmap - [ ] Heatmap
- [ ] Pie chart - [ ] Pie chart
- [ ] Digital data - [ ] Digital data
- [x] Plot customization - [ ] Stairs plot
- [ ] Annotations
- [ ] Dragline
- [ ] Dragpoint
- [ ] Plot customization
- [x] Axis flags - [x] Axis flags
- [x] Styling colors - [x] Styling colors
- [x] Styling variables - [x] Styling variables
- [x] Colormaps - [x] Colormaps
- [ ] Legend locations
- [x] Plot querying - [x] Plot querying
- [x] is hovered - [x] is hovered
- [x] mouse position in plot - [x] mouse position in plot

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 54ed676f42b7d96d6622f1c90df7d884246cc944 Subproject commit a7760f2f7557e15f50fe7916c9243b192345b38e

View file

@ -83,7 +83,7 @@ pub enum Marker {
/// Colorable plot elements. These are called "ImPlotCol" in ImPlot itself, but I found that /// Colorable plot elements. These are called "ImPlotCol" in ImPlot itself, but I found that
/// name somewhat confusing because we are not referring to colors, but _which_ thing can /// name somewhat confusing because we are not referring to colors, but _which_ thing can
/// be colored - hence I added the "Element". /// be colored - hence I added the "Element".
#[repr(i32)] #[repr(u32)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum PlotColorElement { pub enum PlotColorElement {
/// Plot line/outline color (defaults to next unused color in current colormap) /// Plot line/outline color (defaults to next unused color in current colormap)
@ -137,7 +137,7 @@ pub enum PlotColorElement {
} }
/// Colormap choice. Documentation copied from implot.h for convenience. /// Colormap choice. Documentation copied from implot.h for convenience.
#[repr(i32)] #[repr(u32)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum Colormap { pub enum Colormap {
/// ImPlot default colormap (n=10). Called "Standard" here because Default is reserved. /// ImPlot default colormap (n=10). Called "Standard" here because Default is reserved.
@ -164,7 +164,7 @@ pub enum Colormap {
Jet = sys::ImPlotColormap__ImPlotColormap_Jet, Jet = sys::ImPlotColormap__ImPlotColormap_Jet,
} }
#[repr(i32)] #[repr(u32)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum StyleVar { pub enum StyleVar {
/// f32, line weight in pixels /// f32, line weight in pixels
@ -207,8 +207,16 @@ pub enum StyleVar {
LabelPadding = sys::ImPlotStyleVar__ImPlotStyleVar_LabelPadding, LabelPadding = sys::ImPlotStyleVar__ImPlotStyleVar_LabelPadding,
/// ImVec2, legend padding from top-left of plot /// ImVec2, legend padding from top-left of plot
LegendPadding = sys::ImPlotStyleVar__ImPlotStyleVar_LegendPadding, LegendPadding = sys::ImPlotStyleVar__ImPlotStyleVar_LegendPadding,
/// ImVec2, legend inner padding from legend edges
LegendInnerPadding = sys::ImPlotStyleVar__ImPlotStyleVar_LegendInnerPadding,
/// ImVec2, spacing between legend entries
LegendSpacing = sys::ImPlotStyleVar__ImPlotStyleVar_LegendSpacing,
/// ImVec2, padding between plot edge and interior info text /// ImVec2, padding between plot edge and interior info text
InfoPadding = sys::ImPlotStyleVar__ImPlotStyleVar_InfoPadding, MousePosPadding = sys::ImPlotStyleVar__ImPlotStyleVar_MousePosPadding,
/// ImVec2, text padding around annotation labels
AnnotationPadding = sys::ImPlotStyleVar__ImPlotStyleVar_AnnotationPadding,
/// ImVec2, default size used when ImVec2(0,0) is passed to BeginPlot
PlotDefaultSize = sys::ImPlotStyleVar__ImPlotStyleVar_PlotDefaultSize,
/// ImVec2, minimum size plot frame can be when shrunk /// ImVec2, minimum size plot frame can be when shrunk
PlotMinSize = sys::ImPlotStyleVar__ImPlotStyleVar_PlotMinSize, PlotMinSize = sys::ImPlotStyleVar__ImPlotStyleVar_PlotMinSize,
} }

View file

@ -17,7 +17,7 @@ bitflags! {
/// convenience. ImPlot itself also has a "CanvasOnly" flag, which can be emulated here with /// convenience. ImPlot itself also has a "CanvasOnly" flag, which can be emulated here with
/// the combination of `NO_LEGEND`, `NO_MENUS`, `NO_BOX_SELECT` and `NO_MOUSE_POSITION`. /// the combination of `NO_LEGEND`, `NO_MENUS`, `NO_BOX_SELECT` and `NO_MOUSE_POSITION`.
#[repr(transparent)] #[repr(transparent)]
pub struct PlotFlags: i32 { pub struct PlotFlags: u32 {
/// "Default" according to original docs /// "Default" according to original docs
const NONE = sys::ImPlotFlags__ImPlotFlags_None; const NONE = sys::ImPlotFlags__ImPlotFlags_None;
/// Plot items will not be highlighted when their legend entry is hovered /// Plot items will not be highlighted when their legend entry is hovered
@ -51,7 +51,7 @@ bitflags! {
/// has `Lock`, which combines `LOCK_MIN` and `LOCK_MAX`, and `NoDecorations`, which combines /// has `Lock`, which combines `LOCK_MIN` and `LOCK_MAX`, and `NoDecorations`, which combines
/// `NO_GRID_LINES`, `NO_TICK_MARKS` and `NO_TICK_LABELS`. /// `NO_GRID_LINES`, `NO_TICK_MARKS` and `NO_TICK_LABELS`.
#[repr(transparent)] #[repr(transparent)]
pub struct AxisFlags: i32 { pub struct AxisFlags: u32 {
/// "Default" according to original docs /// "Default" according to original docs
const NONE = sys::ImPlotAxisFlags__ImPlotAxisFlags_None; const NONE = sys::ImPlotAxisFlags__ImPlotAxisFlags_None;
/// Grid lines will not be displayed /// Grid lines will not be displayed

View file

@ -191,7 +191,7 @@ impl PlotText {
} }
unsafe { unsafe {
sys::ImPlot_PlotTextdouble( sys::ImPlot_PlotText(
im_str!("{}", self.label).as_ptr() as *const i8, im_str!("{}", self.label).as_ptr() as *const i8,
x, x,
y, y,