mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
Fix most Clippy warnings
This commit is contained in:
parent
efebe174c4
commit
6e246b0c7c
@ -23,54 +23,52 @@
|
||||
//! use winit::event_loop::{ControlFlow, EventLoop};
|
||||
//! use winit::window::{Window};
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let mut event_loop = EventLoop::new();
|
||||
//! let mut window = Window::new(&event_loop).unwrap();
|
||||
//! let mut event_loop = EventLoop::new();
|
||||
//! let mut window = Window::new(&event_loop).unwrap();
|
||||
//!
|
||||
//! let mut imgui = Context::create();
|
||||
//! // configure imgui-rs Context if necessary
|
||||
//! let mut imgui = Context::create();
|
||||
//! // configure imgui-rs Context if necessary
|
||||
//!
|
||||
//! let mut platform = WinitPlatform::init(&mut imgui); // step 1
|
||||
//! platform.attach_window(imgui.io_mut(), &window, HiDpiMode::Default); // step 2
|
||||
//! let mut platform = WinitPlatform::init(&mut imgui); // step 1
|
||||
//! platform.attach_window(imgui.io_mut(), &window, HiDpiMode::Default); // step 2
|
||||
//!
|
||||
//! let mut last_frame = Instant::now();
|
||||
//! let mut run = true;
|
||||
//! event_loop.run(move |event, _, control_flow| {
|
||||
//! match event {
|
||||
//! Event::NewEvents(_) => {
|
||||
//! // other application-specific logic
|
||||
//! last_frame = imgui.io_mut().update_delta_time(last_frame);
|
||||
//! },
|
||||
//! Event::MainEventsCleared => {
|
||||
//! // other application-specific logic
|
||||
//! platform.prepare_frame(imgui.io_mut(), &window) // step 4
|
||||
//! .expect("Failed to prepare frame");
|
||||
//! window.request_redraw();
|
||||
//! }
|
||||
//! Event::RedrawRequested(_) => {
|
||||
//! let ui = imgui.frame();
|
||||
//! // application-specific rendering *under the UI*
|
||||
//!
|
||||
//! // construct the UI
|
||||
//!
|
||||
//! platform.prepare_render(&ui, &window); // step 5
|
||||
//! // render the UI with a renderer
|
||||
//! let draw_data = ui.render();
|
||||
//! // renderer.render(..., draw_data).expect("UI rendering failed");
|
||||
//!
|
||||
//! // application-specific rendering *over the UI*
|
||||
//! },
|
||||
//! Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
||||
//! *control_flow = ControlFlow::Exit;
|
||||
//! }
|
||||
//! // other application-specific event handling
|
||||
//! event => {
|
||||
//! platform.handle_event(imgui.io_mut(), &window, &event); // step 3
|
||||
//! // other application-specific event handling
|
||||
//! }
|
||||
//! let mut last_frame = Instant::now();
|
||||
//! let mut run = true;
|
||||
//! event_loop.run(move |event, _, control_flow| {
|
||||
//! match event {
|
||||
//! Event::NewEvents(_) => {
|
||||
//! // other application-specific logic
|
||||
//! last_frame = imgui.io_mut().update_delta_time(last_frame);
|
||||
//! },
|
||||
//! Event::MainEventsCleared => {
|
||||
//! // other application-specific logic
|
||||
//! platform.prepare_frame(imgui.io_mut(), &window) // step 4
|
||||
//! .expect("Failed to prepare frame");
|
||||
//! window.request_redraw();
|
||||
//! }
|
||||
//! })
|
||||
//! }
|
||||
//! Event::RedrawRequested(_) => {
|
||||
//! let ui = imgui.frame();
|
||||
//! // application-specific rendering *under the UI*
|
||||
//!
|
||||
//! // construct the UI
|
||||
//!
|
||||
//! platform.prepare_render(&ui, &window); // step 5
|
||||
//! // render the UI with a renderer
|
||||
//! let draw_data = ui.render();
|
||||
//! // renderer.render(..., draw_data).expect("UI rendering failed");
|
||||
//!
|
||||
//! // application-specific rendering *over the UI*
|
||||
//! },
|
||||
//! Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
||||
//! *control_flow = ControlFlow::Exit;
|
||||
//! }
|
||||
//! // other application-specific event handling
|
||||
//! event => {
|
||||
//! platform.handle_event(imgui.io_mut(), &window, &event); // step 3
|
||||
//! // other application-specific event handling
|
||||
//! }
|
||||
//! }
|
||||
//! })
|
||||
//! ```
|
||||
|
||||
#[cfg(feature = "winit-19")]
|
||||
|
||||
@ -82,7 +82,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// May be useful to handle the same mouse event on a group of items, for example.
|
||||
///
|
||||
/// Returns a `GroupToken` that must be ended by calling `.end()`
|
||||
#[must_use]
|
||||
pub fn begin_group(&self) -> GroupToken {
|
||||
unsafe { sys::igBeginGroup() };
|
||||
GroupToken { ctx: self.ctx }
|
||||
|
||||
23
src/lib.rs
23
src/lib.rs
@ -229,11 +229,9 @@ impl<T> From<*mut T> for Id<'static> {
|
||||
|
||||
// Widgets: Input
|
||||
impl<'ui> Ui<'ui> {
|
||||
#[must_use]
|
||||
pub fn input_text<'p>(&self, label: &'p ImStr, buf: &'p mut ImString) -> InputText<'ui, 'p> {
|
||||
InputText::new(self, label, buf)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_text_multiline<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -242,11 +240,9 @@ impl<'ui> Ui<'ui> {
|
||||
) -> InputTextMultiline<'ui, 'p> {
|
||||
InputTextMultiline::new(self, label, buf, size)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_float<'p>(&self, label: &'p ImStr, value: &'p mut f32) -> InputFloat<'ui, 'p> {
|
||||
InputFloat::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_float2<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -254,7 +250,6 @@ impl<'ui> Ui<'ui> {
|
||||
) -> InputFloat2<'ui, 'p> {
|
||||
InputFloat2::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_float3<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -262,7 +257,6 @@ impl<'ui> Ui<'ui> {
|
||||
) -> InputFloat3<'ui, 'p> {
|
||||
InputFloat3::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_float4<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -270,19 +264,15 @@ impl<'ui> Ui<'ui> {
|
||||
) -> InputFloat4<'ui, 'p> {
|
||||
InputFloat4::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_int<'p>(&self, label: &'p ImStr, value: &'p mut i32) -> InputInt<'ui, 'p> {
|
||||
InputInt::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_int2<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 2]) -> InputInt2<'ui, 'p> {
|
||||
InputInt2::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_int3<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 3]) -> InputInt3<'ui, 'p> {
|
||||
InputInt3::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn input_int4<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 4]) -> InputInt4<'ui, 'p> {
|
||||
InputInt4::new(self, label, value)
|
||||
}
|
||||
@ -290,11 +280,9 @@ impl<'ui> Ui<'ui> {
|
||||
|
||||
// Widgets: Drag
|
||||
impl<'ui> Ui<'ui> {
|
||||
#[must_use]
|
||||
pub fn drag_float<'p>(&self, label: &'p ImStr, value: &'p mut f32) -> DragFloat<'ui, 'p> {
|
||||
DragFloat::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_float2<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -302,7 +290,6 @@ impl<'ui> Ui<'ui> {
|
||||
) -> DragFloat2<'ui, 'p> {
|
||||
DragFloat2::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_float3<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -310,7 +297,6 @@ impl<'ui> Ui<'ui> {
|
||||
) -> DragFloat3<'ui, 'p> {
|
||||
DragFloat3::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_float4<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -318,7 +304,6 @@ impl<'ui> Ui<'ui> {
|
||||
) -> DragFloat4<'ui, 'p> {
|
||||
DragFloat4::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_float_range2<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -327,23 +312,18 @@ impl<'ui> Ui<'ui> {
|
||||
) -> DragFloatRange2<'ui, 'p> {
|
||||
DragFloatRange2::new(self, label, current_min, current_max)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_int<'p>(&self, label: &'p ImStr, value: &'p mut i32) -> DragInt<'ui, 'p> {
|
||||
DragInt::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_int2<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 2]) -> DragInt2<'ui, 'p> {
|
||||
DragInt2::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_int3<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 3]) -> DragInt3<'ui, 'p> {
|
||||
DragInt3::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_int4<'p>(&self, label: &'p ImStr, value: &'p mut [i32; 4]) -> DragInt4<'ui, 'p> {
|
||||
DragInt4::new(self, label, value)
|
||||
}
|
||||
#[must_use]
|
||||
pub fn drag_int_range2<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
@ -441,7 +421,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// }
|
||||
/// });
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn popup_modal<'p>(&self, str_id: &'p ImStr) -> PopupModal<'ui, 'p> {
|
||||
PopupModal::new(self, str_id)
|
||||
}
|
||||
@ -476,14 +455,12 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
|
||||
impl<'ui> Ui<'ui> {
|
||||
#[must_use]
|
||||
pub fn plot_lines<'p>(&self, label: &'p ImStr, values: &'p [f32]) -> PlotLines<'ui, 'p> {
|
||||
PlotLines::new(self, label, values)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ui> Ui<'ui> {
|
||||
#[must_use]
|
||||
pub fn plot_histogram<'p>(
|
||||
&self,
|
||||
label: &'p ImStr,
|
||||
|
||||
@ -220,6 +220,7 @@ pub struct DrawVert {
|
||||
|
||||
#[cfg(feature = "glium")]
|
||||
use glium::implement_vertex;
|
||||
#[allow(clippy::unneeded_field_pattern)]
|
||||
#[cfg(feature = "glium")]
|
||||
implement_vertex!(DrawVert, pos, uv, col);
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.text("I use the custom font!");
|
||||
/// font.pop(&ui);
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn push_font(&self, id: FontId) -> FontStackToken {
|
||||
let fonts = self.fonts();
|
||||
let font = fonts
|
||||
@ -58,7 +57,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.text("I'm red!");
|
||||
/// color.pop(&ui);
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn push_style_color(&self, style_color: StyleColor, color: [f32; 4]) -> ColorStackToken {
|
||||
unsafe { sys::igPushStyleColor(style_color as i32, color.into()) };
|
||||
ColorStackToken {
|
||||
@ -86,7 +84,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.text_disabled("I'm green!");
|
||||
/// colors.pop(&ui);
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn push_style_colors<'a, I>(&self, style_colors: I) -> ColorStackToken
|
||||
where
|
||||
I: IntoIterator<Item = &'a (StyleColor, [f32; 4])>,
|
||||
@ -115,7 +112,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.text("I'm transparent!");
|
||||
/// style.pop(&ui);
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn push_style_var(&self, style_var: StyleVar) -> StyleStackToken {
|
||||
unsafe { push_style_var(style_var) };
|
||||
StyleStackToken {
|
||||
@ -141,7 +137,6 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.text("...with large spacing as well");
|
||||
/// styles.pop(&ui);
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn push_style_vars<'a, I>(&self, style_vars: I) -> StyleStackToken
|
||||
where
|
||||
I: IntoIterator<Item = &'a StyleVar>,
|
||||
@ -383,7 +378,6 @@ impl<'ui> Ui<'ui> {
|
||||
///
|
||||
/// Returns an `IdStackToken` that must be popped by calling `.pop()`
|
||||
///
|
||||
#[must_use]
|
||||
pub fn push_id<'a, I: Into<Id<'a>>>(&self, id: I) -> IdStackToken {
|
||||
let id = id.into();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user