From ddd7f7ef7b84028248048fb9d3dc314168e00359 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 17:15:25 +0900 Subject: [PATCH 01/42] Update cimgui to 1.53.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update cimgui, fixing #97 and #88. As a side note, the previous version has some compiler warning showing up during build: warning: third-party/cimgui/imgui/imgui.cpp: In function ‘void ImGui::RenderTriangle(ImVec2, ImGuiDir, float)’: warning: third-party/cimgui/imgui/imgui.cpp:3136:11: warning: this statement may fall through [-Wimplicit-fallthrough=] warning: r = -r; // ...fall through, no break! warning: ~~^~~~ The new version has no warning. --- imgui-sys/third-party/cimgui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui-sys/third-party/cimgui b/imgui-sys/third-party/cimgui index 5112189..0781f92 160000 --- a/imgui-sys/third-party/cimgui +++ b/imgui-sys/third-party/cimgui @@ -1 +1 @@ -Subproject commit 511218914b6dde6d5e52c0d98454ead3369eb38d +Subproject commit 0781f921354a3f7a9eefd7aaab557a89cb14baea From 817ecc200509fb628e9ce26e4d80c45e3a6028ca Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 17:49:55 +0900 Subject: [PATCH 02/42] CHANGELOG: Upgrade cimgui to 1.53.1 --- CHANGELOG.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index c2eb1a2..9a423d9 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,6 +2,9 @@ ## [Unreleased] +- Upgrade to imgui/cimgui 1.53.1 + + ## [0.0.18] - 2017-12-23 ### Added From cf15d49e36860a22493b39e19c5e5bdb5a0d9e82 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 17:51:07 +0900 Subject: [PATCH 03/42] [cimgui 1.53.1] Rename Ui::show_test_window to Ui::show_demo_window --- CHANGELOG.markdown | 1 + imgui-examples/examples/test_window.rs | 2 +- imgui-sys/src/lib.rs | 8 +++++++- src/lib.rs | 6 +++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 9a423d9..de2e15a 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -3,6 +3,7 @@ ## [Unreleased] - Upgrade to imgui/cimgui 1.53.1 + - Rename `Ui::show_test_window` to `Ui::show_demo_window`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-examples/examples/test_window.rs b/imgui-examples/examples/test_window.rs index 652b228..d111416 100644 --- a/imgui-examples/examples/test_window.rs +++ b/imgui-examples/examples/test_window.rs @@ -9,7 +9,7 @@ const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.0]; fn main() { support::run("test_window.rs".to_owned(), CLEAR_COLOR, |ui| { let mut open = true; - ui.show_test_window(&mut open); + ui.show_demo_window(&mut open); open }); } diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 3d0f6a1..33419fe 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -860,12 +860,18 @@ extern "C" { // Demo/Debug/Info extern "C" { - pub fn igShowTestWindow(opened: *mut bool); + pub fn igShowDemoWindow(opened: *mut bool); pub fn igShowMetricsWindow(opened: *mut bool); pub fn igShowStyleEditor(style: *mut ImGuiStyle); pub fn igShowUserGuide(); } +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igShowDemoWindow instead")] +pub unsafe fn igShowTestWindow(opened: *mut bool) { + igShowDemoWindow(opened) +} + // Window extern "C" { pub fn igBegin(name: *const c_char, open: *mut bool, flags: ImGuiWindowFlags) -> bool; diff --git a/src/lib.rs b/src/lib.rs index 888405c..bbc188a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -421,9 +421,13 @@ impl<'ui> Ui<'ui> { sys::igShowStyleEditor(style as *mut ImGuiStyle); } } + #[deprecated(since = "0.0.19", note = "please use show_demo_window instead")] pub fn show_test_window(&self, opened: &mut bool) { + self.show_demo_window(opened) + } + pub fn show_demo_window(&self, opened: &mut bool) { unsafe { - sys::igShowTestWindow(opened); + sys::igShowDemoWindow(opened); } } pub fn show_metrics_window(&self, opened: &mut bool) { From 1d10578471a14379ea8f0433f3e9286808c608f2 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 18:46:48 +0900 Subject: [PATCH 04/42] [cimgui 1.53.1] Rename igGetItemsLineHeightWithSpacing to igGetFrameHeightWithSpacing --- CHANGELOG.markdown | 1 + imgui-sys/src/lib.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index de2e15a..e3c1a0c 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -4,6 +4,7 @@ - Upgrade to imgui/cimgui 1.53.1 - Rename `Ui::show_test_window` to `Ui::show_demo_window`. + - Rename `sys::igGetItemsLineHeightWithSpacing` to `sys::igGetFrameHeightWithSpacing`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 33419fe..036f847 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1002,13 +1002,19 @@ extern "C" { pub fn igAlignTextToFramePadding(); pub fn igGetTextLineHeight() -> c_float; pub fn igGetTextLineHeightWithSpacing() -> c_float; - pub fn igGetItemsLineHeightWithSpacing() -> c_float; + pub fn igGetFrameHeightWithSpacing() -> c_float; } #[allow(non_snake_case)] #[deprecated(since = "0.0.18", note = "please use igAlignTextToFramePadding instead")] pub unsafe fn igAlignFirstTextHeightToWidgets() { igAlignTextToFramePadding(); } +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igGetFrameHeightWithSpacing instead")] +pub unsafe fn igGetItemsLineHeightWithSpacing() -> c_float { + igGetFrameHeightWithSpacing() +} + // Columns extern "C" { pub fn igColumns(count: c_int, id: *const c_char, border: bool); From 0c7137054652b556619b688707faa1150c230abc Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 18:47:54 +0900 Subject: [PATCH 05/42] imgui-sys: Add raw binding to GetFrameHeight --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 036f847..4a60651 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1002,6 +1002,7 @@ extern "C" { pub fn igAlignTextToFramePadding(); pub fn igGetTextLineHeight() -> c_float; pub fn igGetTextLineHeightWithSpacing() -> c_float; + pub fn igGetFrameHeight() -> c_float; pub fn igGetFrameHeightWithSpacing() -> c_float; } From a5ed022eee6fe898bc390c2c67b6d74503345b7d Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 19:00:58 +0900 Subject: [PATCH 06/42] [cimgui 1.53.1] Rename ImGuiTreeNodeFlags::AllowOverlapMode to ImGuiTreeNodeFlags::AllowItemOvelap --- CHANGELOG.markdown | 1 + imgui-sys/src/lib.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index e3c1a0c..1950c7c 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -5,6 +5,7 @@ - Upgrade to imgui/cimgui 1.53.1 - Rename `Ui::show_test_window` to `Ui::show_demo_window`. - Rename `sys::igGetItemsLineHeightWithSpacing` to `sys::igGetFrameHeightWithSpacing`. + - Rename `ImGuiTreeNodeFlags::AllowOverlapMode` to `ImGuiTreeNodeFlags::AllowItemOverlap`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 4a60651..4654565 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -298,7 +298,9 @@ bitflags!( pub struct ImGuiTreeNodeFlags: c_int { const Selected = 1; const Framed = 1 << 1; + #[deprecated(since = "0.0.19", note = "please use AllowItemOverlap instead")] const AllowOverlapMode = 1 << 2; + const AllowItemOverlap = 1 << 2; const NoTreePushOnOpen = 1 << 3; const NoAutoOpenOnLog = 1 << 4; const DefaultOpen = 1 << 5; From 24c37293e453627886cbe4031c4ec6a909d4a8b9 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 20:15:46 +0900 Subject: [PATCH 07/42] imgui-sys: Fix binding to igIsWindowFocused This commit adds the `ImGuiFocusedFlags' input flag that was missing. --- imgui-sys/src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 4654565..4e7571e 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -314,6 +314,17 @@ bitflags!( } ); +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)] @@ -1606,7 +1617,7 @@ extern "C" { pub fn igGetItemRectMax(out: *mut ImVec2); pub fn igGetItemRectSize(out: *mut ImVec2); pub fn igSetItemAllowOverlap(); - pub fn igIsWindowFocused() -> bool; + pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; pub fn igIsRootWindowFocused() -> bool; pub fn igIsRootWindowOrAnyChildFocused() -> bool; From f3e994f582a2e08d39dfb484d07b50a29a779515 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 20:20:43 +0900 Subject: [PATCH 08/42] [cimgui 1.53.1] Obsolete sys::igIsRootWindowFocused() Should use `sys::igIsWindowFocused(ImGuiFocusedFlags_RootWindow)` instead. --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 1950c7c..886fbfa 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -6,6 +6,8 @@ - Rename `Ui::show_test_window` to `Ui::show_demo_window`. - Rename `sys::igGetItemsLineHeightWithSpacing` to `sys::igGetFrameHeightWithSpacing`. - Rename `ImGuiTreeNodeFlags::AllowOverlapMode` to `ImGuiTreeNodeFlags::AllowItemOverlap`. + - Obsolete `sys::igIsRootWindowFocused()` in favor of using + `sys::igIsWindowFocused(ImGuiFocusedFlags::RootWindow)`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 4e7571e..5b9b2c3 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1619,7 +1619,6 @@ extern "C" { pub fn igSetItemAllowOverlap(); pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; - pub fn igIsRootWindowFocused() -> bool; pub fn igIsRootWindowOrAnyChildFocused() -> bool; pub fn igIsRootWindowOrAnyChildHovered(flags: ImGuiHoveredFlags) -> bool; pub fn igIsAnyWindowHovered() -> bool; @@ -1671,6 +1670,12 @@ extern "C" { ); } +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igIsWindowFocused(ImGuiFocusedFlags::RootWindow) instead")] +pub unsafe fn igIsRootWindowFocused() -> bool { + igIsWindowFocused(ImGuiFocusedFlags::RootWindow) +} + // Inputs extern "C" { pub fn igGetKeyIndex(imgui_key: ImGuiKey) -> c_int; From 2df079e5635ce31f7b225aa803bb49c49e559512 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 20:31:27 +0900 Subject: [PATCH 09/42] [cimgui 1.53.1] Obsolete sys::igIsRootWindowOrAnyChildFocused() Should use `igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows)` instead. --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 886fbfa..df147e8 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -8,6 +8,8 @@ - Rename `ImGuiTreeNodeFlags::AllowOverlapMode` to `ImGuiTreeNodeFlags::AllowItemOverlap`. - Obsolete `sys::igIsRootWindowFocused()` in favor of using `sys::igIsWindowFocused(ImGuiFocusedFlags::RootWindow)`. + - Obsolete `sys::igIsRootWindowOrAnyChildFocused()` in favor of using + `sys::igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows)`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 5b9b2c3..42a4b18 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1619,7 +1619,6 @@ extern "C" { pub fn igSetItemAllowOverlap(); pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; - pub fn igIsRootWindowOrAnyChildFocused() -> bool; pub fn igIsRootWindowOrAnyChildHovered(flags: ImGuiHoveredFlags) -> bool; pub fn igIsAnyWindowHovered() -> bool; pub fn igIsRectVisible(item_size: ImVec2) -> bool; @@ -1675,6 +1674,11 @@ extern "C" { pub unsafe fn igIsRootWindowFocused() -> bool { igIsWindowFocused(ImGuiFocusedFlags::RootWindow) } +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows) instead")] +pub unsafe fn igIsRootWindowOrAnyChildFocused() -> bool { + igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows) +} // Inputs extern "C" { From 8d3e1a82fcd9c31eb4df1475c4fba2159b1ea94e Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 20:34:34 +0900 Subject: [PATCH 10/42] [cimgui 1.53.1] Obsolete igIsRootWindowOrAnyChildHovered() Update struct for ImGuiHoveredFlags. NB: igIsWindowHovered, and thus igIsRootWindowOrAnyChildHovered, are broken now because of a bug. The fix is commited upstream, but not released yet. https://github.com/Extrawurst/cimgui/commit/baebcfcfafae045ad72137ef80364a243d9df53f I guess nothing can be done but wait for the next cimgui release. --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index df147e8..9456cf1 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -10,6 +10,8 @@ `sys::igIsWindowFocused(ImGuiFocusedFlags::RootWindow)`. - Obsolete `sys::igIsRootWindowOrAnyChildFocused()` in favor of using `sys::igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows)`. + - Obsolete `sys::igIsRootWindowOrAnyChildHovered()` in favor of using + `sys::igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows)`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 42a4b18..030dc01 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -329,12 +329,16 @@ bitflags!( /// Flags for hover checks #[repr(C)] pub struct ImGuiHoveredFlags: c_int { - const AllowWhenBlockedByPopup = 1; - const AllowWhenBlockedByActiveItem = 1 << 2; - const AllowWhenOverlapped = 1 << 3; + 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; } ); @@ -1619,7 +1623,6 @@ extern "C" { pub fn igSetItemAllowOverlap(); pub fn igIsWindowFocused(flags: ImGuiFocusedFlags) -> bool; pub fn igIsWindowHovered(flags: ImGuiHoveredFlags) -> bool; - pub fn igIsRootWindowOrAnyChildHovered(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; @@ -1679,6 +1682,11 @@ pub unsafe fn igIsRootWindowFocused() -> bool { pub unsafe fn igIsRootWindowOrAnyChildFocused() -> bool { igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows) } +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows) instead")] +pub unsafe fn igIsRootWindowOrAnyChildHovered(_flags: ImGuiHoveredFlags) -> bool { + igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows) +} // Inputs extern "C" { From d2e6d41619fb7421e446a678b1ac184ce76235d3 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 23:29:37 +0900 Subject: [PATCH 11/42] [cimgui 1.53.1] Obsolete igSetNextWindowContentWidth There is a small change of behaviour: previous height value is not preserved when igSetNextWindowContentWidth is used. There is no way around it unless we mess with imgui's internals. Official Dear ImGui chose this easy solution as well: static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } https://github.com/ocornut/imgui/blob/429f48bb4fa7fdffdb996e4a697d6df48babe3eb/imgui.h#L1132 --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 9456cf1..5eedb94 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -12,6 +12,8 @@ `sys::igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows)`. - Obsolete `sys::igIsRootWindowOrAnyChildHovered()` in favor of using `sys::igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows)`. + - Obsolete `sys::SetNextWindowContentWidth()` in favor of using + `sys::igSetNextWindowContentSize()`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 030dc01..0997d2f 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -930,7 +930,6 @@ extern "C" { custom_callback_data: *mut c_void, ); pub fn igSetNextWindowContentSize(size: ImVec2); - pub fn igSetNextWindowContentWidth(width: c_float); pub fn igSetNextWindowCollapsed(collapsed: bool, cond: ImGuiCond); pub fn igSetNextWindowFocus(); pub fn igSetWindowPos(pos: ImVec2, cond: ImGuiCond); @@ -963,6 +962,15 @@ pub unsafe fn igSetNextWindowPosCenter(cond: ImGuiCond) { let pivot = ImVec2::new(0.5, 0.5); igSetNextWindowPos(pos, cond, pivot); } +/// Set next window content's width. +/// +/// Original non-deprecated version preserved last Y value set by +/// [`igSetNextWindowContentSize`]. +#[allow(non_snake_case)] +#[deprecated(since = "0.0.19", note = "please use igSetNextWindowContentSize instead")] +pub unsafe fn igSetNextWindowContentWidth(width: c_float) { + igSetNextWindowContentSize(ImVec2 { x: width, y: 0.0 }) +} // Parameter stack (shared) extern "C" { From 37b60a5af00f912e815e612e47e07b67261b2771 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 23:44:19 +0900 Subject: [PATCH 12/42] [cimgui 1.53.1] Rename ImGuiTextBuffer_append() to appendf() This commit does not include deprecation warning. Indeed, defining a `ImGuiTextBuffer_append` function with a deprecation warning would require to write a variadic function in rust. However, this is impossible, and the FFI rust doc says so: https://doc.rust-lang.org/book/first-edition/ffi.html#variadic-functions Dear ImGui did not deprecate `append()`, they simply renamed it too. --- CHANGELOG.markdown | 1 + imgui-sys/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 5eedb94..1a316d5 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -14,6 +14,7 @@ `sys::igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows)`. - Obsolete `sys::SetNextWindowContentWidth()` in favor of using `sys::igSetNextWindowContentSize()`. + - Rename `sys::ImGuiTextBuffer_append()` helper to `appendf()`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 0997d2f..23db9bd 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1790,7 +1790,7 @@ extern "C" { 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_append(buffer: *const ImGuiTextBuffer, fmt: *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, From dbc96892cd240c13857b1f5f0a3e89f9068f7b06 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sun, 29 Apr 2018 23:58:54 +0900 Subject: [PATCH 13/42] [cimgui 1.53.1] DrawList: Remove `anti_aliased: bool` final parameter There is no way I know of to make a deprecation warning in such a case. Code that uses ImDrawList_AddPolyline or ImDrawList_AddConvexPolyFilled will break. --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 1a316d5..cc35918 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -15,6 +15,8 @@ - Obsolete `sys::SetNextWindowContentWidth()` in favor of using `sys::igSetNextWindowContentSize()`. - Rename `sys::ImGuiTextBuffer_append()` helper to `appendf()`. + - Remove `anti_aliased: bool` final parameter of `sys::ImDrawList_AddPolyline` + and `sys::ImDrawList_AddConvexPolyFilled`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 23db9bd..795ecb0 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -2025,14 +2025,12 @@ extern "C" { col: ImU32, closed: bool, thickness: c_float, - anti_aliased: bool, ); pub fn ImDrawList_AddConvexPolyFilled( list: *mut ImDrawList, points: *const ImVec2, num_points: c_int, col: ImU32, - anti_aliased: bool, ); pub fn ImDrawList_AddBezierCurve( list: *mut ImDrawList, From d4eb0fd33a7fa0c3037e9200ab258a5577c4b9ab Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 00:22:03 +0900 Subject: [PATCH 14/42] [cimgui 1.53.1] DrawList: Add ImDrawListFlags to ImDrawList --- imgui-sys/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 795ecb0..40f78b3 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -362,6 +362,14 @@ bitflags!( } ); +bitflags!( + #[repr(C)] + pub struct ImDrawListFlags: c_int { + const AntiAliasedLines = 1 << 0; + const AntiAliasedFill = 1 << 1; + } +); + pub type ImGuiTextEditCallback = Option< extern "C" fn(data: *mut ImGuiTextEditCallbackData) -> c_int, >; @@ -723,6 +731,8 @@ pub struct ImDrawList { 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, @@ -735,6 +745,20 @@ pub struct ImDrawList { channels: ImVector, } +#[repr(C)] +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 { From 3b231d9838fd706bd3590f679c9870b05a3f4287 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 11:27:13 +0900 Subject: [PATCH 15/42] [cimgui 1.53.1] Rename ChildWindowRounding to ChildRounding Add deprecation warning for each renamed variant. However, it will just fail to compile if the deprecated variant is used inside a match statement. It is not possible to make aliases of variants in Rust. --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 7 ++++++- src/lib.rs | 4 ++-- src/style.rs | 10 +++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index cc35918..440efe5 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -17,6 +17,8 @@ - Rename `sys::ImGuiTextBuffer_append()` helper to `appendf()`. - Remove `anti_aliased: bool` final parameter of `sys::ImDrawList_AddPolyline` and `sys::ImDrawList_AddConvexPolyFilled`. + - Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`. + - Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`. ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 40f78b3..c8d8539 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -146,7 +146,7 @@ pub enum ImGuiStyleVar { WindowPadding, WindowRounding, WindowMinSize, - ChildWindowRounding, + ChildRounding, FramePadding, FrameRounding, ItemSpacing, @@ -157,6 +157,11 @@ pub enum ImGuiStyleVar { } pub const ImGuiStyleVar_COUNT: usize = 12; +impl ImGuiStyleVar { + #[deprecated(since = "0.0.19", note = "please use ChildRounding instead")] + pub const ChildWindowRounding: ImGuiStyleVar = ImGuiStyleVar::ChildRounding; +} + /// A key identifier (ImGui-side enum) #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/src/lib.rs b/src/lib.rs index bbc188a..1785b3f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1203,8 +1203,8 @@ impl<'ui> Ui<'ui> { WindowPadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowPadding, v) }, WindowRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowRounding, v) }, WindowMinSize(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowMinSize, v) }, - ChildWindowRounding(v) => unsafe { - igPushStyleVar(ImGuiStyleVar::ChildWindowRounding, v) + ChildRounding(v) => unsafe { + igPushStyleVar(ImGuiStyleVar::ChildRounding, v) }, FramePadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::FramePadding, v) }, FrameRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameRounding, v) }, diff --git a/src/style.rs b/src/style.rs index 04c683c..2b3dbb2 100644 --- a/src/style.rs +++ b/src/style.rs @@ -6,7 +6,7 @@ pub enum StyleVar { WindowPadding(ImVec2), WindowRounding(f32), WindowMinSize(ImVec2), - ChildWindowRounding(f32), + ChildRounding(f32), FramePadding(ImVec2), FrameRounding(f32), ItemSpacing(ImVec2), @@ -15,3 +15,11 @@ pub enum StyleVar { GrabMinSize(f32), ButtonTextAlign(ImVec2), } + +impl StyleVar { + #[allow(non_snake_case)] + #[deprecated(since = "0.0.19", note = "please use ChildRounding instead")] + pub fn ChildWindowRounding(value: f32) -> Self { + StyleVar::ChildRounding(value) + } +} From adfa447d2fe69fabba2eb4543e5d7d782a93fa6a Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 11:39:54 +0900 Subject: [PATCH 16/42] [cimgui 1.53.1] Style: Add PopupRounding, FrameBorderSize, WindowBorderSize, PopupBorderSize --- CHANGELOG.markdown | 2 ++ imgui-sys/src/lib.rs | 6 +++++- src/lib.rs | 12 ++++++++++++ src/style.rs | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 440efe5..bcb6e17 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -20,6 +20,8 @@ - Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`. - Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`. + - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. + ## [0.0.18] - 2017-12-23 diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index c8d8539..e646772 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -147,15 +147,19 @@ pub enum ImGuiStyleVar { WindowRounding, WindowMinSize, ChildRounding, + ChildBorderSize, + PopupRounding, + PopupBorderSize, FramePadding, FrameRounding, + FrameBorderSize, ItemSpacing, ItemInnerSpacing, IndentSpacing, GrabMinSize, ButtonTextAlign, } -pub const ImGuiStyleVar_COUNT: usize = 12; +pub const ImGuiStyleVar_COUNT: usize = 16; impl ImGuiStyleVar { #[deprecated(since = "0.0.19", note = "please use ChildRounding instead")] diff --git a/src/lib.rs b/src/lib.rs index 1785b3f..2c310c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1206,8 +1206,20 @@ impl<'ui> Ui<'ui> { 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) }, diff --git a/src/style.rs b/src/style.rs index 2b3dbb2..5859be8 100644 --- a/src/style.rs +++ b/src/style.rs @@ -7,8 +7,12 @@ pub enum StyleVar { WindowRounding(f32), WindowMinSize(ImVec2), ChildRounding(f32), + ChildBorderSize(f32), + PopupRounding(f32), + PopupBorderSize(f32), FramePadding(ImVec2), FrameRounding(f32), + FrameBorderSize(f32), ItemSpacing(ImVec2), ItemInnerSpacing(ImVec2), IndentSpacing(f32), From 112d21133b87e6e90b3aaeef3c23be6f5abf2cdc Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 00:43:45 +0900 Subject: [PATCH 17/42] [cimgui 1.53.1] Remove ImGuiWindowFlags::ShowBorders --- CHANGELOG.markdown | 3 +++ imgui-examples/examples/test_window_impl.rs | 14 +++++--------- imgui-sys/src/lib.rs | 1 - src/child_frame.rs | 10 ++++------ src/window.rs | 18 +++++++++++++++--- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index bcb6e17..0b6c717 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -19,6 +19,9 @@ and `sys::ImDrawList_AddConvexPolyFilled`. - Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`. - Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`. + - Remove `ImGuiWindowFlags::ShowBorders` window flag. Borders are now fully + set up in the ImGuiStyle structure. + - Obsolete `Window::show_borders`. Use `StyleVar` instead. - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 66a0f74..3c8242e 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -23,7 +23,6 @@ struct State { show_app_metrics: bool, show_app_about: bool, no_titlebar: bool, - no_border: bool, no_resize: bool, no_move: bool, no_scrollbar: bool, @@ -72,7 +71,6 @@ impl Default for State { show_app_metrics: false, show_app_about: false, no_titlebar: false, - no_border: true, no_resize: false, no_move: false, no_scrollbar: false, @@ -269,7 +267,6 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { ui.window(im_str!("ImGui Demo")) .title_bar(!state.no_titlebar) - .show_borders(!state.no_border) .resizable(!state.no_resize) .movable(!state.no_move) .scroll_bar(!state.no_scrollbar) @@ -344,15 +341,14 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { if ui.collapsing_header(im_str!("Window options")).build() { ui.checkbox(im_str!("No titlebar"), &mut state.no_titlebar); ui.same_line(150.0); - ui.checkbox(im_str!("No border"), &mut state.no_border); - ui.same_line(300.0); - ui.checkbox(im_str!("No resize"), &mut state.no_resize); - ui.checkbox(im_str!("No move"), &mut state.no_move); - ui.same_line(150.0); ui.checkbox(im_str!("No scrollbar"), &mut state.no_scrollbar); ui.same_line(300.0); - ui.checkbox(im_str!("No collapse"), &mut state.no_collapse); ui.checkbox(im_str!("No menu"), &mut state.no_menu); + ui.checkbox(im_str!("No move"), &mut state.no_move); + ui.same_line(150.0); + ui.checkbox(im_str!("No resize"), &mut state.no_resize); + ui.same_line(300.0); + ui.checkbox(im_str!("No collapse"), &mut state.no_collapse); ui.tree_node(im_str!("Style")).build(|| { ui.show_default_style_editor() diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index e646772..b762fc8 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -244,7 +244,6 @@ bitflags!( const NoScrollWithMouse = 1 << 4; const NoCollapse = 1 << 5; const AlwaysAutoResize = 1 << 6; - const ShowBorders = 1 << 7; const NoSavedSettings = 1 << 8; const NoInputs = 1 << 9; const MenuBar = 1 << 10; diff --git a/src/child_frame.rs b/src/child_frame.rs index b14f03a..aa1a0fd 100644 --- a/src/child_frame.rs +++ b/src/child_frame.rs @@ -7,6 +7,7 @@ use super::{ImStr, ImVec2, ImGuiWindowFlags, Ui}; pub struct ChildFrame<'ui, 'p> { name: &'p ImStr, size: ImVec2, + border: bool, flags: ImGuiWindowFlags, _phantom: PhantomData<&'ui Ui<'ui>>, } @@ -16,6 +17,7 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> { ChildFrame { name: name, size: size.into(), + border: false, flags: ImGuiWindowFlags::empty(), _phantom: PhantomData, } @@ -47,7 +49,7 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> { } #[inline] pub fn show_borders(mut self, value: bool) -> Self { - self.flags.set(ImGuiWindowFlags::ShowBorders, value); + self.border = value; self } #[inline] @@ -103,12 +105,8 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> { self } pub fn build(self, f: F) { - // See issue for history. - // https://github.com/Gekkio/imgui-rs/pull/58 - let show_border = false; - let render_child_frame = - unsafe { sys::igBeginChild(self.name.as_ptr(), self.size, show_border, self.flags) }; + unsafe { sys::igBeginChild(self.name.as_ptr(), self.size, self.border, self.flags) }; if render_child_frame { f(); } diff --git a/src/window.rs b/src/window.rs index 40d5d6c..b1330ca 100644 --- a/src/window.rs +++ b/src/window.rs @@ -2,7 +2,7 @@ use sys; use std::marker::PhantomData; use std::ptr; -use super::{ImGuiCond, ImGuiWindowFlags, ImStr, ImVec2, Ui}; +use super::{ImGuiCond, ImGuiStyleVar, ImGuiWindowFlags, ImStr, ImVec2, Ui}; #[must_use] pub struct Window<'ui, 'p> { @@ -13,6 +13,8 @@ pub struct Window<'ui, 'p> { name: &'p ImStr, opened: Option<&'p mut bool>, flags: ImGuiWindowFlags, + // Deprecated. Should be removed along with Window::show_borders + border: bool, _phantom: PhantomData<&'ui Ui<'ui>>, } @@ -26,6 +28,7 @@ impl<'ui, 'p> Window<'ui, 'p> { name: name, opened: None, flags: ImGuiWindowFlags::empty(), + border: false, _phantom: PhantomData, } } @@ -87,8 +90,9 @@ impl<'ui, 'p> Window<'ui, 'p> { self } #[inline] + #[deprecated(since = "0.0.19", note = "please use StyleVar instead")] pub fn show_borders(mut self, value: bool) -> Self { - self.flags.set(ImGuiWindowFlags::ShowBorders, value); + self.border = value; self } #[inline] @@ -156,6 +160,9 @@ impl<'ui, 'p> Window<'ui, 'p> { if !self.size_cond.is_empty() { sys::igSetNextWindowSize(self.size.into(), self.size_cond); } + if self.border { + sys::igPushStyleVar(ImGuiStyleVar::FrameBorderSize, 1.0); + } sys::igBegin( self.name.as_ptr(), self.opened.map(|x| x as *mut bool).unwrap_or( @@ -167,6 +174,11 @@ impl<'ui, 'p> Window<'ui, 'p> { if render { f(); } - unsafe { sys::igEnd() }; + unsafe { + sys::igEnd(); + if self.border { + sys::igPopStyleVar(1); + } + }; } } From 5bf3eff812aefd23cbc3c1b79a550270a56ed232 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:11:30 +0900 Subject: [PATCH 18/42] [cimgui 1.53.1] Obsolete ImGuiCol::ComboBg --- CHANGELOG.markdown | 1 + imgui-sys/src/lib.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 0b6c717..edf0e4a 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -22,6 +22,7 @@ - Remove `ImGuiWindowFlags::ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure. - Obsolete `Window::show_borders`. Use `StyleVar` instead. + - Obsolete `ImGuiCol::ComboBg`. Use `PopupBg` instead. - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index b762fc8..6ddbe7a 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -59,7 +59,6 @@ pub enum ImGuiCol { ScrollbarGrab, ScrollbarGrabHovered, ScrollbarGrabActive, - ComboBg, CheckMark, SliderGrab, SliderGrabActive, @@ -86,6 +85,9 @@ pub enum ImGuiCol { ModalWindowDarkening, } impl ImGuiCol { + #[deprecated(since = "0.0.19", note = "ComboBg has been merged with PopupBg. Please use PopupBg instead")] + pub const ComboBg: ImGuiCol = ImGuiCol::PopupBg; + pub fn values() -> &'static [ImGuiCol] { use ImGuiCol::*; static values: &'static [ImGuiCol] = &[ @@ -107,7 +109,6 @@ impl ImGuiCol { ScrollbarGrab, ScrollbarGrabHovered, ScrollbarGrabActive, - ComboBg, CheckMark, SliderGrab, SliderGrabActive, @@ -136,7 +137,7 @@ impl ImGuiCol { values } } -pub const ImGuiCol_COUNT: usize = 43; +pub const ImGuiCol_COUNT: usize = 42; /// A variable identifier for styling #[repr(C)] From b7bb27fdbd028385e9c7a7220a907ee556b87295 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:12:49 +0900 Subject: [PATCH 19/42] [cimgui 1.53.1] Add ImGuiCol::DragDropTarget --- imgui-sys/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 6ddbe7a..b6574a0 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -83,6 +83,7 @@ pub enum ImGuiCol { PlotHistogramHovered, TextSelectedBg, ModalWindowDarkening, + DragDropTarget, } impl ImGuiCol { #[deprecated(since = "0.0.19", note = "ComboBg has been merged with PopupBg. Please use PopupBg instead")] @@ -133,11 +134,12 @@ impl ImGuiCol { PlotHistogramHovered, TextSelectedBg, ModalWindowDarkening, + DragDropTarget, ]; values } } -pub const ImGuiCol_COUNT: usize = 42; +pub const ImGuiCol_COUNT: usize = 43; /// A variable identifier for styling #[repr(C)] From 49ab5c524a192f5795d2fc4ec9dc4b6f42bc8afc Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 10:43:03 +0900 Subject: [PATCH 20/42] [cimgui 1.53.1] test_window_impl: Add "No close" window option Here is the original commit in Dear ImGui implementating the "No close" button: https://github.com/ocornut/imgui/commit/20ba79aa5 --- imgui-examples/examples/test_window_impl.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 3c8242e..a8a6ec1 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -28,6 +28,7 @@ struct State { no_scrollbar: bool, no_collapse: bool, no_menu: bool, + no_close: bool, wrap_width: f32, buf: ImString, item: i32, @@ -76,6 +77,7 @@ impl Default for State { no_scrollbar: false, no_collapse: false, no_menu: false, + no_close: false, wrap_width: 200.0, buf: buf, item: 0, @@ -265,16 +267,18 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { ); } - ui.window(im_str!("ImGui Demo")) + let mut window = ui.window(im_str!("ImGui Demo")) .title_bar(!state.no_titlebar) .resizable(!state.no_resize) .movable(!state.no_move) .scroll_bar(!state.no_scrollbar) .collapsible(!state.no_collapse) .menu_bar(!state.no_menu) - .size((550.0, 680.0), ImGuiCond::FirstUseEver) - .opened(opened) - .build(|| { + .size((550.0, 680.0), ImGuiCond::FirstUseEver); + if !state.no_close { + window = window.opened(opened) + } + window.build(|| { ui.push_item_width(-140.0); ui.text(format!("dear imgui says hello. ({})", imgui::get_version())); ui.menu_bar(|| { @@ -349,6 +353,7 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { ui.checkbox(im_str!("No resize"), &mut state.no_resize); ui.same_line(300.0); ui.checkbox(im_str!("No collapse"), &mut state.no_collapse); + ui.checkbox(im_str!("No close"), &mut state.no_close); ui.tree_node(im_str!("Style")).build(|| { ui.show_default_style_editor() From bba3e58460c82b787fa0ae64297e601255355f15 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:17:22 +0900 Subject: [PATCH 21/42] [cimgui 1.53.1] Rename ImGuiCol::ChildWindowBg to ChildBg --- CHANGELOG.markdown | 1 + imgui-sys/src/lib.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index edf0e4a..8f9b733 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -23,6 +23,7 @@ set up in the ImGuiStyle structure. - Obsolete `Window::show_borders`. Use `StyleVar` instead. - Obsolete `ImGuiCol::ComboBg`. Use `PopupBg` instead. + - Rename `ImGuiCol::ChildWindowBg` to `ImGuiCol::ChildBg`. - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index b6574a0..eb77a9c 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -44,7 +44,7 @@ pub enum ImGuiCol { Text, TextDisabled, WindowBg, - ChildWindowBg, + ChildBg, PopupBg, Border, BorderShadow, @@ -88,6 +88,8 @@ pub enum ImGuiCol { impl ImGuiCol { #[deprecated(since = "0.0.19", note = "ComboBg has been merged with PopupBg. Please use PopupBg instead")] pub const ComboBg: ImGuiCol = ImGuiCol::PopupBg; + #[deprecated(since = "0.0.19", note = "please use ChildBg instead")] + pub const ChildWindowBg: ImGuiCol = ImGuiCol::ChildBg; pub fn values() -> &'static [ImGuiCol] { use ImGuiCol::*; @@ -95,7 +97,7 @@ impl ImGuiCol { Text, TextDisabled, WindowBg, - ChildWindowBg, + ChildBg, PopupBg, Border, BorderShadow, From 286c54a0df178511fc77c16d7cd7c44a3776f6f0 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:30:42 +0900 Subject: [PATCH 22/42] [cimgui 1.53.1] ImGuiIO: Add opt_cursor_blink --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index eb77a9c..066e91b 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -561,6 +561,7 @@ pub struct ImGuiIO { pub display_visible_max: ImVec2, pub osx_behaviors: bool, + pub opt_cursor_blink: bool, pub render_draw_lists_fn: Option, From 5df58069368c10fd947f6b695f3ef48e6054f18e Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:34:59 +0900 Subject: [PATCH 23/42] [cimgui 1.53.1] ImGuiIO: Rename osx_bahaviors to opt_mac_osx_behaviors --- imgui-sys/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 066e91b..0e76ede 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -560,7 +560,7 @@ pub struct ImGuiIO { pub display_visible_min: ImVec2, pub display_visible_max: ImVec2, - pub osx_behaviors: bool, + pub opt_mac_osx_behaviors: bool, pub opt_cursor_blink: bool, pub render_draw_lists_fn: Option, From 85bb975e4077ba57693dc230fdd79ec6fc6ed1ac Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:41:05 +0900 Subject: [PATCH 24/42] [cimgui 1.53.1] ImGuiInputTextFlags: Add NoUndoRedo --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 0e76ede..ba1e63b 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -292,6 +292,7 @@ bitflags!( const AlwaysInsertMode = 1 << 13; const ReadOnly = 1 << 14; const Password = 1 << 15; + const NoUndoRedo = 1 << 16; } ); From abd39597ed58f35fa6ba52d6316c8d16a8b44a37 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:46:18 +0900 Subject: [PATCH 25/42] input: Add API to set read_only, password and no_undo_redo falgs --- src/input.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/input.rs b/src/input.rs index 8b8413b..ec16428 100644 --- a/src/input.rs +++ b/src/input.rs @@ -89,6 +89,24 @@ macro_rules! impl_text_flags { self.flags.set(ImGuiInputTextFlags::AlwaysInsertMode, value); self } + + #[inline] + pub fn read_only(mut self, value: bool) -> Self { + self.flags.set(ImGuiInputTextFlags::ReadOnly, value); + self + } + + #[inline] + pub fn password(mut self, value: bool) -> Self { + self.flags.set(ImGuiInputTextFlags::Password, value); + self + } + + #[inline] + pub fn no_undo_redo(mut self, value: bool) -> Self { + self.flags.set(ImGuiInputTextFlags::NoUndoRedo, value); + self + } } } From 2103da16e6a6acdc29cf6c3e07ab9f2b65b7923d Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 12:48:53 +0900 Subject: [PATCH 26/42] [cimgui 1.53.1] ImGuiWindowFlags: Add ResizeFromAnySide --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index ba1e63b..41bbece 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -258,6 +258,7 @@ bitflags!( const AlwaysVerticalScrollbar = 1 << 14; const AlwaysHorizontalScrollbar = 1 << 15; const AlwaysUseWindowPadding = 1 << 16; + const ResizeFromAnySide = 1 << 17; } ); From 8ec33c569738ffa72203154d63b54e57abd42bb5 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 13:08:09 +0900 Subject: [PATCH 27/42] [cimgui 1.53.1] Update ImGuiStyle structure --- imgui-sys/src/lib.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 41bbece..9888a0b 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -483,19 +483,29 @@ pub struct ImGuiStyle { pub alpha: c_float, /// Padding within a window pub window_padding: ImVec2, - /// Minimum window size - pub window_min_size: 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_window_rounding: c_float, + 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 @@ -530,7 +540,7 @@ pub struct ImGuiStyle { /// 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_shapes: bool, + 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, @@ -2345,12 +2355,15 @@ 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_rounding, 9.0); assert_eq!(style.window_title_align, ImVec2::new(0.0, 0.5)); - assert_eq!(style.child_window_rounding, 0.0); + 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)); @@ -2364,6 +2377,6 @@ fn test_default_style() { 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_shapes, true); + assert_eq!(style.anti_aliased_fill, true); assert_eq!(style.curve_tessellation_tol, 1.25); } From d0543bbcdd1f598a368cabcffa07fdc7a530d579 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 30 Apr 2018 21:49:31 +0900 Subject: [PATCH 28/42] [cimgui 1.53.1] ImDrawCornerFlags: switch BotLeft and BotRight --- imgui-sys/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 9888a0b..fe8d8fc 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -363,8 +363,8 @@ bitflags!( pub struct ImDrawCornerFlags: c_int { const TopLeft = 1 << 0; const TopRight = 1 << 1; - const BotRight = 1 << 2; - const BotLeft = 1 << 3; + const BotLeft = 1 << 2; + const BotRight = 1 << 3; const Top = ImDrawCornerFlags::TopLeft.bits | ImDrawCornerFlags::TopRight.bits; const Bot = ImDrawCornerFlags::BotLeft.bits From e52193be405c1a5264588951fa8c539bda0b72d6 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:08:53 +0900 Subject: [PATCH 29/42] [cimgui 1.53.1] ImGuiIO: Add mouse_drag_max_distance_abs --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index fe8d8fc..1f20f8e 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -618,6 +618,7 @@ pub struct ImGuiIO { 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], From 4b788d095c507be7f3e29698fcfd165ea3dc97a2 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:10:48 +0900 Subject: [PATCH 30/42] [cimgui 1.53.1] Add new Dark and Light styles --- imgui-sys/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 1f20f8e..6b7eb61 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1666,6 +1666,8 @@ extern "C" { // Styles extern "C" { pub fn igStyleColorsClassic(dst: *mut ImGuiStyle); + pub fn igStyleColorsDark(dst: *mut ImGuiStyle); + pub fn igStyleColorsLight(dst: *mut ImGuiStyle); } // Utilities From db5059d17930fe3f70371fa68f97676c34b42884 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:12:49 +0900 Subject: [PATCH 31/42] [cimgui 1.53.1] Add new combo functions Move igCombo{1,2,3} into the combo group along with igBeginCombo and igEndCombo. --- imgui-sys/src/lib.rs | 76 +++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 6b7eb61..46e0f07 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -357,6 +357,29 @@ bitflags!( } ); +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 indictating which corner of a rectangle should be rounded #[repr(C)] @@ -1156,28 +1179,6 @@ extern "C" { 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 igCombo( - 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 igCombo2( - label: *const c_char, - current_item: *mut c_int, - items_separated_by_zeros: *const c_char, - height_in_items: c_int, - ) -> bool; - pub fn igCombo3( - 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, - ) -> bool; pub fn igPlotLines( label: *const c_char, values: *const c_float, @@ -1225,6 +1226,37 @@ extern "C" { pub fn igProgressBar(fraction: c_float, size_arg: *const ImVec2, overlay: *const c_char); } +// Combo +extern "C" { + pub fn igBeginCombo( + label: *const c_char, + preview_value: *const c_char, + flags: ImGuiComboFlags, + ) -> bool; + pub fn igEndCombo(); + pub fn igCombo( + 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 igCombo2( + label: *const c_char, + current_item: *mut c_int, + items_separated_by_zeros: *const c_char, + height_in_items: c_int, + ) -> bool; + pub fn igCombo3( + 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, + ) -> bool; +} + // Widgets: Color Editor/Picker extern "C" { pub fn igColorEdit3( From c016ed66b7720eba307da20fae8a71c12112d33a Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:16:29 +0900 Subject: [PATCH 32/42] [cimgui 1.53.1] Allow access to ImDrawListSharedData Add binding to igGetDrawListDrawData and igGetOverlayDrawList. --- imgui-sys/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 46e0f07..8e3ad72 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -796,7 +796,7 @@ pub struct ImDrawList { } #[repr(C)] -struct ImDrawListSharedData { +pub struct ImDrawListSharedData { /// UV of white pixel in the atlas tex_uv_white_pixel: ImVec2, /// Current/default font (optional, for simplified AddText overload) @@ -1781,6 +1781,12 @@ pub unsafe fn igIsRootWindowOrAnyChildHovered(_flags: ImGuiHoveredFlags) -> bool igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows) } +// DrawList +extern "C" { + pub fn igGetOverlayDrawList() -> *mut ImDrawList; + pub fn igGetDrawListSharedData() -> *mut ImDrawListSharedData; +} + // Inputs extern "C" { pub fn igGetKeyIndex(imgui_key: ImGuiKey) -> c_int; From 20d40f0e01cfff4c9ad62e0f29c992996e2d3ec2 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:17:50 +0900 Subject: [PATCH 33/42] [cimgui 1.53.1] Add binding to igSetItemDefaultFocus Group functions related to focus management together. --- imgui-sys/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 8e3ad72..21a3550 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1023,7 +1023,6 @@ 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 igSetKeyboardFocusHere(offset: c_int); pub fn igSetStateStorage(tree: *mut ImGuiStorage); pub fn igGetStateStorage() -> *mut ImGuiStorage; } @@ -1702,6 +1701,12 @@ extern "C" { pub fn igStyleColorsLight(dst: *mut ImGuiStyle); } +// Focus +extern "C" { + pub fn igSetItemDefaultFocus(); + pub fn igSetKeyboardFocusHere(offset: c_int); +} + // Utilities extern "C" { pub fn igIsItemHovered(flags: ImGuiHoveredFlags) -> bool; From 4eef43f62ba1a3b4226c63d8a1a10e1cfbf7a51d Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:20:37 +0900 Subject: [PATCH 34/42] [cimgui 1.53.1] Add binding to igShowStyleSelector and igShowFontSelector --- imgui-sys/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 21a3550..654e274 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -954,6 +954,8 @@ 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 igShowFontSelector(label: *const c_char); pub fn igShowUserGuide(); } From cd37cf9993bfba6a781ff8d0a208048dde1baf38 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:21:17 +0900 Subject: [PATCH 35/42] [cimgui 1.53.1] Add binding to igEndFrame --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 654e274..72dc869 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -946,6 +946,7 @@ extern "C" { pub fn igGetDrawData() -> *mut ImDrawData; pub fn igNewFrame(); pub fn igRender(); + pub fn igEndFrame(); pub fn igShutdown(); } From 9cd0e61a25d78e152858551709c960a9f5150bac Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:21:44 +0900 Subject: [PATCH 36/42] [cimgui 1.53.1] Add binding to ImFontConfig_DefaultConstructor --- imgui-sys/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 72dc869..bc5b96b 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -1851,6 +1851,10 @@ extern "C" { pub fn igSetCurrentContext(ctx: *mut ImGuiContext); } +extern "C" { + pub fn ImFontConfig_DefaultConstructor(config: *mut ImFontConfig); +} + // ImGuiIO extern "C" { pub fn ImGuiIO_AddInputCharacter(c: c_ushort); From e64a1cff0570afa94c81ef728e2356629f90a42c Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:22:12 +0900 Subject: [PATCH 37/42] [cimgui 1.53.1] Add binding to ImDrawList_AddImageRounded --- imgui-sys/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index bc5b96b..ca06bbf 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -2121,6 +2121,17 @@ extern "C" { 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, From b57d639ca4faa64beaef6f1e4c63a38fe3628be5 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 11:23:10 +0900 Subject: [PATCH 38/42] [cimgui 1.53.1] Add raw bindings to drag/drop API Unfortunately, it seems necessary to pull a new dependency, libc, to be able to use size_t. Is there any alternative? --- imgui-sys/Cargo.toml | 1 + imgui-sys/src/lib.rs | 82 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index bbc0fe1..40488d7 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -13,6 +13,7 @@ build = "build.rs" travis-ci = { repository = "Gekkio/imgui-rs" } [dependencies] +libc = "0.2" bitflags = "1.0" glium = { version = "0.21", default-features = false, optional = true } gfx = { version = "0.17", optional = true } diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index ca06bbf..146e695 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -3,6 +3,8 @@ #[macro_use] extern crate bitflags; +extern crate libc; + #[cfg(feature = "gfx")] #[macro_use] extern crate gfx; @@ -380,6 +382,46 @@ bitflags!( } ); +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)] @@ -672,6 +714,28 @@ pub struct ImGuiTextFilter { 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, @@ -1687,6 +1751,24 @@ extern "C" { pub fn igLogText(fmt: *const c_char, ...); } +// DragDrop +extern "C" { + /// Call when current ID is active. + /// + /// When this returns true you need to: + /// + /// 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; + /// 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, cond: ImGuiCond) -> bool; + pub fn igEndDragDropSource(); + pub fn igBeginDragDropTarget() -> bool; + pub fn igAcceptDragDropPayload(type_: *const c_char, flags: ImGuiDragDropFlags) -> *const ImGuiPayload; + pub fn igEndDragDropTarget(); +} + // Clipping extern "C" { pub fn igPushClipRect( From e4668f02210a8e818400d565aeeee58a5aba6181 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 1 May 2018 13:28:45 +0900 Subject: [PATCH 39/42] [cimgui 1.53.1] Add binding to ImFont_GetDebugName --- imgui-sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 146e695..def7037 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -2428,6 +2428,7 @@ extern "C" { 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, From 0e1ec3cb6a7a56047e4ea2428da0cf17e2a5660c Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sat, 5 May 2018 12:13:28 +0900 Subject: [PATCH 40/42] fonts: Use ImFontConfig_DefaultConstructor to initialize sys::ImFontConfig --- imgui-sys/src/lib.rs | 26 -------------------------- src/fonts.rs | 6 +++++- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index def7037..ba670c9 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -15,7 +15,6 @@ extern crate glium; use std::convert::From; use std::mem; use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void}; -use std::ptr; use std::slice; #[cfg(feature = "gfx")] @@ -911,31 +910,6 @@ pub struct ImFontConfig { name: [c_char; 32], dst_font: *mut ImFont, } -impl ImFontConfig { - // This function only exists because cimgui does not provide a wrapper around - // `ImGuiConfig::ImGuiConfig()`. This code is based off that constructor. - pub fn new() -> ImFontConfig { - ImFontConfig { - font_data: ptr::null_mut(), - font_data_size: 0, - font_data_owned_by_atlas: true, - font_no: 0, - size_pixels: 0.0, - oversample_h: 3, - oversample_v: 1, - pixel_snap_h: false, - glyph_extra_spacing: ImVec2::zero(), - glyph_offset: ImVec2::zero(), - glyph_ranges: ptr::null(), - merge_mode: false, - rasterizer_flags: 0, - rasterizer_multiply: 1.0, - - name: [0; 32], - dst_font: ptr::null_mut(), - } - } -} #[repr(C)] #[derive(Copy, Clone, Debug, Default)] diff --git a/src/fonts.rs b/src/fonts.rs index e5c0aae..a3023b7 100644 --- a/src/fonts.rs +++ b/src/fonts.rs @@ -156,7 +156,11 @@ impl ImFontConfig { } fn make_config(self) -> sys::ImFontConfig { - let mut config = sys::ImFontConfig::new(); + let mut config = unsafe { + let mut config = mem::uninitialized(); + sys::ImFontConfig_DefaultConstructor(&mut config); + config + }; config.size_pixels = self.size_pixels; config.oversample_h = self.oversample_h as c_int; config.oversample_v = self.oversample_v as c_int; From fc4245c30370af6edbc4efc0c95f86e08f27753f Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Tue, 8 May 2018 09:32:56 +0900 Subject: [PATCH 41/42] [cimgui 1.53.1] Update CHANGELOG Follow "keep a changelog" specification. https://keepachangelog.com/en/1.0.0/ --- CHANGELOG.markdown | 50 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 8f9b733..57e6e32 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,10 +2,42 @@ ## [Unreleased] +### Added + +- New things in imgui/cimgui 1.53.1 + - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. + - DemoWindow: Add `no_close` state. + - Input: Add `no_undo_redo` method. + - *imgui-sys*: + - `igStyleColorsDark` and `igStyleColorsLight` + - DragDrop low level API + - `igGetFrameHeight` + - `igBeginCombo`, `igEndCombo` + - `igSetItemDefaultFocus` + - `igGetOverlayDrawList` and `igGetDrawListSharedData` + - `ImFontConfig_DefaultConstructor` + - `ImDrawList_AddImageRounded` +- Input: Add `read_only` and `password` methods. + +### Changed + - Upgrade to imgui/cimgui 1.53.1 - - Rename `Ui::show_test_window` to `Ui::show_demo_window`. + - Rename `Ui::show_test_window` to `Ui::show_demo_window`. Keep redirection. - Rename `sys::igGetItemsLineHeightWithSpacing` to `sys::igGetFrameHeightWithSpacing`. + Keep redirection. - Rename `ImGuiTreeNodeFlags::AllowOverlapMode` to `ImGuiTreeNodeFlags::AllowItemOverlap`. + `sys::igSetNextWindowContentSize()`. Keep redirection. + - Rename `sys::ImGuiTextBuffer_append()` helper to `appendf()`. + - Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`. + Keep redirection. + - Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`. + Keep redirection. + - Rename `ImGuiCol::ChildWindowBg` to `ImGuiCol::ChildBg`. + Keep redirection. + +### Deprecated + +- Various imgui-sys things that were deprecated in imgui/cimgui 1.53.1 - Obsolete `sys::igIsRootWindowFocused()` in favor of using `sys::igIsWindowFocused(ImGuiFocusedFlags::RootWindow)`. - Obsolete `sys::igIsRootWindowOrAnyChildFocused()` in favor of using @@ -13,20 +45,16 @@ - Obsolete `sys::igIsRootWindowOrAnyChildHovered()` in favor of using `sys::igIsWindowHovered(ImGuiHoveredFlags::RootAndChildWindows)`. - Obsolete `sys::SetNextWindowContentWidth()` in favor of using - `sys::igSetNextWindowContentSize()`. - - Rename `sys::ImGuiTextBuffer_append()` helper to `appendf()`. - - Remove `anti_aliased: bool` final parameter of `sys::ImDrawList_AddPolyline` - and `sys::ImDrawList_AddConvexPolyFilled`. - - Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`. - - Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`. - - Remove `ImGuiWindowFlags::ShowBorders` window flag. Borders are now fully - set up in the ImGuiStyle structure. - Obsolete `Window::show_borders`. Use `StyleVar` instead. - Obsolete `ImGuiCol::ComboBg`. Use `PopupBg` instead. - - Rename `ImGuiCol::ChildWindowBg` to `ImGuiCol::ChildBg`. - - Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`. +### Removed +- Features that were removed in imgui/cimgui 1.53.1 + - Remove `anti_aliased: bool` final parameter of `sys::ImDrawList_AddPolyline` + and `sys::ImDrawList_AddConvexPolyFilled`. + - Remove `ImGuiWindowFlags::ShowBorders` window flag. Borders are now fully + set up in the ImGuiStyle structure. ## [0.0.18] - 2017-12-23 From 500e64d67e4701813ede538a681176e1ef348268 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 14 May 2018 11:50:13 +0900 Subject: [PATCH 42/42] [cimgui 1.53.1] StyleVar: Add missing WindowBorderSize Use WindowBorderSize as replacement for border boolean in window.rs --- imgui-sys/src/lib.rs | 3 ++- src/lib.rs | 1 + src/style.rs | 1 + src/window.rs | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index ba670c9..8173361 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -151,6 +151,7 @@ pub enum ImGuiStyleVar { Alpha, WindowPadding, WindowRounding, + WindowBorderSize, WindowMinSize, ChildRounding, ChildBorderSize, @@ -165,7 +166,7 @@ pub enum ImGuiStyleVar { GrabMinSize, ButtonTextAlign, } -pub const ImGuiStyleVar_COUNT: usize = 16; +pub const ImGuiStyleVar_COUNT: usize = 17; impl ImGuiStyleVar { #[deprecated(since = "0.0.19", note = "please use ChildRounding instead")] diff --git a/src/lib.rs b/src/lib.rs index 2c310c7..0c99b31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1202,6 +1202,7 @@ impl<'ui> Ui<'ui> { 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) diff --git a/src/style.rs b/src/style.rs index 5859be8..5e3039b 100644 --- a/src/style.rs +++ b/src/style.rs @@ -5,6 +5,7 @@ pub enum StyleVar { Alpha(f32), WindowPadding(ImVec2), WindowRounding(f32), + WindowBorderSize(f32), WindowMinSize(ImVec2), ChildRounding(f32), ChildBorderSize(f32), diff --git a/src/window.rs b/src/window.rs index b1330ca..7f6427e 100644 --- a/src/window.rs +++ b/src/window.rs @@ -161,7 +161,7 @@ impl<'ui, 'p> Window<'ui, 'p> { sys::igSetNextWindowSize(self.size.into(), self.size_cond); } if self.border { - sys::igPushStyleVar(ImGuiStyleVar::FrameBorderSize, 1.0); + sys::igPushStyleVar(ImGuiStyleVar::WindowBorderSize, 1.0); } sys::igBegin( self.name.as_ptr(),