Upgrade to Rust 2018 edition

We might as well do this since we've been forced to 1.31...
This commit is contained in:
Joonas Javanainen 2018-12-31 11:51:34 +02:00
parent 79829d3200
commit 20139851e2
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179
18 changed files with 63 additions and 53 deletions

View File

@ -1,6 +1,7 @@
[package]
name = "imgui"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "High-level Rust bindings to dear imgui"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-examples"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "imgui crate examples"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-gfx-renderer"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "gfx renderer for the imgui crate"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -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"),

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-glium-examples"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "imgui crate examples using Glium backend"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -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();

View File

@ -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];

View File

@ -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);

View File

@ -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();
}
},

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-glium-renderer"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "Glium renderer for the imgui crate"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-sys"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "Raw FFI bindings to dear imgui"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -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

View File

@ -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,

View File

@ -1,6 +1,7 @@
[package]
name = "imgui-winit-support"
version = "0.0.22-pre"
edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "winit support code for the imgui crate"
homepage = "https://github.com/Gekkio/imgui-rs"

View File

@ -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),

View File

@ -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)]

View File

@ -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) },

View File

@ -1,4 +1,4 @@
use ImVec2;
use crate::ImVec2;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum StyleVar {