From 9d9028903ab626b163cd97975a44e8f78a3a5f15 Mon Sep 17 00:00:00 2001 From: Jack Mac Date: Mon, 21 Feb 2022 21:13:10 -0500 Subject: [PATCH 01/57] init --- imgui-sdl2-support/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/imgui-sdl2-support/src/lib.rs b/imgui-sdl2-support/src/lib.rs index edf8c6b..df6e221 100644 --- a/imgui-sdl2-support/src/lib.rs +++ b/imgui-sdl2-support/src/lib.rs @@ -167,25 +167,29 @@ impl SdlPlatform { /// /// * keyboard state is updated /// * mouse state is updated - pub fn handle_event(&mut self, context: &mut Context, event: &Event) { + pub fn handle_event(&mut self, context: &mut Context, event: &Event) -> bool { let io = context.io_mut(); match *event { Event::MouseWheel { x, y, .. } => { io.mouse_wheel = y as f32; io.mouse_wheel_h = x as f32; + true } Event::MouseButtonDown { mouse_btn, .. } => { self.handle_mouse_button(&mouse_btn, true); + true } Event::MouseButtonUp { mouse_btn, .. } => { self.handle_mouse_button(&mouse_btn, false); + true } Event::TextInput { ref text, .. } => { text.chars().for_each(|c| io.add_input_character(c)); + true } Event::KeyDown { @@ -195,6 +199,7 @@ impl SdlPlatform { } => { io.keys_down[key as usize] = true; handle_key_modifier(io, &keymod); + true } Event::KeyUp { @@ -204,9 +209,10 @@ impl SdlPlatform { } => { io.keys_down[key as usize] = false; handle_key_modifier(io, &keymod); + true } - _ => {} + _ => false } } From 37926397fa62b94c5693735f67ac9e45cecafb3d Mon Sep 17 00:00:00 2001 From: Jack Mac Date: Mon, 21 Feb 2022 21:15:01 -0500 Subject: [PATCH 02/57] lint comma --- imgui-sdl2-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui-sdl2-support/src/lib.rs b/imgui-sdl2-support/src/lib.rs index df6e221..7baf8f4 100644 --- a/imgui-sdl2-support/src/lib.rs +++ b/imgui-sdl2-support/src/lib.rs @@ -212,7 +212,7 @@ impl SdlPlatform { true } - _ => false + _ => false, } } From 30f8f04dcfa0d7491ae74c01dc4c8f2ebaa9ac85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Sejkora?= Date: Sun, 27 Feb 2022 05:30:51 +0100 Subject: [PATCH 03/57] Remove im_str! usage from examples in docs --- imgui/src/draw_list.rs | 2 +- imgui/src/lib.rs | 6 +++--- imgui/src/widget/slider.rs | 9 +++------ imgui/src/widget/tab.rs | 10 +++++----- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/imgui/src/draw_list.rs b/imgui/src/draw_list.rs index 4da1248..0180061 100644 --- a/imgui/src/draw_list.rs +++ b/imgui/src/draw_list.rs @@ -426,7 +426,7 @@ impl<'ui> DrawListMut<'ui> { /// # use imgui::*; /// fn custom_button(ui: &Ui, img_id: TextureId) { /// // Invisible button is good widget to customise with image - /// ui.invisible_button(im_str!("custom_button"), [100.0, 20.0]); + /// ui.invisible_button("custom_button", [100.0, 20.0]); /// /// // Get draw list and draw image over invisible button /// let draw_list = ui.get_window_draw_list(); diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index 7eb289f..c4d4fe7 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -609,7 +609,7 @@ impl Ui { /// ui.text("Hover over me"); /// if ui.is_item_hovered() { /// ui.tooltip(|| { - /// ui.text_colored([1.0, 0.0, 0.0, 1.0], im_str!("I'm red!")); + /// ui.text_colored([1.0, 0.0, 0.0, 1.0], "I'm red!"); /// }); /// } /// } @@ -676,7 +676,7 @@ impl Ui { /// fn user_interface(ui: &Ui) { /// let disable_buttons = true; /// let _d = ui.begin_disabled(disable_buttons); - /// ui.button(im_str!("Dangerous button")); + /// ui.button("Dangerous button"); /// } /// ``` @@ -703,7 +703,7 @@ impl Ui { /// fn user_interface(ui: &Ui) { /// let safe_mode = true; /// ui.disabled(safe_mode, || { - /// ui.button(im_str!("Dangerous button")); + /// ui.button("Dangerous button"); /// }); /// } /// ``` diff --git a/imgui/src/widget/slider.rs b/imgui/src/widget/slider.rs index 9da91d3..6ddec0d 100644 --- a/imgui/src/widget/slider.rs +++ b/imgui/src/widget/slider.rs @@ -196,8 +196,7 @@ where /// Constructs a new vertical slider builder with the given size and range. /// /// ```rust - /// # use imgui::im_str; - /// imgui::VerticalSlider::new(im_str!("Example"), [20.0, 20.0], i8::MIN, i8::MAX) + /// imgui::VerticalSlider::new("Example", [20.0, 20.0], i8::MIN, i8::MAX) /// .range(4, 8) /// // Remember to call .build(&ui) /// ; @@ -227,8 +226,7 @@ where /// Sets the range for the vertical slider. /// /// ```rust - /// # use imgui::im_str; - /// imgui::VerticalSlider::new(im_str!("Example"), [20.0, 20.0], i8::MIN, i8::MAX) + /// imgui::VerticalSlider::new("Example", [20.0, 20.0], i8::MIN, i8::MAX) /// .range(4, 8) /// // Remember to call .build(&ui) /// ; @@ -320,8 +318,7 @@ where { /// Sets the range in degrees (inclusive) /// ```rust - /// # use imgui::im_str; - /// imgui::AngleSlider::new(im_str!("Example")) + /// imgui::AngleSlider::new("Example") /// .range_degrees(-20.0, 20.0) /// // Remember to call .build(&ui) /// ; diff --git a/imgui/src/widget/tab.rs b/imgui/src/widget/tab.rs index 54b43a0..9bdf48d 100644 --- a/imgui/src/widget/tab.rs +++ b/imgui/src/widget/tab.rs @@ -6,12 +6,12 @@ //! # let ui = ctx.frame(); //! //! // During UI construction -//! TabBar::new(im_str!("tabbar")).build(&ui, || { -//! TabItem::new(im_str!("a tab")).build(&ui, || { -//! ui.text(im_str!("tab content 1")); +//! TabBar::new("tabbar").build(&ui, || { +//! TabItem::new("a tab").build(&ui, || { +//! ui.text("tab content 1"); //! }); -//! TabItem::new(im_str!("2tab")).build(&ui, || { -//! ui.text(im_str!("tab content 2")); +//! TabItem::new("2tab").build(&ui, || { +//! ui.text("tab content 2"); //! }); //! }); //! ``` From b5376c3fb4e40a45d537a5d4db39e0fa79df84a7 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 15 Mar 2022 12:14:17 +0100 Subject: [PATCH 04/57] imgui: Upgrade parking_lot to 0.12 with windows-rs bindings `parking_lot` now uses windows-rs's `windows-sys` crate, officially developed and vetted by Microsoft - the bindings are autogenerated from metadata and faster to compile too. See also https://github.com/Amanieu/parking_lot/pull/311. --- imgui/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index 33fcead..3815145 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -19,7 +19,7 @@ features = ["freetype", "docking", "tables-api"] bitflags = "1" imgui-sys = { version = "0.8.1-alpha.0", path = "../imgui-sys" } mint = "0.5.6" -parking_lot = "0.11" +parking_lot = "0.12" cfg-if = "1" [features] From 2b9b938327da6f46b3eef3d7b2dbd338e8a5c1b9 Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 15 Mar 2022 23:05:04 +1100 Subject: [PATCH 05/57] Fix misused anyhow! macro Was msising a return, which bail! includes --- xtask/src/bindgen.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xtask/src/bindgen.rs b/xtask/src/bindgen.rs index 1beb900..830fa39 100644 --- a/xtask/src/bindgen.rs +++ b/xtask/src/bindgen.rs @@ -1,5 +1,5 @@ use crate::flags::Bindgen; -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Context, Result, bail}; use std::path::{Path, PathBuf}; impl Bindgen { @@ -140,7 +140,7 @@ fn generate_binding_file( eprintln!("Executing bindgen [output = {}]", output.display()); let status = cmd.status().context("Failed to execute bindgen")?; if !status.success() { - anyhow!( + bail!( "Failed to execute bindgen: {}, see output for details", status ); From c0fb4b636979120846c0f861cf1dbd4f95c9c1ef Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 15 Mar 2022 23:05:20 +1100 Subject: [PATCH 06/57] Fix future clippy warning --- imgui/src/widget/drag.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imgui/src/widget/drag.rs b/imgui/src/widget/drag.rs index af25ca1..1c550b8 100644 --- a/imgui/src/widget/drag.rs +++ b/imgui/src/widget/drag.rs @@ -253,7 +253,6 @@ where #[doc(alias = "DragIntRange2")] pub fn build(self, ui: &Ui, min: &mut i32, max: &mut i32) -> bool { unsafe { - let label; let mut display_format = std::ptr::null(); let mut max_display_format = std::ptr::null(); @@ -261,7 +260,7 @@ where let buffer = &mut *ui.scratch_buffer().get(); buffer.refresh_buffer(); - label = buffer.push(self.label); + let label = buffer.push(self.label); if let Some(v) = self.display_format { display_format = buffer.push(v); } From 5e2ab214d13667f02ff7f24ccbeb2e1fa24b1cbf Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 15 Mar 2022 23:07:29 +1100 Subject: [PATCH 07/57] fmt --- xtask/src/bindgen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/bindgen.rs b/xtask/src/bindgen.rs index 830fa39..1272f25 100644 --- a/xtask/src/bindgen.rs +++ b/xtask/src/bindgen.rs @@ -1,5 +1,5 @@ use crate::flags::Bindgen; -use anyhow::{anyhow, Context, Result, bail}; +use anyhow::{anyhow, bail, Context, Result}; use std::path::{Path, PathBuf}; impl Bindgen { From b08f3bfe291ca2a222f7b79da9c0e8f6478b66d2 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 12 Nov 2020 23:24:14 +0100 Subject: [PATCH 08/57] imgui-winit-support: Compile doctest on winit 20+ --- imgui-winit-support/src/lib.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 3c2c65d..f8668ed 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -15,8 +15,30 @@ //! //! ## Complete example for winit 0.20+ (without a renderer) //! -//! ```rust,no_run,ignore -//! # // TODO: Remove ignore when only one winit version is used +//! ```no_run +//! # #[cfg(feature = "winit-19")] +//! # fn main() {} +//! # +//! # #[cfg(not(feature = "winit-19"))] +//! # fn main() { +//! # #[cfg(feature = "winit-20")] +//! # use winit_20 as winit; +//! # +//! # #[cfg(feature = "winit-22")] +//! # use winit_22 as winit; +//! # +//! # #[cfg(feature = "winit-23")] +//! # use winit_23 as winit; +//! # +//! # #[cfg(feature = "winit-24")] +//! # use winit_24 as winit; +//! # +//! # #[cfg(feature = "winit-25")] +//! # use winit_25 as winit; +//! # +//! # #[cfg(feature = "winit-26")] +//! # use winit_26 as winit; +//! # //! use imgui::Context; //! use imgui_winit_support::{HiDpiMode, WinitPlatform}; //! use std::time::Instant; @@ -70,6 +92,7 @@ //! } //! } //! }) +//! # } //! ``` //! //! ## `winit` versions and features. From 055c16b4e2ff007fc21277e52072b9bd196dffc6 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 12 Nov 2020 23:38:03 +0100 Subject: [PATCH 09/57] imgui-winit-support: Fix use of update_delta_time in example doc --- imgui-winit-support/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index f8668ed..4a4b057 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -61,7 +61,9 @@ //! match event { //! Event::NewEvents(_) => { //! // other application-specific logic -//! last_frame = imgui.io_mut().update_delta_time(last_frame); +//! let now = Instant::now(); +//! imgui.io_mut().update_delta_time(now - last_frame); +//! last_frame = now; //! }, //! Event::MainEventsCleared => { //! // other application-specific logic From db71313f04e087393d58b97e046755905997593a Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 15 Mar 2022 14:01:50 +0100 Subject: [PATCH 10/57] imgui-winit-support: Get `DrawData` from `Context` instead of `Ui` As per a recent deprecation change scheduled for the 0.9 release. --- imgui-winit-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 4a4b057..ef3847c 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -79,7 +79,7 @@ //! //! platform.prepare_render(&ui, &window); // step 5 //! // render the UI with a renderer -//! let draw_data = ui.render(); +//! let draw_data = imgui.render(); //! // renderer.render(..., draw_data).expect("UI rendering failed"); //! //! // application-specific rendering *over the UI* From cc08285a0431385f7eca0da1b9e7ab5b28672bb6 Mon Sep 17 00:00:00 2001 From: dbr Date: Fri, 18 Mar 2022 22:07:27 +1100 Subject: [PATCH 11/57] Update the list clipper: 1. Avoid calling step() in destructor - incorrect and unnecessary, as it is not required to fully "use" the clipper (you can stop rendering half-way through) 2. Add a harder to misuse iterator interface to the clipper as an alterantive to the C++ style .step() interface Closes #610 --- imgui-examples/examples/long_list.rs | 17 ++- imgui/src/list_clipper.rs | 176 +++++++++++++++++++++++++-- 2 files changed, 181 insertions(+), 12 deletions(-) diff --git a/imgui-examples/examples/long_list.rs b/imgui-examples/examples/long_list.rs index 2204c53..e4b019a 100644 --- a/imgui-examples/examples/long_list.rs +++ b/imgui-examples/examples/long_list.rs @@ -15,8 +15,10 @@ fn main() { let system = support::init(file!()); system.main_loop(move |_, ui| { + // Show the C++ style API ui.window("Hello long world") - .size([300.0, 110.0], Condition::FirstUseEver) + .size([100.0, 500.0], Condition::FirstUseEver) + .position([10.0, 10.0], crate::Condition::Always) .build(|| { let mut clipper = imgui::ListClipper::new(lots_of_words.len() as i32) .items_height(ui.current_font_size()) @@ -27,5 +29,18 @@ fn main() { } } }); + + // Show the more Rust'y iterator + ui.window("Hello long world (iterator API)") + .size([100.0, 500.0], Condition::FirstUseEver) + .position([150.0, 10.0], crate::Condition::Always) + .build(|| { + let clipper = imgui::ListClipper::new(lots_of_words.len() as i32) + .items_height(ui.current_font_size()) + .begin(ui); + for row_num in clipper.iter() { + ui.text(&lots_of_words[row_num as usize]); + } + }); }); } diff --git a/imgui/src/list_clipper.rs b/imgui/src/list_clipper.rs index cfe4ff5..9363556 100644 --- a/imgui/src/list_clipper.rs +++ b/imgui/src/list_clipper.rs @@ -1,5 +1,4 @@ use std::marker::PhantomData; -use std::thread; use crate::sys; use crate::Ui; @@ -22,6 +21,7 @@ pub struct ListClipper { } impl ListClipper { + /// Begins configuring a list clipper. pub const fn new(items_count: i32) -> Self { ListClipper { items_count, @@ -45,6 +45,11 @@ impl ListClipper { } } +/// List clipper is a mechanism to efficiently implement scrolling of +/// large lists with random access. +/// +/// For example you have a list of 1 million buttons, and the list +/// clipper will help you only draw the ones which are visible. pub struct ListClipperToken<'ui> { list_clipper: *mut sys::ImGuiListClipper, _phantom: PhantomData<&'ui Ui>, @@ -58,37 +63,186 @@ impl<'ui> ListClipperToken<'ui> { } } + /// Progress the list clipper. + /// + /// If this returns returns `true` then the you can loop between + /// between `clipper.display_start() .. clipper.display_end()`. + /// If this returns false, you must stop calling this method. + /// + /// Calling step again after it returns `false` will cause imgui + /// to abort. This mirrors the C++ interface. + /// + /// It is recommended to use the iterator interface! pub fn step(&mut self) -> bool { unsafe { sys::ImGuiListClipper_Step(self.list_clipper) } } + /// This is automatically called back the final call to + /// `step`. You can call it sooner but typically not needed. pub fn end(&mut self) { unsafe { sys::ImGuiListClipper_End(self.list_clipper); } } + /// First item to call, updated each call to `step` pub fn display_start(&self) -> i32 { unsafe { (*self.list_clipper).DisplayStart } } + /// End of items to call (exclusive), updated each call to `step` pub fn display_end(&self) -> i32 { unsafe { (*self.list_clipper).DisplayEnd } } + + /// Get an iterator which outputs all visible indexes. This is the + /// recommended way of using the clipper. + pub fn iter(self) -> ListClipperIterator<'ui> { + ListClipperIterator::new(self) + } } impl<'ui> Drop for ListClipperToken<'ui> { fn drop(&mut self) { - if !self.step() { - unsafe { - sys::ImGuiListClipper_destroy(self.list_clipper); - }; - } else if !thread::panicking() { - panic!( - "Forgot to call End(), or to Step() until false? \ - This is the only token in the repository which users must call `.end()` or `.step()` \ - with. See https://github.com/imgui-rs/imgui-rs/issues/438" - ); + unsafe { + sys::ImGuiListClipper_destroy(self.list_clipper); + }; + } +} + +pub struct ListClipperIterator<'ui> { + list_clipper: ListClipperToken<'ui>, + exhausted: bool, + last_value: Option, +} + +impl<'ui> ListClipperIterator<'ui> { + fn new(list_clipper: ListClipperToken<'ui>) -> Self { + Self { + list_clipper, + exhausted: false, + last_value: None, } } } + +impl Iterator for ListClipperIterator<'_> { + type Item = i32; + + fn next(&mut self) -> Option { + if let Some(lv) = self.last_value { + // Currently iterating a chunk (returning all values + // between display_start and display_end) + let next_value = lv + 1; + + if lv >= self.list_clipper.display_end() - 1 { + // If we reach the end of the current chunk, clear + // last_value so we call step below + self.last_value = None; + } else { + // Otherwise just increment it + self.last_value = Some(next_value); + } + } + + if let Some(lv) = self.last_value { + // Next item within current step's chunk + Some(lv) + } else { + // Start iterating a new chunk + + if self.exhausted { + // If the clipper is exhausted, don't call step again! + None + } else { + // Advance the clipper + let ret = self.list_clipper.step(); + if !ret { + self.exhausted = true; + None + } else { + // Setup iteration for this step's chunk + let start = self.list_clipper.display_start(); + let end = self.list_clipper.display_end(); + + if start == end { + // Somewhat special case: if a single item, we + // don't store the last_value so we call + // step() again next iteration + self.last_value = None; + } else { + self.last_value = Some(start); + } + Some(start) + } + } + } + } +} + +#[test] +fn cpp_style_usage() { + // Setup + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + let ui = ctx.frame(); + + let _window = ui + .window("Example") + .position([0.0, 0.0], crate::Condition::Always) + .size([100.0, 800.0], crate::Condition::Always) + .begin(); + + // Create clipper + let clip = ListClipper::new(1000); + let mut tok = clip.begin(&ui); + + let mut ticks = 0; + + while dbg!(tok.step()) { + for row_num in dbg!(tok.display_start())..dbg!(tok.display_end()) { + dbg!(row_num); + ui.text("..."); + ticks += 1; + } + } + + // Check it's called an expected amount of time (only the ones + // visible in given sized window) + assert_eq!(ticks, 44); + + // Calling end multiple times is fine albeit redundant + tok.end(); + tok.end(); + tok.end(); + tok.end(); + tok.end(); + tok.end(); +} + +#[test] +fn iterator_usage() { + // Setup + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + let ui = ctx.frame(); + + let _window = ui + .window("Example") + .position([0.0, 0.0], crate::Condition::Always) + .size([100.0, 800.0], crate::Condition::Always) + .begin(); + + // Create clipper + let clip = ListClipper::new(1000); + + let mut ticks = 0; + + let tok = clip.begin(&ui); + for row_num in tok.iter() { + dbg!(row_num); + ui.text("..."); + ticks += 1; + } + + // Should be consistent with size in `cpp_style_usage` + assert_eq!(ticks, 44); +} From 39e45251b3a03c3237c6c1d2498a953647698318 Mon Sep 17 00:00:00 2001 From: dbr Date: Fri, 18 Mar 2022 22:07:58 +1100 Subject: [PATCH 12/57] Example showing how to use list clipper+table --- imgui-examples/examples/long_table.rs | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 imgui-examples/examples/long_table.rs diff --git a/imgui-examples/examples/long_table.rs b/imgui-examples/examples/long_table.rs new file mode 100644 index 0000000..8b300e9 --- /dev/null +++ b/imgui-examples/examples/long_table.rs @@ -0,0 +1,52 @@ +use imgui::*; + +mod support; + +fn main() { + let system = support::init(file!()); + + system.main_loop(move |_, ui| { + ui.show_demo_window(&mut true); + + ui.window("Table with list clipper") + .size([800.0, 700.0], Condition::FirstUseEver) + .build(|| { + let num_cols = 3; + let num_rows = 1000; + + let flags = imgui::TableFlags::ROW_BG + | imgui::TableFlags::RESIZABLE + | imgui::TableFlags::BORDERS_H + | imgui::TableFlags::BORDERS_V; //| imgui::TableFlags::SCROLL_Y; + + if let Some(_t) = ui.begin_table_with_sizing( + "longtable", + num_cols, + flags, + [300.0, 100.0], + /*inner width=*/ 0.0, + ) { + ui.table_setup_column("A"); + ui.table_setup_column("B"); + ui.table_setup_column("C"); + + // Freeze first row so headers are visible even + // when scrolling + ui.table_setup_scroll_freeze(num_cols, 1); + + // Done with headers row + ui.table_headers_row(); + + // Create clipper with st + let clip = imgui::ListClipper::new(num_rows).begin(ui); + for row_num in clip.iter() { + ui.table_next_row(); + for col_num in 0..num_cols { + ui.table_set_column_index(col_num); + ui.text(format!("Hello {},{}", col_num, row_num)); + } + } + } + }); + }); +} From 68a5af174c5b6c31391ee20130ed4e1819e3f646 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 11:42:06 +1100 Subject: [PATCH 13/57] fmt --- imgui-examples/examples/long_table.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imgui-examples/examples/long_table.rs b/imgui-examples/examples/long_table.rs index 8b300e9..c610ef1 100644 --- a/imgui-examples/examples/long_table.rs +++ b/imgui-examples/examples/long_table.rs @@ -40,11 +40,11 @@ fn main() { // Create clipper with st let clip = imgui::ListClipper::new(num_rows).begin(ui); for row_num in clip.iter() { - ui.table_next_row(); - for col_num in 0..num_cols { - ui.table_set_column_index(col_num); - ui.text(format!("Hello {},{}", col_num, row_num)); - } + ui.table_next_row(); + for col_num in 0..num_cols { + ui.table_set_column_index(col_num); + ui.text(format!("Hello {},{}", col_num, row_num)); + } } } }); From 5a76ed7ce6c6655206826da5fd119731f4b9d823 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 11:43:14 +1100 Subject: [PATCH 14/57] Clippy the wildly pedantic --- imgui/src/list_clipper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui/src/list_clipper.rs b/imgui/src/list_clipper.rs index 9363556..140e10a 100644 --- a/imgui/src/list_clipper.rs +++ b/imgui/src/list_clipper.rs @@ -194,7 +194,7 @@ fn cpp_style_usage() { // Create clipper let clip = ListClipper::new(1000); - let mut tok = clip.begin(&ui); + let mut tok = clip.begin(ui); let mut ticks = 0; @@ -236,7 +236,7 @@ fn iterator_usage() { let mut ticks = 0; - let tok = clip.begin(&ui); + let tok = clip.begin(ui); for row_num in tok.iter() { dbg!(row_num); ui.text("..."); From 091e5a6a15b2764f831a08f69c8b8714c052ae2b Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 20:31:06 +1100 Subject: [PATCH 15/57] Workaround to turn imgui <~ 1.88 segfault into a panic --- imgui/src/list_clipper.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/imgui/src/list_clipper.rs b/imgui/src/list_clipper.rs index 140e10a..7b11684 100644 --- a/imgui/src/list_clipper.rs +++ b/imgui/src/list_clipper.rs @@ -53,6 +53,15 @@ impl ListClipper { pub struct ListClipperToken<'ui> { list_clipper: *mut sys::ImGuiListClipper, _phantom: PhantomData<&'ui Ui>, + + /// In upstream imgui < 1.87, calling step too many times will + /// cause a segfault due to null pointer. So we keep track of this + /// and panic instead. + /// + /// Fixed in https://github.com/ocornut/imgui/commit/dca527b which + /// will likely be part of imgui 1.88 - at which point this can be + /// removed. + consumed_workaround: bool, } impl<'ui> ListClipperToken<'ui> { @@ -60,6 +69,7 @@ impl<'ui> ListClipperToken<'ui> { Self { list_clipper, _phantom: PhantomData, + consumed_workaround: false, } } @@ -74,7 +84,19 @@ impl<'ui> ListClipperToken<'ui> { /// /// It is recommended to use the iterator interface! pub fn step(&mut self) -> bool { - unsafe { sys::ImGuiListClipper_Step(self.list_clipper) } + let is_imgui_1_88_or_higher = false; + if is_imgui_1_88_or_higher { + unsafe { sys::ImGuiListClipper_Step(self.list_clipper) } + } else { + if self.consumed_workaround { + panic!("ListClipperToken::step called after it has previously returned false"); + } + let ret = unsafe { sys::ImGuiListClipper_Step(self.list_clipper) }; + if ret { + self.consumed_workaround = true; + } + ret + } } /// This is automatically called back the final call to From 9648b40d855b0dc6212af761842f0f59803ea7f1 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 21:03:52 +1100 Subject: [PATCH 16/57] Handle window focus lost event Avoids keys getting stuck when window loses focus (e.g alt+tab) Closes #602 --- imgui-winit-support/src/lib.rs | 23 ++++++++++++++++++++++- imgui/src/io.rs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 3c2c65d..c733b80 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -941,7 +941,14 @@ impl WinitPlatform { } _ => (), } - } + }, + WindowEvent::Focused(newly_focused) => { + if !newly_focused { + // Set focus-lost to avoid stuck keys (like 'alt' + // when alt-tabbing) + io.app_focus_lost = true; + } + }, _ => (), } } @@ -1052,6 +1059,13 @@ impl WinitPlatform { _ => (), } } + WindowEvent::Focused(newly_focused) => { + if !newly_focused { + // Set focus-lost to avoid stuck keys (like 'alt' + // when alt-tabbing) + io.app_focus_lost = true; + } + } _ => (), } } @@ -1161,6 +1175,13 @@ impl WinitPlatform { _ => (), } } + WindowEvent::Focused(newly_focused) => { + if !newly_focused { + // Set focus-lost to avoid stuck keys (like 'alt' + // when alt-tabbing) + io.app_focus_lost = true; + } + } _ => (), } } diff --git a/imgui/src/io.rs b/imgui/src/io.rs index 2362c31..4bf8ba1 100644 --- a/imgui/src/io.rs +++ b/imgui/src/io.rs @@ -339,7 +339,7 @@ pub struct Io { nav_inputs_down_duration: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], nav_inputs_down_duration_prev: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], pen_pressure: f32, - app_focus_lost: bool, + pub app_focus_lost: bool, input_queue_surrogate: sys::ImWchar16, input_queue_characters: ImVector, } From a658073bd78e865de6375d2de28e8a1d6ceb6e76 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 21:07:57 +1100 Subject: [PATCH 17/57] Booleano --- imgui/src/list_clipper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui/src/list_clipper.rs b/imgui/src/list_clipper.rs index 7b11684..a7c000c 100644 --- a/imgui/src/list_clipper.rs +++ b/imgui/src/list_clipper.rs @@ -92,7 +92,7 @@ impl<'ui> ListClipperToken<'ui> { panic!("ListClipperToken::step called after it has previously returned false"); } let ret = unsafe { sys::ImGuiListClipper_Step(self.list_clipper) }; - if ret { + if !ret { self.consumed_workaround = true; } ret From 5cd71fef4c722ae62f988db5cdef1602428bb948 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 19 Mar 2022 21:10:22 +1100 Subject: [PATCH 18/57] cargo fmt --all --- imgui-winit-support/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index c733b80..9000dd9 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -941,14 +941,14 @@ impl WinitPlatform { } _ => (), } - }, + } WindowEvent::Focused(newly_focused) => { if !newly_focused { // Set focus-lost to avoid stuck keys (like 'alt' // when alt-tabbing) io.app_focus_lost = true; } - }, + } _ => (), } } From 7861355fe84d2055faa21bb3f8c8b16e99e7372c Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 22 Mar 2022 20:36:51 +1100 Subject: [PATCH 19/57] Docstring for app_focus_lost --- imgui/src/io.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imgui/src/io.rs b/imgui/src/io.rs index 4bf8ba1..50f8975 100644 --- a/imgui/src/io.rs +++ b/imgui/src/io.rs @@ -339,6 +339,10 @@ pub struct Io { nav_inputs_down_duration: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], nav_inputs_down_duration_prev: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], pen_pressure: f32, + + /// Clear buttons state when focus is lost (this is useful so + /// e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger + /// the Alt menu toggle) pub app_focus_lost: bool, input_queue_surrogate: sys::ImWchar16, input_queue_characters: ImVector, From 592af956977f7ba0c6d64e5ac9a8fbd51014d535 Mon Sep 17 00:00:00 2001 From: Will Cassels Date: Sun, 10 Apr 2022 17:24:16 +0100 Subject: [PATCH 20/57] Fix problematic TextCallbackData::selection implementation --- imgui/src/input_widget.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/imgui/src/input_widget.rs b/imgui/src/input_widget.rs index 59e8c29..043e5ef 100644 --- a/imgui/src/input_widget.rs +++ b/imgui/src/input_widget.rs @@ -1051,7 +1051,20 @@ impl TextCallbackData { /// This Range is given in `usize` so that it might be used in indexing /// operations more easily. To quickly grab the selected text, use [selected](Self::selected). pub fn selection(&self) -> Range { - unsafe { (*(self.0)).SelectionStart as usize..(*(self.0)).SelectionEnd as usize } + let (start, end) = unsafe { + ( + (*(self.0)).SelectionStart as usize, + (*(self.0)).SelectionEnd as usize, + ) + }; + // Avoid returning a range with start > end, which would be problematic. For example, it + // would cause panics when used to index the string buffer and would also cause Self::has_selection + // to return a false negative. + if start < end { + start..end + } else { + end..start + } } /// Returns the selected text directly. Note that if no text is selected, From 5ec80ec58443d1e7184ed27d780f0aff96435910 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 23 Apr 2022 13:22:50 +1000 Subject: [PATCH 21/57] Documenting a bunch of methods --- imgui/src/lib.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index c4d4fe7..124e005 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -456,6 +456,7 @@ impl Ui { // Widgets: Input impl<'ui> Ui { + /// Edits text in a single line input widget #[doc(alias = "InputText", alias = "InputTextWithHint")] pub fn input_text<'p, L: AsRef>( &'ui self, @@ -464,6 +465,8 @@ impl<'ui> Ui { ) -> InputText<'ui, 'p, L> { InputText::new(self, label, buf) } + + /// Edits text in a multi line widget #[doc(alias = "InputText", alias = "InputTextMultiline")] pub fn input_text_multiline<'p, L: AsRef>( &'ui self, @@ -473,6 +476,8 @@ impl<'ui> Ui { ) -> InputTextMultiline<'ui, 'p, L> { InputTextMultiline::new(self, label, buf, size) } + + /// Simple floating point number widget #[doc(alias = "InputFloat2")] pub fn input_float<'p, L: AsRef>( &'ui self, @@ -793,6 +798,7 @@ impl Ui { } impl<'ui> Ui { + /// Plot a list of floats as a "sparkline" style plot #[doc(alias = "PlotLines")] pub fn plot_lines<'p, Label: AsRef>( &'ui self, @@ -802,6 +808,7 @@ impl<'ui> Ui { PlotLines::new(self, label, values) } + /// Plot a list of floats as a histogram #[doc(alias = "PlotHistogram")] pub fn plot_histogram<'p, Label: AsRef>( &'ui self, @@ -854,7 +861,11 @@ impl<'ui> Ui { /// # Draw list for custom drawing impl Ui { - /// Get access to drawing API + /// Get access to drawing API. + /// + /// The window draw list draws within the current + /// window. Coordinates are within the current window coordinates, + /// so `[0.0, 0.0]` would be at beginning of window /// /// # Examples /// @@ -889,12 +900,24 @@ impl Ui { DrawListMut::window(self) } + /// Get draw list to draw behind all windows + /// + /// Coordinates are in window coordinates, so `[0.0, 0.0]` is at + /// top left of the Dear ImGui window + /// + /// See [`Self::get_window_draw_list`] for more details #[must_use] #[doc(alias = "GetBackgroundDrawList")] pub fn get_background_draw_list(&self) -> DrawListMut<'_> { DrawListMut::background(self) } + /// Get draw list instance to draw above all window content + /// + /// Coordinates are in window coordinates, so `[0.0, 0.0]` is at + /// top left of the Dear ImGui window + /// + /// See [`Self::get_window_draw_list`] for more details #[must_use] #[doc(alias = "GetForegroundDrawList")] pub fn get_foreground_draw_list(&self) -> DrawListMut<'_> { From 69f43e3025b69fce59c8c80759e2d0c738528e09 Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 23 Apr 2022 13:23:35 +1000 Subject: [PATCH 22/57] Deduplicate ui.enabled(...) and ui.disabled() --- imgui/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index 124e005..cadb3a2 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -723,9 +723,7 @@ impl Ui { /// [`Ui::begin_enabled`]. #[doc(alias = "BeginDisabled", alias = "EndDisabled")] pub fn enabled(&self, enabled: bool, f: F) { - unsafe { sys::igBeginDisabled(!enabled) }; - f(); - unsafe { sys::igEndDisabled() }; + self.disabled(!enabled, f) } } From c032408329090dfd923e573cf54f315c399e540a Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 23 Apr 2022 14:01:01 +1000 Subject: [PATCH 23/57] sudo rm -rf old-winit Somewhat experimental removal of old winit versions, to reduce maintenance burden Significantly reduces (around half) the length of winit-support, should reduce amount of work done in CI --- .github/workflows/ci.yml | 30 +- imgui-winit-support/Cargo.toml | 18 +- imgui-winit-support/UPDATING_WINIT.md | 8 - imgui-winit-support/src/lib.rs | 787 +------------------------- xtask/src/main.rs | 35 +- 5 files changed, 15 insertions(+), 863 deletions(-) delete mode 100644 imgui-winit-support/UPDATING_WINIT.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 670e0d0..c141707 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,15 +67,8 @@ jobs: - name: freetype and docking run: cargo clippy --workspace --all-targets --features freetype,docking - # supported winit versions (with otherwise default features) - - run: cargo doc - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-19 --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20 --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22 --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-23/default --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-24/default --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-25/default --all-targets - - run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-26/default --all-targets + - name: allf eatures + run: cargo clippy --workspace --all-targets --all-features test: name: Run tests @@ -147,20 +140,17 @@ jobs: if: matrix.os != 'windows-latest' run: cargo test --workspace --all-targets --features freetype - - name: freetype and docking + - name: all features if: matrix.os != 'windows-latest' - run: cargo test --workspace --all-targets --features freetype,docking + run: cargo test --workspace --all-targets --all-features + + - name: doc tests + run: cargo test --workspace --doc - - run: cargo test --workspace --doc # run to check for lint problems - - run: cargo doc - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-19 - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20 - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22 - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-23/default - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-24/default - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-25/default - - run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-26/default + - name: build documentation + run: cargo doc + # Run unreasonably slow tests under release, but only the crates that have # them, and don't bother doing this on most platforms. - run: cargo test -p imgui --release -- --ignored diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index e105b0e..8acbcca 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -11,20 +11,4 @@ categories = ["gui"] [dependencies] imgui = { version = "0.8.1-alpha.0", path = "../imgui" } -winit-19 = { version = ">= 0.16, < 0.20", package = "winit", optional = true } -winit-20 = { version = ">= 0.20, < 0.22", package = "winit", optional = true } -winit-22 = { version = "0.22", package = "winit", optional = true } -winit-23 = { version = "0.23", package = "winit", default-features = false, optional = true } -winit-24 = { version = "0.24", package = "winit", default-features = false, optional = true } -winit-25 = { version = "0.25", package = "winit", default-features = false, optional = true } -winit-26 = { version = "0.26", package = "winit", default-features = false, optional = true } - -[features] -default = ["winit-26/default"] -test = ["winit-23/default", "winit-24/default", "winit-25/default", "winit-26/default"] - -# This is phrased as a negative (unlike most features) so that it needs to be -# explicitly disabled (and `default-features = false` won't do it). To avoid -# problems from this we don't expose this in the public API in any way, keeping -# things additive. -no-warn-on-multiple = [] +winit = { version = "0.26.0", default-features = false } diff --git a/imgui-winit-support/UPDATING_WINIT.md b/imgui-winit-support/UPDATING_WINIT.md deleted file mode 100644 index 9ff786d..0000000 --- a/imgui-winit-support/UPDATING_WINIT.md +++ /dev/null @@ -1,8 +0,0 @@ -# Updating Winit - -Updating the default version of Winit is very annoying and error prone. We should make some automated way to do it so we don't have any issues in the future, but here is what needs to be done: - -1. Make sure that glutin is on the new version of Winit that you want to use. It's easier if our default winit version is on that new default. -2. Update the default in the Cargo.toml by simply changing the default guard. -3. At the top of lib.rs, edit the CFG guards which handle `use winit_x as winit;` such that the new default only relies on a positive feature guard (just copy the form used for the old default). If you don't do this, you'll get some particularly strange errors about two crates being used, since somehow the dependency resolver will pick a winit that the user didn't choose (and presumably won't use if it actually made it to compilation). -4. Profit?? diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 7460588..a8b012d 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -13,38 +13,15 @@ //! 4. Call frame preparation callback (every frame) //! 5. Call render preparation callback (every frame) //! -//! ## Complete example for winit 0.20+ (without a renderer) +//! ## Complete example (without a renderer) //! //! ```no_run -//! # #[cfg(feature = "winit-19")] -//! # fn main() {} -//! # -//! # #[cfg(not(feature = "winit-19"))] -//! # fn main() { -//! # #[cfg(feature = "winit-20")] -//! # use winit_20 as winit; -//! # -//! # #[cfg(feature = "winit-22")] -//! # use winit_22 as winit; -//! # -//! # #[cfg(feature = "winit-23")] -//! # use winit_23 as winit; -//! # -//! # #[cfg(feature = "winit-24")] -//! # use winit_24 as winit; -//! # -//! # #[cfg(feature = "winit-25")] -//! # use winit_25 as winit; -//! # -//! # #[cfg(feature = "winit-26")] -//! # use winit_26 as winit; -//! # //! use imgui::Context; //! use imgui_winit_support::{HiDpiMode, WinitPlatform}; //! use std::time::Instant; //! use winit::event::{Event, WindowEvent}; //! use winit::event_loop::{ControlFlow, EventLoop}; -//! use winit::window::{Window}; +//! use winit::window::Window; //! //! let mut event_loop = EventLoop::new(); //! let mut window = Window::new(&event_loop).unwrap(); @@ -94,154 +71,13 @@ //! } //! } //! }) -//! # } //! ``` -//! -//! ## `winit` versions and features. -//! -//! This crate has several features which control the version of winit which is -//! used. -//! -//! The following versions are supported, controlled by the listed feature. -//! -//! - The `winit-26` feature uses winit versions compatible with `0.26`. This is -//! on by default, so to use any other version you need to disable this crates -//! default features. -//! - The `winit-25` feature supports winit versions `0.25`. -//! - The `winit-24` feature supports winit versions `0.24`. -//! - The `winit-23` feature uses winit versions compatible with `0.23`. -//! - The `winit-22` feature uses winit versions compatible with `0.22`. -//! - The `winit-20` feature should support winit either `0.20` or winit `0.21`. -//! - The `winit-19` feature should support winits older than `0.19` (possibly -//! back to winit 0.16.*, but this isn't regularly tested and may not work). -//! -//! If multiple `winit-*` features are enabled, and it is a debug build (as -//! determined by `debug_assertions`), we will log a warning to stderr during -//! init. This can be disabled by either turning on the `no-warn-on-multiple` -//! feature, fixing the configuration, or disabling `debug_assertions`. -//! -//! Conversely, if no `winit-*` features are enabled, we will fail to compile. -//! This is not an issue generally, as by default we turn on `winit-26`. -//! -//! All of this is in attempt to preserve the additive nature of features (while -//! still helping users notice project configuration issues), however it's done -//! fairly weakly as our this crate's API isn't 100% identical across winit -//! versions. -//! -//! ### Using an older `winit` version -//! -//! To use an older version, you must configure `default-features = false` in -//! your `Cargo.toml`: -//! -//! ```toml -//! [dependencies.imgui-winit-support] -//! version = "0.6" -//! features = ["winit-$YOUR_VERSION_HERE"] -//! default-features = false -//! ``` -//! -//! ### Old `winit` compatibility -//! -//! No guarantee is made on how long this crate will support legacy versions of -//! `winit`, but we'll try to follow these rules: -//! -//! - Versions which are still in widespread use in the ecosystem will be -//! supported while that is true (for example, 0.19 at the time of writing is -//! quite old, but used by the most recent version of several popular crates). -//! -//! - Versions which are not a significant maintenance burden will be supported -//! (for example, supporting versions older than winit 0.19 given that we -//! support 0.19). -//! -//! - Explicitly removing support for a feature-indicated version will be -//! considered a breaking change. -//! -//! - Changing the default feature to the new latest `winit` version is *not* a -//! breaking change. - -#[cfg(feature = "winit-26")] -use winit_26 as winit; - -#[cfg(all(not(any(feature = "winit-26")), feature = "winit-25"))] -use winit_25 as winit; - -#[cfg(all( - not(any(feature = "winit-26", feature = "winit-25")), - feature = "winit-24" -))] -use winit_24 as winit; - -#[cfg(all( - not(any(feature = "winit-26", feature = "winit-25", feature = "winit-24")), - feature = "winit-23" -))] -use winit_23 as winit; - -#[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23" - )), - feature = "winit-22", -))] -use winit_22 as winit; - -#[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22" - )), - feature = "winit-20", -))] -use winit_20 as winit; - -#[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", -))] -use winit_19 as winit; use imgui::{self, BackendFlags, ConfigFlags, Context, Io, Key, Ui}; use std::cell::Cell; use std::cmp::Ordering; use winit::dpi::{LogicalPosition, LogicalSize}; -#[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", -))] -use winit::{ - DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, MouseCursor, MouseScrollDelta, - TouchPhase, VirtualKeyCode, Window, WindowEvent, -}; - -#[cfg(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" -))] use winit::{ error::ExternalError, event::{ @@ -251,83 +87,6 @@ use winit::{ window::{CursorIcon as MouseCursor, Window}, }; -// Ensure at least one is enabled -#[cfg(not(any( - feature = "winit-19", - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26", -)))] -compile_error!("Please enable at least one version of `winit` (see documentation for details)."); - -// FIXME(thom): make updading winit and adding a new feature less of a hassle here. -fn check_multiple_winits() { - use std::io::Write as _; - use std::sync::atomic::{AtomicBool, Ordering}; - // bail out for release builds or if we've been explicitly disabled. - if cfg!(any(not(debug_assertions), feature = "no-warn-on-multiple")) { - return; - } - let winits_enabled = cfg!(feature = "winit-26") as usize - + cfg!(feature = "winit-25") as usize - + cfg!(feature = "winit-24") as usize - + cfg!(feature = "winit-23") as usize - + cfg!(feature = "winit-22") as usize - + cfg!(feature = "winit-20") as usize - + cfg!(feature = "winit-19") as usize; - - // Only complain once even if we're called multiple times. - static COMPLAINED: AtomicBool = AtomicBool::new(false); - // Note that the `Ordering` basically doesn't matter here, but even if it - // did, `Relaxed` is still correct because we're only interested in the - // effects on a single atomic variable. - if winits_enabled <= 1 - || COMPLAINED - .compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed) - .is_err() - { - return; - } - let mut err = Vec::with_capacity(512); - - // Log the complaint into a buffer first — in practice this is enough to - // ensure atomicity. - let _ = writeln!( - err, - "Warning (imgui-winit-support): More than one `winit-*` version feature is enabled \ - (this likely indicates misconfiguration, see documentation for details)." - ); - let feats = [ - ("winit-26", cfg!(feature = "winit-26"), " (default)"), - ("winit-25", cfg!(feature = "winit-25"), ""), - ("winit-24", cfg!(feature = "winit-24"), ""), - ("winit-23", cfg!(feature = "winit-23"), ""), - ("winit-22", cfg!(feature = "winit-22"), ""), - ("winit-20", cfg!(feature = "winit-20"), ""), - ("winit-19", cfg!(feature = "winit-19"), ""), - ]; - for &(name, enabled, extra) in &feats { - if enabled { - let _ = writeln!(err, " `feature = {:?}` is enabled{}", name, extra); - } - } - if cfg!(feature = "winit-25") && winits_enabled == 2 { - let _ = writeln!( - err, - " Perhaps you are missing a `default-features = false`?", - ); - } - let _ = writeln!( - err, - " (Note: This warning is only present in debug builds, and \ - can be disabled using the \"no-warn-on-multiple\" feature)" - ); - let _ = std::io::stderr().write_all(&err); -} - /// State of a single mouse button. Used so that we can detect cases where mouse /// press and release occur on the same frame (seems surprisingly frequent on /// macOS now...) @@ -390,34 +149,6 @@ fn to_winit_cursor(cursor: imgui::MouseCursor) -> MouseCursor { } impl CursorSettings { - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - fn apply(&self, window: &Window) { - match self.cursor { - Some(mouse_cursor) if !self.draw_cursor => { - window.hide_cursor(false); - window.set_cursor(to_winit_cursor(mouse_cursor)); - } - _ => window.hide_cursor(true), - } - } - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - ))] fn apply(&self, window: &Window) { match self.cursor { Some(mouse_cursor) if !self.draw_cursor => { @@ -478,8 +209,6 @@ impl WinitPlatform { /// * keys are configured /// * platform name is set pub fn init(imgui: &mut Context) -> WinitPlatform { - // noop in non-debug builds, if disabled, or if called a second time. - check_multiple_winits(); let io = imgui.io_mut(); io.backend_flags.insert(BackendFlags::HAS_MOUSE_CURSORS); io.backend_flags.insert(BackendFlags::HAS_SET_MOUSE_POS); @@ -522,41 +251,6 @@ impl WinitPlatform { /// /// * framebuffer scale (= DPI factor) is set /// * display size is set - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn attach_window(&mut self, io: &mut Io, window: &Window, hidpi_mode: HiDpiMode) { - let (hidpi_mode, hidpi_factor) = hidpi_mode.apply(window.get_hidpi_factor()); - self.hidpi_mode = hidpi_mode; - self.hidpi_factor = hidpi_factor; - io.display_framebuffer_scale = [hidpi_factor as f32, hidpi_factor as f32]; - if let Some(logical_size) = window.get_inner_size() { - let logical_size = self.scale_size_from_winit(window, logical_size); - io.display_size = [logical_size.width as f32, logical_size.height as f32]; - } - } - /// Attaches the platform instance to a winit window. - /// - /// This function configures imgui-rs in the following ways: - /// - /// * framebuffer scale (= DPI factor) is set - /// * display size is set - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26", - ))] pub fn attach_window(&mut self, io: &mut Io, window: &Window, hidpi_mode: HiDpiMode) { let (hidpi_mode, hidpi_factor) = hidpi_mode.apply(window.scale_factor()); self.hidpi_mode = hidpi_mode; @@ -576,37 +270,6 @@ impl WinitPlatform { /// /// This utility function is useful if you are using a DPI mode other than default, and want /// your application to use the same logical coordinates as imgui-rs. - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn scale_size_from_winit(&self, window: &Window, logical_size: LogicalSize) -> LogicalSize { - match self.hidpi_mode { - ActiveHiDpiMode::Default => logical_size, - _ => logical_size - .to_physical(window.get_hidpi_factor()) - .to_logical(self.hidpi_factor), - } - } - /// Scales a logical size coming from winit using the current DPI mode. - /// - /// This utility function is useful if you are using a DPI mode other than default, and want - /// your application to use the same logical coordinates as imgui-rs. - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - ))] pub fn scale_size_from_winit( &self, window: &Window, @@ -623,41 +286,6 @@ impl WinitPlatform { /// /// This utility function is useful if you are using a DPI mode other than default, and want /// your application to use the same logical coordinates as imgui-rs. - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn scale_pos_from_winit( - &self, - window: &Window, - logical_pos: LogicalPosition, - ) -> LogicalPosition { - match self.hidpi_mode { - ActiveHiDpiMode::Default => logical_pos, - _ => logical_pos - .to_physical(window.get_hidpi_factor()) - .to_logical(self.hidpi_factor), - } - } - /// Scales a logical position coming from winit using the current DPI mode. - /// - /// This utility function is useful if you are using a DPI mode other than default, and want - /// your application to use the same logical coordinates as imgui-rs. - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - ))] pub fn scale_pos_from_winit( &self, window: &Window, @@ -674,41 +302,6 @@ impl WinitPlatform { /// /// This utility function is useful if you are using a DPI mode other than default, and want /// your application to use the same logical coordinates as imgui-rs. - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn scale_pos_for_winit( - &self, - window: &Window, - logical_pos: LogicalPosition, - ) -> LogicalPosition { - match self.hidpi_mode { - ActiveHiDpiMode::Default => logical_pos, - _ => logical_pos - .to_physical(self.hidpi_factor) - .to_logical(window.get_hidpi_factor()), - } - } - /// Scales a logical position for winit using the current DPI mode. - /// - /// This utility function is useful if you are using a DPI mode other than default, and want - /// your application to use the same logical coordinates as imgui-rs. - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - ))] pub fn scale_pos_for_winit( &self, window: &Window, @@ -728,116 +321,6 @@ impl WinitPlatform { /// * window size / dpi factor changes are applied /// * keyboard state is updated /// * mouse state is updated - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn handle_event(&mut self, io: &mut Io, window: &Window, event: &Event) { - match *event { - Event::WindowEvent { - window_id, - ref event, - } if window_id == window.id() => { - self.handle_window_event(io, window, event); - } - // Track key release events outside our window. If we don't do this, - // we might never see the release event if some other window gets focus. - Event::DeviceEvent { - event: - DeviceEvent::Key(KeyboardInput { - state: ElementState::Released, - virtual_keycode: Some(key), - .. - }), - .. - } => { - io.keys_down[key as usize] = false; - match key { - VirtualKeyCode::LShift | VirtualKeyCode::RShift => io.key_shift = false, - VirtualKeyCode::LControl | VirtualKeyCode::RControl => io.key_ctrl = false, - VirtualKeyCode::LAlt | VirtualKeyCode::RAlt => io.key_alt = false, - VirtualKeyCode::LWin | VirtualKeyCode::RWin => io.key_super = false, - _ => (), - } - } - _ => (), - } - } - /// Handles a winit event. - /// - /// This function performs the following actions (depends on the event): - /// - /// * window size / dpi factor changes are applied - /// * keyboard state is updated - /// * mouse state is updated - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22" - )), - feature = "winit-20", - ))] - pub fn handle_event(&mut self, io: &mut Io, window: &Window, event: &Event) { - match *event { - Event::WindowEvent { - window_id, - ref event, - } if window_id == window.id() => { - self.handle_window_event(io, window, event); - } - // Track key release events outside our window. If we don't do this, - // we might never see the release event if some other window gets focus. - Event::DeviceEvent { - event: - DeviceEvent::Key(KeyboardInput { - state: ElementState::Released, - virtual_keycode: Some(key), - .. - }), - .. - } => { - io.keys_down[key as usize] = false; - } - - // We need to track modifiers separately because some system like macOS, will - // not reliably send modifier states during certain events like ScreenCapture. - // Gotta let the people show off their pretty imgui widgets! - Event::DeviceEvent { - event: DeviceEvent::ModifiersChanged(modifiers), - .. - } => { - io.key_shift = modifiers.shift(); - io.key_ctrl = modifiers.ctrl(); - io.key_alt = modifiers.alt(); - io.key_super = modifiers.logo(); - } - _ => (), - } - } - /// Handles a winit event. - /// - /// This function performs the following actions (depends on the event): - /// - /// * window size / dpi factor changes are applied - /// * keyboard state is updated - /// * mouse state is updated - #[cfg(any( - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26", - ))] pub fn handle_event(&mut self, io: &mut Io, window: &Window, event: &Event) { match *event { Event::WindowEvent { @@ -872,235 +355,6 @@ impl WinitPlatform { _ => (), } } - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) { - match *event { - WindowEvent::Resized(logical_size) => { - let logical_size = self.scale_size_from_winit(window, logical_size); - io.display_size = [logical_size.width as f32, logical_size.height as f32]; - } - WindowEvent::HiDpiFactorChanged(scale) => { - let hidpi_factor = match self.hidpi_mode { - ActiveHiDpiMode::Default => scale, - ActiveHiDpiMode::Rounded => scale.round(), - _ => return, - }; - // Mouse position needs to be changed while we still have both the old and the new - // values - if io.mouse_pos[0].is_finite() && io.mouse_pos[1].is_finite() { - io.mouse_pos = [ - io.mouse_pos[0] * (hidpi_factor / self.hidpi_factor) as f32, - io.mouse_pos[1] * (hidpi_factor / self.hidpi_factor) as f32, - ]; - } - self.hidpi_factor = hidpi_factor; - io.display_framebuffer_scale = [hidpi_factor as f32, hidpi_factor as f32]; - // Window size might change too if we are using DPI rounding - if let Some(logical_size) = window.get_inner_size() { - let logical_size = self.scale_size_from_winit(window, logical_size); - io.display_size = [logical_size.width as f32, logical_size.height as f32]; - } - } - WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode: Some(key), - state, - .. - }, - .. - } => { - io.keys_down[key as usize] = state == ElementState::Pressed; - } - WindowEvent::ReceivedCharacter(ch) => { - // Exclude the backspace key ('\u{7f}'). Otherwise we will insert this char and then - // delete it. - if ch != '\u{7f}' { - io.add_input_character(ch) - } - } - WindowEvent::CursorMoved { position, .. } => { - let position = self.scale_pos_from_winit(window, position); - io.mouse_pos = [position.x as f32, position.y as f32]; - } - WindowEvent::MouseWheel { - delta, - phase: TouchPhase::Moved, - .. - } => match delta { - MouseScrollDelta::LineDelta(h, v) => { - io.mouse_wheel_h = h; - io.mouse_wheel = v; - } - MouseScrollDelta::PixelDelta(pos) => { - match pos.x.partial_cmp(&0.0) { - Some(Ordering::Greater) => io.mouse_wheel_h += 1.0, - Some(Ordering::Less) => io.mouse_wheel_h -= 1.0, - _ => (), - } - match pos.y.partial_cmp(&0.0) { - Some(Ordering::Greater) => io.mouse_wheel += 1.0, - Some(Ordering::Less) => io.mouse_wheel -= 1.0, - _ => (), - } - } - }, - WindowEvent::MouseInput { state, button, .. } => { - let pressed = state == ElementState::Pressed; - match button { - MouseButton::Left => self.mouse_buttons[0].set(pressed), - MouseButton::Right => self.mouse_buttons[1].set(pressed), - MouseButton::Middle => self.mouse_buttons[2].set(pressed), - MouseButton::Other(idx @ 0..=4) => { - self.mouse_buttons[idx as usize].set(pressed) - } - _ => (), - } - } - WindowEvent::Focused(newly_focused) => { - if !newly_focused { - // Set focus-lost to avoid stuck keys (like 'alt' - // when alt-tabbing) - io.app_focus_lost = true; - } - } - _ => (), - } - } - #[cfg(all( - not(any( - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - )), - any(feature = "winit-20", feature = "winit-22") - ))] - fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) { - match *event { - WindowEvent::Resized(physical_size) => { - let logical_size = physical_size.to_logical(window.scale_factor()); - let logical_size = self.scale_size_from_winit(window, logical_size); - io.display_size = [logical_size.width as f32, logical_size.height as f32]; - } - WindowEvent::ScaleFactorChanged { scale_factor, .. } => { - let hidpi_factor = match self.hidpi_mode { - ActiveHiDpiMode::Default => scale_factor, - ActiveHiDpiMode::Rounded => scale_factor.round(), - _ => return, - }; - // Mouse position needs to be changed while we still have both the old and the new - // values - if io.mouse_pos[0].is_finite() && io.mouse_pos[1].is_finite() { - io.mouse_pos = [ - io.mouse_pos[0] * (hidpi_factor / self.hidpi_factor) as f32, - io.mouse_pos[1] * (hidpi_factor / self.hidpi_factor) as f32, - ]; - } - self.hidpi_factor = hidpi_factor; - io.display_framebuffer_scale = [hidpi_factor as f32, hidpi_factor as f32]; - // Window size might change too if we are using DPI rounding - let logical_size = window.inner_size().to_logical(scale_factor); - let logical_size = self.scale_size_from_winit(window, logical_size); - io.display_size = [logical_size.width as f32, logical_size.height as f32]; - } - WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode: Some(key), - state, - .. - }, - .. - } => { - let pressed = state == ElementState::Pressed; - io.keys_down[key as usize] = pressed; - - // This is a bit redundant here, but we'll leave it in. The OS occasionally - // fails to send modifiers keys, but it doesn't seem to send false-positives, - // so double checking isn't terrible in case some system *doesn't* send - // device events sometimes. - match key { - VirtualKeyCode::LShift | VirtualKeyCode::RShift => io.key_shift = pressed, - VirtualKeyCode::LControl | VirtualKeyCode::RControl => io.key_ctrl = pressed, - VirtualKeyCode::LAlt | VirtualKeyCode::RAlt => io.key_alt = pressed, - VirtualKeyCode::LWin | VirtualKeyCode::RWin => io.key_super = pressed, - _ => (), - } - } - WindowEvent::ReceivedCharacter(ch) => { - // Exclude the backspace key ('\u{7f}'). Otherwise we will insert this char and then - // delete it. - if ch != '\u{7f}' { - io.add_input_character(ch) - } - } - WindowEvent::CursorMoved { position, .. } => { - let position = position.to_logical(window.scale_factor()); - let position = self.scale_pos_from_winit(window, position); - io.mouse_pos = [position.x as f32, position.y as f32]; - } - WindowEvent::MouseWheel { - delta, - phase: TouchPhase::Moved, - .. - } => match delta { - MouseScrollDelta::LineDelta(h, v) => { - io.mouse_wheel_h = h; - io.mouse_wheel = v; - } - MouseScrollDelta::PixelDelta(pos) => { - match pos.x.partial_cmp(&0.0) { - Some(Ordering::Greater) => io.mouse_wheel_h += 1.0, - Some(Ordering::Less) => io.mouse_wheel_h -= 1.0, - _ => (), - } - match pos.y.partial_cmp(&0.0) { - Some(Ordering::Greater) => io.mouse_wheel += 1.0, - Some(Ordering::Less) => io.mouse_wheel -= 1.0, - _ => (), - } - } - }, - WindowEvent::MouseInput { state, button, .. } => { - let pressed = state == ElementState::Pressed; - match button { - MouseButton::Left => self.mouse_buttons[0].set(pressed), - MouseButton::Right => self.mouse_buttons[1].set(pressed), - MouseButton::Middle => self.mouse_buttons[2].set(pressed), - MouseButton::Other(idx @ 0..=4) => { - self.mouse_buttons[idx as usize].set(pressed) - } - _ => (), - } - } - WindowEvent::Focused(newly_focused) => { - if !newly_focused { - // Set focus-lost to avoid stuck keys (like 'alt' - // when alt-tabbing) - io.app_focus_lost = true; - } - } - _ => (), - } - } - - #[cfg(any( - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26" - ))] fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) { match *event { WindowEvent::Resized(physical_size) => { @@ -1216,43 +470,6 @@ impl WinitPlatform { /// This function performs the following actions: /// /// * mouse cursor is repositioned (if requested by imgui-rs) - #[cfg(all( - not(any( - feature = "winit-26", - feature = "winit-25", - feature = "winit-24", - feature = "winit-23", - feature = "winit-22", - feature = "winit-20" - )), - feature = "winit-19", - ))] - pub fn prepare_frame(&self, io: &mut Io, window: &Window) -> Result<(), String> { - self.copy_mouse_to_io(&mut io.mouse_down); - if io.want_set_mouse_pos { - let logical_pos = self.scale_pos_for_winit( - window, - LogicalPosition::new(f64::from(io.mouse_pos[0]), f64::from(io.mouse_pos[1])), - ); - window.set_cursor_position(logical_pos) - } else { - Ok(()) - } - } - /// Frame preparation callback. - /// - /// Call this before calling the imgui-rs context `frame` function. - /// This function performs the following actions: - /// - /// * mouse cursor is repositioned (if requested by imgui-rs) - #[cfg(any( - feature = "winit-20", - feature = "winit-22", - feature = "winit-23", - feature = "winit-24", - feature = "winit-25", - feature = "winit-26", - ))] pub fn prepare_frame(&self, io: &mut Io, window: &Window) -> Result<(), ExternalError> { self.copy_mouse_to_io(&mut io.mouse_down); if io.want_set_mouse_pos { diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1445554..38beb16 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -32,30 +32,11 @@ fn try_main() -> Result<()> { } fn lint_all() -> Result<()> { - // Lint with only default, only docking, and only freetype + // Lint with only default, only docking, and only freetype, and everything xshell::cmd!("cargo clippy --workspace --all-targets").run()?; xshell::cmd!("cargo clippy --workspace --all-targets --features docking").run()?; xshell::cmd!("cargo clippy --workspace --all-targets --features freetype").run()?; - - // Lint winit with all features - xshell::cmd!( - "cargo clippy --manifest-path imgui-winit-support/Cargo.toml --all-features --all-targets" - ) - .run()?; - - // Lint with various winit versions - let winits = &[ - "winit-19", - "winit-20", - "winit-22", - "winit-23/default", - "winit-24/default", - "winit-25/default", - "winit-26/default", - ]; - for &winit in winits { - xshell::cmd!("cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features {winit} --all-targets").run()?; - } + xshell::cmd!("cargo clippy --workspace --all-targets --all-features").run()?; // Check formatting xshell::cmd!("cargo fmt --all -- --check").run()?; @@ -71,18 +52,6 @@ fn test_all() -> Result<()> { // Test doc examples xshell::cmd!("cargo test --workspace --doc").run()?; - // Test with various winit versions - let winits = &[ - "winit-19", - "winit-20", - "winit-22", - "winit-23/default", - "winit-24/default", - "winit-25/default", - ]; - for &winit in winits { - xshell::cmd!("cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features {winit} --all-targets").run()?; - } // Run heavy tests in release mode xshell::cmd!("cargo test -p imgui --release -- --ignored").run()?; Ok(()) From f58744e57949ade294d87fc9798502675a2fd4d5 Mon Sep 17 00:00:00 2001 From: dbr Date: Fri, 29 Apr 2022 11:19:34 +1000 Subject: [PATCH 24/57] Fix CI --all-features doesn't do as expected, just list all (two) features we want to test --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c141707..6a772f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,8 +67,8 @@ jobs: - name: freetype and docking run: cargo clippy --workspace --all-targets --features freetype,docking - - name: allf eatures - run: cargo clippy --workspace --all-targets --all-features + - name: all features + run: cargo clippy --workspace --all-targets --features docking,freetype test: name: Run tests @@ -142,7 +142,7 @@ jobs: - name: all features if: matrix.os != 'windows-latest' - run: cargo test --workspace --all-targets --all-features + run: cargo test --workspace --all-targets --features docking,freetype - name: doc tests run: cargo test --workspace --doc From 59c5538cd9740b267f7ddb90b621ad96967b3c7a Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 28 May 2022 18:27:43 +0930 Subject: [PATCH 25/57] glow: move vertex creation to same method as deletion Prevents leak if set_up_render_state is called without calling render Closes #643 --- imgui-glow-renderer/src/lib.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/imgui-glow-renderer/src/lib.rs b/imgui-glow-renderer/src/lib.rs index a6be20d..d1c2a79 100644 --- a/imgui-glow-renderer/src/lib.rs +++ b/imgui-glow-renderer/src/lib.rs @@ -3,6 +3,11 @@ //! This is heavily influenced by the //! [example from upstream](https://github.com/ocornut/imgui/blob/fe245914114588f272b0924538fdd43f6c127a26/backends/imgui_impl_opengl3.cpp). //! +//! It is important to note this renderer's API is not foolproof. It was designed +//! more for simplicity and control (allowing the user to manually have some control +//! over the GL state) than as a production-ready fully-general API. This control is +//! why so many things are `pub`. +//! //! # Basic usage //! //! A few code [examples] are provided in the source. @@ -276,6 +281,16 @@ impl Renderer { gl_debug_message(gl, "imgui-rs-glow: start render"); self.state_backup.pre_render(gl, self.gl_version); + #[cfg(feature = "bind_vertex_array_support")] + if self.gl_version.bind_vertex_array_support() { + unsafe { + self.vertex_array_object = gl + .create_vertex_array() + .map_err(|err| format!("Error creating vertex array object: {}", err))?; + gl.bind_vertex_array(Some(self.vertex_array_object)); + } + } + self.set_up_render_state(gl, draw_data, fb_width, fb_height)?; gl_debug_message(gl, "start loop over draw lists"); @@ -396,16 +411,6 @@ impl Renderer { unsafe { gl.bind_sampler(0, None) }; } - #[cfg(feature = "bind_vertex_array_support")] - if self.gl_version.bind_vertex_array_support() { - unsafe { - self.vertex_array_object = gl - .create_vertex_array() - .map_err(|err| format!("Error creating vertex array object: {}", err))?; - gl.bind_vertex_array(Some(self.vertex_array_object)); - } - } - // TODO: soon it should be possible for these to be `const` functions let position_field_offset = memoffset::offset_of!(DrawVert, pos) as _; let uv_field_offset = memoffset::offset_of!(DrawVert, uv) as _; From 1de842a402af309adb1332c2b452ba7857fdc5b1 Mon Sep 17 00:00:00 2001 From: dbr Date: Sun, 29 May 2022 11:24:58 +0930 Subject: [PATCH 26/57] Move note about robustness into Scope section --- imgui-glow-renderer/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/imgui-glow-renderer/src/lib.rs b/imgui-glow-renderer/src/lib.rs index d1c2a79..9ee3fd8 100644 --- a/imgui-glow-renderer/src/lib.rs +++ b/imgui-glow-renderer/src/lib.rs @@ -3,11 +3,6 @@ //! This is heavily influenced by the //! [example from upstream](https://github.com/ocornut/imgui/blob/fe245914114588f272b0924538fdd43f6c127a26/backends/imgui_impl_opengl3.cpp). //! -//! It is important to note this renderer's API is not foolproof. It was designed -//! more for simplicity and control (allowing the user to manually have some control -//! over the GL state) than as a production-ready fully-general API. This control is -//! why so many things are `pub`. -//! //! # Basic usage //! //! A few code [examples] are provided in the source. @@ -31,7 +26,10 @@ //! Consider this an example renderer. It is intended to be sufficent for simple //! applications running imgui-rs as the final rendering step. If your application //! has more specific needs, it's probably best to write your own renderer, in -//! which case this can be a useful starting point. +//! which case this can be a useful starting point. This renderer is also not +//! foolproof (largely due to the global nature of the OpenGL state). For example, +//! a few "internal" functions are marked `pub` to allow the user more +//! fine-grained control at the cost of allowing potential rendering errors. //! //! # sRGB //! From 1ec57fa1d97095677e35dee82bab7fde45fc90c8 Mon Sep 17 00:00:00 2001 From: Robert Keizer Date: Mon, 6 Jun 2022 20:42:25 -0500 Subject: [PATCH 27/57] Removing note in README about being under new management. --- README.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.markdown b/README.markdown index 0960ea1..8fbafec 100644 --- a/README.markdown +++ b/README.markdown @@ -5,8 +5,6 @@ [![Documentation on docs.rs](https://docs.rs/imgui/badge.svg)](https://docs.rs/imgui) [![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.84.2-blue.svg)](https://github.com/ocornut/imgui) -(Recently under new maintenance, things subject to change) - ![Hello world](hello_world.png) ```rust From 5fc64b7e68599144b8afa88ff7433cf99cf17d6f Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Wed, 10 Aug 2022 18:01:44 +0200 Subject: [PATCH 28/57] add TextFilter --- imgui-examples/examples/test_window_impl.rs | 20 ++++++ imgui/src/lib.rs | 1 + imgui/src/widget/mod.rs | 1 + imgui/src/widget/text_filter.rs | 76 +++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 imgui/src/widget/text_filter.rs diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index c89f068..69f0f45 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -53,6 +53,7 @@ struct State { stacked_modals_item: usize, stacked_modals_color: [f32; 4], app_log: Vec, + filter: imgui::TextFilter, tabs: TabState, } @@ -117,6 +118,7 @@ impl Default for State { stacked_modals_item: 0, stacked_modals_color: [0.4, 0.7, 0.0, 0.5], app_log: Vec::new(), + filter: TextFilter::new(String::from("Test")), tabs: TabState::default(), } } @@ -732,6 +734,24 @@ CTRL+click on individual component to input value.\n", } } + if CollapsingHeader::new("Filtering").build(ui) { + ui.text_wrapped( + "Filter usage:\n\ + \"\" display all lines\n\ + \"xxx\" display lines containing \"xxx\"\n\ + \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n\ + \"-xxx\" hide lines containing \"xxx\"" + ); + + state.filter.draw(); + let lines = vec!["aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world!"]; + for i in lines.iter() { + if state.filter.pass_filter(String::from(*i)) { + ui.bullet_text(i); + } + } + } + if CollapsingHeader::new("Popups & Modal windows").build(ui) { if let Some(_t) = ui.tree_node("Popups") { ui.text_wrapped( diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index cadb3a2..19cdaea 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -45,6 +45,7 @@ pub use self::widget::progress_bar::*; pub use self::widget::selectable::*; pub use self::widget::slider::*; pub use self::widget::tab::*; +pub use self::widget::text_filter::*; pub use self::widget::tree::*; pub use self::window::child_window::*; pub use self::window::*; diff --git a/imgui/src/widget/mod.rs b/imgui/src/widget/mod.rs index 9ca7887..72a923d 100644 --- a/imgui/src/widget/mod.rs +++ b/imgui/src/widget/mod.rs @@ -10,4 +10,5 @@ pub mod selectable; pub mod slider; pub mod tab; pub mod text; +pub mod text_filter; pub mod tree; diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs new file mode 100644 index 0000000..b123c20 --- /dev/null +++ b/imgui/src/widget/text_filter.rs @@ -0,0 +1,76 @@ +use crate::sys; +use crate::Ui; +use std::ptr; + +pub struct TextFilter { + id: String, + size: f32, + raw: *mut sys::ImGuiTextFilter, +} + +impl TextFilter { + pub fn new(id: String) -> Self { + Self::new_with_filter(id, String::new()) + } + + pub fn new_with_filter(id: String, mut filter: String) -> Self { + filter.push('\0'); + let ptr = filter.as_mut_ptr(); + Self { + id, + size: 0.0, + raw: unsafe { sys::ImGuiTextFilter_ImGuiTextFilter(ptr as *mut sys::cty::c_char) }, + } + } + + pub fn set_size(&mut self, size: f32) { + self.size = size; + } + + pub fn build(&mut self) { + unsafe { + sys::ImGuiTextFilter_Build(self.raw); + } + } + + pub fn draw(&self) { + self.draw_size(0.0); + } + + pub fn draw_size(&self, size: f32) { + unsafe { + let mut id = self.id.clone(); + id.push('\0'); + let ptr = id.as_mut_ptr(); + sys::ImGuiTextFilter_Draw(self.raw, ptr as *mut sys::cty::c_char, size); + } + } + + pub fn is_active(&self) -> bool { + unsafe { sys::ImGuiTextFilter_IsActive(self.raw) } + } + + pub fn pass_filter(&self, mut buf: String) -> bool { + buf.push('\0'); + let ptr = buf.as_mut_ptr(); + unsafe { + sys::ImGuiTextFilter_PassFilter(self.raw, ptr as *mut sys::cty::c_char, ptr::null()) + } + } + + pub fn pass_filter_end(_buf: String, _end: String) -> bool { + true + } + + pub fn clear(&mut self) { + unsafe { + sys::ImGuiTextFilter_Clear(self.raw); + } + } +} + +impl Ui { + pub fn text_filter(label: String) -> TextFilter { + TextFilter::new(label) + } +} From 3d7b56a331f9dc81eb05facd6a97f0fec2845580 Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Wed, 10 Aug 2022 19:40:53 +0200 Subject: [PATCH 29/57] add pass_filter_end --- imgui/src/widget/text_filter.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index b123c20..c6be59a 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -58,8 +58,18 @@ impl TextFilter { } } - pub fn pass_filter_end(_buf: String, _end: String) -> bool { - true + pub fn pass_filter_end(&self, mut start: String, mut end: String) -> bool { + start.push('\0'); + end.push('\0'); + let b_ptr = start.as_mut_ptr(); + let e_ptr = end.as_mut_ptr(); + unsafe { + sys::ImGuiTextFilter_PassFilter( + self.raw, + b_ptr as *mut sys::cty::c_char, + e_ptr as *mut sys::cty::c_char, + ) + } } pub fn clear(&mut self) { From b02c1eb7b2f2823033594c04ad458aac5ac5f599 Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Wed, 10 Aug 2022 19:51:52 +0200 Subject: [PATCH 30/57] add doc --- imgui/src/widget/text_filter.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index c6be59a..b17f004 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -1,3 +1,4 @@ +//! Helper to parse and apply text filters use crate::sys; use crate::Ui; use std::ptr; @@ -9,15 +10,19 @@ pub struct TextFilter { } impl TextFilter { - pub fn new(id: String) -> Self { - Self::new_with_filter(id, String::new()) + /// Creates a new TextFilter with a empty filter. + /// + /// This is equivalent of [new_with_filter](Self::new_with_filter) with `filter` set to `""`. + pub fn new(label: String) -> Self { + Self::new_with_filter(label, String::new()) } - pub fn new_with_filter(id: String, mut filter: String) -> Self { + /// Creates a new TextFilter with a custom filter. + pub fn new_with_filter(label: String, mut filter: String) -> Self { filter.push('\0'); let ptr = filter.as_mut_ptr(); Self { - id, + id: label, size: 0.0, raw: unsafe { sys::ImGuiTextFilter_ImGuiTextFilter(ptr as *mut sys::cty::c_char) }, } @@ -27,12 +32,13 @@ impl TextFilter { self.size = size; } - pub fn build(&mut self) { + pub fn build(&self) { unsafe { sys::ImGuiTextFilter_Build(self.raw); } } + /// Draws the TextFilter. pub fn draw(&self) { self.draw_size(0.0); } @@ -50,6 +56,7 @@ impl TextFilter { unsafe { sys::ImGuiTextFilter_IsActive(self.raw) } } + /// Returns true if the text matches the filter. pub fn pass_filter(&self, mut buf: String) -> bool { buf.push('\0'); let ptr = buf.as_mut_ptr(); @@ -72,7 +79,7 @@ impl TextFilter { } } - pub fn clear(&mut self) { + pub fn clear(&self) { unsafe { sys::ImGuiTextFilter_Clear(self.raw); } From 5450ee613609543bd61001e14a1f9d7da39fa961 Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Thu, 11 Aug 2022 10:12:34 +0200 Subject: [PATCH 31/57] add doc and example, remove useless function --- imgui-examples/examples/test_window_impl.rs | 6 +++++ imgui/src/widget/text_filter.rs | 29 ++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 69f0f45..92f723c 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -745,6 +745,12 @@ CTRL+click on individual component to input value.\n", state.filter.draw(); let lines = vec!["aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world!"]; + + ui.same_line(); + if ui.button("Clear##clear_filter") { + state.filter.clear(); + } + for i in lines.iter() { if state.filter.pass_filter(String::from(*i)) { ui.bullet_text(i); diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index b17f004..95d583b 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -5,12 +5,11 @@ use std::ptr; pub struct TextFilter { id: String, - size: f32, raw: *mut sys::ImGuiTextFilter, } impl TextFilter { - /// Creates a new TextFilter with a empty filter. + /// Creates a new TextFilter with an empty filter. /// /// This is equivalent of [new_with_filter](Self::new_with_filter) with `filter` set to `""`. pub fn new(label: String) -> Self { @@ -23,27 +22,31 @@ impl TextFilter { let ptr = filter.as_mut_ptr(); Self { id: label, - size: 0.0, raw: unsafe { sys::ImGuiTextFilter_ImGuiTextFilter(ptr as *mut sys::cty::c_char) }, } } - pub fn set_size(&mut self, size: f32) { - self.size = size; - } - + /// Builds the TextFilter with its filter attribute. You can use + /// `[pass_filter()](Self::pass_filter)` after it. + /// + /// If you want control the filter with an InputText, check `[draw()](Self::draw)`. pub fn build(&self) { unsafe { sys::ImGuiTextFilter_Build(self.raw); } } - /// Draws the TextFilter. + /// Draws an [InputText](crate::input_widget::InputText) to control the filter of the TextFilter. + /// + /// This is equivalent of [draw_with_size](Self::draw_with_size) with `size` set to `0.0`. pub fn draw(&self) { - self.draw_size(0.0); + self.draw_with_size(0.0); } - pub fn draw_size(&self, size: f32) { + /// Draws an [InputText](crate::input_widget::InputText) to control the filter of the TextFilter. + /// + /// The InputText has the size passed in parameters. + pub fn draw_with_size(&self, size: f32) { unsafe { let mut id = self.id.clone(); id.push('\0'); @@ -52,11 +55,12 @@ impl TextFilter { } } + /// Returns true if the filter is not empty (`""`). pub fn is_active(&self) -> bool { unsafe { sys::ImGuiTextFilter_IsActive(self.raw) } } - /// Returns true if the text matches the filter. + /// Returns true if the buffer matches the filter. pub fn pass_filter(&self, mut buf: String) -> bool { buf.push('\0'); let ptr = buf.as_mut_ptr(); @@ -65,7 +69,7 @@ impl TextFilter { } } - pub fn pass_filter_end(&self, mut start: String, mut end: String) -> bool { + pub fn pass_filter_with_end(&self, mut start: String, mut end: String) -> bool { start.push('\0'); end.push('\0'); let b_ptr = start.as_mut_ptr(); @@ -79,6 +83,7 @@ impl TextFilter { } } + /// Clears the filter. pub fn clear(&self) { unsafe { sys::ImGuiTextFilter_Clear(self.raw); From 2d8ae7c9d0f230bcbd8ca812ed1c11d2815d512e Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Thu, 11 Aug 2022 10:24:58 +0200 Subject: [PATCH 32/57] add new function in ui for textfilter and doc --- imgui/src/widget/text_filter.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index 95d583b..eeac137 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -1,8 +1,8 @@ -//! Helper to parse and apply text filters use crate::sys; use crate::Ui; use std::ptr; +/// Helper to parse and apply text filters pub struct TextFilter { id: String, raw: *mut sys::ImGuiTextFilter, @@ -27,9 +27,9 @@ impl TextFilter { } /// Builds the TextFilter with its filter attribute. You can use - /// `[pass_filter()](Self::pass_filter)` after it. + /// [`pass_filter()`](Self::pass_filter) after it. /// - /// If you want control the filter with an InputText, check `[draw()](Self::draw)`. + /// If you want control the filter with an InputText, check [`draw()`](Self::draw). pub fn build(&self) { unsafe { sys::ImGuiTextFilter_Build(self.raw); @@ -61,6 +61,8 @@ impl TextFilter { } /// Returns true if the buffer matches the filter. + /// + /// [`draw()`](Self::draw) or [`build()`](Self::build) mut be called **before** this function. pub fn pass_filter(&self, mut buf: String) -> bool { buf.push('\0'); let ptr = buf.as_mut_ptr(); @@ -95,4 +97,8 @@ impl Ui { pub fn text_filter(label: String) -> TextFilter { TextFilter::new(label) } + + pub fn text_filter_with_filter(label: String, filter: String) -> TextFilter { + TextFilter::new_with_filter(label, filter) + } } From 5f5450487f706bb2aa33d39292459ec20654f85f Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Fri, 12 Aug 2022 17:32:11 +0200 Subject: [PATCH 33/57] use &str instead of String --- imgui-examples/examples/test_window_impl.rs | 2 +- imgui/src/widget/text_filter.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 92f723c..dd13a71 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -752,7 +752,7 @@ CTRL+click on individual component to input value.\n", } for i in lines.iter() { - if state.filter.pass_filter(String::from(*i)) { + if state.filter.pass_filter(i) { ui.bullet_text(i); } } diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index eeac137..b64ebf9 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -63,7 +63,8 @@ impl TextFilter { /// Returns true if the buffer matches the filter. /// /// [`draw()`](Self::draw) or [`build()`](Self::build) mut be called **before** this function. - pub fn pass_filter(&self, mut buf: String) -> bool { + pub fn pass_filter(&self, buf: &str) -> bool { + let mut buf = String::from(buf); buf.push('\0'); let ptr = buf.as_mut_ptr(); unsafe { @@ -71,7 +72,8 @@ impl TextFilter { } } - pub fn pass_filter_with_end(&self, mut start: String, mut end: String) -> bool { + pub fn pass_filter_with_end(&self, start: &str, end: &str) -> bool { + let (mut start, mut end) = (String::from(start), String::from(end)); start.push('\0'); end.push('\0'); let b_ptr = start.as_mut_ptr(); From c004b3a619ffaa24dae21fb77f714f58aa53b279 Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Fri, 12 Aug 2022 17:34:02 +0200 Subject: [PATCH 34/57] move text_filter file --- imgui/src/lib.rs | 3 ++- imgui/src/{widget => }/text_filter.rs | 3 ++- imgui/src/widget/mod.rs | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) rename imgui/src/{widget => }/text_filter.rs (96%) diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index 19cdaea..02b858d 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -33,6 +33,7 @@ pub use self::style::*; #[cfg(feature = "tables-api")] pub use self::tables::*; +pub use self::text_filter::*; pub use self::utils::*; pub use self::widget::color_editors::*; pub use self::widget::combo_box::*; @@ -45,7 +46,6 @@ pub use self::widget::progress_bar::*; pub use self::widget::selectable::*; pub use self::widget::slider::*; pub use self::widget::tab::*; -pub use self::widget::text_filter::*; pub use self::widget::tree::*; pub use self::window::child_window::*; pub use self::window::*; @@ -82,6 +82,7 @@ mod style; mod tables; #[cfg(test)] mod test; +pub mod text_filter; mod utils; mod widget; mod window; diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/text_filter.rs similarity index 96% rename from imgui/src/widget/text_filter.rs rename to imgui/src/text_filter.rs index b64ebf9..eaf86b8 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/text_filter.rs @@ -17,7 +17,8 @@ impl TextFilter { } /// Creates a new TextFilter with a custom filter. - pub fn new_with_filter(label: String, mut filter: String) -> Self { + pub fn new_with_filter(label: String, filter: String) -> Self { + let mut filter = filter.clone(); filter.push('\0'); let ptr = filter.as_mut_ptr(); Self { diff --git a/imgui/src/widget/mod.rs b/imgui/src/widget/mod.rs index 72a923d..9ca7887 100644 --- a/imgui/src/widget/mod.rs +++ b/imgui/src/widget/mod.rs @@ -10,5 +10,4 @@ pub mod selectable; pub mod slider; pub mod tab; pub mod text; -pub mod text_filter; pub mod tree; From 5fa0f275645f72bfaa22e48a65e78ec67b9c2d0d Mon Sep 17 00:00:00 2001 From: Denis Barkar Date: Wed, 17 Aug 2022 17:37:07 +0300 Subject: [PATCH 35/57] Support winit v0.27.2 --- imgui-examples/Cargo.toml | 2 +- imgui-glium-renderer/Cargo.toml | 2 +- imgui-glium-renderer/src/lib.rs | 3 +++ imgui-glow-renderer/Cargo.toml | 2 +- imgui-winit-support/Cargo.toml | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/imgui-examples/Cargo.toml b/imgui-examples/Cargo.toml index 0f2fba6..989ce25 100644 --- a/imgui-examples/Cargo.toml +++ b/imgui-examples/Cargo.toml @@ -11,7 +11,7 @@ publish = false [dev-dependencies] clipboard = "0.5" -glium = { version = "0.31", default-features = true } +glium = { version = "0.32.1", default-features = true } image = "0.23" imgui = { path = "../imgui", features = ["tables-api"] } imgui-glium-renderer = { path = "../imgui-glium-renderer" } diff --git a/imgui-glium-renderer/Cargo.toml b/imgui-glium-renderer/Cargo.toml index 574b93a..4998f84 100644 --- a/imgui-glium-renderer/Cargo.toml +++ b/imgui-glium-renderer/Cargo.toml @@ -10,5 +10,5 @@ license = "MIT/Apache-2.0" categories = ["gui", "rendering"] [dependencies] -glium = { version = "0.31", default-features = false } +glium = { version = "0.32.1", default-features = false } imgui = { version = "0.8.1-alpha.0", path = "../imgui" } diff --git a/imgui-glium-renderer/src/lib.rs b/imgui-glium-renderer/src/lib.rs index eddc659..8cddd55 100644 --- a/imgui-glium-renderer/src/lib.rs +++ b/imgui-glium-renderer/src/lib.rs @@ -117,18 +117,21 @@ impl glium::vertex::Vertex for GliumDrawVert { ( Borrowed("pos"), 0, + -1, glium::vertex::AttributeType::F32F32, false, ), ( Borrowed("uv"), 8, + -1, glium::vertex::AttributeType::F32F32, false, ), ( Borrowed("col"), 16, + -1, glium::vertex::AttributeType::U8U8U8U8, false, ), diff --git a/imgui-glow-renderer/Cargo.toml b/imgui-glow-renderer/Cargo.toml index a0df2bd..8078f04 100644 --- a/imgui-glow-renderer/Cargo.toml +++ b/imgui-glow-renderer/Cargo.toml @@ -15,7 +15,7 @@ glow = "0.10.0" memoffset = "0.6.4" [dev-dependencies] -glutin = "0.28.0" +glutin = "0.29.1" imgui-winit-support = { version = "0.8.1-alpha.0", path = "../imgui-winit-support" } image = "0.23" diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index 8acbcca..db9b10b 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -11,4 +11,4 @@ categories = ["gui"] [dependencies] imgui = { version = "0.8.1-alpha.0", path = "../imgui" } -winit = { version = "0.26.0", default-features = false } +winit = { version = "0.27.2", default-features = false } From 4ad2b7f3bdc7eadd2fadae34526ca77b99a51f9b Mon Sep 17 00:00:00 2001 From: dbr Date: Thu, 18 Aug 2022 15:19:10 +0930 Subject: [PATCH 36/57] Update MSRV to 1.56 The winit->x11-dl 2.22.0 dependency now requires the 2021 edition which forces us to at least Rust 1.56 (at least on Linux) --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.markdown | 2 +- README.markdown | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a772f0..590f863 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - rust: ["1.54"] + rust: ["1.56"] env: RUSTFLAGS: -D warnings @@ -82,7 +82,7 @@ jobs: rust: - stable - beta - - "1.54" + - "1.56" os: - ubuntu-latest - macos-latest diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index c6784be..4cd05f9 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,7 +2,7 @@ ## Unreleased -- MSRV is now **1.54**. We soft-updated to this in 0.8.0 with a feature `min-const-generics`, which has now been removed (and as such, we resume having no default features). +- MSRV is now **1.56**. We soft-updated to this to Rust 1.54 in the v0.8.0 release (with a feature `min-const-generics`), which has now been removed (and as such, we resume having no default features). Rust 1.56 is required for some indirect dependencies which now use the Rust 2021 edition - Upgraded from Dear ImGui 1.84.2 to 1.86. See [the 1.85](https://github.com/ocornut/imgui/releases/tag/v1.85) and [the 1.86](https://github.com/ocornut/imgui/releases/tag/v1.86) release notes diff --git a/README.markdown b/README.markdown index 0960ea1..6727769 100644 --- a/README.markdown +++ b/README.markdown @@ -51,7 +51,7 @@ Additionally, the following are no longer maintained, but might work still: ## Minimum Support Rust Version (MSRV) -The MSRV for `imgui-rs` and all of the backend crates is **1.54**. We update our MSRV periodically, and issue a minor bump for it. +The MSRV for `imgui-rs` and all of the backend crates is **1.56**. We update our MSRV periodically, and issue a minor bump for it. ## Choosing a backend platform and a renderer From 6fa1fb6991c9069cfba0dd15ed908c48d985d4aa Mon Sep 17 00:00:00 2001 From: "Wang, Lin" Date: Wed, 24 Aug 2022 13:42:14 -0400 Subject: [PATCH 37/57] leave tree_node label None if not set This allows users to hide tree_node label. This change also added an example of making a tree_node as a button. --- imgui-examples/examples/test_window_impl.rs | 17 ++++++++++++++++- imgui/src/widget/tree.rs | 21 ++++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index c89f068..2ff4d34 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -389,7 +389,8 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { } if CollapsingHeader::new("Widgets").build(ui) { if let Some(_t) = ui.tree_node("Tree") { - for i in 0..5 { + let num_child = 4; + for i in 0..num_child { if let Some(_t) = ui.tree_node(format!("Child {}", i)) { ui.text("blah blah"); ui.same_line(); @@ -398,6 +399,20 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) { } } } + + { + let tree_node_stack = ui.tree_node_config("##HideTreeNodeLabel") + .allow_item_overlap(true) + .push(); + ui.same_line(); + if ui.small_button(format!("Child {} is a button", num_child)) { + println!("TreeNode Button pressed."); + } + + if tree_node_stack.is_some() { + ui.text("blah blah") + } + } } if let Some(_t) = ui.tree_node("Bullets") { diff --git a/imgui/src/widget/tree.rs b/imgui/src/widget/tree.rs index 5a707c8..118c93f 100644 --- a/imgui/src/widget/tree.rs +++ b/imgui/src/widget/tree.rs @@ -287,17 +287,16 @@ impl<'a, T: AsRef, L: AsRef> TreeNode<'a, T, L> { sys::igSetNextItemOpen(self.opened, self.opened_cond as i32); } match self.id { - TreeNodeId::Str(id) => { - let (id, label) = match self.label { - Some(label) => self.ui.scratch_txt_two(id, label), - None => { - let v = self.ui.scratch_txt(id); - (v, v) - } - }; - - sys::igTreeNodeExStrStr(id, self.flags.bits() as i32, fmt_ptr(), label) - } + TreeNodeId::Str(id) => match self.label { + Some(label) => { + let (id, label) = self.ui.scratch_txt_two(id, label); + sys::igTreeNodeExStrStr(id, self.flags.bits() as i32, fmt_ptr(), label) + } + None => { + let id = self.ui.scratch_txt(id); + sys::igTreeNodeExStr(id, self.flags.bits() as i32) + } + }, TreeNodeId::Ptr(id) => sys::igTreeNodeExPtr( id, self.flags.bits() as i32, From cddf42ada722fc64c2b86ffb16042a3a4a29d50d Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Mon, 29 Aug 2022 23:30:04 -0400 Subject: [PATCH 38/57] fix doc --- imgui/src/stacks.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/imgui/src/stacks.rs b/imgui/src/stacks.rs index a256c59..81a0bb1 100644 --- a/imgui/src/stacks.rs +++ b/imgui/src/stacks.rs @@ -179,7 +179,8 @@ unsafe fn push_style_var(style_var: StyleVar) { impl Ui { /// Changes the item width by pushing a change to the item width stack. /// - /// Returns an `ItemWidthStackToken` that may be popped by calling `.pop()` + /// Returns an `ItemWidthStackToken`. The pushed width item is popped when either + /// `ItemWidthStackToken` goes out of scope, or `.end()` is called. /// /// - `> 0.0`: width is `item_width` pixels /// - `= 0.0`: default to ~2/3 of window width @@ -208,13 +209,14 @@ impl Ui { unsafe { sys::igCalcItemWidth() } } - /// Changes the text wrapping position to the end of window (or column), which - /// is generally the default. + /// Makes the text wrap at the end of window/column (which is generally the default), by + /// pushing a change to the text wrapping position stack. /// /// This is the same as calling [push_text_wrap_pos_with_pos](Self::push_text_wrap_pos_with_pos) /// with `wrap_pos_x` set to 0.0. /// - /// Returns a `TextWrapPosStackToken` that may be popped by calling `.pop()` + /// Returns a `TextWrapPosStackToken`. The pushed position item is popped when either + /// `TextWrapPosStackToken` goes out of scope, or `.end()` is called. #[doc(alias = "PushTextWrapPos")] pub fn push_text_wrap_pos(&self) -> TextWrapPosStackToken<'_> { self.push_text_wrap_pos_with_pos(0.0) @@ -222,7 +224,8 @@ impl Ui { /// Changes the text wrapping position by pushing a change to the text wrapping position stack. /// - /// Returns a `TextWrapPosStackToken` that may be popped by calling `.pop()` + /// Returns a `TextWrapPosStackToken`. The pushed position item is popped when either + /// `TextWrapPosStackToken` goes out of scope, or `.end()` is called. /// /// - `> 0.0`: wrap at `wrap_pos_x` position in window local space /// - `= 0.0`: wrap to end of window (or column) From 5d14676362335b0ab41bfcc2868eb2692f97eb68 Mon Sep 17 00:00:00 2001 From: dbr Date: Mon, 26 Sep 2022 19:35:05 +0930 Subject: [PATCH 39/57] Bump MSRV to 1.57 Needed by ~glutin --- .github/workflows/ci.yml | 2 +- CHANGELOG.markdown | 2 +- README.markdown | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 590f863..0ac82f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - rust: ["1.56"] + rust: ["1.57"] env: RUSTFLAGS: -D warnings diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 4cd05f9..ecb47c5 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,7 +2,7 @@ ## Unreleased -- MSRV is now **1.56**. We soft-updated to this to Rust 1.54 in the v0.8.0 release (with a feature `min-const-generics`), which has now been removed (and as such, we resume having no default features). Rust 1.56 is required for some indirect dependencies which now use the Rust 2021 edition +- MSRV is now **1.57**. We soft-updated to this to Rust 1.54 in the v0.8.0 release (with a feature `min-const-generics`), which has now been removed (and as such, we resume having no default features). Rust 1.56 is required for the Rust 2021 edition, and 1.57 is required by some dependencies - Upgraded from Dear ImGui 1.84.2 to 1.86. See [the 1.85](https://github.com/ocornut/imgui/releases/tag/v1.85) and [the 1.86](https://github.com/ocornut/imgui/releases/tag/v1.86) release notes diff --git a/README.markdown b/README.markdown index 12bfe01..cceea5d 100644 --- a/README.markdown +++ b/README.markdown @@ -49,7 +49,7 @@ Additionally, the following are no longer maintained, but might work still: ## Minimum Support Rust Version (MSRV) -The MSRV for `imgui-rs` and all of the backend crates is **1.56**. We update our MSRV periodically, and issue a minor bump for it. +The MSRV for `imgui-rs` and all of the backend crates is **1.57**. We update our MSRV periodically, and issue a minor bump for it. ## Choosing a backend platform and a renderer From 45c2d28ced1673d96a1d235af9cba71701060398 Mon Sep 17 00:00:00 2001 From: dbr Date: Mon, 26 Sep 2022 21:33:10 +0930 Subject: [PATCH 40/57] Missed one 1.56 -> 1.57 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ac82f6..90c5d16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,7 @@ jobs: rust: - stable - beta - - "1.56" + - "1.57" os: - ubuntu-latest - macos-latest From 8479f3e5cf9feba0ec8231fd5468e37b722b34e0 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 5 Oct 2022 12:54:13 +1030 Subject: [PATCH 41/57] Proposed branching/release process Closes #665 --- docs/development-process.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/development-process.md diff --git a/docs/development-process.md b/docs/development-process.md new file mode 100644 index 0000000..c368627 --- /dev/null +++ b/docs/development-process.md @@ -0,0 +1,32 @@ +# imgui-rs development process + +As summarised in [issue #665](https://github.com/imgui-rs/imgui-rs/issues/665) + +In summary: + +1. There is a `main` branch +2. For each semver compatible release there is a stable branch (e.g `0.9-stable`) +3. Each patch release becomes a tagged commit on this stable branch (e.g `v0.9.5` would come from a tagged commit on the `0.9-stable` branch) + +## General process + +Day to day development + +1. Work on `main` branch +2. General PR's are submitted against the `main` branch + +When it is time to make a new release, we create a `x.y-stable` branch (e.g `0.9-stable`) from `main` + +1. Ensure `CHANGELOG` is up to date +1. Bump `version` in the various `Cargo.toml` +2. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github + +All further PR's are still done to `main` + +1. If they are applicable to previous release (e.g bugfixes or non-breaking changes), they are cherry-picked back to the applicable `stable` branch(es) + +## When to bump versions in Cargo.toml + +Only before publishing to crates.io. + +This makes users able use [patch.crates-io] without hand-editing versions throughout their dependency tree (typically impossible without forking/editing transitive dependencies, even if there are no breaking code changes otherwise). From c017353eceee4c73535661c3591e6ff4ecaf997f Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 5 Jan 2022 14:35:02 +1100 Subject: [PATCH 42/57] Include imgui/misc/freetype/ in crate package Required for "--features freetype" to work when using via crates.io Closes #594 Closes #589 --- imgui-sys/Cargo.toml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 1a7605f..7c8549d 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -10,8 +10,20 @@ license = "MIT/Apache-2.0" categories = ["gui", "external-ffi-bindings"] build = "build.rs" links = "imgui" -# exclude .json, .lua from imgui dirs - they are intermediate artifacts from cimgui generator -exclude = ["third-party/imgui-*/*.json", "third-party/imgui-*/*.lua"] + +# exclude json, lua, and the imgui subdirs (imgui/examples, imgui/docs, etc) +# ..but we need imgui/misc/freetype/ for the freetype feature +exclude = [ + "third-party/*.json", + "third-party/*.lua", + "third-party/imgui/backends/", + "third-party/imgui/docs/", + "third-party/imgui/examples/", + "third-party/imgui/misc/cpp/", + "third-party/imgui/misc/debuggers/", + "third-party/imgui/misc/fonts/", + "third-party/imgui/misc/single_file/", +] [dependencies] chlorine = "1.0.7" From fa3404fbb5be1c67ab91c3daab48615691be6e15 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 5 Oct 2022 14:52:09 +1030 Subject: [PATCH 43/57] Remove redundant clone in new TextFilter --- imgui/src/text_filter.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imgui/src/text_filter.rs b/imgui/src/text_filter.rs index eaf86b8..b64ebf9 100644 --- a/imgui/src/text_filter.rs +++ b/imgui/src/text_filter.rs @@ -17,8 +17,7 @@ impl TextFilter { } /// Creates a new TextFilter with a custom filter. - pub fn new_with_filter(label: String, filter: String) -> Self { - let mut filter = filter.clone(); + pub fn new_with_filter(label: String, mut filter: String) -> Self { filter.push('\0'); let ptr = filter.as_mut_ptr(); Self { From 18acb91dee37ffc04ddf739c2f34afaedf39643b Mon Sep 17 00:00:00 2001 From: dbr/Ben Date: Sat, 8 Oct 2022 12:18:58 +1030 Subject: [PATCH 44/57] Fix quoting on patch snippet Co-authored-by: Marijn Suijten --- docs/development-process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development-process.md b/docs/development-process.md index c368627..543a388 100644 --- a/docs/development-process.md +++ b/docs/development-process.md @@ -29,4 +29,4 @@ All further PR's are still done to `main` Only before publishing to crates.io. -This makes users able use [patch.crates-io] without hand-editing versions throughout their dependency tree (typically impossible without forking/editing transitive dependencies, even if there are no breaking code changes otherwise). +This makes users able use `[patch.crates-io]` without hand-editing versions throughout their dependency tree (typically impossible without forking/editing transitive dependencies, even if there are no breaking code changes otherwise). From b377181c54f6d074f40afaf47858a8e9846e6dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Miliz=C3=A9?= Date: Thu, 27 Oct 2022 10:03:36 +0200 Subject: [PATCH 45/57] re-export winit and glow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lena Milizé --- imgui-glow-renderer/src/lib.rs | 3 +++ imgui-winit-support/src/lib.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/imgui-glow-renderer/src/lib.rs b/imgui-glow-renderer/src/lib.rs index 9ee3fd8..1f3f3cb 100644 --- a/imgui-glow-renderer/src/lib.rs +++ b/imgui-glow-renderer/src/lib.rs @@ -50,6 +50,9 @@ use std::{borrow::Cow, error::Error, fmt::Display, mem::size_of}; use imgui::{internal::RawWrapper, DrawCmd, DrawData, DrawVert}; use crate::versions::{GlVersion, GlslVersion}; + +// Re-export glow to make it easier for users to use the correct version. +pub use glow; use glow::{Context, HasContext}; pub mod versions; diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index a8b012d..a907fb9 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -76,6 +76,9 @@ use imgui::{self, BackendFlags, ConfigFlags, Context, Io, Key, Ui}; use std::cell::Cell; use std::cmp::Ordering; + +// Re-export winit to make it easier for users to use the correct version. +pub use winit; use winit::dpi::{LogicalPosition, LogicalSize}; use winit::{ From 477e1abd0b561ddd7363c4980893793717fd87f7 Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 22 Nov 2022 16:33:15 +1030 Subject: [PATCH 46/57] Update release process doc Create tags and push them, create release, close tickets --- docs/development-process.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/development-process.md b/docs/development-process.md index 543a388..a546567 100644 --- a/docs/development-process.md +++ b/docs/development-process.md @@ -18,8 +18,11 @@ Day to day development When it is time to make a new release, we create a `x.y-stable` branch (e.g `0.9-stable`) from `main` 1. Ensure `CHANGELOG` is up to date -1. Bump `version` in the various `Cargo.toml` -2. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github +2. Bump `version` in the various `Cargo.toml` +3. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github +4. Create annotated tag `v0.9.0` and push to github +5. Create Release for this version on Github +6. Update and close any relevant tickets All further PR's are still done to `main` From a7c479c906c070bf8b6eb72f682528a41a37730a Mon Sep 17 00:00:00 2001 From: dbr Date: Tue, 22 Nov 2022 17:15:34 +1030 Subject: [PATCH 47/57] Update changelog --- CHANGELOG.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index ecb47c5..663af96 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -6,6 +6,10 @@ - Upgraded from Dear ImGui 1.84.2 to 1.86. See [the 1.85](https://github.com/ocornut/imgui/releases/tag/v1.85) and [the 1.86](https://github.com/ocornut/imgui/releases/tag/v1.86) release notes +- Upgraded winit version to `v0.27` for `imgu-winit-support` + +- The `imgui-winit-support` and `imgui-glow-renderer` re-export `winit` and `glow` respectively to make setup easier for simple projects. [PR #676](https://github.com/imgui-rs/imgui-rs/pull/676) + - BREAKING: Removed `push_style_colors` and `push_style_vars`. Instead, use `push_style_color` in a loop. This was deprecated in `0.7.0` and should have been removed in `0.8.0`. This also removes their associated tokens. - BREAKING: Ui now does not have a lifetime associated with it, but is only ever given to users in the form of `&mut Ui`. Additionally, the `render` function has been moved to the `Context` instead of `Ui`. @@ -36,6 +40,10 @@ - Fixed dpi related issues when not in `HiDpiMode::Default` mode. The wrong scale factor was used when converting winit physical size to logical size, causing the imgui display size to be incorrect. +- Fixed creation of `.crate` (published to crates.io) so required files for freetype feature are included + +- Added binding to TextFilter API. [PR #658](https://github.com/imgui-rs/imgui-rs/pull/658) + ## [0.8.0] - 2021-09-17 Welcome to the `0.8.0` update. This is one of the largest updates imgui-rs has ever seen; it will generate errors in a `0.7` project, but hopefully it should be both quick to fix, and enjoyable to update. See our [release page](https://github.com/imgui-rs/imgui-rs/releases/tag/v0.8.0) for more information and a list of contributors to this cycle. Thank you to everyone who uses `imgui-rs`, files issues, and spend their time and effort to PR new changes into the codebase. Because of all that effort, this is by far the best `imgui-rs` has looked! From 7cc7bf97b30f722966a78758de27ec10c781d4d8 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 00:14:10 +1030 Subject: [PATCH 48/57] Minor hackery to keep CI happy Pin back scoped-tls used indirectly in imgui-examples only Will revert hackery and bump MSRV once v0.9 is released --- imgui-examples/Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imgui-examples/Cargo.toml b/imgui-examples/Cargo.toml index 989ce25..72415eb 100644 --- a/imgui-examples/Cargo.toml +++ b/imgui-examples/Cargo.toml @@ -16,3 +16,11 @@ image = "0.23" imgui = { path = "../imgui", features = ["tables-api"] } imgui-glium-renderer = { path = "../imgui-glium-renderer" } imgui-winit-support = { path = "../imgui-winit-support" } + +# Pin indirect dependency scoped-tls to 1.0.0 +# as 1.0.1 bumped MSRV to 1.59 +# Used only in +# imgui-examples -> glium -> glutin -> wayland-client -> scoped-tls +# so not worth bumping MSRV for this basically to keep CI happy +# FIXME: Remove this for imgui-rs v0.10 and bump MSRV +scoped-tls = "=1.0.0" From 54f4bef7db7783780a32e4efa367bfe401474595 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 00:19:12 +1030 Subject: [PATCH 49/57] Remove ye ol' deprecated im_str! marco Closes #576 --- imgui/src/string.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/imgui/src/string.rs b/imgui/src/string.rs index af6557b..fdd0858 100644 --- a/imgui/src/string.rs +++ b/imgui/src/string.rs @@ -74,36 +74,6 @@ impl UiBuffer { } } -#[macro_export] -#[deprecated = "all functions take AsRef now -- use inline strings or `format` instead"] -macro_rules! im_str { - ($e:literal $(,)?) => {{ - const __INPUT: &str = concat!($e, "\0"); - { - // Trigger a compile error if there's an interior NUL character. - const _CHECK_NUL: [(); 0] = [(); { - let bytes = __INPUT.as_bytes(); - let mut i = 0; - let mut found_nul = 0; - while i < bytes.len() - 1 && found_nul == 0 { - if bytes[i] == 0 { - found_nul = 1; - } - i += 1; - } - found_nul - }]; - const RESULT: &'static $crate::ImStr = unsafe { - $crate::__core::mem::transmute::<&'static [u8], &'static $crate::ImStr>(__INPUT.as_bytes()) - }; - RESULT - } - }}; - ($e:literal, $($arg:tt)+) => ({ - $crate::ImString::new(format!($e, $($arg)*)) - }); -} - /// A UTF-8 encoded, growable, implicitly nul-terminated string. #[derive(Clone, Hash, Ord, Eq, PartialOrd, PartialEq)] pub struct ImString(pub(crate) Vec); From 59ce49c15727193942a8ebc865a486f878bac865 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 09:56:41 +1030 Subject: [PATCH 50/57] Update headings in changelog --- CHANGELOG.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 663af96..6ba0909 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,6 +1,8 @@ # Change Log -## Unreleased +## [unreleased] + +## [0.9.0] - 2022-11-30 - MSRV is now **1.57**. We soft-updated to this to Rust 1.54 in the v0.8.0 release (with a feature `min-const-generics`), which has now been removed (and as such, we resume having no default features). Rust 1.56 is required for the Rust 2021 edition, and 1.57 is required by some dependencies @@ -779,7 +781,8 @@ As mentioned, the 0.6.1 release of `imgui-winit-support` has been yanked. - Initial release with cimgui/imgui 1.44, glium 0.9 -[unreleased]: https://github.com/Gekkio/imgui-rs/compare/v0.8.0...HEAD +[unreleased]: https://github.com/Gekkio/imgui-rs/compare/v0.9.0...HEAD +[0.9.0]: https://github.com/Gekkio/imgui-rs/compare/v0.8.0...v0.9.0 [0.8.0]: https://github.com/Gekkio/imgui-rs/compare/v0.7.0...v0.8.0 [0.7.0]: https://github.com/Gekkio/imgui-rs/compare/v0.6.1...v0.7.0 [0.6.1]: https://github.com/Gekkio/imgui-rs/compare/v0.6.0...v0.6.1 From b8ddd078c1c8366e5b38334e00239b23b42c318e Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 09:57:12 +1030 Subject: [PATCH 51/57] Update unobvious dear-imgui version in README --- README.markdown | 2 +- docs/development-process.md | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index cceea5d..9108b36 100644 --- a/README.markdown +++ b/README.markdown @@ -3,7 +3,7 @@ [![Build Status](https://github.com/imgui-rs/imgui-rs/workflows/ci/badge.svg)](https://github.com/imgui-rs/imgui-rs/actions) [![Latest release on crates.io](https://img.shields.io/crates/v/imgui.svg)](https://crates.io/crates/imgui) [![Documentation on docs.rs](https://docs.rs/imgui/badge.svg)](https://docs.rs/imgui) -[![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.84.2-blue.svg)](https://github.com/ocornut/imgui) +[![Wrapped Dear ImGui Version](https://img.shields.io/badge/Dear%20ImGui%20Version-1.86.0-blue.svg)](https://github.com/ocornut/imgui) ![Hello world](hello_world.png) diff --git a/docs/development-process.md b/docs/development-process.md index a546567..724e8c7 100644 --- a/docs/development-process.md +++ b/docs/development-process.md @@ -18,11 +18,12 @@ Day to day development When it is time to make a new release, we create a `x.y-stable` branch (e.g `0.9-stable`) from `main` 1. Ensure `CHANGELOG` is up to date -2. Bump `version` in the various `Cargo.toml` -3. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github -4. Create annotated tag `v0.9.0` and push to github -5. Create Release for this version on Github -6. Update and close any relevant tickets +2. Ensure README is up-to-date (including the Dear ImGui Version in badge URL, MSRV) +3. Bump `version` in the various `Cargo.toml` +4. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github +5. Create annotated tag `v0.9.0` and push to github +6. Create Release for this version on Github +7. Update and close any relevant tickets All further PR's are still done to `main` From 2eb3f8c3378321123a533da800b7272294af1daf Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 10:10:19 +1030 Subject: [PATCH 52/57] Bump to 0.9.0! --- imgui-glium-renderer/Cargo.toml | 4 ++-- imgui-glow-renderer/Cargo.toml | 6 +++--- imgui-sdl2-support/Cargo.toml | 6 +++--- imgui-sys/Cargo.toml | 2 +- imgui-winit-support/Cargo.toml | 4 ++-- imgui/Cargo.toml | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/imgui-glium-renderer/Cargo.toml b/imgui-glium-renderer/Cargo.toml index 4998f84..accc810 100644 --- a/imgui-glium-renderer/Cargo.toml +++ b/imgui-glium-renderer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui-glium-renderer" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["The imgui-rs Developers"] description = "Glium renderer for the imgui crate" @@ -11,4 +11,4 @@ categories = ["gui", "rendering"] [dependencies] glium = { version = "0.32.1", default-features = false } -imgui = { version = "0.8.1-alpha.0", path = "../imgui" } +imgui = { version = "0.9.0", path = "../imgui" } diff --git a/imgui-glow-renderer/Cargo.toml b/imgui-glow-renderer/Cargo.toml index 8078f04..2ec7bd1 100644 --- a/imgui-glow-renderer/Cargo.toml +++ b/imgui-glow-renderer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui-glow-renderer" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["jmaargh and the imgui-rs Developers"] description = "glow renderer for the imgui crate" @@ -10,13 +10,13 @@ license = "MIT/Apache-2.0" categories = ["gui", "rendering"] [dependencies] -imgui = { version = "0.8.1-alpha.0", path = "../imgui" } +imgui = { version = "0.9.0", path = "../imgui" } glow = "0.10.0" memoffset = "0.6.4" [dev-dependencies] glutin = "0.29.1" -imgui-winit-support = { version = "0.8.1-alpha.0", path = "../imgui-winit-support" } +imgui-winit-support = { version = "0.9.0", path = "../imgui-winit-support" } image = "0.23" [features] diff --git a/imgui-sdl2-support/Cargo.toml b/imgui-sdl2-support/Cargo.toml index dfbc76a..1c97a20 100644 --- a/imgui-sdl2-support/Cargo.toml +++ b/imgui-sdl2-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui-sdl2-support" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["The imgui-rs Developers"] description = "sdl2 support code for the imgui crate" @@ -10,10 +10,10 @@ license = "MIT/Apache-2.0" categories = ["gui"] [dependencies] -imgui = { version = "0.8.1-alpha.0", path = "../imgui" } +imgui = { version = "0.9.0", path = "../imgui" } sdl2 = "0.34.5" [dev-dependencies] glow = "0.10.0" -imgui-glow-renderer = { version = "0.8.1-alpha.0", path = "../imgui-glow-renderer" } +imgui-glow-renderer = { version = "0.9.0", path = "../imgui-glow-renderer" } sdl2 = { version = "0.34.5", features = ["bundled", "static-link"] } diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 7c8549d..9dd1101 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui-sys" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["The imgui-rs Developers"] description = "Raw FFI bindings to dear imgui" diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index db9b10b..7675adc 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui-winit-support" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["The imgui-rs Developers"] description = "winit support code for the imgui crate" @@ -10,5 +10,5 @@ license = "MIT/Apache-2.0" categories = ["gui"] [dependencies] -imgui = { version = "0.8.1-alpha.0", path = "../imgui" } +imgui = { version = "0.9.0", path = "../imgui" } winit = { version = "0.27.2", default-features = false } diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index 3815145..2a52414 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imgui" -version = "0.8.1-alpha.0" +version = "0.9.0" edition = "2018" authors = ["The imgui-rs Developers"] description = "High-level Rust bindings to dear imgui" @@ -17,7 +17,7 @@ features = ["freetype", "docking", "tables-api"] [dependencies] bitflags = "1" -imgui-sys = { version = "0.8.1-alpha.0", path = "../imgui-sys" } +imgui-sys = { version = "0.9.0", path = "../imgui-sys" } mint = "0.5.6" parking_lot = "0.12" cfg-if = "1" From 9776ebef9083244539a3fd8a72314b612f14ecdd Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 10:15:38 +1030 Subject: [PATCH 53/57] Remove authors key from Cargo.toml The field is now optional (as of Rust 1.53) and no longer used by crates.io (as per Rust RFC 3052) --- imgui-examples/Cargo.toml | 1 - imgui-glium-renderer/Cargo.toml | 1 - imgui-glow-renderer/Cargo.toml | 1 - imgui-sys/Cargo.toml | 1 - imgui-winit-support/Cargo.toml | 1 - imgui/Cargo.toml | 1 - xtask/Cargo.toml | 1 - 7 files changed, 7 deletions(-) diff --git a/imgui-examples/Cargo.toml b/imgui-examples/Cargo.toml index 72415eb..9b83f0f 100644 --- a/imgui-examples/Cargo.toml +++ b/imgui-examples/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui-examples" version = "0.0.0" edition = "2018" -authors = ["The imgui-rs Developers"] description = "imgui crate examples using Glium backend" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/imgui-glium-renderer/Cargo.toml b/imgui-glium-renderer/Cargo.toml index accc810..d1333a8 100644 --- a/imgui-glium-renderer/Cargo.toml +++ b/imgui-glium-renderer/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui-glium-renderer" version = "0.9.0" edition = "2018" -authors = ["The imgui-rs Developers"] description = "Glium renderer for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/imgui-glow-renderer/Cargo.toml b/imgui-glow-renderer/Cargo.toml index 2ec7bd1..297ecad 100644 --- a/imgui-glow-renderer/Cargo.toml +++ b/imgui-glow-renderer/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui-glow-renderer" version = "0.9.0" edition = "2018" -authors = ["jmaargh and the imgui-rs Developers"] description = "glow renderer for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 9dd1101..36603c6 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui-sys" version = "0.9.0" edition = "2018" -authors = ["The imgui-rs Developers"] description = "Raw FFI bindings to dear imgui" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index 7675adc..c262845 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui-winit-support" version = "0.9.0" edition = "2018" -authors = ["The imgui-rs Developers"] description = "winit support code for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index 2a52414..bed2485 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -2,7 +2,6 @@ name = "imgui" version = "0.9.0" edition = "2018" -authors = ["The imgui-rs Developers"] description = "High-level Rust bindings to dear imgui" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 355e524..df9a5c7 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -2,7 +2,6 @@ [package] name = "xtask" version = "0.1.0" -authors = ["Thom Chiovoloni "] edition = "2018" publish = false From e47f29b20ac1eb0513ccea81b37776e6a39f2b8d Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 10:20:34 +1030 Subject: [PATCH 54/57] Release process docs: important release crates step --- docs/development-process.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/development-process.md b/docs/development-process.md index 724e8c7..3677469 100644 --- a/docs/development-process.md +++ b/docs/development-process.md @@ -21,9 +21,10 @@ When it is time to make a new release, we create a `x.y-stable` branch (e.g `0.9 2. Ensure README is up-to-date (including the Dear ImGui Version in badge URL, MSRV) 3. Bump `version` in the various `Cargo.toml` 4. A stable branch is created, e.g `git switch -c 0.9-stable` and pushed to Github -5. Create annotated tag `v0.9.0` and push to github -6. Create Release for this version on Github -7. Update and close any relevant tickets +5. Publish various crates (noting it has to be done starting with `imgui-sys`, then `imgui`, then the others) +6. Create annotated tag `v0.9.0` and push to github +7. Create Release for this version on Github +8. Update and close any relevant tickets All further PR's are still done to `main` From 5f079428c840217c7287595ee4249e1cf52cc50d Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 10:28:29 +1030 Subject: [PATCH 55/57] Move imgui-gfx-renderer away from main library crates section As of v0.9 "might work still" becomes unlikely --- README.markdown | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 9108b36..0ba81ac 100644 --- a/README.markdown +++ b/README.markdown @@ -32,11 +32,6 @@ ui.window("Hello world") - imgui-glium-renderer: Renderer implementation that uses the `glium` crate - imgui-sys: Low-level unsafe API (automatically generated) -Additionally, the following are no longer maintained, but might work still: - -- imgui-gfx-renderer: Renderer implementation that uses the `gfx` crate (_not - the new gfx-hal crate_). This can be found at [imgui-rs/imgui-gfx-renderer](https://github.com/imgui-rs/imgui-gfx-renderer) - ## Features - Bindings for Dear ImGui that can be used with safe Rust. Note: API coverage @@ -88,6 +83,8 @@ Additionally, there are other libraries which provide other kinds of renderers, 1. [`imgui-wgpu`](https://github.com/Yatekii/imgui-wgpu-rs) 2. [`imgui-d3d12-renderer`](https://github.com/curldivergence/imgui-d3d12-renderer) 3. [`imgui-dx11-renderer`](https://github.com/veykril/imgui-dx11-renderer) + 4. [`imgui-gfx-renderer`](https://github.com/imgui-rs/imgui-gfx-renderer): Deprecated (no longer maintained beyond imgui-rs v0.8). Renderer implementation that uses the `gfx` crate (_not the new gfx-hal crate_) + You can also write your own support code if you have a more advanced use case, because **imgui-rs is not tied to any specific graphics / OS API**. From 6d6cda275cbe9330fca9352f46b234f6d8616702 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 30 Nov 2022 10:31:02 +1030 Subject: [PATCH 56/57] Add docs links to Cargo.toml So docs link shows up nicely on crates.io --- imgui-glium-renderer/Cargo.toml | 1 + imgui-sdl2-support/Cargo.toml | 1 + imgui-sys/Cargo.toml | 1 + imgui-winit-support/Cargo.toml | 1 + imgui/Cargo.toml | 1 + 5 files changed, 5 insertions(+) diff --git a/imgui-glium-renderer/Cargo.toml b/imgui-glium-renderer/Cargo.toml index d1333a8..6338966 100644 --- a/imgui-glium-renderer/Cargo.toml +++ b/imgui-glium-renderer/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "Glium renderer for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" +documentation = "https://docs.rs/imgui-glium-renderer" license = "MIT/Apache-2.0" categories = ["gui", "rendering"] diff --git a/imgui-sdl2-support/Cargo.toml b/imgui-sdl2-support/Cargo.toml index 1c97a20..c760612 100644 --- a/imgui-sdl2-support/Cargo.toml +++ b/imgui-sdl2-support/Cargo.toml @@ -6,6 +6,7 @@ authors = ["The imgui-rs Developers"] description = "sdl2 support code for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" +documentation = "https://docs.rs/imgui-sdl2-support" license = "MIT/Apache-2.0" categories = ["gui"] diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 36603c6..6923859 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "Raw FFI bindings to dear imgui" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" +documentation = "https://docs.rs/imgui-sys" license = "MIT/Apache-2.0" categories = ["gui", "external-ffi-bindings"] build = "build.rs" diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index c262845..641565e 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "winit support code for the imgui crate" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" +documentation = "https://docs.rs/imgui-winit-support" license = "MIT/Apache-2.0" categories = ["gui"] diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index bed2485..7bbe1a3 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "High-level Rust bindings to dear imgui" homepage = "https://github.com/imgui-rs/imgui-rs" repository = "https://github.com/imgui-rs/imgui-rs" +documentation = "https://docs.rs/imgui" license = "MIT/Apache-2.0" categories = ["gui", "api-bindings"] readme = "../README.markdown" From b1e66d050e84dbb2120001d16ce59d15ef6b5303 Mon Sep 17 00:00:00 2001 From: dbr Date: Fri, 2 Dec 2022 13:42:47 +1030 Subject: [PATCH 57/57] Update changelog --- CHANGELOG.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 6ba0909..6f1464c 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,6 +1,9 @@ # Change Log ## [unreleased] +- Removed `im_str!` macro - deprecated since v0.8. + + `ui.button(im_str!("Example"))` just becomes `ui.button("Example")` and `ui.button(&im_str!("My age is {}", 100))` becomes `ui.button!(format!("My age is {}", 100))` ## [0.9.0] - 2022-11-30