mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
Misc fixes
Mainly changes from newer bindgen
This commit is contained in:
parent
b1150d6c3b
commit
291b7a5b47
@ -16,6 +16,7 @@ exclude = ["third-party/*.json", "third-party/*.lua", "third-party/imgui/*/"]
|
||||
[dependencies]
|
||||
chlorine = "1.0.7"
|
||||
mint = "0.5.6"
|
||||
cfg-if = "1"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
9765
imgui-sys/src/docking_bindings.rs
Normal file
9765
imgui-sys/src/docking_bindings.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,17 +20,29 @@
|
||||
// `libc` has potentially undesirable linking impacts on windows.
|
||||
pub extern crate chlorine as cty;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
mod wasm_bindings;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
pub use crate::wasm_bindings::*;
|
||||
|
||||
#[cfg(not(feature = "wasm"))]
|
||||
mod bindings;
|
||||
|
||||
#[cfg(not(feature = "wasm"))]
|
||||
pub use crate::bindings::*;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "wasm")] {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "docking")] {
|
||||
mod wasm_docking_bindings;
|
||||
pub use crate::wasm_docking_bindings::*;
|
||||
} else {
|
||||
mod wasm_bindings;
|
||||
pub use crate::wasm_bindings::*;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "docking")] {
|
||||
mod docking_bindings;
|
||||
pub use crate::docking_bindings::*;
|
||||
} else {
|
||||
mod bindings;
|
||||
pub use crate::bindings::*;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ImVec2 {
|
||||
#[inline]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10948
imgui-sys/src/wasm_docking_bindings.rs
Normal file
10948
imgui-sys/src/wasm_docking_bindings.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,10 +17,12 @@ bitflags = "1"
|
||||
imgui-sys = { version = "0.8.1-alpha.0", path = "../imgui-sys" }
|
||||
mint = "0.5.6"
|
||||
parking_lot = "0.11"
|
||||
cfg-if = "1"
|
||||
|
||||
[features]
|
||||
wasm = ["imgui-sys/wasm"]
|
||||
freetype = ["imgui-sys/freetype"]
|
||||
docking = ["imgui-sys/docking"]
|
||||
# this api is in beta in the upstream imgui crate. See issue #524 for more info.
|
||||
# it should be stable and fine to use though.
|
||||
tables-api = []
|
||||
|
||||
@ -348,7 +348,7 @@ impl<'ui> DrawListMut<'ui> {
|
||||
unsafe {
|
||||
let start = text.as_ptr() as *const c_char;
|
||||
let end = (start as usize + text.len()) as *const c_char;
|
||||
sys::ImDrawList_AddText_Vec2(
|
||||
sys::ImDrawList_AddTextVec2(
|
||||
self.draw_list,
|
||||
pos.into().into(),
|
||||
col.into().into(),
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use bitflags::bitflags;
|
||||
use std::f32;
|
||||
use std::ops::{Index, IndexMut};
|
||||
use std::os::raw::{c_char, c_int, c_void};
|
||||
use std::os::raw::{c_char, c_void};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::fonts::atlas::FontAtlas;
|
||||
@ -234,7 +234,7 @@ pub struct Io {
|
||||
Option<unsafe extern "C" fn(user_data: *mut c_void, text: *const c_char)>,
|
||||
pub(crate) clipboard_user_data: *mut c_void,
|
||||
#[cfg(not(feature="docking"))]
|
||||
ime_set_input_screen_pos_fn: Option<unsafe extern "C" fn(x: c_int, y: c_int)>,
|
||||
ime_set_input_screen_pos_fn: Option<unsafe extern "C" fn(x: std::os::raw::c_int, y: std::os::raw::c_int)>,
|
||||
#[cfg(not(feature="docking"))]
|
||||
ime_window_handle: *mut c_void,
|
||||
/// Mouse position, in pixels.
|
||||
|
||||
@ -302,20 +302,20 @@ impl Id {
|
||||
impl Ui {
|
||||
pub fn new_id(&self, input: usize) -> Id {
|
||||
let p = input as *const std::os::raw::c_void;
|
||||
let value = unsafe { sys::igGetID_Ptr(p) };
|
||||
let value = unsafe { sys::igGetIDPtr(p) };
|
||||
|
||||
Id(value)
|
||||
}
|
||||
|
||||
pub fn new_id_int(&self, input: i32) -> Id {
|
||||
let p = input as *const std::os::raw::c_void;
|
||||
let value = unsafe { sys::igGetID_Ptr(p) };
|
||||
let value = unsafe { sys::igGetIDPtr(p) };
|
||||
Id(value)
|
||||
}
|
||||
|
||||
pub fn new_id_ptr<T>(&self, input: &T) -> Id {
|
||||
let p = input as *const T as *const sys::cty::c_void;
|
||||
let value = unsafe { sys::igGetID_Ptr(p) };
|
||||
let value = unsafe { sys::igGetIDPtr(p) };
|
||||
Id(value)
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ impl Ui {
|
||||
let s1 = s.as_ptr() as *const std::os::raw::c_char;
|
||||
let value = unsafe {
|
||||
let s2 = s1.add(s.len());
|
||||
sys::igGetID_StrStr(s1, s2)
|
||||
sys::igGetIDStrStr(s1, s2)
|
||||
};
|
||||
Id(value)
|
||||
}
|
||||
@ -740,7 +740,7 @@ impl Ui {
|
||||
};
|
||||
|
||||
unsafe {
|
||||
sys::igListBox_Str_arr(
|
||||
sys::igListBoxStr_arr(
|
||||
label_ptr,
|
||||
current_item,
|
||||
items_inner.as_ptr() as *mut *const c_char,
|
||||
|
||||
@ -71,7 +71,7 @@ impl<'ui, 'p, Label: AsRef<str>, Overlay: AsRef<str>> PlotHistogram<'ui, 'p, Lab
|
||||
unsafe {
|
||||
let (label, overlay_text) = self.ui.scratch_txt_with_opt(self.label, self.overlay_text);
|
||||
|
||||
sys::igPlotHistogram_FloatPtr(
|
||||
sys::igPlotHistogramFloatPtr(
|
||||
label,
|
||||
self.values.as_ptr() as *const c_float,
|
||||
self.values.len() as i32,
|
||||
|
||||
@ -71,7 +71,7 @@ impl<'ui, 'p, Label: AsRef<str>, Overlay: AsRef<str>> PlotLines<'ui, 'p, Label,
|
||||
unsafe {
|
||||
let (label, overlay) = self.ui.scratch_txt_with_opt(self.label, self.overlay_text);
|
||||
|
||||
sys::igPlotLines_FloatPtr(
|
||||
sys::igPlotLinesFloatPtr(
|
||||
label,
|
||||
self.values.as_ptr() as *const c_float,
|
||||
self.values.len() as i32,
|
||||
|
||||
@ -157,7 +157,7 @@ impl Ui {
|
||||
/// able to close a popup without selected an option, use [`PopupModal`].
|
||||
#[doc(alias = "OpenPopup")]
|
||||
pub fn open_popup(&self, str_id: impl AsRef<str>) {
|
||||
unsafe { sys::igOpenPopup_Str(self.scratch_txt(str_id), 0) };
|
||||
unsafe { sys::igOpenPopupStr(self.scratch_txt(str_id), 0) };
|
||||
}
|
||||
|
||||
/// Construct a popup that can have any kind of content.
|
||||
|
||||
@ -61,7 +61,7 @@ impl Ui {
|
||||
style_color: StyleColor,
|
||||
color: impl Into<MintVec4>,
|
||||
) -> ColorStackToken<'_> {
|
||||
unsafe { sys::igPushStyleColor_Vec4(style_color as i32, color.into().into()) };
|
||||
unsafe { sys::igPushStyleColorVec4(style_color as i32, color.into().into()) };
|
||||
ColorStackToken::new(self)
|
||||
}
|
||||
|
||||
@ -138,40 +138,40 @@ impl StyleStackToken<'_> {
|
||||
#[inline]
|
||||
unsafe fn push_style_var(style_var: StyleVar) {
|
||||
use crate::style::StyleVar::*;
|
||||
use crate::sys::{igPushStyleVar_Float, igPushStyleVar_Vec2};
|
||||
use crate::sys::{igPushStyleVarFloat, igPushStyleVarVec2};
|
||||
match style_var {
|
||||
Alpha(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_Alpha as i32, v),
|
||||
WindowPadding(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowPadding as i32, v.into()),
|
||||
WindowRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_WindowRounding as i32, v),
|
||||
WindowBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_WindowBorderSize as i32, v),
|
||||
WindowMinSize(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowMinSize as i32, v.into()),
|
||||
Alpha(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_Alpha as i32, v),
|
||||
WindowPadding(v) => igPushStyleVarVec2(sys::ImGuiStyleVar_WindowPadding as i32, v.into()),
|
||||
WindowRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_WindowRounding as i32, v),
|
||||
WindowBorderSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_WindowBorderSize as i32, v),
|
||||
WindowMinSize(v) => igPushStyleVarVec2(sys::ImGuiStyleVar_WindowMinSize as i32, v.into()),
|
||||
WindowTitleAlign(v) => {
|
||||
igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowTitleAlign as i32, v.into())
|
||||
igPushStyleVarVec2(sys::ImGuiStyleVar_WindowTitleAlign as i32, v.into())
|
||||
}
|
||||
ChildRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ChildRounding as i32, v),
|
||||
ChildBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ChildBorderSize as i32, v),
|
||||
PopupRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_PopupRounding as i32, v),
|
||||
PopupBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_PopupBorderSize as i32, v),
|
||||
FramePadding(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_FramePadding as i32, v.into()),
|
||||
FrameRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_FrameRounding as i32, v),
|
||||
FrameBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_FrameBorderSize as i32, v),
|
||||
ItemSpacing(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_ItemSpacing as i32, v.into()),
|
||||
ChildRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_ChildRounding as i32, v),
|
||||
ChildBorderSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_ChildBorderSize as i32, v),
|
||||
PopupRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_PopupRounding as i32, v),
|
||||
PopupBorderSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_PopupBorderSize as i32, v),
|
||||
FramePadding(v) => igPushStyleVarVec2(sys::ImGuiStyleVar_FramePadding as i32, v.into()),
|
||||
FrameRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_FrameRounding as i32, v),
|
||||
FrameBorderSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_FrameBorderSize as i32, v),
|
||||
ItemSpacing(v) => igPushStyleVarVec2(sys::ImGuiStyleVar_ItemSpacing as i32, v.into()),
|
||||
ItemInnerSpacing(v) => {
|
||||
igPushStyleVar_Vec2(sys::ImGuiStyleVar_ItemInnerSpacing as i32, v.into())
|
||||
igPushStyleVarVec2(sys::ImGuiStyleVar_ItemInnerSpacing as i32, v.into())
|
||||
}
|
||||
IndentSpacing(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_IndentSpacing as i32, v),
|
||||
ScrollbarSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ScrollbarSize as i32, v),
|
||||
IndentSpacing(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_IndentSpacing as i32, v),
|
||||
ScrollbarSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_ScrollbarSize as i32, v),
|
||||
ScrollbarRounding(v) => {
|
||||
igPushStyleVar_Float(sys::ImGuiStyleVar_ScrollbarRounding as i32, v)
|
||||
igPushStyleVarFloat(sys::ImGuiStyleVar_ScrollbarRounding as i32, v)
|
||||
}
|
||||
GrabMinSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_GrabMinSize as i32, v),
|
||||
GrabRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_GrabRounding as i32, v),
|
||||
TabRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_TabRounding as i32, v),
|
||||
GrabMinSize(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_GrabMinSize as i32, v),
|
||||
GrabRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_GrabRounding as i32, v),
|
||||
TabRounding(v) => igPushStyleVarFloat(sys::ImGuiStyleVar_TabRounding as i32, v),
|
||||
ButtonTextAlign(v) => {
|
||||
igPushStyleVar_Vec2(sys::ImGuiStyleVar_ButtonTextAlign as i32, v.into())
|
||||
igPushStyleVarVec2(sys::ImGuiStyleVar_ButtonTextAlign as i32, v.into())
|
||||
}
|
||||
SelectableTextAlign(v) => {
|
||||
igPushStyleVar_Vec2(sys::ImGuiStyleVar_SelectableTextAlign as i32, v.into())
|
||||
igPushStyleVarVec2(sys::ImGuiStyleVar_SelectableTextAlign as i32, v.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -466,7 +466,7 @@ impl<'ui> Ui {
|
||||
let s = s.as_ref();
|
||||
let start = s.as_ptr() as *const c_char;
|
||||
let end = start.add(s.len());
|
||||
sys::igPushID_StrStr(start, end)
|
||||
sys::igPushIDStrStr(start, end)
|
||||
}
|
||||
IdStackToken::new(self)
|
||||
}
|
||||
@ -481,7 +481,7 @@ impl<'ui> Ui {
|
||||
/// [push_id]: Self::push_id
|
||||
#[doc(alias = "PushId")]
|
||||
pub fn push_id_usize(&self, id: usize) -> IdStackToken<'_> {
|
||||
unsafe { sys::igPushID_Ptr(id as *const _) }
|
||||
unsafe { sys::igPushIDPtr(id as *const _) }
|
||||
IdStackToken::new(self)
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ impl<'ui> Ui {
|
||||
/// [push_id]: Self::push_id
|
||||
#[doc(alias = "PushId")]
|
||||
pub fn push_id_int(&self, id: i32) -> IdStackToken<'_> {
|
||||
unsafe { sys::igPushID_Int(id) }
|
||||
unsafe { sys::igPushIDInt(id) }
|
||||
IdStackToken::new(self)
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ impl<'ui> Ui {
|
||||
/// [push_id]: Self::push_id
|
||||
#[doc(alias = "PushId")]
|
||||
pub fn push_id_ptr<T>(&self, value: &T) -> IdStackToken<'_> {
|
||||
unsafe { sys::igPushID_Ptr(value as *const T as *const _) }
|
||||
unsafe { sys::igPushIDPtr(value as *const T as *const _) }
|
||||
IdStackToken::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,6 +401,10 @@ impl StyleColor {
|
||||
StyleColor::NavWindowingHighlight => "NavWindowingHighlight",
|
||||
StyleColor::NavWindowingDimBg => "NavWindowingDimBg",
|
||||
StyleColor::ModalWindowDimBg => "ModalWindowDimBg",
|
||||
#[cfg(feature = "docking")]
|
||||
StyleColor::DockingPreview => "DockingPreview",
|
||||
#[cfg(feature = "docking")]
|
||||
StyleColor::DockingEmptyBg => "DockingEmptyBg",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ impl Ui {
|
||||
/// Returns `true` if the rectangle (of given size, starting from cursor position) is visible
|
||||
#[doc(alias = "IsRectVisibleNil")]
|
||||
pub fn is_cursor_rect_visible(&self, size: impl Into<MintVec2>) -> bool {
|
||||
unsafe { sys::igIsRectVisible_Nil(size.into().into()) }
|
||||
unsafe { sys::igIsRectVisibleNil(size.into().into()) }
|
||||
}
|
||||
/// Returns `true` if the rectangle (in screen coordinates) is visible
|
||||
#[doc(alias = "IsRectVisibleNilVec2")]
|
||||
@ -155,7 +155,7 @@ impl Ui {
|
||||
rect_min: impl Into<MintVec2>,
|
||||
rect_max: impl Into<MintVec2>,
|
||||
) -> bool {
|
||||
unsafe { sys::igIsRectVisible_Vec2(rect_min.into().into(), rect_max.into().into()) }
|
||||
unsafe { sys::igIsRectVisibleVec2(rect_min.into().into(), rect_max.into().into()) }
|
||||
}
|
||||
/// Returns the global imgui-rs time.
|
||||
///
|
||||
|
||||
@ -202,7 +202,7 @@ impl<'ui, Label: AsRef<str>, Shortcut: AsRef<str>> MenuItem<'ui, Label, Shortcut
|
||||
pub fn build(self) -> bool {
|
||||
unsafe {
|
||||
let (label, shortcut) = self.ui.scratch_txt_with_opt(self.label, self.shortcut);
|
||||
sys::igMenuItem_Bool(label, shortcut, self.selected, self.enabled)
|
||||
sys::igMenuItemBool(label, shortcut, self.selected, self.enabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ impl Ui {
|
||||
/// Returns true if this radio button was clicked.
|
||||
#[doc(alias = "RadioButtonBool")]
|
||||
pub fn radio_button_bool(&self, label: impl AsRef<str>, active: bool) -> bool {
|
||||
unsafe { sys::igRadioButton_Bool(self.scratch_txt(label), active) }
|
||||
unsafe { sys::igRadioButtonBool(self.scratch_txt(label), active) }
|
||||
}
|
||||
/// Renders a radio button suitable for choosing an arbitrary value.
|
||||
///
|
||||
|
||||
@ -130,7 +130,7 @@ impl<'ui, T: AsRef<str>> Selectable<'ui, T> {
|
||||
/// Returns true if the selectable was clicked.
|
||||
pub fn build(self) -> bool {
|
||||
unsafe {
|
||||
sys::igSelectable_Bool(
|
||||
sys::igSelectableBool(
|
||||
self.ui.scratch_txt(self.label),
|
||||
self.selected,
|
||||
self.flags.bits() as i32,
|
||||
|
||||
@ -296,9 +296,9 @@ impl<'a, T: AsRef<str>, L: AsRef<str>> TreeNode<'a, T, L> {
|
||||
}
|
||||
};
|
||||
|
||||
sys::igTreeNodeEx_StrStr(id, self.flags.bits() as i32, fmt_ptr(), label)
|
||||
sys::igTreeNodeExStrStr(id, self.flags.bits() as i32, fmt_ptr(), label)
|
||||
}
|
||||
TreeNodeId::Ptr(id) => sys::igTreeNodeEx_Ptr(
|
||||
TreeNodeId::Ptr(id) => sys::igTreeNodeExPtr(
|
||||
id,
|
||||
self.flags.bits() as i32,
|
||||
fmt_ptr(),
|
||||
@ -471,7 +471,7 @@ impl<T: AsRef<str>> CollapsingHeader<T> {
|
||||
#[inline]
|
||||
pub fn build(self, ui: &Ui) -> bool {
|
||||
unsafe {
|
||||
sys::igCollapsingHeader_TreeNodeFlags(
|
||||
sys::igCollapsingHeaderTreeNodeFlags(
|
||||
ui.scratch_txt(self.label),
|
||||
self.flags.bits() as i32,
|
||||
)
|
||||
@ -485,7 +485,7 @@ impl<T: AsRef<str>> CollapsingHeader<T> {
|
||||
#[inline]
|
||||
pub fn build_with_close_button(self, ui: &Ui, opened: &mut bool) -> bool {
|
||||
unsafe {
|
||||
sys::igCollapsingHeader_BoolPtr(
|
||||
sys::igCollapsingHeaderBoolPtr(
|
||||
ui.scratch_txt(self.label),
|
||||
opened as *mut bool,
|
||||
self.flags.bits() as i32,
|
||||
|
||||
@ -266,7 +266,7 @@ impl<'ui> ChildWindow<'ui> {
|
||||
unsafe { sys::igSetNextWindowBgAlpha(self.bg_alpha) };
|
||||
}
|
||||
let should_render = unsafe {
|
||||
sys::igBeginChild_ID(
|
||||
sys::igBeginChildID(
|
||||
self.id,
|
||||
self.size.into(),
|
||||
self.border,
|
||||
|
||||
@ -36,7 +36,8 @@ impl Ui {
|
||||
out.into()
|
||||
}
|
||||
#[doc(alias = "GetContentRegionWidth")]
|
||||
#[deprecated(note = "Removed in Dear ImGui 1.85, 'not very useful in practice' and can be done with window_content_region_min/_max")]
|
||||
pub fn window_content_region_width(&self) -> f32 {
|
||||
unsafe { sys::igGetWindowContentRegionWidth() }
|
||||
self.window_content_region_max()[0] - self.window_content_region_min()[0]
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ use crate::sys;
|
||||
use crate::Ui;
|
||||
|
||||
/// # Window scrolling
|
||||
impl<'ui> Ui<'ui> {
|
||||
impl<'ui> Ui {
|
||||
/// Returns the horizontal scrolling position.
|
||||
///
|
||||
/// Value is between 0.0 and self.scroll_max_x().
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user