From 2b72a2a62ccd28a1bcb711504667d8804491198e Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sun, 12 Jan 2020 14:05:51 +0200 Subject: [PATCH] Upgrade to cimgui/imgui 1.74 --- CHANGELOG.markdown | 4 +- README.markdown | 2 +- imgui-sys-bindgen/src/lib.rs | 2 +- imgui-sys/src/bindings.rs | 138 ++++++++++++++++++----------------- imgui-sys/third-party/cimgui | 2 +- src/io.rs | 2 +- src/lib.rs | 2 +- src/utils.rs | 4 + 8 files changed, 81 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index a97ccec..458a15e 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -8,8 +8,8 @@ ### Changed -- Upgrade to cimgui / imgui 1.73 -- +- Upgrade to cimgui / imgui 1.74 + ### Removed - Various things that were deprecated in imgui-rs 0.2.0 diff --git a/README.markdown b/README.markdown index f7b39e6..1129add 100644 --- a/README.markdown +++ b/README.markdown @@ -4,7 +4,7 @@ Minimum Rust version: 1.36 -Wrapped Dear ImGui version: 1.73 +Wrapped Dear ImGui version: 1.74 [![Build Status](https://github.com/Gekkio/imgui-rs/workflows/ci/badge.svg)](https://github.com/Gekkio/imgui-rs/actions) [![Latest release on crates.io](https://meritbadge.herokuapp.com/imgui)](https://crates.io/crates/imgui) diff --git a/imgui-sys-bindgen/src/lib.rs b/imgui-sys-bindgen/src/lib.rs index 4dc0f20..0ff7cbb 100644 --- a/imgui-sys-bindgen/src/lib.rs +++ b/imgui-sys-bindgen/src/lib.rs @@ -90,7 +90,7 @@ pub fn generate_bindings>(cimgui_path: &P) -> Result(), - 5472usize, + 5456usize, concat!("Size of: ", stringify!(ImGuiIO)) ); assert_eq!( @@ -2524,7 +2523,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).WantCaptureMouse as *const _ as usize }, - 924usize, + 920usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2534,7 +2533,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).WantCaptureKeyboard as *const _ as usize }, - 925usize, + 921usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2544,7 +2543,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).WantTextInput as *const _ as usize }, - 926usize, + 922usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2554,7 +2553,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).WantSetMousePos as *const _ as usize }, - 927usize, + 923usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2564,7 +2563,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).WantSaveIniSettings as *const _ as usize }, - 928usize, + 924usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2574,7 +2573,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).NavActive as *const _ as usize }, - 929usize, + 925usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2584,7 +2583,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).NavVisible as *const _ as usize }, - 930usize, + 926usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2594,7 +2593,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).Framerate as *const _ as usize }, - 932usize, + 928usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2604,7 +2603,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MetricsRenderVertices as *const _ as usize }, - 936usize, + 932usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2614,7 +2613,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MetricsRenderIndices as *const _ as usize }, - 940usize, + 936usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2624,7 +2623,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MetricsRenderWindows as *const _ as usize }, - 944usize, + 940usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2634,7 +2633,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MetricsActiveWindows as *const _ as usize }, - 948usize, + 944usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2646,7 +2645,7 @@ fn bindgen_test_layout_ImGuiIO() { unsafe { &(*(::std::ptr::null::())).MetricsActiveAllocations as *const _ as usize }, - 952usize, + 948usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2656,7 +2655,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDelta as *const _ as usize }, - 956usize, + 952usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2666,7 +2665,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MousePosPrev as *const _ as usize }, - 964usize, + 960usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2676,7 +2675,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseClickedPos as *const _ as usize }, - 972usize, + 968usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2686,7 +2685,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseClickedTime as *const _ as usize }, - 1016usize, + 1008usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2696,7 +2695,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseClicked as *const _ as usize }, - 1056usize, + 1048usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2706,7 +2705,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDoubleClicked as *const _ as usize }, - 1061usize, + 1053usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2716,7 +2715,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseReleased as *const _ as usize }, - 1066usize, + 1058usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2726,7 +2725,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDownOwned as *const _ as usize }, - 1071usize, + 1063usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2736,7 +2735,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDownWasDoubleClick as *const _ as usize }, - 1076usize, + 1068usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2746,7 +2745,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDownDuration as *const _ as usize }, - 1084usize, + 1076usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2756,7 +2755,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDownDurationPrev as *const _ as usize }, - 1104usize, + 1096usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2766,7 +2765,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDragMaxDistanceAbs as *const _ as usize }, - 1124usize, + 1116usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2776,7 +2775,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).MouseDragMaxDistanceSqr as *const _ as usize }, - 1164usize, + 1156usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2786,7 +2785,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).KeysDownDuration as *const _ as usize }, - 1184usize, + 1176usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2796,7 +2795,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).KeysDownDurationPrev as *const _ as usize }, - 3232usize, + 3224usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2806,7 +2805,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).NavInputsDownDuration as *const _ as usize }, - 5280usize, + 5272usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2818,7 +2817,7 @@ fn bindgen_test_layout_ImGuiIO() { unsafe { &(*(::std::ptr::null::())).NavInputsDownDurationPrev as *const _ as usize }, - 5368usize, + 5356usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -2828,7 +2827,7 @@ fn bindgen_test_layout_ImGuiIO() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).InputQueueCharacters as *const _ as usize }, - 5456usize, + 5440usize, concat!( "Offset of field: ", stringify!(ImGuiIO), @@ -5735,10 +5734,10 @@ extern "C" { pub fn igDragScalar( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, v_speed: f32, - v_min: *const ::std::os::raw::c_void, - v_max: *const ::std::os::raw::c_void, + p_min: *const ::std::os::raw::c_void, + p_max: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, power: f32, ) -> bool; @@ -5747,11 +5746,11 @@ extern "C" { pub fn igDragScalarN( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, components: ::std::os::raw::c_int, v_speed: f32, - v_min: *const ::std::os::raw::c_void, - v_max: *const ::std::os::raw::c_void, + p_min: *const ::std::os::raw::c_void, + p_max: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, power: f32, ) -> bool; @@ -5845,9 +5844,9 @@ extern "C" { pub fn igSliderScalar( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, - v_min: *const ::std::os::raw::c_void, - v_max: *const ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, + p_min: *const ::std::os::raw::c_void, + p_max: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, power: f32, ) -> bool; @@ -5856,10 +5855,10 @@ extern "C" { pub fn igSliderScalarN( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, components: ::std::os::raw::c_int, - v_min: *const ::std::os::raw::c_void, - v_max: *const ::std::os::raw::c_void, + p_min: *const ::std::os::raw::c_void, + p_max: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, power: f32, ) -> bool; @@ -5890,9 +5889,9 @@ extern "C" { label: *const ::std::os::raw::c_char, size: ImVec2, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, - v_min: *const ::std::os::raw::c_void, - v_max: *const ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, + p_min: *const ::std::os::raw::c_void, + p_max: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, power: f32, ) -> bool; @@ -6007,9 +6006,9 @@ extern "C" { pub fn igInputScalar( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, - step: *const ::std::os::raw::c_void, - step_fast: *const ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, + p_step: *const ::std::os::raw::c_void, + p_step_fast: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, flags: ImGuiInputTextFlags, ) -> bool; @@ -6018,10 +6017,10 @@ extern "C" { pub fn igInputScalarN( label: *const ::std::os::raw::c_char, data_type: ImGuiDataType, - v: *mut ::std::os::raw::c_void, + p_data: *mut ::std::os::raw::c_void, components: ::std::os::raw::c_int, - step: *const ::std::os::raw::c_void, - step_fast: *const ::std::os::raw::c_void, + p_step: *const ::std::os::raw::c_void, + p_step_fast: *const ::std::os::raw::c_void, format: *const ::std::os::raw::c_char, flags: ImGuiInputTextFlags, ) -> bool; @@ -6263,18 +6262,18 @@ extern "C" { float_format: *const ::std::os::raw::c_char, ); } -extern "C" { - pub fn igBeginMainMenuBar() -> bool; -} -extern "C" { - pub fn igEndMainMenuBar(); -} extern "C" { pub fn igBeginMenuBar() -> bool; } extern "C" { pub fn igEndMenuBar(); } +extern "C" { + pub fn igBeginMainMenuBar() -> bool; +} +extern "C" { + pub fn igEndMainMenuBar(); +} extern "C" { pub fn igBeginMenu(label: *const ::std::os::raw::c_char, enabled: bool) -> bool; } @@ -6486,6 +6485,9 @@ extern "C" { extern "C" { pub fn igIsItemDeactivatedAfterEdit() -> bool; } +extern "C" { + pub fn igIsItemToggledOpen() -> bool; +} extern "C" { pub fn igIsAnyItemHovered() -> bool; } diff --git a/imgui-sys/third-party/cimgui b/imgui-sys/third-party/cimgui index 1c65ee2..d9e1d9a 160000 --- a/imgui-sys/third-party/cimgui +++ b/imgui-sys/third-party/cimgui @@ -1 +1 @@ -Subproject commit 1c65ee2bdc719fb3ef62b4615d66fe8effa21148 +Subproject commit d9e1d9a80d621cd96d9900ac340092853100416f diff --git a/src/io.rs b/src/io.rs index c2cc6ea..9550c80 100644 --- a/src/io.rs +++ b/src/io.rs @@ -117,7 +117,7 @@ impl NavInput { NavInput::TweakFast, ]; /// Amount of internal/hidden variants (not exposed by imgui-rs) - const INTERNAL_COUNT: usize = 6; + const INTERNAL_COUNT: usize = 5; /// Total count of `NavInput` variants pub const COUNT: usize = sys::ImGuiNavInput_COUNT as usize - NavInput::INTERNAL_COUNT; } diff --git a/src/lib.rs b/src/lib.rs index 73f4682..4003250 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,7 +85,7 @@ pub fn dear_imgui_version() -> &'static str { #[test] fn test_version() { - assert_eq!(dear_imgui_version(), "1.73"); + assert_eq!(dear_imgui_version(), "1.74"); } impl Context { diff --git a/src/utils.rs b/src/utils.rs index 4285de0..2ce3309 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -64,6 +64,10 @@ impl<'ui> Ui<'ui> { pub fn is_item_deactivated_after_edit(&self) -> bool { unsafe { sys::igIsItemDeactivatedAfterEdit() } } + /// Returns `true` if the last item open state was toggled + pub fn is_item_toggled_open(&self) -> bool { + unsafe { sys::igIsItemToggledOpen() } + } /// Returns `true` if any item is hovered pub fn is_any_item_hovered(&self) -> bool { unsafe { sys::igIsAnyItemHovered() }