mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-15 23:48:31 +00:00
Merge pull request #164 from Gekkio/feature/cimgui-1.65.2
Upgrade to imgui 1.65 + cimgui 1.65.2
This commit is contained in:
commit
411a7c7514
@ -2,6 +2,11 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrade to cimgui 1.65.2 / imgui 1.65. **This is a very big update, so there
|
||||
are a lot of breaking changes**
|
||||
|
||||
## [0.0.21] - 2018-10-11
|
||||
|
||||
### Added
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
Minimum Rust version: 1.26
|
||||
|
||||
Wrapped Dear ImGui version: 1.65
|
||||
|
||||
[](https://travis-ci.org/Gekkio/imgui-rs)
|
||||
[](https://crates.io/crates/imgui)
|
||||
[](https://docs.rs/imgui)
|
||||
@ -84,7 +86,7 @@ Licensed under either of
|
||||
|
||||
at your option.
|
||||
|
||||
Uses [ImGui](https://github.com/ocornut/imgui) and [cimgui](https://github.com/Extrawurst/cimgui).
|
||||
Uses [ImGui](https://github.com/ocornut/imgui) and [cimgui](https://github.com/cimgui/cimgui).
|
||||
|
||||
### Contribution
|
||||
|
||||
|
||||
BIN
hello_world.png
BIN
hello_world.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 2.5 KiB |
@ -145,7 +145,7 @@ fn example_2(ui: &Ui) {
|
||||
im_str!("Red + ColorPreview::HalfAlpha"),
|
||||
(1.0, 0.0, 0.0, 0.5),
|
||||
).preview(ColorPreview::HalfAlpha)
|
||||
.build();
|
||||
.build();
|
||||
|
||||
ui.separator();
|
||||
ui.text_wrapped(im_str!(
|
||||
|
||||
@ -30,9 +30,17 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
|
||||
let font_size = (13.0 * hidpi_factor) as f32;
|
||||
|
||||
imgui.fonts().add_default_font_with_config(
|
||||
ImFontConfig::new()
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size),
|
||||
);
|
||||
|
||||
imgui.fonts().add_font_with_config(
|
||||
include_bytes!("../mplus-1p-regular.ttf"),
|
||||
ImFontConfig::new()
|
||||
.merge_mode(true)
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size)
|
||||
@ -40,14 +48,6 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
&FontGlyphRange::japanese(),
|
||||
);
|
||||
|
||||
imgui.fonts().add_default_font_with_config(
|
||||
ImFontConfig::new()
|
||||
.merge_mode(true)
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size),
|
||||
);
|
||||
|
||||
imgui.set_font_global_scale((1.0 / hidpi_factor) as f32);
|
||||
|
||||
let mut renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer");
|
||||
@ -155,11 +155,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"),
|
||||
ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow,
|
||||
ImGuiMouseCursor::TextInput => glutin::MouseCursor::Text,
|
||||
ImGuiMouseCursor::Move => glutin::MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeAll => glutin::MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeNS => glutin::MouseCursor::NsResize,
|
||||
ImGuiMouseCursor::ResizeEW => glutin::MouseCursor::EwResize,
|
||||
ImGuiMouseCursor::ResizeNESW => glutin::MouseCursor::NeswResize,
|
||||
ImGuiMouseCursor::ResizeNWSE => glutin::MouseCursor::NwseResize,
|
||||
ImGuiMouseCursor::Hand => glutin::MouseCursor::Hand,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -66,9 +66,17 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
|
||||
let font_size = (13.0 * hidpi_factor) as f32;
|
||||
|
||||
imgui.fonts().add_default_font_with_config(
|
||||
ImFontConfig::new()
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size),
|
||||
);
|
||||
|
||||
imgui.fonts().add_font_with_config(
|
||||
include_bytes!("../mplus-1p-regular.ttf"),
|
||||
ImFontConfig::new()
|
||||
.merge_mode(true)
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size)
|
||||
@ -76,14 +84,6 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
&FontGlyphRange::japanese(),
|
||||
);
|
||||
|
||||
imgui.fonts().add_default_font_with_config(
|
||||
ImFontConfig::new()
|
||||
.merge_mode(true)
|
||||
.oversample_h(1)
|
||||
.pixel_snap_h(true)
|
||||
.size_pixels(font_size),
|
||||
);
|
||||
|
||||
imgui.set_font_global_scale((1.0 / hidpi_factor) as f32);
|
||||
|
||||
let mut renderer = Renderer::init(&mut imgui, &mut factory, shaders, main_color.clone())
|
||||
@ -199,11 +199,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"),
|
||||
ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow,
|
||||
ImGuiMouseCursor::TextInput => glutin::MouseCursor::Text,
|
||||
ImGuiMouseCursor::Move => glutin::MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeAll => glutin::MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeNS => glutin::MouseCursor::NsResize,
|
||||
ImGuiMouseCursor::ResizeEW => glutin::MouseCursor::EwResize,
|
||||
ImGuiMouseCursor::ResizeNESW => glutin::MouseCursor::NeswResize,
|
||||
ImGuiMouseCursor::ResizeNWSE => glutin::MouseCursor::NwseResize,
|
||||
ImGuiMouseCursor::Hand => glutin::MouseCursor::Hand,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,7 @@ fn main() {
|
||||
canvas_pos,
|
||||
[canvas_pos.0 + RADIUS, canvas_pos.1 + RADIUS],
|
||||
RED,
|
||||
)
|
||||
.thickness(5.0)
|
||||
).thickness(5.0)
|
||||
.build();
|
||||
|
||||
channels.set_current(0);
|
||||
|
||||
@ -778,7 +778,7 @@ fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) {
|
||||
ui.checkbox(im_str!("Check"), &mut state.b);
|
||||
});
|
||||
ui.menu(im_str!("Colors")).build(|| {
|
||||
for &col in ImGuiCol::values() {
|
||||
for &col in ImGuiCol::VARIANTS.iter() {
|
||||
ui.menu_item(imgui::get_style_color_name(col)).build();
|
||||
}
|
||||
});
|
||||
@ -879,8 +879,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(x + state.sz * 0.5, y + state.sz * 0.5),
|
||||
state.sz * 0.5,
|
||||
state.col,
|
||||
)
|
||||
.num_segments(20)
|
||||
).num_segments(20)
|
||||
.thickness(thickness)
|
||||
.build();
|
||||
x += state.sz + spacing;
|
||||
@ -909,8 +908,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(x + state.sz, y + state.sz - 0.5),
|
||||
(x, y + state.sz - 0.5),
|
||||
state.col,
|
||||
)
|
||||
.thickness(thickness)
|
||||
).thickness(thickness)
|
||||
.build();
|
||||
x += state.sz + spacing;
|
||||
draw_list
|
||||
@ -935,8 +933,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(x + state.sz - state.sz * 1.3, y + state.sz - state.sz * 0.3),
|
||||
(x + state.sz, y + state.sz),
|
||||
state.col,
|
||||
)
|
||||
.thickness(thickness)
|
||||
).thickness(thickness)
|
||||
.build();
|
||||
y += state.sz + spacing;
|
||||
}
|
||||
@ -946,8 +943,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(x + state.sz * 0.5, y + state.sz * 0.5),
|
||||
state.sz * 0.5,
|
||||
state.col,
|
||||
)
|
||||
.num_segments(32)
|
||||
).num_segments(32)
|
||||
.filled(true)
|
||||
.build();
|
||||
x += state.sz + spacing;
|
||||
@ -976,8 +972,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(x + state.sz, y + state.sz - 0.5),
|
||||
(x, y + state.sz - 0.5),
|
||||
state.col,
|
||||
)
|
||||
.filled(true)
|
||||
).filled(true)
|
||||
.build();
|
||||
x += state.sz + spacing;
|
||||
const MULTICOLOR_RECT_CORNER_COLOR1: [f32; 3] = [0.0, 0.0, 0.0];
|
||||
@ -1046,8 +1041,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
canvas_pos,
|
||||
(canvas_pos.0 + canvas_size.0, canvas_pos.1 + canvas_size.1),
|
||||
CANVAS_BORDER_COLOR,
|
||||
)
|
||||
.build();
|
||||
).build();
|
||||
|
||||
let mut adding_preview = false;
|
||||
ui.invisible_button(im_str!("canvas"), canvas_size);
|
||||
@ -1088,8 +1082,7 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
|
||||
(canvas_pos.0 + p1.0, canvas_pos.1 + p1.1),
|
||||
(canvas_pos.0 + p2.0, canvas_pos.1 + p2.1),
|
||||
LINE_COLOR,
|
||||
)
|
||||
.thickness(2.0)
|
||||
).thickness(2.0)
|
||||
.build();
|
||||
}
|
||||
},
|
||||
|
||||
@ -4,11 +4,11 @@ extern crate imgui;
|
||||
|
||||
use gfx::handle::{Buffer, RenderTargetView};
|
||||
use gfx::memory::Bind;
|
||||
use gfx::pso::{PipelineData, PipelineState};
|
||||
use gfx::texture::{FilterMethod, SamplerInfo, WrapMode};
|
||||
use gfx::traits::FactoryExt;
|
||||
use gfx::{CommandBuffer, Encoder, Factory, IntoIndexBuffer, Rect, Resources, Slice};
|
||||
use gfx::pso::{PipelineData, PipelineState};
|
||||
use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, Ui, Textures, ImTexture};
|
||||
use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, ImTexture, Textures, Ui};
|
||||
|
||||
pub type RendererResult<T> = Result<T, RendererError>;
|
||||
|
||||
@ -131,7 +131,10 @@ impl Shaders {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Texture<R> = (gfx::handle::ShaderResourceView<R, [f32; 4]>, gfx::handle::Sampler<R>);
|
||||
pub type Texture<R> = (
|
||||
gfx::handle::ShaderResourceView<R, [f32; 4]>,
|
||||
gfx::handle::Sampler<R>,
|
||||
);
|
||||
|
||||
pub struct Renderer<R: Resources> {
|
||||
bundle: Bundle<R, pipe::Data<R>>,
|
||||
@ -254,7 +257,9 @@ impl<R: Resources> Renderer<R> {
|
||||
self.bundle.slice.start = 0;
|
||||
for cmd in draw_list.cmd_buffer {
|
||||
let texture_id = cmd.texture_id.into();
|
||||
let tex = self.textures.get(texture_id)
|
||||
let tex = self
|
||||
.textures
|
||||
.get(texture_id)
|
||||
.ok_or_else(|| RendererError::BadTexture(texture_id))?;
|
||||
|
||||
self.bundle.slice.end = self.bundle.slice.start + cmd.elem_count;
|
||||
|
||||
@ -8,7 +8,7 @@ use glium::program;
|
||||
use glium::texture;
|
||||
use glium::vertex;
|
||||
use glium::{DrawError, IndexBuffer, Program, Surface, Texture2d, VertexBuffer};
|
||||
use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, Ui, Textures, ImTexture};
|
||||
use imgui::{DrawList, FrameSize, ImDrawIdx, ImDrawVert, ImGui, ImTexture, Textures, Ui};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
@ -137,7 +137,10 @@ impl Renderer {
|
||||
let mut idx_start = 0;
|
||||
for cmd in draw_list.cmd_buffer {
|
||||
let texture_id = cmd.texture_id.into();
|
||||
let texture = self.device_objects.textures.get(texture_id)
|
||||
let texture = self
|
||||
.device_objects
|
||||
.textures
|
||||
.get(texture_id)
|
||||
.ok_or_else(|| RendererError::BadTexture(texture_id))?;
|
||||
|
||||
let idx_end = idx_start + cmd.elem_count as usize;
|
||||
|
||||
@ -210,11 +210,12 @@ pub fn update_mouse_cursor(imgui: &ImGui, window: &Window) {
|
||||
ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"),
|
||||
ImGuiMouseCursor::Arrow => MouseCursor::Arrow,
|
||||
ImGuiMouseCursor::TextInput => MouseCursor::Text,
|
||||
ImGuiMouseCursor::Move => MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeAll => MouseCursor::Move,
|
||||
ImGuiMouseCursor::ResizeNS => MouseCursor::NsResize,
|
||||
ImGuiMouseCursor::ResizeEW => MouseCursor::EwResize,
|
||||
ImGuiMouseCursor::ResizeNESW => MouseCursor::NeswResize,
|
||||
ImGuiMouseCursor::ResizeNWSE => MouseCursor::NwseResize,
|
||||
ImGuiMouseCursor::Hand => MouseCursor::Hand,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,12 +3,10 @@ extern crate cc;
|
||||
fn main() {
|
||||
cc::Build::new()
|
||||
.cpp(true)
|
||||
.file("third-party/cimgui/cimgui/cimgui.cpp")
|
||||
.file("third-party/cimgui/cimgui/fontAtlas.cpp")
|
||||
.file("third-party/cimgui/cimgui/drawList.cpp")
|
||||
.file("third-party/cimgui/cimgui/listClipper.cpp")
|
||||
.file("third-party/cimgui/cimgui.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_demo.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_draw.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_widgets.cpp")
|
||||
.compile("libcimgui.a");
|
||||
}
|
||||
|
||||
430
imgui-sys/src/enums.rs
Normal file
430
imgui-sys/src/enums.rs
Normal file
@ -0,0 +1,430 @@
|
||||
/// A color identifier for styling
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiCol {
|
||||
Text,
|
||||
TextDisabled,
|
||||
/// Background of normal windows
|
||||
WindowBg,
|
||||
/// Background of child windows
|
||||
ChildBg,
|
||||
/// Background of popups, menus, tooltips windows
|
||||
PopupBg,
|
||||
Border,
|
||||
BorderShadow,
|
||||
/// Background of checkbox, radio button, plot, slider, text input
|
||||
FrameBg,
|
||||
FrameBgHovered,
|
||||
FrameBgActive,
|
||||
TitleBg,
|
||||
TitleBgActive,
|
||||
TitleBgCollapsed,
|
||||
MenuBarBg,
|
||||
ScrollbarBg,
|
||||
ScrollbarGrab,
|
||||
ScrollbarGrabHovered,
|
||||
ScrollbarGrabActive,
|
||||
CheckMark,
|
||||
SliderGrab,
|
||||
SliderGrabActive,
|
||||
Button,
|
||||
ButtonHovered,
|
||||
ButtonActive,
|
||||
Header,
|
||||
HeaderHovered,
|
||||
HeaderActive,
|
||||
Separator,
|
||||
SeparatorHovered,
|
||||
SeparatorActive,
|
||||
ResizeGrip,
|
||||
ResizeGripHovered,
|
||||
ResizeGripActive,
|
||||
PlotLines,
|
||||
PlotLinesHovered,
|
||||
PlotHistogram,
|
||||
PlotHistogramHovered,
|
||||
TextSelectedBg,
|
||||
DragDropTarget,
|
||||
/// Gamepad/keyboard: current highlighted item
|
||||
NavHighlight,
|
||||
/// Highlight window when using CTRL+TAB
|
||||
NavWindowingHighlight,
|
||||
/// Darken/colorize entire screen behind the CTRL+TAB window list, when active
|
||||
NavWindowingDimBg,
|
||||
/// Darken/colorize entire screen behind a modal window, when one is active
|
||||
ModalWindowDimBg,
|
||||
}
|
||||
impl ImGuiCol {
|
||||
/// All possible `ImGuiCol` variants
|
||||
pub const VARIANTS: [ImGuiCol; 43] = [
|
||||
ImGuiCol::Text,
|
||||
ImGuiCol::TextDisabled,
|
||||
ImGuiCol::WindowBg,
|
||||
ImGuiCol::ChildBg,
|
||||
ImGuiCol::PopupBg,
|
||||
ImGuiCol::Border,
|
||||
ImGuiCol::BorderShadow,
|
||||
ImGuiCol::FrameBg,
|
||||
ImGuiCol::FrameBgHovered,
|
||||
ImGuiCol::FrameBgActive,
|
||||
ImGuiCol::TitleBg,
|
||||
ImGuiCol::TitleBgActive,
|
||||
ImGuiCol::TitleBgCollapsed,
|
||||
ImGuiCol::MenuBarBg,
|
||||
ImGuiCol::ScrollbarBg,
|
||||
ImGuiCol::ScrollbarGrab,
|
||||
ImGuiCol::ScrollbarGrabHovered,
|
||||
ImGuiCol::ScrollbarGrabActive,
|
||||
ImGuiCol::CheckMark,
|
||||
ImGuiCol::SliderGrab,
|
||||
ImGuiCol::SliderGrabActive,
|
||||
ImGuiCol::Button,
|
||||
ImGuiCol::ButtonHovered,
|
||||
ImGuiCol::ButtonActive,
|
||||
ImGuiCol::Header,
|
||||
ImGuiCol::HeaderHovered,
|
||||
ImGuiCol::HeaderActive,
|
||||
ImGuiCol::Separator,
|
||||
ImGuiCol::SeparatorHovered,
|
||||
ImGuiCol::SeparatorActive,
|
||||
ImGuiCol::ResizeGrip,
|
||||
ImGuiCol::ResizeGripHovered,
|
||||
ImGuiCol::ResizeGripActive,
|
||||
ImGuiCol::PlotLines,
|
||||
ImGuiCol::PlotLinesHovered,
|
||||
ImGuiCol::PlotHistogram,
|
||||
ImGuiCol::PlotHistogramHovered,
|
||||
ImGuiCol::TextSelectedBg,
|
||||
ImGuiCol::DragDropTarget,
|
||||
ImGuiCol::NavHighlight,
|
||||
ImGuiCol::NavWindowingHighlight,
|
||||
ImGuiCol::NavWindowingDimBg,
|
||||
ImGuiCol::ModalWindowDimBg,
|
||||
];
|
||||
pub const COUNT: usize = 43;
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiCol::ModalWindowDimBg instead"
|
||||
)]
|
||||
pub const ModalWindowDarkening: ImGuiCol = ImGuiCol::ModalWindowDimBg;
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiCol::VARIANTS instead"
|
||||
)]
|
||||
pub fn values() -> &'static [ImGuiCol] {
|
||||
&ImGuiCol::VARIANTS
|
||||
}
|
||||
}
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiCol::COUNT instead"
|
||||
)]
|
||||
pub const ImGuiCol_COUNT: usize = 43;
|
||||
|
||||
/// A primary data type
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiDataType {
|
||||
/// `i32` (C data type `int`)
|
||||
S32,
|
||||
/// `u32` (C data type `unsigned int`)
|
||||
U32,
|
||||
/// `i64` (C data type `long long`, `__int64`)
|
||||
S64,
|
||||
/// `u64` (C data type `unsigned long long`, `unsigned __int64`)
|
||||
U64,
|
||||
/// `f32` (C data type `float`)
|
||||
Float,
|
||||
/// `f64` (C data type `double`)
|
||||
Double,
|
||||
}
|
||||
impl ImGuiDataType {
|
||||
/// All possible `ImGuiDataType` variants
|
||||
pub const VARIANTS: [ImGuiDataType; 6] = [
|
||||
ImGuiDataType::S32,
|
||||
ImGuiDataType::U32,
|
||||
ImGuiDataType::S64,
|
||||
ImGuiDataType::U64,
|
||||
ImGuiDataType::Float,
|
||||
ImGuiDataType::Double,
|
||||
];
|
||||
}
|
||||
|
||||
/// A cardinal direction
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiDir {
|
||||
None = -1,
|
||||
Left = 0,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
}
|
||||
impl ImGuiDir {
|
||||
/// All possible `ImGuiDir` variants, except None
|
||||
pub const VARIANTS: [ImGuiDir; 4] = [
|
||||
// None variant intentionally skipped
|
||||
ImGuiDir::Left,
|
||||
ImGuiDir::Right,
|
||||
ImGuiDir::Up,
|
||||
ImGuiDir::Down,
|
||||
];
|
||||
}
|
||||
|
||||
/// A key identifier (ImGui-side enum)
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiKey {
|
||||
Tab,
|
||||
LeftArrow,
|
||||
RightArrow,
|
||||
UpArrow,
|
||||
DownArrow,
|
||||
PageUp,
|
||||
PageDown,
|
||||
Home,
|
||||
End,
|
||||
Insert,
|
||||
Delete,
|
||||
Backspace,
|
||||
Space,
|
||||
Enter,
|
||||
Escape,
|
||||
/// for text edit CTRL+A: select all
|
||||
A,
|
||||
/// for text edit CTRL+C: copy
|
||||
C,
|
||||
/// for text edit CTRL+V: paste
|
||||
V,
|
||||
/// for text edit CTRL+X: cut
|
||||
X,
|
||||
/// for text edit CTRL+Y: redo
|
||||
Y,
|
||||
/// for text edit CTRL+Z: undo
|
||||
Z,
|
||||
}
|
||||
impl ImGuiKey {
|
||||
/// All possible `ImGuiKey` variants
|
||||
pub const VARIANTS: [ImGuiKey; 21] = [
|
||||
ImGuiKey::Tab,
|
||||
ImGuiKey::LeftArrow,
|
||||
ImGuiKey::RightArrow,
|
||||
ImGuiKey::UpArrow,
|
||||
ImGuiKey::DownArrow,
|
||||
ImGuiKey::PageUp,
|
||||
ImGuiKey::PageDown,
|
||||
ImGuiKey::Home,
|
||||
ImGuiKey::End,
|
||||
ImGuiKey::Insert,
|
||||
ImGuiKey::Delete,
|
||||
ImGuiKey::Backspace,
|
||||
ImGuiKey::Space,
|
||||
ImGuiKey::Enter,
|
||||
ImGuiKey::Escape,
|
||||
ImGuiKey::A,
|
||||
ImGuiKey::C,
|
||||
ImGuiKey::V,
|
||||
ImGuiKey::X,
|
||||
ImGuiKey::Y,
|
||||
ImGuiKey::Z,
|
||||
];
|
||||
pub const COUNT: usize = 21;
|
||||
}
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiKey::COUNT instead"
|
||||
)]
|
||||
pub const ImGuiKey_COUNT: usize = 21;
|
||||
|
||||
/// A mouse cursor identifier
|
||||
///
|
||||
/// User code may request binding to display given cursor, which is why we have some cursors that
|
||||
/// are marked unused here
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiMouseCursor {
|
||||
None = -1,
|
||||
Arrow = 0,
|
||||
/// When hovering over InputText, etc.
|
||||
TextInput,
|
||||
/// (Unused by imgui functions)
|
||||
ResizeAll,
|
||||
/// When hovering over an horizontal border
|
||||
ResizeNS,
|
||||
/// When hovering over a vertical border or a column
|
||||
ResizeEW,
|
||||
/// When hovering over the bottom-left corner of a window
|
||||
ResizeNESW,
|
||||
/// When hovering over the bottom-right corner of a window
|
||||
ResizeNWSE,
|
||||
/// (Unused by imgui functions. Use for e.g. hyperlinks)
|
||||
Hand,
|
||||
}
|
||||
impl ImGuiMouseCursor {
|
||||
/// All possible `ImGuiMouseCursor` variants, except None
|
||||
pub const VARIANTS: [ImGuiMouseCursor; 8] = [
|
||||
// None variant intentionally skipped
|
||||
ImGuiMouseCursor::Arrow,
|
||||
ImGuiMouseCursor::TextInput,
|
||||
ImGuiMouseCursor::ResizeAll,
|
||||
ImGuiMouseCursor::ResizeNS,
|
||||
ImGuiMouseCursor::ResizeEW,
|
||||
ImGuiMouseCursor::ResizeNESW,
|
||||
ImGuiMouseCursor::ResizeNWSE,
|
||||
ImGuiMouseCursor::Hand,
|
||||
];
|
||||
}
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiMouseCursor::VARIANTS.len() instead"
|
||||
)]
|
||||
pub const ImGuiMouseCursor_COUNT: usize = 8;
|
||||
|
||||
/// An input identifier for navigation
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiNavInput {
|
||||
/// activate / open / toggle / tweak value
|
||||
///
|
||||
/// e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard)
|
||||
Activate,
|
||||
/// cancel / close / exit
|
||||
///
|
||||
/// e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard)
|
||||
Cancel,
|
||||
/// text input / on-screen keyboard
|
||||
///
|
||||
/// e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
|
||||
Input,
|
||||
/// tap: toggle menu / hold: focus, move, resize
|
||||
///
|
||||
/// e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
|
||||
Menu,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Left (Gamepads), Left arrow (Keyboard)
|
||||
DpadLeft,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Right (Gamepads), Right arrow (Keyboard)
|
||||
DpadRight,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Up (Gamepads), Up arrow (Keyboard)
|
||||
DpadUp,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Down (Gamepads), Down arrow (Keyboard)
|
||||
DpadDown,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Left
|
||||
LStickLeft,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Right
|
||||
LStickRight,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Up
|
||||
LStickUp,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Down
|
||||
LStickDown,
|
||||
/// next window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||
FocusPrev,
|
||||
/// prev window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||
FocusNext,
|
||||
/// slower tweaks
|
||||
///
|
||||
/// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||
TweakSlow,
|
||||
/// faster tweaks
|
||||
///
|
||||
/// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||
TweakFast,
|
||||
}
|
||||
impl ImGuiNavInput {
|
||||
/// All possible `ImGuiNavInput` variants
|
||||
pub const VARIANTS: [ImGuiNavInput; 16] = [
|
||||
ImGuiNavInput::Activate,
|
||||
ImGuiNavInput::Cancel,
|
||||
ImGuiNavInput::Input,
|
||||
ImGuiNavInput::Menu,
|
||||
ImGuiNavInput::DpadLeft,
|
||||
ImGuiNavInput::DpadRight,
|
||||
ImGuiNavInput::DpadUp,
|
||||
ImGuiNavInput::DpadDown,
|
||||
ImGuiNavInput::LStickLeft,
|
||||
ImGuiNavInput::LStickRight,
|
||||
ImGuiNavInput::LStickUp,
|
||||
ImGuiNavInput::LStickDown,
|
||||
ImGuiNavInput::FocusPrev,
|
||||
ImGuiNavInput::FocusNext,
|
||||
ImGuiNavInput::TweakSlow,
|
||||
ImGuiNavInput::TweakFast,
|
||||
];
|
||||
pub const COUNT: usize = 16;
|
||||
}
|
||||
|
||||
/// A variable identifier for styling
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiStyleVar {
|
||||
Alpha,
|
||||
WindowPadding,
|
||||
WindowRounding,
|
||||
WindowBorderSize,
|
||||
WindowMinSize,
|
||||
WindowTitleAlign,
|
||||
ChildRounding,
|
||||
ChildBorderSize,
|
||||
PopupRounding,
|
||||
PopupBorderSize,
|
||||
FramePadding,
|
||||
FrameRounding,
|
||||
FrameBorderSize,
|
||||
ItemSpacing,
|
||||
ItemInnerSpacing,
|
||||
IndentSpacing,
|
||||
ScrollbarSize,
|
||||
ScrollbarRounding,
|
||||
GrabMinSize,
|
||||
GrabRounding,
|
||||
ButtonTextAlign,
|
||||
}
|
||||
impl ImGuiStyleVar {
|
||||
pub const VARIANTS: [ImGuiStyleVar; 21] = [
|
||||
ImGuiStyleVar::Alpha,
|
||||
ImGuiStyleVar::WindowPadding,
|
||||
ImGuiStyleVar::WindowRounding,
|
||||
ImGuiStyleVar::WindowBorderSize,
|
||||
ImGuiStyleVar::WindowMinSize,
|
||||
ImGuiStyleVar::WindowTitleAlign,
|
||||
ImGuiStyleVar::ChildRounding,
|
||||
ImGuiStyleVar::ChildBorderSize,
|
||||
ImGuiStyleVar::PopupRounding,
|
||||
ImGuiStyleVar::PopupBorderSize,
|
||||
ImGuiStyleVar::FramePadding,
|
||||
ImGuiStyleVar::FrameRounding,
|
||||
ImGuiStyleVar::FrameBorderSize,
|
||||
ImGuiStyleVar::ItemSpacing,
|
||||
ImGuiStyleVar::ItemInnerSpacing,
|
||||
ImGuiStyleVar::IndentSpacing,
|
||||
ImGuiStyleVar::ScrollbarSize,
|
||||
ImGuiStyleVar::ScrollbarRounding,
|
||||
ImGuiStyleVar::GrabMinSize,
|
||||
ImGuiStyleVar::GrabRounding,
|
||||
ImGuiStyleVar::ButtonTextAlign,
|
||||
];
|
||||
}
|
||||
#[deprecated(
|
||||
since = "0.0.21",
|
||||
note = "please use ImGuiStyleVar::VARIANTS.len() instead"
|
||||
)]
|
||||
pub const ImGuiStyleVar_COUNT: usize = 21;
|
||||
409
imgui-sys/src/flags.rs
Normal file
409
imgui-sys/src/flags.rs
Normal file
@ -0,0 +1,409 @@
|
||||
use std::os::raw::c_int;
|
||||
|
||||
bitflags!(
|
||||
/// Back-end capability flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiBackendFlags: c_int {
|
||||
/// Back-end supports gamepad and currently has one connected.
|
||||
const HasGamepad = 1;
|
||||
/// Back-end supports honoring GetMouseCursor() value to change the OS cursor shape.
|
||||
const HasMouseCursors = 1 << 1;
|
||||
/// Back-end supports want_set_mouse_pos requests to reposition the OS mouse position.
|
||||
const HasSetMousePos = 1 << 2;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Color edit flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiColorEditFlags: c_int {
|
||||
/// ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the
|
||||
/// input pointer).
|
||||
const NoAlpha = 1;
|
||||
/// ColorEdit: disable picker when clicking on colored square.
|
||||
const NoPicker = 1 << 2;
|
||||
/// ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
|
||||
const NoOptions = 1 << 3;
|
||||
/// ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to
|
||||
/// show only the inputs)
|
||||
const NoSmallPreview = 1 << 4;
|
||||
/// ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the
|
||||
/// small preview colored square).
|
||||
const NoInputs = 1 << 5;
|
||||
/// ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
|
||||
const NoTooltip = 1 << 6;
|
||||
/// ColorEdit, ColorPicker: disable display of inline text label (the label is still
|
||||
/// forwarded to the tooltip and picker).
|
||||
const NoLabel = 1 << 7;
|
||||
/// ColorPicker: disable bigger color preview on right side of the picker, use small
|
||||
/// colored square preview instead.
|
||||
const NoSidePreview = 1 << 8;
|
||||
/// ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
|
||||
const NoDragDrop = 1 << 9;
|
||||
|
||||
/// ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
|
||||
const AlphaBar = 1 << 16;
|
||||
/// ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a
|
||||
/// checkerboard, instead of opaque.
|
||||
const AlphaPreview = 1 << 17;
|
||||
/// ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead
|
||||
/// of opaque.
|
||||
const AlphaPreviewHalf= 1 << 18;
|
||||
/// (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you
|
||||
/// probably want to use ImGuiColorEditFlags::Float flag as well).
|
||||
const HDR = 1 << 19;
|
||||
/// ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using
|
||||
/// RGB/HSV/HEX.
|
||||
const RGB = 1 << 20;
|
||||
const HSV = 1 << 21;
|
||||
const HEX = 1 << 22;
|
||||
/// ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
|
||||
const Uint8 = 1 << 23;
|
||||
/// ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats
|
||||
/// instead of 0..255 integers. No round-trip of value via integers.
|
||||
const Float = 1 << 24;
|
||||
/// ColorPicker: bar for Hue, rectangle for Sat/Value.
|
||||
const PickerHueBar = 1 << 25;
|
||||
/// ColorPicker: wheel for Hue, triangle for Sat/Value.
|
||||
const PickerHueWheel = 1 << 26;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for combo boxes
|
||||
#[repr(C)]
|
||||
pub struct ImGuiComboFlags: c_int {
|
||||
/// Align the popup toward the left by default
|
||||
const PopupAlignLeft = 1;
|
||||
/// Max ~4 items visible.
|
||||
const HeightSmall = 1 << 1;
|
||||
/// Max ~8 items visible (default)
|
||||
const HeightRegular = 1 << 2;
|
||||
/// Max ~20 items visible
|
||||
const HeightLarge = 1 << 3;
|
||||
/// As many fitting items as possible
|
||||
const HeightLargest = 1 << 4;
|
||||
/// Display on the preview box without the square arrow button
|
||||
const NoArrowButton = 1 << 5;
|
||||
/// Display only a square arrow button
|
||||
const NoPreview = 1 << 6;
|
||||
|
||||
const HeightMask = ImGuiComboFlags::HeightSmall.bits
|
||||
| ImGuiComboFlags::HeightRegular.bits
|
||||
| ImGuiComboFlags::HeightLarge.bits
|
||||
| ImGuiComboFlags::HeightLargest.bits;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Condition flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiCond: c_int {
|
||||
/// Set the variable
|
||||
const Always = 1;
|
||||
/// Set the variable once per runtime session (only the first call with succeed)
|
||||
const Once = 1 << 1;
|
||||
/// Set the variable if the object/window has no persistently saved data (no entry in .ini
|
||||
/// file)
|
||||
const FirstUseEver = 1 << 2;
|
||||
/// Set the variable if the object/window is appearing after being hidden/inactive (or the
|
||||
/// first time)
|
||||
const Appearing = 1 << 3;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Configuration flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiConfigFlags: c_int {
|
||||
/// Master keyboard navigation enable flag.
|
||||
const NavEnableKeyboard = 1;
|
||||
/// Master gamepad navigation enable flag.
|
||||
const NavEnableGamepad = 1 << 1;
|
||||
/// Instruct navigation to move the mouse cursor. May be useful on TV/console systems where
|
||||
/// moving a virtual mouse is awkward.
|
||||
const NavEnableSetMousePos = 1 << 2;
|
||||
/// Instruct navigation to not set the want_capture_keyboard flag when nav_active is set.
|
||||
const NavNoCaptureKeyboard = 1 << 3;
|
||||
/// Instruct imgui to clear mouse position/buttons on a new frame. This allows ignoring the
|
||||
/// mouse information set by the back-end.
|
||||
const NoMouse = 1 << 4;
|
||||
/// Instruct back-end to not alter mouse cursor shape and visibility.
|
||||
const NoMouseCursorChange = 1 << 5;
|
||||
/// Application is SRGB-aware.
|
||||
const IsSRGB = 1 << 20;
|
||||
/// Application is using a touch screen instead of a mouse.
|
||||
const IsTouchScreen = 1 << 21;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for igBeginDragDropSource(), igAcceptDragDropPayload()
|
||||
#[repr(C)]
|
||||
pub struct ImGuiDragDropFlags: c_int {
|
||||
/// By default, a successful call to igBeginDragDropSource opens a tooltip so you can
|
||||
/// display a preview or description of the source contents. This flag disable this
|
||||
/// behavior.
|
||||
const SourceNoPreviewTooltip = 1;
|
||||
/// By default, when dragging we clear data so that igIsItemHovered() will return false, to
|
||||
/// avoid subsequent user code submitting tooltips. This flag disable this behavior so you
|
||||
/// can still call igIsItemHovered() on the source item.
|
||||
const SourceNoDisableHover = 1 << 1;
|
||||
/// Disable the behavior that allows to open tree nodes and collapsing header by holding
|
||||
/// over them while dragging a source item.
|
||||
const SourceNoHoldToOpenOthers = 1 << 2;
|
||||
/// Allow items such as igText(), igImage() that have no unique identifier to be used as
|
||||
/// drag source, by manufacturing a temporary identifier based on their window-relative
|
||||
/// position. This is extremely unusual within the dear imgui ecosystem and so we made it
|
||||
/// explicit.
|
||||
const SourceAllowNullID = 1 << 3;
|
||||
/// External source (from outside of imgui), won't attempt to read current item/window
|
||||
/// info. Will always return true. Only one Extern source can be active simultaneously.
|
||||
const SourceExtern = 1 << 4;
|
||||
/// Automatically expire the payload if the source cease to be submitted (otherwise
|
||||
/// payloads are persisting while being dragged)
|
||||
const SourceAutoExpirePayload = 1 << 5;
|
||||
/// igAcceptDragDropPayload() will returns true even before the mouse button is released.
|
||||
/// You can then call igIsDelivery() to test if the payload needs to be delivered.
|
||||
const AcceptBeforeDelivery = 1 << 10;
|
||||
/// Do not draw the default highlight rectangle when hovering over target.
|
||||
const AcceptNoDrawDefaultRect = 1 << 11;
|
||||
/// Request hiding the igBeginDragDropSource tooltip from the igBeginDragDropTarget site.
|
||||
const AcceptNoPreviewTooltip = 1 << 12;
|
||||
/// For peeking ahead and inspecting the payload before delivery.
|
||||
const AcceptPeekOnly = ImGuiDragDropFlags::AcceptBeforeDelivery.bits
|
||||
| ImGuiDragDropFlags::AcceptNoDrawDefaultRect.bits;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for indictating which corner of a rectangle should be rounded
|
||||
#[repr(C)]
|
||||
pub struct ImDrawCornerFlags: c_int {
|
||||
const TopLeft = 1;
|
||||
const TopRight = 1 << 1;
|
||||
const BotLeft = 1 << 2;
|
||||
const BotRight = 1 << 3;
|
||||
const Top = ImDrawCornerFlags::TopLeft.bits
|
||||
| ImDrawCornerFlags::TopRight.bits;
|
||||
const Bot = ImDrawCornerFlags::BotLeft.bits
|
||||
| ImDrawCornerFlags::BotRight.bits;
|
||||
const Left = ImDrawCornerFlags::TopLeft.bits
|
||||
| ImDrawCornerFlags::BotLeft.bits;
|
||||
const Right = ImDrawCornerFlags::TopRight.bits
|
||||
| ImDrawCornerFlags::BotRight.bits;
|
||||
const All = 0xF;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Draw list flags
|
||||
#[repr(C)]
|
||||
pub struct ImDrawListFlags: c_int {
|
||||
const AntiAliasedLines = 1;
|
||||
const AntiAliasedFill = 1 << 1;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for window focus checks
|
||||
#[repr(C)]
|
||||
pub struct ImGuiFocusedFlags: c_int {
|
||||
/// Return true if any children of the window is focused
|
||||
const ChildWindows = 1;
|
||||
/// Test from root window (top most parent of the current hierarchy)
|
||||
const RootWindow = 1 << 1;
|
||||
/// Return true if any window is focused
|
||||
const AnyWindow = 1 << 2;
|
||||
|
||||
const RootAndChildWindows =
|
||||
ImGuiFocusedFlags::RootWindow.bits | ImGuiFocusedFlags::ChildWindows.bits;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for font atlases
|
||||
#[repr(C)]
|
||||
pub struct ImFontAtlasFlags: c_int {
|
||||
/// Don't round the height to next power of two
|
||||
const NoPowerOfTwoHeight = 1;
|
||||
/// Don't build software mouse cursors into the atlas
|
||||
const NoMouseCursors = 1 << 1;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for hover checks
|
||||
#[repr(C)]
|
||||
pub struct ImGuiHoveredFlags: c_int {
|
||||
/// Window hover checks only: Return true if any children of the window is hovered
|
||||
const ChildWindows = 1;
|
||||
/// Window hover checks only: Test from root window (top most parent of the current hierarchy)
|
||||
const RootWindow = 1 << 1;
|
||||
/// Window hover checks only: Return true if any window is hovered
|
||||
const AnyWindow = 1 << 2;
|
||||
/// Return true even if a popup window is normally blocking access to this item/window
|
||||
const AllowWhenBlockedByPopup = 1 << 3;
|
||||
/// Return true even if an active item is blocking access to this item/window. Useful for
|
||||
/// Drag and Drop patterns.
|
||||
const AllowWhenBlockedByActiveItem = 1 << 5;
|
||||
/// Return true even if the position is overlapped by another window
|
||||
const AllowWhenOverlapped = 1 << 6;
|
||||
/// Return true even if the item is disabled
|
||||
const AllowWhenDisabled = 1 << 7;
|
||||
|
||||
const RectOnly = ImGuiHoveredFlags::AllowWhenBlockedByPopup.bits
|
||||
| ImGuiHoveredFlags::AllowWhenBlockedByActiveItem.bits
|
||||
| ImGuiHoveredFlags::AllowWhenOverlapped.bits;
|
||||
const RootAndChildWindows = ImGuiFocusedFlags::RootWindow.bits
|
||||
| ImGuiFocusedFlags::ChildWindows.bits;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for text inputs
|
||||
#[repr(C)]
|
||||
pub struct ImGuiInputTextFlags: c_int {
|
||||
/// Allow 0123456789.+-*/
|
||||
const CharsDecimal = 1;
|
||||
/// Allow 0123456789ABCDEFabcdef
|
||||
const CharsHexadecimal = 1 << 1;
|
||||
/// Turn a..z into A..Z
|
||||
const CharsUppercase = 1 << 2;
|
||||
/// Filter out spaces, tabs
|
||||
const CharsNoBlank = 1 << 3;
|
||||
/// Select entire text when first taking mouse focus
|
||||
const AutoSelectAll = 1 << 4;
|
||||
/// Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
||||
const EnterReturnsTrue = 1 << 5;
|
||||
/// Call user function on pressing TAB (for completion handling)
|
||||
const CallbackCompletion = 1 << 6;
|
||||
/// Call user function on pressing Up/Down arrows (for history handling)
|
||||
const CallbackHistory = 1 << 7;
|
||||
/// Call user function every time. User code may query cursor position, modify text buffer.
|
||||
const CallbackAlways = 1 << 8;
|
||||
/// Call user function to filter character.
|
||||
const CallbackCharFilter = 1 << 9;
|
||||
/// Pressing TAB input a '\t' character into the text field
|
||||
const AllowTabInput = 1 << 10;
|
||||
/// In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is
|
||||
/// opposite: unfocus with Ctrl+Enter, add line with Enter).
|
||||
const CtrlEnterForNewLine = 1 << 11;
|
||||
/// Disable following the cursor horizontally
|
||||
const NoHorizontalScroll = 1 << 12;
|
||||
/// Insert mode
|
||||
const AlwaysInsertMode = 1 << 13;
|
||||
/// Read-only mode
|
||||
const ReadOnly = 1 << 14;
|
||||
/// Password mode, display all characters as '*'
|
||||
const Password = 1 << 15;
|
||||
/// Disable undo/redo.
|
||||
const NoUndoRedo = 1 << 16;
|
||||
/// Allow 0123456789.+-*/eE (Scientific notation input)
|
||||
const CharsScientific = 1 << 17;
|
||||
/// Allow buffer capacity resize + notify when the string wants to be resized
|
||||
const CallbackResize = 1 << 18;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for selectables
|
||||
#[repr(C)]
|
||||
pub struct ImGuiSelectableFlags: c_int {
|
||||
/// Clicking this don't close parent popup window
|
||||
const DontClosePopups = 1;
|
||||
/// Selectable frame can span all columns (text will still fit in current column)
|
||||
const SpanAllColumns = 1 << 1;
|
||||
/// Generate press events on double clicks too
|
||||
const AllowDoubleClick = 1 << 2;
|
||||
/// Cannot be selected, display greyed out text
|
||||
const Disabled = 1 << 3;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for trees and collapsing headers
|
||||
#[repr(C)]
|
||||
pub struct ImGuiTreeNodeFlags: c_int {
|
||||
/// Draw as selected
|
||||
const Selected = 1;
|
||||
/// Full colored frame (e.g. for collapsing header)
|
||||
const Framed = 1 << 1;
|
||||
/// Hit testing to allow subsequent widgets to overlap this one
|
||||
const AllowItemOverlap = 1 << 2;
|
||||
/// Don't do a tree push when open (e.g. for collapsing header) = no extra indent nor
|
||||
/// pushing on ID stack
|
||||
const NoTreePushOnOpen = 1 << 3;
|
||||
/// Don't automatically and temporarily open node when Logging is active (by default
|
||||
/// logging will automatically open tree nodes)
|
||||
const NoAutoOpenOnLog = 1 << 4;
|
||||
/// Default node to be open
|
||||
const DefaultOpen = 1 << 5;
|
||||
/// Need double-click to open node
|
||||
const OpenOnDoubleClick = 1 << 6;
|
||||
/// Only open when clicking on the arrow part. If OpenOnDoubleClick is also set,
|
||||
/// single-click arrow or double-click all box to open.
|
||||
const OpenOnArrow = 1 << 7;
|
||||
/// No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||
const Leaf = 1 << 8;
|
||||
/// Display a bullet instead of arrow
|
||||
const Bullet = 1 << 9;
|
||||
/// Use FramePadding (even for an unframed text node) to vertically align text baseline to
|
||||
/// regular widget height.
|
||||
const FramePadding = 1 << 10;
|
||||
const NavLeftJumpsBackHere = 1 << 13;
|
||||
|
||||
const CollapsingHeader =
|
||||
ImGuiTreeNodeFlags::Framed.bits | ImGuiTreeNodeFlags::NoTreePushOnOpen.bits |
|
||||
ImGuiTreeNodeFlags::NoAutoOpenOnLog.bits;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Window flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiWindowFlags: c_int {
|
||||
/// Disable title-bar.
|
||||
const NoTitleBar = 1;
|
||||
/// Disable user resizing with the lower-right grip.
|
||||
const NoResize = 1 << 1;
|
||||
/// Disable user moving the window.
|
||||
const NoMove = 1 << 2;
|
||||
/// Disable scrollbars (window can still scroll with mouse or programatically).
|
||||
const NoScrollbar = 1 << 3;
|
||||
/// Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will
|
||||
/// be forwarded to the parent unless NoScrollbar is also set.
|
||||
const NoScrollWithMouse = 1 << 4;
|
||||
/// Disable user collapsing window by double-clicking on it.
|
||||
const NoCollapse = 1 << 5;
|
||||
/// Resize every window to its content every frame.
|
||||
const AlwaysAutoResize = 1 << 6;
|
||||
/// Never load/save settings in .ini file.
|
||||
const NoSavedSettings = 1 << 8;
|
||||
/// Disable catching mouse or keyboard inputs;hovering test with pass through.
|
||||
const NoInputs = 1 << 9;
|
||||
/// Has a menu-bar.
|
||||
const MenuBar = 1 << 10;
|
||||
/// Allow horizontal scrollbar to appear (off by default).
|
||||
const HorizontalScrollbar = 1 << 11;
|
||||
/// Disable taking focus when transitioning from hidden to visible state.
|
||||
const NoFocusOnAppearing = 1 << 12;
|
||||
/// Disable bringing window to front when taking focus (e.g. clicking on it or
|
||||
/// programmatically giving it focus).
|
||||
const NoBringToFrontOnFocus = 1 << 13;
|
||||
/// Always show vertical scrollbar.
|
||||
const AlwaysVerticalScrollbar = 1 << 14;
|
||||
/// Always show horizontal scrollbar.
|
||||
const AlwaysHorizontalScrollbar = 1<< 15;
|
||||
/// Ensure child windows without border use window padding (ignored by default for
|
||||
/// non-bordered child windows, because more convenient).
|
||||
const AlwaysUseWindowPadding = 1 << 16;
|
||||
/// No gamepad/keyboard navigation within the window.
|
||||
const NoNavInputs = 1 << 18;
|
||||
/// No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by
|
||||
/// CTRL+TAB).
|
||||
const NoNavFocus = 1 << 19;
|
||||
|
||||
const NoNav = ImGuiWindowFlags::NoNavInputs.bits | ImGuiWindowFlags::NoNavFocus.bits;
|
||||
}
|
||||
);
|
||||
2453
imgui-sys/src/lib.rs
2453
imgui-sys/src/lib.rs
File diff suppressed because it is too large
Load Diff
1054
imgui-sys/src/structs.rs
Normal file
1054
imgui-sys/src/structs.rs
Normal file
File diff suppressed because it is too large
Load Diff
2
imgui-sys/third-party/cimgui
vendored
2
imgui-sys/third-party/cimgui
vendored
@ -1 +1 @@
|
||||
Subproject commit 0781f921354a3f7a9eefd7aaab557a89cb14baea
|
||||
Subproject commit 3efb1001aa4639676b5626eaaf2c58e1370be3b2
|
||||
39
src/fonts.rs
39
src/fonts.rs
@ -6,7 +6,8 @@ use sys;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
|
||||
enum FontGlyphRangeData {
|
||||
Chinese,
|
||||
ChineseSimplifiedCommon,
|
||||
ChineseFull,
|
||||
Cyrillic,
|
||||
Default,
|
||||
Japanese,
|
||||
@ -24,9 +25,13 @@ impl FontGlyphRange {
|
||||
FontGlyphRange(FontGlyphRangeData::Default)
|
||||
}
|
||||
|
||||
/// A set of glyph ranges appropriate for use with simplified common Chinese text.
|
||||
pub fn chinese_simplified_common() -> FontGlyphRange {
|
||||
FontGlyphRange(FontGlyphRangeData::ChineseSimplifiedCommon)
|
||||
}
|
||||
/// A set of glyph ranges appropriate for use with Chinese text.
|
||||
pub fn chinese() -> FontGlyphRange {
|
||||
FontGlyphRange(FontGlyphRangeData::Chinese)
|
||||
pub fn chinese_full() -> FontGlyphRange {
|
||||
FontGlyphRange(FontGlyphRangeData::ChineseFull)
|
||||
}
|
||||
/// A set of glyph ranges appropriate for use with Cyrillic text.
|
||||
pub fn cyrillic() -> FontGlyphRange {
|
||||
@ -122,7 +127,10 @@ impl FontGlyphRange {
|
||||
|
||||
unsafe fn to_ptr(&self, atlas: *mut sys::ImFontAtlas) -> *const sys::ImWchar {
|
||||
match &self.0 {
|
||||
&FontGlyphRangeData::Chinese => sys::ImFontAtlas_GetGlyphRangesChinese(atlas),
|
||||
&FontGlyphRangeData::ChineseFull => sys::ImFontAtlas_GetGlyphRangesChineseFull(atlas),
|
||||
&FontGlyphRangeData::ChineseSimplifiedCommon => {
|
||||
sys::ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(atlas)
|
||||
}
|
||||
&FontGlyphRangeData::Cyrillic => sys::ImFontAtlas_GetGlyphRangesCyrillic(atlas),
|
||||
&FontGlyphRangeData::Default => sys::ImFontAtlas_GetGlyphRangesDefault(atlas),
|
||||
&FontGlyphRangeData::Japanese => sys::ImFontAtlas_GetGlyphRangesJapanese(atlas),
|
||||
@ -258,25 +266,27 @@ impl<'a> ImFont<'a> {
|
||||
}
|
||||
|
||||
pub fn font_size(&self) -> f32 {
|
||||
unsafe { sys::ImFont_GetFontSize(self.font) }
|
||||
unsafe { (*self.font).font_size }
|
||||
}
|
||||
pub fn set_font_size(&mut self, size: f32) -> ImFont {
|
||||
unsafe { sys::ImFont_SetFontSize(self.font, size) }
|
||||
unsafe {
|
||||
(*self.font).font_size = size;
|
||||
}
|
||||
self.chain()
|
||||
}
|
||||
|
||||
pub fn scale(&self) -> f32 {
|
||||
unsafe { sys::ImFont_GetScale(self.font) }
|
||||
unsafe { (*self.font).scale }
|
||||
}
|
||||
pub fn set_scale(&mut self, size: f32) -> ImFont {
|
||||
unsafe { sys::ImFont_SetScale(self.font, size) }
|
||||
unsafe {
|
||||
(*self.font).scale = size;
|
||||
}
|
||||
self.chain()
|
||||
}
|
||||
|
||||
pub fn display_offset(&self) -> (f32, f32) {
|
||||
let mut display_offset = unsafe { mem::uninitialized() };
|
||||
unsafe { sys::ImFont_GetDisplayOffset(self.font, &mut display_offset) }
|
||||
display_offset.into()
|
||||
unsafe { (*self.font).display_offset.into() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +360,7 @@ impl<'a> ImFontAtlas<'a> {
|
||||
|
||||
/// The number of fonts currently registered in the atlas.
|
||||
pub fn font_count(&self) -> usize {
|
||||
unsafe { sys::ImFontAtlas_Fonts_size(self.atlas) as usize }
|
||||
unsafe { (*self.atlas).fonts.size as usize }
|
||||
}
|
||||
|
||||
/// Gets a font from the atlas.
|
||||
@ -360,8 +370,9 @@ impl<'a> ImFontAtlas<'a> {
|
||||
///
|
||||
/// Panics if the index is out of range.
|
||||
pub fn index_font(&mut self, index: usize) -> ImFont {
|
||||
assert!(index < self.font_count(), "Font index is out of range.");
|
||||
unsafe { ImFont::from_ptr(sys::ImFontAtlas_Fonts_index(self.atlas, index as c_int)) }
|
||||
let fonts = unsafe { (*self.atlas).fonts.as_slice() };
|
||||
assert!(index < fonts.len(), "Font index is out of range.");
|
||||
unsafe { ImFont::from_ptr(fonts[index]) }
|
||||
}
|
||||
|
||||
/// Clears all fonts associated with this texture atlas.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use super::{ImVec2, ImVec4, Ui};
|
||||
use std::marker::PhantomData;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::os::raw::c_void;
|
||||
use sys;
|
||||
|
||||
|
||||
20
src/input.rs
20
src/input.rs
@ -126,16 +126,6 @@ macro_rules! impl_step_params {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_precision_params {
|
||||
($InputType:ident) => {
|
||||
#[inline]
|
||||
pub fn decimal_precision(mut self, value: i32) -> Self {
|
||||
self.decimal_precision = value;
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub struct InputText<'ui, 'p> {
|
||||
label: &'p ImStr,
|
||||
@ -257,7 +247,6 @@ pub struct InputFloat<'ui, 'p> {
|
||||
value: &'p mut f32,
|
||||
step: f32,
|
||||
step_fast: f32,
|
||||
decimal_precision: i32,
|
||||
flags: ImGuiInputTextFlags,
|
||||
_phantom: PhantomData<&'ui Ui<'ui>>,
|
||||
}
|
||||
@ -269,7 +258,6 @@ impl<'ui, 'p> InputFloat<'ui, 'p> {
|
||||
value,
|
||||
step: 0.0,
|
||||
step_fast: 0.0,
|
||||
decimal_precision: -1,
|
||||
flags: ImGuiInputTextFlags::empty(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
@ -282,14 +270,13 @@ impl<'ui, 'p> InputFloat<'ui, 'p> {
|
||||
self.value as *mut f32,
|
||||
self.step,
|
||||
self.step_fast,
|
||||
self.decimal_precision,
|
||||
b"%.3f\0".as_ptr() as *const _,
|
||||
self.flags,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl_step_params!(InputFloat, f32);
|
||||
impl_precision_params!(InputFloat);
|
||||
impl_text_flags!(InputFloat);
|
||||
}
|
||||
|
||||
@ -299,7 +286,6 @@ macro_rules! impl_input_floatn {
|
||||
pub struct $InputFloatN<'ui, 'p> {
|
||||
label: &'p ImStr,
|
||||
value: &'p mut [f32; $N],
|
||||
decimal_precision: i32,
|
||||
flags: ImGuiInputTextFlags,
|
||||
_phantom: PhantomData<&'ui Ui<'ui>>,
|
||||
}
|
||||
@ -309,7 +295,6 @@ macro_rules! impl_input_floatn {
|
||||
$InputFloatN {
|
||||
label,
|
||||
value,
|
||||
decimal_precision: -1,
|
||||
flags: ImGuiInputTextFlags::empty(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
@ -320,13 +305,12 @@ macro_rules! impl_input_floatn {
|
||||
sys::$igInputFloatN(
|
||||
self.label.as_ptr(),
|
||||
self.value.as_mut_ptr(),
|
||||
self.decimal_precision,
|
||||
b"%.3f\0".as_ptr() as *const _,
|
||||
self.flags,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl_precision_params!($InputFloatN);
|
||||
impl_text_flags!($InputFloatN);
|
||||
}
|
||||
};
|
||||
|
||||
109
src/lib.rs
109
src/lib.rs
@ -130,6 +130,9 @@ impl FrameSize {
|
||||
|
||||
impl ImGui {
|
||||
pub fn init() -> ImGui {
|
||||
unsafe {
|
||||
sys::igCreateContext(ptr::null_mut());
|
||||
}
|
||||
ImGui {
|
||||
ini_filename: None,
|
||||
log_filename: None,
|
||||
@ -384,7 +387,7 @@ impl ImGui {
|
||||
let mut buf = [0; 5];
|
||||
character.encode_utf8(&mut buf);
|
||||
unsafe {
|
||||
sys::ImGuiIO_AddInputCharactersUTF8(buf.as_ptr() as *const _);
|
||||
sys::ImGuiIO_AddInputCharactersUTF8(self.io_mut(), buf.as_ptr() as *const _);
|
||||
}
|
||||
}
|
||||
pub fn get_time(&self) -> f32 {
|
||||
@ -425,7 +428,7 @@ impl Drop for ImGui {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
CURRENT_UI = None;
|
||||
sys::igShutdown();
|
||||
sys::igDestroyContext(ptr::null_mut());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -529,10 +532,6 @@ impl<'ui> Ui<'ui> {
|
||||
let io = self.imgui.io();
|
||||
io.framerate
|
||||
}
|
||||
pub fn metrics_allocs(&self) -> i32 {
|
||||
let io = self.imgui.io();
|
||||
io.metrics_allocs
|
||||
}
|
||||
pub fn metrics_render_vertices(&self) -> i32 {
|
||||
let io = self.imgui.io();
|
||||
io.metrics_render_vertices
|
||||
@ -606,19 +605,13 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Get current window's size in pixels
|
||||
pub fn get_window_size(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetWindowSize(&mut out as *mut ImVec2);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetWindowSize() };
|
||||
size.into()
|
||||
}
|
||||
/// Get current window's position in pixels
|
||||
pub fn get_window_pos(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetWindowPos(&mut out);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetWindowPos() };
|
||||
size.into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,8 +687,7 @@ impl<'ui> Ui<'ui> {
|
||||
/// Fill a space of `size` in pixels with nothing on the current window.
|
||||
/// Can be used to move the cursor on the window.
|
||||
pub fn dummy<S: Into<ImVec2>>(&self, size: S) {
|
||||
let size = size.into();
|
||||
unsafe { sys::igDummy(&size) }
|
||||
unsafe { sys::igDummy(size.into()) }
|
||||
}
|
||||
|
||||
/// Get cursor position on the screen, in screen coordinates.
|
||||
@ -704,11 +696,8 @@ impl<'ui> Ui<'ui> {
|
||||
/// This is especially useful for drawing, as the drawing API uses
|
||||
/// screen coordiantes.
|
||||
pub fn get_cursor_screen_pos(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetCursorScreenPos(&mut out);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetCursorScreenPos() };
|
||||
size.into()
|
||||
}
|
||||
|
||||
/// Set cursor position on the screen, in screen coordinates.
|
||||
@ -719,11 +708,8 @@ impl<'ui> Ui<'ui> {
|
||||
|
||||
/// Get cursor position on the screen, in window coordinates.
|
||||
pub fn get_cursor_pos(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetCursorPos(&mut out);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetCursorPos() };
|
||||
size.into()
|
||||
}
|
||||
|
||||
/// Set cursor position on the screen, in window coordinates.
|
||||
@ -735,11 +721,8 @@ impl<'ui> Ui<'ui> {
|
||||
/// Get available space left between the cursor and the edges of the current
|
||||
/// window.
|
||||
pub fn get_content_region_avail(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetContentRegionAvail(&mut out);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetContentRegionAvail() };
|
||||
size.into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +770,7 @@ impl<'ui> Ui<'ui> {
|
||||
ImId::Str(s) => {
|
||||
let start = s.as_ptr() as *const c_char;
|
||||
let end = start.offset(s.len() as isize);
|
||||
sys::igPushIDStrRange(start, end);
|
||||
sys::igPushIDRange(start, end);
|
||||
}
|
||||
ImId::Ptr(p) => {
|
||||
sys::igPushIDPtr(p as *const c_void);
|
||||
@ -1206,7 +1189,7 @@ impl<'ui> Ui<'ui> {
|
||||
where
|
||||
F: FnOnce(),
|
||||
{
|
||||
let render = unsafe { sys::igBeginPopup(str_id.as_ptr()) };
|
||||
let render = unsafe { sys::igBeginPopup(str_id.as_ptr(), ImGuiWindowFlags::empty()) };
|
||||
if render {
|
||||
f();
|
||||
unsafe { sys::igEndPopup() };
|
||||
@ -1272,7 +1255,7 @@ impl<'ui> Ui<'ui> {
|
||||
) -> bool {
|
||||
let items_inner: Vec<*const c_char> = items.into_iter().map(|item| item.as_ptr()).collect();
|
||||
unsafe {
|
||||
sys::igListBox(
|
||||
sys::igListBoxStr_arr(
|
||||
label.as_ptr(),
|
||||
current_item,
|
||||
items_inner.as_ptr() as *mut *const c_char,
|
||||
@ -1299,7 +1282,7 @@ impl<'ui> Ui<'ui> {
|
||||
/// ui.radio_button(im_str!("Item 3"), &mut selected_radio_value, 3);
|
||||
/// ```
|
||||
pub fn radio_button<'p>(&self, label: &'p ImStr, value: &'p mut i32, wanted: i32) -> bool {
|
||||
unsafe { sys::igRadioButton(label.as_ptr(), value, wanted) }
|
||||
unsafe { sys::igRadioButtonIntPtr(label.as_ptr(), value, wanted) }
|
||||
}
|
||||
|
||||
/// Creates a radio button that shows as selected if the given value is true.
|
||||
@ -1362,17 +1345,14 @@ impl<'ui> Ui<'ui> {
|
||||
hide_text_after_double_hash: bool,
|
||||
wrap_width: f32,
|
||||
) -> ImVec2 {
|
||||
let mut buffer = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igCalcTextSize(
|
||||
&mut buffer as *mut ImVec2,
|
||||
text.as_ptr(),
|
||||
std::ptr::null(),
|
||||
hide_text_after_double_hash,
|
||||
wrap_width,
|
||||
);
|
||||
)
|
||||
}
|
||||
buffer
|
||||
}
|
||||
}
|
||||
|
||||
@ -1383,11 +1363,8 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Get previously drawn item's size
|
||||
pub fn get_item_rect_size(&self) -> (f32, f32) {
|
||||
let mut out = ImVec2::new(0.0, 0.0);
|
||||
unsafe {
|
||||
sys::igGetItemRectSize(&mut out);
|
||||
}
|
||||
(out.x, out.y)
|
||||
let size = unsafe { sys::igGetItemRectSize() };
|
||||
size.into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1483,26 +1460,30 @@ impl<'ui> Ui<'ui> {
|
||||
|
||||
#[inline]
|
||||
fn push_style_var(&self, style_var: StyleVar) {
|
||||
use sys::{igPushStyleVar, igPushStyleVarVec};
|
||||
use sys::{igPushStyleVarFloat, igPushStyleVarVec2};
|
||||
use StyleVar::*;
|
||||
match style_var {
|
||||
Alpha(v) => unsafe { igPushStyleVar(ImGuiStyleVar::Alpha, v) },
|
||||
WindowPadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowPadding, v) },
|
||||
WindowRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowRounding, v) },
|
||||
WindowBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::WindowBorderSize, v) },
|
||||
WindowMinSize(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::WindowMinSize, v) },
|
||||
ChildRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::ChildRounding, v) },
|
||||
ChildBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::ChildBorderSize, v) },
|
||||
PopupRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::PopupRounding, v) },
|
||||
PopupBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::PopupBorderSize, v) },
|
||||
FramePadding(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::FramePadding, v) },
|
||||
FrameRounding(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameRounding, v) },
|
||||
FrameBorderSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::FrameBorderSize, v) },
|
||||
ItemSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemSpacing, v) },
|
||||
ItemInnerSpacing(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ItemInnerSpacing, v) },
|
||||
IndentSpacing(v) => unsafe { igPushStyleVar(ImGuiStyleVar::IndentSpacing, v) },
|
||||
GrabMinSize(v) => unsafe { igPushStyleVar(ImGuiStyleVar::GrabMinSize, v) },
|
||||
ButtonTextAlign(v) => unsafe { igPushStyleVarVec(ImGuiStyleVar::ButtonTextAlign, v) },
|
||||
Alpha(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::Alpha, v) },
|
||||
WindowPadding(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::WindowPadding, v) },
|
||||
WindowRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::WindowRounding, v) },
|
||||
WindowBorderSize(v) => unsafe {
|
||||
igPushStyleVarFloat(ImGuiStyleVar::WindowBorderSize, v)
|
||||
},
|
||||
WindowMinSize(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::WindowMinSize, v) },
|
||||
ChildRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::ChildRounding, v) },
|
||||
ChildBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::ChildBorderSize, v) },
|
||||
PopupRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::PopupRounding, v) },
|
||||
PopupBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::PopupBorderSize, v) },
|
||||
FramePadding(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::FramePadding, v) },
|
||||
FrameRounding(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::FrameRounding, v) },
|
||||
FrameBorderSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::FrameBorderSize, v) },
|
||||
ItemSpacing(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::ItemSpacing, v) },
|
||||
ItemInnerSpacing(v) => unsafe {
|
||||
igPushStyleVarVec2(ImGuiStyleVar::ItemInnerSpacing, v)
|
||||
},
|
||||
IndentSpacing(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::IndentSpacing, v) },
|
||||
GrabMinSize(v) => unsafe { igPushStyleVarFloat(ImGuiStyleVar::GrabMinSize, v) },
|
||||
ButtonTextAlign(v) => unsafe { igPushStyleVarVec2(ImGuiStyleVar::ButtonTextAlign, v) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +75,6 @@ impl<'ui, 'p> MenuItem<'ui, 'p> {
|
||||
.map(|x| x as *mut bool)
|
||||
.unwrap_or(ptr::null_mut());
|
||||
let enabled = self.enabled;
|
||||
unsafe { sys::igMenuItemPtr(label, shortcut, selected, enabled) }
|
||||
unsafe { sys::igMenuItemBoolPtr(label, shortcut, selected, enabled) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ impl<'ui, 'p> PlotHistogram<'ui, 'p> {
|
||||
|
||||
pub fn build(self) {
|
||||
unsafe {
|
||||
sys::igPlotHistogram(
|
||||
sys::igPlotHistogramFloatPtr(
|
||||
self.label.as_ptr(),
|
||||
self.values.as_ptr() as *const c_float,
|
||||
self.values.len() as i32,
|
||||
|
||||
@ -51,7 +51,7 @@ impl<'ui, 'p> ProgressBar<'ui, 'p> {
|
||||
unsafe {
|
||||
sys::igProgressBar(
|
||||
self.fraction,
|
||||
&self.size,
|
||||
self.size,
|
||||
self.overlay_text.map(|x| x.as_ptr()).unwrap_or(ptr::null()),
|
||||
);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ impl<'ui, 'p> TreeNode<'ui, 'p> {
|
||||
if !self.opened_cond.is_empty() {
|
||||
sys::igSetNextTreeNodeOpen(self.opened, self.opened_cond);
|
||||
}
|
||||
sys::igTreeNodeExStr(
|
||||
sys::igTreeNodeExStrStr(
|
||||
self.id.as_ptr(),
|
||||
self.flags,
|
||||
super::fmt_ptr(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user