diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index bf7cff1..635dad8 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,6 +2,11 @@ ## [Unreleased] +### Changed + +- Upgrade to cimgui 1.65.2 / imgui 1.65. **This is a very big update, so there + are a lot of breaking changes** + ## [0.0.21] - 2018-10-11 ### Added diff --git a/README.markdown b/README.markdown index 59f5690..4879639 100644 --- a/README.markdown +++ b/README.markdown @@ -4,6 +4,8 @@ Minimum Rust version: 1.26 +Wrapped Dear ImGui version: 1.65 + [![Build Status](https://travis-ci.org/Gekkio/imgui-rs.svg?branch=master)](https://travis-ci.org/Gekkio/imgui-rs) [![Latest release on crates.io](https://meritbadge.herokuapp.com/imgui)](https://crates.io/crates/imgui) [![Documentation on docs.rs](https://docs.rs/imgui/badge.svg)](https://docs.rs/imgui) @@ -84,7 +86,7 @@ Licensed under either of at your option. -Uses [ImGui](https://github.com/ocornut/imgui) and [cimgui](https://github.com/Extrawurst/cimgui). +Uses [ImGui](https://github.com/ocornut/imgui) and [cimgui](https://github.com/cimgui/cimgui). ### Contribution diff --git a/hello_world.png b/hello_world.png index 886b902..ccfbee7 100644 Binary files a/hello_world.png and b/hello_world.png differ diff --git a/imgui-examples/examples/color_button.rs b/imgui-examples/examples/color_button.rs index 6a0a3d7..41f2215 100644 --- a/imgui-examples/examples/color_button.rs +++ b/imgui-examples/examples/color_button.rs @@ -145,7 +145,7 @@ fn example_2(ui: &Ui) { im_str!("Red + ColorPreview::HalfAlpha"), (1.0, 0.0, 0.0, 0.5), ).preview(ColorPreview::HalfAlpha) - .build(); + .build(); ui.separator(); ui.text_wrapped(im_str!( diff --git a/imgui-examples/examples/support/mod.rs b/imgui-examples/examples/support/mod.rs index 2a81d71..5ad2eb0 100644 --- a/imgui-examples/examples/support/mod.rs +++ b/imgui-examples/examples/support/mod.rs @@ -30,9 +30,17 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ let font_size = (13.0 * hidpi_factor) as f32; + imgui.fonts().add_default_font_with_config( + ImFontConfig::new() + .oversample_h(1) + .pixel_snap_h(true) + .size_pixels(font_size), + ); + imgui.fonts().add_font_with_config( include_bytes!("../mplus-1p-regular.ttf"), ImFontConfig::new() + .merge_mode(true) .oversample_h(1) .pixel_snap_h(true) .size_pixels(font_size) @@ -40,14 +48,6 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ &FontGlyphRange::japanese(), ); - imgui.fonts().add_default_font_with_config( - ImFontConfig::new() - .merge_mode(true) - .oversample_h(1) - .pixel_snap_h(true) - .size_pixels(font_size), - ); - imgui.set_font_global_scale((1.0 / hidpi_factor) as f32); let mut renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer"); @@ -155,11 +155,12 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"), ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow, ImGuiMouseCursor::TextInput => glutin::MouseCursor::Text, - ImGuiMouseCursor::Move => glutin::MouseCursor::Move, + ImGuiMouseCursor::ResizeAll => glutin::MouseCursor::Move, ImGuiMouseCursor::ResizeNS => glutin::MouseCursor::NsResize, ImGuiMouseCursor::ResizeEW => glutin::MouseCursor::EwResize, ImGuiMouseCursor::ResizeNESW => glutin::MouseCursor::NeswResize, ImGuiMouseCursor::ResizeNWSE => glutin::MouseCursor::NwseResize, + ImGuiMouseCursor::Hand => glutin::MouseCursor::Hand, }); } diff --git a/imgui-examples/examples/support_gfx/mod.rs b/imgui-examples/examples/support_gfx/mod.rs index e867f47..8f97e3a 100644 --- a/imgui-examples/examples/support_gfx/mod.rs +++ b/imgui-examples/examples/support_gfx/mod.rs @@ -66,9 +66,17 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ let font_size = (13.0 * hidpi_factor) as f32; + imgui.fonts().add_default_font_with_config( + ImFontConfig::new() + .oversample_h(1) + .pixel_snap_h(true) + .size_pixels(font_size), + ); + imgui.fonts().add_font_with_config( include_bytes!("../mplus-1p-regular.ttf"), ImFontConfig::new() + .merge_mode(true) .oversample_h(1) .pixel_snap_h(true) .size_pixels(font_size) @@ -76,14 +84,6 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ &FontGlyphRange::japanese(), ); - imgui.fonts().add_default_font_with_config( - ImFontConfig::new() - .merge_mode(true) - .oversample_h(1) - .pixel_snap_h(true) - .size_pixels(font_size), - ); - imgui.set_font_global_scale((1.0 / hidpi_factor) as f32); let mut renderer = Renderer::init(&mut imgui, &mut factory, shaders, main_color.clone()) @@ -199,11 +199,12 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"), ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow, ImGuiMouseCursor::TextInput => glutin::MouseCursor::Text, - ImGuiMouseCursor::Move => glutin::MouseCursor::Move, + ImGuiMouseCursor::ResizeAll => glutin::MouseCursor::Move, ImGuiMouseCursor::ResizeNS => glutin::MouseCursor::NsResize, ImGuiMouseCursor::ResizeEW => glutin::MouseCursor::EwResize, ImGuiMouseCursor::ResizeNESW => glutin::MouseCursor::NeswResize, ImGuiMouseCursor::ResizeNWSE => glutin::MouseCursor::NwseResize, + ImGuiMouseCursor::Hand => glutin::MouseCursor::Hand, }); } diff --git a/imgui-examples/examples/test_drawing_channels_split.rs b/imgui-examples/examples/test_drawing_channels_split.rs index d38d8b8..fc3c491 100644 --- a/imgui-examples/examples/test_drawing_channels_split.rs +++ b/imgui-examples/examples/test_drawing_channels_split.rs @@ -29,8 +29,7 @@ fn main() { canvas_pos, [canvas_pos.0 + RADIUS, canvas_pos.1 + RADIUS], RED, - ) - .thickness(5.0) + ).thickness(5.0) .build(); channels.set_current(0); diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 979f840..2778d5b 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -778,7 +778,7 @@ fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) { ui.checkbox(im_str!("Check"), &mut state.b); }); ui.menu(im_str!("Colors")).build(|| { - for &col in ImGuiCol::values() { + for &col in ImGuiCol::VARIANTS.iter() { ui.menu_item(imgui::get_style_color_name(col)).build(); } }); @@ -879,8 +879,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz * 0.5, y + state.sz * 0.5), state.sz * 0.5, state.col, - ) - .num_segments(20) + ).num_segments(20) .thickness(thickness) .build(); x += state.sz + spacing; @@ -909,8 +908,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz, y + state.sz - 0.5), (x, y + state.sz - 0.5), state.col, - ) - .thickness(thickness) + ).thickness(thickness) .build(); x += state.sz + spacing; draw_list @@ -935,8 +933,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz - state.sz * 1.3, y + state.sz - state.sz * 0.3), (x + state.sz, y + state.sz), state.col, - ) - .thickness(thickness) + ).thickness(thickness) .build(); y += state.sz + spacing; } @@ -946,8 +943,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz * 0.5, y + state.sz * 0.5), state.sz * 0.5, state.col, - ) - .num_segments(32) + ).num_segments(32) .filled(true) .build(); x += state.sz + spacing; @@ -976,8 +972,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz, y + state.sz - 0.5), (x, y + state.sz - 0.5), state.col, - ) - .filled(true) + ).filled(true) .build(); x += state.sz + spacing; const MULTICOLOR_RECT_CORNER_COLOR1: [f32; 3] = [0.0, 0.0, 0.0]; @@ -1046,8 +1041,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, canvas_pos, (canvas_pos.0 + canvas_size.0, canvas_pos.1 + canvas_size.1), CANVAS_BORDER_COLOR, - ) - .build(); + ).build(); let mut adding_preview = false; ui.invisible_button(im_str!("canvas"), canvas_size); @@ -1088,8 +1082,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (canvas_pos.0 + p1.0, canvas_pos.1 + p1.1), (canvas_pos.0 + p2.0, canvas_pos.1 + p2.1), LINE_COLOR, - ) - .thickness(2.0) + ).thickness(2.0) .build(); } }, diff --git a/imgui-gfx-renderer/src/lib.rs b/imgui-gfx-renderer/src/lib.rs index 97437cc..85a27f6 100644 --- a/imgui-gfx-renderer/src/lib.rs +++ b/imgui-gfx-renderer/src/lib.rs @@ -4,11 +4,11 @@ extern crate imgui; use gfx::handle::{Buffer, RenderTargetView}; use gfx::memory::Bind; +use gfx::pso::{PipelineData, PipelineState}; use gfx::texture::{FilterMethod, SamplerInfo, WrapMode}; use gfx::traits::FactoryExt; use gfx::{CommandBuffer, Encoder, Factory, IntoIndexBuffer, Rect, Resources, Slice}; -use gfx::pso::{PipelineData, PipelineState}; -use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, Ui, Textures, ImTexture}; +use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, ImTexture, Textures, Ui}; pub type RendererResult = Result; @@ -131,7 +131,10 @@ impl Shaders { } } -pub type Texture = (gfx::handle::ShaderResourceView, gfx::handle::Sampler); +pub type Texture = ( + gfx::handle::ShaderResourceView, + gfx::handle::Sampler, +); pub struct Renderer { bundle: Bundle>, @@ -254,7 +257,9 @@ impl Renderer { self.bundle.slice.start = 0; for cmd in draw_list.cmd_buffer { let texture_id = cmd.texture_id.into(); - let tex = self.textures.get(texture_id) + let tex = self + .textures + .get(texture_id) .ok_or_else(|| RendererError::BadTexture(texture_id))?; self.bundle.slice.end = self.bundle.slice.start + cmd.elem_count; diff --git a/imgui-glium-renderer/src/lib.rs b/imgui-glium-renderer/src/lib.rs index 9091103..c17874e 100644 --- a/imgui-glium-renderer/src/lib.rs +++ b/imgui-glium-renderer/src/lib.rs @@ -8,7 +8,7 @@ use glium::program; use glium::texture; use glium::vertex; use glium::{DrawError, IndexBuffer, Program, Surface, Texture2d, VertexBuffer}; -use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, Ui, Textures, ImTexture}; +use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, ImTexture, Textures, Ui}; use std::borrow::Cow; use std::fmt; use std::rc::Rc; @@ -137,7 +137,10 @@ impl Renderer { let mut idx_start = 0; for cmd in draw_list.cmd_buffer { let texture_id = cmd.texture_id.into(); - let texture = self.device_objects.textures.get(texture_id) + let texture = self + .device_objects + .textures + .get(texture_id) .ok_or_else(|| RendererError::BadTexture(texture_id))?; let idx_end = idx_start + cmd.elem_count as usize; diff --git a/imgui-glutin-support/src/lib.rs b/imgui-glutin-support/src/lib.rs index 7372ef5..bd3efc9 100644 --- a/imgui-glutin-support/src/lib.rs +++ b/imgui-glutin-support/src/lib.rs @@ -210,11 +210,12 @@ pub fn update_mouse_cursor(imgui: &ImGui, window: &Window) { ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"), ImGuiMouseCursor::Arrow => MouseCursor::Arrow, ImGuiMouseCursor::TextInput => MouseCursor::Text, - ImGuiMouseCursor::Move => MouseCursor::Move, + ImGuiMouseCursor::ResizeAll => MouseCursor::Move, ImGuiMouseCursor::ResizeNS => MouseCursor::NsResize, ImGuiMouseCursor::ResizeEW => MouseCursor::EwResize, ImGuiMouseCursor::ResizeNESW => MouseCursor::NeswResize, ImGuiMouseCursor::ResizeNWSE => MouseCursor::NwseResize, + ImGuiMouseCursor::Hand => MouseCursor::Hand, }); } } diff --git a/imgui-sys/build.rs b/imgui-sys/build.rs index bc13450..1502302 100644 --- a/imgui-sys/build.rs +++ b/imgui-sys/build.rs @@ -3,12 +3,10 @@ extern crate cc; fn main() { cc::Build::new() .cpp(true) - .file("third-party/cimgui/cimgui/cimgui.cpp") - .file("third-party/cimgui/cimgui/fontAtlas.cpp") - .file("third-party/cimgui/cimgui/drawList.cpp") - .file("third-party/cimgui/cimgui/listClipper.cpp") + .file("third-party/cimgui/cimgui.cpp") .file("third-party/cimgui/imgui/imgui.cpp") .file("third-party/cimgui/imgui/imgui_demo.cpp") .file("third-party/cimgui/imgui/imgui_draw.cpp") + .file("third-party/cimgui/imgui/imgui_widgets.cpp") .compile("libcimgui.a"); } diff --git a/imgui-sys/src/enums.rs b/imgui-sys/src/enums.rs new file mode 100644 index 0000000..5163579 --- /dev/null +++ b/imgui-sys/src/enums.rs @@ -0,0 +1,430 @@ +/// A color identifier for styling +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiCol { + Text, + TextDisabled, + /// Background of normal windows + WindowBg, + /// Background of child windows + ChildBg, + /// Background of popups, menus, tooltips windows + PopupBg, + Border, + BorderShadow, + /// Background of checkbox, radio button, plot, slider, text input + FrameBg, + FrameBgHovered, + FrameBgActive, + TitleBg, + TitleBgActive, + TitleBgCollapsed, + MenuBarBg, + ScrollbarBg, + ScrollbarGrab, + ScrollbarGrabHovered, + ScrollbarGrabActive, + CheckMark, + SliderGrab, + SliderGrabActive, + Button, + ButtonHovered, + ButtonActive, + Header, + HeaderHovered, + HeaderActive, + Separator, + SeparatorHovered, + SeparatorActive, + ResizeGrip, + ResizeGripHovered, + ResizeGripActive, + PlotLines, + PlotLinesHovered, + PlotHistogram, + PlotHistogramHovered, + TextSelectedBg, + DragDropTarget, + /// Gamepad/keyboard: current highlighted item + NavHighlight, + /// Highlight window when using CTRL+TAB + NavWindowingHighlight, + /// Darken/colorize entire screen behind the CTRL+TAB window list, when active + NavWindowingDimBg, + /// Darken/colorize entire screen behind a modal window, when one is active + ModalWindowDimBg, +} +impl ImGuiCol { + /// All possible `ImGuiCol` variants + pub const VARIANTS: [ImGuiCol; 43] = [ + ImGuiCol::Text, + ImGuiCol::TextDisabled, + ImGuiCol::WindowBg, + ImGuiCol::ChildBg, + ImGuiCol::PopupBg, + ImGuiCol::Border, + ImGuiCol::BorderShadow, + ImGuiCol::FrameBg, + ImGuiCol::FrameBgHovered, + ImGuiCol::FrameBgActive, + ImGuiCol::TitleBg, + ImGuiCol::TitleBgActive, + ImGuiCol::TitleBgCollapsed, + ImGuiCol::MenuBarBg, + ImGuiCol::ScrollbarBg, + ImGuiCol::ScrollbarGrab, + ImGuiCol::ScrollbarGrabHovered, + ImGuiCol::ScrollbarGrabActive, + ImGuiCol::CheckMark, + ImGuiCol::SliderGrab, + ImGuiCol::SliderGrabActive, + ImGuiCol::Button, + ImGuiCol::ButtonHovered, + ImGuiCol::ButtonActive, + ImGuiCol::Header, + ImGuiCol::HeaderHovered, + ImGuiCol::HeaderActive, + ImGuiCol::Separator, + ImGuiCol::SeparatorHovered, + ImGuiCol::SeparatorActive, + ImGuiCol::ResizeGrip, + ImGuiCol::ResizeGripHovered, + ImGuiCol::ResizeGripActive, + ImGuiCol::PlotLines, + ImGuiCol::PlotLinesHovered, + ImGuiCol::PlotHistogram, + ImGuiCol::PlotHistogramHovered, + ImGuiCol::TextSelectedBg, + ImGuiCol::DragDropTarget, + ImGuiCol::NavHighlight, + ImGuiCol::NavWindowingHighlight, + ImGuiCol::NavWindowingDimBg, + ImGuiCol::ModalWindowDimBg, + ]; + pub const COUNT: usize = 43; + #[deprecated( + since = "0.0.21", + note = "please use ImGuiCol::ModalWindowDimBg instead" + )] + pub const ModalWindowDarkening: ImGuiCol = ImGuiCol::ModalWindowDimBg; + #[deprecated( + since = "0.0.21", + note = "please use ImGuiCol::VARIANTS instead" + )] + pub fn values() -> &'static [ImGuiCol] { + &ImGuiCol::VARIANTS + } +} +#[deprecated( + since = "0.0.21", + note = "please use ImGuiCol::COUNT instead" +)] +pub const ImGuiCol_COUNT: usize = 43; + +/// A primary data type +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiDataType { + /// `i32` (C data type `int`) + S32, + /// `u32` (C data type `unsigned int`) + U32, + /// `i64` (C data type `long long`, `__int64`) + S64, + /// `u64` (C data type `unsigned long long`, `unsigned __int64`) + U64, + /// `f32` (C data type `float`) + Float, + /// `f64` (C data type `double`) + Double, +} +impl ImGuiDataType { + /// All possible `ImGuiDataType` variants + pub const VARIANTS: [ImGuiDataType; 6] = [ + ImGuiDataType::S32, + ImGuiDataType::U32, + ImGuiDataType::S64, + ImGuiDataType::U64, + ImGuiDataType::Float, + ImGuiDataType::Double, + ]; +} + +/// A cardinal direction +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiDir { + None = -1, + Left = 0, + Right, + Up, + Down, +} +impl ImGuiDir { + /// All possible `ImGuiDir` variants, except None + pub const VARIANTS: [ImGuiDir; 4] = [ + // None variant intentionally skipped + ImGuiDir::Left, + ImGuiDir::Right, + ImGuiDir::Up, + ImGuiDir::Down, + ]; +} + +/// A key identifier (ImGui-side enum) +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiKey { + Tab, + LeftArrow, + RightArrow, + UpArrow, + DownArrow, + PageUp, + PageDown, + Home, + End, + Insert, + Delete, + Backspace, + Space, + Enter, + Escape, + /// for text edit CTRL+A: select all + A, + /// for text edit CTRL+C: copy + C, + /// for text edit CTRL+V: paste + V, + /// for text edit CTRL+X: cut + X, + /// for text edit CTRL+Y: redo + Y, + /// for text edit CTRL+Z: undo + Z, +} +impl ImGuiKey { + /// All possible `ImGuiKey` variants + pub const VARIANTS: [ImGuiKey; 21] = [ + ImGuiKey::Tab, + ImGuiKey::LeftArrow, + ImGuiKey::RightArrow, + ImGuiKey::UpArrow, + ImGuiKey::DownArrow, + ImGuiKey::PageUp, + ImGuiKey::PageDown, + ImGuiKey::Home, + ImGuiKey::End, + ImGuiKey::Insert, + ImGuiKey::Delete, + ImGuiKey::Backspace, + ImGuiKey::Space, + ImGuiKey::Enter, + ImGuiKey::Escape, + ImGuiKey::A, + ImGuiKey::C, + ImGuiKey::V, + ImGuiKey::X, + ImGuiKey::Y, + ImGuiKey::Z, + ]; + pub const COUNT: usize = 21; +} +#[deprecated( + since = "0.0.21", + note = "please use ImGuiKey::COUNT instead" +)] +pub const ImGuiKey_COUNT: usize = 21; + +/// A mouse cursor identifier +/// +/// User code may request binding to display given cursor, which is why we have some cursors that +/// are marked unused here +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiMouseCursor { + None = -1, + Arrow = 0, + /// When hovering over InputText, etc. + TextInput, + /// (Unused by imgui functions) + ResizeAll, + /// When hovering over an horizontal border + ResizeNS, + /// When hovering over a vertical border or a column + ResizeEW, + /// When hovering over the bottom-left corner of a window + ResizeNESW, + /// When hovering over the bottom-right corner of a window + ResizeNWSE, + /// (Unused by imgui functions. Use for e.g. hyperlinks) + Hand, +} +impl ImGuiMouseCursor { + /// All possible `ImGuiMouseCursor` variants, except None + pub const VARIANTS: [ImGuiMouseCursor; 8] = [ + // None variant intentionally skipped + ImGuiMouseCursor::Arrow, + ImGuiMouseCursor::TextInput, + ImGuiMouseCursor::ResizeAll, + ImGuiMouseCursor::ResizeNS, + ImGuiMouseCursor::ResizeEW, + ImGuiMouseCursor::ResizeNESW, + ImGuiMouseCursor::ResizeNWSE, + ImGuiMouseCursor::Hand, + ]; +} +#[deprecated( + since = "0.0.21", + note = "please use ImGuiMouseCursor::VARIANTS.len() instead" +)] +pub const ImGuiMouseCursor_COUNT: usize = 8; + +/// An input identifier for navigation +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiNavInput { + /// activate / open / toggle / tweak value + /// + /// e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard) + Activate, + /// cancel / close / exit + /// + /// e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard) + Cancel, + /// text input / on-screen keyboard + /// + /// e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard) + Input, + /// tap: toggle menu / hold: focus, move, resize + /// + /// e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard) + Menu, + /// move / tweak / resize window (w/ PadMenu) + /// + /// e.g. D-pad Left (Gamepads), Left arrow (Keyboard) + DpadLeft, + /// move / tweak / resize window (w/ PadMenu) + /// + /// e.g. D-pad Right (Gamepads), Right arrow (Keyboard) + DpadRight, + /// move / tweak / resize window (w/ PadMenu) + /// + /// e.g. D-pad Up (Gamepads), Up arrow (Keyboard) + DpadUp, + /// move / tweak / resize window (w/ PadMenu) + /// + /// e.g. D-pad Down (Gamepads), Down arrow (Keyboard) + DpadDown, + /// scroll / move window (w/ PadMenu) + /// + /// e.g. Left Analog Stick Left + LStickLeft, + /// scroll / move window (w/ PadMenu) + /// + /// e.g. Left Analog Stick Right + LStickRight, + /// scroll / move window (w/ PadMenu) + /// + /// e.g. Left Analog Stick Up + LStickUp, + /// scroll / move window (w/ PadMenu) + /// + /// e.g. Left Analog Stick Down + LStickDown, + /// next window (w/ PadMenu) + /// + /// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) + FocusPrev, + /// prev window (w/ PadMenu) + /// + /// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) + FocusNext, + /// slower tweaks + /// + /// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) + TweakSlow, + /// faster tweaks + /// + /// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) + TweakFast, +} +impl ImGuiNavInput { + /// All possible `ImGuiNavInput` variants + pub const VARIANTS: [ImGuiNavInput; 16] = [ + ImGuiNavInput::Activate, + ImGuiNavInput::Cancel, + ImGuiNavInput::Input, + ImGuiNavInput::Menu, + ImGuiNavInput::DpadLeft, + ImGuiNavInput::DpadRight, + ImGuiNavInput::DpadUp, + ImGuiNavInput::DpadDown, + ImGuiNavInput::LStickLeft, + ImGuiNavInput::LStickRight, + ImGuiNavInput::LStickUp, + ImGuiNavInput::LStickDown, + ImGuiNavInput::FocusPrev, + ImGuiNavInput::FocusNext, + ImGuiNavInput::TweakSlow, + ImGuiNavInput::TweakFast, + ]; + pub const COUNT: usize = 16; +} + +/// A variable identifier for styling +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum ImGuiStyleVar { + Alpha, + WindowPadding, + WindowRounding, + WindowBorderSize, + WindowMinSize, + WindowTitleAlign, + ChildRounding, + ChildBorderSize, + PopupRounding, + PopupBorderSize, + FramePadding, + FrameRounding, + FrameBorderSize, + ItemSpacing, + ItemInnerSpacing, + IndentSpacing, + ScrollbarSize, + ScrollbarRounding, + GrabMinSize, + GrabRounding, + ButtonTextAlign, +} +impl ImGuiStyleVar { + pub const VARIANTS: [ImGuiStyleVar; 21] = [ + ImGuiStyleVar::Alpha, + ImGuiStyleVar::WindowPadding, + ImGuiStyleVar::WindowRounding, + ImGuiStyleVar::WindowBorderSize, + ImGuiStyleVar::WindowMinSize, + ImGuiStyleVar::WindowTitleAlign, + ImGuiStyleVar::ChildRounding, + ImGuiStyleVar::ChildBorderSize, + ImGuiStyleVar::PopupRounding, + ImGuiStyleVar::PopupBorderSize, + ImGuiStyleVar::FramePadding, + ImGuiStyleVar::FrameRounding, + ImGuiStyleVar::FrameBorderSize, + ImGuiStyleVar::ItemSpacing, + ImGuiStyleVar::ItemInnerSpacing, + ImGuiStyleVar::IndentSpacing, + ImGuiStyleVar::ScrollbarSize, + ImGuiStyleVar::ScrollbarRounding, + ImGuiStyleVar::GrabMinSize, + ImGuiStyleVar::GrabRounding, + ImGuiStyleVar::ButtonTextAlign, + ]; +} +#[deprecated( + since = "0.0.21", + note = "please use ImGuiStyleVar::VARIANTS.len() instead" +)] +pub const ImGuiStyleVar_COUNT: usize = 21; diff --git a/imgui-sys/src/flags.rs b/imgui-sys/src/flags.rs new file mode 100644 index 0000000..fb21235 --- /dev/null +++ b/imgui-sys/src/flags.rs @@ -0,0 +1,409 @@ +use std::os::raw::c_int; + +bitflags!( + /// Back-end capability flags + #[repr(C)] + pub struct ImGuiBackendFlags: c_int { + /// Back-end supports gamepad and currently has one connected. + const HasGamepad = 1; + /// Back-end supports honoring GetMouseCursor() value to change the OS cursor shape. + const HasMouseCursors = 1 << 1; + /// Back-end supports want_set_mouse_pos requests to reposition the OS mouse position. + const HasSetMousePos = 1 << 2; + } +); + +bitflags!( + /// Color edit flags + #[repr(C)] + pub struct ImGuiColorEditFlags: c_int { + /// ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the + /// input pointer). + const NoAlpha = 1; + /// ColorEdit: disable picker when clicking on colored square. + const NoPicker = 1 << 2; + /// ColorEdit: disable toggling options menu when right-clicking on inputs/small preview. + const NoOptions = 1 << 3; + /// ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to + /// show only the inputs) + const NoSmallPreview = 1 << 4; + /// ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the + /// small preview colored square). + const NoInputs = 1 << 5; + /// ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview. + const NoTooltip = 1 << 6; + /// ColorEdit, ColorPicker: disable display of inline text label (the label is still + /// forwarded to the tooltip and picker). + const NoLabel = 1 << 7; + /// ColorPicker: disable bigger color preview on right side of the picker, use small + /// colored square preview instead. + const NoSidePreview = 1 << 8; + /// ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source. + const NoDragDrop = 1 << 9; + + /// ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker. + const AlphaBar = 1 << 16; + /// ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a + /// checkerboard, instead of opaque. + const AlphaPreview = 1 << 17; + /// ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead + /// of opaque. + const AlphaPreviewHalf= 1 << 18; + /// (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you + /// probably want to use ImGuiColorEditFlags::Float flag as well). + const HDR = 1 << 19; + /// ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using + /// RGB/HSV/HEX. + const RGB = 1 << 20; + const HSV = 1 << 21; + const HEX = 1 << 22; + /// ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255. + const Uint8 = 1 << 23; + /// ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats + /// instead of 0..255 integers. No round-trip of value via integers. + const Float = 1 << 24; + /// ColorPicker: bar for Hue, rectangle for Sat/Value. + const PickerHueBar = 1 << 25; + /// ColorPicker: wheel for Hue, triangle for Sat/Value. + const PickerHueWheel = 1 << 26; + } +); + +bitflags!( + /// Flags for combo boxes + #[repr(C)] + pub struct ImGuiComboFlags: c_int { + /// Align the popup toward the left by default + const PopupAlignLeft = 1; + /// Max ~4 items visible. + const HeightSmall = 1 << 1; + /// Max ~8 items visible (default) + const HeightRegular = 1 << 2; + /// Max ~20 items visible + const HeightLarge = 1 << 3; + /// As many fitting items as possible + const HeightLargest = 1 << 4; + /// Display on the preview box without the square arrow button + const NoArrowButton = 1 << 5; + /// Display only a square arrow button + const NoPreview = 1 << 6; + + const HeightMask = ImGuiComboFlags::HeightSmall.bits + | ImGuiComboFlags::HeightRegular.bits + | ImGuiComboFlags::HeightLarge.bits + | ImGuiComboFlags::HeightLargest.bits; + } +); + +bitflags!( + /// Condition flags + #[repr(C)] + pub struct ImGuiCond: c_int { + /// Set the variable + const Always = 1; + /// Set the variable once per runtime session (only the first call with succeed) + const Once = 1 << 1; + /// Set the variable if the object/window has no persistently saved data (no entry in .ini + /// file) + const FirstUseEver = 1 << 2; + /// Set the variable if the object/window is appearing after being hidden/inactive (or the + /// first time) + const Appearing = 1 << 3; + } +); + +bitflags!( + /// Configuration flags + #[repr(C)] + pub struct ImGuiConfigFlags: c_int { + /// Master keyboard navigation enable flag. + const NavEnableKeyboard = 1; + /// Master gamepad navigation enable flag. + const NavEnableGamepad = 1 << 1; + /// Instruct navigation to move the mouse cursor. May be useful on TV/console systems where + /// moving a virtual mouse is awkward. + const NavEnableSetMousePos = 1 << 2; + /// Instruct navigation to not set the want_capture_keyboard flag when nav_active is set. + const NavNoCaptureKeyboard = 1 << 3; + /// Instruct imgui to clear mouse position/buttons on a new frame. This allows ignoring the + /// mouse information set by the back-end. + const NoMouse = 1 << 4; + /// Instruct back-end to not alter mouse cursor shape and visibility. + const NoMouseCursorChange = 1 << 5; + /// Application is SRGB-aware. + const IsSRGB = 1 << 20; + /// Application is using a touch screen instead of a mouse. + const IsTouchScreen = 1 << 21; + } +); + +bitflags!( + /// Flags for igBeginDragDropSource(), igAcceptDragDropPayload() + #[repr(C)] + pub struct ImGuiDragDropFlags: c_int { + /// By default, a successful call to igBeginDragDropSource opens a tooltip so you can + /// display a preview or description of the source contents. This flag disable this + /// behavior. + const SourceNoPreviewTooltip = 1; + /// By default, when dragging we clear data so that igIsItemHovered() will return false, to + /// avoid subsequent user code submitting tooltips. This flag disable this behavior so you + /// can still call igIsItemHovered() on the source item. + const SourceNoDisableHover = 1 << 1; + /// Disable the behavior that allows to open tree nodes and collapsing header by holding + /// over them while dragging a source item. + const SourceNoHoldToOpenOthers = 1 << 2; + /// Allow items such as igText(), igImage() that have no unique identifier to be used as + /// drag source, by manufacturing a temporary identifier based on their window-relative + /// position. This is extremely unusual within the dear imgui ecosystem and so we made it + /// explicit. + const SourceAllowNullID = 1 << 3; + /// External source (from outside of imgui), won't attempt to read current item/window + /// info. Will always return true. Only one Extern source can be active simultaneously. + const SourceExtern = 1 << 4; + /// Automatically expire the payload if the source cease to be submitted (otherwise + /// payloads are persisting while being dragged) + const SourceAutoExpirePayload = 1 << 5; + /// igAcceptDragDropPayload() will returns true even before the mouse button is released. + /// You can then call igIsDelivery() to test if the payload needs to be delivered. + const AcceptBeforeDelivery = 1 << 10; + /// Do not draw the default highlight rectangle when hovering over target. + const AcceptNoDrawDefaultRect = 1 << 11; + /// Request hiding the igBeginDragDropSource tooltip from the igBeginDragDropTarget site. + const AcceptNoPreviewTooltip = 1 << 12; + /// For peeking ahead and inspecting the payload before delivery. + const AcceptPeekOnly = ImGuiDragDropFlags::AcceptBeforeDelivery.bits + | ImGuiDragDropFlags::AcceptNoDrawDefaultRect.bits; + } +); + +bitflags!( + /// Flags for indictating which corner of a rectangle should be rounded + #[repr(C)] + pub struct ImDrawCornerFlags: c_int { + const TopLeft = 1; + const TopRight = 1 << 1; + const BotLeft = 1 << 2; + const BotRight = 1 << 3; + const Top = ImDrawCornerFlags::TopLeft.bits + | ImDrawCornerFlags::TopRight.bits; + const Bot = ImDrawCornerFlags::BotLeft.bits + | ImDrawCornerFlags::BotRight.bits; + const Left = ImDrawCornerFlags::TopLeft.bits + | ImDrawCornerFlags::BotLeft.bits; + const Right = ImDrawCornerFlags::TopRight.bits + | ImDrawCornerFlags::BotRight.bits; + const All = 0xF; + } +); + +bitflags!( + /// Draw list flags + #[repr(C)] + pub struct ImDrawListFlags: c_int { + const AntiAliasedLines = 1; + const AntiAliasedFill = 1 << 1; + } +); + +bitflags!( + /// Flags for window focus checks + #[repr(C)] + pub struct ImGuiFocusedFlags: c_int { + /// Return true if any children of the window is focused + const ChildWindows = 1; + /// Test from root window (top most parent of the current hierarchy) + const RootWindow = 1 << 1; + /// Return true if any window is focused + const AnyWindow = 1 << 2; + + const RootAndChildWindows = + ImGuiFocusedFlags::RootWindow.bits | ImGuiFocusedFlags::ChildWindows.bits; + } +); + +bitflags!( + /// Flags for font atlases + #[repr(C)] + pub struct ImFontAtlasFlags: c_int { + /// Don't round the height to next power of two + const NoPowerOfTwoHeight = 1; + /// Don't build software mouse cursors into the atlas + const NoMouseCursors = 1 << 1; + } +); + +bitflags!( + /// Flags for hover checks + #[repr(C)] + pub struct ImGuiHoveredFlags: c_int { + /// Window hover checks only: Return true if any children of the window is hovered + const ChildWindows = 1; + /// Window hover checks only: Test from root window (top most parent of the current hierarchy) + const RootWindow = 1 << 1; + /// Window hover checks only: Return true if any window is hovered + const AnyWindow = 1 << 2; + /// Return true even if a popup window is normally blocking access to this item/window + const AllowWhenBlockedByPopup = 1 << 3; + /// Return true even if an active item is blocking access to this item/window. Useful for + /// Drag and Drop patterns. + const AllowWhenBlockedByActiveItem = 1 << 5; + /// Return true even if the position is overlapped by another window + const AllowWhenOverlapped = 1 << 6; + /// Return true even if the item is disabled + const AllowWhenDisabled = 1 << 7; + + const RectOnly = ImGuiHoveredFlags::AllowWhenBlockedByPopup.bits + | ImGuiHoveredFlags::AllowWhenBlockedByActiveItem.bits + | ImGuiHoveredFlags::AllowWhenOverlapped.bits; + const RootAndChildWindows = ImGuiFocusedFlags::RootWindow.bits + | ImGuiFocusedFlags::ChildWindows.bits; + } +); + +bitflags!( + /// Flags for text inputs + #[repr(C)] + pub struct ImGuiInputTextFlags: c_int { + /// Allow 0123456789.+-*/ + const CharsDecimal = 1; + /// Allow 0123456789ABCDEFabcdef + const CharsHexadecimal = 1 << 1; + /// Turn a..z into A..Z + const CharsUppercase = 1 << 2; + /// Filter out spaces, tabs + const CharsNoBlank = 1 << 3; + /// Select entire text when first taking mouse focus + const AutoSelectAll = 1 << 4; + /// Return 'true' when Enter is pressed (as opposed to when the value was modified) + const EnterReturnsTrue = 1 << 5; + /// Call user function on pressing TAB (for completion handling) + const CallbackCompletion = 1 << 6; + /// Call user function on pressing Up/Down arrows (for history handling) + const CallbackHistory = 1 << 7; + /// Call user function every time. User code may query cursor position, modify text buffer. + const CallbackAlways = 1 << 8; + /// Call user function to filter character. + const CallbackCharFilter = 1 << 9; + /// Pressing TAB input a '\t' character into the text field + const AllowTabInput = 1 << 10; + /// In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is + /// opposite: unfocus with Ctrl+Enter, add line with Enter). + const CtrlEnterForNewLine = 1 << 11; + /// Disable following the cursor horizontally + const NoHorizontalScroll = 1 << 12; + /// Insert mode + const AlwaysInsertMode = 1 << 13; + /// Read-only mode + const ReadOnly = 1 << 14; + /// Password mode, display all characters as '*' + const Password = 1 << 15; + /// Disable undo/redo. + const NoUndoRedo = 1 << 16; + /// Allow 0123456789.+-*/eE (Scientific notation input) + const CharsScientific = 1 << 17; + /// Allow buffer capacity resize + notify when the string wants to be resized + const CallbackResize = 1 << 18; + } +); + +bitflags!( + /// Flags for selectables + #[repr(C)] + pub struct ImGuiSelectableFlags: c_int { + /// Clicking this don't close parent popup window + const DontClosePopups = 1; + /// Selectable frame can span all columns (text will still fit in current column) + const SpanAllColumns = 1 << 1; + /// Generate press events on double clicks too + const AllowDoubleClick = 1 << 2; + /// Cannot be selected, display greyed out text + const Disabled = 1 << 3; + } +); + +bitflags!( + /// Flags for trees and collapsing headers + #[repr(C)] + pub struct ImGuiTreeNodeFlags: c_int { + /// Draw as selected + const Selected = 1; + /// Full colored frame (e.g. for collapsing header) + const Framed = 1 << 1; + /// Hit testing to allow subsequent widgets to overlap this one + const AllowItemOverlap = 1 << 2; + /// Don't do a tree push when open (e.g. for collapsing header) = no extra indent nor + /// pushing on ID stack + const NoTreePushOnOpen = 1 << 3; + /// Don't automatically and temporarily open node when Logging is active (by default + /// logging will automatically open tree nodes) + const NoAutoOpenOnLog = 1 << 4; + /// Default node to be open + const DefaultOpen = 1 << 5; + /// Need double-click to open node + const OpenOnDoubleClick = 1 << 6; + /// Only open when clicking on the arrow part. If OpenOnDoubleClick is also set, + /// single-click arrow or double-click all box to open. + const OpenOnArrow = 1 << 7; + /// No collapsing, no arrow (use as a convenience for leaf nodes). + const Leaf = 1 << 8; + /// Display a bullet instead of arrow + const Bullet = 1 << 9; + /// Use FramePadding (even for an unframed text node) to vertically align text baseline to + /// regular widget height. + const FramePadding = 1 << 10; + const NavLeftJumpsBackHere = 1 << 13; + + const CollapsingHeader = + ImGuiTreeNodeFlags::Framed.bits | ImGuiTreeNodeFlags::NoTreePushOnOpen.bits | + ImGuiTreeNodeFlags::NoAutoOpenOnLog.bits; + } +); + +bitflags!( + /// Window flags + #[repr(C)] + pub struct ImGuiWindowFlags: c_int { + /// Disable title-bar. + const NoTitleBar = 1; + /// Disable user resizing with the lower-right grip. + const NoResize = 1 << 1; + /// Disable user moving the window. + const NoMove = 1 << 2; + /// Disable scrollbars (window can still scroll with mouse or programatically). + const NoScrollbar = 1 << 3; + /// Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will + /// be forwarded to the parent unless NoScrollbar is also set. + const NoScrollWithMouse = 1 << 4; + /// Disable user collapsing window by double-clicking on it. + const NoCollapse = 1 << 5; + /// Resize every window to its content every frame. + const AlwaysAutoResize = 1 << 6; + /// Never load/save settings in .ini file. + const NoSavedSettings = 1 << 8; + /// Disable catching mouse or keyboard inputs;hovering test with pass through. + const NoInputs = 1 << 9; + /// Has a menu-bar. + const MenuBar = 1 << 10; + /// Allow horizontal scrollbar to appear (off by default). + const HorizontalScrollbar = 1 << 11; + /// Disable taking focus when transitioning from hidden to visible state. + const NoFocusOnAppearing = 1 << 12; + /// Disable bringing window to front when taking focus (e.g. clicking on it or + /// programmatically giving it focus). + const NoBringToFrontOnFocus = 1 << 13; + /// Always show vertical scrollbar. + const AlwaysVerticalScrollbar = 1 << 14; + /// Always show horizontal scrollbar. + const AlwaysHorizontalScrollbar = 1<< 15; + /// Ensure child windows without border use window padding (ignored by default for + /// non-bordered child windows, because more convenient). + const AlwaysUseWindowPadding = 1 << 16; + /// No gamepad/keyboard navigation within the window. + const NoNavInputs = 1 << 18; + /// No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by + /// CTRL+TAB). + const NoNavFocus = 1 << 19; + + const NoNav = ImGuiWindowFlags::NoNavInputs.bits | ImGuiWindowFlags::NoNavFocus.bits; + } +); diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index ac996a9..d8f7b43 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -12,9 +12,17 @@ extern crate gfx; #[cfg(feature = "glium")] extern crate glium; +use libc::size_t; use std::convert::From; -use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void}; -use std::slice; +use std::os::raw::{c_char, c_double, c_float, c_int, c_uint, c_ushort, c_void}; + +pub use self::enums::*; +pub use self::flags::*; +pub use self::structs::*; + +mod enums; +mod flags; +mod structs; #[cfg(feature = "gfx")] mod gfx_support; @@ -22,426 +30,34 @@ mod gfx_support; #[cfg(feature = "glium")] mod glium_support; +/// Vertex index +pub type ImDrawIdx = c_ushort; + /// ImGui context (opaque) pub enum ImGuiContext {} +/// Unique ID used by widgets (typically hashed from a stack of string) +pub type ImGuiID = ImU32; + +/// User data to identify a texture +pub type ImTextureID = *mut c_void; + /// 32-bit unsigned integer (typically used to store packed colors) pub type ImU32 = c_uint; /// Character for keyboard input/display pub type ImWchar = c_ushort; -/// User data to identify a texture -pub type ImTextureID = *mut c_void; +/// Draw callback for advanced use +pub type ImDrawCallback = + Option; -/// Unique ID used by widgets (typically hashed from a stack of string) -pub type ImGuiID = ImU32; +/// Input text callback for advanced use +pub type ImGuiInputTextCallback = + Option c_int>; -/// A color identifier for styling -#[repr(C)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ImGuiCol { - Text, - TextDisabled, - WindowBg, - ChildBg, - PopupBg, - Border, - BorderShadow, - FrameBg, - FrameBgHovered, - FrameBgActive, - TitleBg, - TitleBgActive, - TitleBgCollapsed, - MenuBarBg, - ScrollbarBg, - ScrollbarGrab, - ScrollbarGrabHovered, - ScrollbarGrabActive, - CheckMark, - SliderGrab, - SliderGrabActive, - Button, - ButtonHovered, - ButtonActive, - Header, - HeaderHovered, - HeaderActive, - Separator, - SeparatorHovered, - SeparatorActive, - ResizeGrip, - ResizeGripHovered, - ResizeGripActive, - CloseButton, - CloseButtonHovered, - CloseButtonActive, - PlotLines, - PlotLinesHovered, - PlotHistogram, - PlotHistogramHovered, - TextSelectedBg, - ModalWindowDarkening, - DragDropTarget, -} -impl ImGuiCol { - pub fn values() -> &'static [ImGuiCol] { - use ImGuiCol::*; - static values: &'static [ImGuiCol] = &[ - Text, - TextDisabled, - WindowBg, - ChildBg, - PopupBg, - Border, - BorderShadow, - FrameBg, - FrameBgHovered, - FrameBgActive, - TitleBg, - TitleBgActive, - TitleBgCollapsed, - MenuBarBg, - ScrollbarBg, - ScrollbarGrab, - ScrollbarGrabHovered, - ScrollbarGrabActive, - CheckMark, - SliderGrab, - SliderGrabActive, - Button, - ButtonHovered, - ButtonActive, - Header, - HeaderHovered, - HeaderActive, - Separator, - SeparatorHovered, - SeparatorActive, - ResizeGrip, - ResizeGripHovered, - ResizeGripActive, - CloseButton, - CloseButtonHovered, - CloseButtonActive, - PlotLines, - PlotLinesHovered, - PlotHistogram, - PlotHistogramHovered, - TextSelectedBg, - ModalWindowDarkening, - DragDropTarget, - ]; - values - } -} -pub const ImGuiCol_COUNT: usize = 43; - -/// A variable identifier for styling -#[repr(C)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ImGuiStyleVar { - Alpha, - WindowPadding, - WindowRounding, - WindowBorderSize, - WindowMinSize, - ChildRounding, - ChildBorderSize, - PopupRounding, - PopupBorderSize, - FramePadding, - FrameRounding, - FrameBorderSize, - ItemSpacing, - ItemInnerSpacing, - IndentSpacing, - GrabMinSize, - ButtonTextAlign, -} -pub const ImGuiStyleVar_COUNT: usize = 17; - -/// A key identifier (ImGui-side enum) -#[repr(C)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ImGuiKey { - Tab, - LeftArrow, - RightArrow, - UpArrow, - DownArrow, - PageUp, - PageDown, - Home, - End, - Delete, - Backspace, - Enter, - Escape, - A, - C, - V, - X, - Y, - Z, -} -pub const ImGuiKey_COUNT: usize = 19; - -bitflags!( - /// Color edit flags - #[repr(C)] - pub struct ImGuiColorEditFlags: c_int { - const NoAlpha = 1 << 1; - const NoPicker = 1 << 2; - const NoOptions = 1 << 3; - const NoSmallPreview = 1 << 4; - const NoInputs = 1 << 5; - const NoTooltip = 1 << 6; - const NoLabel = 1 << 7; - const NoSidePreview = 1 << 8; - const AlphaBar = 1 << 9; - const AlphaPreview = 1 << 10; - const AlphaPreviewHalf = 1 << 11; - const HDR = 1 << 12; - const RGB = 1 << 13; - const HSV = 1 << 14; - const HEX = 1 << 15; - const Uint8 = 1 << 16; - const Float = 1 << 17; - const PickerHueBar = 1 << 18; - const PickerHueWheel = 1 << 19; - } -); - -/// A mouse cursor identifier -#[repr(C)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum ImGuiMouseCursor { - None = -1, - Arrow, - TextInput, - Move, - ResizeNS, - ResizeEW, - ResizeNESW, - ResizeNWSE, -} -pub const ImGuiMouseCursor_COUNT: usize = 7; - -bitflags!( - /// Window flags - #[repr(C)] - pub struct ImGuiWindowFlags: c_int { - const NoTitleBar = 1; - const NoResize = 1 << 1; - const NoMove = 1 << 2; - const NoScrollbar = 1 << 3; - const NoScrollWithMouse = 1 << 4; - const NoCollapse = 1 << 5; - const AlwaysAutoResize = 1 << 6; - const NoSavedSettings = 1 << 8; - const NoInputs = 1 << 9; - const MenuBar = 1 << 10; - const HorizontalScrollbar = 1 << 11; - const NoFocusOnAppearing = 1 << 12; - const NoBringToFrontOnFocus = 1 << 13; - const AlwaysVerticalScrollbar = 1 << 14; - const AlwaysHorizontalScrollbar = 1 << 15; - const AlwaysUseWindowPadding = 1 << 16; - const ResizeFromAnySide = 1 << 17; - } -); - -bitflags!( - /// Condition flags - #[repr(C)] - pub struct ImGuiCond: c_int { - const Always = 1; - const Once = 1 << 1; - const FirstUseEver = 1 << 2; - const Appearing = 1 << 3; - } -); - -bitflags!( - /// Flags for text inputs - #[repr(C)] - pub struct ImGuiInputTextFlags: c_int { - const CharsDecimal = 1; - const CharsHexadecimal = 1 << 1; - const CharsUppercase = 1 << 2; - const CharsNoBlank = 1 << 3; - const AutoSelectAll = 1 << 4; - const EnterReturnsTrue = 1 << 5; - const CallbackCompletion = 1 << 6; - const CallbackHistory = 1 << 7; - const CallbackAlways = 1 << 8; - const CallbackCharFilter = 1 << 9; - const AllowTabInput = 1 << 10; - const CtrlEnterForNewLine = 1 << 11; - const NoHorizontalScroll = 1 << 12; - const AlwaysInsertMode = 1 << 13; - const ReadOnly = 1 << 14; - const Password = 1 << 15; - const NoUndoRedo = 1 << 16; - } -); - -bitflags!( - /// Flags for selectables - #[repr(C)] - pub struct ImGuiSelectableFlags: c_int { - const DontClosePopups = 1; - const SpanAllColumns = 1 << 1; - const AllowDoubleClick = 1 << 2; - } -); - -bitflags!( - /// Flags for trees and collapsing headers - #[repr(C)] - pub struct ImGuiTreeNodeFlags: c_int { - const Selected = 1; - const Framed = 1 << 1; - const AllowItemOverlap = 1 << 2; - const NoTreePushOnOpen = 1 << 3; - const NoAutoOpenOnLog = 1 << 4; - const DefaultOpen = 1 << 5; - const OpenOnDoubleClick = 1 << 6; - const OpenOnArrow = 1 << 7; - const Leaf = 1 << 8; - const Bullet = 1 << 9; - const FramePadding = 1 << 10; - const CollapsingHeader = - ImGuiTreeNodeFlags::Framed.bits | ImGuiTreeNodeFlags::NoAutoOpenOnLog.bits; - } -); - -bitflags!( - /// Flags for window focus check - #[repr(C)] - pub struct ImGuiFocusedFlags: c_int { - const ChildWindows = 1 << 0; - const RootWindow = 1 << 1; - const RootAndChildWindows = - ImGuiFocusedFlags::RootWindow.bits | ImGuiFocusedFlags::ChildWindows.bits; - } -); - -bitflags!( - /// Flags for hover checks - #[repr(C)] - pub struct ImGuiHoveredFlags: c_int { - const ChildWindows = 1 << 0; - const RootWindow = 1 << 1; - const AllowWhenBlockedByPopup = 1 << 2; - const AllowWhenBlockedByActiveItem = 1 << 4; - const AllowWhenOverlapped = 1 << 5; - const RectOnly = ImGuiHoveredFlags::AllowWhenBlockedByPopup.bits - | ImGuiHoveredFlags::AllowWhenBlockedByActiveItem.bits - | ImGuiHoveredFlags::AllowWhenOverlapped.bits; - const RootAndChildWindows = ImGuiFocusedFlags::RootWindow.bits - | ImGuiFocusedFlags::ChildWindows.bits; - } -); - -bitflags!( - /// Flags for igBeginCombo - #[repr(C)] - pub struct ImGuiComboFlags: c_int { - /// Align the popup toward the left by default - const PopupAlignLeft = 1 << 0; - /// Max ~4 items visible. - /// Tip: If you want your combo popup to be a specific size you can use - /// igSetNextWindowSizeConstraints() prior to calling igBeginCombo() - const HeightSmall = 1 << 1; - /// Max ~8 items visible (default) - const HeightRegular = 1 << 2; - /// Max ~20 items visible - const HeightLarge = 1 << 3; - /// As many fitting items as possible - const HeightLargest = 1 << 4; - const HeightMask = ImGuiComboFlags::HeightSmall.bits - | ImGuiComboFlags::HeightRegular.bits - | ImGuiComboFlags::HeightLarge.bits - | ImGuiComboFlags::HeightLargest.bits; - } -); - -bitflags!( - /// Flags for igBeginDragDropSource(), igAcceptDragDropPayload() - #[repr(C)] - pub struct ImGuiDragDropFlags: c_int { - // BeginDragDropSource() flags - /// By default, a successful call to igBeginDragDropSource opens a - /// tooltip so you can display a preview or description of the source - /// contents. This flag disable this behavior. - const SourceNoPreviewTooltip = 1 << 0; - /// By default, when dragging we clear data so that igIsItemHovered() - /// will return true, to avoid subsequent user code submitting tooltips. - /// This flag disable this behavior so you can still call - /// igIsItemHovered() on the source item. - const SourceNoDisableHover = 1 << 1; - /// Disable the behavior that allows to open tree nodes and collapsing - /// header by holding over them while dragging a source item. - const SourceNoHoldToOpenOthers = 1 << 2; - /// Allow items such as igText(), igImage() that have no unique - /// identifier to be used as drag source, by manufacturing a temporary - /// identifier based on their window-relative position. This is - /// extremely unusual within the dear imgui ecosystem and so we made it - /// explicit. - const SourceAllowNullID = 1 << 3; - /// External source (from outside of imgui), won't attempt to read - /// current item/window info. Will always return true. Only one Extern - /// source can be active simultaneously. - const SourceExtern = 1 << 4; - // AcceptDragDropPayload() flags - /// igAcceptDragDropPayload() will returns true even before the mouse - /// button is released. You can then call igIsDelivery() to test if the - /// payload needs to be delivered. - const AcceptBeforeDelivery = 1 << 10; - /// Do not draw the default highlight rectangle when hovering over target. - const AcceptNoDrawDefaultRect = 1 << 11; - /// For peeking ahead and inspecting the payload before delivery. - const AcceptPeekOnly = ImGuiDragDropFlags::AcceptBeforeDelivery.bits - | ImGuiDragDropFlags::AcceptNoDrawDefaultRect.bits; - } -); - -bitflags!( - /// Flags for indictating which corner of a rectangle should be rounded - #[repr(C)] - pub struct ImDrawCornerFlags: c_int { - const TopLeft = 1 << 0; - const TopRight = 1 << 1; - const BotLeft = 1 << 2; - const BotRight = 1 << 3; - const Top = ImDrawCornerFlags::TopLeft.bits - | ImDrawCornerFlags::TopRight.bits; - const Bot = ImDrawCornerFlags::BotLeft.bits - | ImDrawCornerFlags::BotRight.bits; - const Left = ImDrawCornerFlags::TopLeft.bits - | ImDrawCornerFlags::BotLeft.bits; - const Right = ImDrawCornerFlags::TopRight.bits - | ImDrawCornerFlags::BotRight.bits; - const All = 0xF; - } -); - -bitflags!( - #[repr(C)] - pub struct ImDrawListFlags: c_int { - const AntiAliasedLines = 1 << 0; - const AntiAliasedFill = 1 << 1; - } -); - -pub type ImGuiTextEditCallback = - Option c_int>; - -pub type ImGuiSizeConstraintCallback = - Option; +/// Size constraint callback for advanced use +pub type ImGuiSizeCallback = Option; /// A tuple of 2 floating-point values #[repr(C)] @@ -543,466 +159,51 @@ impl Into<(f32, f32, f32, f32)> for ImVec4 { } } -/// Runtime data for styling/colors -#[repr(C)] -#[derive(Clone)] -pub struct ImGuiStyle { - /// Global alpha applies to everything in ImGui - pub alpha: c_float, - /// Padding within a window - pub window_padding: ImVec2, - /// Radius of window corners rounding. Set to 0.0f to have rectangular windows - pub window_rounding: c_float, - /// Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. - pub window_border_size: c_float, - /// Minimum window size - pub window_min_size: ImVec2, - /// Alignment for title bar text. Defaults to (0.0f, 0.5f) for left-aligned, vertically centered - pub window_title_align: ImVec2, - /// Radius of child window corners rounding. Set to 0.0f to have rectangular child windows - pub child_rounding: c_float, - /// Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. - pub child_border_size: c_float, - /// Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows - pub popup_rounding: c_float, - /// Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. - pub popup_border_size: c_float, - /// Padding within a framed rectangle (used by most widgets) - pub frame_padding: ImVec2, - /// Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most - /// widgets). - pub frame_rounding: c_float, - /// Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. - pub frame_border_size: c_float, - /// Horizontal and vertical spacing between widgets/lines - pub item_spacing: ImVec2, - /// Horizontal and vertical spacing between within elements of a composed - /// widget (e.g. a slider and its label) - pub item_inner_spacing: ImVec2, - /// Expand reactive bounding box for touch-based system where touch position is not accurate - /// enough. Unfortunately we don't sort widgets so priority on overlap will always be given - /// to the first widget. So don't grow this too much! - pub touch_extra_padding: ImVec2, - /// Horizontal spacing when e.g. entering a tree node. - /// Generally == (FontSize + FramePadding.x*2). - pub indent_spacing: c_float, - /// Minimum horizontal spacing between two columns - pub columns_min_spacing: c_float, - /// Width of the vertical scrollbar, Height of the horizontal scrollbar - pub scrollbar_size: c_float, - /// Width of the vertical scrollbar, Height of the horizontal scrollbar - pub scrollbar_rounding: c_float, - /// Minimum width/height of a grab box for slider/scrollbar - pub grab_min_size: c_float, - /// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. - pub grab_rounding: c_float, - /// Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) - /// for horizontally + vertically centered - pub button_text_align: ImVec2, - /// Window positions are clamped to be visible within the display area by at least this - /// amount. Only covers regular windows. - pub display_window_padding: ImVec2, - /// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. - /// Covers popups/tooltips as well regular windows. - pub display_safe_area_padding: ImVec2, - /// Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU. - pub anti_aliased_lines: bool, - /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) - pub anti_aliased_fill: bool, - /// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more - /// polygons), increase to reduce quality. - pub curve_tessellation_tol: c_float, - /// Colors for the user interface - pub colors: [ImVec4; ImGuiCol_COUNT], -} - -/// Main configuration and I/O between your application and ImGui -#[repr(C)] -pub struct ImGuiIO { - pub display_size: ImVec2, - pub delta_time: c_float, - pub ini_saving_rate: c_float, - pub ini_filename: *const c_char, - pub log_filename: *const c_char, - pub mouse_double_click_time: c_float, - pub mouse_double_click_max_dist: c_float, - pub mouse_drag_threshold: c_float, - pub key_map: [c_int; ImGuiKey_COUNT], - pub key_repeat_delay: c_float, - pub key_repeat_rate: c_float, - pub user_data: *mut c_void, - - pub fonts: *mut ImFontAtlas, - pub font_global_scale: c_float, - pub font_allow_user_scaling: bool, - pub font_default: *mut ImFont, - pub display_framebuffer_scale: ImVec2, - pub display_visible_min: ImVec2, - pub display_visible_max: ImVec2, - - pub opt_mac_osx_behaviors: bool, - pub opt_cursor_blink: bool, - - pub render_draw_lists_fn: Option, - - pub get_clipboard_text_fn: Option *const c_char>, - pub set_clipboard_text_fn: Option, - pub clipboard_user_data: *mut c_void, - - pub mem_alloc_fn: Option *mut c_void>, - pub mem_free_fn: Option, - - pub ime_set_input_screen_pos_fn: Option, - pub ime_window_handle: *mut c_void, - - pub mouse_pos: ImVec2, - pub mouse_down: [bool; 5], - pub mouse_wheel: c_float, - pub mouse_draw_cursor: bool, - pub key_ctrl: bool, - pub key_shift: bool, - pub key_alt: bool, - pub key_super: bool, - pub keys_down: [bool; 512], - pub input_characters: [ImWchar; 16 + 1], - - pub want_capture_mouse: bool, - pub want_capture_keyboard: bool, - pub want_text_input: bool, - pub want_move_mouse: bool, - pub framerate: c_float, - pub metrics_allocs: c_int, - pub metrics_render_vertices: c_int, - pub metrics_render_indices: c_int, - pub metrics_active_windows: c_int, - pub mouse_delta: ImVec2, - - mouse_pos_prev: ImVec2, - mouse_clicked_pos: [ImVec2; 5], - mouse_clicked_time: [c_float; 5], - mouse_clicked: [bool; 5], - mouse_double_clicked: [bool; 5], - mouse_released: [bool; 5], - mouse_down_owned: [bool; 5], - mouse_down_duration: [c_float; 5], - mouse_down_duration_prev: [c_float; 5], - mouse_drag_max_distance_abs: [ImVec2; 5], - mouse_drag_max_distance_sqr: [c_float; 5], - keys_down_duration: [c_float; 512], - keys_down_duration_prev: [c_float; 512], -} - -/// Lightweight vector struct -#[repr(C)] -pub struct ImVector { - pub size: c_int, - pub capacity: c_int, - pub data: *mut T, -} - -impl ImVector { - pub unsafe fn as_slice(&self) -> &[T] { - slice::from_raw_parts(self.data, self.size as usize) - } -} - -#[repr(C)] -pub struct TextRange { - pub begin: *const c_char, - pub end: *const c_char, -} - -#[repr(C)] -pub struct ImGuiTextFilter { - pub input_buf: [c_char; 256], - pub filters: ImVector, - pub count_grep: c_int, -} - -/// Data payload for Drag and Drop operations -#[repr(C)] -pub struct ImGuiPayload { - /// Data (copied and owned by dear imgui) - pub data: *const c_void, - /// Data size - pub data_size: c_int, - - /// Source item id - source_id: ImGuiID, - /// Source parent id (if available) - source_parent_id: ImGuiID, - /// Data timestamp - data_frame_count: c_int, - /// Data type tag (short user-supplied string) - data_type: [c_char; 8 + 1], - /// Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) - preview: bool, - /// Set when AcceptDragDropPayload() was called and mouse button is released over the target item. - delivery: bool, -} - -#[repr(C)] -pub struct ImGuiTextBuffer { - pub buf: ImVector, -} - -#[repr(C)] -pub struct Pair { - pub key: ImGuiID, - pub value: PairValue, -} - -#[repr(C)] -pub union PairValue { - val_i: c_int, - val_f: c_float, - val_p: *mut c_void, -} - -#[repr(C)] -pub struct ImGuiStorage { - pub data: ImVector, -} - -#[repr(C)] -pub struct ImGuiTextEditCallbackData { - pub event_flag: ImGuiInputTextFlags, - pub flags: ImGuiInputTextFlags, - pub user_data: *mut c_void, - pub read_only: bool, - - pub event_char: ImWchar, - - pub event_key: ImGuiKey, - pub buf: *mut c_char, - pub buf_text_len: c_int, - pub buf_size: c_int, - pub buf_dirty: bool, - pub cursor_pos: c_int, - pub selection_start: c_int, - pub selection_end: c_int, -} - -#[repr(C)] -pub struct ImGuiSizeConstraintCallbackData { - pub user_data: *mut c_void, - pub pos: ImVec2, - pub current_size: ImVec2, - pub desired_size: ImVec2, -} - -#[repr(C)] -#[derive(Copy, Clone, Debug, Default)] -pub struct ImColor { - pub value: ImVec4, -} - -/// Helper to manually clip large list of items -#[repr(C)] -#[derive(Copy, Clone, Debug)] -pub struct ImGuiListClipper { - pub start_pos_y: c_float, - pub items_height: c_float, - pub items_count: c_int, - pub step_no: c_int, - pub display_start: c_int, - pub display_end: c_int, -} - -pub type ImDrawCallback = - Option; - -/// A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call) -#[repr(C)] -pub struct ImDrawCmd { - pub elem_count: c_uint, - pub clip_rect: ImVec4, - pub texture_id: ImTextureID, - pub user_callback: ImDrawCallback, - pub user_callback_data: *mut c_void, -} - -/// Vertex index -pub type ImDrawIdx = c_ushort; - -/// A single vertex -#[repr(C)] -#[derive(Copy, Clone, Debug, Default)] -pub struct ImDrawVert { - pub pos: ImVec2, - pub uv: ImVec2, - pub col: ImU32, -} - -/// Temporary storage for outputting drawing commands out of order -#[repr(C)] -pub struct ImDrawChannel { - pub cmd_buffer: ImVector, - pub idx_buffer: ImVector, -} - -/// A single draw command list (generally one per window) -#[repr(C)] -pub struct ImDrawList { - pub cmd_buffer: ImVector, - pub idx_buffer: ImVector, - pub vtx_buffer: ImVector, - - flags: ImDrawListFlags, - data: *const ImDrawListSharedData, - owner_name: *const c_char, - vtx_current_idx: c_uint, - vtx_write_ptr: *mut ImDrawVert, - idx_write_ptr: *mut ImDrawIdx, - clip_rect_stack: ImVector, - texture_id_stack: ImVector, - path: ImVector, - channels_current: c_int, - channels_count: c_int, - channels: ImVector, -} - -#[repr(C)] -pub struct ImDrawListSharedData { - /// UV of white pixel in the atlas - tex_uv_white_pixel: ImVec2, - /// Current/default font (optional, for simplified AddText overload) - font: *mut ImFont, - /// Current/default font size (optional, for simplified AddText overload) - font_size: c_float, - curve_tessellation_tol: c_float, - /// Value for PushClipRectFullscreen() - clip_rect_fullscreen: ImVec4, - circle_vtx12: [ImVec2; 12], -} - -/// All draw command lists required to render the frame -#[repr(C)] -pub struct ImDrawData { - pub valid: bool, - pub cmd_lists: *mut *mut ImDrawList, - pub cmd_lists_count: c_int, - pub total_vtx_count: c_int, - pub total_idx_count: c_int, -} - -impl ImDrawData { - pub unsafe fn cmd_lists(&self) -> &[*const ImDrawList] { - let cmd_lists = self.cmd_lists as *const *const ImDrawList; - slice::from_raw_parts(cmd_lists, self.cmd_lists_count as usize) - } -} - -/// Configuration data when adding a font or merging fonts -#[repr(C)] -pub struct ImFontConfig { - pub font_data: *mut c_void, - pub font_data_size: c_int, - pub font_data_owned_by_atlas: bool, - pub font_no: c_int, - pub size_pixels: c_float, - pub oversample_h: c_int, - pub oversample_v: c_int, - pub pixel_snap_h: bool, - pub glyph_extra_spacing: ImVec2, - pub glyph_offset: ImVec2, - pub glyph_ranges: *const ImWchar, - pub merge_mode: bool, - pub rasterizer_flags: c_uint, - pub rasterizer_multiply: c_float, - - name: [c_char; 32], - dst_font: *mut ImFont, -} - -#[repr(C)] -#[derive(Copy, Clone, Debug, Default)] -pub struct ImFontGlyph { - codepoint: ImWchar, - advance_x: c_float, - x0: c_float, - y0: c_float, - x1: c_float, - y1: c_float, - u0: c_float, - v0: c_float, - u1: c_float, - v1: c_float, -} - -#[repr(C)] -pub struct CustomRect { - pub id: c_uint, - pub width: c_ushort, - pub height: c_ushort, - pub x: c_ushort, - pub y: c_ushort, - pub glyph_advance_x: c_float, - pub glyph_offset: ImVec2, - pub font: *mut ImFont, -} - -/// Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader -#[repr(C)] -pub struct ImFontAtlas { - pub tex_id: *mut c_void, - pub tex_desired_width: c_int, - pub tex_glyph_padding: c_int, - - tex_pixels_alpha8: *mut c_uchar, - tex_pixels_rgba32: *mut c_uint, - tex_width: c_int, - tex_height: c_int, - tex_uv_white_pixel: ImVec2, - fonts: ImVector<*mut ImFont>, - custom_rects: ImVector, - config_data: ImVector, - custom_rect_ids: [c_int; 1], -} - -/// Runtime data for a single font within a parent ImFontAtlas -#[repr(C)] -pub struct ImFont { - font_size: c_float, - scale: c_float, - display_offset: ImVec2, - glyphs: ImVector, - index_advance_x: ImVector, - index_lookup: ImVector, - fallback_glyph: *const ImFontGlyph, - fallback_advance_x: c_float, - fallback_char: ImWchar, - - config_data_count: c_short, - config_data: *mut ImFontConfig, - container_atlas: *mut ImFontAtlas, - ascent: c_float, - descent: c_float, - metrics_total_surface: c_int, +// Context creation and access +extern "C" { + pub fn igCreateContext(shared_font_atlas: *mut ImFontAtlas) -> *mut ImGuiContext; + pub fn igDestroyContext(ctx: *mut ImGuiContext); + pub fn igGetCurrentContext() -> *mut ImGuiContext; + pub fn igSetCurrentContext(ctx: *mut ImGuiContext); + pub fn igDebugCheckVersionAndDataLayout( + version_str: *const c_char, + sz_io: size_t, + sz_style: size_t, + sz_vec2: size_t, + sz_vec4: size_t, + sz_drawvert: size_t, + ) -> bool; } // Main extern "C" { pub fn igGetIO() -> *mut ImGuiIO; pub fn igGetStyle() -> *mut ImGuiStyle; - pub fn igGetDrawData() -> *mut ImDrawData; pub fn igNewFrame(); - pub fn igRender(); pub fn igEndFrame(); - pub fn igShutdown(); + pub fn igRender(); + pub fn igGetDrawData() -> *mut ImDrawData; } -// Demo/Debug/Info +// Demo, Debug, Information extern "C" { pub fn igShowDemoWindow(opened: *mut bool); pub fn igShowMetricsWindow(opened: *mut bool); pub fn igShowStyleEditor(style: *mut ImGuiStyle); - pub fn igShowStyleSelector(label: *const c_char); + pub fn igShowStyleSelector(label: *const c_char) -> bool; pub fn igShowFontSelector(label: *const c_char); pub fn igShowUserGuide(); + pub fn igGetVersion() -> *const c_char; } -// Window +// Styles +extern "C" { + pub fn igStyleColorsDark(dst: *mut ImGuiStyle); + pub fn igStyleColorsClassic(dst: *mut ImGuiStyle); + pub fn igStyleColorsLight(dst: *mut ImGuiStyle); +} + +// Windows extern "C" { pub fn igBegin(name: *const c_char, open: *mut bool, flags: ImGuiWindowFlags) -> bool; pub fn igEnd(); @@ -1010,50 +211,56 @@ extern "C" { str_id: *const c_char, size: ImVec2, border: bool, - extra_flags: ImGuiWindowFlags, - ) -> bool; - pub fn igBeginChildEx( - id: ImGuiID, - size: ImVec2, - border: bool, - extra_flags: ImGuiWindowFlags, + flags: ImGuiWindowFlags, ) -> bool; + pub fn igBeginChildID(id: ImGuiID, size: ImVec2, border: bool, flags: ImGuiWindowFlags) + -> bool; pub fn igEndChild(); - pub fn igGetContentRegionMax(out: *mut ImVec2); - pub fn igGetContentRegionAvail(out: *mut ImVec2); - pub fn igGetContentRegionAvailWidth() -> c_float; - pub fn igGetWindowContentRegionMin(out: *mut ImVec2); - pub fn igGetWindowContentRegionMax(out: *mut ImVec2); - pub fn igGetWindowContentRegionWidth() -> c_float; +} + +// Windows Utilities +extern "C" { + pub fn igIsWindowAppearing() -> bool; + pub fn igIsWindowCollapsed() -> bool; + pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; + pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; pub fn igGetWindowDrawList() -> *mut ImDrawList; - pub fn igGetWindowPos(out: *mut ImVec2); - pub fn igGetWindowSize(out: *mut ImVec2); + pub fn igGetWindowPos() -> ImVec2; + pub fn igGetWindowSize() -> ImVec2; pub fn igGetWindowWidth() -> c_float; pub fn igGetWindowHeight() -> c_float; - pub fn igIsWindowCollapsed() -> bool; - pub fn igIsWindowAppearing() -> bool; - pub fn igSetWindowFontScale(scale: c_float); + pub fn igGetContentRegionMax() -> ImVec2; + pub fn igGetContentRegionAvail() -> ImVec2; + pub fn igGetContentRegionAvailWidth() -> c_float; + pub fn igGetWindowContentRegionMin() -> ImVec2; + pub fn igGetWindowContentRegionMax() -> ImVec2; + pub fn igGetWindowContentRegionWidth() -> c_float; pub fn igSetNextWindowPos(pos: ImVec2, cond: ImGuiCond, pivot: ImVec2); pub fn igSetNextWindowSize(size: ImVec2, cond: ImGuiCond); pub fn igSetNextWindowConstraints( size_min: ImVec2, size_max: ImVec2, - custom_callback: ImGuiSizeConstraintCallback, + custom_callback: ImGuiSizeCallback, custom_callback_data: *mut c_void, ); pub fn igSetNextWindowContentSize(size: ImVec2); pub fn igSetNextWindowCollapsed(collapsed: bool, cond: ImGuiCond); pub fn igSetNextWindowFocus(); - pub fn igSetWindowPos(pos: ImVec2, cond: ImGuiCond); - pub fn igSetWindowSize(size: ImVec2, cond: ImGuiCond); - pub fn igSetWindowCollapsed(collapsed: bool, cond: ImGuiCond); + pub fn igSetNextWindowBgAlpha(alpha: c_float); + pub fn igSetWindowPosVec2(pos: ImVec2, cond: ImGuiCond); + pub fn igSetWindowSizeVec2(size: ImVec2, cond: ImGuiCond); + pub fn igSetWindowCollapsedBool(collapsed: bool, cond: ImGuiCond); pub fn igSetWindowFocus(); - pub fn igSetWindowPosByName(name: *const c_char, pos: ImVec2, cond: ImGuiCond); - pub fn igSetWindowSize2(name: *const c_char, size: ImVec2, cond: ImGuiCond); - pub fn igSetWindowCollapsed2(name: *const c_char, collapsed: bool, cond: ImGuiCond); - pub fn igSetWindowFocus2(name: *const c_char); + pub fn igSetWindowFontScale(scale: c_float); + pub fn igSetWindowPosStr(name: *const c_char, pos: ImVec2, cond: ImGuiCond); + pub fn igSetWindowSizeStr(name: *const c_char, size: ImVec2, cond: ImGuiCond); + pub fn igSetWindowCollapsedStr(name: *const c_char, collapsed: bool, cond: ImGuiCond); + pub fn igSetWindowFocusStr(name: *const c_char); +} +// Windows scrolling +extern "C" { pub fn igGetScrollX() -> c_float; pub fn igGetScrollY() -> c_float; pub fn igGetScrollMaxX() -> c_float; @@ -1062,26 +269,24 @@ extern "C" { pub fn igSetScrollY(scroll_y: c_float); pub fn igSetScrollHere(center_y_ratio: c_float); pub fn igSetScrollFromPosY(pos_y: c_float, center_y_ratio: c_float); - pub fn igSetStateStorage(tree: *mut ImGuiStorage); - pub fn igGetStateStorage() -> *mut ImGuiStorage; } -// Parameter stack (shared) +// Parameter stacks (shared) extern "C" { pub fn igPushFont(font: *mut ImFont); pub fn igPopFont(); pub fn igPushStyleColorU32(idx: ImGuiCol, col: ImU32); pub fn igPushStyleColor(idx: ImGuiCol, col: ImVec4); pub fn igPopStyleColor(count: c_int); - pub fn igPushStyleVar(idx: ImGuiStyleVar, val: c_float); - pub fn igPushStyleVarVec(idx: ImGuiStyleVar, val: ImVec2); + pub fn igPushStyleVarFloat(idx: ImGuiStyleVar, val: c_float); + pub fn igPushStyleVarVec2(idx: ImGuiStyleVar, val: ImVec2); pub fn igPopStyleVar(count: c_int); - pub fn igGetStyleColorVec4(out: *mut ImVec4, idx: ImGuiCol); + pub fn igGetStyleColorVec4(idx: ImGuiCol) -> *const ImVec4; pub fn igGetFont() -> *mut ImFont; pub fn igGetFontSize() -> c_float; - pub fn igGetFontTexUvWhitePixel(out: *mut ImVec2); + pub fn igGetFontTexUvWhitePixel() -> ImVec2; pub fn igGetColorU32(idx: ImGuiCol, alpha_mul: c_float) -> ImU32; - pub fn igGetColorU32Vec(col: *const ImVec4) -> ImU32; + pub fn igGetColorU32Vec(col: ImVec4) -> ImU32; pub fn igGetColorU32U32(col: ImU32) -> ImU32; } @@ -1104,20 +309,20 @@ extern "C" { pub fn igSameLine(pos_x: c_float, spacing_w: c_float); pub fn igNewLine(); pub fn igSpacing(); - pub fn igDummy(size: *const ImVec2); + pub fn igDummy(size: ImVec2); pub fn igIndent(indent_w: c_float); pub fn igUnindent(indent_w: c_float); pub fn igBeginGroup(); pub fn igEndGroup(); - pub fn igGetCursorPos(out: *mut ImVec2); + pub fn igGetCursorPos() -> ImVec2; pub fn igGetCursorPosX() -> c_float; pub fn igGetCursorPosY() -> c_float; pub fn igSetCursorPos(local_pos: ImVec2); pub fn igSetCursorPosX(x: c_float); pub fn igSetCursorPosY(y: c_float); - pub fn igGetCursorStartPos(out: *mut ImVec2); - pub fn igGetCursorScreenPos(out: *mut ImVec2); - pub fn igSetCursorScreenPos(pos: ImVec2); + pub fn igGetCursorStartPos() -> ImVec2; + pub fn igGetCursorScreenPos() -> ImVec2; + pub fn igSetCursorScreenPos(screen_pos: ImVec2); pub fn igAlignTextToFramePadding(); pub fn igGetTextLineHeight() -> c_float; pub fn igGetTextLineHeightWithSpacing() -> c_float; @@ -1125,49 +330,35 @@ extern "C" { pub fn igGetFrameHeightWithSpacing() -> c_float; } -// Columns -extern "C" { - pub fn igColumns(count: c_int, id: *const c_char, border: bool); - pub fn igNextColumn(); - pub fn igGetColumnIndex() -> c_int; - pub fn igGetColumnWidth(column_index: c_int) -> c_float; - pub fn igSetColumnWidth(column_index: c_int, width: c_float); - pub fn igGetColumnOffset(column_index: c_int) -> c_float; - pub fn igSetColumnOffset(column_index: c_int, offset_x: c_float); - pub fn igGetColumnsCount() -> c_int; -} - -// ID scopes +// ID stack/scopes extern "C" { pub fn igPushIDStr(str_id: *const c_char); - pub fn igPushIDStrRange(str_begin: *const c_char, str_end: *const c_char); + pub fn igPushIDRange(str_id_begin: *const c_char, str_id_end: *const c_char); pub fn igPushIDPtr(ptr_id: *const c_void); pub fn igPushIDInt(int_id: c_int); pub fn igPopID(); pub fn igGetIDStr(str_id: *const c_char) -> ImGuiID; - pub fn igGetIDStrRange(str_begin: *const c_char, str_end: *const c_char) -> ImGuiID; + pub fn igGetIDStrStr(str_id_begin: *const c_char, str_id_end: *const c_char) -> ImGuiID; pub fn igGetIDPtr(ptr_id: *const c_void) -> ImGuiID; } -// Widgets +// Widgets: Text extern "C" { pub fn igTextUnformatted(text: *const c_char, text_end: *const c_char); pub fn igText(fmt: *const c_char, ...); - // pub fn igTextV(fmt: *const c_char, args: va_list); pub fn igTextColored(col: ImVec4, fmt: *const c_char, ...); - // pub fn igTextColoredV(col: ImVec4, fmt: *const c_char, args: va_list); pub fn igTextDisabled(fmt: *const c_char, ...); - // pub fn igTextDisabledV(fmt: *const c_char, args: va_list); pub fn igTextWrapped(fmt: *const c_char, ...); - // pub fn igTextWrappedV(fmt: *const c_char, args: va_list); pub fn igLabelText(label: *const c_char, fmt: *const c_char, ...); - // pub fn igLabelTextV(label: *const c_char, fmt: *const c_char, args: va_list); pub fn igBulletText(fmt: *const c_char, ...); - // pub fn igBulletTextV(fmt: *const c_char, args: va_list); - pub fn igBullet(); +} + +// Widgets: Main +extern "C" { pub fn igButton(label: *const c_char, size: ImVec2) -> bool; pub fn igSmallButton(label: *const c_char) -> bool; pub fn igInvisibleButton(str_id: *const c_char, size: ImVec2) -> bool; + pub fn igArrowButton(str_id: *const c_char, dir: ImGuiDir) -> bool; pub fn igImage( user_texture_id: ImTextureID, size: ImVec2, @@ -1188,55 +379,12 @@ extern "C" { pub fn igCheckbox(label: *const c_char, v: *mut bool) -> bool; pub fn igCheckboxFlags(label: *const c_char, flags: *mut c_uint, flags_value: c_uint) -> bool; pub fn igRadioButtonBool(label: *const c_char, active: bool) -> bool; - pub fn igRadioButton(label: *const c_char, v: *mut c_int, v_button: c_int) -> bool; - pub fn igPlotLines( - label: *const c_char, - values: *const c_float, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - stride: c_int, - ); - pub fn igPlotLines2( - label: *const c_char, - values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, - data: *mut c_void, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - ); - pub fn igPlotHistogram( - label: *const c_char, - values: *const c_float, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - stride: c_int, - ); - pub fn igPlotHistogram2( - label: *const c_char, - values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, - data: *mut c_void, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - ); - pub fn igProgressBar(fraction: c_float, size_arg: *const ImVec2, overlay: *const c_char); + pub fn igRadioButtonIntPtr(label: *const c_char, v: *mut c_int, v_button: c_int) -> bool; + pub fn igProgressBar(fraction: c_float, size_arg: ImVec2, overlay: *const c_char); + pub fn igBullet(); } -// Combo +// Widgets: Combo Box extern "C" { pub fn igBeginCombo( label: *const c_char, @@ -1249,22 +397,348 @@ extern "C" { current_item: *mut c_int, items: *const *const c_char, items_count: c_int, - height_in_items: c_int, + popup_max_height_in_items: c_int, ) -> bool; - pub fn igCombo2( + pub fn igComboStr( label: *const c_char, current_item: *mut c_int, items_separated_by_zeros: *const c_char, - height_in_items: c_int, + popup_max_height_in_items: c_int, ) -> bool; - pub fn igCombo3( + pub fn igComboFnPtr( label: *const c_char, current_item: *mut c_int, items_getter: extern "C" fn(data: *mut c_void, idx: c_int, out_text: *mut *const c_char) -> bool, data: *mut c_void, items_count: c_int, - height_in_items: c_int, + popup_max_height_in_items: c_int, + ) -> bool; +} + +// Widgets: Drags +extern "C" { + pub fn igDragFloat( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat2( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat3( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat4( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloatRange2( + label: *const c_char, + v_current_min: *mut c_float, + v_current_max: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + format_max: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragInt( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igDragInt2( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igDragInt3( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igDragInt4( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igDragIntRange2( + label: *const c_char, + v_current_min: *mut c_int, + v_current_max: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + format: *const c_char, + format_max: *const c_char, + ) -> bool; + pub fn igDragScalar( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + v_speed: c_float, + v_min: *const c_void, + v_max: *const c_void, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragScalarN( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + components: c_int, + v_speed: c_float, + v_min: *const c_void, + v_max: *const c_void, + format: *const c_char, + power: c_float, + ) -> bool; +} + +// Widgets: Sliders +extern "C" { + pub fn igSliderFloat( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat2( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat3( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat4( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderAngle( + label: *const c_char, + v_rad: *mut c_float, + v_degrees_min: c_float, + v_degrees_max: c_float, + ) -> bool; + pub fn igSliderInt( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igSliderInt2( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igSliderInt3( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igSliderInt4( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igSliderScalar( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + v_min: *const c_void, + v_max: *const c_void, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderScalarN( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + components: c_int, + v_min: *const c_void, + v_max: *const c_void, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igVSliderFloat( + label: *const c_char, + size: ImVec2, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + format: *const c_char, + power: c_float, + ) -> bool; + pub fn igVSliderInt( + label: *const c_char, + size: ImVec2, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + format: *const c_char, + ) -> bool; + pub fn igVSliderScalar( + label: *const c_char, + size: ImVec2, + data_type: ImGuiDataType, + v: *mut c_void, + v_min: *const c_void, + v_max: *const c_void, + format: *const c_char, + power: c_float, + ) -> bool; +} + +// Widgets: Input with Keyboard +extern "C" { + pub fn igInputText( + label: *const c_char, + buf: *mut c_char, + buf_size: usize, + flags: ImGuiInputTextFlags, + callback: ImGuiInputTextCallback, + user_data: *mut c_void, + ) -> bool; + pub fn igInputTextMultiline( + label: *const c_char, + buf: *mut c_char, + buf_size: usize, + size: ImVec2, + flags: ImGuiInputTextFlags, + callback: ImGuiInputTextCallback, + user_data: *mut c_void, + ) -> bool; + pub fn igInputFloat( + label: *const c_char, + v: *mut c_float, + step: c_float, + step_fast: c_float, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat2( + label: *const c_char, + v: *mut c_float, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat3( + label: *const c_char, + v: *mut c_float, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat4( + label: *const c_char, + v: *mut c_float, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt( + label: *const c_char, + v: *mut c_int, + step: c_int, + step_fast: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt2( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt3( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt4( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputDouble( + label: *const c_char, + v: *mut c_double, + step: c_double, + step_fast: c_double, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputScalar( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + step: *const c_void, + step_fast: *const c_void, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputScalarN( + label: *const c_char, + data_type: ImGuiDataType, + v: *mut c_void, + components: c_int, + step: *const c_void, + step_fast: *const c_void, + format: *const c_char, + extra_flags: ImGuiInputTextFlags, ) -> bool; } @@ -1300,264 +774,13 @@ extern "C" { pub fn igSetColorEditOptions(flags: ImGuiColorEditFlags); } -// Widgets: Drags -extern "C" { - pub fn igDragFloat( - label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igDragFloat2( - label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igDragFloat3( - label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igDragFloat4( - label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igDragFloatRange2( - label: *const c_char, - v_current_min: *mut c_float, - v_current_max: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - display_format_max: *const c_char, - power: c_float, - ) -> bool; - pub fn igDragInt( - label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igDragInt2( - label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igDragInt3( - label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igDragInt4( - label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igDragIntRange2( - label: *const c_char, - v_current_min: *mut c_int, - v_current_max: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - display_format_max: *const c_char, - ) -> bool; -} - -// Widgets: Input with Keyboard -extern "C" { - pub fn igInputText( - label: *const c_char, - buf: *mut c_char, - buf_size: usize, - flags: ImGuiInputTextFlags, - callback: ImGuiTextEditCallback, - user_data: *mut c_void, - ) -> bool; - pub fn igInputTextMultiline( - label: *const c_char, - buf: *mut c_char, - buf_size: usize, - size: ImVec2, - flags: ImGuiInputTextFlags, - callback: ImGuiTextEditCallback, - user_data: *mut c_void, - ) -> bool; - pub fn igInputFloat( - label: *const c_char, - v: *mut c_float, - step: c_float, - step_fast: c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputFloat2( - label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputFloat3( - label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputFloat4( - label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputInt( - label: *const c_char, - v: *mut c_int, - step: c_int, - step_fast: c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputInt2( - label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputInt3( - label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; - pub fn igInputInt4( - label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags, - ) -> bool; -} - -// Widgets: Sliders -extern "C" { - pub fn igSliderFloat( - label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igSliderFloat2( - label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igSliderFloat3( - label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igSliderFloat4( - label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igSliderAngle( - label: *const c_char, - v_rad: *mut c_float, - v_degrees_min: c_float, - v_degrees_max: c_float, - ) -> bool; - pub fn igSliderInt( - label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igSliderInt2( - label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igSliderInt3( - label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igSliderInt4( - label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; - pub fn igVSliderFloat( - label: *const c_char, - size: ImVec2, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float, - ) -> bool; - pub fn igVSliderInt( - label: *const c_char, - size: ImVec2, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - ) -> bool; -} - // Widgets: Trees extern "C" { - pub fn igTreeNode(label: *const c_char) -> bool; - pub fn igTreeNodeStr(str_id: *const c_char, fmt: *const c_char, ...) -> bool; + pub fn igTreeNodeStr(label: *const c_char) -> bool; + pub fn igTreeNodeStrStr(str_id: *const c_char, fmt: *const c_char, ...) -> bool; pub fn igTreeNodePtr(ptr_id: *const c_void, fmt: *const c_char, ...) -> bool; - // pub fn igTreeNodeStrV(str_id: *const c_char, fmt: *const c_char, args: va_list) -> bool; - // pub fn igTreeNodePtrV(ptr_id: *const c_void, fmt: *const c_char, args: va_list) -> bool; - pub fn igTreeNodeEx(label: *const c_char, flags: ImGuiTreeNodeFlags) -> bool; - pub fn igTreeNodeExStr( + pub fn igTreeNodeExStr(label: *const c_char, flags: ImGuiTreeNodeFlags) -> bool; + pub fn igTreeNodeExStrStr( str_id: *const c_char, flags: ImGuiTreeNodeFlags, fmt: *const c_char, @@ -1569,10 +792,6 @@ extern "C" { fmt: *const c_char, ... ) -> bool; - // pub fn igTreeNodeExV(str_id: *const c_char, flags: ImGuiTreeNodeFlags, - // fmt: *const c_char, args: va_list) -> bool; - // pub fn igTreeNodeExVPtr(ptr_id: *const c_void, flags: ImGuiTreeNodeFlags, - // fmt: *const c_char, args: va_list) -> bool; pub fn igTreePushStr(str_id: *const c_char); pub fn igTreePushPtr(ptr_id: *const c_void); pub fn igTreePop(); @@ -1580,14 +799,14 @@ extern "C" { pub fn igGetTreeNodeToLabelSpacing() -> c_float; pub fn igSetNextTreeNodeOpen(opened: bool, cond: ImGuiCond); pub fn igCollapsingHeader(label: *const c_char, flags: ImGuiTreeNodeFlags) -> bool; - pub fn igCollapsingHeaderEx( + pub fn igCollapsingHeaderBoolPtr( label: *const c_char, open: *mut bool, flags: ImGuiTreeNodeFlags, ) -> bool; } -// Widgets: Selectable / Lists +// Widgets: Selectables extern "C" { pub fn igSelectable( label: *const c_char, @@ -1595,20 +814,24 @@ extern "C" { flags: ImGuiSelectableFlags, size: ImVec2, ) -> bool; - pub fn igSelectableEx( + pub fn igSelectableBoolPtr( label: *const c_char, p_selected: *mut bool, flags: ImGuiSelectableFlags, size: ImVec2, ) -> bool; - pub fn igListBox( +} + +// Widgets: List Boxes +extern "C" { + pub fn igListBoxStr_arr( label: *const c_char, current_item: *mut c_int, items: *const *const c_char, items_count: c_int, height_in_items: c_int, ) -> bool; - pub fn igListBox2( + pub fn igListBoxFnPtr( label: *const c_char, current_item: *mut c_int, items_getter: extern "C" fn(data: *mut c_void, idx: c_int, out_text: *mut *const c_char) @@ -1617,8 +840,8 @@ extern "C" { items_count: c_int, height_in_items: c_int, ) -> bool; - pub fn igListBoxHeader(label: *const c_char, size: ImVec2) -> bool; - pub fn igListBoxHeader2( + pub fn igListBoxHeaderVec2(label: *const c_char, size: ImVec2) -> bool; + pub fn igListBoxHeaderInt( label: *const c_char, items_count: c_int, height_in_items: c_int, @@ -1626,6 +849,54 @@ extern "C" { pub fn igListBoxFooter(); } +// Widgets: Data Plotting +extern "C" { + pub fn igPlotLines( + label: *const c_char, + values: *const c_float, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + stride: c_int, + ); + pub fn igPlotLinesFnPtr( + label: *const c_char, + values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, + data: *mut c_void, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + ); + pub fn igPlotHistogramFloatPtr( + label: *const c_char, + values: *const c_float, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + stride: c_int, + ); + pub fn igPlotHistogramFnPtr( + label: *const c_char, + values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, + data: *mut c_void, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + ); +} + // Widgets: Value() Helpers extern "C" { pub fn igValueBool(prefix: *const c_char, b: bool); @@ -1634,14 +905,6 @@ extern "C" { pub fn igValueFloat(prefix: *const c_char, v: c_float, float_format: *const c_char); } -// Tooltip -extern "C" { - pub fn igSetTooltip(fmt: *const c_char, ...); - // pub fn igSetTooltipV(fmt: *const c_char, args: va_list); - pub fn igBeginTooltip(); - pub fn igEndTooltip(); -} - // Widgets: Menus extern "C" { pub fn igBeginMainMenuBar() -> bool; @@ -1650,13 +913,13 @@ extern "C" { pub fn igEndMenuBar(); pub fn igBeginMenu(label: *const c_char, enabled: bool) -> bool; pub fn igEndMenu(); - pub fn igMenuItem( + pub fn igMenuItemBool( label: *const c_char, shortcut: *const c_char, selected: bool, enabled: bool, ) -> bool; - pub fn igMenuItemPtr( + pub fn igMenuItemBoolPtr( label: *const c_char, shortcut: *const c_char, p_selected: *mut bool, @@ -1664,16 +927,17 @@ extern "C" { ) -> bool; } -// Popup +// Tooltips +extern "C" { + pub fn igBeginTooltip(); + pub fn igEndTooltip(); + pub fn igSetTooltip(fmt: *const c_char, ...); +} + +// Popups extern "C" { pub fn igOpenPopup(str_id: *const c_char); - pub fn igOpenPopupOnItemClick(str_id: *const c_char, mouse_button: c_int) -> bool; - pub fn igBeginPopup(str_id: *const c_char) -> bool; - pub fn igBeginPopupModal( - name: *const c_char, - open: *mut bool, - extra_flags: ImGuiWindowFlags, - ) -> bool; + pub fn igBeginPopup(str_id: *const c_char, flags: ImGuiWindowFlags) -> bool; pub fn igBeginPopupContextItem(str_id: *const c_char, mouse_button: c_int) -> bool; pub fn igBeginPopupContextWindow( str_id: *const c_char, @@ -1681,12 +945,27 @@ extern "C" { also_over_items: bool, ) -> bool; pub fn igBeginPopupContextVoid(str_id: *const c_char, mouse_button: c_int) -> bool; + pub fn igBeginPopupModal(name: *const c_char, open: *mut bool, flags: ImGuiWindowFlags) + -> bool; pub fn igEndPopup(); + pub fn igOpenPopupOnItemClick(str_id: *const c_char, mouse_button: c_int) -> bool; pub fn igIsPopupOpen(str_id: *const c_char) -> bool; pub fn igCloseCurrentPopup(); } -// Logging +// Columns +extern "C" { + pub fn igColumns(count: c_int, id: *const c_char, border: bool); + pub fn igNextColumn(); + pub fn igGetColumnIndex() -> c_int; + pub fn igGetColumnWidth(column_index: c_int) -> c_float; + pub fn igSetColumnWidth(column_index: c_int, width: c_float); + pub fn igGetColumnOffset(column_index: c_int) -> c_float; + pub fn igSetColumnOffset(column_index: c_int, offset_x: c_float); + pub fn igGetColumnsCount() -> c_int; +} + +// Logging/Capture extern "C" { pub fn igLogToTTY(max_depth: c_int); pub fn igLogToFile(max_depth: c_int, filename: *const c_char); @@ -1696,7 +975,7 @@ extern "C" { pub fn igLogText(fmt: *const c_char, ...); } -// DragDrop +// Drag and Drop extern "C" { /// Call when current ID is active. /// @@ -1705,12 +984,12 @@ extern "C" { /// 1. call [`igSetDragDropPayload`] exactly once, /// 2. you may render the payload visual/description, /// 3. pcall [`igEndDragDropSource`] - pub fn igBeginDragDropSource(flags: ImGuiDragDropFlags, mouse_button: c_int) -> bool; + pub fn igBeginDragDropSource(flags: ImGuiDragDropFlags) -> bool; /// Use 'cond' to choose to submit payload on drag start or every frame pub fn igSetDragDropPayload( type_: *const c_char, data: *const c_void, - size: libc::size_t, + size: size_t, cond: ImGuiCond, ) -> bool; pub fn igEndDragDropSource(); @@ -1732,13 +1011,6 @@ extern "C" { pub fn igPopClipRect(); } -// Styles -extern "C" { - pub fn igStyleColorsClassic(dst: *mut ImGuiStyle); - pub fn igStyleColorsDark(dst: *mut ImGuiStyle); - pub fn igStyleColorsLight(dst: *mut ImGuiStyle); -} - // Focus extern "C" { pub fn igSetItemDefaultFocus(); @@ -1749,35 +1021,34 @@ extern "C" { extern "C" { pub fn igIsItemHovered(flags: ImGuiHoveredFlags) -> bool; pub fn igIsItemActive() -> bool; + pub fn igIsItemFocused() -> bool; pub fn igIsItemClicked(mouse_button: c_int) -> bool; pub fn igIsItemVisible() -> bool; + pub fn igIsItemEdited() -> bool; + pub fn igIsItemDeactivated() -> bool; + pub fn igIsItemDeactivatedAfterEdit() -> bool; pub fn igIsAnyItemHovered() -> bool; pub fn igIsAnyItemActive() -> bool; - pub fn igGetItemRectMin(out: *mut ImVec2); - pub fn igGetItemRectMax(out: *mut ImVec2); - pub fn igGetItemRectSize(out: *mut ImVec2); + pub fn igIsAnyItemFocused() -> bool; + pub fn igGetItemRectMin() -> ImVec2; + pub fn igGetItemRectMax() -> ImVec2; + pub fn igGetItemRectSize() -> ImVec2; pub fn igSetItemAllowOverlap(); - pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; - pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; - pub fn igIsAnyWindowHovered() -> bool; - pub fn igIsRectVisible(item_size: ImVec2) -> bool; - pub fn igIsRectVisible2(rect_min: *const ImVec2, rect_max: *const ImVec2) -> bool; + pub fn igIsRectVisible(size: ImVec2) -> bool; + pub fn igIsRectVisibleVec2(rect_min: ImVec2, rect_max: ImVec2) -> bool; pub fn igGetTime() -> c_float; pub fn igGetFrameCount() -> c_int; + pub fn igGetOverlayDrawList() -> *mut ImDrawList; + pub fn igGetDrawListSharedData() -> *mut ImDrawListSharedData; pub fn igGetStyleColorName(idx: ImGuiCol) -> *const c_char; - pub fn igCalcItemRectClosestPoint( - out: *mut ImVec2, - pos: ImVec2, - on_edge: bool, - outward: c_float, - ); + pub fn igSetStateStorage(storage: *mut ImGuiStorage); + pub fn igGetStateStorage() -> *mut ImGuiStorage; pub fn igCalcTextSize( - out: *mut ImVec2, text: *const c_char, text_end: *const c_char, hide_text_after_double_hash: bool, wrap_width: c_float, - ); + ) -> ImVec2; pub fn igCalcListClipping( items_count: c_int, items_height: c_float, @@ -1785,10 +1056,10 @@ extern "C" { out_items_display_end: *mut c_int, ); - pub fn igBeginChildFrame(id: ImGuiID, size: ImVec2, extra_flags: ImGuiWindowFlags) -> bool; + pub fn igBeginChildFrame(id: ImGuiID, size: ImVec2, flags: ImGuiWindowFlags) -> bool; pub fn igEndChildFrame(); - pub fn igColorConvertU32ToFloat4(out: *mut ImVec4, color: ImU32); + pub fn igColorConvertU32ToFloat4(color: ImU32) -> ImVec4; pub fn igColorConvertFloat4ToU32(color: ImVec4) -> ImU32; pub fn igColorConvertRGBtoHSV( r: c_float, @@ -1808,12 +1079,6 @@ extern "C" { ); } -// DrawList -extern "C" { - pub fn igGetOverlayDrawList() -> *mut ImDrawList; - pub fn igGetDrawListSharedData() -> *mut ImDrawListSharedData; -} - // Inputs extern "C" { pub fn igGetKeyIndex(imgui_key: ImGuiKey) -> c_int; @@ -1822,15 +1087,16 @@ extern "C" { pub fn igIsKeyReleased(user_key_index: c_int) -> bool; pub fn igGetKeyPressedAmount(key_index: c_int, repeat_delay: c_float, rate: c_float) -> c_int; pub fn igIsMouseDown(button: c_int) -> bool; + pub fn igIsAnyMouseDown() -> bool; pub fn igIsMouseClicked(button: c_int, repeat: bool) -> bool; pub fn igIsMouseDoubleClicked(button: c_int) -> bool; pub fn igIsMouseReleased(button: c_int) -> bool; pub fn igIsMouseDragging(button: c_int, lock_threshold: c_float) -> bool; pub fn igIsMouseHoveringRect(r_min: ImVec2, r_max: ImVec2, clip: bool) -> bool; pub fn igIsMousePosValid(mouse_pos: *const ImVec2) -> bool; - pub fn igGetMousePos(out: *mut ImVec2); - pub fn igGetMousePosOnOpeningCurrentPopup(out: *mut ImVec2); - pub fn igGetMouseDragDelta(out: *mut ImVec2, button: c_int, lock_threshold: c_float); + pub fn igGetMousePos() -> ImVec2; + pub fn igGetMousePosOnOpeningCurrentPopup() -> ImVec2; + pub fn igGetMouseDragDelta(button: c_int, lock_threshold: c_float) -> ImVec2; pub fn igResetMouseDragDelta(button: c_int); pub fn igGetMouseCursor() -> ImGuiMouseCursor; pub fn igSetMouseCursor(cursor: ImGuiMouseCursor); @@ -1838,608 +1104,27 @@ extern "C" { pub fn igCaptureMouseFromApp(capture: bool); } -// Helpers functions to access functions pointers in ImGui::GetIO() +// Clipboard utilities extern "C" { - pub fn igMemAlloc(sz: usize) -> *mut c_void; - pub fn igMemFree(ptr: *mut c_void); pub fn igGetClipboardText() -> *const c_char; pub fn igSetClipboardText(text: *const c_char); } -// Internal state access +// Settings/.Ini Utilities extern "C" { - pub fn igGetVersion() -> *const c_char; - pub fn igCreateContext( - malloc_fn: Option *mut c_void>, - free_fn: Option, - ) -> *mut ImGuiContext; - pub fn igDestroyContext(ctx: *mut ImGuiContext); - pub fn igGetCurrentContext() -> *mut ImGuiContext; - pub fn igSetCurrentContext(ctx: *mut ImGuiContext); + pub fn igLoadIniSettingsFromDisk(ini_filename: *const c_char); + pub fn igLoadIniSettingsFromMemory(ini_data: *const c_char, ini_size: usize); + pub fn igSaveIniSettingsToDisk(ini_filename: *const c_char); + pub fn igSaveIniSettingsToMemory(out_ini_size: *const usize) -> *const c_char; } +// Memory Utilities extern "C" { - pub fn ImFontConfig_DefaultConstructor(config: *mut ImFontConfig); -} - -// ImGuiIO -extern "C" { - pub fn ImGuiIO_AddInputCharacter(c: c_ushort); - pub fn ImGuiIO_AddInputCharactersUTF8(utf8_chars: *const c_char); - pub fn ImGuiIO_ClearInputCharacters(); -} - -// ImGuiTextFilter -extern "C" { - pub fn ImGuiTextFilter_Create(default_filter: *const c_char) -> *mut ImGuiTextFilter; - pub fn ImGuiTextFilter_Destroy(filter: *mut ImGuiTextFilter); - pub fn ImGuiTextFilter_Clear(filter: *mut ImGuiTextFilter); - pub fn ImGuiTextFilter_Draw( - filter: *mut ImGuiTextFilter, - label: *const c_char, - width: c_float, - ) -> bool; - pub fn ImGuiTextFilter_PassFilter( - filter: *const ImGuiTextFilter, - text: *const c_char, - text_end: *const c_char, - ) -> bool; - pub fn ImGuiTextFilter_IsActive(filter: *const ImGuiTextFilter) -> bool; - pub fn ImGuiTextFilter_Build(filter: *const ImGuiTextFilter); - pub fn ImGuiTextFilter_GetInputBuf(filter: *mut ImGuiTextFilter) -> *const c_char; -} - -// ImGuiTextBuffer -extern "C" { - pub fn ImGuiTextBuffer_Create() -> *mut ImGuiTextBuffer; - pub fn ImGuiTextBuffer_Destroy(buffer: *mut ImGuiTextBuffer); - pub fn ImGuiTextBuffer_index(buffer: *mut ImGuiTextBuffer, i: c_int) -> c_char; - pub fn ImGuiTextBuffer_begin(buffer: *const ImGuiTextBuffer) -> *const c_char; - pub fn ImGuiTextBuffer_end(buffer: *const ImGuiTextBuffer) -> *const c_char; - pub fn ImGuiTextBuffer_size(buffer: *const ImGuiTextBuffer) -> c_int; - pub fn ImGuiTextBuffer_empty(buffer: *mut ImGuiTextBuffer) -> bool; - pub fn ImGuiTextBuffer_clear(buffer: *mut ImGuiTextBuffer); - pub fn ImGuiTextBuffer_c_str(buffer: *const ImGuiTextBuffer) -> *const c_char; - pub fn ImGuiTextBuffer_appendf(buffer: *const ImGuiTextBuffer, fmt: *const c_char, ...); -// pub fn ImGuiTextBuffer_appendv( -// buffer: *const ImGuiTextBuffer, -// fmt: *const c_char, -// args: va_list -// ); -} - -// ImGuiStorage -extern "C" { - pub fn ImGuiStorage_Create() -> *mut ImGuiStorage; - pub fn ImGuiStorage_Destroy(storage: *mut ImGuiStorage); - pub fn ImGuiStorage_GetInt( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: c_int, - ) -> c_int; - pub fn ImGuiStorage_SetInt(storage: *mut ImGuiStorage, key: ImGuiID, val: c_int); - pub fn ImGuiStorage_GetBool( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: bool, - ) -> bool; - pub fn ImGuiStorage_SetBool(storage: *mut ImGuiStorage, key: ImGuiID, val: bool); - pub fn ImGuiStorage_GetFloat( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: c_float, - ) -> c_float; - pub fn ImGuiStorage_SetFloat(storage: *mut ImGuiStorage, key: ImGuiID, val: c_float); - pub fn ImGuiStorage_GetVoidPtr(storage: *mut ImGuiStorage, key: ImGuiID); - pub fn ImGuiStorage_SetVoidPtr(storage: *mut ImGuiStorage, key: ImGuiID, val: *mut c_void); - pub fn ImGuiStorage_GetIntRef( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: c_int, - ) -> *mut c_int; - pub fn ImGuiStorage_GetBoolRef( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: bool, - ) -> *mut bool; - pub fn ImGuiStorage_GetFloatRef( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: c_float, - ) -> *mut c_float; - pub fn ImGuiStorage_GetVoidPtrRef( - storage: *mut ImGuiStorage, - key: ImGuiID, - default_val: *mut c_void, - ) -> *mut *mut c_void; - pub fn ImGuiStorage_SetAllInt(storage: *mut ImGuiStorage, val: c_int); -} - -// ImGuiTextEditCallbackData -extern "C" { - pub fn ImGuiTextEditCallbackData_DeleteChars( - data: *mut ImGuiTextEditCallbackData, - pos: c_int, - bytes_count: c_int, - ); - pub fn ImGuiTextEditCallbackData_InsertChars( - data: *mut ImGuiTextEditCallbackData, - pos: c_int, - text: *const c_char, - text_end: *const c_char, - ); - pub fn ImGuiTextEditCallbackData_HasSelection(data: *mut ImGuiTextEditCallbackData) -> bool; -} - -// ImGuiListClipper -extern "C" { - pub fn ImGuiListClipper_Step(clipper: *mut ImGuiListClipper) -> bool; - pub fn ImGuiListClipper_Begin( - clipper: *mut ImGuiListClipper, - count: c_int, - items_height: c_float, - ); - pub fn ImGuiListClipper_End(clipper: *mut ImGuiListClipper); - pub fn ImGuiListClipper_GetDisplayStart(clipper: *mut ImGuiListClipper) -> c_int; - pub fn ImGuiListClipper_GetDisplayEnd(clipper: *mut ImGuiListClipper) -> c_int; -} - -// ImDrawList -extern "C" { - pub fn ImDrawList_GetVertexBufferSize(list: *mut ImDrawList) -> c_int; - pub fn ImDrawList_GetVertexPtr(list: *mut ImDrawList, n: c_int) -> *mut ImDrawVert; - pub fn ImDrawList_GetIndexBufferSize(list: *mut ImDrawList) -> c_int; - pub fn ImDrawList_GetIndexPtr(list: *mut ImDrawList, n: c_int) -> *mut ImDrawIdx; - pub fn ImDrawList_GetCmdSize(list: *mut ImDrawList) -> c_int; - pub fn ImDrawList_GetCmdPtr(list: *mut ImDrawList, n: c_int) -> *mut ImDrawCmd; - - pub fn ImDrawList_Clear(list: *mut ImDrawList); - pub fn ImDrawList_ClearFreeMemory(list: *mut ImDrawList); - pub fn ImDrawList_PushClipRect( - list: *mut ImDrawList, - clip_rect_min: ImVec2, - clip_rect_max: ImVec2, - intersect_with_current_: bool, - ); - pub fn ImDrawList_PushClipRectFullScreen(list: *mut ImDrawList); - pub fn ImDrawList_PopClipRect(list: *mut ImDrawList); - pub fn ImDrawList_PushTextureID(list: *mut ImDrawList, texture_id: ImTextureID); - pub fn ImDrawList_PopTextureID(list: *mut ImDrawList); - pub fn ImDrawList_GetClipRectMin(out: *mut ImVec2, list: *mut ImDrawList); - pub fn ImDrawList_GetClipRectMax(out: *mut ImVec2, list: *mut ImDrawList); - - pub fn ImDrawList_AddLine( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - thickness: c_float, - ); - pub fn ImDrawList_AddRect( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - rounding: c_float, - rounding_corners_flags: ImDrawCornerFlags, - thickness: c_float, - ); - pub fn ImDrawList_AddRectFilled( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - rounding: c_float, - rounding_corners_flags: ImDrawCornerFlags, - ); - pub fn ImDrawList_AddRectFilledMultiColor( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col_upr_left: ImU32, - col_upr_right: ImU32, - col_bot_right: ImU32, - col_bot_left: ImU32, - ); - pub fn ImDrawList_AddQuad( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - col: ImU32, - thickness: c_float, - ); - pub fn ImDrawList_AddQuadFilled( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_AddTriangle( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - col: ImU32, - thickness: c_float, - ); - pub fn ImDrawList_AddTriangleFilled( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_AddCircle( - list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - col: ImU32, - num_segments: c_int, - thickness: c_float, - ); - pub fn ImDrawList_AddCircleFilled( - list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - col: ImU32, - num_segments: c_int, - ); - pub fn ImDrawList_AddText( - list: *mut ImDrawList, - pos: ImVec2, - col: ImU32, - text_begin: *const c_char, - text_end: *const c_char, - ); - pub fn ImDrawList_AddTextExt( - list: *mut ImDrawList, - font: *const ImFont, - font_size: c_float, - pos: ImVec2, - col: ImU32, - text_begin: *const c_char, - text_end: *const c_char, - wrap_width: c_float, - cpu_fine_clip_rect: *const ImVec4, - ); - pub fn ImDrawList_AddImage( - list: *mut ImDrawList, - user_texture_id: ImTextureID, - a: ImVec2, - b: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_AddImageQuad( - list: *mut ImDrawList, - user_texture_id: ImTextureID, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - uv_c: ImVec2, - uv_d: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_AddImageRounded( - list: *mut ImDrawList, - user_texture_id: ImTextureID, - a: ImVec2, - b: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - col: ImU32, - rounding: c_float, - rounding_corners: c_int, - ); - pub fn ImDrawList_AddPolyLine( - list: *mut ImDrawList, - points: *const ImVec2, - num_points: c_int, - col: ImU32, - closed: bool, - thickness: c_float, - ); - pub fn ImDrawList_AddConvexPolyFilled( - list: *mut ImDrawList, - points: *const ImVec2, - num_points: c_int, - col: ImU32, - ); - pub fn ImDrawList_AddBezierCurve( - list: *mut ImDrawList, - pos0: ImVec2, - cp0: ImVec2, - cp1: ImVec2, - pos1: ImVec2, - col: ImU32, - thickness: c_float, - num_segments: c_int, - ); - - pub fn ImDrawList_PathClear(list: *mut ImDrawList); - pub fn ImDrawList_PathLineTo(list: *mut ImDrawList, pos: ImVec2); - pub fn ImDrawList_PathLineToMergeDuplicate(list: *mut ImDrawList, pos: ImVec2); - pub fn ImDrawList_PathFillConvex(list: *mut ImDrawList, col: ImU32); - pub fn ImDrawList_PathStroke( - list: *mut ImDrawList, - col: ImU32, - closed: bool, - thickness: c_float, - ); - pub fn ImDrawList_PathArcTo( - list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - a_min: c_float, - a_max: c_float, - num_segments: c_int, - ); - pub fn ImDrawList_PathArcToFast( - list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - a_min_of_12: c_int, - a_max_of_12: c_int, - ); - pub fn ImDrawList_PathBezierCurveTo( - list: *mut ImDrawList, - p1: ImVec2, - p2: ImVec2, - p3: ImVec2, - num_segments: c_int, - ); - pub fn ImDrawList_PathRect( - list: *mut ImDrawList, - rect_min: ImVec2, - rect_max: ImVec2, - rounding: c_float, - rounding_corners_flags: c_int, - ); - - pub fn ImDrawList_ChannelsSplit(list: *mut ImDrawList, channels_count: c_int); - pub fn ImDrawList_ChannelsMerge(list: *mut ImDrawList); - pub fn ImDrawList_ChannelsSetCurrent(list: *mut ImDrawList, channel_index: c_int); - - pub fn ImDrawList_AddCallback( - list: *mut ImDrawList, - callback: ImDrawCallback, - callback_data: *mut c_void, - ); - pub fn ImDrawList_AddDrawCmd(list: *mut ImDrawList); - - pub fn ImDrawList_PrimReserve(list: *mut ImDrawList, idx_count: c_int, vtx_count: c_int); - pub fn ImDrawList_PrimRect(list: *mut ImDrawList, a: ImVec2, b: ImVec2, col: ImU32); - pub fn ImDrawList_PrimRectUV( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_PrimQuadUV( - list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - uv_c: ImVec2, - uv_d: ImVec2, - col: ImU32, - ); - pub fn ImDrawList_PrimWriteVtx(list: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); - pub fn ImDrawList_PrimWriteIdx(list: *mut ImDrawList, idx: ImDrawIdx); - pub fn ImDrawList_PrimVtx(list: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); - pub fn ImDrawList_UpdateClipRect(list: *mut ImDrawList); - pub fn ImDrawList_UpdateTextureID(list: *mut ImDrawList); -} - -// ImDrawData -extern "C" { - pub fn ImDrawData_DeIndexAllBuffers(drawData: *mut ImDrawData); - pub fn ImDrawData_ScaleClipRects(drawData: *mut ImDrawData, sc: ImVec2); -} - -extern "C" { - pub fn ImFontAtlas_GetTexDataAsRGBA32( - atlas: *mut ImFontAtlas, - out_pixels: *mut *mut c_uchar, - out_width: *mut c_int, - out_height: *mut c_int, - out_bytes_per_pixel: *mut c_int, - ); - pub fn ImFontAtlas_GetTexDataAsAlpha8( - atlas: *mut ImFontAtlas, - out_pixels: *mut *mut c_uchar, - out_width: *mut c_int, - out_height: *mut c_int, - out_bytes_per_pixel: *mut c_int, - ); - pub fn ImFontAtlas_SetTexID(atlas: *mut ImFontAtlas, tex: ImTextureID); - pub fn ImFontAtlas_AddFont( - atlas: *mut ImFontAtlas, - font_cfg: *const ImFontConfig, - ) -> *mut ImFont; - pub fn ImFontAtlas_AddFontDefault( - atlas: *mut ImFontAtlas, - font_cfg: *const ImFontConfig, - ) -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromFileTTF( - atlas: *mut ImFontAtlas, - filename: *const c_char, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar, - ) -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromMemoryTTF( - atlas: *mut ImFontAtlas, - font_data: *mut c_void, - font_size: c_int, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar, - ) -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromMemoryCompressedTTF( - atlas: *mut ImFontAtlas, - compressed_font_data: *const c_void, - compressed_font_size: c_int, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar, - ) -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromMemoryCompressedBase85TTF( - atlas: *mut ImFontAtlas, - compressed_font_data_base85: *const c_char, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar, - ) -> *mut ImFont; - pub fn ImFontAtlas_ClearTexData(atlas: *mut ImFontAtlas); - pub fn ImFontAtlas_Clear(atlas: *mut ImFontAtlas); - pub fn ImFontAtlas_GetGlyphRangesDefault(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetGlyphRangesKorean(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetGlyphRangesJapanese(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetGlyphRangesChinese(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetGlyphRangesCyrillic(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetGlyphRangesThai(atlas: *mut ImFontAtlas) -> *const ImWchar; - pub fn ImFontAtlas_GetTexID(atlas: *mut ImFontAtlas) -> ImTextureID; - pub fn ImFontAtlas_GetTexPixelsAlpha8(atlas: *mut ImFontAtlas) -> *mut c_uchar; - pub fn ImFontAtlas_GetTexPixelsRGBA32(altas: *mut ImFontAtlas) -> *mut c_uint; - pub fn ImFontAtlas_GetTexWidth(atlas: *mut ImFontAtlas) -> c_int; - pub fn ImFontAtlas_GetTexHeight(atlas: *mut ImFontAtlas) -> c_int; - pub fn ImFontAtlas_GetTexDesiredWidth(atlas: *mut ImFontAtlas) -> c_int; - pub fn ImFontAtlas_SetTexDesiredWidth(atlas: *mut ImFontAtlas, TexDesiredWidth_: c_int); - pub fn ImFontAtlas_GetTexGlyphPadding(atlas: *mut ImFontAtlas) -> c_int; - pub fn ImFontAtlas_SetTexGlyphPadding(atlas: *mut ImFontAtlas, TexGlyphPadding_: c_int); - pub fn ImFontAtlas_GetTexUvWhitePixel(atlas: *mut ImFontAtlas, out: *mut ImVec2); -} - -// ImFontAtlas::Fonts -extern "C" { - pub fn ImFontAtlas_Fonts_size(atlas: *mut ImFontAtlas) -> c_int; - pub fn ImFontAtlas_Fonts_index(atlas: *mut ImFontAtlas, index: c_int) -> *mut ImFont; -} - -// ImFont -extern "C" { - pub fn ImFont_GetFontSize(font: *const ImFont) -> c_float; - pub fn ImFont_SetFontSize(font: *mut ImFont, FontSize_: c_float); - pub fn ImFont_GetScale(font: *const ImFont) -> c_float; - pub fn ImFont_SetScale(font: *mut ImFont, Scale_: c_float); - pub fn ImFont_GetDisplayOffset(font: *const ImFont, out: *mut ImVec2); - pub fn ImFont_GetFallbackGlyph(font: *const ImFont) -> *const ImFontGlyph; - pub fn ImFont_SetFallbackGlyph(font: *mut ImFont, FallbackGlyph: *const ImFontGlyph); - pub fn ImFont_GetFallbackAdvanceX(font: *const ImFont) -> c_float; - pub fn ImFont_GetFallbackChar(font: *const ImFont) -> ImWchar; - pub fn ImFont_GetConfigDataCount(font: *const ImFont) -> c_short; - pub fn ImFont_GetConfigData(font: *mut ImFont) -> *mut ImFontConfig; - pub fn ImFont_GetContainerAtlas(font: *mut ImFont) -> *mut ImFontAtlas; - pub fn ImFont_GetAscent(font: *const ImFont) -> c_float; - pub fn ImFont_GetDescent(font: *const ImFont) -> c_float; - pub fn ImFont_GetMetricsTotalSurface(font: *const ImFont) -> c_int; - pub fn ImFont_ClearOutputData(font: *mut ImFont); - pub fn ImFont_BuildLookupTable(font: *mut ImFont); - pub fn ImFont_FindGlyph(font: *const ImFont, c: ImWchar) -> *const ImFontGlyph; - pub fn ImFont_SetFallbackChar(font: *mut ImFont, c: ImWchar); - pub fn ImFont_GetCharAdvance(font: *const ImFont, c: ImWchar) -> c_float; - pub fn ImFont_IsLoaded(font: *const ImFont) -> bool; - pub fn ImFont_GetDebugName(font: *const ImFont) -> *const c_char; - pub fn ImFont_CalcTextSizeA( - font: *const ImFont, - out: *mut ImVec2, - size: c_float, - max_width: c_float, - wrap_width: c_float, - text_begin: *const c_char, - text_end: *const c_char, - remaining: *mut *const c_char, - ); - pub fn ImFont_CalcWordWrapPositionA( - font: *const ImFont, - scale: c_float, - text: *const c_char, - text_end: *const c_char, - wrap_width: c_float, - ) -> *const c_char; - pub fn ImFont_RenderChar( - font: *const ImFont, - draw_list: *mut ImDrawList, - size: c_float, - pos: ImVec2, - col: ImU32, - c: c_ushort, - ); - pub fn ImFont_RenderText( - font: *const ImFont, - draw_list: *mut ImDrawList, - size: c_float, - pos: ImVec2, - col: ImU32, - clip_rect: *const ImVec4, - text_begin: *const c_char, - text_end: *const c_char, - wrap_width: c_float, - cpu_fine_clip: bool, - ); -} - -// ImFont::Glyph -extern "C" { - pub fn ImFont_Glyphs_size(font: *const ImFont) -> c_int; - pub fn ImFont_Glyphs_index(font: *mut ImFont, index: c_int) -> *mut ImFontGlyph; -} - -// ImFont::IndexXAdvance -extern "C" { - pub fn ImFont_IndexXAdvance_size(font: *const ImFont) -> c_int; - pub fn ImFont_IndexXAdvance_index(font: *const ImFont, index: c_int) -> c_float; -} - -// ImFont::IndexLookup -extern "C" { - pub fn ImFont_IndexLookup_size(ofnt: *const ImFont) -> c_int; - pub fn ImFont_IndexLookup_index(font: *const ImFont, index: c_int) -> c_ushort; -} - -// Although this test is sensitive to ImGui updates, it's useful to reveal potential -// alignment errors -#[test] -fn test_default_style() { - let style = unsafe { &*igGetStyle() }; - assert_eq!(style.alpha, 1.0); - assert_eq!(style.window_padding, ImVec2::new(8.0, 8.0)); - assert_eq!(style.window_rounding, 7.0); - assert_eq!(style.window_border_size, 0.0); - assert_eq!(style.window_min_size, ImVec2::new(32.0, 32.0)); - assert_eq!(style.window_title_align, ImVec2::new(0.0, 0.5)); - assert_eq!(style.popup_rounding, 0.0); - assert_eq!(style.popup_border_size, 1.0); - assert_eq!(style.frame_padding, ImVec2::new(4.0, 3.0)); - assert_eq!(style.frame_rounding, 0.0); - assert_eq!(style.frame_border_size, 0.0); - assert_eq!(style.item_spacing, ImVec2::new(8.0, 4.0)); - assert_eq!(style.item_inner_spacing, ImVec2::new(4.0, 4.0)); - assert_eq!(style.touch_extra_padding, ImVec2::new(0.0, 0.0)); - assert_eq!(style.indent_spacing, 21.0); - assert_eq!(style.columns_min_spacing, 6.0); - assert_eq!(style.scrollbar_size, 16.0); - assert_eq!(style.scrollbar_rounding, 9.0); - assert_eq!(style.grab_min_size, 10.0); - assert_eq!(style.grab_rounding, 0.0); - assert_eq!(style.button_text_align, ImVec2::new(0.5, 0.5)); - assert_eq!(style.display_window_padding, ImVec2::new(22.0, 22.0)); - assert_eq!(style.display_safe_area_padding, ImVec2::new(4.0, 4.0)); - assert_eq!(style.anti_aliased_lines, true); - assert_eq!(style.anti_aliased_fill, true); - assert_eq!(style.curve_tessellation_tol, 1.25); + pub fn igSetAllocatorFunctions( + alloc_func: Option *mut c_void>, + free_func: Option, + user_data: *mut c_void, + ); + pub fn igMemAlloc(size: usize) -> *mut c_void; + pub fn igMemFree(ptr: *mut c_void); } diff --git a/imgui-sys/src/structs.rs b/imgui-sys/src/structs.rs new file mode 100644 index 0000000..e0559ef --- /dev/null +++ b/imgui-sys/src/structs.rs @@ -0,0 +1,1054 @@ +use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void}; +use std::slice; + +use super::enums::{ImGuiCol, ImGuiKey, ImGuiMouseCursor, ImGuiNavInput}; +use super::flags::{ + ImDrawCornerFlags, ImDrawListFlags, ImFontAtlasFlags, ImGuiBackendFlags, ImGuiConfigFlags, + ImGuiInputTextFlags, +}; +use super::{ImDrawCallback, ImDrawIdx, ImGuiID, ImTextureID, ImU32, ImVec2, ImVec4, ImWchar}; + +/// Font atlas glyph range builder +#[repr(C)] +pub struct GlyphRangesBuilder { + pub used_chars: ImVector, +} + +/// Font atlas custom rectangle +#[repr(C)] +pub struct CustomRect { + pub id: c_uint, + pub width: c_ushort, + pub height: c_ushort, + pub x: c_ushort, + pub y: c_ushort, + pub glyph_advance_x: c_float, + pub glyph_offset: ImVec2, + pub font: *mut ImFont, +} + +/// Temporary storage for outputting drawing commands out of order +#[repr(C)] +pub struct ImDrawChannel { + pub cmd_buffer: ImVector, + pub idx_buffer: ImVector, +} + +/// A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call) +#[repr(C)] +pub struct ImDrawCmd { + pub elem_count: c_uint, + pub clip_rect: ImVec4, + pub texture_id: ImTextureID, + pub user_callback: ImDrawCallback, + pub user_callback_data: *mut c_void, +} + +/// All draw command lists required to render the frame +#[repr(C)] +pub struct ImDrawData { + pub valid: bool, + pub cmd_lists: *mut *mut ImDrawList, + pub cmd_lists_count: c_int, + pub total_idx_count: c_int, + pub total_vtx_count: c_int, + pub display_pos: ImVec2, + pub display_size: ImVec2, +} + +impl ImDrawData { + pub unsafe fn cmd_lists(&self) -> &[*const ImDrawList] { + let cmd_lists = self.cmd_lists as *const *const ImDrawList; + slice::from_raw_parts(cmd_lists, self.cmd_lists_count as usize) + } +} + +/// A single draw command list (generally one per window) +#[repr(C)] +pub struct ImDrawList { + pub cmd_buffer: ImVector, + pub idx_buffer: ImVector, + pub vtx_buffer: ImVector, + pub flags: ImDrawListFlags, + + data: *const ImDrawListSharedData, + owner_name: *const c_char, + vtx_current_idx: c_uint, + vtx_write_ptr: *mut ImDrawVert, + idx_write_ptr: *mut ImDrawIdx, + clip_rect_stack: ImVector, + texture_id_stack: ImVector, + path: ImVector, + channels_current: c_int, + channels_count: c_int, + channels: ImVector, +} + +/// Data shared among multiple draw lists +#[repr(C)] +pub struct ImDrawListSharedData { + /// UV of white pixel in the atlas + tex_uv_white_pixel: ImVec2, + /// Current/default font (optional, for simplified AddText overload) + font: *mut ImFont, + /// Current/default font size (optional, for simplified AddText overload) + font_size: c_float, + curve_tessellation_tol: c_float, + /// Value for PushClipRectFullscreen() + clip_rect_fullscreen: ImVec4, + circle_vtx12: [ImVec2; 12], +} + +/// A single vertex +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +pub struct ImDrawVert { + pub pos: ImVec2, + pub uv: ImVec2, + pub col: ImU32, +} + +/// Runtime data for a single font within a parent ImFontAtlas +#[repr(C)] +pub struct ImFont { + pub font_size: c_float, + pub scale: c_float, + pub display_offset: ImVec2, + pub glyphs: ImVector, + pub index_advance_x: ImVector, + pub index_lookup: ImVector, + pub fallback_glyph: *const ImFontGlyph, + pub fallback_advance_x: c_float, + pub fallback_char: ImWchar, + + pub config_data_count: c_short, + pub config_data: *mut ImFontConfig, + pub container_font_atlas: *mut ImFontAtlas, + pub ascent: c_float, + pub descent: c_float, + pub dirty_lookup_tables: bool, + pub metrics_total_surface: c_int, +} + +/// Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader +#[repr(C)] +pub struct ImFontAtlas { + pub locked: bool, + pub flags: ImFontAtlasFlags, + pub tex_id: ImTextureID, + pub tex_desired_width: c_int, + pub tex_glyph_padding: c_int, + + pub tex_pixels_alpha8: *mut c_uchar, + pub tex_pixels_rgba32: *mut c_uint, + pub tex_width: c_int, + pub tex_height: c_int, + pub tex_uv_scale: ImVec2, + pub tex_uv_white_pixel: ImVec2, + pub fonts: ImVector<*mut ImFont>, + pub custom_rects: ImVector, + pub config_data: ImVector, + pub custom_rect_ids: [c_int; 1], +} + +/// Configuration data when adding a font or merging fonts +#[repr(C)] +pub struct ImFontConfig { + pub font_data: *mut c_void, + pub font_data_size: c_int, + pub font_data_owned_by_atlas: bool, + pub font_no: c_int, + pub size_pixels: c_float, + pub oversample_h: c_int, + pub oversample_v: c_int, + pub pixel_snap_h: bool, + pub glyph_extra_spacing: ImVec2, + pub glyph_offset: ImVec2, + pub glyph_ranges: *const ImWchar, + pub glyph_min_advance_x: c_float, + pub glyph_max_advance_x: c_float, + pub merge_mode: bool, + pub rasterizer_flags: c_uint, + pub rasterizer_multiply: c_float, + + name: [c_char; 40], + dst_font: *mut ImFont, +} + +/// Font glyph +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +pub struct ImFontGlyph { + pub codepoint: ImWchar, + pub advance_x: c_float, + pub x0: c_float, + pub y0: c_float, + pub x1: c_float, + pub y1: c_float, + pub u0: c_float, + pub v0: c_float, + pub u1: c_float, + pub v1: c_float, +} + +/// Shared state of input text callback +#[repr(C)] +pub struct ImGuiInputTextCallbackData { + pub event_flag: ImGuiInputTextFlags, + pub flags: ImGuiInputTextFlags, + pub user_data: *mut c_void, + + pub event_char: ImWchar, + pub event_key: ImGuiKey, + pub buf: *mut c_char, + pub buf_text_len: c_int, + pub buf_size: c_int, + pub buf_dirty: bool, + pub cursor_pos: c_int, + pub selection_start: c_int, + pub selection_end: c_int, +} + +/// Main configuration and I/O between your application and ImGui +#[repr(C)] +pub struct ImGuiIO { + pub config_flags: ImGuiConfigFlags, + pub backend_flags: ImGuiBackendFlags, + pub display_size: ImVec2, + pub delta_time: c_float, + pub ini_saving_rate: c_float, + pub ini_filename: *const c_char, + pub log_filename: *const c_char, + pub mouse_double_click_time: c_float, + pub mouse_double_click_max_dist: c_float, + pub mouse_drag_threshold: c_float, + pub key_map: [c_int; ImGuiKey::COUNT], + pub key_repeat_delay: c_float, + pub key_repeat_rate: c_float, + pub user_data: *mut c_void, + pub fonts: *mut ImFontAtlas, + pub font_global_scale: c_float, + pub font_allow_user_scaling: bool, + pub font_default: *mut ImFont, + pub display_framebuffer_scale: ImVec2, + pub display_visible_min: ImVec2, + pub display_visible_max: ImVec2, + pub mouse_draw_cursor: bool, + pub config_mac_osx_behaviors: bool, + pub config_input_text_cursor_blink: bool, + pub config_resize_windows_from_edges: bool, + + pub get_clipboard_text_fn: Option *const c_char>, + pub set_clipboard_text_fn: Option, + pub clipboard_user_data: *mut c_void, + + pub ime_set_input_screen_pos_fn: Option, + pub ime_window_handle: *mut c_void, + + pub render_draw_lists_fn_unused: *mut c_void, + + pub mouse_pos: ImVec2, + pub mouse_down: [bool; 5], + pub mouse_wheel: c_float, + pub mouse_wheel_h: c_float, + pub key_ctrl: bool, + pub key_shift: bool, + pub key_alt: bool, + pub key_super: bool, + pub keys_down: [bool; 512], + pub input_characters: [ImWchar; 16 + 1], + pub nav_inputs: [c_float; ImGuiNavInput::COUNT], + + pub want_capture_mouse: bool, + pub want_capture_keyboard: bool, + pub want_text_input: bool, + pub want_move_mouse: bool, + pub want_save_ini_settings: bool, + pub nav_active: bool, + pub nav_visible: bool, + pub framerate: c_float, + pub metrics_render_vertices: c_int, + pub metrics_render_indices: c_int, + pub metrics_render_windows: c_int, + pub metrics_active_windows: c_int, + pub metrics_active_allocations: c_int, + pub mouse_delta: ImVec2, + + mouse_pos_prev: ImVec2, + mouse_clicked_pos: [ImVec2; 5], + mouse_clicked_time: [c_float; 5], + mouse_clicked: [bool; 5], + mouse_double_clicked: [bool; 5], + mouse_released: [bool; 5], + mouse_down_owned: [bool; 5], + mouse_down_duration: [c_float; 5], + mouse_down_duration_prev: [c_float; 5], + mouse_drag_max_distance_abs: [ImVec2; 5], + mouse_drag_max_distance_sqr: [c_float; 5], + keys_down_duration: [c_float; 512], + keys_down_duration_prev: [c_float; 512], + nav_inputs_down_duration: [c_float; ImGuiNavInput::COUNT], + nav_inputs_down_duration_prev: [c_float; ImGuiNavInput::COUNT], +} + +/// Helper to manually clip large list of items +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct ImGuiListClipper { + pub start_pos_y: c_float, + pub items_height: c_float, + pub items_count: c_int, + pub step_no: c_int, + pub display_start: c_int, + pub display_end: c_int, +} + +/// Data payload for Drag and Drop operations +#[repr(C)] +pub struct ImGuiPayload { + /// Data (copied and owned by dear imgui) + pub data: *const c_void, + /// Data size + pub data_size: c_int, + + /// Source item id + source_id: ImGuiID, + /// Source parent id (if available) + source_parent_id: ImGuiID, + /// Data timestamp + data_frame_count: c_int, + /// Data type tag (short user-supplied string) + data_type: [c_char; 32 + 1], + /// Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) + preview: bool, + /// Set when AcceptDragDropPayload() was called and mouse button is released over the target item. + delivery: bool, +} + +/// Callback data for size constraint callback +#[repr(C)] +pub struct ImGuiSizeCallbackData { + pub user_data: *mut c_void, + pub pos: ImVec2, + pub current_size: ImVec2, + pub desired_size: ImVec2, +} + +/// Key->value storage +#[repr(C)] +pub struct ImGuiStorage { + pub data: ImVector, +} + +/// Runtime data for styling/colors +#[repr(C)] +#[derive(Clone)] +pub struct ImGuiStyle { + /// Global alpha applies to everything in ImGui. + pub alpha: c_float, + /// Padding within a window. + pub window_padding: ImVec2, + /// Radius of window corners rounding. Set to 0.0 to have rectangular windows. + pub window_rounding: c_float, + /// Thickness of border around windows. Generally set to 0.0 or 1.0. (Other values are not well + /// tested and more CPU/GPU costly). + pub window_border_size: c_float, + /// Minimum window size. This is a global setting. If you want to constraint individual + /// windows, use igSetNextWindowSizeConstraints(). + pub window_min_size: ImVec2, + /// Alignment for title bar text. Defaults to (0.0, 0.5) for left-aligned, vertically centered. + pub window_title_align: ImVec2, + /// Radius of child window corners rounding. Set to 0.0 to have rectangular windows. + pub child_rounding: c_float, + /// Thickness of border around child windows. Generally set to 0.0 or 1.0. (Other values are + /// not well tested and more CPU/GPU costly). + pub child_border_size: c_float, + /// Radius of popup window corners rounding. (Note that tooltip windows use window_rounding) + pub popup_rounding: c_float, + /// Thickness of border around popup/tooltip windows. Generally set to 0.0 or 1.0. (Other + /// values are not well tested and more CPU/GPU costly). + pub popup_border_size: c_float, + /// Padding within a framed rectangle (used by most widgets). + pub frame_padding: ImVec2, + /// Radius of frame corners rounding. Set to 0.0 to have rectangular frame (used by most + /// widgets). + pub frame_rounding: c_float, + /// Thickness of border around frames. Generally set to 0.0 or 1.0. (Other values are not well + /// tested and more CPU/GPU costly). + pub frame_border_size: c_float, + /// Horizontal and vertical spacing between widgets/lines. + pub item_spacing: ImVec2, + /// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider + /// and its label). + pub item_inner_spacing: ImVec2, + /// Expand reactive bounding box for touch-based system where touch position is not accurate + /// enough. Unfortunately we don't sort widgets so priority on overlap will always be given to + /// the first widget. So don't grow this too much! + pub touch_extra_padding: ImVec2, + /// Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + + /// FramePadding.x*2). + pub indent_spacing: c_float, + /// Minimum horizontal spacing between two columns. + pub columns_min_spacing: c_float, + /// Width of the vertical scrollbar, Height of the horizontal scrollbar. + pub scrollbar_size: c_float, + /// Radius of grab corners for scrollbar. + pub scrollbar_rounding: c_float, + /// Minimum width/height of a grab box for slider/scrollbar. + pub grab_min_size: c_float, + /// Radius of grabs corners rounding. Set to 0.0 to have rectangular slider grabs. + pub grab_rounding: c_float, + /// Alignment of button text when button is larger than text. Defaults to (0.5, 0.5) for + /// horizontally+vertically centered. + pub button_text_align: ImVec2, + /// Window position are clamped to be visible within the display area by at least this amount. + /// Only applies to regular windows. + pub display_window_padding: ImVec2, + /// If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. + /// Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets + /// correctly! + pub display_safe_area_padding: ImVec2, + /// Scale software rendered mouse cursor (when io.mouse_draw_cursor is enabled). May be removed + /// later. + pub mouse_cursor_scale: c_float, + /// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU. + pub anti_aliased_lines: bool, + /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) + pub anti_aliased_fill: bool, + /// Tessellation tolerance when using igPathBezierCurveTo() without a specific number of + /// segments. Decrease for highly tessellated curves (higher quality, more polygons), increase + /// to reduce quality. + pub curve_tessellation_tol: c_float, + /// Colors for the user interface + pub colors: [ImVec4; ImGuiCol::COUNT], +} + +/// Text buffer for logging/accumulating text +#[repr(C)] +pub struct ImGuiTextBuffer { + pub buf: ImVector, +} + +/// Parse and apply text filters +#[repr(C)] +pub struct ImGuiTextFilter { + pub input_buf: [c_char; 256], + pub filters: ImVector, + pub count_grep: c_int, +} + +/// Lightweight vector struct +#[repr(C)] +pub struct ImVector { + pub size: c_int, + pub capacity: c_int, + pub data: *mut T, +} + +impl ImVector { + pub unsafe fn as_slice(&self) -> &[T] { + slice::from_raw_parts(self.data, self.size as usize) + } +} + +/// ImGuiStorage key->value pair +#[repr(C)] +pub struct Pair { + pub key: ImGuiID, + pub value: PairValue, +} + +/// ImGuiStorage value union +#[repr(C)] +pub union PairValue { + pub val_i: c_int, + pub val_f: c_float, + pub val_p: *mut c_void, +} + +/// ImGuiTextFilter text range +#[repr(C)] +pub struct TextRange { + pub begin: *const c_char, + pub end: *const c_char, +} + +// ImGuiStyle +extern "C" { + pub fn ImGuiStyle_ScaleAllSizes(this: *mut ImGuiStyle, scale_factor: c_float); +} + +// ImGuiIO +extern "C" { + pub fn ImGuiIO_AddInputCharacter(this: *mut ImGuiIO, c: c_ushort); + pub fn ImGuiIO_AddInputCharactersUTF8(this: *mut ImGuiIO, utf8_chars: *const c_char); + pub fn ImGuiIO_ClearInputCharacters(this: *mut ImGuiIO); +} + +// ImGuiTextFilter +extern "C" { + pub fn ImGuiTextFilter_Draw( + this: *mut ImGuiTextFilter, + label: *const c_char, + width: c_float, + ) -> bool; + pub fn ImGuiTextFilter_PassFilter( + this: *mut ImGuiTextFilter, + text: *const c_char, + text_end: *const c_char, + ) -> bool; + pub fn ImGuiTextFilter_Build(this: *mut ImGuiTextFilter); + pub fn ImGuiTextFilter_Clear(this: *mut ImGuiTextFilter); + pub fn ImGuiTextFilter_IsActive(this: *mut ImGuiTextFilter) -> bool; +} + +// TextRange +extern "C" { + pub fn TextRange_begin(this: *mut TextRange) -> *const c_char; + pub fn TextRange_end(this: *mut TextRange) -> *const c_char; + pub fn TextRange_empty(this: *mut TextRange) -> bool; + pub fn TextRange_split(this: *mut TextRange, separator: c_char, out: *mut ImVector); +} + +// ImGuiTextBuffer +extern "C" { + pub fn ImGuiTextBuffer_begin(this: *mut ImGuiTextBuffer) -> *const c_char; + pub fn ImGuiTextBuffer_end(this: *mut ImGuiTextBuffer) -> *const c_char; + pub fn ImGuiTextBuffer_size(this: *mut ImGuiTextBuffer) -> c_int; + pub fn ImGuiTextBuffer_empty(this: *mut ImGuiTextBuffer) -> bool; + pub fn ImGuiTextBuffer_clear(this: *mut ImGuiTextBuffer); + pub fn ImGuiTextBuffer_reserve(this: *mut ImGuiTextBuffer, capacity: c_int); + pub fn ImGuiTextBuffer_c_str(this: *mut ImGuiTextBuffer) -> *const c_char; + pub fn ImGuiTextBuffer_appendf(this: *mut ImGuiTextBuffer, fmt: *const c_char, ...); +} + +// ImGuiStorage +extern "C" { + pub fn ImGuiStorage_Clear(this: *mut ImGuiStorage); + pub fn ImGuiStorage_GetInt(this: *mut ImGuiStorage, key: ImGuiID, default_val: c_int) -> c_int; + pub fn ImGuiStorage_SetInt(this: *mut ImGuiStorage, key: ImGuiID, val: c_int); + pub fn ImGuiStorage_GetBool(this: *mut ImGuiStorage, key: ImGuiID, default_val: bool) -> bool; + pub fn ImGuiStorage_SetBool(this: *mut ImGuiStorage, key: ImGuiID, val: bool); + pub fn ImGuiStorage_GetFloat( + this: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_float, + ) -> c_float; + pub fn ImGuiStorage_SetFloat(this: *mut ImGuiStorage, key: ImGuiID, val: c_float); + pub fn ImGuiStorage_GetVoidPtr(this: *mut ImGuiStorage, key: ImGuiID); + pub fn ImGuiStorage_SetVoidPtr(this: *mut ImGuiStorage, key: ImGuiID, val: *mut c_void); + pub fn ImGuiStorage_GetIntRef( + this: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_int, + ) -> *mut c_int; + pub fn ImGuiStorage_GetBoolRef( + this: *mut ImGuiStorage, + key: ImGuiID, + default_val: bool, + ) -> *mut bool; + pub fn ImGuiStorage_GetFloatRef( + this: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_float, + ) -> *mut c_float; + pub fn ImGuiStorage_GetVoidPtrRef( + this: *mut ImGuiStorage, + key: ImGuiID, + default_val: *mut c_void, + ) -> *mut *mut c_void; + pub fn ImGuiStorage_SetAllInt(this: *mut ImGuiStorage, val: c_int); + pub fn ImGuiStorage_BuildSortByKey(this: *mut ImGuiStorage); +} + +// ImGuiInputTextCallbackData +extern "C" { + pub fn ImGuiInputTextCallbackData_DeleteChars( + this: *mut ImGuiInputTextCallbackData, + pos: c_int, + bytes_count: c_int, + ); + pub fn ImGuiInputTextCallbackData_InsertChars( + this: *mut ImGuiInputTextCallbackData, + pos: c_int, + text: *const c_char, + text_end: *const c_char, + ); + pub fn ImGuiInputTextCallbackData_HasSelection(this: *mut ImGuiInputTextCallbackData) -> bool; +} + +// ImGuiPayload +extern "C" { + pub fn ImGuiPayload_Clear(this: *mut ImGuiPayload); + pub fn ImGuiPayload_IsDataType(this: *mut ImGuiPayload, type_: *const c_char) -> bool; + pub fn ImGuiPayload_IsPreview(this: *mut ImGuiPayload) -> bool; + pub fn ImGuiPayload_IsDelivery(this: *mut ImGuiPayload) -> bool; +} + +// ImGuiListClipper +extern "C" { + pub fn ImGuiListClipper_Step(this: *mut ImGuiListClipper) -> bool; + pub fn ImGuiListClipper_Begin( + this: *mut ImGuiListClipper, + items_count: c_int, + items_height: c_float, + ); + pub fn ImGuiListClipper_End(this: *mut ImGuiListClipper); +} + +// ImDrawList +extern "C" { + pub fn ImDrawList_PushClipRect( + this: *mut ImDrawList, + clip_rect_min: ImVec2, + clip_rect_max: ImVec2, + intersect_with_current_clip_rect: bool, + ); + pub fn ImDrawList_PushClipRectFullScreen(this: *mut ImDrawList); + pub fn ImDrawList_PopClipRect(this: *mut ImDrawList); + pub fn ImDrawList_PushTextureID(this: *mut ImDrawList, texture_id: ImTextureID); + pub fn ImDrawList_PopTextureID(this: *mut ImDrawList); + pub fn ImDrawList_GetClipRectMin(this: *mut ImDrawList) -> ImVec2; + pub fn ImDrawList_GetClipRectMax(this: *mut ImDrawList) -> ImVec2; + + pub fn ImDrawList_AddLine( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddRect( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + rounding: c_float, + rounding_corners_flags: ImDrawCornerFlags, + thickness: c_float, + ); + pub fn ImDrawList_AddRectFilled( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + rounding: c_float, + rounding_corners_flags: ImDrawCornerFlags, + ); + pub fn ImDrawList_AddRectFilledMultiColor( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col_upr_left: ImU32, + col_upr_right: ImU32, + col_bot_right: ImU32, + col_bot_left: ImU32, + ); + pub fn ImDrawList_AddQuad( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddQuadFilled( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddTriangle( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddTriangleFilled( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddCircle( + this: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + col: ImU32, + num_segments: c_int, + thickness: c_float, + ); + pub fn ImDrawList_AddCircleFilled( + this: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + col: ImU32, + num_segments: c_int, + ); + pub fn ImDrawList_AddText( + this: *mut ImDrawList, + pos: ImVec2, + col: ImU32, + text_begin: *const c_char, + text_end: *const c_char, + ); + pub fn ImDrawList_AddTextFontPtr( + this: *mut ImDrawList, + font: *const ImFont, + font_size: c_float, + pos: ImVec2, + col: ImU32, + text_begin: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + cpu_fine_clip_rect: *const ImVec4, + ); + pub fn ImDrawList_AddImage( + this: *mut ImDrawList, + user_texture_id: ImTextureID, + a: ImVec2, + b: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddImageQuad( + this: *mut ImDrawList, + user_texture_id: ImTextureID, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + uv_c: ImVec2, + uv_d: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddImageRounded( + this: *mut ImDrawList, + user_texture_id: ImTextureID, + a: ImVec2, + b: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + col: ImU32, + rounding: c_float, + rounding_corners: ImDrawCornerFlags, + ); + pub fn ImDrawList_AddPolyLine( + this: *mut ImDrawList, + points: *const ImVec2, + num_points: c_int, + col: ImU32, + closed: bool, + thickness: c_float, + ); + pub fn ImDrawList_AddConvexPolyFilled( + this: *mut ImDrawList, + points: *const ImVec2, + num_points: c_int, + col: ImU32, + ); + pub fn ImDrawList_AddBezierCurve( + this: *mut ImDrawList, + pos0: ImVec2, + cp0: ImVec2, + cp1: ImVec2, + pos1: ImVec2, + col: ImU32, + thickness: c_float, + num_segments: c_int, + ); + + pub fn ImDrawList_PathClear(this: *mut ImDrawList); + pub fn ImDrawList_PathLineTo(this: *mut ImDrawList, pos: ImVec2); + pub fn ImDrawList_PathLineToMergeDuplicate(this: *mut ImDrawList, pos: ImVec2); + pub fn ImDrawList_PathFillConvex(this: *mut ImDrawList, col: ImU32); + pub fn ImDrawList_PathStroke( + this: *mut ImDrawList, + col: ImU32, + closed: bool, + thickness: c_float, + ); + pub fn ImDrawList_PathArcTo( + this: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + a_min: c_float, + a_max: c_float, + num_segments: c_int, + ); + pub fn ImDrawList_PathArcToFast( + this: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + a_min_of_12: c_int, + a_max_of_12: c_int, + ); + pub fn ImDrawList_PathBezierCurveTo( + this: *mut ImDrawList, + p1: ImVec2, + p2: ImVec2, + p3: ImVec2, + num_segments: c_int, + ); + pub fn ImDrawList_PathRect( + this: *mut ImDrawList, + rect_min: ImVec2, + rect_max: ImVec2, + rounding: c_float, + rounding_corners_flags: c_int, + ); + + pub fn ImDrawList_ChannelsSplit(this: *mut ImDrawList, channels_count: c_int); + pub fn ImDrawList_ChannelsMerge(this: *mut ImDrawList); + pub fn ImDrawList_ChannelsSetCurrent(this: *mut ImDrawList, channel_index: c_int); + + pub fn ImDrawList_AddCallback( + this: *mut ImDrawList, + callback: ImDrawCallback, + callback_data: *mut c_void, + ); + pub fn ImDrawList_AddDrawCmd(this: *mut ImDrawList); + + pub fn ImDrawList_CloneOutput(this: *mut ImDrawList) -> *mut ImDrawList; + pub fn ImDrawList_Clear(this: *mut ImDrawList); + pub fn ImDrawList_ClearFreeMemory(this: *mut ImDrawList); + + pub fn ImDrawList_PrimReserve(this: *mut ImDrawList, idx_count: c_int, vtx_count: c_int); + pub fn ImDrawList_PrimRect(this: *mut ImDrawList, a: ImVec2, b: ImVec2, col: ImU32); + pub fn ImDrawList_PrimRectUV( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_PrimQuadUV( + this: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + uv_c: ImVec2, + uv_d: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_PrimWriteVtx(this: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); + pub fn ImDrawList_PrimWriteIdx(this: *mut ImDrawList, idx: ImDrawIdx); + pub fn ImDrawList_PrimVtx(this: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); + pub fn ImDrawList_UpdateClipRect(this: *mut ImDrawList); + pub fn ImDrawList_UpdateTextureID(this: *mut ImDrawList); +} + +// ImDrawData +extern "C" { + pub fn ImDrawData_Clear(this: *mut ImDrawData); + pub fn ImDrawData_DeIndexAllBuffers(this: *mut ImDrawData); + pub fn ImDrawData_ScaleClipRects(this: *mut ImDrawData, sc: ImVec2); +} + +// ImFontConfig +extern "C" { + pub fn ImFontConfig_DefaultConstructor(config: *mut ImFontConfig); +} + +// ImFontAtlas +extern "C" { + pub fn ImFontAtlas_AddFont( + this: *mut ImFontAtlas, + font_cfg: *const ImFontConfig, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontDefault( + this: *mut ImFontAtlas, + font_cfg: *const ImFontConfig, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromFileTTF( + this: *mut ImFontAtlas, + filename: *const c_char, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromMemoryTTF( + this: *mut ImFontAtlas, + font_data: *mut c_void, + font_size: c_int, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromMemoryCompressedTTF( + this: *mut ImFontAtlas, + compressed_font_data: *const c_void, + compressed_font_size: c_int, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromMemoryCompressedBase85TTF( + this: *mut ImFontAtlas, + compressed_font_data_base85: *const c_char, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_ClearInputData(this: *mut ImFontAtlas); + pub fn ImFontAtlas_ClearTexData(this: *mut ImFontAtlas); + pub fn ImFontAtlas_ClearFonts(this: *mut ImFontAtlas); + pub fn ImFontAtlas_Clear(this: *mut ImFontAtlas); + pub fn ImFontAtlas_Build(this: *mut ImFontAtlas) -> bool; + pub fn ImFontAtlas_IsBuilt(this: *mut ImFontAtlas) -> bool; + pub fn ImFontAtlas_GetTexDataAsAlpha8( + this: *mut ImFontAtlas, + out_pixels: *mut *mut c_uchar, + out_width: *mut c_int, + out_height: *mut c_int, + out_bytes_per_pixel: *mut c_int, + ); + pub fn ImFontAtlas_GetTexDataAsRGBA32( + this: *mut ImFontAtlas, + out_pixels: *mut *mut c_uchar, + out_width: *mut c_int, + out_height: *mut c_int, + out_bytes_per_pixel: *mut c_int, + ); + pub fn ImFontAtlas_SetTexID(this: *mut ImFontAtlas, id: ImTextureID); + pub fn ImFontAtlas_GetGlyphRangesDefault(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesKorean(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesJapanese(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesChineseFull(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon( + this: *mut ImFontAtlas, + ) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesCyrillic(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_GetGlyphRangesThai(this: *mut ImFontAtlas) -> *const ImWchar; + pub fn ImFontAtlas_AddCustomRectRegular( + this: *mut ImFontAtlas, + id: c_uint, + width: c_int, + height: c_int, + ) -> c_int; + pub fn ImFontAtlas_AddCustomRectFontGlyph( + this: *mut ImFontAtlas, + font: *mut ImFont, + id: ImWchar, + width: c_int, + height: c_int, + advance_x: c_float, + offset: ImVec2, + ) -> c_int; + pub fn ImFontAtlas_GetCustomRectByIndex( + this: *mut ImFontAtlas, + index: c_int, + ) -> *const CustomRect; + pub fn ImFontAtlas_CalcCustomRectUV( + this: *mut ImFontAtlas, + rect: *const CustomRect, + out_uv_min: *mut ImVec2, + out_uv_max: *mut ImVec2, + ); + pub fn ImFontAtlas_GetMouseCursorTexData( + this: *mut ImFontAtlas, + cursor: ImGuiMouseCursor, + out_offset: *mut ImVec2, + out_size: *mut ImVec2, + out_uv_border: *mut ImVec2, + out_uv_fill: *mut ImVec2, + ) -> bool; +} + +// GlyphRangesBuilder +extern "C" { + pub fn GlyphRangesBuilder_GetBit(this: *mut GlyphRangesBuilder, n: c_int) -> bool; + pub fn GlyphRangesBuilder_SetBit(this: *mut GlyphRangesBuilder, n: c_int); + pub fn GlyphRangesBuilder_AddChar(this: *mut GlyphRangesBuilder, c: ImWchar); + pub fn GlyphRangesBuilder_AddText( + this: *mut GlyphRangesBuilder, + text: *const c_char, + text_end: *const c_char, + ); + pub fn GlyphRangesBuilder_AddRanges(this: *mut GlyphRangesBuilder, ranges: *const ImWchar); + pub fn GlyphRangesBuilder_BuildRanges( + this: *mut GlyphRangesBuilder, + out_ranges: *mut ImVector, + ); +} + +// CustomRect +extern "C" { + pub fn CustomRect_IsPacked(this: *mut CustomRect) -> bool; +} + +// ImFont +extern "C" { + pub fn ImFont_ClearOutputData(this: *mut ImFont); + pub fn ImFont_BuildLookupTable(this: *mut ImFont); + pub fn ImFont_FindGlyph(this: *mut ImFont, c: ImWchar) -> *const ImFontGlyph; + pub fn ImFont_FindGlyphNoFallback(this: *mut ImFont, c: ImWchar) -> *const ImFontGlyph; + pub fn ImFont_SetFallbackChar(this: *mut ImFont, c: ImWchar); + pub fn ImFont_GetCharAdvance(this: *mut ImFont, c: ImWchar) -> c_float; + pub fn ImFont_IsLoaded(this: *mut ImFont) -> bool; + pub fn ImFont_GetDebugName(this: *mut ImFont) -> *const c_char; + pub fn ImFont_CalcTextSizeA( + this: *mut ImFont, + size: c_float, + max_width: c_float, + wrap_width: c_float, + text_begin: *const c_char, + text_end: *const c_char, + remaining: *mut *const c_char, + ) -> ImVec2; + pub fn ImFont_CalcWordWrapPositionA( + this: *mut ImFont, + scale: c_float, + text: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + ) -> *const c_char; + pub fn ImFont_RenderChar( + this: *mut ImFont, + draw_list: *mut ImDrawList, + size: c_float, + pos: ImVec2, + col: ImU32, + c: c_ushort, + ); + pub fn ImFont_RenderText( + this: *mut ImFont, + draw_list: *mut ImDrawList, + size: c_float, + pos: ImVec2, + col: ImU32, + clip_rect: ImVec4, + text_begin: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + cpu_fine_clip: bool, + ); + pub fn ImFont_GrowIndex(this: *mut ImFont, new_size: c_int); + pub fn ImFont_AddGlyph( + this: *mut ImFont, + c: ImWchar, + x0: c_float, + y0: c_float, + x1: c_float, + y1: c_float, + u0: c_float, + v0: c_float, + u1: c_float, + v1: c_float, + advance_x: c_float, + ); + pub fn ImFont_AddRemapChar(this: *mut ImFont, dst: ImWchar, src: ImWchar, overwrite_dst: bool); +} diff --git a/imgui-sys/third-party/cimgui b/imgui-sys/third-party/cimgui index 0781f92..3efb100 160000 --- a/imgui-sys/third-party/cimgui +++ b/imgui-sys/third-party/cimgui @@ -1 +1 @@ -Subproject commit 0781f921354a3f7a9eefd7aaab557a89cb14baea +Subproject commit 3efb1001aa4639676b5626eaaf2c58e1370be3b2 diff --git a/src/fonts.rs b/src/fonts.rs index 25c63f3..1e5e6bf 100644 --- a/src/fonts.rs +++ b/src/fonts.rs @@ -6,7 +6,8 @@ use sys; #[derive(Clone, Eq, PartialEq, Hash, Debug)] enum FontGlyphRangeData { - Chinese, + ChineseSimplifiedCommon, + ChineseFull, Cyrillic, Default, Japanese, @@ -24,9 +25,13 @@ impl FontGlyphRange { FontGlyphRange(FontGlyphRangeData::Default) } + /// A set of glyph ranges appropriate for use with simplified common Chinese text. + pub fn chinese_simplified_common() -> FontGlyphRange { + FontGlyphRange(FontGlyphRangeData::ChineseSimplifiedCommon) + } /// A set of glyph ranges appropriate for use with Chinese text. - pub fn chinese() -> FontGlyphRange { - FontGlyphRange(FontGlyphRangeData::Chinese) + pub fn chinese_full() -> FontGlyphRange { + FontGlyphRange(FontGlyphRangeData::ChineseFull) } /// A set of glyph ranges appropriate for use with Cyrillic text. pub fn cyrillic() -> FontGlyphRange { @@ -122,7 +127,10 @@ impl FontGlyphRange { unsafe fn to_ptr(&self, atlas: *mut sys::ImFontAtlas) -> *const sys::ImWchar { match &self.0 { - &FontGlyphRangeData::Chinese => sys::ImFontAtlas_GetGlyphRangesChinese(atlas), + &FontGlyphRangeData::ChineseFull => sys::ImFontAtlas_GetGlyphRangesChineseFull(atlas), + &FontGlyphRangeData::ChineseSimplifiedCommon => { + sys::ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(atlas) + } &FontGlyphRangeData::Cyrillic => sys::ImFontAtlas_GetGlyphRangesCyrillic(atlas), &FontGlyphRangeData::Default => sys::ImFontAtlas_GetGlyphRangesDefault(atlas), &FontGlyphRangeData::Japanese => sys::ImFontAtlas_GetGlyphRangesJapanese(atlas), @@ -258,25 +266,27 @@ impl<'a> ImFont<'a> { } pub fn font_size(&self) -> f32 { - unsafe { sys::ImFont_GetFontSize(self.font) } + unsafe { (*self.font).font_size } } pub fn set_font_size(&mut self, size: f32) -> ImFont { - unsafe { sys::ImFont_SetFontSize(self.font, size) } + unsafe { + (*self.font).font_size = size; + } self.chain() } pub fn scale(&self) -> f32 { - unsafe { sys::ImFont_GetScale(self.font) } + unsafe { (*self.font).scale } } pub fn set_scale(&mut self, size: f32) -> ImFont { - unsafe { sys::ImFont_SetScale(self.font, size) } + unsafe { + (*self.font).scale = size; + } self.chain() } pub fn display_offset(&self) -> (f32, f32) { - let mut display_offset = unsafe { mem::uninitialized() }; - unsafe { sys::ImFont_GetDisplayOffset(self.font, &mut display_offset) } - display_offset.into() + unsafe { (*self.font).display_offset.into() } } } @@ -350,7 +360,7 @@ impl<'a> ImFontAtlas<'a> { /// The number of fonts currently registered in the atlas. pub fn font_count(&self) -> usize { - unsafe { sys::ImFontAtlas_Fonts_size(self.atlas) as usize } + unsafe { (*self.atlas).fonts.size as usize } } /// Gets a font from the atlas. @@ -360,8 +370,9 @@ impl<'a> ImFontAtlas<'a> { /// /// Panics if the index is out of range. pub fn index_font(&mut self, index: usize) -> ImFont { - assert!(index < self.font_count(), "Font index is out of range."); - unsafe { ImFont::from_ptr(sys::ImFontAtlas_Fonts_index(self.atlas, index as c_int)) } + let fonts = unsafe { (*self.atlas).fonts.as_slice() }; + assert!(index < fonts.len(), "Font index is out of range."); + unsafe { ImFont::from_ptr(fonts[index]) } } /// Clears all fonts associated with this texture atlas. diff --git a/src/image.rs b/src/image.rs index 18bb692..7defc9b 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1,6 +1,6 @@ use super::{ImVec2, ImVec4, Ui}; -use std::marker::PhantomData; use std::collections::HashMap; +use std::marker::PhantomData; use std::os::raw::c_void; use sys; diff --git a/src/input.rs b/src/input.rs index 23f2daf..e59d790 100644 --- a/src/input.rs +++ b/src/input.rs @@ -126,16 +126,6 @@ macro_rules! impl_step_params { } } -macro_rules! impl_precision_params { - ($InputType:ident) => { - #[inline] - pub fn decimal_precision(mut self, value: i32) -> Self { - self.decimal_precision = value; - self - } - } -} - #[must_use] pub struct InputText<'ui, 'p> { label: &'p ImStr, @@ -257,7 +247,6 @@ pub struct InputFloat<'ui, 'p> { value: &'p mut f32, step: f32, step_fast: f32, - decimal_precision: i32, flags: ImGuiInputTextFlags, _phantom: PhantomData<&'ui Ui<'ui>>, } @@ -269,7 +258,6 @@ impl<'ui, 'p> InputFloat<'ui, 'p> { value, step: 0.0, step_fast: 0.0, - decimal_precision: -1, flags: ImGuiInputTextFlags::empty(), _phantom: PhantomData, } @@ -282,14 +270,13 @@ impl<'ui, 'p> InputFloat<'ui, 'p> { self.value as *mut f32, self.step, self.step_fast, - self.decimal_precision, + b"%.3f\0".as_ptr() as *const _, self.flags, ) } } impl_step_params!(InputFloat, f32); - impl_precision_params!(InputFloat); impl_text_flags!(InputFloat); } @@ -299,7 +286,6 @@ macro_rules! impl_input_floatn { pub struct $InputFloatN<'ui, 'p> { label: &'p ImStr, value: &'p mut [f32; $N], - decimal_precision: i32, flags: ImGuiInputTextFlags, _phantom: PhantomData<&'ui Ui<'ui>>, } @@ -309,7 +295,6 @@ macro_rules! impl_input_floatn { $InputFloatN { label, value, - decimal_precision: -1, flags: ImGuiInputTextFlags::empty(), _phantom: PhantomData, } @@ -320,13 +305,12 @@ macro_rules! impl_input_floatn { sys::$igInputFloatN( self.label.as_ptr(), self.value.as_mut_ptr(), - self.decimal_precision, + b"%.3f\0".as_ptr() as *const _, self.flags, ) } } - impl_precision_params!($InputFloatN); impl_text_flags!($InputFloatN); } }; diff --git a/src/lib.rs b/src/lib.rs index c16ea67..9c7d0a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -130,6 +130,9 @@ impl FrameSize { impl ImGui { pub fn init() -> ImGui { + unsafe { + sys::igCreateContext(ptr::null_mut()); + } ImGui { ini_filename: None, log_filename: None, @@ -384,7 +387,7 @@ impl ImGui { let mut buf = [0; 5]; character.encode_utf8(&mut buf); unsafe { - sys::ImGuiIO_AddInputCharactersUTF8(buf.as_ptr() as *const _); + sys::ImGuiIO_AddInputCharactersUTF8(self.io_mut(), buf.as_ptr() as *const _); } } pub fn get_time(&self) -> f32 { @@ -425,7 +428,7 @@ impl Drop for ImGui { fn drop(&mut self) { unsafe { CURRENT_UI = None; - sys::igShutdown(); + sys::igDestroyContext(ptr::null_mut()); } } } @@ -529,10 +532,6 @@ impl<'ui> Ui<'ui> { let io = self.imgui.io(); io.framerate } - pub fn metrics_allocs(&self) -> i32 { - let io = self.imgui.io(); - io.metrics_allocs - } pub fn metrics_render_vertices(&self) -> i32 { let io = self.imgui.io(); io.metrics_render_vertices @@ -606,19 +605,13 @@ impl<'ui> Ui<'ui> { } /// Get current window's size in pixels pub fn get_window_size(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetWindowSize(&mut out as *mut ImVec2); - } - (out.x, out.y) + let size = unsafe { sys::igGetWindowSize() }; + size.into() } /// Get current window's position in pixels pub fn get_window_pos(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetWindowPos(&mut out); - } - (out.x, out.y) + let size = unsafe { sys::igGetWindowPos() }; + size.into() } } @@ -694,8 +687,7 @@ impl<'ui> Ui<'ui> { /// Fill a space of `size` in pixels with nothing on the current window. /// Can be used to move the cursor on the window. pub fn dummy>(&self, size: S) { - let size = size.into(); - unsafe { sys::igDummy(&size) } + unsafe { sys::igDummy(size.into()) } } /// Get cursor position on the screen, in screen coordinates. @@ -704,11 +696,8 @@ impl<'ui> Ui<'ui> { /// This is especially useful for drawing, as the drawing API uses /// screen coordiantes. pub fn get_cursor_screen_pos(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetCursorScreenPos(&mut out); - } - (out.x, out.y) + let size = unsafe { sys::igGetCursorScreenPos() }; + size.into() } /// Set cursor position on the screen, in screen coordinates. @@ -719,11 +708,8 @@ impl<'ui> Ui<'ui> { /// Get cursor position on the screen, in window coordinates. pub fn get_cursor_pos(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetCursorPos(&mut out); - } - (out.x, out.y) + let size = unsafe { sys::igGetCursorPos() }; + size.into() } /// Set cursor position on the screen, in window coordinates. @@ -735,11 +721,8 @@ impl<'ui> Ui<'ui> { /// Get available space left between the cursor and the edges of the current /// window. pub fn get_content_region_avail(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetContentRegionAvail(&mut out); - } - (out.x, out.y) + let size = unsafe { sys::igGetContentRegionAvail() }; + size.into() } } @@ -787,7 +770,7 @@ impl<'ui> Ui<'ui> { ImId::Str(s) => { let start = s.as_ptr() as *const c_char; let end = start.offset(s.len() as isize); - sys::igPushIDStrRange(start, end); + sys::igPushIDRange(start, end); } ImId::Ptr(p) => { sys::igPushIDPtr(p as *const c_void); @@ -1206,7 +1189,7 @@ impl<'ui> Ui<'ui> { where F: FnOnce(), { - let render = unsafe { sys::igBeginPopup(str_id.as_ptr()) }; + let render = unsafe { sys::igBeginPopup(str_id.as_ptr(), ImGuiWindowFlags::empty()) }; if render { f(); unsafe { sys::igEndPopup() }; @@ -1272,7 +1255,7 @@ impl<'ui> Ui<'ui> { ) -> bool { let items_inner: Vec<*const c_char> = items.into_iter().map(|item| item.as_ptr()).collect(); unsafe { - sys::igListBox( + sys::igListBoxStr_arr( label.as_ptr(), current_item, items_inner.as_ptr() as *mut *const c_char, @@ -1299,7 +1282,7 @@ impl<'ui> Ui<'ui> { /// ui.radio_button(im_str!("Item 3"), &mut selected_radio_value, 3); /// ``` pub fn radio_button<'p>(&self, label: &'p ImStr, value: &'p mut i32, wanted: i32) -> bool { - unsafe { sys::igRadioButton(label.as_ptr(), value, wanted) } + unsafe { sys::igRadioButtonIntPtr(label.as_ptr(), value, wanted) } } /// Creates a radio button that shows as selected if the given value is true. @@ -1362,17 +1345,14 @@ impl<'ui> Ui<'ui> { hide_text_after_double_hash: bool, wrap_width: f32, ) -> ImVec2 { - let mut buffer = ImVec2::new(0.0, 0.0); unsafe { sys::igCalcTextSize( - &mut buffer as *mut ImVec2, text.as_ptr(), std::ptr::null(), hide_text_after_double_hash, wrap_width, - ); + ) } - buffer } } @@ -1383,11 +1363,8 @@ impl<'ui> Ui<'ui> { } /// Get previously drawn item's size pub fn get_item_rect_size(&self) -> (f32, f32) { - let mut out = ImVec2::new(0.0, 0.0); - unsafe { - sys::igGetItemRectSize(&mut out); - } - (out.x, out.y) + let size = unsafe { sys::igGetItemRectSize() }; + size.into() } } @@ -1483,26 +1460,30 @@ impl<'ui> Ui<'ui> { #[inline] fn push_style_var(&self, style_var: StyleVar) { - use sys::{igPushStyleVar, igPushStyleVarVec}; + use sys::{igPushStyleVarFloat, igPushStyleVarVec2}; use StyleVar::*; match style_var { - Alpha(v) => unsafe { igPushStyleVar(ImGuiStyleVar::Alpha, v) }, - WindowPadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowPadding, v) }, - WindowRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowRounding, v) }, - WindowBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowBorderSize, v) }, - WindowMinSize(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowMinSize, v) }, - ChildRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::ChildRounding, v) }, - ChildBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::ChildBorderSize, v) }, - PopupRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::PopupRounding, v) }, - PopupBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::PopupBorderSize, v) }, - FramePadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::FramePadding, v) }, - FrameRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameRounding, v) }, - FrameBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameBorderSize, v) }, - ItemSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemSpacing, v) }, - ItemInnerSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemInnerSpacing, v) }, - IndentSpacing(v) => unsafe { igPushStyleVar(ImGuiStyleVar::IndentSpacing, v) }, - GrabMinSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::GrabMinSize, v) }, - ButtonTextAlign(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ButtonTextAlign, v) }, + Alpha(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::Alpha, v) }, + WindowPadding(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::WindowPadding, v) }, + WindowRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::WindowRounding, v) }, + WindowBorderSize(v) => unsafe { + igPushStyleVarFloat(ImGuiStyleVar::WindowBorderSize, v) + }, + WindowMinSize(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::WindowMinSize, v) }, + ChildRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::ChildRounding, v) }, + ChildBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::ChildBorderSize, v) }, + PopupRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::PopupRounding, v) }, + PopupBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::PopupBorderSize, v) }, + FramePadding(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::FramePadding, v) }, + FrameRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::FrameRounding, v) }, + FrameBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::FrameBorderSize, v) }, + ItemSpacing(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::ItemSpacing, v) }, + ItemInnerSpacing(v) => unsafe { + igPushStyleVarVec2(ImGuiStyleVar::ItemInnerSpacing, v) + }, + IndentSpacing(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::IndentSpacing, v) }, + GrabMinSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::GrabMinSize, v) }, + ButtonTextAlign(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::ButtonTextAlign, v) }, } } } diff --git a/src/menus.rs b/src/menus.rs index 2407edc..84d6d46 100644 --- a/src/menus.rs +++ b/src/menus.rs @@ -75,6 +75,6 @@ impl<'ui, 'p> MenuItem<'ui, 'p> { .map(|x| x as *mut bool) .unwrap_or(ptr::null_mut()); let enabled = self.enabled; - unsafe { sys::igMenuItemPtr(label, shortcut, selected, enabled) } + unsafe { sys::igMenuItemBoolPtr(label, shortcut, selected, enabled) } } } diff --git a/src/plothistogram.rs b/src/plothistogram.rs index 9a13fd3..dc6d7ea 100644 --- a/src/plothistogram.rs +++ b/src/plothistogram.rs @@ -63,7 +63,7 @@ impl<'ui, 'p> PlotHistogram<'ui, 'p> { pub fn build(self) { unsafe { - sys::igPlotHistogram( + sys::igPlotHistogramFloatPtr( self.label.as_ptr(), self.values.as_ptr() as *const c_float, self.values.len() as i32, diff --git a/src/progressbar.rs b/src/progressbar.rs index c6b4bf6..00e357d 100644 --- a/src/progressbar.rs +++ b/src/progressbar.rs @@ -51,7 +51,7 @@ impl<'ui, 'p> ProgressBar<'ui, 'p> { unsafe { sys::igProgressBar( self.fraction, - &self.size, + self.size, self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()), ); } diff --git a/src/trees.rs b/src/trees.rs index 42c2e58..cafddfd 100644 --- a/src/trees.rs +++ b/src/trees.rs @@ -100,7 +100,7 @@ impl<'ui, 'p> TreeNode<'ui, 'p> { if !self.opened_cond.is_empty() { sys::igSetNextTreeNodeOpen(self.opened, self.opened_cond); } - sys::igTreeNodeExStr( + sys::igTreeNodeExStrStr( self.id.as_ptr(), self.flags, super::fmt_ptr(),