diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index 5072ee9..27f3275 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -117,12 +117,17 @@ fn main() { fn show_user_guide<'a>(ui: &Ui<'a>) { ui.bullet_text(im_str!("Double-click on title bar to collapse window.")); - ui.bullet_text(im_str!("Click and drag on lower right corner to resize window.")); + ui.bullet_text(im_str!( + "Click and drag on lower right corner to resize window." + )); ui.bullet_text(im_str!("Click and drag on any empty space to move window.")); ui.bullet_text(im_str!("Mouse Wheel to scroll.")); - ui.bullet_text(im_str!("TAB/SHIFT+TAB to cycle through keyboard editable fields.")); + ui.bullet_text(im_str!( + "TAB/SHIFT+TAB to cycle through keyboard editable fields." + )); ui.bullet_text(im_str!("CTRL+Click on a slider or drag box to input text.")); - ui.bullet_text(im_str!("While editing text: + ui.bullet_text(im_str!( + "While editing text: - Hold SHIFT or use mouse to select text - \ CTRL+Left/Right to word jump @@ -134,7 +139,8 @@ fn show_user_guide<'a>(ui: &Ui<'a>) { to revert - You can apply arithmetic operators +,*,/ on numerical \ values. - Use +- to subtract.")); + Use +- to subtract." + )); } fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { @@ -145,9 +151,11 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { show_example_app_main_menu_bar(ui, state) } if state.show_app_auto_resize { - show_example_app_auto_resize(ui, - &mut state.auto_resize_state, - &mut state.show_app_auto_resize); + show_example_app_auto_resize( + ui, + &mut state.auto_resize_state, + &mut state.show_app_auto_resize, + ); } if state.show_app_fixed_overlay { show_example_app_fixed_overlay(ui, &mut state.show_app_fixed_overlay); @@ -163,8 +171,10 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { ui.text(im_str!("ImGui {}", imgui::get_version())); ui.separator(); ui.text(im_str!("By Omar Cornut and all github contributors.")); - ui.text(im_str!("ImGui is licensed under the MIT License, see LICENSE for more \ - information.")); + ui.text(im_str!( + "ImGui is licensed under the MIT License, see LICENSE for more \ + information." + )); }) } @@ -182,50 +192,51 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { .build(|| { ui.text(im_str!("ImGui says hello.")); ui.menu_bar(|| { - ui.menu(im_str!("Menu")) - .build(|| { show_example_menu_file(ui, &mut state.file_menu); }); - ui.menu(im_str!("Examples")) - .build(|| { - ui.menu_item(im_str!("Main menu bar")) - .selected(&mut state.show_app_main_menu_bar) - .build(); - ui.menu_item(im_str!("Console")) - .selected(&mut state.show_app_console) - .build(); - ui.menu_item(im_str!("Simple layout")) - .selected(&mut state.show_app_layout) - .build(); - ui.menu_item(im_str!("Long text display")) - .selected(&mut state.show_app_long_text) - .build(); - ui.menu_item(im_str!("Auto-resizing window")) - .selected(&mut state.show_app_auto_resize) - .build(); - ui.menu_item(im_str!("Simple overlay")) - .selected(&mut state.show_app_fixed_overlay) - .build(); - ui.menu_item(im_str!("Manipulating window title")) - .selected(&mut state.show_app_manipulating_window_title) - .build(); - ui.menu_item(im_str!("Custom rendering")) - .selected(&mut state.show_app_custom_rendering) - .build(); - }); - ui.menu(im_str!("Help")) - .build(|| { - ui.menu_item(im_str!("Metrics")) - .selected(&mut state.show_app_metrics) - .build(); - ui.menu_item(im_str!("About ImGui")) - .selected(&mut state.show_app_about) - .build(); - }); + ui.menu(im_str!("Menu")).build(|| { + show_example_menu_file(ui, &mut state.file_menu); + }); + ui.menu(im_str!("Examples")).build(|| { + ui.menu_item(im_str!("Main menu bar")) + .selected(&mut state.show_app_main_menu_bar) + .build(); + ui.menu_item(im_str!("Console")) + .selected(&mut state.show_app_console) + .build(); + ui.menu_item(im_str!("Simple layout")) + .selected(&mut state.show_app_layout) + .build(); + ui.menu_item(im_str!("Long text display")) + .selected(&mut state.show_app_long_text) + .build(); + ui.menu_item(im_str!("Auto-resizing window")) + .selected(&mut state.show_app_auto_resize) + .build(); + ui.menu_item(im_str!("Simple overlay")) + .selected(&mut state.show_app_fixed_overlay) + .build(); + ui.menu_item(im_str!("Manipulating window title")) + .selected(&mut state.show_app_manipulating_window_title) + .build(); + ui.menu_item(im_str!("Custom rendering")) + .selected(&mut state.show_app_custom_rendering) + .build(); + }); + ui.menu(im_str!("Help")).build(|| { + ui.menu_item(im_str!("Metrics")) + .selected(&mut state.show_app_metrics) + .build(); + ui.menu_item(im_str!("About ImGui")) + .selected(&mut state.show_app_about) + .build(); + }); }); ui.spacing(); if ui.collapsing_header(im_str!("Help")).build() { - ui.text_wrapped(im_str!("This window is being created by the show_test_window() \ + ui.text_wrapped(im_str!( + "This window is being created by the show_test_window() \ function. Please refer to the code for programming \ - reference.\n\nUser Guide:")); + reference.\n\nUser Guide:" + )); show_user_guide(ui); } @@ -244,55 +255,53 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { ui.slider_float(im_str!("bg alpha"), &mut state.bg_alpha, 0.0, 1.0) .build(); - ui.tree_node(im_str!("Style")) - .build(|| { - // TODO: Reimplement style editor - ui.show_default_style_editor(); - }); + ui.tree_node(im_str!("Style")).build(|| { + // TODO: Reimplement style editor + ui.show_default_style_editor(); + }); ui.tree_node(im_str!("Fonts")) .label(im_str!("Fonts ({})", "TODO")) .build(|| { - ui.text_wrapped(im_str!("Tip: Load fonts with \ - io.Fonts->AddFontFromFileTTF().")); - ui.tree_node(im_str!("Atlas texture")) - .build(|| { - // TODO - }); - }); + ui.text_wrapped(im_str!( + "Tip: Load fonts with \ + io.Fonts->AddFontFromFileTTF()." + )); + ui.tree_node(im_str!("Atlas texture")).build(|| { + // TODO + }); + }); } if ui.collapsing_header(im_str!("Widgets")).build() { - ui.tree_node(im_str!("Tree")) - .build(|| for i in 0..5 { - ui.tree_node(im_str!("Child {}", i)) - .build(|| { - ui.text(im_str!("blah blah")); - ui.same_line(0.0); - if ui.small_button(im_str!("print")) { - println!("Child {} pressed", i); - } - }); - }); - ui.tree_node(im_str!("Bullets")) - .build(|| { - ui.bullet_text(im_str!("Bullet point 1")); - ui.bullet_text(im_str!("Bullet point 2\nOn multiple lines")); - ui.bullet(); - ui.text(im_str!("Bullet point 3 (two calls)")); - - ui.bullet(); - ui.small_button(im_str!("Button")); + ui.tree_node(im_str!("Tree")).build(|| for i in 0..5 { + ui.tree_node(im_str!("Child {}", i)).build(|| { + ui.text(im_str!("blah blah")); + ui.same_line(0.0); + if ui.small_button(im_str!("print")) { + println!("Child {} pressed", i); + } }); - ui.tree_node(im_str!("Colored text")) - .build(|| { - ui.text_colored((1.0, 0.0, 1.0, 1.0), im_str!("Pink")); - ui.text_colored((1.0, 1.0, 0.0, 1.0), im_str!("Yellow")); - ui.text_disabled(im_str!("Disabled")); - }); + }); + ui.tree_node(im_str!("Bullets")).build(|| { + ui.bullet_text(im_str!("Bullet point 1")); + ui.bullet_text(im_str!("Bullet point 2\nOn multiple lines")); + ui.bullet(); + ui.text(im_str!("Bullet point 3 (two calls)")); + + ui.bullet(); + ui.small_button(im_str!("Button")); + }); + ui.tree_node(im_str!("Colored text")).build(|| { + ui.text_colored((1.0, 0.0, 1.0, 1.0), im_str!("Pink")); + ui.text_colored((1.0, 1.0, 0.0, 1.0), im_str!("Yellow")); + ui.text_disabled(im_str!("Disabled")); + }); ui.tree_node(im_str!("Word Wrapping")).build(|| { - ui.text_wrapped(im_str!("This text should automatically wrap on the edge of \ + ui.text_wrapped(im_str!( + "This text should automatically wrap on the edge of \ the window.The current implementation for text \ wrapping follows simple rulessuitable for English \ - and possibly other languages.")); + and possibly other languages." + )); ui.spacing(); ui.slider_float(im_str!("Wrap width"), &mut state.wrap_width, -20.0, 600.0) @@ -305,18 +314,19 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { ui.text(im_str!("Test paragraph 2:")); // TODO }); - ui.tree_node(im_str!("UTF-8 Text")) - .build(|| { - ui.text_wrapped(im_str!("CJK text will only appear if the font was loaded \ + ui.tree_node(im_str!("UTF-8 Text")).build(|| { + ui.text_wrapped(im_str!( + "CJK text will only appear if the font was loaded \ with theappropriate CJK character ranges. Call \ io.Font->LoadFromFileTTF()manually to load extra \ - character ranges.")); + character ranges." + )); - ui.text(im_str!("Hiragana: かきくけこ (kakikukeko)")); - ui.text(im_str!("Kanjis: 日本語 (nihongo)")); - ui.input_text(im_str!("UTF-8 input"), &mut state.buf) - .build(); - }); + ui.text(im_str!("Hiragana: かきくけこ (kakikukeko)")); + ui.text(im_str!("Kanjis: 日本語 (nihongo)")); + ui.input_text(im_str!("UTF-8 input"), &mut state.buf) + .build(); + }); ui.radio_button(im_str!("radio a"), &mut state.radio_button, 0); ui.same_line(0.0); @@ -326,25 +336,31 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { ui.separator(); ui.label_text(im_str!("label"), im_str!("Value")); - ui.combo(im_str!("combo"), - &mut state.item, - &[im_str!("aaaa"), - im_str!("bbbb"), - im_str!("cccc"), - im_str!("dddd"), - im_str!("eeee")], - -1); - let items = [im_str!("AAAA"), - im_str!("BBBB"), - im_str!("CCCC"), - im_str!("DDDD"), - im_str!("EEEE"), - im_str!("FFFF"), - im_str!("GGGG"), - im_str!("HHHH"), - im_str!("IIII"), - im_str!("JJJJ"), - im_str!("KKKK")]; + ui.combo( + im_str!("combo"), + &mut state.item, + &[ + im_str!("aaaa"), + im_str!("bbbb"), + im_str!("cccc"), + im_str!("dddd"), + im_str!("eeee"), + ], + -1, + ); + let items = [ + im_str!("AAAA"), + im_str!("BBBB"), + im_str!("CCCC"), + im_str!("DDDD"), + im_str!("EEEE"), + im_str!("FFFF"), + im_str!("GGGG"), + im_str!("HHHH"), + im_str!("IIII"), + im_str!("JJJJ"), + im_str!("KKKK"), + ]; ui.combo(im_str!("combo scroll"), &mut state.item2, &items, -1); ui.input_text(im_str!("input text"), &mut state.text) .build(); @@ -356,127 +372,126 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { ui.input_float3(im_str!("input float3"), &mut state.vec3f) .build(); - ui.tree_node(im_str!("Multi-component Widgets")) - .build(|| { - ui.input_float2(im_str!("input float2"), &mut state.vec2f) - .build(); - ui.input_int2(im_str!("input int2"), &mut state.vec2i) - .build(); - ui.spacing(); + ui.tree_node(im_str!("Multi-component Widgets")).build(|| { + ui.input_float2(im_str!("input float2"), &mut state.vec2f) + .build(); + ui.input_int2(im_str!("input int2"), &mut state.vec2i) + .build(); + ui.spacing(); - ui.input_float3(im_str!("input float3"), &mut state.vec3f) - .build(); - ui.input_int3(im_str!("input int3"), &mut state.vec3i) - .build(); - ui.spacing(); - }); + ui.input_float3(im_str!("input float3"), &mut state.vec3f) + .build(); + ui.input_int3(im_str!("input int3"), &mut state.vec3i) + .build(); + ui.spacing(); + }); } if ui.collapsing_header(im_str!("Popups & Modal windows")) - .build() { - ui.tree_node(im_str!("Popups")) - .build(|| { - ui.text_wrapped(im_str!("When a popup is active, it inhibits interacting \ + .build() + { + ui.tree_node(im_str!("Popups")).build(|| { + ui.text_wrapped(im_str!( + "When a popup is active, it inhibits interacting \ with windows that are behind the popup. Clicking \ - outside the popup closes it.")); - let names = [im_str!("Bream"), - im_str!("Haddock"), - im_str!("Mackerel"), - im_str!("Pollock"), - im_str!("Tilefish")]; - if ui.small_button(im_str!("Select..")) { - ui.open_popup(im_str!("select")); - } - ui.same_line(0.0); - ui.text(match state.selected_fish { - Some(index) => names[index].clone(), - None => im_str!(""), - }); - ui.popup(im_str!("select"), || { - ui.text(im_str!("Aquarium")); - ui.separator(); - for (index, name) in names.iter().enumerate() { - if ui.selectable(name.clone(), - false, - ImGuiSelectableFlags::empty(), - ImVec2::new(0.0, 0.0)) { - state.selected_fish = Some(index); - } - } - }); + outside the popup closes it." + )); + let names = [ + im_str!("Bream"), + im_str!("Haddock"), + im_str!("Mackerel"), + im_str!("Pollock"), + im_str!("Tilefish"), + ]; + if ui.small_button(im_str!("Select..")) { + ui.open_popup(im_str!("select")); + } + ui.same_line(0.0); + ui.text(match state.selected_fish { + Some(index) => names[index].clone(), + None => im_str!(""), }); + ui.popup(im_str!("select"), || { + ui.text(im_str!("Aquarium")); + ui.separator(); + for (index, name) in names.iter().enumerate() { + if ui.selectable( + name.clone(), + false, + ImGuiSelectableFlags::empty(), + ImVec2::new(0.0, 0.0), + ) + { + state.selected_fish = Some(index); + } + } + }); + }); } }) } fn show_example_app_main_menu_bar<'a>(ui: &Ui<'a>, state: &mut State) { ui.main_menu_bar(|| { - ui.menu(im_str!("File")) - .build(|| { show_example_menu_file(ui, &mut state.file_menu); }); - ui.menu(im_str!("Edit")) - .build(|| { - ui.menu_item(im_str!("Undo")) - .shortcut(im_str!("CTRL+Z")) - .build(); - ui.menu_item(im_str!("Redo")) - .shortcut(im_str!("CTRL+Y")) - .enabled(false) - .build(); - ui.separator(); - ui.menu_item(im_str!("Cut")) - .shortcut(im_str!("CTRL+X")) - .build(); - ui.menu_item(im_str!("Copy")) - .shortcut(im_str!("CTRL+C")) - .build(); - ui.menu_item(im_str!("Paste")) - .shortcut(im_str!("CTRL+V")) - .build(); - }); + ui.menu(im_str!("File")).build(|| { + show_example_menu_file(ui, &mut state.file_menu); + }); + ui.menu(im_str!("Edit")).build(|| { + ui.menu_item(im_str!("Undo")) + .shortcut(im_str!("CTRL+Z")) + .build(); + ui.menu_item(im_str!("Redo")) + .shortcut(im_str!("CTRL+Y")) + .enabled(false) + .build(); + ui.separator(); + ui.menu_item(im_str!("Cut")) + .shortcut(im_str!("CTRL+X")) + .build(); + ui.menu_item(im_str!("Copy")) + .shortcut(im_str!("CTRL+C")) + .build(); + ui.menu_item(im_str!("Paste")) + .shortcut(im_str!("CTRL+V")) + .build(); + }); }); } fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) { - ui.menu_item(im_str!("(dummy menu)")) - .enabled(false) - .build(); + ui.menu_item(im_str!("(dummy menu)")).enabled(false).build(); ui.menu_item(im_str!("New")).build(); ui.menu_item(im_str!("Open")) .shortcut(im_str!("Ctrl+O")) .build(); - ui.menu(im_str!("Open Recent")) - .build(|| { - ui.menu_item(im_str!("fish_hat.c")).build(); - ui.menu_item(im_str!("fish_hat.inl")).build(); - ui.menu_item(im_str!("fish_hat.h")).build(); - ui.menu(im_str!("More..")) - .build(|| { - ui.menu_item(im_str!("Hello")).build(); - ui.menu_item(im_str!("Sailor")).build(); - ui.menu(im_str!("Recurse..")) - .build(|| { show_example_menu_file(ui, state); }); - }); + ui.menu(im_str!("Open Recent")).build(|| { + ui.menu_item(im_str!("fish_hat.c")).build(); + ui.menu_item(im_str!("fish_hat.inl")).build(); + ui.menu_item(im_str!("fish_hat.h")).build(); + ui.menu(im_str!("More..")).build(|| { + ui.menu_item(im_str!("Hello")).build(); + ui.menu_item(im_str!("Sailor")).build(); + ui.menu(im_str!("Recurse..")).build(|| { + show_example_menu_file(ui, state); + }); }); + }); ui.menu_item(im_str!("Save")) .shortcut(im_str!("Ctrl+S")) .build(); ui.menu_item(im_str!("Save As..")).build(); ui.separator(); - ui.menu(im_str!("Options")) - .build(|| { - ui.menu_item(im_str!("Enabled")) - .selected(&mut state.enabled) - .build(); - // TODO - }); - ui.menu(im_str!("Colors")) - .build(|| { - // TODO - }); - ui.menu(im_str!("Disabled")) - .enabled(false) - .build(|| { - unreachable!(); - }); + ui.menu(im_str!("Options")).build(|| { + ui.menu_item(im_str!("Enabled")) + .selected(&mut state.enabled) + .build(); + // TODO + }); + ui.menu(im_str!("Colors")).build(|| { + // TODO + }); + ui.menu(im_str!("Disabled")).enabled(false).build(|| { + unreachable!(); + }); let mut checked = true; ui.menu_item(im_str!("Checked")) .selected(&mut checked) @@ -491,9 +506,11 @@ fn show_example_app_auto_resize<'a>(ui: &Ui<'a>, state: &mut AutoResizeState, op .opened(opened) .always_auto_resize(true) .build(|| { - ui.text(im_str!("Window will resize every-ui to the size of its content. + ui.text(im_str!( + "Window will resize every-ui to the size of its content. Note that you probably don't want to query the window size to -output your content because that would create a feedback loop.")); +output your content because that would create a feedback loop." + )); ui.slider_int(im_str!("Number of lines"), &mut state.lines, 1, 20) .build(); for i in 0..state.lines { @@ -511,26 +528,36 @@ fn show_example_app_fixed_overlay<'a>(ui: &Ui<'a>, opened: &mut bool) { .movable(false) .save_settings(false) .build(|| { - ui.text(im_str!("Simple overlay\non the top-left side of the screen.")); - ui.separator(); - let mouse_pos = ui.imgui().mouse_pos(); - ui.text(im_str!("Mouse Position: ({:.1},{:.1})", mouse_pos.0, mouse_pos.1)); - }) + ui.text(im_str!( + "Simple overlay\non the top-left side of the screen." + )); + ui.separator(); + let mouse_pos = ui.imgui().mouse_pos(); + ui.text(im_str!( + "Mouse Position: ({:.1},{:.1})", + mouse_pos.0, + mouse_pos.1 + )); + }) } fn show_example_app_manipulating_window_title<'a>(ui: &Ui<'a>) { ui.window(im_str!("Same title as another window##1")) .position((100.0, 100.0), ImGuiCond::FirstUseEver) .build(|| { - ui.text(im_str!("This is window 1. -My title is the same as window 2, but my identifier is unique.")); - }); + ui.text(im_str!( + "This is window 1. +My title is the same as window 2, but my identifier is unique." + )); + }); ui.window(im_str!("Same title as another window##2")) .position((100.0, 200.0), ImGuiCond::FirstUseEver) .build(|| { - ui.text(im_str!("This is window 2. -My title is the same as window 1, but my identifier is unique.")); - }); + ui.text(im_str!( + "This is window 2. +My title is the same as window 1, but my identifier is unique." + )); + }); let chars = ['|', '/', '-', '\\']; let ch_idx = (ui.imgui().get_time() / 0.25) as usize & 3; let num = ui.imgui().get_frame_count(); // The C++ version uses rand() here diff --git a/imgui-gfx-renderer/src/lib.rs b/imgui-gfx-renderer/src/lib.rs index 84ce4af..f3c5dfe 100644 --- a/imgui-gfx-renderer/src/lib.rs +++ b/imgui-gfx-renderer/src/lib.rs @@ -14,7 +14,7 @@ pub enum RendererError { Update(gfx::UpdateError), Buffer(gfx::buffer::CreationError), Pipeline(gfx::PipelineStateError), - Combined(gfx::CombinedError) + Combined(gfx::CombinedError), } impl From> for RendererError { @@ -86,32 +86,50 @@ pub struct Renderer { } impl Renderer { - pub fn init>(imgui: &mut ImGui, - factory: &mut F, - shaders: Shaders, - out: RenderTargetView) - -> RendererResult> { + pub fn init>( + imgui: &mut ImGui, + factory: &mut F, + shaders: Shaders, + out: RenderTargetView, + ) -> RendererResult> { let (vs_code, ps_code) = shaders.get_program_code(); - let pso = factory.create_pipeline_simple(vs_code, ps_code, pipe::new())?; - let vertex_buffer = factory.create_buffer::(256, - gfx::buffer::Role::Vertex, - gfx::memory::Usage::Dynamic, - Bind::empty())?; - let index_buffer = factory.create_buffer::(256, - gfx::buffer::Role::Index, - gfx::memory::Usage::Dynamic, - Bind::empty())?; + let pso = factory.create_pipeline_simple( + vs_code, + ps_code, + pipe::new(), + )?; + let vertex_buffer = factory.create_buffer::( + 256, + gfx::buffer::Role::Vertex, + gfx::memory::Usage::Dynamic, + Bind::empty(), + )?; + let index_buffer = factory.create_buffer::( + 256, + gfx::buffer::Role::Index, + gfx::memory::Usage::Dynamic, + Bind::empty(), + )?; let (_, texture) = imgui.prepare_texture(|handle| { - factory.create_texture_immutable_u8::(gfx::texture::Kind::D2(handle.width as u16, handle.height as u16, gfx::texture::AaMode::Single), &[handle.pixels]) + factory.create_texture_immutable_u8::( + gfx::texture::Kind::D2( + handle.width as u16, + handle.height as u16, + gfx::texture::AaMode::Single, + ), + &[handle.pixels], + ) })?; // TODO: set texture id in imgui let sampler = factory.create_sampler_linear(); let data = pipe::Data { vertex_buffer: vertex_buffer, - matrix: [[0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, -1.0, 0.0], - [-1.0, 1.0, 0.0, 1.0]], + matrix: [ + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, -1.0, 0.0], + [-1.0, 1.0, 0.0, 1.0], + ], tex: (texture, sampler), out: out, scissor: Rect { @@ -136,37 +154,51 @@ impl Renderer { pub fn update_render_target(&mut self, out: RenderTargetView) { self.bundle.data.out = out; } - pub fn render<'a, F: Factory, C: CommandBuffer>(&mut self, - ui: Ui<'a>, - factory: &mut F, - encoder: &mut Encoder) - -> RendererResult<()> { + pub fn render<'a, F: Factory, C: CommandBuffer>( + &mut self, + ui: Ui<'a>, + factory: &mut F, + encoder: &mut Encoder, + ) -> RendererResult<()> { let (width, height) = ui.imgui().display_size(); if width == 0.0 || height == 0.0 { return Ok(()); } - self.bundle.data.matrix = [[2.0 / width as f32, 0.0, 0.0, 0.0], - [0.0, -2.0 / height as f32, 0.0, 0.0], - [0.0, 0.0, -1.0, 0.0], - [-1.0, 1.0, 0.0, 1.0]]; + self.bundle.data.matrix = [ + [2.0 / width as f32, 0.0, 0.0, 0.0], + [0.0, -2.0 / height as f32, 0.0, 0.0], + [0.0, 0.0, -1.0, 0.0], + [-1.0, 1.0, 0.0, 1.0], + ]; - ui.render(|ui, draw_list| self.render_draw_list(ui, factory, encoder, draw_list)) + ui.render(|ui, draw_list| { + self.render_draw_list(ui, factory, encoder, draw_list) + }) } - fn render_draw_list<'a, F: Factory, C: CommandBuffer>(&mut self, - ui: &'a Ui<'a>, - factory: &mut F, - encoder: &mut Encoder, - draw_list: DrawList<'a>) - -> RendererResult<()> { + fn render_draw_list<'a, F: Factory, C: CommandBuffer>( + &mut self, + ui: &'a Ui<'a>, + factory: &mut F, + encoder: &mut Encoder, + draw_list: DrawList<'a>, + ) -> RendererResult<()> { let (scale_width, scale_height) = ui.imgui().display_framebuffer_scale(); self.bundle.slice.start = 0; for cmd in draw_list.cmd_buffer { // TODO: check cmd.texture_id - self.upload_vertex_buffer(factory, encoder, draw_list.vtx_buffer)?; - self.upload_index_buffer(factory, encoder, draw_list.idx_buffer)?; + self.upload_vertex_buffer( + factory, + encoder, + draw_list.vtx_buffer, + )?; + self.upload_index_buffer( + factory, + encoder, + draw_list.idx_buffer, + )?; self.bundle.slice.end = self.bundle.slice.start + cmd.elem_count; self.bundle.data.scissor = Rect { @@ -180,29 +212,39 @@ impl Renderer { } Ok(()) } - fn upload_vertex_buffer, C: CommandBuffer>(&mut self, - factory: &mut F, - encoder: &mut Encoder, - vtx_buffer: &[ImDrawVert]) - -> RendererResult<()> { + fn upload_vertex_buffer, C: CommandBuffer>( + &mut self, + factory: &mut F, + encoder: &mut Encoder, + vtx_buffer: &[ImDrawVert], + ) -> RendererResult<()> { if self.bundle.data.vertex_buffer.len() < vtx_buffer.len() { - self.bundle.data.vertex_buffer = factory.create_buffer::(vtx_buffer.len(), - gfx::buffer::Role::Vertex, - gfx::memory::Usage::Dynamic, - Bind::empty())?; + self.bundle.data.vertex_buffer = factory.create_buffer::( + vtx_buffer.len(), + gfx::buffer::Role::Vertex, + gfx::memory::Usage::Dynamic, + Bind::empty(), + )?; } - Ok(encoder.update_buffer(&self.bundle.data.vertex_buffer, vtx_buffer, 0)?) + Ok(encoder.update_buffer( + &self.bundle.data.vertex_buffer, + vtx_buffer, + 0, + )?) } - fn upload_index_buffer, C: CommandBuffer>(&mut self, - factory: &mut F, - encoder: &mut Encoder, - idx_buffer: &[ImDrawIdx]) - -> RendererResult<()> { + fn upload_index_buffer, C: CommandBuffer>( + &mut self, + factory: &mut F, + encoder: &mut Encoder, + idx_buffer: &[ImDrawIdx], + ) -> RendererResult<()> { if self.index_buffer.len() < idx_buffer.len() { - self.index_buffer = factory.create_buffer::(idx_buffer.len(), - gfx::buffer::Role::Index, - gfx::memory::Usage::Dynamic, - Bind::empty())?; + self.index_buffer = factory.create_buffer::( + idx_buffer.len(), + gfx::buffer::Role::Index, + gfx::memory::Usage::Dynamic, + Bind::empty(), + )?; self.bundle.slice.buffer = self.index_buffer.clone().into_index_buffer(factory); } Ok(encoder.update_buffer(&self.index_buffer, idx_buffer, 0)?) diff --git a/imgui-glium-renderer/src/lib.rs b/imgui-glium-renderer/src/lib.rs index 1db3bb7..1cb24a7 100644 --- a/imgui-glium-renderer/src/lib.rs +++ b/imgui-glium-renderer/src/lib.rs @@ -73,21 +73,30 @@ impl Renderer { pub fn render<'a, S: Surface>(&mut self, surface: &mut S, ui: Ui<'a>) -> RendererResult<()> { let _ = self.ctx.insert_debug_marker("imgui-rs: starting rendering"); - let result = ui.render(|ui, draw_list| self.render_draw_list(surface, ui, draw_list)); + let result = ui.render(|ui, draw_list| { + self.render_draw_list(surface, ui, draw_list) + }); let _ = self.ctx.insert_debug_marker("imgui-rs: rendering finished"); result } - fn render_draw_list<'a, S: Surface>(&mut self, - surface: &mut S, - ui: &'a Ui<'a>, - draw_list: DrawList<'a>) - -> RendererResult<()> { + fn render_draw_list<'a, S: Surface>( + &mut self, + surface: &mut S, + ui: &'a Ui<'a>, + draw_list: DrawList<'a>, + ) -> RendererResult<()> { use glium::{Blend, DrawParameters, Rect}; use glium::uniforms::{MinifySamplerFilter, MagnifySamplerFilter}; - try!(self.device_objects.upload_vertex_buffer(&self.ctx, draw_list.vtx_buffer)); - try!(self.device_objects.upload_index_buffer(&self.ctx, draw_list.idx_buffer)); + try!(self.device_objects.upload_vertex_buffer( + &self.ctx, + draw_list.vtx_buffer, + )); + try!(self.device_objects.upload_index_buffer( + &self.ctx, + draw_list.idx_buffer, + )); let (width, height) = ui.imgui().display_size(); let (scale_width, scale_height) = ui.imgui().display_framebuffer_scale(); @@ -96,10 +105,12 @@ impl Renderer { return Ok(()); } - let matrix = [[2.0 / width as f32, 0.0, 0.0, 0.0], - [0.0, 2.0 / -(height as f32), 0.0, 0.0], - [0.0, 0.0, -1.0, 0.0], - [-1.0, 1.0, 0.0, 1.0]]; + let matrix = [ + [2.0 / width as f32, 0.0, 0.0, 0.0], + [0.0, 2.0 / -(height as f32), 0.0, 0.0], + [0.0, 0.0, -1.0, 0.0], + [-1.0, 1.0, 0.0, 1.0], + ]; let font_texture_id = self.device_objects.texture.get_id() as usize; let mut idx_start = 0; @@ -109,31 +120,32 @@ impl Renderer { let idx_end = idx_start + cmd.elem_count as usize; - try!(surface.draw(&self.device_objects.vertex_buffer, - &self.device_objects - .index_buffer - .slice(idx_start..idx_end) - .expect("Invalid index buffer range"), - &self.device_objects.program, - &uniform! { + try!( + surface.draw( + &self.device_objects.vertex_buffer, + &self.device_objects + .index_buffer + .slice(idx_start..idx_end) + .expect("Invalid index buffer range"), + &self.device_objects.program, + &uniform! { matrix: matrix, tex: self.device_objects.texture.sampled() .magnify_filter(MagnifySamplerFilter::Nearest) .minify_filter(MinifySamplerFilter::Nearest), }, - &DrawParameters { - blend: Blend::alpha_blending(), - scissor: Some(Rect { - left: (cmd.clip_rect.x * scale_width) as u32, - bottom: ((height - cmd.clip_rect.w) * scale_height) as u32, - width: ((cmd.clip_rect.z - cmd.clip_rect.x) * scale_width) as - u32, - height: ((cmd.clip_rect.w - cmd.clip_rect.y) * - scale_height) as - u32, - }), - ..DrawParameters::default() - })); + &DrawParameters { + blend: Blend::alpha_blending(), + scissor: Some(Rect { + left: (cmd.clip_rect.x * scale_width) as u32, + bottom: ((height - cmd.clip_rect.w) * scale_height) as u32, + width: ((cmd.clip_rect.z - cmd.clip_rect.x) * scale_width) as u32, + height: ((cmd.clip_rect.w - cmd.clip_rect.y) * scale_height) as u32, + }), + ..DrawParameters::default() + }, + ) + ); idx_start = idx_end; } @@ -149,8 +161,9 @@ pub struct DeviceObjects { texture: Texture2d, } -fn compile_default_program(ctx: &F) - -> Result { +fn compile_default_program( + ctx: &F, +) -> Result { program!( ctx, 400 => { @@ -186,7 +199,11 @@ impl DeviceObjects { use glium::texture::{ClientFormat, RawImage2d}; let vertex_buffer = try!(VertexBuffer::empty_dynamic(ctx, 0)); - let index_buffer = try!(IndexBuffer::empty_dynamic(ctx, PrimitiveType::TrianglesList, 0)); + let index_buffer = try!(IndexBuffer::empty_dynamic( + ctx, + PrimitiveType::TrianglesList, + 0, + )); let program = try!(compile_default_program(ctx)); let texture = try!(im_gui.prepare_texture(|handle| { @@ -207,35 +224,42 @@ impl DeviceObjects { texture: texture, }) } - pub fn upload_vertex_buffer(&mut self, - ctx: &F, - vtx_buffer: &[ImDrawVert]) - -> RendererResult<()> { + pub fn upload_vertex_buffer( + &mut self, + ctx: &F, + vtx_buffer: &[ImDrawVert], + ) -> RendererResult<()> { self.vertex_buffer.invalidate(); if let Some(slice) = self.vertex_buffer.slice_mut(0..vtx_buffer.len()) { slice.write(vtx_buffer); return Ok(()); } self.vertex_buffer = try!(VertexBuffer::dynamic(ctx, vtx_buffer)); - let _ = ctx.get_context() - .insert_debug_marker(&format!("imgui-rs: resized vertex buffer to {} bytes", - self.vertex_buffer.get_size())); + let _ = ctx.get_context().insert_debug_marker(&format!( + "imgui-rs: resized vertex buffer to {} bytes", + self.vertex_buffer.get_size() + )); Ok(()) } - pub fn upload_index_buffer(&mut self, - ctx: &F, - idx_buffer: &[ImDrawIdx]) - -> RendererResult<()> { + pub fn upload_index_buffer( + &mut self, + ctx: &F, + idx_buffer: &[ImDrawIdx], + ) -> RendererResult<()> { self.index_buffer.invalidate(); if let Some(slice) = self.index_buffer.slice_mut(0..idx_buffer.len()) { slice.write(idx_buffer); return Ok(()); } - self.index_buffer = - try!(IndexBuffer::dynamic(ctx, PrimitiveType::TrianglesList, idx_buffer)); - let _ = ctx.get_context() - .insert_debug_marker(&format!("imgui-rs: resized index buffer to {} bytes", - self.index_buffer.get_size())); + self.index_buffer = try!(IndexBuffer::dynamic( + ctx, + PrimitiveType::TrianglesList, + idx_buffer, + )); + let _ = ctx.get_context().insert_debug_marker(&format!( + "imgui-rs: resized index buffer to {} bytes", + self.index_buffer.get_size() + )); Ok(()) } } diff --git a/imgui-sys/src/gfx_support.rs b/imgui-sys/src/gfx_support.rs index e6adb53..5b08582 100644 --- a/imgui-sys/src/gfx_support.rs +++ b/imgui-sys/src/gfx_support.rs @@ -20,7 +20,10 @@ impl Structure for ImDrawVert { Some(s) if s.starts_with('.') => &s[1..], _ => name, }; - (sub_name, array_id * (mem::size_of::() as ElemOffset)) + ( + sub_name, + array_id * (mem::size_of::() as ElemOffset), + ) } None => (name, 0), } @@ -31,21 +34,21 @@ impl Structure for ImDrawVert { Some(Element { format: ::get_format(), offset: unsafe { mem::transmute::<_, usize>(&dummy.pos) } as ElemOffset + - big_offset, + big_offset, }) } "uv" => { Some(Element { format: ::get_format(), offset: unsafe { mem::transmute::<_, usize>(&dummy.uv) } as ElemOffset + - big_offset, + big_offset, }) } "col" => { Some(Element { format: <[U8Norm; 4] as Formatted>::get_format(), offset: unsafe { mem::transmute::<_, usize>(&dummy.col) } as ElemOffset + - big_offset, + big_offset, }) } _ => None, diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 0aa5b4a..8065324 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -220,7 +220,8 @@ pub const ImGuiWindowFlags_NoMove: ImGuiWindowFlags = ImGuiWindowFlags::NoMove; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::NoScrollbar instead")] pub const ImGuiWindowFlags_NoScrollbar: ImGuiWindowFlags = ImGuiWindowFlags::NoScrollbar; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::NoScrollWithMouse instead")] -pub const ImGuiWindowFlags_NoScrollWithMouse: ImGuiWindowFlags = ImGuiWindowFlags::NoScrollWithMouse; +pub const ImGuiWindowFlags_NoScrollWithMouse: ImGuiWindowFlags = + ImGuiWindowFlags::NoScrollWithMouse; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::NoCollapse instead")] pub const ImGuiWindowFlags_NoCollapse: ImGuiWindowFlags = ImGuiWindowFlags::NoCollapse; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::AlwaysAutoResize instead")] @@ -234,17 +235,26 @@ pub const ImGuiWindowFlags_NoInputs: ImGuiWindowFlags = ImGuiWindowFlags::NoInpu #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::MenuBar instead")] pub const ImGuiWindowFlags_MenuBar: ImGuiWindowFlags = ImGuiWindowFlags::MenuBar; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::HorizontalScrollbar instead")] -pub const ImGuiWindowFlags_HorizontalScrollbar: ImGuiWindowFlags = ImGuiWindowFlags::HorizontalScrollbar; +pub const ImGuiWindowFlags_HorizontalScrollbar: ImGuiWindowFlags = + ImGuiWindowFlags::HorizontalScrollbar; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::NoFocusOnAppearing instead")] -pub const ImGuiWindowFlags_NoFocusOnAppearing: ImGuiWindowFlags = ImGuiWindowFlags::NoFocusOnAppearing; +pub const ImGuiWindowFlags_NoFocusOnAppearing: ImGuiWindowFlags = + ImGuiWindowFlags::NoFocusOnAppearing; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::NoBringToFrontOnFocus instead")] -pub const ImGuiWindowFlags_NoBringToFrontOnFocus: ImGuiWindowFlags = ImGuiWindowFlags::NoBringToFrontOnFocus; -#[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::AlwaysVerticalScrollbar instead")] -pub const ImGuiWindowFlags_AlwaysVerticalScrollbar: ImGuiWindowFlags = ImGuiWindowFlags::AlwaysVerticalScrollbar; -#[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::AlwaysHorizontalScrollbar instead")] -pub const ImGuiWindowFlags_AlwaysHorizontalScrollbar: ImGuiWindowFlags = ImGuiWindowFlags::AlwaysHorizontalScrollbar; -#[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::AlwaysUseWindowPadding instead")] -pub const ImGuiWindowFlags_AlwaysUseWindowPadding: ImGuiWindowFlags = ImGuiWindowFlags::AlwaysUseWindowPadding; +pub const ImGuiWindowFlags_NoBringToFrontOnFocus: ImGuiWindowFlags = + ImGuiWindowFlags::NoBringToFrontOnFocus; +#[deprecated(since = "0.0.17", + note = "please use ImGuiWindowFlags::AlwaysVerticalScrollbar instead")] +pub const ImGuiWindowFlags_AlwaysVerticalScrollbar: ImGuiWindowFlags = + ImGuiWindowFlags::AlwaysVerticalScrollbar; +#[deprecated(since = "0.0.17", + note = "please use ImGuiWindowFlags::AlwaysHorizontalScrollbar instead")] +pub const ImGuiWindowFlags_AlwaysHorizontalScrollbar: ImGuiWindowFlags = + ImGuiWindowFlags::AlwaysHorizontalScrollbar; +#[deprecated(since = "0.0.17", + note = "please use ImGuiWindowFlags::AlwaysUseWindowPadding instead")] +pub const ImGuiWindowFlags_AlwaysUseWindowPadding: ImGuiWindowFlags = + ImGuiWindowFlags::AlwaysUseWindowPadding; #[deprecated(since = "0.0.17", note = "please use ImGuiWindowFlags::ChildWindow instead")] pub const ImGuiWindowFlags_ChildWindow: ImGuiWindowFlags = ImGuiWindowFlags::ChildWindow; @@ -324,31 +334,44 @@ bitflags!( #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CharsDecimal instead")] pub const ImGuiInputTextFlags_CharsDecimal: ImGuiInputTextFlags = ImGuiInputTextFlags::CharsDecimal; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CharsHexadecimal instead")] -pub const ImGuiInputTextFlags_CharsHexadecimal: ImGuiInputTextFlags = ImGuiInputTextFlags::CharsHexadecimal; +pub const ImGuiInputTextFlags_CharsHexadecimal: ImGuiInputTextFlags = + ImGuiInputTextFlags::CharsHexadecimal; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CharsUppercase instead")] -pub const ImGuiInputTextFlags_CharsUppercase: ImGuiInputTextFlags = ImGuiInputTextFlags::CharsUppercase; +pub const ImGuiInputTextFlags_CharsUppercase: ImGuiInputTextFlags = + ImGuiInputTextFlags::CharsUppercase; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CharsNoBlank instead")] pub const ImGuiInputTextFlags_CharsNoBlank: ImGuiInputTextFlags = ImGuiInputTextFlags::CharsNoBlank; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::AutoSelectAll instead")] -pub const ImGuiInputTextFlags_AutoSelectAll: ImGuiInputTextFlags = ImGuiInputTextFlags::AutoSelectAll; +pub const ImGuiInputTextFlags_AutoSelectAll: ImGuiInputTextFlags = + ImGuiInputTextFlags::AutoSelectAll; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::EnterReturnsTrue instead")] -pub const ImGuiInputTextFlags_EnterReturnsTrue: ImGuiInputTextFlags = ImGuiInputTextFlags::EnterReturnsTrue; +pub const ImGuiInputTextFlags_EnterReturnsTrue: ImGuiInputTextFlags = + ImGuiInputTextFlags::EnterReturnsTrue; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CallbackCompletion instead")] -pub const ImGuiInputTextFlags_CallbackCompletion: ImGuiInputTextFlags = ImGuiInputTextFlags::CallbackCompletion; +pub const ImGuiInputTextFlags_CallbackCompletion: ImGuiInputTextFlags = + ImGuiInputTextFlags::CallbackCompletion; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CallbackHistory instead")] -pub const ImGuiInputTextFlags_CallbackHistory: ImGuiInputTextFlags = ImGuiInputTextFlags::CallbackHistory; +pub const ImGuiInputTextFlags_CallbackHistory: ImGuiInputTextFlags = + ImGuiInputTextFlags::CallbackHistory; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CallbackAlways instead")] -pub const ImGuiInputTextFlags_CallbackAlways: ImGuiInputTextFlags = ImGuiInputTextFlags::CallbackAlways; +pub const ImGuiInputTextFlags_CallbackAlways: ImGuiInputTextFlags = + ImGuiInputTextFlags::CallbackAlways; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CallbackCharFilter instead")] -pub const ImGuiInputTextFlags_CallbackCharFilter: ImGuiInputTextFlags = ImGuiInputTextFlags::CallbackCharFilter; +pub const ImGuiInputTextFlags_CallbackCharFilter: ImGuiInputTextFlags = + ImGuiInputTextFlags::CallbackCharFilter; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::AllowTabInput instead")] -pub const ImGuiInputTextFlags_AllowTabInput: ImGuiInputTextFlags = ImGuiInputTextFlags::AllowTabInput; -#[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::CtrlEnterForNewLine instead")] -pub const ImGuiInputTextFlags_CtrlEnterForNewLine: ImGuiInputTextFlags = ImGuiInputTextFlags::CtrlEnterForNewLine; +pub const ImGuiInputTextFlags_AllowTabInput: ImGuiInputTextFlags = + ImGuiInputTextFlags::AllowTabInput; +#[deprecated(since = "0.0.17", + note = "please use ImGuiInputTextFlags::CtrlEnterForNewLine instead")] +pub const ImGuiInputTextFlags_CtrlEnterForNewLine: ImGuiInputTextFlags = + ImGuiInputTextFlags::CtrlEnterForNewLine; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::NoHorizontalScroll instead")] -pub const ImGuiInputTextFlags_NoHorizontalScroll: ImGuiInputTextFlags = ImGuiInputTextFlags::NoHorizontalScroll; +pub const ImGuiInputTextFlags_NoHorizontalScroll: ImGuiInputTextFlags = + ImGuiInputTextFlags::NoHorizontalScroll; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::AlwaysInsertMode instead")] -pub const ImGuiInputTextFlags_AlwaysInsertMode: ImGuiInputTextFlags = ImGuiInputTextFlags::AlwaysInsertMode; +pub const ImGuiInputTextFlags_AlwaysInsertMode: ImGuiInputTextFlags = + ImGuiInputTextFlags::AlwaysInsertMode; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::ReadOnly instead")] pub const ImGuiInputTextFlags_ReadOnly: ImGuiInputTextFlags = ImGuiInputTextFlags::ReadOnly; #[deprecated(since = "0.0.17", note = "please use ImGuiInputTextFlags::Password instead")] @@ -367,11 +390,14 @@ bitflags!( ); #[deprecated(since = "0.0.17", note = "please use ImGuiSelectableFlags::DontClosePopups instead")] -pub const ImGuiSelectableFlags_DontClosePopups: ImGuiSelectableFlags = ImGuiSelectableFlags::DontClosePopups; +pub const ImGuiSelectableFlags_DontClosePopups: ImGuiSelectableFlags = + ImGuiSelectableFlags::DontClosePopups; #[deprecated(since = "0.0.17", note = "please use ImGuiSelectableFlags::SpanAllColumns instead")] -pub const ImGuiSelectableFlags_SpanAllColumns: ImGuiSelectableFlags = ImGuiSelectableFlags::SpanAllColumns; +pub const ImGuiSelectableFlags_SpanAllColumns: ImGuiSelectableFlags = + ImGuiSelectableFlags::SpanAllColumns; #[deprecated(since = "0.0.17", note = "please use ImGuiSelectableFlags::AllowDoubleClick instead")] -pub const ImGuiSelectableFlags_AllowDoubleClick: ImGuiSelectableFlags = ImGuiSelectableFlags::AllowDoubleClick; +pub const ImGuiSelectableFlags_AllowDoubleClick: ImGuiSelectableFlags = + ImGuiSelectableFlags::AllowDoubleClick; bitflags!( /// Flags for trees and collapsing headers @@ -397,15 +423,19 @@ pub const ImGuiTreeNodeFlags_Selected: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags:: #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::Framed instead")] pub const ImGuiTreeNodeFlags_Framed: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::Framed; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::AllowOverlapMode instead")] -pub const ImGuiTreeNodeFlags_AllowOverlapMode: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::AllowOverlapMode; +pub const ImGuiTreeNodeFlags_AllowOverlapMode: ImGuiTreeNodeFlags = + ImGuiTreeNodeFlags::AllowOverlapMode; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::NoTreePushOnOpen instead")] -pub const ImGuiTreeNodeFlags_NoTreePushOnOpen: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::NoTreePushOnOpen; +pub const ImGuiTreeNodeFlags_NoTreePushOnOpen: ImGuiTreeNodeFlags = + ImGuiTreeNodeFlags::NoTreePushOnOpen; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::NoAutoOpenOnLog instead")] -pub const ImGuiTreeNodeFlags_NoAutoOpenOnLog: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::NoAutoOpenOnLog; +pub const ImGuiTreeNodeFlags_NoAutoOpenOnLog: ImGuiTreeNodeFlags = + ImGuiTreeNodeFlags::NoAutoOpenOnLog; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::DefaultOpen instead")] pub const ImGuiTreeNodeFlags_DefaultOpen: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::DefaultOpen; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::OpenOnDoubleClick instead")] -pub const ImGuiTreeNodeFlags_OpenOnDoubleClick: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::OpenOnDoubleClick; +pub const ImGuiTreeNodeFlags_OpenOnDoubleClick: ImGuiTreeNodeFlags = + ImGuiTreeNodeFlags::OpenOnDoubleClick; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::OpenOnArrow instead")] pub const ImGuiTreeNodeFlags_OpenOnArrow: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::OpenOnArrow; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::Leaf instead")] @@ -413,9 +443,12 @@ pub const ImGuiTreeNodeFlags_Leaf: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::Leaf #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::Bullet instead")] pub const ImGuiTreeNodeFlags_Bullet: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::Bullet; #[deprecated(since = "0.0.17", note = "please use ImGuiTreeNodeFlags::CollapsingHeader instead")] -pub const ImGuiTreeNodeFlags_CollapsingHeader: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags::CollapsingHeader; +pub const ImGuiTreeNodeFlags_CollapsingHeader: ImGuiTreeNodeFlags = + ImGuiTreeNodeFlags::CollapsingHeader; -pub type ImGuiTextEditCallback = Option c_int>; +pub type ImGuiTextEditCallback = Option< + extern "C" fn(data: *mut ImGuiTextEditCallbackData) -> c_int, +>; pub type ImGuiSizeConstraintCallback = Option; @@ -735,8 +768,10 @@ impl Default for ImGuiListClipper { } } -pub type ImDrawCallback = Option; +pub type ImDrawCallback = Option< + extern "C" fn(parent_list: *const ImDrawList, + cmd: *const ImDrawCmd), +>; /// A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call) #[repr(C)] @@ -890,23 +925,26 @@ extern "C" { // Window extern "C" { pub fn igBegin(name: *const c_char, open: *mut bool, flags: ImGuiWindowFlags) -> bool; - pub fn igBegin2(name: *const c_char, - open: *mut bool, - size_on_first_use: ImVec2, - bg_alpha: c_float, - flags: ImGuiWindowFlags) - -> bool; + pub fn igBegin2( + name: *const c_char, + open: *mut bool, + size_on_first_use: ImVec2, + bg_alpha: c_float, + flags: ImGuiWindowFlags, + ) -> bool; pub fn igEnd(); - pub fn igBeginChild(str_id: *const c_char, - size: ImVec2, - border: bool, - extra_flags: ImGuiWindowFlags) - -> bool; - pub fn igBeginChildEx(id: ImGuiID, - size: ImVec2, - border: bool, - extra_flags: ImGuiWindowFlags) - -> bool; + pub fn igBeginChild( + str_id: *const c_char, + size: ImVec2, + border: bool, + extra_flags: ImGuiWindowFlags, + ) -> bool; + pub fn igBeginChildEx( + id: ImGuiID, + size: ImVec2, + border: bool, + extra_flags: ImGuiWindowFlags, + ) -> bool; pub fn igEndChild(); pub fn igGetContentRegionMax(out: *mut ImVec2); pub fn igGetContentRegionAvail(out: *mut ImVec2); @@ -925,10 +963,12 @@ extern "C" { pub fn igSetNextWindowPos(pos: ImVec2, cond: ImGuiCond); pub fn igSetNextWindowPosCenter(cond: ImGuiCond); pub fn igSetNextWindowSize(size: ImVec2, cond: ImGuiCond); - pub fn igSetNextWindowConstraints(size_min: ImVec2, - size_max: ImVec2, - custom_callback: ImGuiSizeConstraintCallback, - custom_callback_data: *mut c_void); + pub fn igSetNextWindowConstraints( + size_min: ImVec2, + size_max: ImVec2, + custom_callback: ImGuiSizeConstraintCallback, + custom_callback_data: *mut c_void, + ); pub fn igSetNextWindowContentSize(size: ImVec2); pub fn igSetNextWindowContentWidth(width: c_float); pub fn igSetNextWindowCollapsed(collapsed: bool, cond: ImGuiCond); @@ -1039,9 +1079,7 @@ extern "C" { #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igPushIDStr instead")] -pub unsafe fn igPushIdStr(str_id: *const c_char) { - igPushIDStr(str_id) -} +pub unsafe fn igPushIdStr(str_id: *const c_char) { igPushIDStr(str_id) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igPushIDStrRange instead")] pub unsafe fn igPushIdStrRange(str_begin: *const c_char, str_end: *const c_char) { @@ -1049,24 +1087,16 @@ pub unsafe fn igPushIdStrRange(str_begin: *const c_char, str_end: *const c_char) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igPushIDPtr instead")] -pub unsafe fn igPushIdPtr(ptr_id: *const c_void) { - igPushIDPtr(ptr_id) -} +pub unsafe fn igPushIdPtr(ptr_id: *const c_void) { igPushIDPtr(ptr_id) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igPushIDInt instead")] -pub unsafe fn igPushIdInt(int_id: c_int) { - igPushIDInt(int_id) -} +pub unsafe fn igPushIdInt(int_id: c_int) { igPushIDInt(int_id) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igPopID instead")] -pub unsafe fn igPopId() { - igPopID() -} +pub unsafe fn igPopId() { igPopID() } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igGetIDStr instead")] -pub unsafe fn igGetIdStr(str_id: *const c_char) -> ImGuiID { - igGetIDStr(str_id) -} +pub unsafe fn igGetIdStr(str_id: *const c_char) -> ImGuiID { igGetIDStr(str_id) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igGetIDStrRange instead")] pub unsafe fn igGetIdstrRange(str_begin: *const c_char, str_end: *const c_char) -> ImGuiID { @@ -1074,9 +1104,7 @@ pub unsafe fn igGetIdstrRange(str_begin: *const c_char, str_end: *const c_char) } #[allow(non_snake_case)] #[deprecated(since = "0.0.17", note = "please use igGetIDPtr instead")] -pub unsafe fn igGetIdPtr(ptr_id: *const c_void) -> ImGuiID { - igGetIDPtr(ptr_id) -} +pub unsafe fn igGetIdPtr(ptr_id: *const c_void) -> ImGuiID { igGetIDPtr(ptr_id) } // Widgets extern "C" { @@ -1097,315 +1125,375 @@ extern "C" { pub fn igButton(label: *const c_char, size: ImVec2) -> bool; pub fn igSmallButton(label: *const c_char) -> bool; pub fn igInvisibleButton(str_id: *const c_char, size: ImVec2) -> bool; - pub fn igImage(user_texture_id: ImTextureID, - size: ImVec2, - uv0: ImVec2, - uv1: ImVec2, - tint_col: ImVec4, - border_col: ImVec4); - pub fn igImageButton(user_texture_id: ImTextureID, - size: ImVec2, - uv0: ImVec2, - uv1: ImVec2, - frame_padding: c_int, - bg_col: ImVec4, - tint_col: ImVec4) - -> bool; + pub fn igImage( + user_texture_id: ImTextureID, + size: ImVec2, + uv0: ImVec2, + uv1: ImVec2, + tint_col: ImVec4, + border_col: ImVec4, + ); + pub fn igImageButton( + user_texture_id: ImTextureID, + size: ImVec2, + uv0: ImVec2, + uv1: ImVec2, + frame_padding: c_int, + bg_col: ImVec4, + tint_col: ImVec4, + ) -> bool; pub fn igCheckbox(label: *const c_char, v: *mut bool) -> bool; pub fn igCheckboxFlags(label: *const c_char, flags: *mut c_uint, flags_value: c_uint) -> bool; pub fn igRadioButtonBool(label: *const c_char, active: bool) -> bool; pub fn igRadioButton(label: *const c_char, v: *mut c_int, v_button: c_int) -> bool; - pub fn igCombo(label: *const c_char, - current_item: *mut c_int, - items: *const *const c_char, - items_count: c_int, - height_in_items: c_int) - -> bool; - pub fn igCombo2(label: *const c_char, - current_item: *mut c_int, - items_separated_by_zeros: *const c_char, - height_in_items: c_int) - -> bool; - pub fn igCombo3(label: *const c_char, - current_item: *mut c_int, - items_getter: extern "C" fn(data: *mut c_void, - idx: c_int, - out_text: *mut *const c_char) - -> bool, - data: *mut c_void, - items_count: c_int, - height_in_items: c_int) - -> bool; - pub fn igPlotLines(label: *const c_char, - values: *const c_float, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - stride: c_int); - pub fn igPlotLines2(label: *const c_char, - values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, - data: *mut c_void, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2); - pub fn igPlotHistogram(label: *const c_char, - values: *const c_float, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2, - stride: c_int); - pub fn igPlotHistogram2(label: *const c_char, - values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, - data: *mut c_void, - values_count: c_int, - values_offset: c_int, - overlay_text: *const c_char, - scale_min: c_float, - scale_max: c_float, - graph_size: ImVec2); + pub fn igCombo( + label: *const c_char, + current_item: *mut c_int, + items: *const *const c_char, + items_count: c_int, + height_in_items: c_int, + ) -> bool; + pub fn igCombo2( + label: *const c_char, + current_item: *mut c_int, + items_separated_by_zeros: *const c_char, + height_in_items: c_int, + ) -> bool; + pub fn igCombo3( + label: *const c_char, + current_item: *mut c_int, + items_getter: extern "C" fn(data: *mut c_void, idx: c_int, out_text: *mut *const c_char) + -> bool, + data: *mut c_void, + items_count: c_int, + height_in_items: c_int, + ) -> bool; + pub fn igPlotLines( + label: *const c_char, + values: *const c_float, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + stride: c_int, + ); + pub fn igPlotLines2( + label: *const c_char, + values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, + data: *mut c_void, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + ); + pub fn igPlotHistogram( + label: *const c_char, + values: *const c_float, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + stride: c_int, + ); + pub fn igPlotHistogram2( + label: *const c_char, + values_getter: extern "C" fn(data: *mut c_void, idx: c_int) -> c_float, + data: *mut c_void, + values_count: c_int, + values_offset: c_int, + overlay_text: *const c_char, + scale_min: c_float, + scale_max: c_float, + graph_size: ImVec2, + ); pub fn igProgressBar(fraction: c_float, size_arg: *const ImVec2, overlay: *const c_char); } // Widgets: Sliders extern "C" { - pub fn igSliderFloat(label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igSliderFloat2(label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igSliderFloat3(label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igSliderFloat4(label: *const c_char, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igSliderAngle(label: *const c_char, - v_rad: *mut c_float, - v_degrees_min: c_float, - v_degrees_max: c_float) - -> bool; - pub fn igSliderInt(label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igSliderInt2(label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igSliderInt3(label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igSliderInt4(label: *const c_char, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igVSliderFloat(label: *const c_char, - size: ImVec2, - v: *mut c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igVSliderInt(label: *const c_char, - size: ImVec2, - v: *mut c_int, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; + pub fn igSliderFloat( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat2( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat3( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderFloat4( + label: *const c_char, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igSliderAngle( + label: *const c_char, + v_rad: *mut c_float, + v_degrees_min: c_float, + v_degrees_max: c_float, + ) -> bool; + pub fn igSliderInt( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igSliderInt2( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igSliderInt3( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igSliderInt4( + label: *const c_char, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igVSliderFloat( + label: *const c_char, + size: ImVec2, + v: *mut c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igVSliderInt( + label: *const c_char, + size: ImVec2, + v: *mut c_int, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; } // Widgets: Color Editor/Picker extern "C" { - pub fn igColorEdit3(label: *const c_char, col: *mut c_float, - flags: ImGuiColorEditFlags) -> bool; - pub fn igColorEdit4(label: *const c_char, col: *mut c_float, - flags: ImGuiColorEditFlags) -> bool; - pub fn igColorPicker3(label: *const c_char, col: *mut c_float, - flags: ImGuiColorEditFlags) -> bool; - pub fn igColorPicker4(label: *const c_char, col: *mut c_float, - flags: ImGuiColorEditFlags, ref_col: *const c_float) -> bool; - pub fn igColorButton(desc_id: *const c_char, col: ImVec4, - flags: ImGuiColorEditFlags, size: ImVec2) -> bool; + pub fn igColorEdit3( + label: *const c_char, + col: *mut c_float, + flags: ImGuiColorEditFlags, + ) -> bool; + pub fn igColorEdit4( + label: *const c_char, + col: *mut c_float, + flags: ImGuiColorEditFlags, + ) -> bool; + pub fn igColorPicker3( + label: *const c_char, + col: *mut c_float, + flags: ImGuiColorEditFlags, + ) -> bool; + pub fn igColorPicker4( + label: *const c_char, + col: *mut c_float, + flags: ImGuiColorEditFlags, + ref_col: *const c_float, + ) -> bool; + pub fn igColorButton( + desc_id: *const c_char, + col: ImVec4, + flags: ImGuiColorEditFlags, + size: ImVec2, + ) -> bool; pub fn igSetColorEditOptions(flags: ImGuiColorEditFlags); } // Widgets: Drags extern "C" { - pub fn igDragFloat(label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igDragFloat2(label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igDragFloat3(label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igDragFloat4(label: *const c_char, - v: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - power: c_float) - -> bool; - pub fn igDragFloatRange2(label: *const c_char, - v_current_min: *mut c_float, - v_current_max: *mut c_float, - v_speed: c_float, - v_min: c_float, - v_max: c_float, - display_format: *const c_char, - display_format_max: *const c_char, - power: c_float) - -> bool; - pub fn igDragInt(label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igDragInt2(label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igDragInt3(label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igDragInt4(label: *const c_char, - v: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char) - -> bool; - pub fn igDragIntRange2(label: *const c_char, - v_current_min: *mut c_int, - v_current_max: *mut c_int, - v_speed: c_float, - v_min: c_int, - v_max: c_int, - display_format: *const c_char, - display_format_max: *const c_char) - -> bool; + pub fn igDragFloat( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat2( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat3( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloat4( + label: *const c_char, + v: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragFloatRange2( + label: *const c_char, + v_current_min: *mut c_float, + v_current_max: *mut c_float, + v_speed: c_float, + v_min: c_float, + v_max: c_float, + display_format: *const c_char, + display_format_max: *const c_char, + power: c_float, + ) -> bool; + pub fn igDragInt( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igDragInt2( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igDragInt3( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igDragInt4( + label: *const c_char, + v: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + ) -> bool; + pub fn igDragIntRange2( + label: *const c_char, + v_current_min: *mut c_int, + v_current_max: *mut c_int, + v_speed: c_float, + v_min: c_int, + v_max: c_int, + display_format: *const c_char, + display_format_max: *const c_char, + ) -> bool; } // Widgets: Input extern "C" { - pub fn igInputText(label: *const c_char, - buf: *mut c_char, - buf_size: usize, - flags: ImGuiInputTextFlags, - callback: ImGuiTextEditCallback, - user_data: *mut c_void) - -> bool; - pub fn igInputTextMultiline(label: *const c_char, - buf: *mut c_char, - buf_size: usize, - size: ImVec2, - flags: ImGuiInputTextFlags, - callback: ImGuiTextEditCallback, - user_data: *mut c_void) - -> bool; - pub fn igInputFloat(label: *const c_char, - v: *mut c_float, - step: c_float, - step_fast: c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputFloat2(label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputFloat3(label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputFloat4(label: *const c_char, - v: *mut c_float, - decimal_precision: c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputInt(label: *const c_char, - v: *mut c_int, - step: c_int, - step_fast: c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputInt2(label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputInt3(label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; - pub fn igInputInt4(label: *const c_char, - v: *mut c_int, - extra_flags: ImGuiInputTextFlags) - -> bool; + pub fn igInputText( + label: *const c_char, + buf: *mut c_char, + buf_size: usize, + flags: ImGuiInputTextFlags, + callback: ImGuiTextEditCallback, + user_data: *mut c_void, + ) -> bool; + pub fn igInputTextMultiline( + label: *const c_char, + buf: *mut c_char, + buf_size: usize, + size: ImVec2, + flags: ImGuiInputTextFlags, + callback: ImGuiTextEditCallback, + user_data: *mut c_void, + ) -> bool; + pub fn igInputFloat( + label: *const c_char, + v: *mut c_float, + step: c_float, + step_fast: c_float, + decimal_precision: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat2( + label: *const c_char, + v: *mut c_float, + decimal_precision: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat3( + label: *const c_char, + v: *mut c_float, + decimal_precision: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputFloat4( + label: *const c_char, + v: *mut c_float, + decimal_precision: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt( + label: *const c_char, + v: *mut c_int, + step: c_int, + step_fast: c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt2( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt3( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; + pub fn igInputInt4( + label: *const c_char, + v: *mut c_int, + extra_flags: ImGuiInputTextFlags, + ) -> bool; } // Widgets: Trees @@ -1416,16 +1504,18 @@ extern "C" { // pub fn igTreeNodeStrV(str_id: *const c_char, fmt: *const c_char, args: va_list) -> bool; // pub fn igTreeNodePtrV(ptr_id: *const c_void, fmt: *const c_char, args: va_list) -> bool; pub fn igTreeNodeEx(label: *const c_char, flags: ImGuiTreeNodeFlags) -> bool; - pub fn igTreeNodeExStr(str_id: *const c_char, - flags: ImGuiTreeNodeFlags, - fmt: *const c_char, - ...) - -> bool; - pub fn igTreeNodeExPtr(ptr_id: *const c_void, - flags: ImGuiTreeNodeFlags, - fmt: *const c_char, - ...) - -> bool; + pub fn igTreeNodeExStr( + str_id: *const c_char, + flags: ImGuiTreeNodeFlags, + fmt: *const c_char, + ... + ) -> bool; + pub fn igTreeNodeExPtr( + ptr_id: *const c_void, + flags: ImGuiTreeNodeFlags, + fmt: *const c_char, + ... + ) -> bool; // pub fn igTreeNodeExV(str_id: *const c_char, flags: ImGuiTreeNodeFlags, // fmt: *const c_char, args: va_list) -> bool; // pub fn igTreeNodeExVPtr(ptr_id: *const c_void, flags: ImGuiTreeNodeFlags, @@ -1437,45 +1527,49 @@ extern "C" { pub fn igGetTreeNodeToLabelSpacing() -> c_float; pub fn igSetNextTreeNodeOpen(opened: bool, cond: ImGuiCond); pub fn igCollapsingHeader(label: *const c_char, flags: ImGuiTreeNodeFlags) -> bool; - pub fn igCollapsingHeaderEx(label: *const c_char, - open: *mut bool, - flags: ImGuiTreeNodeFlags) - -> bool; + pub fn igCollapsingHeaderEx( + label: *const c_char, + open: *mut bool, + flags: ImGuiTreeNodeFlags, + ) -> bool; } // Widgets: Selectable / Lists extern "C" { - pub fn igSelectable(label: *const c_char, - selected: bool, - flags: ImGuiSelectableFlags, - size: ImVec2) - -> bool; - pub fn igSelectableEx(label: *const c_char, - p_selected: *mut bool, - flags: ImGuiSelectableFlags, - size: ImVec2) - -> bool; - pub fn igListBox(label: *const c_char, - current_item: *mut c_int, - items: *const *const c_char, - items_count: c_int, - height_in_items: c_int) - -> bool; - pub fn igListBox2(label: *const c_char, - current_item: *mut c_int, - items_getter: extern "C" fn(data: *mut c_void, - idx: c_int, - out_text: *mut *const c_char) - -> bool, - data: *mut c_void, - items_count: c_int, - height_in_items: c_int) - -> bool; + pub fn igSelectable( + label: *const c_char, + selected: bool, + flags: ImGuiSelectableFlags, + size: ImVec2, + ) -> bool; + pub fn igSelectableEx( + label: *const c_char, + p_selected: *mut bool, + flags: ImGuiSelectableFlags, + size: ImVec2, + ) -> bool; + pub fn igListBox( + label: *const c_char, + current_item: *mut c_int, + items: *const *const c_char, + items_count: c_int, + height_in_items: c_int, + ) -> bool; + pub fn igListBox2( + label: *const c_char, + current_item: *mut c_int, + items_getter: extern "C" fn(data: *mut c_void, idx: c_int, out_text: *mut *const c_char) + -> bool, + data: *mut c_void, + items_count: c_int, + height_in_items: c_int, + ) -> bool; pub fn igListBoxHeader(label: *const c_char, size: ImVec2) -> bool; - pub fn igListBoxHeader2(label: *const c_char, - items_count: c_int, - height_in_items: c_int) - -> bool; + pub fn igListBoxHeader2( + label: *const c_char, + items_count: c_int, + height_in_items: c_int, + ) -> bool; pub fn igListBoxFooter(); } @@ -1503,31 +1597,35 @@ extern "C" { pub fn igEndMenuBar(); pub fn igBeginMenu(label: *const c_char, enabled: bool) -> bool; pub fn igEndMenu(); - pub fn igMenuItem(label: *const c_char, - shortcut: *const c_char, - selected: bool, - enabled: bool) - -> bool; - pub fn igMenuItemPtr(label: *const c_char, - shortcut: *const c_char, - p_selected: *mut bool, - enabled: bool) - -> bool; + pub fn igMenuItem( + label: *const c_char, + shortcut: *const c_char, + selected: bool, + enabled: bool, + ) -> bool; + pub fn igMenuItemPtr( + label: *const c_char, + shortcut: *const c_char, + p_selected: *mut bool, + enabled: bool, + ) -> bool; } // Popup extern "C" { pub fn igOpenPopup(str_id: *const c_char); pub fn igBeginPopup(str_id: *const c_char) -> bool; - pub fn igBeginPopupModal(name: *const c_char, - open: *mut bool, - extra_flags: ImGuiWindowFlags) - -> bool; + pub fn igBeginPopupModal( + name: *const c_char, + open: *mut bool, + extra_flags: ImGuiWindowFlags, + ) -> bool; pub fn igBeginPopupContextItem(str_id: *const c_char, mouse_button: c_int) -> bool; - pub fn igBeginPopupContextWindow(str_id: *const c_char, - mouse_button: c_int, - also_over_items: bool) - -> bool; + pub fn igBeginPopupContextWindow( + str_id: *const c_char, + mouse_button: c_int, + also_over_items: bool, + ) -> bool; pub fn igBeginPopupContextVoid(str_id: *const c_char, mouse_button: c_int) -> bool; pub fn igEndPopup(); pub fn igIsPopupOpen(str_id: *const c_char) -> bool; @@ -1546,9 +1644,11 @@ extern "C" { // Clipping extern "C" { - pub fn igPushClipRect(clip_rect_min: ImVec2, - clip_rect_max: ImVec2, - intersect_with_current_clip_rect: bool); + pub fn igPushClipRect( + clip_rect_min: ImVec2, + clip_rect_max: ImVec2, + intersect_with_current_clip_rect: bool, + ); pub fn igPopClipRect(); } @@ -1591,37 +1691,47 @@ extern "C" { pub fn igGetTime() -> c_float; pub fn igGetFrameCount() -> c_int; pub fn igGetStyleColorName(idx: ImGuiCol) -> *const c_char; - pub fn igCalcItemRectClosestPoint(out: *mut ImVec2, - pos: ImVec2, - on_edge: bool, - outward: c_float); - pub fn igCalcTextSize(out: *mut ImVec2, - text: *const c_char, - text_end: *const c_char, - hide_text_after_double_hash: bool, - wrap_width: c_float); - pub fn igCalcListClipping(items_count: c_int, - items_height: c_float, - out_items_display_start: *mut c_int, - out_items_display_end: *mut c_int); + pub fn igCalcItemRectClosestPoint( + out: *mut ImVec2, + pos: ImVec2, + on_edge: bool, + outward: c_float, + ); + pub fn igCalcTextSize( + out: *mut ImVec2, + text: *const c_char, + text_end: *const c_char, + hide_text_after_double_hash: bool, + wrap_width: c_float, + ); + pub fn igCalcListClipping( + items_count: c_int, + items_height: c_float, + out_items_display_start: *mut c_int, + out_items_display_end: *mut c_int, + ); pub fn igBeginChildFrame(id: ImGuiID, size: ImVec2, extra_flags: ImGuiWindowFlags) -> bool; pub fn igEndChildFrame(); pub fn igColorConvertU32ToFloat4(out: *mut ImVec4, color: ImU32); pub fn igColorConvertFloat4ToU32(color: ImVec4) -> ImU32; - pub fn igColorConvertRGBtoHSV(r: c_float, - g: c_float, - b: c_float, - out_h: *mut c_float, - out_s: *mut c_float, - out_v: *mut c_float); - pub fn igColorConvertHSVtoRGB(h: c_float, - s: c_float, - v: c_float, - out_r: *mut c_float, - out_g: *mut c_float, - out_b: *mut c_float); + pub fn igColorConvertRGBtoHSV( + r: c_float, + g: c_float, + b: c_float, + out_h: *mut c_float, + out_s: *mut c_float, + out_v: *mut c_float, + ); + pub fn igColorConvertHSVtoRGB( + h: c_float, + s: c_float, + v: c_float, + out_r: *mut c_float, + out_g: *mut c_float, + out_b: *mut c_float, + ); pub fn igGetKeyIndex(imgui_key: ImGuiKey) -> c_int; pub fn igIsKeyDown(user_key_index: c_int) -> bool; @@ -1654,9 +1764,10 @@ extern "C" { // Internal state access extern "C" { pub fn igGetVersion() -> *const c_char; - pub fn igCreateContext(malloc_fn: Option *mut c_void>, - free_fn: Option) - -> *mut ImGuiContext; + pub fn igCreateContext( + malloc_fn: Option *mut c_void>, + free_fn: Option, + ) -> *mut ImGuiContext; pub fn igDestroyContext(ctx: *mut ImGuiContext); pub fn igGetCurrentContext() -> *mut ImGuiContext; pub fn igSetCurrentContext(ctx: *mut ImGuiContext); @@ -1674,10 +1785,16 @@ extern "C" { pub fn ImGuiTextFilter_Create(default_filter: *const c_char) -> *mut ImGuiTextFilter; pub fn ImGuiTextFilter_Destroy(filter: *mut ImGuiTextFilter); pub fn ImGuiTextFilter_Clear(filter: *mut ImGuiTextFilter); - pub fn ImGuiTextFilter_Draw(filter: *mut ImGuiTextFilter, - label: *const c_char, width: c_float) -> bool; - pub fn ImGuiTextFilter_PassFilter(filter: *const ImGuiTextFilter, - text: *const c_char, text_end: *const c_char) -> bool; + pub fn ImGuiTextFilter_Draw( + filter: *mut ImGuiTextFilter, + label: *const c_char, + width: c_float, + ) -> bool; + pub fn ImGuiTextFilter_PassFilter( + filter: *const ImGuiTextFilter, + text: *const c_char, + text_end: *const c_char, + ) -> bool; pub fn ImGuiTextFilter_IsActive(filter: *const ImGuiTextFilter) -> bool; pub fn ImGuiTextFilter_Build(filter: *const ImGuiTextFilter); pub fn ImGuiTextFilter_GetInputBuf(filter: *mut ImGuiTextFilter) -> *const c_char; @@ -1695,49 +1812,79 @@ extern "C" { pub fn ImGuiTextBuffer_clear(buffer: *mut ImGuiTextBuffer); pub fn ImGuiTextBuffer_c_str(buffer: *const ImGuiTextBuffer) -> *const c_char; pub fn ImGuiTextBuffer_append(buffer: *const ImGuiTextBuffer, fmt: *const c_char, ...); - // pub fn ImGuiTextBuffer_appendv(buffer: *const ImGuiTextBuffer, fmt: *const c_char, args: va_list); +// pub fn ImGuiTextBuffer_appendv(buffer: *const ImGuiTextBuffer, fmt: *const c_char, args: va_list); } // ImGuiStorage extern "C" { pub fn ImGuiStorage_Create() -> *mut ImGuiStorage; pub fn ImGuiStorage_Destroy(storage: *mut ImGuiStorage); - pub fn ImGuiStorage_GetInt(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: c_int) -> c_int; + pub fn ImGuiStorage_GetInt( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_int, + ) -> c_int; pub fn ImGuiStorage_SetInt(storage: *mut ImGuiStorage, key: ImGuiID, val: c_int); - pub fn ImGuiStorage_GetBool(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: bool) -> bool; + pub fn ImGuiStorage_GetBool( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: bool, + ) -> bool; pub fn ImGuiStorage_SetBool(storage: *mut ImGuiStorage, key: ImGuiID, val: bool); - pub fn ImGuiStorage_GetFloat(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: c_float) -> c_float; + pub fn ImGuiStorage_GetFloat( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_float, + ) -> c_float; pub fn ImGuiStorage_SetFloat(storage: *mut ImGuiStorage, key: ImGuiID, val: c_float); pub fn ImGuiStorage_GetVoidPtr(storage: *mut ImGuiStorage, key: ImGuiID); pub fn ImGuiStorage_SetVoidPtr(storage: *mut ImGuiStorage, key: ImGuiID, val: *mut c_void); - pub fn ImGuiStorage_GetIntRef(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: c_int) -> *mut c_int; - pub fn ImGuiStorage_GetBoolRef(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: bool) -> *mut bool; - pub fn ImGuiStorage_GetFloatRef(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: c_float) -> *mut c_float; - pub fn ImGuiStorage_GetVoidPtrRef(storage: *mut ImGuiStorage, key: ImGuiID, - default_val: *mut c_void) -> *mut *mut c_void; + pub fn ImGuiStorage_GetIntRef( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_int, + ) -> *mut c_int; + pub fn ImGuiStorage_GetBoolRef( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: bool, + ) -> *mut bool; + pub fn ImGuiStorage_GetFloatRef( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: c_float, + ) -> *mut c_float; + pub fn ImGuiStorage_GetVoidPtrRef( + storage: *mut ImGuiStorage, + key: ImGuiID, + default_val: *mut c_void, + ) -> *mut *mut c_void; pub fn ImGuiStorage_SetAllInt(storage: *mut ImGuiStorage, val: c_int); } // ImGuiTextEditCallbackData extern "C" { - pub fn ImGuiTextEditCallbackData_DeleteChars(data: *mut ImGuiTextEditCallbackData, - pos: c_int, bytes_count: c_int); - pub fn ImGuiTextEditCallbackData_InsertChars(data: *mut ImGuiTextEditCallbackData, - pos: c_int, - text: *const c_char, text_end: *const c_char); + pub fn ImGuiTextEditCallbackData_DeleteChars( + data: *mut ImGuiTextEditCallbackData, + pos: c_int, + bytes_count: c_int, + ); + pub fn ImGuiTextEditCallbackData_InsertChars( + data: *mut ImGuiTextEditCallbackData, + pos: c_int, + text: *const c_char, + text_end: *const c_char, + ); pub fn ImGuiTextEditCallbackData_HasSelection(data: *mut ImGuiTextEditCallbackData) -> bool; } // ImGuiListClipper extern "C" { - pub fn ImGuiListClipper_Begin(clipper: *mut ImGuiListClipper, - count: c_int, items_height: c_float); + pub fn ImGuiListClipper_Begin( + clipper: *mut ImGuiListClipper, + count: c_int, + items_height: c_float, + ); pub fn ImGuiListClipper_End(clipper: *mut ImGuiListClipper); pub fn ImGuiListClipper_Step(clipper: *mut ImGuiListClipper) -> bool; pub fn ImGuiListClipper_GetDisplayStart(clipper: *mut ImGuiListClipper) -> c_int; @@ -1755,10 +1902,12 @@ extern "C" { pub fn ImDrawList_Clear(list: *mut ImDrawList); pub fn ImDrawList_ClearFreeMemory(list: *mut ImDrawList); - pub fn ImDrawList_PushClipRect(list: *mut ImDrawList, - clip_rect_min: ImVec2, - clip_rect_max: ImVec2, - intersect_with_current_: bool); + pub fn ImDrawList_PushClipRect( + list: *mut ImDrawList, + clip_rect_min: ImVec2, + clip_rect_max: ImVec2, + intersect_with_current_: bool, + ); pub fn ImDrawList_PushClipRectFullScreen(list: *mut ImDrawList); pub fn ImDrawList_PopClipRect(list: *mut ImDrawList); pub fn ImDrawList_PushTextureID(list: *mut ImDrawList, texture_id: ImTextureID); @@ -1766,175 +1915,225 @@ extern "C" { pub fn ImDrawList_GetClipRectMin(out: *mut ImVec2, list: *mut ImDrawList); pub fn ImDrawList_GetClipRectMax(out: *mut ImVec2, list: *mut ImDrawList); - pub fn ImDrawList_AddLine(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - thickness: c_float); - pub fn ImDrawList_AddRect(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - rounding: c_float, - rounding_corners_flags: c_int, - thickness: c_float); - pub fn ImDrawList_AddRectFilled(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col: ImU32, - rounding: c_float, - rounding_corners_flags: c_int); - pub fn ImDrawList_AddRectFilledMultiColor(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - col_upr_left: ImU32, - col_upr_right: ImU32, - col_bot_right: ImU32, - col_bot_left: ImU32); - pub fn ImDrawList_AddQuad(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - col: ImU32, - thickness: c_float); - pub fn ImDrawList_AddQuadFilled(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - col: ImU32); - pub fn ImDrawList_AddTriangle(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - col: ImU32, - thickness: c_float); - pub fn ImDrawList_AddTriangleFilled(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - col: ImU32); - pub fn ImDrawList_AddCircle(list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - col: ImU32, - num_segments: c_int); - pub fn ImDrawList_AddCircleFilled(list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - col: ImU32, - num_segments: c_int); - pub fn ImDrawList_AddText(list: *mut ImDrawList, - pos: ImVec2, - col: ImU32, - text_begin: *const c_char, - text_end: *const c_char); - pub fn ImDrawList_AddTextExt(list: *mut ImDrawList, - font: *const ImFont, - font_size: c_float, - pos: ImVec2, - col: ImU32, - text_begin: *const c_char, - text_end: *const c_char, - wrap_width: c_float, - cpu_fine_clip_rect: *const ImVec4); - pub fn ImDrawList_AddImage(list: *mut ImDrawList, - user_texture_id: ImTextureID, - a: ImVec2, - b: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - col: ImU32); - pub fn ImDrawList_AddImageQuad(list: *mut ImDrawList, - user_texture_id: ImTextureID, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - uv_c: ImVec2, - uv_d: ImVec2, - col: ImU32); - pub fn ImDrawList_AddPolyLine(list: *mut ImDrawList, - points: *const ImVec2, - num_points: c_int, - col: ImU32, - closed: bool, - thickness: c_float, - anti_aliased: bool); - pub fn ImDrawList_AddConvexPolyFilled(list: *mut ImDrawList, - points: *const ImVec2, - num_points: c_int, - col: ImU32, - anti_aliased: bool); - pub fn ImDrawList_AddBezierCurve(list: *mut ImDrawList, - pos0: ImVec2, - cp0: ImVec2, - cp1: ImVec2, - pos1: ImVec2, - col: ImU32, - thickness: c_float, - num_segments: c_int); + pub fn ImDrawList_AddLine( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddRect( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + rounding: c_float, + rounding_corners_flags: c_int, + thickness: c_float, + ); + pub fn ImDrawList_AddRectFilled( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col: ImU32, + rounding: c_float, + rounding_corners_flags: c_int, + ); + pub fn ImDrawList_AddRectFilledMultiColor( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + col_upr_left: ImU32, + col_upr_right: ImU32, + col_bot_right: ImU32, + col_bot_left: ImU32, + ); + pub fn ImDrawList_AddQuad( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddQuadFilled( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddTriangle( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + col: ImU32, + thickness: c_float, + ); + pub fn ImDrawList_AddTriangleFilled( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddCircle( + list: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + col: ImU32, + num_segments: c_int, + ); + pub fn ImDrawList_AddCircleFilled( + list: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + col: ImU32, + num_segments: c_int, + ); + pub fn ImDrawList_AddText( + list: *mut ImDrawList, + pos: ImVec2, + col: ImU32, + text_begin: *const c_char, + text_end: *const c_char, + ); + pub fn ImDrawList_AddTextExt( + list: *mut ImDrawList, + font: *const ImFont, + font_size: c_float, + pos: ImVec2, + col: ImU32, + text_begin: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + cpu_fine_clip_rect: *const ImVec4, + ); + pub fn ImDrawList_AddImage( + list: *mut ImDrawList, + user_texture_id: ImTextureID, + a: ImVec2, + b: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddImageQuad( + list: *mut ImDrawList, + user_texture_id: ImTextureID, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + uv_c: ImVec2, + uv_d: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_AddPolyLine( + list: *mut ImDrawList, + points: *const ImVec2, + num_points: c_int, + col: ImU32, + closed: bool, + thickness: c_float, + anti_aliased: bool, + ); + pub fn ImDrawList_AddConvexPolyFilled( + list: *mut ImDrawList, + points: *const ImVec2, + num_points: c_int, + col: ImU32, + anti_aliased: bool, + ); + pub fn ImDrawList_AddBezierCurve( + list: *mut ImDrawList, + pos0: ImVec2, + cp0: ImVec2, + cp1: ImVec2, + pos1: ImVec2, + col: ImU32, + thickness: c_float, + num_segments: c_int, + ); pub fn ImDrawList_PathClear(list: *mut ImDrawList); pub fn ImDrawList_PathLineTo(list: *mut ImDrawList, pos: ImVec2); pub fn ImDrawList_PathLineToMergeDuplicate(list: *mut ImDrawList, pos: ImVec2); pub fn ImDrawList_PathFillConvex(list: *mut ImDrawList, col: ImU32); - pub fn ImDrawList_PathStroke(list: *mut ImDrawList, - col: ImU32, - closed: bool, - thickness: c_float); - pub fn ImDrawList_PathArcTo(list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - a_min: c_float, - a_max: c_float, - num_segments: c_int); - pub fn ImDrawList_PathArcToFast(list: *mut ImDrawList, - centre: ImVec2, - radius: c_float, - a_min_of_12: c_int, - a_max_of_12: c_int); - pub fn ImDrawList_PathBezierCurveTo(list: *mut ImDrawList, - p1: ImVec2, - p2: ImVec2, - p3: ImVec2, - num_segments: c_int); - pub fn ImDrawList_PathRect(list: *mut ImDrawList, - rect_min: ImVec2, - rect_max: ImVec2, - rounding: c_float, - rounding_corners_flags: c_int); + pub fn ImDrawList_PathStroke( + list: *mut ImDrawList, + col: ImU32, + closed: bool, + thickness: c_float, + ); + pub fn ImDrawList_PathArcTo( + list: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + a_min: c_float, + a_max: c_float, + num_segments: c_int, + ); + pub fn ImDrawList_PathArcToFast( + list: *mut ImDrawList, + centre: ImVec2, + radius: c_float, + a_min_of_12: c_int, + a_max_of_12: c_int, + ); + pub fn ImDrawList_PathBezierCurveTo( + list: *mut ImDrawList, + p1: ImVec2, + p2: ImVec2, + p3: ImVec2, + num_segments: c_int, + ); + pub fn ImDrawList_PathRect( + list: *mut ImDrawList, + rect_min: ImVec2, + rect_max: ImVec2, + rounding: c_float, + rounding_corners_flags: c_int, + ); pub fn ImDrawList_ChannelsSplit(list: *mut ImDrawList, channels_count: c_int); pub fn ImDrawList_ChannelsMerge(list: *mut ImDrawList); pub fn ImDrawList_ChannelsSetCurrent(list: *mut ImDrawList, channel_index: c_int); - pub fn ImDrawList_AddCallback(list: *mut ImDrawList, - callback: ImDrawCallback, - callback_data: *mut c_void); + pub fn ImDrawList_AddCallback( + list: *mut ImDrawList, + callback: ImDrawCallback, + callback_data: *mut c_void, + ); pub fn ImDrawList_AddDrawCmd(list: *mut ImDrawList); pub fn ImDrawList_PrimReserve(list: *mut ImDrawList, idx_count: c_int, vtx_count: c_int); pub fn ImDrawList_PrimRect(list: *mut ImDrawList, a: ImVec2, b: ImVec2, col: ImU32); - pub fn ImDrawList_PrimRectUV(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - col: ImU32); - pub fn ImDrawList_PrimQuadUV(list: *mut ImDrawList, - a: ImVec2, - b: ImVec2, - c: ImVec2, - d: ImVec2, - uv_a: ImVec2, - uv_b: ImVec2, - uv_c: ImVec2, - uv_d: ImVec2, - col: ImU32); + pub fn ImDrawList_PrimRectUV( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + col: ImU32, + ); + pub fn ImDrawList_PrimQuadUV( + list: *mut ImDrawList, + a: ImVec2, + b: ImVec2, + c: ImVec2, + d: ImVec2, + uv_a: ImVec2, + uv_b: ImVec2, + uv_c: ImVec2, + uv_d: ImVec2, + col: ImU32, + ); pub fn ImDrawList_PrimWriteVtx(list: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); pub fn ImDrawList_PrimWriteIdx(list: *mut ImDrawList, idx: ImDrawIdx); pub fn ImDrawList_PrimVtx(list: *mut ImDrawList, pos: ImVec2, uv: ImVec2, col: ImU32); @@ -1949,49 +2148,59 @@ extern "C" { } extern "C" { - pub fn ImFontAtlas_GetTexDataAsRGBA32(atlas: *mut ImFontAtlas, - out_pixels: *mut *mut c_uchar, - out_width: *mut c_int, - out_height: *mut c_int, - out_bytes_per_pixel: *mut c_int); - pub fn ImFontAtlas_GetTexDataAsAlpha8(atlas: *mut ImFontAtlas, - out_pixels: *mut *mut c_uchar, - out_width: *mut c_int, - out_height: *mut c_int, - out_bytes_per_pixel: *mut c_int); + pub fn ImFontAtlas_GetTexDataAsRGBA32( + atlas: *mut ImFontAtlas, + out_pixels: *mut *mut c_uchar, + out_width: *mut c_int, + out_height: *mut c_int, + out_bytes_per_pixel: *mut c_int, + ); + pub fn ImFontAtlas_GetTexDataAsAlpha8( + atlas: *mut ImFontAtlas, + out_pixels: *mut *mut c_uchar, + out_width: *mut c_int, + out_height: *mut c_int, + out_bytes_per_pixel: *mut c_int, + ); pub fn ImFontAtlas_SetTexID(atlas: *mut ImFontAtlas, tex: ImTextureID); - pub fn ImFontAtlas_AddFont(atlas: *mut ImFontAtlas, - font_cfg: *const ImFontConfig) - -> *mut ImFont; - pub fn ImFontAtlas_AddFontDefault(atlas: *mut ImFontAtlas, - font_cfg: *const ImFontConfig) - -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromFileTTF(atlas: *mut ImFontAtlas, - filename: *const c_char, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar) - -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromMemoryTTF(atlas: *mut ImFontAtlas, - font_data: *mut c_void, - font_size: c_int, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar) - -> *mut ImFont; - pub fn ImFontAtlas_AddFontFromMemoryCompressedTTF(atlas: *mut ImFontAtlas, - compressed_font_data: *const c_void, - compressed_font_size: c_int, - size_pixels: c_float, - font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar) - -> *mut ImFont; + pub fn ImFontAtlas_AddFont( + atlas: *mut ImFontAtlas, + font_cfg: *const ImFontConfig, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontDefault( + atlas: *mut ImFontAtlas, + font_cfg: *const ImFontConfig, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromFileTTF( + atlas: *mut ImFontAtlas, + filename: *const c_char, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromMemoryTTF( + atlas: *mut ImFontAtlas, + font_data: *mut c_void, + font_size: c_int, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; + pub fn ImFontAtlas_AddFontFromMemoryCompressedTTF( + atlas: *mut ImFontAtlas, + compressed_font_data: *const c_void, + compressed_font_size: c_int, + size_pixels: c_float, + font_cfg: *const ImFontConfig, + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; pub fn ImFontAtlas_AddFontFromMemoryCompressedBase85TTF( atlas: *mut ImFontAtlas, compressed_font_data_base85: *const c_char, size_pixels: c_float, font_cfg: *const ImFontConfig, - glyph_ranges: *const ImWchar) -> *mut ImFont; + glyph_ranges: *const ImWchar, + ) -> *mut ImFont; pub fn ImFontAtlas_ClearTexData(atlas: *mut ImFontAtlas); pub fn ImFontAtlas_Clear(atlas: *mut ImFontAtlas); pub fn ImFontAtlas_GetGlyphRangesDefault(atlas: *mut ImFontAtlas) -> *const ImWchar; @@ -2041,19 +2250,43 @@ extern "C" { pub fn ImFont_SetFallbackChar(font: *mut ImFont, c: ImWchar); pub fn ImFont_GetCharAdvance(font: *const ImFont, c: ImWchar) -> c_float; pub fn ImFont_IsLoaded(font: *const ImFont) -> bool; - pub fn ImFont_CalcTextSizeA(font: *const ImFont, out: *mut ImVec2, size: c_float, - max_width: c_float, wrap_width: c_float, - text_begin: *const c_char, text_end: *const c_char, - remaining: *mut *const c_char); - pub fn ImFont_CalcWordWrapPositionA(font: *const ImFont, scale: c_float, - text: *const c_char, text_end: *const c_char, - wrap_width: c_float) -> *const c_char; - pub fn ImFont_RenderChar(font: *const ImFont, draw_list: *mut ImDrawList, size: c_float, - pos: ImVec2, col: ImU32, c: c_ushort); - pub fn ImFont_RenderText(font: *const ImFont, draw_list: *mut ImDrawList, size: c_float, - pos: ImVec2, col: ImU32, clip_rect: *const ImVec4, - text_begin: *const c_char, text_end: *const c_char, - wrap_width: c_float, cpu_fine_clip: bool); + pub fn ImFont_CalcTextSizeA( + font: *const ImFont, + out: *mut ImVec2, + size: c_float, + max_width: c_float, + wrap_width: c_float, + text_begin: *const c_char, + text_end: *const c_char, + remaining: *mut *const c_char, + ); + pub fn ImFont_CalcWordWrapPositionA( + font: *const ImFont, + scale: c_float, + text: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + ) -> *const c_char; + pub fn ImFont_RenderChar( + font: *const ImFont, + draw_list: *mut ImDrawList, + size: c_float, + pos: ImVec2, + col: ImU32, + c: c_ushort, + ); + pub fn ImFont_RenderText( + font: *const ImFont, + draw_list: *mut ImDrawList, + size: c_float, + pos: ImVec2, + col: ImU32, + clip_rect: *const ImVec4, + text_begin: *const c_char, + text_end: *const c_char, + wrap_width: c_float, + cpu_fine_clip: bool, + ); } // ImFont::Glyph diff --git a/src/child_frame.rs b/src/child_frame.rs index 4579214..c0837d3 100644 --- a/src/child_frame.rs +++ b/src/child_frame.rs @@ -107,7 +107,9 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> { // https://github.com/Gekkio/imgui-rs/pull/58 let show_border = false; - let render_child_frame = unsafe { imgui_sys::igBeginChild(self.name.as_ptr(), self.size, show_border, self.flags) }; + let render_child_frame = unsafe { + imgui_sys::igBeginChild(self.name.as_ptr(), self.size, show_border, self.flags) + }; if render_child_frame { f(); } diff --git a/src/input.rs b/src/input.rs index bc38a2d..14ed5cc 100644 --- a/src/input.rs +++ b/src/input.rs @@ -143,12 +143,14 @@ impl<'ui, 'p> InputText<'ui, 'p> { pub fn build(self) -> bool { unsafe { - imgui_sys::igInputText(self.label.as_ptr(), - self.buf.as_mut_ptr(), - self.buf.capacity_with_nul(), - self.flags, - None, - ptr::null_mut()) + imgui_sys::igInputText( + self.label.as_ptr(), + self.buf.as_mut_ptr(), + self.buf.capacity_with_nul(), + self.flags, + None, + ptr::null_mut(), + ) } } } @@ -177,11 +179,13 @@ impl<'ui, 'p> InputInt<'ui, 'p> { pub fn build(self) -> bool { unsafe { - imgui_sys::igInputInt(self.label.as_ptr(), - self.value as *mut i32, - self.step, - self.step_fast, - self.flags) + imgui_sys::igInputInt( + self.label.as_ptr(), + self.value as *mut i32, + self.step, + self.step_fast, + self.flags, + ) } } @@ -215,12 +219,14 @@ impl<'ui, 'p> InputFloat<'ui, 'p> { pub fn build(self) -> bool { unsafe { - imgui_sys::igInputFloat(self.label.as_ptr(), - self.value as *mut f32, - self.step, - self.step_fast, - self.decimal_precision, - self.flags) + imgui_sys::igInputFloat( + self.label.as_ptr(), + self.value as *mut f32, + self.step, + self.step_fast, + self.decimal_precision, + self.flags, + ) } } diff --git a/src/lib.rs b/src/lib.rs index 3ca8df1..38f94d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,25 +9,24 @@ use std::str; use imgui_sys::ImGuiStyleVar; #[allow(deprecated)] -pub use imgui_sys::{ImGuiInputTextFlags_AllowTabInput, - ImGuiInputTextFlags_AlwaysInsertMode, ImGuiInputTextFlags_AutoSelectAll, - ImGuiInputTextFlags_CallbackAlways, ImGuiInputTextFlags_CallbackCharFilter, +pub use imgui_sys::{ImGuiInputTextFlags_AllowTabInput, ImGuiInputTextFlags_AlwaysInsertMode, + ImGuiInputTextFlags_AutoSelectAll, ImGuiInputTextFlags_CallbackAlways, + ImGuiInputTextFlags_CallbackCharFilter, ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackHistory, ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal, ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsUppercase, ImGuiInputTextFlags_CtrlEnterForNewLine, ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_NoHorizontalScroll, ImGuiInputTextFlags_Password, - ImGuiInputTextFlags_ReadOnly, - ImGuiSelectableFlags_DontClosePopups, ImGuiSelectableFlags_SpanAllColumns, - ImGuiSetCond_Always, ImGuiSetCond_Appearing, - ImGuiSetCond_FirstUseEver, ImGuiSetCond_Once, + ImGuiInputTextFlags_ReadOnly, ImGuiSelectableFlags_DontClosePopups, + ImGuiSelectableFlags_SpanAllColumns, ImGuiSetCond_Always, + ImGuiSetCond_Appearing, ImGuiSetCond_FirstUseEver, ImGuiSetCond_Once, ImGuiTreeNodeFlags_AllowOverlapMode, ImGuiTreeNodeFlags_Bullet, ImGuiTreeNodeFlags_CollapsingHeader, ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Framed, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_NoAutoOpenOnLog, ImGuiTreeNodeFlags_NoTreePushOnOpen, ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick, - ImGuiTreeNodeFlags_Selected, - ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_AlwaysHorizontalScrollbar, + ImGuiTreeNodeFlags_Selected, ImGuiWindowFlags_AlwaysAutoResize, + ImGuiWindowFlags_AlwaysHorizontalScrollbar, ImGuiWindowFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_AlwaysVerticalScrollbar, ImGuiWindowFlags_HorizontalScrollbar, ImGuiWindowFlags_MenuBar, @@ -39,10 +38,11 @@ pub use imgui_sys::{ImGuiInputTextFlags_AllowTabInput, ImGuiWindowFlags_ShowBorders}; pub use imgui_sys::{ImDrawIdx, ImDrawVert, ImGuiInputTextFlags, ImGuiKey, ImGuiSelectableFlags, - ImGuiCond, ImGuiCol, ImGuiStyle, ImGuiTreeNodeFlags, ImGuiWindowFlags, - ImVec2, ImVec4}; + ImGuiCond, ImGuiCol, ImGuiStyle, ImGuiTreeNodeFlags, ImGuiWindowFlags, ImVec2, + ImVec4}; pub use child_frame::ChildFrame; -pub use input::{InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, InputInt4, InputText}; +pub use input::{InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, + InputInt4, InputText}; pub use menus::{Menu, MenuItem}; pub use plothistogram::PlotHistogram; pub use plotlines::PlotLines; @@ -113,7 +113,8 @@ impl ImGui { pub fn style(&self) -> &ImGuiStyle { unsafe { &*imgui_sys::igGetStyle() } } pub fn style_mut(&mut self) -> &mut ImGuiStyle { unsafe { &mut *imgui_sys::igGetStyle() } } pub fn prepare_texture<'a, F, T>(&mut self, f: F) -> T - where F: FnOnce(TextureHandle<'a>) -> T + where + F: FnOnce(TextureHandle<'a>) -> T, { let io = self.io(); let mut pixels: *mut c_uchar = ptr::null_mut(); @@ -121,17 +122,18 @@ impl ImGui { let mut height: c_int = 0; let mut bytes_per_pixel: c_int = 0; unsafe { - imgui_sys::ImFontAtlas_GetTexDataAsRGBA32(io.fonts, - &mut pixels, - &mut width, - &mut height, - &mut bytes_per_pixel); + imgui_sys::ImFontAtlas_GetTexDataAsRGBA32( + io.fonts, + &mut pixels, + &mut width, + &mut height, + &mut bytes_per_pixel, + ); f(TextureHandle { - width: width as u32, - height: height as u32, - pixels: slice::from_raw_parts(pixels, - (width * height * bytes_per_pixel) as usize), - }) + width: width as u32, + height: height as u32, + pixels: slice::from_raw_parts(pixels, (width * height * bytes_per_pixel) as usize), + }) } } pub fn set_texture_id(&mut self, value: usize) { @@ -193,7 +195,10 @@ impl ImGui { } pub fn display_framebuffer_scale(&self) -> (f32, f32) { let io = self.io(); - (io.display_framebuffer_scale.x, io.display_framebuffer_scale.y) + ( + io.display_framebuffer_scale.x, + io.display_framebuffer_scale.y, + ) } pub fn mouse_pos(&self) -> (f32, f32) { let io = self.io(); @@ -250,11 +255,12 @@ impl ImGui { pub fn get_time(&self) -> f32 { unsafe { imgui_sys::igGetTime() } } pub fn get_frame_count(&self) -> i32 { unsafe { imgui_sys::igGetFrameCount() } } pub fn get_frame_rate(&self) -> f32 { self.io().framerate } - pub fn frame<'ui, 'a: 'ui>(&'a mut self, - size_points: (u32, u32), - size_pixels: (u32, u32), - delta_time: f32) - -> Ui<'ui> { + pub fn frame<'ui, 'a: 'ui>( + &'a mut self, + size_points: (u32, u32), + size_pixels: (u32, u32), + delta_time: f32, + ) -> Ui<'ui> { { let io = self.io_mut(); io.display_size.x = size_points.0 as c_float; @@ -335,7 +341,8 @@ impl<'ui> Ui<'ui> { io.metrics_active_windows } pub fn render(self, mut f: F) -> Result<(), E> - where F: FnMut(&Ui, DrawList) -> Result<(), E> + where + F: FnMut(&Ui, DrawList) -> Result<(), E>, { unsafe { imgui_sys::igRender(); @@ -396,7 +403,8 @@ impl<'ui> Ui<'ui> { /// Runs a function after temporarily pushing a value to the item width stack. pub fn with_item_width(&self, width: f32, f: F) - where F: FnOnce() + where + F: FnOnce(), { self.push_item_width(width); f(); @@ -447,7 +455,8 @@ impl<'ui> Ui<'ui> { /// Runs a function after temporarily pushing a value to the ID stack. pub fn with_id(&self, id: i32, f: F) - where F: FnOnce() + where + F: FnOnce(), { self.push_id(id); f(); @@ -464,7 +473,8 @@ impl<'ui> Ui<'ui> { } } pub fn text_colored<'p, A>(&self, col: A, text: &'p ImStr) - where A: Into + where + A: Into, { unsafe { imgui_sys::igTextColored(col.into(), fmt_ptr(), text.as_ptr()); @@ -514,22 +524,25 @@ impl<'ui> Ui<'ui> { pub fn input_float<'p>(&self, label: &'p ImStr, value: &'p mut f32) -> InputFloat<'ui, 'p> { InputFloat::new(self, label, value) } - pub fn input_float2<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 2]) - -> InputFloat2<'ui, 'p> { + pub fn input_float2<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 2], + ) -> InputFloat2<'ui, 'p> { InputFloat2::new(self, label, value) } - pub fn input_float3<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 3]) - -> InputFloat3<'ui, 'p> { + pub fn input_float3<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 3], + ) -> InputFloat3<'ui, 'p> { InputFloat3::new(self, label, value) } - pub fn input_float4<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 4]) - -> InputFloat4<'ui, 'p> { + pub fn input_float4<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 4], + ) -> InputFloat4<'ui, 'p> { InputFloat4::new(self, label, value) } pub fn input_int<'p>(&self, label: &'p ImStr, value: &'p mut i32) -> InputInt<'ui, 'p> { @@ -548,68 +561,76 @@ impl<'ui> Ui<'ui> { // Widgets: Sliders impl<'ui> Ui<'ui> { - pub fn slider_float<'p>(&self, - label: &'p ImStr, - value: &'p mut f32, - min: f32, - max: f32) - -> SliderFloat<'ui, 'p> { + pub fn slider_float<'p>( + &self, + label: &'p ImStr, + value: &'p mut f32, + min: f32, + max: f32, + ) -> SliderFloat<'ui, 'p> { SliderFloat::new(self, label, value, min, max) } - pub fn slider_float2<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 2], - min: f32, - max: f32) - -> SliderFloat2<'ui, 'p> { + pub fn slider_float2<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 2], + min: f32, + max: f32, + ) -> SliderFloat2<'ui, 'p> { SliderFloat2::new(self, label, value, min, max) } - pub fn slider_float3<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 3], - min: f32, - max: f32) - -> SliderFloat3<'ui, 'p> { + pub fn slider_float3<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 3], + min: f32, + max: f32, + ) -> SliderFloat3<'ui, 'p> { SliderFloat3::new(self, label, value, min, max) } - pub fn slider_float4<'p>(&self, - label: &'p ImStr, - value: &'p mut [f32; 4], - min: f32, - max: f32) - -> SliderFloat4<'ui, 'p> { + pub fn slider_float4<'p>( + &self, + label: &'p ImStr, + value: &'p mut [f32; 4], + min: f32, + max: f32, + ) -> SliderFloat4<'ui, 'p> { SliderFloat4::new(self, label, value, min, max) } - pub fn slider_int<'p>(&self, - label: &'p ImStr, - value: &'p mut i32, - min: i32, - max: i32) - -> SliderInt<'ui, 'p> { + pub fn slider_int<'p>( + &self, + label: &'p ImStr, + value: &'p mut i32, + min: i32, + max: i32, + ) -> SliderInt<'ui, 'p> { SliderInt::new(self, label, value, min, max) } - pub fn slider_int2<'p>(&self, - label: &'p ImStr, - value: &'p mut [i32; 2], - min: i32, - max: i32) - -> SliderInt2<'ui, 'p> { + pub fn slider_int2<'p>( + &self, + label: &'p ImStr, + value: &'p mut [i32; 2], + min: i32, + max: i32, + ) -> SliderInt2<'ui, 'p> { SliderInt2::new(self, label, value, min, max) } - pub fn slider_int3<'p>(&self, - label: &'p ImStr, - value: &'p mut [i32; 3], - min: i32, - max: i32) - -> SliderInt3<'ui, 'p> { + pub fn slider_int3<'p>( + &self, + label: &'p ImStr, + value: &'p mut [i32; 3], + min: i32, + max: i32, + ) -> SliderInt3<'ui, 'p> { SliderInt3::new(self, label, value, min, max) } - pub fn slider_int4<'p>(&self, - label: &'p ImStr, - value: &'p mut [i32; 4], - min: i32, - max: i32) - -> SliderInt4<'ui, 'p> { + pub fn slider_int4<'p>( + &self, + label: &'p ImStr, + value: &'p mut [i32; 4], + min: i32, + max: i32, + ) -> SliderInt4<'ui, 'p> { SliderInt4::new(self, label, value, min, max) } } @@ -624,12 +645,13 @@ impl<'ui> Ui<'ui> { // Widgets: Selectable / Lists impl<'ui> Ui<'ui> { - pub fn selectable<'p, S: Into>(&self, - label: &'p ImStr, - selected: bool, - flags: ImGuiSelectableFlags, - size: S) - -> bool { + pub fn selectable<'p, S: Into>( + &self, + label: &'p ImStr, + selected: bool, + flags: ImGuiSelectableFlags, + size: S, + ) -> bool { unsafe { imgui_sys::igSelectable(label.as_ptr(), selected, flags, size.into()) } } } @@ -637,7 +659,8 @@ impl<'ui> Ui<'ui> { // Widgets: Menus impl<'ui> Ui<'ui> { pub fn main_menu_bar(&self, f: F) - where F: FnOnce() + where + F: FnOnce(), { let render = unsafe { imgui_sys::igBeginMainMenuBar() }; if render { @@ -646,7 +669,8 @@ impl<'ui> Ui<'ui> { } } pub fn menu_bar(&self, f: F) - where F: FnOnce() + where + F: FnOnce(), { let render = unsafe { imgui_sys::igBeginMenuBar() }; if render { @@ -655,7 +679,9 @@ impl<'ui> Ui<'ui> { } } pub fn menu<'p>(&self, label: &'p ImStr) -> Menu<'ui, 'p> { Menu::new(self, label) } - pub fn menu_item<'p>(&self, label: &'p ImStr) -> MenuItem<'ui, 'p> { MenuItem::new(self, label) } + pub fn menu_item<'p>(&self, label: &'p ImStr) -> MenuItem<'ui, 'p> { + MenuItem::new(self, label) + } } // Widgets: Popups @@ -664,7 +690,8 @@ impl<'ui> Ui<'ui> { unsafe { imgui_sys::igOpenPopup(str_id.as_ptr()) }; } pub fn popup<'p, F>(&self, str_id: &'p ImStr, f: F) - where F: FnOnce() + where + F: FnOnce(), { let render = unsafe { imgui_sys::igBeginPopup(str_id.as_ptr()) }; if render { @@ -677,38 +704,44 @@ impl<'ui> Ui<'ui> { // Widgets: Combos impl<'ui> Ui<'ui> { - pub fn combo<'p>(&self, - label: &'p ImStr, - current_item: &mut i32, - items: &'p [&'p ImStr], - height_in_items: i32) - -> bool { + pub fn combo<'p>( + &self, + label: &'p ImStr, + current_item: &mut i32, + items: &'p [&'p ImStr], + height_in_items: i32, + ) -> bool { let items_inner: Vec<*const c_char> = items.into_iter().map(|item| item.as_ptr()).collect(); unsafe { - imgui_sys::igCombo(label.as_ptr(), - current_item, - items_inner.as_ptr() as *mut *const c_char, - items_inner.len() as i32, - height_in_items) + imgui_sys::igCombo( + label.as_ptr(), + current_item, + items_inner.as_ptr() as *mut *const c_char, + items_inner.len() as i32, + height_in_items, + ) } } } // Widgets: ListBox impl<'ui> Ui<'ui> { - pub fn list_box<'p>(&self, - label: &'p ImStr, - current_item: &mut i32, - items: &'p [&'p ImStr], - height_in_items: i32) - -> bool { + pub fn list_box<'p>( + &self, + label: &'p ImStr, + current_item: &mut i32, + items: &'p [&'p ImStr], + height_in_items: i32, + ) -> bool { let items_inner: Vec<*const c_char> = items.into_iter().map(|item| item.as_ptr()).collect(); unsafe { - imgui_sys::igListBox(label.as_ptr(), - current_item, - items_inner.as_ptr() as *mut *const c_char, - items_inner.len() as i32, - height_in_items) + imgui_sys::igListBox( + label.as_ptr(), + current_item, + items_inner.as_ptr() as *mut *const c_char, + items_inner.len() as i32, + height_in_items, + ) } } } @@ -728,13 +761,8 @@ impl<'ui> Ui<'ui> { /// ui.radio_button(im_str!("Item 2"), &mut selected_radio_value, 2); /// ui.radio_button(im_str!("Item 3"), &mut selected_radio_value, 3); /// ``` - pub fn radio_button<'p>(&self, - label: &'p ImStr, - value: &'p mut i32, - wanted: i32) -> bool { - unsafe { - imgui_sys::igRadioButton(label.as_ptr(), value, wanted) - } + pub fn radio_button<'p>(&self, label: &'p ImStr, value: &'p mut i32, wanted: i32) -> bool { + unsafe { imgui_sys::igRadioButton(label.as_ptr(), value, wanted) } } /// Creates a radio button that shows as selected if the given value is true. @@ -754,9 +782,7 @@ impl<'ui> Ui<'ui> { /// } /// ``` pub fn radio_button_bool<'p>(&self, label: &'p ImStr, value: bool) -> bool { - unsafe { - imgui_sys::igRadioButtonBool(label.as_ptr(), value) - } + unsafe { imgui_sys::igRadioButtonBool(label.as_ptr(), value) } } } @@ -767,7 +793,11 @@ impl<'ui> Ui<'ui> { } impl<'ui> Ui<'ui> { - pub fn plot_histogram<'p>(&self, label: &'p ImStr, values: &'p [f32]) -> PlotHistogram<'ui, 'p> { + pub fn plot_histogram<'p>( + &self, + label: &'p ImStr, + values: &'p [f32], + ) -> PlotHistogram<'ui, 'p> { PlotHistogram::new(self, label, values) } } @@ -779,9 +809,22 @@ impl<'ui> Ui<'ui> { /// This is a feature of imgui. /// /// wrap_width allows you to request a width at which to wrap the text to a newline for the calculation. - pub fn calc_text_size(&self, text: &ImStr, hide_text_after_double_hash: bool, wrap_width: f32) -> ImVec2 { + pub fn calc_text_size( + &self, + text: &ImStr, + hide_text_after_double_hash: bool, + wrap_width: f32, + ) -> ImVec2 { let mut buffer = ImVec2::new(0.0, 0.0); - unsafe { imgui_sys::igCalcTextSize(&mut buffer as *mut ImVec2, text.as_ptr(), std::ptr::null(), hide_text_after_double_hash, wrap_width); } + unsafe { + imgui_sys::igCalcTextSize( + &mut buffer as *mut ImVec2, + text.as_ptr(), + std::ptr::null(), + hide_text_after_double_hash, + wrap_width, + ); + } buffer } } @@ -799,31 +842,39 @@ impl<'ui> Ui<'ui> { /// .overlay_text(im_str!("Progress!")) /// .build(); /// ``` - pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'ui, 'p> { ProgressBar::new(self, fraction) } + pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'ui, 'p> { + ProgressBar::new(self, fraction) + } } impl<'ui> Ui<'ui> { - /// Creates a child frame. Size is size of child_frame within parent window. - /// - /// # Example - /// ```rust,no_run - /// # use imgui::*; - /// # let mut imgui = ImGui::init(); - /// # let ui = imgui.frame((0, 0), (0, 0), 0.1); - /// ui.window(im_str!("ChatWindow")) - /// .title_bar(true) - /// .scrollable(false) - /// .build(|| { - /// ui.separator(); - /// - /// ui.child_frame(im_str!("child frame"), (400.0, 100.0)) - /// .show_borders(true) - /// .always_show_vertical_scroll_bar(true) - /// .build(|| { - /// ui.text_colored((1.0, 0.0, 0.0, 1.0), im_str!("hello mate!")); - /// }); - /// }); - pub fn child_frame<'p, S: Into>(&self, name: &'p ImStr, size: S) -> ChildFrame<'ui, 'p> { ChildFrame::new(self, name, size.into()) } + /// Creates a child frame. Size is size of child_frame within parent window. + /// + /// # Example + /// ```rust,no_run + /// # use imgui::*; + /// # let mut imgui = ImGui::init(); + /// # let ui = imgui.frame((0, 0), (0, 0), 0.1); + /// ui.window(im_str!("ChatWindow")) + /// .title_bar(true) + /// .scrollable(false) + /// .build(|| { + /// ui.separator(); + /// + /// ui.child_frame(im_str!("child frame"), (400.0, 100.0)) + /// .show_borders(true) + /// .always_show_vertical_scroll_bar(true) + /// .build(|| { + /// ui.text_colored((1.0, 0.0, 0.0, 1.0), im_str!("hello mate!")); + /// }); + /// }); + pub fn child_frame<'p, S: Into>( + &self, + name: &'p ImStr, + size: S, + ) -> ChildFrame<'ui, 'p> { + ChildFrame::new(self, name, size.into()) + } } impl<'ui> Ui<'ui> { @@ -877,14 +928,16 @@ impl<'ui> Ui<'ui> { WindowPadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowPadding, v) }, WindowRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowRounding, v) }, WindowMinSize(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowMinSize, v) }, - ChildWindowRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::ChildWindowRounding, v) }, + ChildWindowRounding(v) => unsafe { + igPushStyleVar(ImGuiStyleVar::ChildWindowRounding, v) + }, FramePadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::FramePadding, v) }, FrameRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameRounding, v) }, ItemSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemSpacing, v) }, ItemInnerSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemInnerSpacing, v) }, IndentSpacing(v) => unsafe { igPushStyleVar(ImGuiStyleVar::IndentSpacing, v) }, GrabMinSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::GrabMinSize, v) }, - ButtonTextAlign(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ButtonTextAlign, v) } + ButtonTextAlign(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ButtonTextAlign, v) }, } } } @@ -901,10 +954,19 @@ impl<'ui> Ui<'ui> { /// ui.text_wrapped(im_str!("AB")); /// }); /// ``` - pub fn with_color_var + Copy>(&self, var: ImGuiCol, color: C, f: F) { - unsafe { imgui_sys::igPushStyleColor(var, color.into()); } + pub fn with_color_var + Copy>( + &self, + var: ImGuiCol, + color: C, + f: F, + ) { + unsafe { + imgui_sys::igPushStyleColor(var, color.into()); + } f(); - unsafe {imgui_sys::igPopStyleColor(1); } + unsafe { + imgui_sys::igPopStyleColor(1); + } } /// Runs a function after temporarily pushing an array of values to the color stack. @@ -921,9 +983,15 @@ impl<'ui> Ui<'ui> { /// ui.text_wrapped(im_str!("AB")); /// }); /// ``` - pub fn with_color_vars + Copy>(&self, color_vars: &[(ImGuiCol, C)], f: F) { + pub fn with_color_vars + Copy>( + &self, + color_vars: &[(ImGuiCol, C)], + f: F, + ) { for &(color_var, color) in color_vars { - unsafe { imgui_sys::igPushStyleColor(color_var, color.into()); } + unsafe { + imgui_sys::igPushStyleColor(color_var, color.into()); + } } f(); unsafe { imgui_sys::igPopStyleColor(color_vars.len() as i32) }; diff --git a/src/menus.rs b/src/menus.rs index 8598ee1..155ca7b 100644 --- a/src/menus.rs +++ b/src/menus.rs @@ -70,9 +70,9 @@ impl<'ui, 'p> MenuItem<'ui, 'p> { pub fn build(self) -> bool { let label = self.label.as_ptr(); let shortcut = self.shortcut.map(|x| x.as_ptr()).unwrap_or(ptr::null()); - let selected = self.selected - .map(|x| x as *mut bool) - .unwrap_or(ptr::null_mut()); + let selected = self.selected.map(|x| x as *mut bool).unwrap_or( + ptr::null_mut(), + ); let enabled = self.enabled; unsafe { imgui_sys::igMenuItemPtr(label, shortcut, selected, enabled) } } diff --git a/src/plothistogram.rs b/src/plothistogram.rs index a00ebd3..30b8311 100644 --- a/src/plothistogram.rs +++ b/src/plothistogram.rs @@ -63,17 +63,17 @@ impl<'ui, 'p> PlotHistogram<'ui, 'p> { pub fn build(self) { unsafe { - imgui_sys::igPlotHistogram(self.label.as_ptr(), - self.values.as_ptr() as *const c_float, - self.values.len() as i32, - self.values_offset as i32, - self.overlay_text - .map(|x| x.as_ptr()) - .unwrap_or(ptr::null()), - self.scale_min, - self.scale_max, - self.graph_size, - mem::size_of::() as i32); + imgui_sys::igPlotHistogram( + self.label.as_ptr(), + self.values.as_ptr() as *const c_float, + self.values.len() as i32, + self.values_offset as i32, + self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()), + self.scale_min, + self.scale_max, + self.graph_size, + mem::size_of::() as i32, + ); } } } diff --git a/src/plotlines.rs b/src/plotlines.rs index a9c562d..e339272 100644 --- a/src/plotlines.rs +++ b/src/plotlines.rs @@ -63,17 +63,17 @@ impl<'ui, 'p> PlotLines<'ui, 'p> { pub fn build(self) { unsafe { - imgui_sys::igPlotLines(self.label.as_ptr(), - self.values.as_ptr() as *const c_float, - self.values.len() as i32, - self.values_offset as i32, - self.overlay_text - .map(|x| x.as_ptr()) - .unwrap_or(ptr::null()), - self.scale_min, - self.scale_max, - self.graph_size, - mem::size_of::() as i32); + imgui_sys::igPlotLines( + self.label.as_ptr(), + self.values.as_ptr() as *const c_float, + self.values.len() as i32, + self.values_offset as i32, + self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()), + self.scale_min, + self.scale_max, + self.graph_size, + mem::size_of::() as i32, + ); } } } diff --git a/src/progressbar.rs b/src/progressbar.rs index 112935c..b6408f9 100644 --- a/src/progressbar.rs +++ b/src/progressbar.rs @@ -49,11 +49,11 @@ impl<'ui, 'p> ProgressBar<'ui, 'p> { /// of the progress bar, otherwise the it will not be shown. pub fn build(self) { unsafe { - imgui_sys::igProgressBar(self.fraction, - &self.size, - self.overlay_text - .map(|x| x.as_ptr()) - .unwrap_or(ptr::null())); + imgui_sys::igProgressBar( + self.fraction, + &self.size, + self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()), + ); } } } diff --git a/src/sliders.rs b/src/sliders.rs index bcb6899..f648706 100644 --- a/src/sliders.rs +++ b/src/sliders.rs @@ -33,11 +33,13 @@ impl<'ui, 'p> SliderInt<'ui, 'p> { } pub fn build(self) -> bool { unsafe { - imgui_sys::igSliderInt(self.label.as_ptr(), - self.value, - self.min, - self.max, - self.display_format.as_ptr()) + imgui_sys::igSliderInt( + self.label.as_ptr(), + self.value, + self.min, + self.max, + self.display_format.as_ptr(), + ) } } } @@ -123,12 +125,14 @@ impl<'ui, 'p> SliderFloat<'ui, 'p> { } pub fn build(self) -> bool { unsafe { - imgui_sys::igSliderFloat(self.label.as_ptr(), - self.value, - self.min, - self.max, - self.display_format.as_ptr(), - self.power) + imgui_sys::igSliderFloat( + self.label.as_ptr(), + self.value, + self.min, + self.max, + self.display_format.as_ptr(), + self.power, + ) } } } diff --git a/src/string.rs b/src/string.rs index fc9f28a..f6c78e6 100644 --- a/src/string.rs +++ b/src/string.rs @@ -1,5 +1,5 @@ use std::borrow::Borrow; -use std::ffi::{CStr}; +use std::ffi::CStr; use std::fmt; use std::mem; use std::ops::Deref; @@ -22,9 +22,7 @@ impl ImString { v.push(b'\0'); ImString(v) } - pub unsafe fn from_utf8_with_nul_unchecked(v: Vec) -> ImString { - ImString(v) - } + pub unsafe fn from_utf8_with_nul_unchecked(v: Vec) -> ImString { ImString(v) } pub fn clear(&mut self) { self.0.clear(); self.0.push(b'\0'); @@ -40,12 +38,8 @@ impl ImString { } pub fn capacity(&self) -> usize { self.0.capacity() - 1 } pub fn capacity_with_nul(&self) -> usize { self.0.capacity() } - pub fn reserve(&mut self, additional: usize) { - self.0.reserve(additional); - } - pub fn reserve_exact(&mut self, additional: usize) { - self.0.reserve_exact(additional); - } + pub fn reserve(&mut self, additional: usize) { self.0.reserve(additional); } + pub fn reserve_exact(&mut self, additional: usize) { self.0.reserve_exact(additional); } pub fn as_ptr(&self) -> *const c_char { self.0.as_ptr() as *const _ } pub fn as_mut_ptr(&mut self) -> *mut c_char { self.0.as_mut_ptr() as *mut _ } @@ -101,19 +95,13 @@ impl<'a> Default for &'a ImStr { } impl fmt::Debug for ImStr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self.0, f) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.0, f) } } impl ImStr { - pub unsafe fn from_utf8_with_nul_unchecked(bytes: &[u8]) -> &ImStr { - mem::transmute(bytes) - } + pub unsafe fn from_utf8_with_nul_unchecked(bytes: &[u8]) -> &ImStr { mem::transmute(bytes) } pub fn as_ptr(&self) -> *const c_char { self.0.as_ptr() } - pub fn to_str(&self) -> &str { - unsafe { str::from_utf8_unchecked(self.0.to_bytes()) } - } + pub fn to_str(&self) -> &str { unsafe { str::from_utf8_unchecked(self.0.to_bytes()) } } } impl<'a> Into<&'a CStr> for &'a ImStr { @@ -135,7 +123,5 @@ impl ToOwned for ImStr { impl Deref for ImStr { type Target = str; - fn deref(&self) -> &str { - unsafe { str::from_utf8_unchecked(self.0.to_bytes()) } - } + fn deref(&self) -> &str { unsafe { str::from_utf8_unchecked(self.0.to_bytes()) } } } diff --git a/src/trees.rs b/src/trees.rs index e638edd..32d722d 100644 --- a/src/trees.rs +++ b/src/trees.rs @@ -38,9 +38,11 @@ impl<'ui, 'p> TreeNode<'ui, 'p> { if !self.opened_cond.is_empty() { imgui_sys::igSetNextTreeNodeOpen(self.opened, self.opened_cond); } - imgui_sys::igTreeNodeStr(self.id.as_ptr(), - super::fmt_ptr(), - self.label.unwrap_or(self.id).as_ptr()) + imgui_sys::igTreeNodeStr( + self.id.as_ptr(), + super::fmt_ptr(), + self.label.unwrap_or(self.id).as_ptr(), + ) }; if render { f(); @@ -83,8 +85,7 @@ impl<'ui, 'p> CollapsingHeader<'ui, 'p> { } #[inline] pub fn open_on_double_click(mut self, value: bool) -> Self { - self.flags - .set(ImGuiTreeNodeFlags::OpenOnDoubleClick, value); + self.flags.set(ImGuiTreeNodeFlags::OpenOnDoubleClick, value); self } #[inline] diff --git a/src/window.rs b/src/window.rs index 4e226a5..ec7cb7c 100644 --- a/src/window.rs +++ b/src/window.rs @@ -80,8 +80,7 @@ impl<'ui, 'p> Window<'ui, 'p> { } #[inline] pub fn scrollable(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::NoScrollWithMouse, !value); + self.flags.set(ImGuiWindowFlags::NoScrollWithMouse, !value); self } #[inline] @@ -116,38 +115,44 @@ impl<'ui, 'p> Window<'ui, 'p> { } #[inline] pub fn horizontal_scrollbar(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::HorizontalScrollbar, value); + self.flags.set(ImGuiWindowFlags::HorizontalScrollbar, value); self } #[inline] pub fn no_focus_on_appearing(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::NoFocusOnAppearing, value); + self.flags.set(ImGuiWindowFlags::NoFocusOnAppearing, value); self } #[inline] pub fn no_bring_to_front_on_focus(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::NoBringToFrontOnFocus, value); + self.flags.set( + ImGuiWindowFlags::NoBringToFrontOnFocus, + value, + ); self } #[inline] pub fn always_vertical_scrollbar(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::AlwaysVerticalScrollbar, value); + self.flags.set( + ImGuiWindowFlags::AlwaysVerticalScrollbar, + value, + ); self } #[inline] pub fn always_horizontal_scrollbar(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::AlwaysHorizontalScrollbar, value); + self.flags.set( + ImGuiWindowFlags::AlwaysHorizontalScrollbar, + value, + ); self } #[inline] pub fn always_use_window_padding(mut self, value: bool) -> Self { - self.flags - .set(ImGuiWindowFlags::AlwaysUseWindowPadding, value); + self.flags.set( + ImGuiWindowFlags::AlwaysUseWindowPadding, + value, + ); self } pub fn build(self, f: F) { @@ -158,13 +163,15 @@ impl<'ui, 'p> Window<'ui, 'p> { if !self.size_cond.is_empty() { imgui_sys::igSetNextWindowSize(self.size.into(), self.size_cond); } - imgui_sys::igBegin2(self.name.as_ptr(), - self.opened - .map(|x| x as *mut bool) - .unwrap_or(ptr::null_mut()), - ImVec2::new(0.0, 0.0), - self.bg_alpha, - self.flags) + imgui_sys::igBegin2( + self.name.as_ptr(), + self.opened.map(|x| x as *mut bool).unwrap_or( + ptr::null_mut(), + ), + ImVec2::new(0.0, 0.0), + self.bg_alpha, + self.flags, + ) }; if render { f();