mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-27 13:28:28 +00:00
Merge pull request #48 from mulimoen/clippy_warnings
Rustfmt and clippy-lints fixes
This commit is contained in:
commit
eb53a3a3cd
@ -18,9 +18,7 @@ pub struct Support {
|
|||||||
|
|
||||||
impl Support {
|
impl Support {
|
||||||
pub fn init() -> Support {
|
pub fn init() -> Support {
|
||||||
let display = glutin::WindowBuilder::new()
|
let display = glutin::WindowBuilder::new().build_glium().unwrap();
|
||||||
.build_glium()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut imgui = ImGui::init();
|
let mut imgui = ImGui::init();
|
||||||
let renderer = Renderer::init(&mut imgui, &display).unwrap();
|
let renderer = Renderer::init(&mut imgui, &display).unwrap();
|
||||||
@ -58,9 +56,11 @@ impl Support {
|
|||||||
|
|
||||||
pub fn update_mouse(&mut self) {
|
pub fn update_mouse(&mut self) {
|
||||||
let scale = self.imgui.display_framebuffer_scale();
|
let scale = self.imgui.display_framebuffer_scale();
|
||||||
self.imgui.set_mouse_pos(self.mouse_pos.0 as f32 / scale.0,
|
self.imgui
|
||||||
|
.set_mouse_pos(self.mouse_pos.0 as f32 / scale.0,
|
||||||
self.mouse_pos.1 as f32 / scale.1);
|
self.mouse_pos.1 as f32 / scale.1);
|
||||||
self.imgui.set_mouse_down(&[self.mouse_pressed.0,
|
self.imgui
|
||||||
|
.set_mouse_down(&[self.mouse_pressed.0,
|
||||||
self.mouse_pressed.1,
|
self.mouse_pressed.1,
|
||||||
self.mouse_pressed.2,
|
self.mouse_pressed.2,
|
||||||
false,
|
false,
|
||||||
@ -140,9 +140,7 @@ impl Support {
|
|||||||
Event::MouseInput(state, MouseButton::Middle) => {
|
Event::MouseInput(state, MouseButton::Middle) => {
|
||||||
self.mouse_pressed.2 = state == ElementState::Pressed
|
self.mouse_pressed.2 = state == ElementState::Pressed
|
||||||
}
|
}
|
||||||
Event::MouseWheel(MouseScrollDelta::LineDelta(_, y), TouchPhase::Moved) => {
|
Event::MouseWheel(MouseScrollDelta::LineDelta(_, y), TouchPhase::Moved) |
|
||||||
self.mouse_wheel = y
|
|
||||||
}
|
|
||||||
Event::MouseWheel(MouseScrollDelta::PixelDelta(_, y), TouchPhase::Moved) => {
|
Event::MouseWheel(MouseScrollDelta::PixelDelta(_, y), TouchPhase::Moved) => {
|
||||||
self.mouse_wheel = y
|
self.mouse_wheel = y
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,7 +197,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
ui.menu_bar(|| {
|
ui.menu_bar(|| {
|
||||||
ui.menu(im_str!("Menu"))
|
ui.menu(im_str!("Menu"))
|
||||||
.build(|| { show_example_menu_file(ui, &mut state.file_menu); });
|
.build(|| { show_example_menu_file(ui, &mut state.file_menu); });
|
||||||
ui.menu(im_str!("Examples")).build(|| {
|
ui.menu(im_str!("Examples"))
|
||||||
|
.build(|| {
|
||||||
ui.menu_item(im_str!("Main menu bar"))
|
ui.menu_item(im_str!("Main menu bar"))
|
||||||
.selected(&mut state.show_app_main_menu_bar)
|
.selected(&mut state.show_app_main_menu_bar)
|
||||||
.build();
|
.build();
|
||||||
@ -223,7 +224,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
.selected(&mut state.show_app_custom_rendering)
|
.selected(&mut state.show_app_custom_rendering)
|
||||||
.build();
|
.build();
|
||||||
});
|
});
|
||||||
ui.menu(im_str!("Help")).build(|| {
|
ui.menu(im_str!("Help"))
|
||||||
|
.build(|| {
|
||||||
ui.menu_item(im_str!("Metrics"))
|
ui.menu_item(im_str!("Metrics"))
|
||||||
.selected(&mut state.show_app_metrics)
|
.selected(&mut state.show_app_metrics)
|
||||||
.build();
|
.build();
|
||||||
@ -252,9 +254,11 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
ui.same_line(300.0);
|
ui.same_line(300.0);
|
||||||
ui.checkbox(im_str!("no collapse"), &mut state.no_collapse);
|
ui.checkbox(im_str!("no collapse"), &mut state.no_collapse);
|
||||||
ui.checkbox(im_str!("no menu"), &mut state.no_menu);
|
ui.checkbox(im_str!("no menu"), &mut state.no_menu);
|
||||||
ui.slider_float(im_str!("bg alpha"), &mut state.bg_alpha, 0.0, 1.0).build();
|
ui.slider_float(im_str!("bg alpha"), &mut state.bg_alpha, 0.0, 1.0)
|
||||||
|
.build();
|
||||||
|
|
||||||
ui.tree_node(im_str!("Style")).build(|| {
|
ui.tree_node(im_str!("Style"))
|
||||||
|
.build(|| {
|
||||||
// TODO: Reimplement style editor
|
// TODO: Reimplement style editor
|
||||||
ui.show_default_style_editor();
|
ui.show_default_style_editor();
|
||||||
});
|
});
|
||||||
@ -263,14 +267,17 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
.build(|| {
|
.build(|| {
|
||||||
ui.text_wrapped(im_str!("Tip: Load fonts with \
|
ui.text_wrapped(im_str!("Tip: Load fonts with \
|
||||||
io.Fonts->AddFontFromFileTTF()."));
|
io.Fonts->AddFontFromFileTTF()."));
|
||||||
ui.tree_node(im_str!("Atlas texture")).build(|| {
|
ui.tree_node(im_str!("Atlas texture"))
|
||||||
|
.build(|| {
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ui.collapsing_header(im_str!("Widgets")).build() {
|
if ui.collapsing_header(im_str!("Widgets")).build() {
|
||||||
ui.tree_node(im_str!("Tree")).build(|| for i in 0..5 {
|
ui.tree_node(im_str!("Tree"))
|
||||||
ui.tree_node(im_str!("Child {}", i)).build(|| {
|
.build(|| for i in 0..5 {
|
||||||
|
ui.tree_node(im_str!("Child {}", i))
|
||||||
|
.build(|| {
|
||||||
ui.text(im_str!("blah blah"));
|
ui.text(im_str!("blah blah"));
|
||||||
ui.same_line(0.0);
|
ui.same_line(0.0);
|
||||||
if ui.small_button(im_str!("print")) {
|
if ui.small_button(im_str!("print")) {
|
||||||
@ -278,7 +285,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.tree_node(im_str!("Bullets")).build(|| {
|
ui.tree_node(im_str!("Bullets"))
|
||||||
|
.build(|| {
|
||||||
ui.bullet_text(im_str!("Bullet point 1"));
|
ui.bullet_text(im_str!("Bullet point 1"));
|
||||||
ui.bullet_text(im_str!("Bullet point 2\nOn multiple lines"));
|
ui.bullet_text(im_str!("Bullet point 2\nOn multiple lines"));
|
||||||
ui.bullet();
|
ui.bullet();
|
||||||
@ -287,7 +295,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
ui.bullet();
|
ui.bullet();
|
||||||
ui.small_button(im_str!("Button"));
|
ui.small_button(im_str!("Button"));
|
||||||
});
|
});
|
||||||
ui.tree_node(im_str!("Colored text")).build(|| {
|
ui.tree_node(im_str!("Colored text"))
|
||||||
|
.build(|| {
|
||||||
ui.text_colored((1.0, 0.0, 1.0, 1.0), im_str!("Pink"));
|
ui.text_colored((1.0, 0.0, 1.0, 1.0), im_str!("Pink"));
|
||||||
ui.text_colored((1.0, 1.0, 0.0, 1.0), im_str!("Yellow"));
|
ui.text_colored((1.0, 1.0, 0.0, 1.0), im_str!("Yellow"));
|
||||||
ui.text_disabled(im_str!("Disabled"));
|
ui.text_disabled(im_str!("Disabled"));
|
||||||
@ -309,7 +318,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
ui.text(im_str!("Test paragraph 2:"));
|
ui.text(im_str!("Test paragraph 2:"));
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
ui.tree_node(im_str!("UTF-8 Text")).build(|| {
|
ui.tree_node(im_str!("UTF-8 Text"))
|
||||||
|
.build(|| {
|
||||||
ui.text_wrapped(im_str!("CJK text will only appear if the font was loaded \
|
ui.text_wrapped(im_str!("CJK text will only appear if the font was loaded \
|
||||||
with theappropriate CJK character ranges. Call \
|
with theappropriate CJK character ranges. Call \
|
||||||
io.Font->LoadFromFileTTF()manually to load extra \
|
io.Font->LoadFromFileTTF()manually to load extra \
|
||||||
@ -317,7 +327,8 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
|
|
||||||
ui.text(im_str!("Hiragana: かきくけこ (kakikukeko)"));
|
ui.text(im_str!("Hiragana: かきくけこ (kakikukeko)"));
|
||||||
ui.text(im_str!("Kanjis: 日本語 (nihongo)"));
|
ui.text(im_str!("Kanjis: 日本語 (nihongo)"));
|
||||||
ui.input_text(im_str!("UTF-8 input"), &mut state.buf).build();
|
ui.input_text(im_str!("UTF-8 input"), &mut state.buf)
|
||||||
|
.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
@ -342,28 +353,39 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
im_str!("JJJJ"),
|
im_str!("JJJJ"),
|
||||||
im_str!("KKKK")];
|
im_str!("KKKK")];
|
||||||
ui.combo(im_str!("combo scroll"), &mut state.item2, &items, -1);
|
ui.combo(im_str!("combo scroll"), &mut state.item2, &items, -1);
|
||||||
ui.input_text(im_str!("input text"), &mut state.text).build();
|
ui.input_text(im_str!("input text"), &mut state.text)
|
||||||
|
.build();
|
||||||
ui.input_int(im_str!("input int"), &mut state.i0).build();
|
ui.input_int(im_str!("input int"), &mut state.i0).build();
|
||||||
ui.input_float(im_str!("input float"), &mut state.f0)
|
ui.input_float(im_str!("input float"), &mut state.f0)
|
||||||
.step(0.01)
|
.step(0.01)
|
||||||
.step_fast(1.0)
|
.step_fast(1.0)
|
||||||
.build();
|
.build();
|
||||||
ui.input_float3(im_str!("input float3"), &mut state.vec3f).build();
|
ui.input_float3(im_str!("input float3"), &mut state.vec3f)
|
||||||
ui.color_edit3(im_str!("color 1"), &mut state.col1).build();
|
.build();
|
||||||
ui.color_edit4(im_str!("color 2"), &mut state.col2).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(|| {
|
ui.tree_node(im_str!("Multi-component Widgets"))
|
||||||
ui.input_float2(im_str!("input float2"), &mut state.vec2f).build();
|
.build(|| {
|
||||||
ui.input_int2(im_str!("input int2"), &mut state.vec2i).build();
|
ui.input_float2(im_str!("input float2"), &mut state.vec2f)
|
||||||
|
.build();
|
||||||
|
ui.input_int2(im_str!("input int2"), &mut state.vec2i)
|
||||||
|
.build();
|
||||||
ui.spacing();
|
ui.spacing();
|
||||||
|
|
||||||
ui.input_float3(im_str!("input float3"), &mut state.vec3f).build();
|
ui.input_float3(im_str!("input float3"), &mut state.vec3f)
|
||||||
ui.input_int3(im_str!("input int3"), &mut state.vec3i).build();
|
.build();
|
||||||
|
ui.input_int3(im_str!("input int3"), &mut state.vec3i)
|
||||||
|
.build();
|
||||||
ui.spacing();
|
ui.spacing();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ui.collapsing_header(im_str!("Popups & Modal windows")).build() {
|
if ui.collapsing_header(im_str!("Popups & Modal windows"))
|
||||||
ui.tree_node(im_str!("Popups")).build(|| {
|
.build() {
|
||||||
|
ui.tree_node(im_str!("Popups"))
|
||||||
|
.build(|| {
|
||||||
ui.text_wrapped(im_str!("When a popup is active, it inhibits interacting \
|
ui.text_wrapped(im_str!("When a popup is active, it inhibits interacting \
|
||||||
with windows that are behind the popup. Clicking \
|
with windows that are behind the popup. Clicking \
|
||||||
outside the popup closes it."));
|
outside the popup closes it."));
|
||||||
@ -399,51 +421,80 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) {
|
|||||||
|
|
||||||
fn show_example_app_main_menu_bar<'a>(ui: &Ui<'a>, state: &mut State) {
|
fn show_example_app_main_menu_bar<'a>(ui: &Ui<'a>, state: &mut State) {
|
||||||
ui.main_menu_bar(|| {
|
ui.main_menu_bar(|| {
|
||||||
ui.menu(im_str!("File")).build(|| { show_example_menu_file(ui, &mut state.file_menu); });
|
ui.menu(im_str!("File"))
|
||||||
ui.menu(im_str!("Edit")).build(|| {
|
.build(|| { show_example_menu_file(ui, &mut state.file_menu); });
|
||||||
ui.menu_item(im_str!("Undo")).shortcut(im_str!("CTRL+Z")).build();
|
ui.menu(im_str!("Edit"))
|
||||||
|
.build(|| {
|
||||||
|
ui.menu_item(im_str!("Undo"))
|
||||||
|
.shortcut(im_str!("CTRL+Z"))
|
||||||
|
.build();
|
||||||
ui.menu_item(im_str!("Redo"))
|
ui.menu_item(im_str!("Redo"))
|
||||||
.shortcut(im_str!("CTRL+Y"))
|
.shortcut(im_str!("CTRL+Y"))
|
||||||
.enabled(false)
|
.enabled(false)
|
||||||
.build();
|
.build();
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.menu_item(im_str!("Cut")).shortcut(im_str!("CTRL+X")).build();
|
ui.menu_item(im_str!("Cut"))
|
||||||
ui.menu_item(im_str!("Copy")).shortcut(im_str!("CTRL+C")).build();
|
.shortcut(im_str!("CTRL+X"))
|
||||||
ui.menu_item(im_str!("Paste")).shortcut(im_str!("CTRL+V")).build();
|
.build();
|
||||||
|
ui.menu_item(im_str!("Copy"))
|
||||||
|
.shortcut(im_str!("CTRL+C"))
|
||||||
|
.build();
|
||||||
|
ui.menu_item(im_str!("Paste"))
|
||||||
|
.shortcut(im_str!("CTRL+V"))
|
||||||
|
.build();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) {
|
fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) {
|
||||||
ui.menu_item(im_str!("(dummy menu)")).enabled(false).build();
|
ui.menu_item(im_str!("(dummy menu)"))
|
||||||
|
.enabled(false)
|
||||||
|
.build();
|
||||||
ui.menu_item(im_str!("New")).build();
|
ui.menu_item(im_str!("New")).build();
|
||||||
ui.menu_item(im_str!("Open")).shortcut(im_str!("Ctrl+O")).build();
|
ui.menu_item(im_str!("Open"))
|
||||||
ui.menu(im_str!("Open Recent")).build(|| {
|
.shortcut(im_str!("Ctrl+O"))
|
||||||
|
.build();
|
||||||
|
ui.menu(im_str!("Open Recent"))
|
||||||
|
.build(|| {
|
||||||
ui.menu_item(im_str!("fish_hat.c")).build();
|
ui.menu_item(im_str!("fish_hat.c")).build();
|
||||||
ui.menu_item(im_str!("fish_hat.inl")).build();
|
ui.menu_item(im_str!("fish_hat.inl")).build();
|
||||||
ui.menu_item(im_str!("fish_hat.h")).build();
|
ui.menu_item(im_str!("fish_hat.h")).build();
|
||||||
ui.menu(im_str!("More..")).build(|| {
|
ui.menu(im_str!("More.."))
|
||||||
|
.build(|| {
|
||||||
ui.menu_item(im_str!("Hello")).build();
|
ui.menu_item(im_str!("Hello")).build();
|
||||||
ui.menu_item(im_str!("Sailor")).build();
|
ui.menu_item(im_str!("Sailor")).build();
|
||||||
ui.menu(im_str!("Recurse..")).build(|| { show_example_menu_file(ui, state); });
|
ui.menu(im_str!("Recurse.."))
|
||||||
|
.build(|| { show_example_menu_file(ui, state); });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.menu_item(im_str!("Save")).shortcut(im_str!("Ctrl+S")).build();
|
ui.menu_item(im_str!("Save"))
|
||||||
|
.shortcut(im_str!("Ctrl+S"))
|
||||||
|
.build();
|
||||||
ui.menu_item(im_str!("Save As..")).build();
|
ui.menu_item(im_str!("Save As..")).build();
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.menu(im_str!("Options")).build(|| {
|
ui.menu(im_str!("Options"))
|
||||||
ui.menu_item(im_str!("Enabled")).selected(&mut state.enabled).build();
|
.build(|| {
|
||||||
|
ui.menu_item(im_str!("Enabled"))
|
||||||
|
.selected(&mut state.enabled)
|
||||||
|
.build();
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
ui.menu(im_str!("Colors")).build(|| {
|
ui.menu(im_str!("Colors"))
|
||||||
|
.build(|| {
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
ui.menu(im_str!("Disabled")).enabled(false).build(|| {
|
ui.menu(im_str!("Disabled"))
|
||||||
|
.enabled(false)
|
||||||
|
.build(|| {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
});
|
});
|
||||||
let mut checked = true;
|
let mut checked = true;
|
||||||
ui.menu_item(im_str!("Checked")).selected(&mut checked).build();
|
ui.menu_item(im_str!("Checked"))
|
||||||
ui.menu_item(im_str!("Quit")).shortcut(im_str!("Alt+F4")).build();
|
.selected(&mut checked)
|
||||||
|
.build();
|
||||||
|
ui.menu_item(im_str!("Quit"))
|
||||||
|
.shortcut(im_str!("Alt+F4"))
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_example_app_auto_resize<'a>(ui: &Ui<'a>, state: &mut AutoResizeState, opened: &mut bool) {
|
fn show_example_app_auto_resize<'a>(ui: &Ui<'a>, state: &mut AutoResizeState, opened: &mut bool) {
|
||||||
@ -454,7 +505,8 @@ fn show_example_app_auto_resize<'a>(ui: &Ui<'a>, state: &mut AutoResizeState, op
|
|||||||
ui.text(im_str!("Window will resize every-ui to the size of its content.
|
ui.text(im_str!("Window will resize every-ui to the size of its content.
|
||||||
Note that you probably don't want to query the window size to
|
Note that you probably don't want to query the window size to
|
||||||
output your content because that would create a feedback loop."));
|
output your content because that would create a feedback loop."));
|
||||||
ui.slider_int(im_str!("Number of lines"), &mut state.lines, 1, 20).build();
|
ui.slider_int(im_str!("Number of lines"), &mut state.lines, 1, 20)
|
||||||
|
.build();
|
||||||
for i in 0..state.lines {
|
for i in 0..state.lines {
|
||||||
ui.text(im_str!("{:2$}This is line {}", "", i, i as usize * 4));
|
ui.text(im_str!("{:2$}This is line {}", "", i, i as usize * 4));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,8 @@ use super::{ImGuiInputTextFlags,
|
|||||||
ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackHistory,
|
ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackHistory,
|
||||||
ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal,
|
ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal,
|
||||||
ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsUppercase,
|
ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsUppercase,
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_NoHorizontalScroll, ImStr, Ui};
|
ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_NoHorizontalScroll, ImStr,
|
||||||
|
Ui};
|
||||||
|
|
||||||
macro_rules! impl_text_flags {
|
macro_rules! impl_text_flags {
|
||||||
($InputType:ident) => {
|
($InputType:ident) => {
|
||||||
|
|||||||
48
src/lib.rs
48
src/lib.rs
@ -29,15 +29,16 @@ pub use imgui_sys::{ImDrawIdx, ImDrawVert, ImGuiInputTextFlags, ImGuiInputTextFl
|
|||||||
ImGuiTreeNodeFlags_Selected, ImGuiWindowFlags,
|
ImGuiTreeNodeFlags_Selected, ImGuiWindowFlags,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_AlwaysHorizontalScrollbar,
|
ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_AlwaysHorizontalScrollbar,
|
||||||
ImGuiWindowFlags_AlwaysUseWindowPadding,
|
ImGuiWindowFlags_AlwaysUseWindowPadding,
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar, ImGuiWindowFlags_HorizontalScrollbar,
|
ImGuiWindowFlags_AlwaysVerticalScrollbar,
|
||||||
ImGuiWindowFlags_MenuBar, ImGuiWindowFlags_NoBringToFrontOnFocus,
|
ImGuiWindowFlags_HorizontalScrollbar, ImGuiWindowFlags_MenuBar,
|
||||||
ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoFocusOnAppearing,
|
ImGuiWindowFlags_NoBringToFrontOnFocus, ImGuiWindowFlags_NoCollapse,
|
||||||
ImGuiWindowFlags_NoInputs, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize,
|
ImGuiWindowFlags_NoFocusOnAppearing, ImGuiWindowFlags_NoInputs,
|
||||||
|
ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize,
|
||||||
ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse,
|
ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse,
|
||||||
ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar,
|
ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar,
|
||||||
ImGuiWindowFlags_ShowBorders, ImVec2, ImVec4};
|
ImGuiWindowFlags_ShowBorders, ImVec2, ImVec4};
|
||||||
pub use input::{ColorEdit3, ColorEdit4, InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt,
|
pub use input::{ColorEdit3, ColorEdit4, InputFloat, InputFloat2, InputFloat3, InputFloat4,
|
||||||
InputInt2, InputInt3, InputInt4, InputText};
|
InputInt, InputInt2, InputInt3, InputInt4, InputText};
|
||||||
pub use menus::{Menu, MenuItem};
|
pub use menus::{Menu, MenuItem};
|
||||||
pub use plothistogram::PlotHistogram;
|
pub use plothistogram::PlotHistogram;
|
||||||
pub use plotlines::PlotLines;
|
pub use plotlines::PlotLines;
|
||||||
@ -121,14 +122,10 @@ impl ImGui {
|
|||||||
log_filename: None,
|
log_filename: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn io(&self) -> &imgui_sys::ImGuiIO { unsafe { mem::transmute(imgui_sys::igGetIO()) } }
|
fn io(&self) -> &imgui_sys::ImGuiIO { unsafe { &*imgui_sys::igGetIO() } }
|
||||||
fn io_mut(&mut self) -> &mut imgui_sys::ImGuiIO {
|
fn io_mut(&mut self) -> &mut imgui_sys::ImGuiIO { unsafe { &mut *imgui_sys::igGetIO() } }
|
||||||
unsafe { mem::transmute(imgui_sys::igGetIO()) }
|
pub fn style(&self) -> &ImGuiStyle { unsafe { &*imgui_sys::igGetStyle() } }
|
||||||
}
|
pub fn style_mut(&mut self) -> &mut ImGuiStyle { unsafe { &mut *imgui_sys::igGetStyle() } }
|
||||||
pub fn style(&self) -> &ImGuiStyle { unsafe { mem::transmute(imgui_sys::igGetStyle()) } }
|
|
||||||
pub fn style_mut(&self) -> &mut ImGuiStyle {
|
|
||||||
unsafe { mem::transmute(imgui_sys::igGetStyle()) }
|
|
||||||
}
|
|
||||||
pub fn prepare_texture<'a, F, T>(&mut self, f: F) -> T
|
pub fn prepare_texture<'a, F, T>(&mut self, f: F) -> T
|
||||||
where F: FnOnce(TextureHandle<'a>) -> T
|
where F: FnOnce(TextureHandle<'a>) -> T
|
||||||
{
|
{
|
||||||
@ -146,7 +143,8 @@ impl ImGui {
|
|||||||
f(TextureHandle {
|
f(TextureHandle {
|
||||||
width: width as u32,
|
width: width as u32,
|
||||||
height: height as u32,
|
height: height as u32,
|
||||||
pixels: slice::from_raw_parts(pixels, (width * height * bytes_per_pixel) as usize),
|
pixels: slice::from_raw_parts(pixels,
|
||||||
|
(width * height * bytes_per_pixel) as usize),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,7 +409,9 @@ impl<'ui> Ui<'ui> {
|
|||||||
pub fn pop_item_width(&self) { unsafe { imgui_sys::igPopItemWidth() } }
|
pub fn pop_item_width(&self) { unsafe { imgui_sys::igPopItemWidth() } }
|
||||||
|
|
||||||
/// Runs a function after temporarily pushing a value to the item width stack.
|
/// Runs a function after temporarily pushing a value to the item width stack.
|
||||||
pub fn with_item_width<F>(&self, width: f32, f: F) where F: FnOnce() {
|
pub fn with_item_width<F>(&self, width: f32, f: F)
|
||||||
|
where F: FnOnce()
|
||||||
|
{
|
||||||
self.push_item_width(width);
|
self.push_item_width(width);
|
||||||
f();
|
f();
|
||||||
self.pop_item_width();
|
self.pop_item_width();
|
||||||
@ -450,20 +450,18 @@ impl<'ui> Ui<'ui> {
|
|||||||
// ID scopes
|
// ID scopes
|
||||||
impl<'ui> Ui<'ui> {
|
impl<'ui> Ui<'ui> {
|
||||||
/// Pushes an identifier to the ID stack.
|
/// Pushes an identifier to the ID stack.
|
||||||
pub fn push_id(&self, id: i32) {
|
pub fn push_id(&self, id: i32) { unsafe { imgui_sys::igPushIdInt(id) }; }
|
||||||
unsafe { imgui_sys::igPushIdInt(id) };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pops an identifier from the ID stack.
|
/// Pops an identifier from the ID stack.
|
||||||
///
|
///
|
||||||
/// # Aborts
|
/// # Aborts
|
||||||
/// The current process is aborted if the ID stack is empty.
|
/// The current process is aborted if the ID stack is empty.
|
||||||
pub fn pop_id(&self) {
|
pub fn pop_id(&self) { unsafe { imgui_sys::igPopId() }; }
|
||||||
unsafe { imgui_sys::igPopId() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Runs a function after temporarily pushing a value to the ID stack.
|
/// Runs a function after temporarily pushing a value to the ID stack.
|
||||||
pub fn with_id<F>(&self, id: i32, f: F) where F: FnOnce() {
|
pub fn with_id<F>(&self, id: i32, f: F)
|
||||||
|
where F: FnOnce()
|
||||||
|
{
|
||||||
self.push_id(id);
|
self.push_id(id);
|
||||||
f();
|
f();
|
||||||
self.pop_id();
|
self.pop_id();
|
||||||
@ -765,7 +763,5 @@ impl<'ui> Ui<'ui> {
|
|||||||
/// .overlay_text(im_str!("Progress!"))
|
/// .overlay_text(im_str!("Progress!"))
|
||||||
/// .build();
|
/// .build();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'p> {
|
pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'p> { ProgressBar::new(fraction) }
|
||||||
ProgressBar::new(fraction)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,9 @@ impl<'ui, 'p> MenuItem<'ui, 'p> {
|
|||||||
pub fn build(self) -> bool {
|
pub fn build(self) -> bool {
|
||||||
let label = self.label.as_ptr();
|
let label = self.label.as_ptr();
|
||||||
let shortcut = self.shortcut.map(|x| x.as_ptr()).unwrap_or(ptr::null());
|
let shortcut = self.shortcut.map(|x| x.as_ptr()).unwrap_or(ptr::null());
|
||||||
let selected = self.selected.map(|x| x as *mut bool).unwrap_or(ptr::null_mut());
|
let selected = self.selected
|
||||||
|
.map(|x| x as *mut bool)
|
||||||
|
.unwrap_or(ptr::null_mut());
|
||||||
let enabled = self.enabled;
|
let enabled = self.enabled;
|
||||||
unsafe { imgui_sys::igMenuItemPtr(label, shortcut, selected, enabled) }
|
unsafe { imgui_sys::igMenuItemPtr(label, shortcut, selected, enabled) }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,9 @@ impl<'p> PlotLines<'p> {
|
|||||||
self.values.as_ptr() as *const c_float,
|
self.values.as_ptr() as *const c_float,
|
||||||
self.values.len() as i32,
|
self.values.len() as i32,
|
||||||
self.values_offset as i32,
|
self.values_offset as i32,
|
||||||
self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()),
|
self.overlay_text
|
||||||
|
.map(|x| x.as_ptr())
|
||||||
|
.unwrap_or(ptr::null()),
|
||||||
self.scale_min,
|
self.scale_min,
|
||||||
self.scale_max,
|
self.scale_max,
|
||||||
self.graph_size,
|
self.graph_size,
|
||||||
|
|||||||
@ -49,7 +49,9 @@ impl<'p> ProgressBar<'p> {
|
|||||||
unsafe {
|
unsafe {
|
||||||
imgui_sys::igProgressBar(self.fraction,
|
imgui_sys::igProgressBar(self.fraction,
|
||||||
&self.size,
|
&self.size,
|
||||||
self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()));
|
self.overlay_text
|
||||||
|
.map(|x| x.as_ptr())
|
||||||
|
.unwrap_or(ptr::null()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,9 @@ use imgui_sys;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use super::{ImGuiSetCond, ImGuiTreeNodeFlags, ImGuiTreeNodeFlags_Bullet,
|
use super::{ImGuiSetCond, ImGuiTreeNodeFlags, ImGuiTreeNodeFlags_Bullet,
|
||||||
ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_OpenOnArrow,
|
ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf,
|
||||||
ImGuiTreeNodeFlags_OpenOnDoubleClick, ImGuiTreeNodeFlags_Selected, ImStr, Ui};
|
ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick,
|
||||||
|
ImGuiTreeNodeFlags_Selected, ImStr, Ui};
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct TreeNode<'ui, 'p> {
|
pub struct TreeNode<'ui, 'p> {
|
||||||
@ -85,7 +86,8 @@ impl<'ui, 'p> CollapsingHeader<'ui, 'p> {
|
|||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn open_on_double_click(mut self, value: bool) -> Self {
|
pub fn open_on_double_click(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiTreeNodeFlags_OpenOnDoubleClick, value);
|
self.flags
|
||||||
|
.set(ImGuiTreeNodeFlags_OpenOnDoubleClick, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@ -9,8 +9,8 @@ use super::{ImGuiSetCond, ImGuiWindowFlags, ImGuiWindowFlags_AlwaysAutoResize,
|
|||||||
ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoFocusOnAppearing,
|
ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoFocusOnAppearing,
|
||||||
ImGuiWindowFlags_NoInputs, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize,
|
ImGuiWindowFlags_NoInputs, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize,
|
||||||
ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse,
|
ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollWithMouse,
|
||||||
ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar, ImGuiWindowFlags_ShowBorders,
|
ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar,
|
||||||
ImStr, ImVec2, Ui};
|
ImGuiWindowFlags_ShowBorders, ImStr, ImVec2, Ui};
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct Window<'ui, 'p> {
|
pub struct Window<'ui, 'p> {
|
||||||
@ -88,7 +88,8 @@ impl<'ui, 'p> Window<'ui, 'p> {
|
|||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scrollable(mut self, value: bool) -> Self {
|
pub fn scrollable(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_NoScrollWithMouse, !value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_NoScrollWithMouse, !value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -123,32 +124,38 @@ impl<'ui, 'p> Window<'ui, 'p> {
|
|||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn horizontal_scrollbar(mut self, value: bool) -> Self {
|
pub fn horizontal_scrollbar(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_HorizontalScrollbar, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_HorizontalScrollbar, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn no_focus_on_appearing(mut self, value: bool) -> Self {
|
pub fn no_focus_on_appearing(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_NoFocusOnAppearing, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_NoFocusOnAppearing, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn no_bring_to_front_on_focus(mut self, value: bool) -> Self {
|
pub fn no_bring_to_front_on_focus(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_NoBringToFrontOnFocus, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_NoBringToFrontOnFocus, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn always_vertical_scrollbar(mut self, value: bool) -> Self {
|
pub fn always_vertical_scrollbar(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_AlwaysVerticalScrollbar, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_AlwaysVerticalScrollbar, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn always_horizontal_scrollbar(mut self, value: bool) -> Self {
|
pub fn always_horizontal_scrollbar(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_AlwaysHorizontalScrollbar, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_AlwaysHorizontalScrollbar, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn always_use_window_padding(mut self, value: bool) -> Self {
|
pub fn always_use_window_padding(mut self, value: bool) -> Self {
|
||||||
self.flags.set(ImGuiWindowFlags_AlwaysUseWindowPadding, value);
|
self.flags
|
||||||
|
.set(ImGuiWindowFlags_AlwaysUseWindowPadding, value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn build<F: FnOnce()>(self, f: F) {
|
pub fn build<F: FnOnce()>(self, f: F) {
|
||||||
@ -160,7 +167,9 @@ impl<'ui, 'p> Window<'ui, 'p> {
|
|||||||
imgui_sys::igSetNextWindowSize(self.size.into(), self.size_cond);
|
imgui_sys::igSetNextWindowSize(self.size.into(), self.size_cond);
|
||||||
}
|
}
|
||||||
imgui_sys::igBegin2(self.name.as_ptr(),
|
imgui_sys::igBegin2(self.name.as_ptr(),
|
||||||
self.opened.map(|x| x as *mut bool).unwrap_or(ptr::null_mut()),
|
self.opened
|
||||||
|
.map(|x| x as *mut bool)
|
||||||
|
.unwrap_or(ptr::null_mut()),
|
||||||
ImVec2::new(0.0, 0.0),
|
ImVec2::new(0.0, 0.0),
|
||||||
self.bg_alpha,
|
self.bg_alpha,
|
||||||
self.flags)
|
self.flags)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user