mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
clippy don't be so mad!
This commit is contained in:
parent
cef617ba02
commit
50e166e84f
@ -189,8 +189,8 @@ impl Lenna {
|
|||||||
decoder.read_image(&mut image)?;
|
decoder.read_image(&mut image)?;
|
||||||
let raw = RawImage2d {
|
let raw = RawImage2d {
|
||||||
data: Cow::Owned(image),
|
data: Cow::Owned(image),
|
||||||
width: width as u32,
|
width,
|
||||||
height: height as u32,
|
height,
|
||||||
format: ClientFormat::U8U8U8,
|
format: ClientFormat::U8U8U8,
|
||||||
};
|
};
|
||||||
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
let gl_texture = Texture2d::new(gl_ctx, raw)?;
|
||||||
|
|||||||
@ -759,7 +759,7 @@ CTRL+click on individual component to input value.\n",
|
|||||||
);
|
);
|
||||||
|
|
||||||
state.filter.draw();
|
state.filter.draw();
|
||||||
let lines = vec!["aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world!"];
|
let lines = ["aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world!"];
|
||||||
|
|
||||||
ui.same_line();
|
ui.same_line();
|
||||||
if ui.button("Clear##clear_filter") {
|
if ui.button("Clear##clear_filter") {
|
||||||
@ -1285,7 +1285,7 @@ fn show_app_log(ui: &Ui, app_log: &mut Vec<String>) {
|
|||||||
}
|
}
|
||||||
ui.same_line();
|
ui.same_line();
|
||||||
if ui.button("Copy") {
|
if ui.button("Copy") {
|
||||||
ui.set_clipboard_text(&ImString::from(app_log.join("\n")));
|
ui.set_clipboard_text(ImString::from(app_log.join("\n")));
|
||||||
}
|
}
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.child_window("logwindow")
|
ui.child_window("logwindow")
|
||||||
|
|||||||
@ -106,7 +106,7 @@ fn main() {
|
|||||||
if !data.str().is_empty() {
|
if !data.str().is_empty() {
|
||||||
data.remove_chars(0, 1);
|
data.remove_chars(0, 1);
|
||||||
|
|
||||||
if let Some((idx, _)) = data.str().char_indices().rev().next() {
|
if let Some((idx, _)) = data.str().char_indices().next_back() {
|
||||||
data.remove_chars(idx, 1);
|
data.remove_chars(idx, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// insert last char
|
// insert last char
|
||||||
if let Some((idx, _)) = self.1.char_indices().rev().next() {
|
if let Some((idx, _)) = self.1.char_indices().next_back() {
|
||||||
data.push_str(&self.1[idx..]);
|
data.push_str(&self.1[idx..]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1152,7 +1152,7 @@ fn calculate_matrix(draw_data: &DrawData, clip_origin_is_lower_left: bool) -> [f
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn to_byte_slice<T>(slice: &[T]) -> &[u8] {
|
unsafe fn to_byte_slice<T>(slice: &[T]) -> &[u8] {
|
||||||
std::slice::from_raw_parts(slice.as_ptr().cast(), slice.len() * size_of::<T>())
|
std::slice::from_raw_parts(slice.as_ptr().cast(), std::mem::size_of_val(slice))
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn imgui_index_type_as_gl() -> u32 {
|
const fn imgui_index_type_as_gl() -> u32 {
|
||||||
|
|||||||
@ -523,7 +523,7 @@ impl Context {
|
|||||||
// we take this with an `&mut Self` here, which means
|
// we take this with an `&mut Self` here, which means
|
||||||
// that we can't get the sharedfontatlas through safe code
|
// that we can't get the sharedfontatlas through safe code
|
||||||
// otherwise
|
// otherwise
|
||||||
unsafe { &mut *(self.io_mut().fonts as *mut FontAtlas) }
|
unsafe { &mut *self.io_mut().fonts }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to clone the interior shared font atlas **if it exists**.
|
/// Attempts to clone the interior shared font atlas **if it exists**.
|
||||||
|
|||||||
@ -27,7 +27,6 @@ bitflags!(
|
|||||||
/// Options for some DrawList operations.
|
/// Options for some DrawList operations.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DrawFlags: u32 {
|
pub struct DrawFlags: u32 {
|
||||||
const NONE = sys::ImDrawFlags_None;
|
|
||||||
const CLOSED = sys::ImDrawFlags_Closed;
|
const CLOSED = sys::ImDrawFlags_Closed;
|
||||||
const ROUND_CORNERS_TOP_LEFT = sys::ImDrawFlags_RoundCornersTopLeft;
|
const ROUND_CORNERS_TOP_LEFT = sys::ImDrawFlags_RoundCornersTopLeft;
|
||||||
const ROUND_CORNERS_TOP_RIGHT = sys::ImDrawFlags_RoundCornersTopRight;
|
const ROUND_CORNERS_TOP_RIGHT = sys::ImDrawFlags_RoundCornersTopRight;
|
||||||
@ -46,7 +45,6 @@ bitflags!(
|
|||||||
/// Draw list flags
|
/// Draw list flags
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DrawListFlags: u32 {
|
pub struct DrawListFlags: u32 {
|
||||||
const NONE = sys::ImDrawListFlags_None;
|
|
||||||
/// Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines
|
/// Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines
|
||||||
/// thin enough to be drawn using textures, otherwise *3 the number of triangles)
|
/// thin enough to be drawn using textures, otherwise *3 the number of triangles)
|
||||||
const ANTI_ALIASED_LINES = sys::ImDrawListFlags_AntiAliasedLines;
|
const ANTI_ALIASED_LINES = sys::ImDrawListFlags_AntiAliasedLines;
|
||||||
|
|||||||
@ -17,10 +17,6 @@ enum FontGlyphRangeData {
|
|||||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||||
pub struct FontGlyphRanges(FontGlyphRangeData);
|
pub struct FontGlyphRanges(FontGlyphRangeData);
|
||||||
impl FontGlyphRanges {
|
impl FontGlyphRanges {
|
||||||
/// The default set of glyph ranges used by imgui.
|
|
||||||
pub fn default() -> FontGlyphRanges {
|
|
||||||
FontGlyphRanges(FontGlyphRangeData::Default)
|
|
||||||
}
|
|
||||||
/// A set of glyph ranges appropriate for use with simplified common Chinese text.
|
/// A set of glyph ranges appropriate for use with simplified common Chinese text.
|
||||||
pub fn chinese_simplified_common() -> FontGlyphRanges {
|
pub fn chinese_simplified_common() -> FontGlyphRanges {
|
||||||
FontGlyphRanges(FontGlyphRangeData::ChineseSimplifiedCommon)
|
FontGlyphRanges(FontGlyphRangeData::ChineseSimplifiedCommon)
|
||||||
@ -162,3 +158,10 @@ impl FontGlyphRanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FontGlyphRanges {
|
||||||
|
/// The default set of glyph ranges used by imgui.
|
||||||
|
fn default() -> Self {
|
||||||
|
FontGlyphRanges(FontGlyphRangeData::Default)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
//! Internal raw utilities (don't use unless you know what you're doing!)
|
//! Internal raw utilities (don't use unless you know what you're doing!)
|
||||||
|
|
||||||
use std::{mem::size_of, slice};
|
use std::slice;
|
||||||
|
|
||||||
/// A generic version of the raw imgui-sys ImVector struct types
|
/// A generic version of the raw imgui-sys ImVector struct types
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -25,7 +25,7 @@ impl<T> ImVector<T> {
|
|||||||
unsafe {
|
unsafe {
|
||||||
sys::igMemFree(self.data as *mut _);
|
sys::igMemFree(self.data as *mut _);
|
||||||
|
|
||||||
let buffer_ptr = sys::igMemAlloc(size_of::<T>() * data.len()) as *mut T;
|
let buffer_ptr = sys::igMemAlloc(std::mem::size_of_val(data)) as *mut T;
|
||||||
buffer_ptr.copy_from_nonoverlapping(data.as_ptr(), data.len());
|
buffer_ptr.copy_from_nonoverlapping(data.as_ptr(), data.len());
|
||||||
|
|
||||||
self.size = data.len() as i32;
|
self.size = data.len() as i32;
|
||||||
|
|||||||
@ -334,7 +334,7 @@ impl From<&DrawData> for OwnedDrawData {
|
|||||||
OwnedDrawData {
|
OwnedDrawData {
|
||||||
draw_data: unsafe {
|
draw_data: unsafe {
|
||||||
let other_ptr = value.raw();
|
let other_ptr = value.raw();
|
||||||
let mut result = sys::ImDrawData_ImDrawData();
|
let result = sys::ImDrawData_ImDrawData();
|
||||||
(*result).Valid = other_ptr.Valid;
|
(*result).Valid = other_ptr.Valid;
|
||||||
(*result).TotalIdxCount = other_ptr.TotalIdxCount;
|
(*result).TotalIdxCount = other_ptr.TotalIdxCount;
|
||||||
(*result).TotalVtxCount = other_ptr.TotalVtxCount;
|
(*result).TotalVtxCount = other_ptr.TotalVtxCount;
|
||||||
@ -404,7 +404,7 @@ fn test_owneddrawdata_from_drawdata() {
|
|||||||
DisplaySize: sys::ImVec2 { x: 789.0, y: 012.0 },
|
DisplaySize: sys::ImVec2 { x: 789.0, y: 012.0 },
|
||||||
FramebufferScale: sys::ImVec2 { x: 3.0, y: 7.0 },
|
FramebufferScale: sys::ImVec2 { x: 3.0, y: 7.0 },
|
||||||
#[cfg(feature = "docking")]
|
#[cfg(feature = "docking")]
|
||||||
OwnerViewport: unsafe { (std::ptr::null_mut() as *mut sys::ImGuiViewport).offset(123) },
|
OwnerViewport: unsafe { std::ptr::null_mut::<sys::ImGuiViewport>().offset(123) },
|
||||||
};
|
};
|
||||||
let draw_data = unsafe { DrawData::from_raw(&draw_data_raw) };
|
let draw_data = unsafe { DrawData::from_raw(&draw_data_raw) };
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user