From 20139851e290de3f4d45c107fb9c4a3e71f1ab35 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Mon, 31 Dec 2018 11:51:34 +0200 Subject: [PATCH] Upgrade to Rust 2018 edition We might as well do this since we've been forced to 1.31... --- Cargo.toml | 1 + imgui-examples/Cargo.toml | 1 + imgui-gfx-renderer/Cargo.toml | 1 + imgui-gfx-renderer/src/lib.rs | 2 +- imgui-glium-examples/Cargo.toml | 1 + imgui-glium-examples/examples/color_button.rs | 3 +- .../examples/custom_textures.rs | 2 +- .../examples/test_drawing_channels_split.rs | 3 +- .../examples/test_window_impl.rs | 21 ++++++---- imgui-glium-renderer/Cargo.toml | 1 + imgui-sys/Cargo.toml | 1 + imgui-sys/src/enums.rs | 15 ++------ imgui-sys/src/lib.rs | 19 ++++++---- imgui-winit-support/Cargo.toml | 1 + imgui-winit-support/src/lib.rs | 2 +- src/color_editors.rs | 2 +- src/lib.rs | 38 +++++++++---------- src/style.rs | 2 +- 18 files changed, 63 insertions(+), 53 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e71ee68..5cd2f7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "High-level Rust bindings to dear imgui" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-examples/Cargo.toml b/imgui-examples/Cargo.toml index 0a1d7c0..9b96920 100644 --- a/imgui-examples/Cargo.toml +++ b/imgui-examples/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-examples" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "imgui crate examples" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-gfx-renderer/Cargo.toml b/imgui-gfx-renderer/Cargo.toml index 3a3f3b6..6950087 100644 --- a/imgui-gfx-renderer/Cargo.toml +++ b/imgui-gfx-renderer/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-gfx-renderer" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "gfx renderer for the imgui crate" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-gfx-renderer/src/lib.rs b/imgui-gfx-renderer/src/lib.rs index 8d99966..f3e646a 100644 --- a/imgui-gfx-renderer/src/lib.rs +++ b/imgui-gfx-renderer/src/lib.rs @@ -106,7 +106,7 @@ pub enum Shaders { impl Shaders { fn get_program_code(self) -> (&'static [u8], &'static [u8]) { - use Shaders::*; + use self::Shaders::*; match self { GlSl400 => ( include_bytes!("shader/glsl_400.vert"), diff --git a/imgui-glium-examples/Cargo.toml b/imgui-glium-examples/Cargo.toml index e50c8a2..2259ce8 100644 --- a/imgui-glium-examples/Cargo.toml +++ b/imgui-glium-examples/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-glium-examples" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "imgui crate examples using Glium backend" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-glium-examples/examples/color_button.rs b/imgui-glium-examples/examples/color_button.rs index 1624025..b1ff2c8 100644 --- a/imgui-glium-examples/examples/color_button.rs +++ b/imgui-glium-examples/examples/color_button.rs @@ -145,7 +145,8 @@ fn example_2(ui: &Ui) { ui.color_button( im_str!("Red + ColorPreview::HalfAlpha"), (1.0, 0.0, 0.0, 0.5), - ).preview(ColorPreview::HalfAlpha) + ) + .preview(ColorPreview::HalfAlpha) .build(); ui.separator(); diff --git a/imgui-glium-examples/examples/custom_textures.rs b/imgui-glium-examples/examples/custom_textures.rs index c08a213..d265867 100644 --- a/imgui-glium-examples/examples/custom_textures.rs +++ b/imgui-glium-examples/examples/custom_textures.rs @@ -17,7 +17,7 @@ use image::{jpeg::JPEGDecoder, DecodingResult, ImageDecoder}; use imgui::*; mod support; -use support::Textures; +use self::support::Textures; const CLEAR_COLOR: [f32; 4] = [1.0, 1.0, 1.0, 1.0]; diff --git a/imgui-glium-examples/examples/test_drawing_channels_split.rs b/imgui-glium-examples/examples/test_drawing_channels_split.rs index f403fcc..bd6807b 100644 --- a/imgui-glium-examples/examples/test_drawing_channels_split.rs +++ b/imgui-glium-examples/examples/test_drawing_channels_split.rs @@ -30,7 +30,8 @@ fn main() { canvas_pos, [canvas_pos.0 + RADIUS, canvas_pos.1 + RADIUS], RED, - ).thickness(5.0) + ) + .thickness(5.0) .build(); channels.set_current(0); diff --git a/imgui-glium-examples/examples/test_window_impl.rs b/imgui-glium-examples/examples/test_window_impl.rs index c7de3ce..c426124 100644 --- a/imgui-glium-examples/examples/test_window_impl.rs +++ b/imgui-glium-examples/examples/test_window_impl.rs @@ -880,7 +880,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz * 0.5, y + state.sz * 0.5), state.sz * 0.5, state.col, - ).num_segments(20) + ) + .num_segments(20) .thickness(thickness) .build(); x += state.sz + spacing; @@ -909,7 +910,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz, y + state.sz - 0.5), (x, y + state.sz - 0.5), state.col, - ).thickness(thickness) + ) + .thickness(thickness) .build(); x += state.sz + spacing; draw_list @@ -934,7 +936,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz - state.sz * 1.3, y + state.sz - state.sz * 0.3), (x + state.sz, y + state.sz), state.col, - ).thickness(thickness) + ) + .thickness(thickness) .build(); y += state.sz + spacing; } @@ -944,7 +947,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz * 0.5, y + state.sz * 0.5), state.sz * 0.5, state.col, - ).num_segments(32) + ) + .num_segments(32) .filled(true) .build(); x += state.sz + spacing; @@ -973,7 +977,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (x + state.sz, y + state.sz - 0.5), (x, y + state.sz - 0.5), state.col, - ).filled(true) + ) + .filled(true) .build(); x += state.sz + spacing; const MULTICOLOR_RECT_CORNER_COLOR1: [f32; 3] = [0.0, 0.0, 0.0]; @@ -1042,7 +1047,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, canvas_pos, (canvas_pos.0 + canvas_size.0, canvas_pos.1 + canvas_size.1), CANVAS_BORDER_COLOR, - ).build(); + ) + .build(); let mut adding_preview = false; ui.invisible_button(im_str!("canvas"), canvas_size); @@ -1083,7 +1089,8 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, (canvas_pos.0 + p1.0, canvas_pos.1 + p1.1), (canvas_pos.0 + p2.0, canvas_pos.1 + p2.1), LINE_COLOR, - ).thickness(2.0) + ) + .thickness(2.0) .build(); } }, diff --git a/imgui-glium-renderer/Cargo.toml b/imgui-glium-renderer/Cargo.toml index 54512d8..882d3e4 100644 --- a/imgui-glium-renderer/Cargo.toml +++ b/imgui-glium-renderer/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-glium-renderer" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "Glium renderer for the imgui crate" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 8a9f8eb..792761f 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-sys" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "Raw FFI bindings to dear imgui" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-sys/src/enums.rs b/imgui-sys/src/enums.rs index 2e56d34..023cea2 100644 --- a/imgui-sys/src/enums.rs +++ b/imgui-sys/src/enums.rs @@ -107,18 +107,12 @@ impl ImGuiCol { note = "please use ImGuiCol::ModalWindowDimBg instead" )] pub const ModalWindowDarkening: ImGuiCol = ImGuiCol::ModalWindowDimBg; - #[deprecated( - since = "0.0.21", - note = "please use ImGuiCol::VARIANTS instead" - )] + #[deprecated(since = "0.0.21", note = "please use ImGuiCol::VARIANTS instead")] pub fn values() -> &'static [ImGuiCol] { &ImGuiCol::VARIANTS } } -#[deprecated( - since = "0.0.21", - note = "please use ImGuiCol::COUNT instead" -)] +#[deprecated(since = "0.0.21", note = "please use ImGuiCol::COUNT instead")] pub const ImGuiCol_COUNT: usize = 43; /// A primary data type @@ -230,10 +224,7 @@ impl ImGuiKey { ]; pub const COUNT: usize = 21; } -#[deprecated( - since = "0.0.21", - note = "please use ImGuiKey::COUNT instead" -)] +#[deprecated(since = "0.0.21", note = "please use ImGuiKey::COUNT instead")] pub const ImGuiKey_COUNT: usize = 21; /// A mouse cursor identifier diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index 895ff80..53d4c7a 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -321,10 +321,7 @@ extern "C" { pub fn igSetScrollFromPosY(pos_y: c_float, center_y_ratio: c_float); } -#[deprecated( - since = "0.0.22", - note = "please use igSetScrollHereY instead" -)] +#[deprecated(since = "0.0.22", note = "please use igSetScrollHereY instead")] #[allow(non_snake_case)] pub unsafe fn igSetScrollHere(center_y_ratio: c_float) { igSetScrollHereY(center_y_ratio) @@ -501,8 +498,11 @@ extern "C" { pub fn igComboFnPtr( 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, + 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, popup_max_height_in_items: c_int, @@ -928,8 +928,11 @@ extern "C" { pub fn igListBoxFnPtr( 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, + 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, diff --git a/imgui-winit-support/Cargo.toml b/imgui-winit-support/Cargo.toml index 394c3de..8fedc5f 100644 --- a/imgui-winit-support/Cargo.toml +++ b/imgui-winit-support/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "imgui-winit-support" version = "0.0.22-pre" +edition = "2018" authors = ["Joonas Javanainen ", "imgui-rs contributors"] description = "winit support code for the imgui crate" homepage = "https://github.com/Gekkio/imgui-rs" diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 11b4643..67e0923 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -199,7 +199,7 @@ pub fn handle_window_event( window_hidpi_factor: f64, app_hidpi_factor: f64, ) { - use WindowEvent::*; + use self::WindowEvent::*; match event { &KeyboardInput { input, .. } => handle_keyboard_input(imgui, input), &ReceivedCharacter(ch) => imgui.add_input_character(ch), diff --git a/src/color_editors.rs b/src/color_editors.rs index 9b78c73..023ebff 100644 --- a/src/color_editors.rs +++ b/src/color_editors.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use std::ptr; use sys; -use {ImGuiColorEditFlags, ImStr, ImVec2, ImVec4, Ui}; +use crate::{ImGuiColorEditFlags, ImStr, ImVec2, ImVec4, Ui}; /// Mutable reference to an editable color value. #[derive(Debug)] diff --git a/src/lib.rs b/src/lib.rs index a8f7cb4..4ea0cd8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,40 +8,40 @@ use std::slice; use std::str; use sys::ImGuiStyleVar; -pub use child_frame::ChildFrame; -pub use color_editors::{ +pub use self::child_frame::ChildFrame; +pub use self::color_editors::{ ColorButton, ColorEdit, ColorEditMode, ColorFormat, ColorPicker, ColorPickerMode, ColorPreview, EditableColor, }; -pub use drag::{ +pub use self::drag::{ DragFloat, DragFloat2, DragFloat3, DragFloat4, DragFloatRange2, DragInt, DragInt2, DragInt3, DragInt4, DragIntRange2, }; -pub use fonts::{FontGlyphRange, ImFont, ImFontAtlas, ImFontConfig}; -pub use image::{ImTexture, Image, Textures}; -pub use input::{ +pub use self::fonts::{FontGlyphRange, ImFont, ImFontAtlas, ImFontConfig}; +pub use self::image::{ImTexture, Image, Textures}; +pub use self::input::{ InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, InputInt4, InputText, InputTextMultiline, }; -pub use menus::{Menu, MenuItem}; -pub use plothistogram::PlotHistogram; -pub use plotlines::PlotLines; -pub use popup_modal::PopupModal; -pub use progressbar::ProgressBar; -pub use sliders::{ +pub use self::menus::{Menu, MenuItem}; +pub use self::plothistogram::PlotHistogram; +pub use self::plotlines::PlotLines; +pub use self::popup_modal::PopupModal; +pub use self::progressbar::ProgressBar; +pub use self::sliders::{ SliderFloat, SliderFloat2, SliderFloat3, SliderFloat4, SliderInt, SliderInt2, SliderInt3, SliderInt4, }; -pub use string::{ImStr, ImString}; -pub use style::StyleVar; -pub use sys::{ +pub use self::string::{ImStr, ImString}; +pub use self::style::StyleVar; +pub use self::sys::{ ImDrawIdx, ImDrawVert, ImGuiCol, ImGuiColorEditFlags, ImGuiCond, ImGuiFocusedFlags, ImGuiHoveredFlags, ImGuiInputTextFlags, ImGuiKey, ImGuiMouseCursor, ImGuiSelectableFlags, ImGuiStyle, ImGuiTreeNodeFlags, ImGuiWindowFlags, ImVec2, ImVec4, }; -pub use trees::{CollapsingHeader, TreeNode}; -pub use window::Window; -pub use window_draw_list::{ChannelsSplit, ImColor, WindowDrawList}; +pub use self::trees::{CollapsingHeader, TreeNode}; +pub use self::window::Window; +pub use self::window_draw_list::{ChannelsSplit, ImColor, WindowDrawList}; mod child_frame; mod color_editors; @@ -1488,8 +1488,8 @@ impl<'ui> Ui<'ui> { #[inline] fn push_style_var(&self, style_var: StyleVar) { + use self::StyleVar::*; use sys::{igPushStyleVarFloat, igPushStyleVarVec2}; - use StyleVar::*; match style_var { Alpha(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::Alpha, v) }, WindowPadding(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::WindowPadding, v) }, diff --git a/src/style.rs b/src/style.rs index 19218d7..db23072 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1,4 +1,4 @@ -use ImVec2; +use crate::ImVec2; #[derive(Copy, Clone, Debug, PartialEq)] pub enum StyleVar {