only run bindgen on ImPlot... names

not sure why bindgen switches to i32 everywhere
moved imgui dependency up one step as this seems where its actually used
This commit is contained in:
Benedikt Mandelkow 2020-10-26 18:54:48 +01:00 committed by 4bb4
parent cdc7e273c0
commit 6bdfd76d51
11 changed files with 31 additions and 8241 deletions

View file

@ -12,6 +12,7 @@ readme = "README.md"
[dependencies] [dependencies]
implot-sys = { version = "0.1.0", path = "implot-sys" } implot-sys = { version = "0.1.0", path = "implot-sys" }
imgui = { version = "0.5.0" }
bitflags = "1.0" bitflags = "1.0"
parking_lot = "0.11" parking_lot = "0.11"
lazy_static = "1.1" lazy_static = "1.1"

View file

@ -4,9 +4,6 @@ version = "0.1.0"
authors = ["Sandro Merkli"] authors = ["Sandro Merkli"]
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bindgen = "0.53.1" bindgen = "0.55.1"
imgui-sys = { version = "0.5.0" } imgui-sys = { version = "0.5.0" }
imgui = { version = "0.5.0" }

View file

@ -1,6 +1,4 @@
use std::env; use std::env;
use std::io::Write;
use std::path::PathBuf;
fn main() { fn main() {
// We just forward the DEP_IMGUI_THIRD_PARTY variable here because the // We just forward the DEP_IMGUI_THIRD_PARTY variable here because the

View file

@ -34,6 +34,8 @@ fn main() {
) )
.parse_callbacks(Box::new(CargoCallbacks)) .parse_callbacks(Box::new(CargoCallbacks))
.clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1") .clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1")
.whitelist_function("ImPlot.*")
.whitelist_type("ImPlot.*")
.generate() .generate()
.expect("Unable to generate bindings"); .expect("Unable to generate bindings");

View file

@ -13,7 +13,6 @@ links = "implot"
[dependencies] [dependencies]
imgui-sys = "0.5.0" imgui-sys = "0.5.0"
imgui = "0.5.0"
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,8 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
pub use imgui; // just for linking for tests
#[cfg(test)]
use imgui_sys as _;
include!("bindings.rs"); include!("bindings.rs");

View file

@ -4,8 +4,8 @@
use parking_lot::ReentrantMutex; use parking_lot::ReentrantMutex;
use crate::sys;
use crate::PlotUi; use crate::PlotUi;
/// An implot context. /// An implot context.
/// ///
/// A context is required to do most of the things this library provides. While this was created /// A context is required to do most of the things this library provides. While this was created
@ -16,7 +16,7 @@ pub struct Context {
raw: *mut sys::ImPlotContext, raw: *mut sys::ImPlotContext,
} }
lazy_static! { lazy_static::lazy_static! {
// This mutex is used to guard any accesses to the context // This mutex is used to guard any accesses to the context
static ref CTX_MUTEX: ReentrantMutex<()> = ReentrantMutex::new(()); static ref CTX_MUTEX: ReentrantMutex<()> = ReentrantMutex::new(());
} }

View file

@ -12,17 +12,11 @@
//! you'd really like a particular feature, file an issue and it'll be given priority for wrapping, //! you'd really like a particular feature, file an issue and it'll be given priority for wrapping,
//! or directly contribute a PR, or use the low-level bindings directly for the time being. //! or directly contribute a PR, or use the low-level bindings directly for the time being.
//! //!
extern crate implot_sys as sys; use implot_sys as sys;
#[macro_use]
extern crate lazy_static;
// TODO(4bb4) facade-wrap these? // TODO(4bb4) facade-wrap these?
pub use sys::{imgui::Condition, ImPlotLimits, ImPlotPoint, ImPlotRange, ImVec2, ImVec4}; pub use self::{context::*, plot::*, plot_elements::*};
pub use sys::{ImPlotLimits, ImPlotPoint, ImPlotRange, ImVec2, ImVec4};
pub use self::context::*;
pub use self::plot::*;
pub use self::plot_elements::*;
mod context; mod context;
mod plot; mod plot;
@ -89,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(u32)] #[repr(i32)]
#[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)
@ -143,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(u32)] #[repr(i32)]
#[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.
@ -170,7 +164,7 @@ pub enum Colormap {
Jet = sys::ImPlotColormap__ImPlotColormap_Jet, Jet = sys::ImPlotColormap__ImPlotColormap_Jet,
} }
#[repr(u32)] #[repr(i32)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum StyleVar { pub enum StyleVar {
/// f32, line weight in pixels /// f32, line weight in pixels

View file

@ -2,13 +2,12 @@
//! //!
//! This module defines the `Plot` struct, which is used to create a 2D plot that will //! This module defines the `Plot` struct, which is used to create a 2D plot that will
//! contain all other objects that can be created using this library. //! contain all other objects that can be created using this library.
extern crate implot_sys as sys;
use bitflags::bitflags;
pub use sys::imgui::Condition;
use sys::imgui::{im_str, ImString};
pub use sys::{ImPlotLimits, ImPlotPoint, ImPlotRange, ImVec2, ImVec4};
use crate::{Context, PlotUi, YAxisChoice, NUMBER_OF_Y_AXES}; use crate::{Context, PlotUi, YAxisChoice, NUMBER_OF_Y_AXES};
use bitflags::bitflags;
pub use imgui::Condition;
use imgui::{im_str, ImString};
use implot_sys as sys;
pub use sys::{ImPlotLimits, ImPlotPoint, ImPlotRange, ImVec2, ImVec4};
const DEFAULT_PLOT_SIZE_X: f32 = 400.0; const DEFAULT_PLOT_SIZE_X: f32 = 400.0;
const DEFAULT_PLOT_SIZE_Y: f32 = 400.0; const DEFAULT_PLOT_SIZE_Y: f32 = 400.0;
@ -18,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: u32 { pub struct PlotFlags: i32 {
/// "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
@ -52,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: u32 { pub struct AxisFlags: i32 {
/// "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

@ -3,7 +3,8 @@
//! This module defines the various structs that can be used for drawing different things such //! This module defines the various structs that can be used for drawing different things such
//! as lines, bars, scatter plots and text in a plot. For the module to create plots themselves, //! as lines, bars, scatter plots and text in a plot. For the module to create plots themselves,
//! see `plot`. //! see `plot`.
use sys::imgui::im_str; use crate::sys;
use imgui::im_str;
// --- Actual plotting functionality ------------------------------------------------------------- // --- Actual plotting functionality -------------------------------------------------------------
/// Struct to provide functionality for plotting a line in a plot. /// Struct to provide functionality for plotting a line in a plot.