Added more doc aliases
This commit is contained in:
parent
5d82bba3d6
commit
191a6f2fd4
3 changed files with 17 additions and 1 deletions
|
@ -12,6 +12,7 @@ use crate::PlotUi;
|
||||||
/// implicitly in earlier versions of the library, it is now created explicitly. These contexts
|
/// implicitly in earlier versions of the library, it is now created explicitly. These contexts
|
||||||
/// cannot currently be disabled through the high level API. This could be implemented though,
|
/// cannot currently be disabled through the high level API. This could be implemented though,
|
||||||
/// if you need multiple contexts that you can switch around between, file an issue.
|
/// if you need multiple contexts that you can switch around between, file an issue.
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "ImPlotContext"))]
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
raw: *mut sys::ImPlotContext,
|
raw: *mut sys::ImPlotContext,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
//! 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.
|
||||||
//!
|
//!
|
||||||
|
//! If you've seen a construct or feature in C++ implot and can't find it here, try searching for
|
||||||
|
//! the C++ name - some doc aliases are defined to increase the chances of that working. If this
|
||||||
|
//! does not yield any results, you can also try cloning the source and doing a full-text search to
|
||||||
|
//! see if the feature is used somewhere internally the code.
|
||||||
use implot_sys as sys;
|
use implot_sys as sys;
|
||||||
|
|
||||||
// TODO(4bb4) facade-wrap these?
|
// TODO(4bb4) facade-wrap these?
|
||||||
|
@ -46,6 +50,7 @@ pub enum YAxisChoice {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Turn an Option<YAxisChoice> into an i32. Picks IMPLOT_AUTO for None.
|
/// Turn an Option<YAxisChoice> into an i32. Picks IMPLOT_AUTO for None.
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "IMPLOT_AUTO"))]
|
||||||
fn y_axis_choice_option_to_i32(y_axis_choice: Option<YAxisChoice>) -> i32 {
|
fn y_axis_choice_option_to_i32(y_axis_choice: Option<YAxisChoice>) -> i32 {
|
||||||
match y_axis_choice {
|
match y_axis_choice {
|
||||||
Some(choice) => choice as i32,
|
Some(choice) => choice as i32,
|
||||||
|
@ -333,6 +338,7 @@ pub struct StyleColorToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StyleColorToken {
|
impl StyleColorToken {
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "PopStyleColor"))]
|
||||||
pub fn pop(mut self) {
|
pub fn pop(mut self) {
|
||||||
if self.was_popped {
|
if self.was_popped {
|
||||||
panic!("Attempted to pop a style color token twice.")
|
panic!("Attempted to pop a style color token twice.")
|
||||||
|
@ -393,6 +399,7 @@ pub struct StyleVarToken {
|
||||||
|
|
||||||
impl StyleVarToken {
|
impl StyleVarToken {
|
||||||
/// Pop this token from the stack.
|
/// Pop this token from the stack.
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "PopStyleVar"))]
|
||||||
pub fn pop(mut self) {
|
pub fn pop(mut self) {
|
||||||
if self.was_popped {
|
if self.was_popped {
|
||||||
panic!("Attempted to pop a style var token twice.")
|
panic!("Attempted to pop a style var token twice.")
|
||||||
|
|
10
src/plot.rs
10
src/plot.rs
|
@ -12,6 +12,7 @@ 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;
|
||||||
|
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "ImPlotFlags"))]
|
||||||
bitflags! {
|
bitflags! {
|
||||||
/// Flags for customizing plot behavior and interaction. Documentation copied from implot.h for
|
/// Flags for customizing plot behavior and interaction. Documentation copied from implot.h for
|
||||||
/// 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
|
||||||
|
@ -48,6 +49,7 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "ImPlotAxisFlags"))]
|
||||||
bitflags! {
|
bitflags! {
|
||||||
/// Axis flags. Documentation copied from implot.h for convenience. ImPlot itself also
|
/// Axis flags. Documentation copied from implot.h for convenience. ImPlot itself also
|
||||||
/// 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
|
||||||
|
@ -309,6 +311,7 @@ impl Plot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the legend location, orientation and whether it is to be drawn outside the plot
|
/// Set the legend location, orientation and whether it is to be drawn outside the plot
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "SetLegendLocation"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_legend_location(
|
pub fn with_legend_location(
|
||||||
mut self,
|
mut self,
|
||||||
|
@ -414,6 +417,7 @@ impl Plot {
|
||||||
///
|
///
|
||||||
/// For a convenient implementation of all this, use [`build()`](struct.Plot.html#method.build)
|
/// For a convenient implementation of all this, use [`build()`](struct.Plot.html#method.build)
|
||||||
/// instead.
|
/// instead.
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "BeginPlot"))]
|
||||||
pub fn begin(&self, plot_ui: &PlotUi) -> Option<PlotToken> {
|
pub fn begin(&self, plot_ui: &PlotUi) -> Option<PlotToken> {
|
||||||
self.maybe_set_axis_limits();
|
self.maybe_set_axis_limits();
|
||||||
self.maybe_set_tick_labels();
|
self.maybe_set_tick_labels();
|
||||||
|
@ -463,10 +467,13 @@ impl Plot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a window and runs a closure to construct the contents.
|
/// Creates a window and runs a closure to construct the contents. This internally
|
||||||
|
/// calls `begin` and `end`.
|
||||||
///
|
///
|
||||||
/// Note: the closure is not called if ImPlot::BeginPlot() returned
|
/// Note: the closure is not called if ImPlot::BeginPlot() returned
|
||||||
/// false - TODO(4bb4) figure out if this is if things are not rendered
|
/// false - TODO(4bb4) figure out if this is if things are not rendered
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "BeginPlot"))]
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "EndPlot"))]
|
||||||
pub fn build<F: FnOnce()>(self, plot_ui: &PlotUi, f: F) {
|
pub fn build<F: FnOnce()>(self, plot_ui: &PlotUi, f: F) {
|
||||||
if let Some(token) = self.begin(plot_ui) {
|
if let Some(token) = self.begin(plot_ui) {
|
||||||
f();
|
f();
|
||||||
|
@ -484,6 +491,7 @@ pub struct PlotToken {
|
||||||
|
|
||||||
impl PlotToken {
|
impl PlotToken {
|
||||||
/// End a previously begin()'ed plot.
|
/// End a previously begin()'ed plot.
|
||||||
|
#[rustversion::attr(since(1.48), doc(alias = "EndPlot"))]
|
||||||
pub fn end(mut self) {
|
pub fn end(mut self) {
|
||||||
self.context = std::ptr::null();
|
self.context = std::ptr::null();
|
||||||
unsafe { sys::ImPlot_EndPlot() };
|
unsafe { sys::ImPlot_EndPlot() };
|
||||||
|
|
Loading…
Reference in a new issue