diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 4e69233..a81824d 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -17,7 +17,9 @@ fn main() { loop { support.render(CLEAR_COLOR, hello_world); let active = support.update_events(); - if !active { break } + if !active { + break; + } } } diff --git a/examples/support/mod.rs b/examples/support/mod.rs index 357fe0c..94aa867 100644 --- a/examples/support/mod.rs +++ b/examples/support/mod.rs @@ -52,14 +52,19 @@ impl Support { last_frame: Instant::now(), mouse_pos: (0, 0), mouse_pressed: (false, false, false), - mouse_wheel: 0.0 + mouse_wheel: 0.0, } } pub fn update_mouse(&mut self) { let scale = self.imgui.display_framebuffer_scale(); - self.imgui.set_mouse_pos(self.mouse_pos.0 as f32 / scale.0, self.mouse_pos.1 as f32 / scale.1); - self.imgui.set_mouse_down(&[self.mouse_pressed.0, self.mouse_pressed.1, self.mouse_pressed.2, false, false]); + self.imgui.set_mouse_pos(self.mouse_pos.0 as f32 / scale.0, + self.mouse_pos.1 as f32 / scale.1); + self.imgui.set_mouse_down(&[self.mouse_pressed.0, + self.mouse_pressed.1, + self.mouse_pressed.2, + false, + false]); self.imgui.set_mouse_wheel(self.mouse_wheel / scale.1); self.mouse_wheel = 0.0; } @@ -73,8 +78,7 @@ impl Support { self.update_mouse(); let mut target = self.display.draw(); - target.clear_color(clear_color.0, clear_color.1, - clear_color.2, clear_color.3); + target.clear_color(clear_color.0, clear_color.1, clear_color.2, clear_color.3); let window = self.display.get_window().unwrap(); let size_points = window.get_inner_size_points().unwrap(); @@ -115,30 +119,35 @@ impl Support { Some(VirtualKeyCode::X) => self.imgui.set_key(16, pressed), Some(VirtualKeyCode::Y) => self.imgui.set_key(17, pressed), Some(VirtualKeyCode::Z) => self.imgui.set_key(18, pressed), - Some(VirtualKeyCode::LControl) | Some(VirtualKeyCode::RControl) => - self.imgui.set_key_ctrl(pressed), - Some(VirtualKeyCode::LShift) | Some(VirtualKeyCode::RShift) => - self.imgui.set_key_shift(pressed), - Some(VirtualKeyCode::LAlt) | Some(VirtualKeyCode::RAlt) => - self.imgui.set_key_alt(pressed), - Some(VirtualKeyCode::LWin) | Some(VirtualKeyCode::RWin) => - self.imgui.set_key_super(pressed), - _ => {}, + Some(VirtualKeyCode::LControl) | + Some(VirtualKeyCode::RControl) => self.imgui.set_key_ctrl(pressed), + Some(VirtualKeyCode::LShift) | + Some(VirtualKeyCode::RShift) => self.imgui.set_key_shift(pressed), + Some(VirtualKeyCode::LAlt) | + Some(VirtualKeyCode::RAlt) => self.imgui.set_key_alt(pressed), + Some(VirtualKeyCode::LWin) | + Some(VirtualKeyCode::RWin) => self.imgui.set_key_super(pressed), + _ => {} } - }, + } Event::MouseMoved(x, y) => self.mouse_pos = (x, y), - Event::MouseInput(state, MouseButton::Left) => - self.mouse_pressed.0 = state == ElementState::Pressed, - Event::MouseInput(state, MouseButton::Right) => - self.mouse_pressed.1 = state == ElementState::Pressed, - Event::MouseInput(state, MouseButton::Middle) => - self.mouse_pressed.2 = state == ElementState::Pressed, - Event::MouseWheel(MouseScrollDelta::LineDelta(_, y), TouchPhase::Moved) => - self.mouse_wheel = y, - Event::MouseWheel(MouseScrollDelta::PixelDelta(_, y), TouchPhase::Moved) => - self.mouse_wheel = y, + Event::MouseInput(state, MouseButton::Left) => { + self.mouse_pressed.0 = state == ElementState::Pressed + } + Event::MouseInput(state, MouseButton::Right) => { + self.mouse_pressed.1 = state == ElementState::Pressed + } + Event::MouseInput(state, MouseButton::Middle) => { + self.mouse_pressed.2 = state == ElementState::Pressed + } + Event::MouseWheel(MouseScrollDelta::LineDelta(_, y), TouchPhase::Moved) => { + self.mouse_wheel = y + } + Event::MouseWheel(MouseScrollDelta::PixelDelta(_, y), TouchPhase::Moved) => { + self.mouse_wheel = y + } Event::ReceivedCharacter(c) => self.imgui.add_input_character(c), - _ => () + _ => (), } } true diff --git a/examples/test_window.rs b/examples/test_window.rs index 00309b3..195dc9a 100644 --- a/examples/test_window.rs +++ b/examples/test_window.rs @@ -14,10 +14,10 @@ fn main() { loop { let mut open = true; - support.render(CLEAR_COLOR, |ui| { - ui.show_test_window(&mut open) - }); + support.render(CLEAR_COLOR, |ui| ui.show_test_window(&mut open)); let active = support.update_events(); - if !active || !open { break } + if !active || !open { + break; + } } } diff --git a/examples/test_window_impl.rs b/examples/test_window_impl.rs index d9a731e..8559f71 100644 --- a/examples/test_window_impl.rs +++ b/examples/test_window_impl.rs @@ -37,15 +37,15 @@ struct State { text: String, i0: i32, f0: f32, - vec2f: [f32;2], - vec3f: [f32;3], - vec2i: [i32;2], - vec3i: [i32;3], - col1: [f32;3], - col2: [f32;4], + vec2f: [f32; 2], + vec3f: [f32; 3], + vec2i: [i32; 2], + vec3i: [i32; 3], + col1: [f32; 3], + col2: [f32; 4], selected_fish: Option, auto_resize_state: AutoResizeState, - file_menu: FileMenuState + file_menu: FileMenuState, } impl Default for State { @@ -92,33 +92,25 @@ impl Default for State { col2: [0.4, 0.7, 0.0, 0.5], selected_fish: None, auto_resize_state: Default::default(), - file_menu: Default::default() + file_menu: Default::default(), } } } struct FileMenuState { - enabled: bool + enabled: bool, } impl Default for FileMenuState { - fn default() -> Self { - FileMenuState { - enabled: true - } - } + fn default() -> Self { FileMenuState { enabled: true } } } struct AutoResizeState { - lines: i32 + lines: i32, } impl Default for AutoResizeState { - fn default() -> Self { - AutoResizeState { - lines: 10 - } - } + fn default() -> Self { AutoResizeState { lines: 10 } } } fn main() { @@ -127,11 +119,12 @@ fn main() { let mut opened = true; loop { - support.render(state.clear_color, |ui| { - show_test_window(ui, &mut state, &mut opened); - }); + support.render(state.clear_color, + |ui| { show_test_window(ui, &mut state, &mut opened); }); let active = support.update_events(); - if !active || !opened { break } + if !active || !opened { + break; + } } } @@ -142,15 +135,18 @@ fn show_user_guide<'a>(ui: &Ui<'a>) { 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!("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 +- \ + CTRL+Left/Right to word jump - CTRL+A or double-click to select all -- CTRL+X,CTRL+C,CTRL+V clipboard +\ + - CTRL+X,CTRL+C,CTRL+V clipboard - CTRL+Z,CTRL+Y undo/redo -- ESCAPE to revert -- You can apply arithmetic operators +,*,/ on numerical values. +- ESCAPE \ + to revert +- You can apply arithmetic operators +,*,/ on numerical \ + values. Use +- to subtract.")); } @@ -158,9 +154,13 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { if state.show_app_metrics { ui.show_metrics_window(&mut state.show_app_metrics); } - if state.show_app_main_menu_bar { show_example_app_main_menu_bar(ui, state) } + if state.show_app_main_menu_bar { + 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); @@ -176,7 +176,8 @@ 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.")); }) } @@ -194,37 +195,48 @@ 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!("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(); + .selected(&mut state.show_app_main_menu_bar) + .build(); ui.menu_item(im_str!("Console")) - .selected(&mut state.show_app_console).build(); + .selected(&mut state.show_app_console) + .build(); ui.menu_item(im_str!("Simple layout")) - .selected(&mut state.show_app_layout).build(); + .selected(&mut state.show_app_layout) + .build(); ui.menu_item(im_str!("Long text display")) - .selected(&mut state.show_app_long_text).build(); + .selected(&mut state.show_app_long_text) + .build(); ui.menu_item(im_str!("Auto-resizing window")) - .selected(&mut state.show_app_auto_resize).build(); + .selected(&mut state.show_app_auto_resize) + .build(); ui.menu_item(im_str!("Simple overlay")) - .selected(&mut state.show_app_fixed_overlay).build(); + .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(); + .selected(&mut state.show_app_manipulating_window_title) + .build(); ui.menu_item(im_str!("Custom rendering")) - .selected(&mut state.show_app_custom_rendering).build(); + .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(); + .selected(&mut state.show_app_metrics) + .build(); ui.menu_item(im_str!("About ImGui")) - .selected(&mut state.show_app_about).build(); + .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() function. Please refer to the code for programming reference.\n\nUser Guide:")); + 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:")); show_user_guide(ui); } @@ -249,23 +261,22 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { 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!("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")); @@ -282,10 +293,10 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { 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 the window.\ - The current implementation for text wrapping follows simple rules\ - suitable for English and possibly other languages.")); + 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.")); ui.spacing(); ui.slider_float(im_str!("Wrap width"), &mut state.wrap_width, -20.0, 600.0) @@ -299,10 +310,10 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { // 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 with the\ - appropriate CJK character ranges. Call io.Font->LoadFromFileTTF()\ - manually to load extra character ranges.")); + 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.")); ui.text(im_str!("Hiragana: かきくけこ (kakikukeko)")); ui.text(im_str!("Kanjis: 日本語 (nihongo)")); @@ -311,17 +322,32 @@ 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(); ui.input_int(im_str!("input int"), &mut state.i0).build(); ui.input_float(im_str!("input float"), &mut state.f0) - .step(0.01).step_fast(1.0).build(); + .step(0.01) + .step_fast(1.0) + .build(); ui.input_float3(im_str!("input float3"), &mut state.vec3f).build(); ui.color_edit3(im_str!("color 1"), &mut state.col1).build(); ui.color_edit4(im_str!("color 2"), &mut state.col2).build(); @@ -338,22 +364,30 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { } 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 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")]; + 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.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)) { + if ui.selectable(name.clone(), + false, + ImGuiSelectableFlags::empty(), + ImVec2::new(0.0, 0.0)) { state.selected_fish = Some(index); } } @@ -365,13 +399,13 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { 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!("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(); + .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(); @@ -391,9 +425,7 @@ fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) { 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!("Recurse..")).build(|| { show_example_menu_file(ui, state); }); }); }); ui.menu_item(im_str!("Save")).shortcut(im_str!("Ctrl+S")).build(); @@ -423,7 +455,7 @@ fn show_example_app_auto_resize<'a>(ui: &Ui<'a>, state: &mut AutoResizeState, op Note that you probably don't want to query the window size to 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 { + for i in 0..state.lines { ui.text(im_str!("{:2$}This is line {}", "", i, i as usize * 4)); } }) @@ -464,7 +496,5 @@ My title is the same as window 1, but my identifier is unique.")); let title = im_str!("Animated title {} {}###AnimatedTitle", chars[ch_idx], num); ui.window(title) .position((100.0, 300.0), ImGuiSetCond_FirstUseEver) - .build(|| { - ui.text(im_str!("This window has a changing title")); - }); + .build(|| { ui.text(im_str!("This window has a changing title")); }); } diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 4fa9d66..a4f8efe 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -24,7 +24,7 @@ pub type ImU32 = c_uint; /// Character for keyboard input/display pub type ImWchar = c_ushort; -/// User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp) +/// User data to identify a texture pub type ImTextureID = *mut c_void; /// Unique ID used by widgets (typically hashed from a stack of string) @@ -260,8 +260,7 @@ bitflags!( } ); -pub type ImGuiTextEditCallback = - Option c_int>; +pub type ImGuiTextEditCallback = Option c_int>; pub type ImGuiSizeConstraintCallback = Option; @@ -357,15 +356,20 @@ pub struct ImGuiStyle { pub child_window_rounding: c_float, /// Padding within a framed rectangle (used by most widgets) pub frame_padding: ImVec2, - /// Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). + /// Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most + /// widgets). pub frame_rounding: c_float, /// Horizontal and vertical spacing between widgets/lines pub item_spacing: ImVec2, - /// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) + /// Horizontal and vertical spacing between within elements of a composed + /// widget (e.g. a slider and its label) pub item_inner_spacing: ImVec2, - /// Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + /// Expand reactive bounding box for touch-based system where touch position is not accurat + /// enough. Unfortunately we don't sort widgets so priority on overlap will always be given + /// to the first widget. So don't grow this too much! pub touch_extra_padding: ImVec2, - /// Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + /// Horizontal spacing when e.g. entering a tree node. + /// Generally == (FontSize + FramePadding.x*2). pub indent_spacing: c_float, /// Minimum horizontal spacing between two columns pub columns_min_spacing: c_float, @@ -377,15 +381,18 @@ pub struct ImGuiStyle { pub grab_min_size: c_float, /// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. pub grab_rounding: c_float, - /// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows. + /// Window positions are clamped to be visible within the display area by at least this + /// amount. Only covers regular windows. pub display_window_padding: ImVec2, - /// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. + /// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. + /// Covers popups/tooltips as well regular windows. pub display_safe_area_padding: ImVec2, /// Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU. pub anti_aliased_lines: bool, /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) pub anti_aliased_shapes: bool, - /// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + /// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more + /// polygons), increase to reduce quality. pub curve_tessellation_tol: c_float, /// Colors for the user interface pub colors: [ImVec4; ImGuiCol_COUNT], @@ -577,11 +584,13 @@ impl Vertex for ImDrawVert { fn build_bindings() -> VertexFormat { unsafe { let dummy: &ImDrawVert = mem::transmute(0usize); - Cow::Owned(vec![ - ("pos".into(), mem::transmute(&dummy.pos), ::get_type()), - ("uv".into(), mem::transmute(&dummy.uv), ::get_type()), - ("col".into(), mem::transmute(&dummy.col), AttributeType::U8U8U8U8) - ]) + Cow::Owned(vec![("pos".into(), + mem::transmute(&dummy.pos), + ::get_type()), + ("uv".into(), + mem::transmute(&dummy.uv), + ::get_type()), + ("col".into(), mem::transmute(&dummy.col), AttributeType::U8U8U8U8)]) } } } diff --git a/rustfmt.toml b/rustfmt.toml index 30ab64e..9efa1ea 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1 @@ fn_single_line = true -reorder_imports = true diff --git a/src/glium_renderer.rs b/src/glium_renderer.rs index e49d96a..5e4d4b9 100644 --- a/src/glium_renderer.rs +++ b/src/glium_renderer.rs @@ -107,26 +107,29 @@ 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! { + &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), }, - &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; } diff --git a/src/input.rs b/src/input.rs index 977703d..300fb1c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -9,8 +9,7 @@ use super::{ImGuiInputTextFlags, ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackHistory, ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal, ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsUppercase, - ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_NoHorizontalScroll, ImStr, - Ui}; + ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_NoHorizontalScroll, ImStr, Ui}; macro_rules! impl_text_flags { ($InputType:ident) => { diff --git a/src/lib.rs b/src/lib.rs index 53298de..4392602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,16 +33,15 @@ pub use imgui_sys::{ImDrawIdx, ImDrawVert, ImGuiInputTextFlags, ImGuiInputTextFl ImGuiTreeNodeFlags_Selected, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_AlwaysHorizontalScrollbar, ImGuiWindowFlags_AlwaysUseWindowPadding, - ImGuiWindowFlags_AlwaysVerticalScrollbar, - ImGuiWindowFlags_HorizontalScrollbar, ImGuiWindowFlags_MenuBar, - ImGuiWindowFlags_NoBringToFrontOnFocus, ImGuiWindowFlags_NoCollapse, - ImGuiWindowFlags_NoFocusOnAppearing, ImGuiWindowFlags_NoInputs, - ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize, + ImGuiWindowFlags_AlwaysVerticalScrollbar, ImGuiWindowFlags_HorizontalScrollbar, + ImGuiWindowFlags_MenuBar, ImGuiWindowFlags_NoBringToFrontOnFocus, + ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoFocusOnAppearing, + ImGuiWindowFlags_NoInputs, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize, ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse, ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar, ImGuiWindowFlags_ShowBorders, ImVec2, ImVec4}; -pub use input::{ColorEdit3, ColorEdit4, InputFloat, InputFloat2, InputFloat3, InputFloat4, - InputInt, InputInt2, InputInt3, InputInt4, InputText}; +pub use input::{ColorEdit3, ColorEdit4, InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, + InputInt2, InputInt3, InputInt4, InputText}; pub use menus::{Menu, MenuItem}; pub use plothistogram::PlotHistogram; pub use plotlines::PlotLines; @@ -617,9 +616,7 @@ impl<'ui> Ui<'ui> { unsafe { imgui_sys::igEndPopup() }; } } - pub fn close_current_popup(&self) { - unsafe { imgui_sys::igCloseCurrentPopup() }; - } + pub fn close_current_popup(&self) { unsafe { imgui_sys::igCloseCurrentPopup() }; } } // Widgets: Combos diff --git a/src/trees.rs b/src/trees.rs index a393872..372f2f6 100644 --- a/src/trees.rs +++ b/src/trees.rs @@ -2,9 +2,8 @@ use imgui_sys; use std::marker::PhantomData; use super::{ImGuiSetCond, ImGuiTreeNodeFlags, ImGuiTreeNodeFlags_Bullet, - ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf, - ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick, - ImGuiTreeNodeFlags_Selected, ImStr, Ui}; + ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_OpenOnArrow, + ImGuiTreeNodeFlags_OpenOnDoubleClick, ImGuiTreeNodeFlags_Selected, ImStr, Ui}; #[must_use] pub struct TreeNode<'ui, 'p> { diff --git a/src/window.rs b/src/window.rs index 2e4220a..b276d60 100644 --- a/src/window.rs +++ b/src/window.rs @@ -9,8 +9,8 @@ use super::{ImGuiSetCond, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoFocusOnAppearing, ImGuiWindowFlags_NoInputs, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize, ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse, - ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar, - ImGuiWindowFlags_ShowBorders, ImStr, ImVec2, Ui}; + ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar, ImGuiWindowFlags_ShowBorders, + ImStr, ImVec2, Ui}; #[must_use] pub struct Window<'ui, 'p> {