mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-27 13:28:28 +00:00
Add some initial documentation
This commit is contained in:
parent
ca5c6ac2f8
commit
5d4dd1f622
@ -16,13 +16,21 @@ use std::mem;
|
|||||||
use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void};
|
use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
|
/// ImGui context (opaque)
|
||||||
pub enum ImGuiContext { }
|
pub enum ImGuiContext { }
|
||||||
|
|
||||||
pub type ImU32 = c_uint;
|
pub type ImU32 = c_uint;
|
||||||
|
|
||||||
|
/// Character for keyboard input/display
|
||||||
pub type ImWchar = c_ushort;
|
pub type ImWchar = c_ushort;
|
||||||
|
|
||||||
|
/// User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||||
pub type ImTextureID = *mut c_void;
|
pub type ImTextureID = *mut c_void;
|
||||||
|
|
||||||
|
/// Unique ID used by widgets (typically hashed from a stack of string)
|
||||||
pub type ImGuiID = ImU32;
|
pub type ImGuiID = ImU32;
|
||||||
|
|
||||||
|
/// A color identifier for styling
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ImGuiCol {
|
pub enum ImGuiCol {
|
||||||
@ -72,6 +80,7 @@ pub enum ImGuiCol {
|
|||||||
}
|
}
|
||||||
pub const ImGuiCol_COUNT: usize = 43;
|
pub const ImGuiCol_COUNT: usize = 43;
|
||||||
|
|
||||||
|
/// A variable identifier for styling
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ImGuiStyleVar {
|
pub enum ImGuiStyleVar {
|
||||||
@ -88,6 +97,7 @@ pub enum ImGuiStyleVar {
|
|||||||
GrabMinSize,
|
GrabMinSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A key identifier (ImGui-side enum)
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ImGuiKey {
|
pub enum ImGuiKey {
|
||||||
@ -114,6 +124,7 @@ pub enum ImGuiKey {
|
|||||||
pub const ImGuiKey_COUNT: usize = 19;
|
pub const ImGuiKey_COUNT: usize = 19;
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Alignment
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiAlign: c_int {
|
pub flags ImGuiAlign: c_int {
|
||||||
const ImGuiAlign_Left = 1 << 0,
|
const ImGuiAlign_Left = 1 << 0,
|
||||||
@ -125,6 +136,7 @@ bitflags!(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Color edit mode
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ImGuiColorEditMode {
|
pub enum ImGuiColorEditMode {
|
||||||
@ -135,6 +147,7 @@ pub enum ImGuiColorEditMode {
|
|||||||
HEX = 2,
|
HEX = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A mouse cursor identifier
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ImGuiMouseCursor {
|
pub enum ImGuiMouseCursor {
|
||||||
@ -150,6 +163,7 @@ pub enum ImGuiMouseCursor {
|
|||||||
pub const ImGuiMouseCursor_COUNT: usize = 7;
|
pub const ImGuiMouseCursor_COUNT: usize = 7;
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Window flags
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiWindowFlags: c_int {
|
pub flags ImGuiWindowFlags: c_int {
|
||||||
const ImGuiWindowFlags_NoTitleBar = 1 << 0,
|
const ImGuiWindowFlags_NoTitleBar = 1 << 0,
|
||||||
@ -194,6 +208,7 @@ impl ImGuiWindowFlags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Condition flags
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiSetCond: c_int {
|
pub flags ImGuiSetCond: c_int {
|
||||||
const ImGuiSetCond_Always = 1 << 0,
|
const ImGuiSetCond_Always = 1 << 0,
|
||||||
@ -204,6 +219,7 @@ bitflags!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Flags for text inputs
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiInputTextFlags: c_int {
|
pub flags ImGuiInputTextFlags: c_int {
|
||||||
const ImGuiInputTextFlags_CharsDecimal = 1 << 0,
|
const ImGuiInputTextFlags_CharsDecimal = 1 << 0,
|
||||||
@ -241,6 +257,7 @@ impl ImGuiInputTextFlags {
|
|||||||
|
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Flags for selectables
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiSelectableFlags: c_int {
|
pub flags ImGuiSelectableFlags: c_int {
|
||||||
const ImGuiSelectableFlags_DontClosePopups = 1 << 0,
|
const ImGuiSelectableFlags_DontClosePopups = 1 << 0,
|
||||||
@ -250,6 +267,7 @@ bitflags!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
|
/// Flags for trees and collapsing headers
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub flags ImGuiTreeNodeFlags: c_int {
|
pub flags ImGuiTreeNodeFlags: c_int {
|
||||||
const ImGuiTreeNodeFlags_Selected = 1 << 0,
|
const ImGuiTreeNodeFlags_Selected = 1 << 0,
|
||||||
@ -285,6 +303,7 @@ pub type ImGuiTextEditCallback =
|
|||||||
pub type ImGuiSizeConstraintCallback =
|
pub type ImGuiSizeConstraintCallback =
|
||||||
Option<extern "C" fn(data: *mut ImGuiSizeConstraintCallbackData)>;
|
Option<extern "C" fn(data: *mut ImGuiSizeConstraintCallbackData)>;
|
||||||
|
|
||||||
|
/// A tuple of 2 floating-point values
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||||
pub struct ImVec2 {
|
pub struct ImVec2 {
|
||||||
@ -320,6 +339,7 @@ unsafe impl Attribute for ImVec2 {
|
|||||||
fn get_type() -> AttributeType { <(c_float, c_float) as Attribute>::get_type() }
|
fn get_type() -> AttributeType { <(c_float, c_float) as Attribute>::get_type() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A tuple of 4 floating-point values
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||||
pub struct ImVec4 {
|
pub struct ImVec4 {
|
||||||
@ -357,33 +377,58 @@ unsafe impl Attribute for ImVec4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runtime data for styling/colors
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImGuiStyle {
|
pub struct ImGuiStyle {
|
||||||
|
/// Global alpha applies to everything in ImGui
|
||||||
pub alpha: c_float,
|
pub alpha: c_float,
|
||||||
|
/// Padding within a window
|
||||||
pub window_padding: ImVec2,
|
pub window_padding: ImVec2,
|
||||||
|
/// Minimum window size
|
||||||
pub window_min_size: ImVec2,
|
pub window_min_size: ImVec2,
|
||||||
|
/// Radius of window corners rounding. Set to 0.0f to have rectangular windows
|
||||||
pub window_rounding: c_float,
|
pub window_rounding: c_float,
|
||||||
|
/// Alignment for title bar text
|
||||||
pub window_title_align: ImGuiAlign,
|
pub window_title_align: ImGuiAlign,
|
||||||
|
/// Radius of child window corners rounding. Set to 0.0f to have rectangular child windows
|
||||||
pub child_window_rounding: c_float,
|
pub child_window_rounding: c_float,
|
||||||
|
/// Padding within a framed rectangle (used by most widgets)
|
||||||
pub frame_padding: ImVec2,
|
pub frame_padding: ImVec2,
|
||||||
|
/// Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
|
||||||
pub frame_rounding: c_float,
|
pub frame_rounding: c_float,
|
||||||
|
/// Horizontal and vertical spacing between widgets/lines
|
||||||
pub item_spacing: ImVec2,
|
pub item_spacing: ImVec2,
|
||||||
|
/// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||||
pub item_inner_spacing: ImVec2,
|
pub item_inner_spacing: ImVec2,
|
||||||
|
/// Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||||
pub touch_extra_padding: ImVec2,
|
pub touch_extra_padding: ImVec2,
|
||||||
|
/// Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
|
||||||
pub indent_spacing: c_float,
|
pub indent_spacing: c_float,
|
||||||
|
/// Minimum horizontal spacing between two columns
|
||||||
pub columns_min_spacing: c_float,
|
pub columns_min_spacing: c_float,
|
||||||
|
/// Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||||
pub scrollbar_size: c_float,
|
pub scrollbar_size: c_float,
|
||||||
|
/// Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||||
pub scrollbar_rounding: c_float,
|
pub scrollbar_rounding: c_float,
|
||||||
|
/// Minimum width/height of a grab box for slider/scrollbar
|
||||||
pub grab_min_size: c_float,
|
pub grab_min_size: c_float,
|
||||||
|
/// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
pub grab_rounding: c_float,
|
pub grab_rounding: c_float,
|
||||||
|
/// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
||||||
pub display_window_padding: ImVec2,
|
pub display_window_padding: ImVec2,
|
||||||
|
/// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
||||||
pub display_safe_area_padding: ImVec2,
|
pub display_safe_area_padding: ImVec2,
|
||||||
|
/// Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
|
||||||
pub anti_aliased_lines: bool,
|
pub anti_aliased_lines: bool,
|
||||||
|
/// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
||||||
pub anti_aliased_shapes: bool,
|
pub anti_aliased_shapes: bool,
|
||||||
|
/// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
pub curve_tessellation_tol: c_float,
|
pub curve_tessellation_tol: c_float,
|
||||||
|
/// Colors for the user interface
|
||||||
pub colors: [ImVec4; ImGuiCol_COUNT],
|
pub colors: [ImVec4; ImGuiCol_COUNT],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Main configuration and I/O between your application and ImGui
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImGuiIO {
|
pub struct ImGuiIO {
|
||||||
pub display_size: ImVec2,
|
pub display_size: ImVec2,
|
||||||
@ -455,6 +500,7 @@ pub struct ImGuiIO {
|
|||||||
pub keys_down_duration_prev: [c_float; 512],
|
pub keys_down_duration_prev: [c_float; 512],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Lightweight vector struct
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImVector<T> {
|
pub struct ImVector<T> {
|
||||||
pub size: c_int,
|
pub size: c_int,
|
||||||
@ -541,7 +587,7 @@ pub struct ImGuiListClipper {
|
|||||||
pub type ImDrawCallback = Option<extern "C" fn(parent_list: *const ImDrawList,
|
pub type ImDrawCallback = Option<extern "C" fn(parent_list: *const ImDrawList,
|
||||||
cmd: *const ImDrawCmd)>;
|
cmd: *const ImDrawCmd)>;
|
||||||
|
|
||||||
|
/// A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call)
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImDrawCmd {
|
pub struct ImDrawCmd {
|
||||||
pub elem_count: c_uint,
|
pub elem_count: c_uint,
|
||||||
@ -551,8 +597,10 @@ pub struct ImDrawCmd {
|
|||||||
pub user_callback_data: *mut c_void,
|
pub user_callback_data: *mut c_void,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Vertex index
|
||||||
pub type ImDrawIdx = c_ushort;
|
pub type ImDrawIdx = c_ushort;
|
||||||
|
|
||||||
|
/// A single vertex
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
pub struct ImDrawVert {
|
pub struct ImDrawVert {
|
||||||
@ -575,12 +623,14 @@ impl Vertex for ImDrawVert {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Temporary storage for outputting drawing commands out of order
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImDrawChannel {
|
pub struct ImDrawChannel {
|
||||||
pub cmd_buffer: ImVector<ImDrawCmd>,
|
pub cmd_buffer: ImVector<ImDrawCmd>,
|
||||||
pub idx_buffer: ImVector<ImDrawIdx>,
|
pub idx_buffer: ImVector<ImDrawIdx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A single draw command list (generally one per window)
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImDrawList {
|
pub struct ImDrawList {
|
||||||
pub cmd_buffer: ImVector<ImDrawCmd>,
|
pub cmd_buffer: ImVector<ImDrawCmd>,
|
||||||
@ -599,6 +649,7 @@ pub struct ImDrawList {
|
|||||||
channels: ImVector<ImDrawChannel>,
|
channels: ImVector<ImDrawChannel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// All draw command lists required to render the frame
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImDrawData {
|
pub struct ImDrawData {
|
||||||
pub valid: bool,
|
pub valid: bool,
|
||||||
@ -615,6 +666,7 @@ impl ImDrawData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configuration data when adding a font or merging fonts
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImFontConfig {
|
pub struct ImFontConfig {
|
||||||
pub font_data: *mut c_void,
|
pub font_data: *mut c_void,
|
||||||
@ -634,6 +686,7 @@ pub struct ImFontConfig {
|
|||||||
dst_font: *mut ImFont,
|
dst_font: *mut ImFont,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF font loader
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImFontAtlas {
|
pub struct ImFontAtlas {
|
||||||
pub tex_id: *mut c_void,
|
pub tex_id: *mut c_void,
|
||||||
@ -663,6 +716,7 @@ pub struct Glyph {
|
|||||||
v1: c_float,
|
v1: c_float,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runtime data for a single font within a parent ImFontAtlas
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ImFont {
|
pub struct ImFont {
|
||||||
font_size: c_float,
|
font_size: c_float,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user