mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
Adapt to 1.51 changes
This commit is contained in:
parent
4ec6214feb
commit
332ef93633
@ -15,7 +15,7 @@ fn main() { support_gfx::run("hello_gfx.rs".to_owned(), CLEAR_COLOR, hello_world
|
||||
|
||||
fn hello_world<'a>(ui: &Ui<'a>) -> bool {
|
||||
ui.window(im_str!("Hello world"))
|
||||
.size((300.0, 100.0), ImGuiSetCond_FirstUseEver)
|
||||
.size((300.0, 100.0), ImGuiCond_FirstUseEver)
|
||||
.build(|| {
|
||||
ui.text(im_str!("Hello world!"));
|
||||
ui.text(im_str!("This...is...imgui-rs!"));
|
||||
|
||||
@ -13,7 +13,7 @@ fn main() { support::run("hellow_world.rs".to_owned(), CLEAR_COLOR, hello_world)
|
||||
|
||||
fn hello_world<'a>(ui: &Ui<'a>) -> bool {
|
||||
ui.window(im_str!("Hello world"))
|
||||
.size((300.0, 100.0), ImGuiSetCond_FirstUseEver)
|
||||
.size((300.0, 100.0), ImGuiCond_FirstUseEver)
|
||||
.build(|| {
|
||||
ui.text(im_str!("Hello world!"));
|
||||
ui.text(im_str!("This...is...imgui-rs!"));
|
||||
|
||||
@ -37,8 +37,6 @@ struct State {
|
||||
vec3f: [f32; 3],
|
||||
vec2i: [i32; 2],
|
||||
vec3i: [i32; 3],
|
||||
col1: [f32; 3],
|
||||
col2: [f32; 4],
|
||||
selected_fish: Option<usize>,
|
||||
auto_resize_state: AutoResizeState,
|
||||
file_menu: FileMenuState,
|
||||
@ -81,8 +79,6 @@ impl Default for State {
|
||||
vec3f: [0.10, 0.20, 0.30],
|
||||
vec2i: [10, 20],
|
||||
vec3i: [10, 20, 30],
|
||||
col1: [1.0, 0.0, 0.2],
|
||||
col2: [0.4, 0.7, 0.0, 0.5],
|
||||
selected_fish: None,
|
||||
auto_resize_state: Default::default(),
|
||||
file_menu: Default::default(),
|
||||
@ -181,7 +177,7 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
||||
.collapsible(!state.no_collapse)
|
||||
.menu_bar(!state.no_menu)
|
||||
.bg_alpha(state.bg_alpha)
|
||||
.size((550.0, 680.0), ImGuiSetCond_FirstUseEver)
|
||||
.size((550.0, 680.0), ImGuiCond_FirstUseEver)
|
||||
.opened(opened)
|
||||
.build(|| {
|
||||
ui.text(im_str!("ImGui says hello."));
|
||||
@ -359,10 +355,6 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
||||
.build();
|
||||
ui.input_float3(im_str!("input float3"), &mut state.vec3f)
|
||||
.build();
|
||||
ui.color_edit3(im_str!("color 1"), &mut state.col1)
|
||||
.build();
|
||||
ui.color_edit4(im_str!("color 2"), &mut state.col2)
|
||||
.build();
|
||||
|
||||
ui.tree_node(im_str!("Multi-component Widgets"))
|
||||
.build(|| {
|
||||
@ -528,13 +520,13 @@ fn show_example_app_fixed_overlay<'a>(ui: &Ui<'a>, opened: &mut bool) {
|
||||
|
||||
fn show_example_app_manipulating_window_title<'a>(ui: &Ui<'a>) {
|
||||
ui.window(im_str!("Same title as another window##1"))
|
||||
.position((100.0, 100.0), ImGuiSetCond_FirstUseEver)
|
||||
.position((100.0, 100.0), ImGuiCond_FirstUseEver)
|
||||
.build(|| {
|
||||
ui.text(im_str!("This is window 1.
|
||||
My title is the same as window 2, but my identifier is unique."));
|
||||
});
|
||||
ui.window(im_str!("Same title as another window##2"))
|
||||
.position((100.0, 200.0), ImGuiSetCond_FirstUseEver)
|
||||
.position((100.0, 200.0), ImGuiCond_FirstUseEver)
|
||||
.build(|| {
|
||||
ui.text(im_str!("This is window 2.
|
||||
My title is the same as window 1, but my identifier is unique."));
|
||||
@ -544,6 +536,6 @@ My title is the same as window 1, but my identifier is unique."));
|
||||
let num = ui.imgui().get_frame_count(); // The C++ version uses rand() here
|
||||
let title = im_str!("Animated title {} {}###AnimatedTitle", chars[ch_idx], num);
|
||||
ui.window(title)
|
||||
.position((100.0, 300.0), ImGuiSetCond_FirstUseEver)
|
||||
.position((100.0, 300.0), ImGuiCond_FirstUseEver)
|
||||
.build(|| { ui.text(im_str!("This window has a changing title")); });
|
||||
}
|
||||
|
||||
48
src/input.rs
48
src/input.rs
@ -316,51 +316,3 @@ macro_rules! impl_input_intn {
|
||||
impl_input_intn!(InputInt2, 2, igInputInt2);
|
||||
impl_input_intn!(InputInt3, 3, igInputInt3);
|
||||
impl_input_intn!(InputInt4, 4, igInputInt4);
|
||||
|
||||
#[must_use]
|
||||
pub struct ColorEdit3<'ui, 'p> {
|
||||
label: &'p ImStr,
|
||||
value: &'p mut [f32; 3],
|
||||
_phantom: PhantomData<&'ui Ui<'ui>>,
|
||||
}
|
||||
|
||||
impl<'ui, 'p> ColorEdit3<'ui, 'p> {
|
||||
pub fn new(_: &Ui<'ui>, label: &'p ImStr, value: &'p mut [f32; 3]) -> Self {
|
||||
ColorEdit3 {
|
||||
label: label,
|
||||
value: value,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> bool {
|
||||
unsafe { imgui_sys::igColorEdit3(self.label.as_ptr(), self.value.as_mut_ptr()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub struct ColorEdit4<'ui, 'p> {
|
||||
label: &'p ImStr,
|
||||
value: &'p mut [f32; 4],
|
||||
show_alpha: bool,
|
||||
_phantom: PhantomData<&'ui Ui<'ui>>,
|
||||
}
|
||||
|
||||
impl<'ui, 'p> ColorEdit4<'ui, 'p> {
|
||||
pub fn new(_: &Ui<'ui>, label: &'p ImStr, value: &'p mut [f32; 4]) -> Self {
|
||||
ColorEdit4 {
|
||||
label: label,
|
||||
value: value,
|
||||
show_alpha: true,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> bool {
|
||||
unsafe {
|
||||
imgui_sys::igColorEdit4(self.label.as_ptr(),
|
||||
self.value.as_mut_ptr(),
|
||||
self.show_alpha)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
src/lib.rs
36
src/lib.rs
@ -17,8 +17,9 @@ pub use imgui_sys::{ImDrawIdx, ImDrawVert, ImGuiInputTextFlags, ImGuiInputTextFl
|
||||
ImGuiInputTextFlags_NoHorizontalScroll, ImGuiInputTextFlags_Password,
|
||||
ImGuiInputTextFlags_ReadOnly, ImGuiKey, ImGuiSelectableFlags,
|
||||
ImGuiSelectableFlags_DontClosePopups, ImGuiSelectableFlags_SpanAllColumns,
|
||||
ImGuiSetCond, ImGuiSetCond_Always, ImGuiSetCond_Appearing,
|
||||
ImGuiSetCond_FirstUseEver, ImGuiSetCond_Once, ImGuiCol, ImGuiStyle, ImGuiStyleVar, ImGuiTreeNodeFlags,
|
||||
ImGuiCond, ImGuiCond_Always, ImGuiCond_Appearing,
|
||||
ImGuiCond_FirstUseEver, ImGuiCond_Once,
|
||||
ImGuiCol, ImGuiStyle, ImGuiStyleVar, ImGuiTreeNodeFlags,
|
||||
ImGuiTreeNodeFlags_AllowOverlapMode, ImGuiTreeNodeFlags_Bullet,
|
||||
ImGuiTreeNodeFlags_CollapsingHeader, ImGuiTreeNodeFlags_DefaultOpen,
|
||||
ImGuiTreeNodeFlags_Framed, ImGuiTreeNodeFlags_Leaf,
|
||||
@ -36,8 +37,7 @@ pub use imgui_sys::{ImDrawIdx, ImDrawVert, ImGuiInputTextFlags, ImGuiInputTextFl
|
||||
ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar,
|
||||
ImGuiWindowFlags_ShowBorders, ImVec2, ImVec4};
|
||||
pub use child_frame::ChildFrame;
|
||||
pub use input::{ColorEdit3, ColorEdit4, InputFloat, InputFloat2, InputFloat3, InputFloat4,
|
||||
InputInt, InputInt2, InputInt3, InputInt4, InputText};
|
||||
pub use input::{InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, InputInt4, InputText};
|
||||
pub use menus::{Menu, MenuItem};
|
||||
pub use plothistogram::PlotHistogram;
|
||||
pub use plotlines::PlotLines;
|
||||
@ -49,6 +49,22 @@ pub use style::StyleVar;
|
||||
pub use trees::{CollapsingHeader, TreeNode};
|
||||
pub use window::Window;
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[deprecated(since = "0.0.17", note = "please use ImGuiCond instead")]
|
||||
pub type ImGuiSetCond = ImGuiCond;
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[deprecated(since = "0.0.17", note = "please use ImGuiCond_Always instead")]
|
||||
pub const ImGuiSetCond_Always: ImGuiCond = ImGuiCond_Always;
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[deprecated(since = "0.0.17", note = "please use ImGuiCond_Once instead")]
|
||||
pub const ImGuiSetCond_Once: ImGuiCond = ImGuiCond_Once;
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[deprecated(since = "0.0.17", note = "please use ImGuiCond_FirstUseEver instead")]
|
||||
pub const ImGuiSetCond_FirstUseEver: ImGuiCond = ImGuiCond_FirstUseEver;
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[deprecated(since = "0.0.17", note = "please use ImGuiCond_Appearing instead")]
|
||||
pub const ImGuiSetCond_Appearing: ImGuiCond = ImGuiCond_Appearing;
|
||||
|
||||
mod child_frame;
|
||||
mod input;
|
||||
mod menus;
|
||||
@ -503,18 +519,6 @@ impl<'ui> Ui<'ui> {
|
||||
|
||||
// Widgets: Input
|
||||
impl<'ui> Ui<'ui> {
|
||||
pub fn color_edit3<'p>(&self,
|
||||
label: &'p ImStr,
|
||||
value: &'p mut [f32; 3])
|
||||
-> ColorEdit3<'ui, 'p> {
|
||||
ColorEdit3::new(self, label, value)
|
||||
}
|
||||
pub fn color_edit4<'p>(&self,
|
||||
label: &'p ImStr,
|
||||
value: &'p mut [f32; 4])
|
||||
-> ColorEdit4<'ui, 'p> {
|
||||
ColorEdit4::new(self, label, value)
|
||||
}
|
||||
pub fn input_text<'p>(&self, label: &'p ImStr, buf: &'p mut ImString) -> InputText<'ui, 'p> {
|
||||
InputText::new(self, label, buf)
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use imgui_sys;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use super::{ImGuiSetCond, ImGuiTreeNodeFlags, ImGuiTreeNodeFlags_Bullet,
|
||||
use super::{ImGuiCond, ImGuiTreeNodeFlags, ImGuiTreeNodeFlags_Bullet,
|
||||
ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf,
|
||||
ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick,
|
||||
ImGuiTreeNodeFlags_Selected, ImStr, Ui};
|
||||
@ -11,7 +11,7 @@ pub struct TreeNode<'ui, 'p> {
|
||||
id: &'p ImStr,
|
||||
label: Option<&'p ImStr>,
|
||||
opened: bool,
|
||||
opened_cond: ImGuiSetCond,
|
||||
opened_cond: ImGuiCond,
|
||||
_phantom: PhantomData<&'ui Ui<'ui>>,
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ impl<'ui, 'p> TreeNode<'ui, 'p> {
|
||||
id: id,
|
||||
label: None,
|
||||
opened: false,
|
||||
opened_cond: ImGuiSetCond::empty(),
|
||||
opened_cond: ImGuiCond::empty(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ impl<'ui, 'p> TreeNode<'ui, 'p> {
|
||||
self
|
||||
}
|
||||
#[inline]
|
||||
pub fn opened(mut self, opened: bool, cond: ImGuiSetCond) -> Self {
|
||||
pub fn opened(mut self, opened: bool, cond: ImGuiCond) -> Self {
|
||||
self.opened = opened;
|
||||
self.opened_cond = cond;
|
||||
self
|
||||
|
||||
@ -2,7 +2,7 @@ use imgui_sys;
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr;
|
||||
|
||||
use super::{ImGuiSetCond, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize,
|
||||
use super::{ImGuiCond, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize,
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar, ImGuiWindowFlags_AlwaysUseWindowPadding,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar, ImGuiWindowFlags_HorizontalScrollbar,
|
||||
ImGuiWindowFlags_MenuBar, ImGuiWindowFlags_NoBringToFrontOnFocus,
|
||||
@ -15,9 +15,9 @@ use super::{ImGuiSetCond, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize,
|
||||
#[must_use]
|
||||
pub struct Window<'ui, 'p> {
|
||||
pos: (f32, f32),
|
||||
pos_cond: ImGuiSetCond,
|
||||
pos_cond: ImGuiCond,
|
||||
size: (f32, f32),
|
||||
size_cond: ImGuiSetCond,
|
||||
size_cond: ImGuiCond,
|
||||
name: &'p ImStr,
|
||||
opened: Option<&'p mut bool>,
|
||||
bg_alpha: f32,
|
||||
@ -29,9 +29,9 @@ impl<'ui, 'p> Window<'ui, 'p> {
|
||||
pub fn new(_: &Ui<'ui>, name: &'p ImStr) -> Window<'ui, 'p> {
|
||||
Window {
|
||||
pos: (0.0, 0.0),
|
||||
pos_cond: ImGuiSetCond::empty(),
|
||||
pos_cond: ImGuiCond::empty(),
|
||||
size: (0.0, 0.0),
|
||||
size_cond: ImGuiSetCond::empty(),
|
||||
size_cond: ImGuiCond::empty(),
|
||||
name: name,
|
||||
opened: None,
|
||||
bg_alpha: -1.0,
|
||||
@ -40,13 +40,13 @@ impl<'ui, 'p> Window<'ui, 'p> {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn position(mut self, pos: (f32, f32), cond: ImGuiSetCond) -> Self {
|
||||
pub fn position(mut self, pos: (f32, f32), cond: ImGuiCond) -> Self {
|
||||
self.pos = pos;
|
||||
self.pos_cond = cond;
|
||||
self
|
||||
}
|
||||
#[inline]
|
||||
pub fn size(mut self, size: (f32, f32), cond: ImGuiSetCond) -> Self {
|
||||
pub fn size(mut self, size: (f32, f32), cond: ImGuiCond) -> Self {
|
||||
self.size = size;
|
||||
self.size_cond = cond;
|
||||
self
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user