mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-15 23:48:31 +00:00
Update Dear Imgui to v1.82
This commit is contained in:
parent
de5496d390
commit
cb918fc652
@ -24,19 +24,21 @@ use crate::render::renderer::TextureId;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
bitflags!(
|
||||
/// Flags for indictating which corner of a rectangle should be rounded
|
||||
/// Options for some DrawList operations.
|
||||
#[repr(C)]
|
||||
pub struct CornerFlags: u32 {
|
||||
const NONE = sys::ImDrawCornerFlags_None;
|
||||
const TOP_LEFT = sys::ImDrawCornerFlags_TopLeft;
|
||||
const TOP_RIGHT = sys::ImDrawCornerFlags_TopRight;
|
||||
const BOT_LEFT = sys::ImDrawCornerFlags_BotLeft;
|
||||
const BOT_RIGHT = sys::ImDrawCornerFlags_BotRight;
|
||||
const TOP = sys::ImDrawCornerFlags_Top;
|
||||
const BOT = sys::ImDrawCornerFlags_Bot;
|
||||
const LEFT = sys::ImDrawCornerFlags_Left;
|
||||
const RIGHT = sys::ImDrawCornerFlags_Right;
|
||||
const ALL = sys::ImDrawCornerFlags_All;
|
||||
pub struct DrawFlags: u32 {
|
||||
const NONE = sys::ImDrawFlags_None;
|
||||
const CLOSED = sys::ImDrawFlags_Closed;
|
||||
const ROUND_CORNERS_TOP_LEFT = sys::ImDrawFlags_RoundCornersTopLeft;
|
||||
const ROUND_CORNERS_TOP_RIGHT = sys::ImDrawFlags_RoundCornersTopRight;
|
||||
const ROUND_CORNERS_BOT_LEFT = sys::ImDrawFlags_RoundCornersBottomLeft;
|
||||
const ROUND_CORNERS_BOT_RIGHT = sys::ImDrawFlags_RoundCornersBottomRight;
|
||||
const ROUND_CORNERS_TOP = sys::ImDrawFlags_RoundCornersTop;
|
||||
const ROUND_CORNERS_BOT = sys::ImDrawFlags_RoundCornersBottom;
|
||||
const ROUND_CORNERS_LEFT = sys::ImDrawFlags_RoundCornersLeft;
|
||||
const ROUND_CORNERS_RIGHT = sys::ImDrawFlags_RoundCornersRight;
|
||||
const ROUND_CORNERS_ALL = sys::ImDrawFlags_RoundCornersAll;
|
||||
const ROUND_CORNERS_NONE = sys::ImDrawFlags_RoundCornersNone;
|
||||
}
|
||||
);
|
||||
|
||||
@ -419,7 +421,7 @@ pub struct Rect<'ui> {
|
||||
p2: [f32; 2],
|
||||
color: ImColor32,
|
||||
rounding: f32,
|
||||
flags: CornerFlags,
|
||||
flags: DrawFlags,
|
||||
thickness: f32,
|
||||
filled: bool,
|
||||
draw_list: &'ui DrawListMut<'ui>,
|
||||
@ -435,7 +437,7 @@ impl<'ui> Rect<'ui> {
|
||||
p2,
|
||||
color: c.into(),
|
||||
rounding: 0.0,
|
||||
flags: CornerFlags::ALL,
|
||||
flags: DrawFlags::ROUND_CORNERS_ALL,
|
||||
thickness: 1.0,
|
||||
filled: false,
|
||||
draw_list,
|
||||
@ -451,25 +453,25 @@ impl<'ui> Rect<'ui> {
|
||||
|
||||
/// Set flag to indicate if rectangle's top-left corner will be rounded.
|
||||
pub fn round_top_left(mut self, value: bool) -> Self {
|
||||
self.flags.set(CornerFlags::TOP_LEFT, value);
|
||||
self.flags.set(DrawFlags::ROUND_CORNERS_TOP_LEFT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if rectangle's top-right corner will be rounded.
|
||||
pub fn round_top_right(mut self, value: bool) -> Self {
|
||||
self.flags.set(CornerFlags::TOP_RIGHT, value);
|
||||
self.flags.set(DrawFlags::ROUND_CORNERS_TOP_RIGHT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if rectangle's bottom-left corner will be rounded.
|
||||
pub fn round_bot_left(mut self, value: bool) -> Self {
|
||||
self.flags.set(CornerFlags::BOT_LEFT, value);
|
||||
self.flags.set(DrawFlags::ROUND_CORNERS_BOT_LEFT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if rectangle's bottom-right corner will be rounded.
|
||||
pub fn round_bot_right(mut self, value: bool) -> Self {
|
||||
self.flags.set(CornerFlags::BOT_RIGHT, value);
|
||||
self.flags.set(DrawFlags::ROUND_CORNERS_BOT_RIGHT, value);
|
||||
self
|
||||
}
|
||||
|
||||
@ -894,7 +896,7 @@ pub struct ImageRounded<'ui> {
|
||||
uv_max: [f32; 2],
|
||||
col: ImColor32,
|
||||
rounding: f32,
|
||||
rounding_corners: CornerFlags,
|
||||
draw_flags: DrawFlags,
|
||||
draw_list: &'ui DrawListMut<'ui>,
|
||||
}
|
||||
|
||||
@ -915,7 +917,7 @@ impl<'ui> ImageRounded<'ui> {
|
||||
uv_max: [1.0, 1.0],
|
||||
col: [1.0, 1.0, 1.0, 1.0].into(),
|
||||
rounding,
|
||||
rounding_corners: CornerFlags::ALL,
|
||||
draw_flags: DrawFlags::ROUND_CORNERS_ALL,
|
||||
draw_list,
|
||||
}
|
||||
}
|
||||
@ -942,31 +944,35 @@ impl<'ui> ImageRounded<'ui> {
|
||||
|
||||
/// Set flag to indicate rounding on all all corners.
|
||||
pub fn round_all(mut self, value: bool) -> Self {
|
||||
self.rounding_corners.set(CornerFlags::ALL, value);
|
||||
self.draw_flags.set(DrawFlags::ROUND_CORNERS_ALL, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if image's top-left corner will be rounded.
|
||||
pub fn round_top_left(mut self, value: bool) -> Self {
|
||||
self.rounding_corners.set(CornerFlags::TOP_LEFT, value);
|
||||
self.draw_flags
|
||||
.set(DrawFlags::ROUND_CORNERS_TOP_LEFT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if image's top-right corner will be rounded.
|
||||
pub fn round_top_right(mut self, value: bool) -> Self {
|
||||
self.rounding_corners.set(CornerFlags::TOP_RIGHT, value);
|
||||
self.draw_flags
|
||||
.set(DrawFlags::ROUND_CORNERS_TOP_RIGHT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if image's bottom-left corner will be rounded.
|
||||
pub fn round_bot_left(mut self, value: bool) -> Self {
|
||||
self.rounding_corners.set(CornerFlags::BOT_LEFT, value);
|
||||
self.draw_flags
|
||||
.set(DrawFlags::ROUND_CORNERS_BOT_LEFT, value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set flag to indicate if image's bottom-right corner will be rounded.
|
||||
pub fn round_bot_right(mut self, value: bool) -> Self {
|
||||
self.rounding_corners.set(CornerFlags::BOT_RIGHT, value);
|
||||
self.draw_flags
|
||||
.set(DrawFlags::ROUND_CORNERS_BOT_RIGHT, value);
|
||||
self
|
||||
}
|
||||
|
||||
@ -984,7 +990,7 @@ impl<'ui> ImageRounded<'ui> {
|
||||
self.uv_max.into(),
|
||||
self.col.into(),
|
||||
self.rounding,
|
||||
self.rounding_corners.bits() as i32,
|
||||
self.draw_flags.bits() as i32,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ pub struct FontId(pub(crate) *const Font);
|
||||
/// A font atlas that builds a single texture
|
||||
#[repr(C)]
|
||||
pub struct FontAtlas {
|
||||
locked: bool,
|
||||
/// Configuration flags
|
||||
pub flags: FontAtlasFlags,
|
||||
/// Texture identifier
|
||||
@ -48,6 +47,8 @@ pub struct FontAtlas {
|
||||
/// this to 0.
|
||||
pub tex_glyph_padding: i32,
|
||||
|
||||
locked: bool,
|
||||
tex_pixels_use_colors: bool,
|
||||
tex_pixels_alpha8: *mut u8,
|
||||
tex_pixels_rgba32: *mut u32,
|
||||
tex_width: i32,
|
||||
@ -263,6 +264,7 @@ fn test_font_atlas_memory_layout() {
|
||||
assert_field_offset!(tex_id, TexID);
|
||||
assert_field_offset!(tex_desired_width, TexDesiredWidth);
|
||||
assert_field_offset!(tex_glyph_padding, TexGlyphPadding);
|
||||
assert_field_offset!(tex_pixels_use_colors, TexPixelsUseColors);
|
||||
assert_field_offset!(tex_pixels_alpha8, TexPixelsAlpha8);
|
||||
assert_field_offset!(tex_pixels_rgba32, TexPixelsRGBA32);
|
||||
assert_field_offset!(tex_width, TexWidth);
|
||||
|
||||
@ -37,8 +37,8 @@ bitflags!(
|
||||
const CTRL_ENTER_FOR_NEW_LINE = sys::ImGuiInputTextFlags_CtrlEnterForNewLine;
|
||||
/// Disable following the cursor horizontally
|
||||
const NO_HORIZONTAL_SCROLL = sys::ImGuiInputTextFlags_NoHorizontalScroll;
|
||||
/// Insert mode
|
||||
const ALWAYS_INSERT_MODE = sys::ImGuiInputTextFlags_AlwaysInsertMode;
|
||||
/// Always overwrite (aka "insert mode").
|
||||
const ALWAYS_OVERWRITE = sys::ImGuiInputTextFlags_AlwaysOverwrite;
|
||||
/// Read-only mode
|
||||
const READ_ONLY = sys::ImGuiInputTextFlags_ReadOnly;
|
||||
/// Password mode, display all characters as '*'
|
||||
@ -138,9 +138,16 @@ macro_rules! impl_text_flags {
|
||||
self
|
||||
}
|
||||
|
||||
/// Note: this is equivalent to `always_overwrite`
|
||||
#[inline]
|
||||
pub fn always_insert_mode(mut self, value: bool) -> Self {
|
||||
self.flags.set(InputTextFlags::ALWAYS_INSERT_MODE, value);
|
||||
pub fn always_insert_mode(self, value: bool) -> Self {
|
||||
self.always_overwrite(value)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
pub fn always_overwrite(mut self, value: bool) -> Self {
|
||||
self.flags.set(InputTextFlags::ALWAYS_OVERWRITE, value);
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ pub fn dear_imgui_version() -> &'static str {
|
||||
#[test]
|
||||
fn test_version() {
|
||||
// TODO: what's the point of this test?
|
||||
assert_eq!(dear_imgui_version(), "1.81");
|
||||
assert_eq!(dear_imgui_version(), "1.82");
|
||||
}
|
||||
|
||||
impl Context {
|
||||
|
||||
@ -144,7 +144,7 @@ pub struct Style {
|
||||
/// explicit segment count specified.
|
||||
///
|
||||
/// Decrease for higher quality but more geometry.
|
||||
pub circle_segment_max_error: f32,
|
||||
pub circle_tesselation_max_error: f32,
|
||||
/// Style colors.
|
||||
pub colors: [[f32; 4]; StyleColor::COUNT],
|
||||
}
|
||||
@ -492,7 +492,7 @@ fn test_style_memory_layout() {
|
||||
assert_field_offset!(anti_aliased_lines_use_tex, AntiAliasedLinesUseTex);
|
||||
assert_field_offset!(anti_aliased_fill, AntiAliasedFill);
|
||||
assert_field_offset!(curve_tessellation_tol, CurveTessellationTol);
|
||||
assert_field_offset!(circle_segment_max_error, CircleSegmentMaxError);
|
||||
assert_field_offset!(circle_tesselation_max_error, CircleTessellationMaxError);
|
||||
assert_field_offset!(colors, Colors);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user