From 46ba46ce9d126896f0c76fc32fad821003aae695 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 16 Oct 2021 11:37:29 +0200 Subject: [PATCH] build/plugins: Added initial support for Rust plugins (#327) * build: Added initial support for Rust plugins * github: Install correct rust version * github: Fixed rustup command * github: Fix swapped win/linux commands * github: Install linux rust toolchain on Linux * github: Add rustup parameters to correct command * build: libimhex-rust -> hex * rust-plugins: Disable optimization to export functions correctly * build: Use cdylib instead of dylib * build: Fixed rust building and artifact copying * build: Fixed installing plugins * build: Fix copying and installing on Windows * github: Added windows debugging * github: Use curl instead of wget * github: Added debug on failure * github: Update path variable with rust toolchain path * build/github: Set rust location so cmake can find it * build: Remove leftovers * api: Added rust wrappers for the ImHexAPI * rust: Fixed compile flags with older gcc/clang * build: Enable concepts for cxx.rs * build: Explicitly set compiler for cxx.rs * rust: Added imgui-rs to libimhex-rust * rust: Export functions with double underscore prefix on mac * rust: Export functions adjusted for ABI * Add Rust target folder to gitignore * Add vendored imgui-rs copy * Add Context::current() to vendored imgui-rs * Fix libimhex not exporting cimgui symbols * Simplify plugin export mangling * build: Fixed cimgui linking * build: Only specify --export-all-symbols on Windows * Add context setting to Rust plugins * rust: Cleanup * deps: Update curl Co-authored-by: jam1garner <8260240+jam1garner@users.noreply.github.com> --- .github/workflows/build.yml | 17 +- .gitignore | 3 + CMakeLists.txt | 3 +- cmake/build_helpers.cmake | 32 +- external/ImGui/CMakeLists.txt | 10 +- external/ImGui/include/cimgui.h | 3485 ++++++++++++ external/ImGui/source/cimgui.cpp | 4598 +++++++++++++++ .../{example => example_cpp}/CMakeLists.txt | 2 +- .../source/plugin_example.cpp | 2 +- plugins/example_rust/CMakeLists.txt | 44 + plugins/example_rust/Cargo.lock | 295 + plugins/example_rust/Cargo.toml | 15 + plugins/example_rust/source/plugin_example.rs | 7 + plugins/libimhex-rust/Cargo.lock | 288 + plugins/libimhex-rust/Cargo.toml | 16 + plugins/libimhex-rust/build.rs | 15 + plugins/libimhex-rust/imgui-rs/Cargo.lock | 159 + plugins/libimhex-rust/imgui-rs/Cargo.toml | 31 + plugins/libimhex-rust/imgui-rs/LICENSE-APACHE | 202 + plugins/libimhex-rust/imgui-rs/LICENSE-MIT | 19 + .../libimhex-rust/imgui-rs/README.markdown | 1 + .../libimhex-rust/imgui-rs/src/clipboard.rs | 142 + plugins/libimhex-rust/imgui-rs/src/color.rs | 370 ++ plugins/libimhex-rust/imgui-rs/src/columns.rs | 68 + plugins/libimhex-rust/imgui-rs/src/context.rs | 582 ++ .../libimhex-rust/imgui-rs/src/drag_drop.rs | 594 ++ .../libimhex-rust/imgui-rs/src/draw_list.rs | 1041 ++++ .../libimhex-rust/imgui-rs/src/fonts/atlas.rs | 508 ++ .../libimhex-rust/imgui-rs/src/fonts/font.rs | 71 + .../libimhex-rust/imgui-rs/src/fonts/glyph.rs | 67 + .../imgui-rs/src/fonts/glyph_ranges.rs | 164 + .../libimhex-rust/imgui-rs/src/fonts/mod.rs | 36 + .../imgui-rs/src/input/keyboard.rs | 215 + .../libimhex-rust/imgui-rs/src/input/mod.rs | 2 + .../libimhex-rust/imgui-rs/src/input/mouse.rs | 478 ++ .../imgui-rs/src/input_widget.rs | 1023 ++++ .../libimhex-rust/imgui-rs/src/internal.rs | 159 + plugins/libimhex-rust/imgui-rs/src/io.rs | 506 ++ plugins/libimhex-rust/imgui-rs/src/layout.rs | 176 + plugins/libimhex-rust/imgui-rs/src/lib.rs | 753 +++ .../imgui-rs/src/list_clipper.rs | 81 + .../imgui-rs/src/plothistogram.rs | 87 + .../libimhex-rust/imgui-rs/src/plotlines.rs | 87 + plugins/libimhex-rust/imgui-rs/src/popups.rs | 214 + .../imgui-rs/src/render/draw_data.rs | 285 + .../libimhex-rust/imgui-rs/src/render/mod.rs | 2 + .../imgui-rs/src/render/renderer.rs | 95 + plugins/libimhex-rust/imgui-rs/src/stacks.rs | 471 ++ plugins/libimhex-rust/imgui-rs/src/string.rs | 544 ++ plugins/libimhex-rust/imgui-rs/src/style.rs | 506 ++ plugins/libimhex-rust/imgui-rs/src/tables.rs | 879 +++ plugins/libimhex-rust/imgui-rs/src/test.rs | 23 + plugins/libimhex-rust/imgui-rs/src/tokens.rs | 43 + plugins/libimhex-rust/imgui-rs/src/utils.rs | 176 + .../imgui-rs/src/widget/color_editors.rs | 647 +++ .../imgui-rs/src/widget/combo_box.rs | 317 ++ .../libimhex-rust/imgui-rs/src/widget/drag.rs | 285 + .../imgui-rs/src/widget/image.rs | 147 + .../imgui-rs/src/widget/list_box.rs | 96 + .../libimhex-rust/imgui-rs/src/widget/menu.rs | 214 + .../libimhex-rust/imgui-rs/src/widget/misc.rs | 129 + .../libimhex-rust/imgui-rs/src/widget/mod.rs | 13 + .../imgui-rs/src/widget/progress_bar.rs | 73 + .../imgui-rs/src/widget/selectable.rs | 130 + .../imgui-rs/src/widget/slider.rs | 342 ++ .../libimhex-rust/imgui-rs/src/widget/tab.rs | 238 + .../libimhex-rust/imgui-rs/src/widget/text.rs | 55 + .../libimhex-rust/imgui-rs/src/widget/tree.rs | 475 ++ .../imgui-rs/src/window/child_window.rs | 296 + .../imgui-rs/src/window/content_region.rs | 42 + .../libimhex-rust/imgui-rs/src/window/mod.rs | 559 ++ .../imgui-rs/src/window/scroll.rs | 118 + plugins/libimhex-rust/imgui-sys/Cargo.lock | 30 + plugins/libimhex-rust/imgui-sys/Cargo.toml | 26 + .../libimhex-rust/imgui-sys/LICENSE-APACHE | 202 + plugins/libimhex-rust/imgui-sys/LICENSE-MIT | 19 + .../libimhex-rust/imgui-sys/README.markdown | 10 + plugins/libimhex-rust/imgui-sys/build.rs | 8 + .../imgui-sys/include_all_imgui.cpp | 16 + .../libimhex-rust/imgui-sys/src/bindings.rs | 4359 +++++++++++++++ plugins/libimhex-rust/imgui-sys/src/lib.rs | 142 + .../imgui-sys/src/wasm_bindings.rs | 4954 +++++++++++++++++ .../libimhex-rust/proc_macros/CMakeLists.txt | 32 + plugins/libimhex-rust/proc_macros/Cargo.lock | 46 + plugins/libimhex-rust/proc_macros/Cargo.toml | 11 + plugins/libimhex-rust/proc_macros/src/lib.rs | 70 + plugins/libimhex-rust/src/imhex_api.rs | 99 + plugins/libimhex-rust/src/lib.rs | 9 + plugins/libimhex/CMakeLists.txt | 4 + .../include/hex/api/content_registry.hpp | 112 +- .../libimhex/include/hex/api/imhex_api.hpp | 37 +- .../libimhex/include/hex/helpers/logger.hpp | 2 +- plugins/libimhex/source/api/imhex_api.cpp | 6 + source/helpers/project_file_handler.cpp | 8 +- 94 files changed, 33968 insertions(+), 102 deletions(-) create mode 100644 external/ImGui/include/cimgui.h create mode 100644 external/ImGui/source/cimgui.cpp rename plugins/{example => example_cpp}/CMakeLists.txt (96%) rename plugins/{example => example_cpp}/source/plugin_example.cpp (79%) create mode 100644 plugins/example_rust/CMakeLists.txt create mode 100644 plugins/example_rust/Cargo.lock create mode 100644 plugins/example_rust/Cargo.toml create mode 100644 plugins/example_rust/source/plugin_example.rs create mode 100644 plugins/libimhex-rust/Cargo.lock create mode 100644 plugins/libimhex-rust/Cargo.toml create mode 100644 plugins/libimhex-rust/build.rs create mode 100644 plugins/libimhex-rust/imgui-rs/Cargo.lock create mode 100644 plugins/libimhex-rust/imgui-rs/Cargo.toml create mode 100644 plugins/libimhex-rust/imgui-rs/LICENSE-APACHE create mode 100644 plugins/libimhex-rust/imgui-rs/LICENSE-MIT create mode 120000 plugins/libimhex-rust/imgui-rs/README.markdown create mode 100644 plugins/libimhex-rust/imgui-rs/src/clipboard.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/color.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/columns.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/context.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/drag_drop.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/draw_list.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/fonts/atlas.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/fonts/font.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/fonts/glyph.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/fonts/glyph_ranges.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/fonts/mod.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/input/keyboard.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/input/mod.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/input/mouse.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/input_widget.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/internal.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/io.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/layout.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/lib.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/list_clipper.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/plothistogram.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/plotlines.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/popups.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/render/draw_data.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/render/mod.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/render/renderer.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/stacks.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/string.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/style.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/tables.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/test.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/tokens.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/utils.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/color_editors.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/combo_box.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/drag.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/image.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/list_box.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/menu.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/misc.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/mod.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/progress_bar.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/selectable.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/slider.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/tab.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/text.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/widget/tree.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/window/child_window.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/window/content_region.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/window/mod.rs create mode 100644 plugins/libimhex-rust/imgui-rs/src/window/scroll.rs create mode 100644 plugins/libimhex-rust/imgui-sys/Cargo.lock create mode 100644 plugins/libimhex-rust/imgui-sys/Cargo.toml create mode 100644 plugins/libimhex-rust/imgui-sys/LICENSE-APACHE create mode 100644 plugins/libimhex-rust/imgui-sys/LICENSE-MIT create mode 100644 plugins/libimhex-rust/imgui-sys/README.markdown create mode 100644 plugins/libimhex-rust/imgui-sys/build.rs create mode 100644 plugins/libimhex-rust/imgui-sys/include_all_imgui.cpp create mode 100644 plugins/libimhex-rust/imgui-sys/src/bindings.rs create mode 100644 plugins/libimhex-rust/imgui-sys/src/lib.rs create mode 100644 plugins/libimhex-rust/imgui-sys/src/wasm_bindings.rs create mode 100644 plugins/libimhex-rust/proc_macros/CMakeLists.txt create mode 100644 plugins/libimhex-rust/proc_macros/Cargo.lock create mode 100644 plugins/libimhex-rust/proc_macros/Cargo.toml create mode 100644 plugins/libimhex-rust/proc_macros/src/lib.rs create mode 100644 plugins/libimhex-rust/src/imhex_api.rs create mode 100644 plugins/libimhex-rust/src/lib.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a69dd669..35c1f4b2b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,13 @@ jobs: run: | sudo apt update sudo bash dist/get_deps_debian.sh + + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh + sh rustup-init.sh -y --default-toolchain none + rm rustup-init.sh + $HOME/.cargo/bin/rustup install nightly + $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-gnu + $HOME/.cargo/bin/rustup default nightly - name: 🛠️ Build run: | @@ -42,6 +49,7 @@ jobs: -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DCMAKE_INSTALL_PREFIX="$PWD/install" \ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DRUST_PATH="$HOME/.cargo/bin/" \ .. make -j 4 install @@ -91,6 +99,12 @@ jobs: - name: ⬇️ Install dependencies run: | bash dist/get_deps_msys2.sh + + curl --proto '=https' --tlsv1.2 -sSf https://win.rustup.rs > rustup-init.exe + ./rustup-init.exe -y --default-host=x86_64-pc-windows-gnu --default-toolchain=none + rm rustup-init.exe + $USERPROFILE/.cargo/bin/rustup.exe target add x86_64-pc-windows-gnu + $USERPROFILE/.cargo/bin/rustup.exe default nightly - name: 📜 Prepare Cache id: prep-ccache @@ -121,10 +135,11 @@ jobs: -DCREATE_PACKAGE=ON \ -DPython_LIBRARY="$PYTHON_LIB_PATH" \ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DRUST_PATH="$USERPROFILE/.cargo/bin/" \ .. mingw32-make -j4 install cpack - + - name: ⬆️ Upload Portable ZIP uses: actions/upload-artifact@v2 with: diff --git a/.gitignore b/.gitignore index f482a2bf5..e671ed8b8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ build*/ *.mgc imgui.ini .DS_Store +plugins/.rustc_info.json + +**/target diff --git a/CMakeLists.txt b/CMakeLists.txt index a9fcb1dd0..6cee20652 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") set(PLUGINS builtin windows - # example + # example_cpp + # example_rust ) findLibraries() diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index c1c9bf5c5..a49aac0f2 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -157,17 +157,29 @@ macro(createPackage) add_subdirectory("plugins/${plugin}") if (TARGET ${plugin}) set_target_properties(${plugin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins) + set_target_properties(${plugin} PROPERTIES CARGO_BUILD_TARGET_DIR ${CMAKE_BINARY_DIR}/plugins) - if (WIN32) - install(TARGETS ${plugin} RUNTIME DESTINATION ${PLUGINS_INSTALL_LOCATION}) - elseif (APPLE) - if (CREATE_BUNDLE) - set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY $/${PLUGINS_INSTALL_LOCATION}) - else () - set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins) - endif () + get_target_property(IS_RUST_PROJECT ${plugin} RUST_PROJECT) + + if (IS_RUST_PROJECT) + set_target_properties(${plugin} PROPERTIES CARGO_BUILD_TARGET_DIR ${CMAKE_BINARY_DIR}/plugins) + + get_target_property(PLUGIN_LOCATION ${plugin} LOCATION) + + install(FILES "${PLUGIN_LOCATION}/../${plugin}.hexplug" DESTINATION "${PLUGINS_INSTALL_LOCATION}") else () - install(TARGETS ${plugin} LIBRARY DESTINATION ${PLUGINS_INSTALL_LOCATION}) + set_target_properties(${plugin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins) + if (WIN32) + install(TARGETS ${plugin} RUNTIME DESTINATION ${PLUGINS_INSTALL_LOCATION}) + elseif (APPLE) + if (CREATE_BUNDLE) + set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY $/${PLUGINS_INSTALL_LOCATION}) + else () + set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins) + endif () + else () + install(TARGETS ${plugin} LIBRARY DESTINATION ${PLUGINS_INSTALL_LOCATION}) + endif () endif () add_dependencies(imhex ${plugin}) @@ -254,4 +266,4 @@ macro(setDefaultBuiltTypeIfUnset) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Using Release build type as it was left unset" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") endif() -endmacro() \ No newline at end of file +endmacro() diff --git a/external/ImGui/CMakeLists.txt b/external/ImGui/CMakeLists.txt index 5fa06d0b7..d75ce7d4b 100644 --- a/external/ImGui/CMakeLists.txt +++ b/external/ImGui/CMakeLists.txt @@ -13,7 +13,7 @@ endif () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -add_library(imgui STATIC +add_library(imgui OBJECT source/imgui.cpp source/imgui_demo.cpp source/imgui_draw.cpp @@ -23,6 +23,8 @@ add_library(imgui STATIC source/imgui_tables.cpp source/imgui_widgets.cpp + source/cimgui.cpp + source/TextEditor.cpp source/imgui_imhex_extensions.cpp @@ -40,12 +42,12 @@ add_library(imgui STATIC add_compile_definitions(IMGUI_IMPL_OPENGL_LOADER_GLAD) -target_include_directories(imgui PUBLIC include fonts ${FREETYPE_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS}) +target_include_directories(imgui PUBLIC include fonts ${CMAKE_CURRENT_SOURCE_DIR} ${FREETYPE_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS}) target_link_directories(imgui PUBLIC ${GLFW_LIBRARY_DIRS}) if (WIN32) - target_link_libraries(imgui Freetype::Freetype glfw3 opengl32.lib) + target_link_libraries(imgui PUBLIC Freetype::Freetype glfw3 opengl32.lib) elseif (UNIX) - target_link_libraries(imgui Freetype::Freetype glfw OpenGL::GL) + target_link_libraries(imgui PUBLIC Freetype::Freetype glfw OpenGL::GL) endif() diff --git a/external/ImGui/include/cimgui.h b/external/ImGui/include/cimgui.h new file mode 100644 index 000000000..a5db05fd4 --- /dev/null +++ b/external/ImGui/include/cimgui.h @@ -0,0 +1,3485 @@ +//This file is automatically generated by generator.lua from https://github.com/cimgui/cimgui +//based on imgui.h file version "1.84.1" from Dear ImGui https://github.com/ocornut/imgui +//with imgui_internal.h api +#ifndef CIMGUI_INCLUDED +#define CIMGUI_INCLUDED +#include +#include +#if defined _WIN32 || defined __CYGWIN__ + #ifdef CIMGUI_NO_EXPORT + #define API + #else + #define API __declspec(dllexport) + #endif +#else + #ifdef __GNUC__ + #define API __attribute__((__visibility__("default"))) + #else + #define API + #endif +#endif + +#if defined __cplusplus + #define EXTERN extern "C" +#else + #include + #include + #define EXTERN extern +#endif + +#define CIMGUI_API EXTERN API +#define CONST const + + +#ifdef _MSC_VER +typedef unsigned __int64 ImU64; +#else +//typedef unsigned long long ImU64; +#endif + + +#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS +typedef struct ImGuiTableColumnSettings ImGuiTableColumnSettings; +typedef struct ImGuiTableCellData ImGuiTableCellData; +typedef struct ImGuiViewportP ImGuiViewportP; +typedef struct ImGuiPtrOrIndex ImGuiPtrOrIndex; +typedef struct ImGuiShrinkWidthItem ImGuiShrinkWidthItem; +typedef struct ImGuiWindowStackData ImGuiWindowStackData; +typedef struct ImGuiComboPreviewData ImGuiComboPreviewData; +typedef struct ImGuiDataTypeTempStorage ImGuiDataTypeTempStorage; +typedef struct ImVec2ih ImVec2ih; +typedef struct ImVec1 ImVec1; +typedef struct StbTexteditRow StbTexteditRow; +typedef struct STB_TexteditState STB_TexteditState; +typedef struct StbUndoState StbUndoState; +typedef struct StbUndoRecord StbUndoRecord; +typedef struct ImGuiWindowSettings ImGuiWindowSettings; +typedef struct ImGuiWindowTempData ImGuiWindowTempData; +typedef struct ImGuiWindow ImGuiWindow; +typedef struct ImGuiTableColumnsSettings ImGuiTableColumnsSettings; +typedef struct ImGuiTableSettings ImGuiTableSettings; +typedef struct ImGuiTableTempData ImGuiTableTempData; +typedef struct ImGuiTableColumn ImGuiTableColumn; +typedef struct ImGuiTable ImGuiTable; +typedef struct ImGuiTabItem ImGuiTabItem; +typedef struct ImGuiTabBar ImGuiTabBar; +typedef struct ImGuiStyleMod ImGuiStyleMod; +typedef struct ImGuiStackSizes ImGuiStackSizes; +typedef struct ImGuiSettingsHandler ImGuiSettingsHandler; +typedef struct ImGuiPopupData ImGuiPopupData; +typedef struct ImGuiOldColumns ImGuiOldColumns; +typedef struct ImGuiOldColumnData ImGuiOldColumnData; +typedef struct ImGuiNextItemData ImGuiNextItemData; +typedef struct ImGuiNextWindowData ImGuiNextWindowData; +typedef struct ImGuiMetricsConfig ImGuiMetricsConfig; +typedef struct ImGuiNavItemData ImGuiNavItemData; +typedef struct ImGuiMenuColumns ImGuiMenuColumns; +typedef struct ImGuiLastItemData ImGuiLastItemData; +typedef struct ImGuiInputTextState ImGuiInputTextState; +typedef struct ImGuiGroupData ImGuiGroupData; +typedef struct ImGuiDataTypeInfo ImGuiDataTypeInfo; +typedef struct ImGuiContextHook ImGuiContextHook; +typedef struct ImGuiColorMod ImGuiColorMod; +typedef struct ImDrawDataBuilder ImDrawDataBuilder; +typedef struct ImRect ImRect; +typedef struct ImBitVector ImBitVector; +typedef struct ImFontAtlasCustomRect ImFontAtlasCustomRect; +typedef struct ImDrawCmdHeader ImDrawCmdHeader; +typedef struct ImGuiStoragePair ImGuiStoragePair; +typedef struct ImGuiTextRange ImGuiTextRange; +typedef struct ImVec4 ImVec4; +typedef struct ImVec2 ImVec2; +typedef struct ImGuiViewport ImGuiViewport; +typedef struct ImGuiTextFilter ImGuiTextFilter; +typedef struct ImGuiTextBuffer ImGuiTextBuffer; +typedef struct ImGuiTableColumnSortSpecs ImGuiTableColumnSortSpecs; +typedef struct ImGuiTableSortSpecs ImGuiTableSortSpecs; +typedef struct ImGuiStyle ImGuiStyle; +typedef struct ImGuiStorage ImGuiStorage; +typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData; +typedef struct ImGuiPayload ImGuiPayload; +typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame; +typedef struct ImGuiListClipper ImGuiListClipper; +typedef struct ImGuiInputTextCallbackData ImGuiInputTextCallbackData; +typedef struct ImGuiIO ImGuiIO; +typedef struct ImGuiContext ImGuiContext; +typedef struct ImColor ImColor; +typedef struct ImFontGlyphRangesBuilder ImFontGlyphRangesBuilder; +typedef struct ImFontGlyph ImFontGlyph; +typedef struct ImFontConfig ImFontConfig; +typedef struct ImFontBuilderIO ImFontBuilderIO; +typedef struct ImFontAtlas ImFontAtlas; +typedef struct ImFont ImFont; +typedef struct ImDrawVert ImDrawVert; +typedef struct ImDrawListSplitter ImDrawListSplitter; +typedef struct ImDrawListSharedData ImDrawListSharedData; +typedef struct ImDrawList ImDrawList; +typedef struct ImDrawData ImDrawData; +typedef struct ImDrawCmd ImDrawCmd; +typedef struct ImDrawChannel ImDrawChannel; + +struct ImDrawChannel; +struct ImDrawCmd; +struct ImDrawData; +struct ImDrawList; +struct ImDrawListSharedData; +struct ImDrawListSplitter; +struct ImDrawVert; +struct ImFont; +struct ImFontAtlas; +struct ImFontBuilderIO; +struct ImFontConfig; +struct ImFontGlyph; +struct ImFontGlyphRangesBuilder; +struct ImColor; +struct ImGuiContext; +struct ImGuiIO; +struct ImGuiInputTextCallbackData; +struct ImGuiListClipper; +struct ImGuiOnceUponAFrame; +struct ImGuiPayload; +struct ImGuiSizeCallbackData; +struct ImGuiStorage; +struct ImGuiStyle; +struct ImGuiTableSortSpecs; +struct ImGuiTableColumnSortSpecs; +struct ImGuiTextBuffer; +struct ImGuiTextFilter; +struct ImGuiViewport; +typedef int ImGuiCol; +typedef int ImGuiCond; +typedef int ImGuiDataType; +typedef int ImGuiDir; +typedef int ImGuiKey; +typedef int ImGuiNavInput; +typedef int ImGuiMouseButton; +typedef int ImGuiMouseCursor; +typedef int ImGuiSortDirection; +typedef int ImGuiStyleVar; +typedef int ImGuiTableBgTarget; +typedef int ImDrawFlags; +typedef int ImDrawListFlags; +typedef int ImFontAtlasFlags; +typedef int ImGuiBackendFlags; +typedef int ImGuiButtonFlags; +typedef int ImGuiColorEditFlags; +typedef int ImGuiConfigFlags; +typedef int ImGuiComboFlags; +typedef int ImGuiDragDropFlags; +typedef int ImGuiFocusedFlags; +typedef int ImGuiHoveredFlags; +typedef int ImGuiInputTextFlags; +typedef int ImGuiKeyModFlags; +typedef int ImGuiPopupFlags; +typedef int ImGuiSelectableFlags; +typedef int ImGuiSliderFlags; +typedef int ImGuiTabBarFlags; +typedef int ImGuiTabItemFlags; +typedef int ImGuiTableFlags; +typedef int ImGuiTableColumnFlags; +typedef int ImGuiTableRowFlags; +typedef int ImGuiTreeNodeFlags; +typedef int ImGuiViewportFlags; +typedef int ImGuiWindowFlags; +typedef void* ImTextureID; +typedef unsigned int ImGuiID; +typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); +typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); +typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); +typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); +typedef unsigned short ImWchar16; +typedef unsigned int ImWchar32; +typedef ImWchar16 ImWchar; +typedef signed char ImS8; +typedef unsigned char ImU8; +typedef signed short ImS16; +typedef unsigned short ImU16; +typedef signed int ImS32; +typedef unsigned int ImU32; +typedef int64_t ImS64; +typedef uint64_t ImU64; +typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); +typedef unsigned short ImDrawIdx; +struct ImBitVector; +struct ImRect; +struct ImDrawDataBuilder; +struct ImDrawListSharedData; +struct ImGuiColorMod; +struct ImGuiContext; +struct ImGuiContextHook; +struct ImGuiDataTypeInfo; +struct ImGuiGroupData; +struct ImGuiInputTextState; +struct ImGuiLastItemData; +struct ImGuiMenuColumns; +struct ImGuiNavItemData; +struct ImGuiMetricsConfig; +struct ImGuiNextWindowData; +struct ImGuiNextItemData; +struct ImGuiOldColumnData; +struct ImGuiOldColumns; +struct ImGuiPopupData; +struct ImGuiSettingsHandler; +struct ImGuiStackSizes; +struct ImGuiStyleMod; +struct ImGuiTabBar; +struct ImGuiTabItem; +struct ImGuiTable; +struct ImGuiTableColumn; +struct ImGuiTableTempData; +struct ImGuiTableSettings; +struct ImGuiTableColumnsSettings; +struct ImGuiWindow; +struct ImGuiWindowTempData; +struct ImGuiWindowSettings; +typedef int ImGuiLayoutType; +typedef int ImGuiItemFlags; +typedef int ImGuiItemAddFlags; +typedef int ImGuiItemStatusFlags; +typedef int ImGuiOldColumnFlags; +typedef int ImGuiNavHighlightFlags; +typedef int ImGuiNavDirSourceFlags; +typedef int ImGuiNavMoveFlags; +typedef int ImGuiNextItemDataFlags; +typedef int ImGuiNextWindowDataFlags; +typedef int ImGuiSeparatorFlags; +typedef int ImGuiTextFlags; +typedef int ImGuiTooltipFlags; +typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...); +extern ImGuiContext* GImGui; +typedef FILE* ImFileHandle; +typedef int ImPoolIdx; +typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook); +typedef ImS8 ImGuiTableColumnIdx; +typedef ImU8 ImGuiTableDrawChannelIdx; +typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector; +typedef struct ImVector_ImGuiTableSettings {int Size;int Capacity;ImGuiTableSettings* Data;} ImVector_ImGuiTableSettings; +typedef struct ImChunkStream_ImGuiTableSettings {ImVector_ImGuiTableSettings Buf;} ImChunkStream_ImGuiTableSettings; +typedef struct ImVector_ImGuiWindowSettings {int Size;int Capacity;ImGuiWindowSettings* Data;} ImVector_ImGuiWindowSettings; +typedef struct ImChunkStream_ImGuiWindowSettings {ImVector_ImGuiWindowSettings Buf;} ImChunkStream_ImGuiWindowSettings; +typedef struct ImSpan_ImGuiTableCellData {ImGuiTableCellData* Data;ImGuiTableCellData* DataEnd;} ImSpan_ImGuiTableCellData; +typedef struct ImSpan_ImGuiTableColumn {ImGuiTableColumn* Data;ImGuiTableColumn* DataEnd;} ImSpan_ImGuiTableColumn; +typedef struct ImSpan_ImGuiTableColumnIdx {ImGuiTableColumnIdx* Data;ImGuiTableColumnIdx* DataEnd;} ImSpan_ImGuiTableColumnIdx; +typedef struct ImVector_ImDrawChannel {int Size;int Capacity;ImDrawChannel* Data;} ImVector_ImDrawChannel; +typedef struct ImVector_ImDrawCmd {int Size;int Capacity;ImDrawCmd* Data;} ImVector_ImDrawCmd; +typedef struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVector_ImDrawIdx; +typedef struct ImVector_ImDrawListPtr {int Size;int Capacity;ImDrawList** Data;} ImVector_ImDrawListPtr; +typedef struct ImVector_ImDrawVert {int Size;int Capacity;ImDrawVert* Data;} ImVector_ImDrawVert; +typedef struct ImVector_ImFontPtr {int Size;int Capacity;ImFont** Data;} ImVector_ImFontPtr; +typedef struct ImVector_ImFontAtlasCustomRect {int Size;int Capacity;ImFontAtlasCustomRect* Data;} ImVector_ImFontAtlasCustomRect; +typedef struct ImVector_ImFontConfig {int Size;int Capacity;ImFontConfig* Data;} ImVector_ImFontConfig; +typedef struct ImVector_ImFontGlyph {int Size;int Capacity;ImFontGlyph* Data;} ImVector_ImFontGlyph; +typedef struct ImVector_ImGuiColorMod {int Size;int Capacity;ImGuiColorMod* Data;} ImVector_ImGuiColorMod; +typedef struct ImVector_ImGuiContextHook {int Size;int Capacity;ImGuiContextHook* Data;} ImVector_ImGuiContextHook; +typedef struct ImVector_ImGuiGroupData {int Size;int Capacity;ImGuiGroupData* Data;} ImVector_ImGuiGroupData; +typedef struct ImVector_ImGuiID {int Size;int Capacity;ImGuiID* Data;} ImVector_ImGuiID; +typedef struct ImVector_ImGuiItemFlags {int Size;int Capacity;ImGuiItemFlags* Data;} ImVector_ImGuiItemFlags; +typedef struct ImVector_ImGuiOldColumnData {int Size;int Capacity;ImGuiOldColumnData* Data;} ImVector_ImGuiOldColumnData; +typedef struct ImVector_ImGuiOldColumns {int Size;int Capacity;ImGuiOldColumns* Data;} ImVector_ImGuiOldColumns; +typedef struct ImVector_ImGuiPopupData {int Size;int Capacity;ImGuiPopupData* Data;} ImVector_ImGuiPopupData; +typedef struct ImVector_ImGuiPtrOrIndex {int Size;int Capacity;ImGuiPtrOrIndex* Data;} ImVector_ImGuiPtrOrIndex; +typedef struct ImVector_ImGuiSettingsHandler {int Size;int Capacity;ImGuiSettingsHandler* Data;} ImVector_ImGuiSettingsHandler; +typedef struct ImVector_ImGuiShrinkWidthItem {int Size;int Capacity;ImGuiShrinkWidthItem* Data;} ImVector_ImGuiShrinkWidthItem; +typedef struct ImVector_ImGuiStoragePair {int Size;int Capacity;ImGuiStoragePair* Data;} ImVector_ImGuiStoragePair; +typedef struct ImVector_ImGuiStyleMod {int Size;int Capacity;ImGuiStyleMod* Data;} ImVector_ImGuiStyleMod; +typedef struct ImVector_ImGuiTabItem {int Size;int Capacity;ImGuiTabItem* Data;} ImVector_ImGuiTabItem; +typedef struct ImVector_ImGuiTableColumnSortSpecs {int Size;int Capacity;ImGuiTableColumnSortSpecs* Data;} ImVector_ImGuiTableColumnSortSpecs; +typedef struct ImVector_ImGuiTableTempData {int Size;int Capacity;ImGuiTableTempData* Data;} ImVector_ImGuiTableTempData; +typedef struct ImVector_ImGuiTextRange {int Size;int Capacity;ImGuiTextRange* Data;} ImVector_ImGuiTextRange; +typedef struct ImVector_ImGuiViewportPPtr {int Size;int Capacity;ImGuiViewportP** Data;} ImVector_ImGuiViewportPPtr; +typedef struct ImVector_ImGuiWindowPtr {int Size;int Capacity;ImGuiWindow** Data;} ImVector_ImGuiWindowPtr; +typedef struct ImVector_ImGuiWindowStackData {int Size;int Capacity;ImGuiWindowStackData* Data;} ImVector_ImGuiWindowStackData; +typedef struct ImVector_ImTextureID {int Size;int Capacity;ImTextureID* Data;} ImVector_ImTextureID; +typedef struct ImVector_ImU32 {int Size;int Capacity;ImU32* Data;} ImVector_ImU32; +typedef struct ImVector_ImVec2 {int Size;int Capacity;ImVec2* Data;} ImVector_ImVec2; +typedef struct ImVector_ImVec4 {int Size;int Capacity;ImVec4* Data;} ImVector_ImVec4; +typedef struct ImVector_ImWchar {int Size;int Capacity;ImWchar* Data;} ImVector_ImWchar; +typedef struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char; +typedef struct ImVector_float {int Size;int Capacity;float* Data;} ImVector_float; +typedef struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char; + +struct ImVec2 +{ + float x, y; +}; +struct ImVec4 +{ + float x, y, z, w; +}; +typedef enum { + ImGuiWindowFlags_None = 0, + ImGuiWindowFlags_NoTitleBar = 1 << 0, + ImGuiWindowFlags_NoResize = 1 << 1, + ImGuiWindowFlags_NoMove = 1 << 2, + ImGuiWindowFlags_NoScrollbar = 1 << 3, + ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, + ImGuiWindowFlags_NoCollapse = 1 << 5, + ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, + ImGuiWindowFlags_NoBackground = 1 << 7, + ImGuiWindowFlags_NoSavedSettings = 1 << 8, + ImGuiWindowFlags_NoMouseInputs = 1 << 9, + ImGuiWindowFlags_MenuBar = 1 << 10, + ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, + ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, + ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, + ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, + ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, + ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, + ImGuiWindowFlags_NoNavInputs = 1 << 18, + ImGuiWindowFlags_NoNavFocus = 1 << 19, + ImGuiWindowFlags_UnsavedDocument = 1 << 20, + ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, + ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse, + ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, + ImGuiWindowFlags_NavFlattened = 1 << 23, + ImGuiWindowFlags_ChildWindow = 1 << 24, + ImGuiWindowFlags_Tooltip = 1 << 25, + ImGuiWindowFlags_Popup = 1 << 26, + ImGuiWindowFlags_Modal = 1 << 27, + ImGuiWindowFlags_ChildMenu = 1 << 28 +}ImGuiWindowFlags_; +typedef enum { + ImGuiInputTextFlags_None = 0, + ImGuiInputTextFlags_CharsDecimal = 1 << 0, + ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, + ImGuiInputTextFlags_CharsUppercase = 1 << 2, + ImGuiInputTextFlags_CharsNoBlank = 1 << 3, + ImGuiInputTextFlags_AutoSelectAll = 1 << 4, + ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, + ImGuiInputTextFlags_CallbackCompletion = 1 << 6, + ImGuiInputTextFlags_CallbackHistory = 1 << 7, + ImGuiInputTextFlags_CallbackAlways = 1 << 8, + ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, + ImGuiInputTextFlags_AllowTabInput = 1 << 10, + ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, + ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, + ImGuiInputTextFlags_AlwaysOverwrite = 1 << 13, + ImGuiInputTextFlags_ReadOnly = 1 << 14, + ImGuiInputTextFlags_Password = 1 << 15, + ImGuiInputTextFlags_NoUndoRedo = 1 << 16, + ImGuiInputTextFlags_CharsScientific = 1 << 17, + ImGuiInputTextFlags_CallbackResize = 1 << 18, + ImGuiInputTextFlags_CallbackEdit = 1 << 19 +}ImGuiInputTextFlags_; +typedef enum { + ImGuiTreeNodeFlags_None = 0, + ImGuiTreeNodeFlags_Selected = 1 << 0, + ImGuiTreeNodeFlags_Framed = 1 << 1, + ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, + ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, + ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, + ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, + ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, + ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, + ImGuiTreeNodeFlags_Leaf = 1 << 8, + ImGuiTreeNodeFlags_Bullet = 1 << 9, + ImGuiTreeNodeFlags_FramePadding = 1 << 10, + ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, + ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, + ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, + ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog +}ImGuiTreeNodeFlags_; +typedef enum { + ImGuiPopupFlags_None = 0, + ImGuiPopupFlags_MouseButtonLeft = 0, + ImGuiPopupFlags_MouseButtonRight = 1, + ImGuiPopupFlags_MouseButtonMiddle = 2, + ImGuiPopupFlags_MouseButtonMask_ = 0x1F, + ImGuiPopupFlags_MouseButtonDefault_ = 1, + ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, + ImGuiPopupFlags_NoOpenOverItems = 1 << 6, + ImGuiPopupFlags_AnyPopupId = 1 << 7, + ImGuiPopupFlags_AnyPopupLevel = 1 << 8, + ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel +}ImGuiPopupFlags_; +typedef enum { + ImGuiSelectableFlags_None = 0, + ImGuiSelectableFlags_DontClosePopups = 1 << 0, + ImGuiSelectableFlags_SpanAllColumns = 1 << 1, + ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, + ImGuiSelectableFlags_Disabled = 1 << 3, + ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 +}ImGuiSelectableFlags_; +typedef enum { + ImGuiComboFlags_None = 0, + ImGuiComboFlags_PopupAlignLeft = 1 << 0, + ImGuiComboFlags_HeightSmall = 1 << 1, + ImGuiComboFlags_HeightRegular = 1 << 2, + ImGuiComboFlags_HeightLarge = 1 << 3, + ImGuiComboFlags_HeightLargest = 1 << 4, + ImGuiComboFlags_NoArrowButton = 1 << 5, + ImGuiComboFlags_NoPreview = 1 << 6, + ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest +}ImGuiComboFlags_; +typedef enum { + ImGuiTabBarFlags_None = 0, + ImGuiTabBarFlags_Reorderable = 1 << 0, + ImGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, + ImGuiTabBarFlags_TabListPopupButton = 1 << 2, + ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, + ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, + ImGuiTabBarFlags_NoTooltip = 1 << 5, + ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, + ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, + ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll, + ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown +}ImGuiTabBarFlags_; +typedef enum { + ImGuiTabItemFlags_None = 0, + ImGuiTabItemFlags_UnsavedDocument = 1 << 0, + ImGuiTabItemFlags_SetSelected = 1 << 1, + ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, + ImGuiTabItemFlags_NoPushId = 1 << 3, + ImGuiTabItemFlags_NoTooltip = 1 << 4, + ImGuiTabItemFlags_NoReorder = 1 << 5, + ImGuiTabItemFlags_Leading = 1 << 6, + ImGuiTabItemFlags_Trailing = 1 << 7 +}ImGuiTabItemFlags_; +typedef enum { + ImGuiTableFlags_None = 0, + ImGuiTableFlags_Resizable = 1 << 0, + ImGuiTableFlags_Reorderable = 1 << 1, + ImGuiTableFlags_Hideable = 1 << 2, + ImGuiTableFlags_Sortable = 1 << 3, + ImGuiTableFlags_NoSavedSettings = 1 << 4, + ImGuiTableFlags_ContextMenuInBody = 1 << 5, + ImGuiTableFlags_RowBg = 1 << 6, + ImGuiTableFlags_BordersInnerH = 1 << 7, + ImGuiTableFlags_BordersOuterH = 1 << 8, + ImGuiTableFlags_BordersInnerV = 1 << 9, + ImGuiTableFlags_BordersOuterV = 1 << 10, + ImGuiTableFlags_BordersH = ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH, + ImGuiTableFlags_BordersV = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuterV, + ImGuiTableFlags_BordersInner = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersInnerH, + ImGuiTableFlags_BordersOuter = ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_BordersOuterH, + ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, + ImGuiTableFlags_NoBordersInBody = 1 << 11, + ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, + ImGuiTableFlags_SizingFixedFit = 1 << 13, + ImGuiTableFlags_SizingFixedSame = 2 << 13, + ImGuiTableFlags_SizingStretchProp = 3 << 13, + ImGuiTableFlags_SizingStretchSame = 4 << 13, + ImGuiTableFlags_NoHostExtendX = 1 << 16, + ImGuiTableFlags_NoHostExtendY = 1 << 17, + ImGuiTableFlags_NoKeepColumnsVisible = 1 << 18, + ImGuiTableFlags_PreciseWidths = 1 << 19, + ImGuiTableFlags_NoClip = 1 << 20, + ImGuiTableFlags_PadOuterX = 1 << 21, + ImGuiTableFlags_NoPadOuterX = 1 << 22, + ImGuiTableFlags_NoPadInnerX = 1 << 23, + ImGuiTableFlags_ScrollX = 1 << 24, + ImGuiTableFlags_ScrollY = 1 << 25, + ImGuiTableFlags_SortMulti = 1 << 26, + ImGuiTableFlags_SortTristate = 1 << 27, + ImGuiTableFlags_SizingMask_ = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_SizingStretchSame +}ImGuiTableFlags_; +typedef enum { + ImGuiTableColumnFlags_None = 0, + ImGuiTableColumnFlags_Disabled = 1 << 0, + ImGuiTableColumnFlags_DefaultHide = 1 << 1, + ImGuiTableColumnFlags_DefaultSort = 1 << 2, + ImGuiTableColumnFlags_WidthStretch = 1 << 3, + ImGuiTableColumnFlags_WidthFixed = 1 << 4, + ImGuiTableColumnFlags_NoResize = 1 << 5, + ImGuiTableColumnFlags_NoReorder = 1 << 6, + ImGuiTableColumnFlags_NoHide = 1 << 7, + ImGuiTableColumnFlags_NoClip = 1 << 8, + ImGuiTableColumnFlags_NoSort = 1 << 9, + ImGuiTableColumnFlags_NoSortAscending = 1 << 10, + ImGuiTableColumnFlags_NoSortDescending = 1 << 11, + ImGuiTableColumnFlags_NoHeaderLabel = 1 << 12, + ImGuiTableColumnFlags_NoHeaderWidth = 1 << 13, + ImGuiTableColumnFlags_PreferSortAscending = 1 << 14, + ImGuiTableColumnFlags_PreferSortDescending = 1 << 15, + ImGuiTableColumnFlags_IndentEnable = 1 << 16, + ImGuiTableColumnFlags_IndentDisable = 1 << 17, + ImGuiTableColumnFlags_IsEnabled = 1 << 24, + ImGuiTableColumnFlags_IsVisible = 1 << 25, + ImGuiTableColumnFlags_IsSorted = 1 << 26, + ImGuiTableColumnFlags_IsHovered = 1 << 27, + ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed, + ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable, + ImGuiTableColumnFlags_StatusMask_ = ImGuiTableColumnFlags_IsEnabled | ImGuiTableColumnFlags_IsVisible | ImGuiTableColumnFlags_IsSorted | ImGuiTableColumnFlags_IsHovered, + ImGuiTableColumnFlags_NoDirectResize_ = 1 << 30 +}ImGuiTableColumnFlags_; +typedef enum { + ImGuiTableRowFlags_None = 0, + ImGuiTableRowFlags_Headers = 1 << 0 +}ImGuiTableRowFlags_; +typedef enum { + ImGuiTableBgTarget_None = 0, + ImGuiTableBgTarget_RowBg0 = 1, + ImGuiTableBgTarget_RowBg1 = 2, + ImGuiTableBgTarget_CellBg = 3 +}ImGuiTableBgTarget_; +typedef enum { + ImGuiFocusedFlags_None = 0, + ImGuiFocusedFlags_ChildWindows = 1 << 0, + ImGuiFocusedFlags_RootWindow = 1 << 1, + ImGuiFocusedFlags_AnyWindow = 1 << 2, + ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows +}ImGuiFocusedFlags_; +typedef enum { + ImGuiHoveredFlags_None = 0, + ImGuiHoveredFlags_ChildWindows = 1 << 0, + ImGuiHoveredFlags_RootWindow = 1 << 1, + ImGuiHoveredFlags_AnyWindow = 1 << 2, + ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 3, + ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, + ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, + ImGuiHoveredFlags_AllowWhenDisabled = 1 << 7, + ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, + ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows +}ImGuiHoveredFlags_; +typedef enum { + ImGuiDragDropFlags_None = 0, + ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, + ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, + ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, + ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, + ImGuiDragDropFlags_SourceExtern = 1 << 4, + ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, + ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, + ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, + ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, + ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect +}ImGuiDragDropFlags_; +typedef enum { + ImGuiDataType_S8, + ImGuiDataType_U8, + ImGuiDataType_S16, + ImGuiDataType_U16, + ImGuiDataType_S32, + ImGuiDataType_U32, + ImGuiDataType_S64, + ImGuiDataType_U64, + ImGuiDataType_Float, + ImGuiDataType_Double, + ImGuiDataType_COUNT +}ImGuiDataType_; +typedef enum { + ImGuiDir_None = -1, + ImGuiDir_Left = 0, + ImGuiDir_Right = 1, + ImGuiDir_Up = 2, + ImGuiDir_Down = 3, + ImGuiDir_COUNT +}ImGuiDir_; +typedef enum { + ImGuiSortDirection_None = 0, + ImGuiSortDirection_Ascending = 1, + ImGuiSortDirection_Descending = 2 +}ImGuiSortDirection_; +typedef enum { + 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_KeyPadEnter, + ImGuiKey_A, + ImGuiKey_C, + ImGuiKey_V, + ImGuiKey_X, + ImGuiKey_Y, + ImGuiKey_Z, + ImGuiKey_COUNT +}ImGuiKey_; +typedef enum { + ImGuiKeyModFlags_None = 0, + ImGuiKeyModFlags_Ctrl = 1 << 0, + ImGuiKeyModFlags_Shift = 1 << 1, + ImGuiKeyModFlags_Alt = 1 << 2, + ImGuiKeyModFlags_Super = 1 << 3 +}ImGuiKeyModFlags_; +typedef enum { + 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, + ImGuiNavInput_KeyLeft_, + ImGuiNavInput_KeyRight_, + ImGuiNavInput_KeyUp_, + ImGuiNavInput_KeyDown_, + ImGuiNavInput_COUNT, + ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_ +}ImGuiNavInput_; +typedef enum { + ImGuiConfigFlags_None = 0, + ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, + ImGuiConfigFlags_NavEnableGamepad = 1 << 1, + ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, + ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, + ImGuiConfigFlags_NoMouse = 1 << 4, + ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, + ImGuiConfigFlags_IsSRGB = 1 << 20, + ImGuiConfigFlags_IsTouchScreen = 1 << 21 +}ImGuiConfigFlags_; +typedef enum { + ImGuiBackendFlags_None = 0, + ImGuiBackendFlags_HasGamepad = 1 << 0, + ImGuiBackendFlags_HasMouseCursors = 1 << 1, + ImGuiBackendFlags_HasSetMousePos = 1 << 2, + ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3 +}ImGuiBackendFlags_; +typedef enum { + 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_Tab, + ImGuiCol_TabHovered, + ImGuiCol_TabActive, + ImGuiCol_TabUnfocused, + ImGuiCol_TabUnfocusedActive, + ImGuiCol_PlotLines, + ImGuiCol_PlotLinesHovered, + ImGuiCol_PlotHistogram, + ImGuiCol_PlotHistogramHovered, + ImGuiCol_TableHeaderBg, + ImGuiCol_TableBorderStrong, + ImGuiCol_TableBorderLight, + ImGuiCol_TableRowBg, + ImGuiCol_TableRowBgAlt, + ImGuiCol_TextSelectedBg, + ImGuiCol_DragDropTarget, + ImGuiCol_NavHighlight, + ImGuiCol_NavWindowingHighlight, + ImGuiCol_NavWindowingDimBg, + ImGuiCol_ModalWindowDimBg, + ImGuiCol_COUNT +}ImGuiCol_; +typedef enum { + ImGuiStyleVar_Alpha, + ImGuiStyleVar_DisabledAlpha, + 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_CellPadding, + ImGuiStyleVar_ScrollbarSize, + ImGuiStyleVar_ScrollbarRounding, + ImGuiStyleVar_GrabMinSize, + ImGuiStyleVar_GrabRounding, + ImGuiStyleVar_TabRounding, + ImGuiStyleVar_ButtonTextAlign, + ImGuiStyleVar_SelectableTextAlign, + ImGuiStyleVar_COUNT +}ImGuiStyleVar_; +typedef enum { + ImGuiButtonFlags_None = 0, + ImGuiButtonFlags_MouseButtonLeft = 1 << 0, + ImGuiButtonFlags_MouseButtonRight = 1 << 1, + ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, + ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, + ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft +}ImGuiButtonFlags_; +typedef enum { + ImGuiColorEditFlags_None = 0, + ImGuiColorEditFlags_NoAlpha = 1 << 1, + ImGuiColorEditFlags_NoPicker = 1 << 2, + ImGuiColorEditFlags_NoOptions = 1 << 3, + ImGuiColorEditFlags_NoSmallPreview = 1 << 4, + ImGuiColorEditFlags_NoInputs = 1 << 5, + ImGuiColorEditFlags_NoTooltip = 1 << 6, + ImGuiColorEditFlags_NoLabel = 1 << 7, + ImGuiColorEditFlags_NoSidePreview = 1 << 8, + ImGuiColorEditFlags_NoDragDrop = 1 << 9, + ImGuiColorEditFlags_NoBorder = 1 << 10, + ImGuiColorEditFlags_AlphaBar = 1 << 16, + ImGuiColorEditFlags_AlphaPreview = 1 << 17, + ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, + ImGuiColorEditFlags_HDR = 1 << 19, + ImGuiColorEditFlags_DisplayRGB = 1 << 20, + ImGuiColorEditFlags_DisplayHSV = 1 << 21, + ImGuiColorEditFlags_DisplayHex = 1 << 22, + ImGuiColorEditFlags_Uint8 = 1 << 23, + ImGuiColorEditFlags_Float = 1 << 24, + ImGuiColorEditFlags_PickerHueBar = 1 << 25, + ImGuiColorEditFlags_PickerHueWheel = 1 << 26, + ImGuiColorEditFlags_InputRGB = 1 << 27, + ImGuiColorEditFlags_InputHSV = 1 << 28, + ImGuiColorEditFlags_DefaultOptions_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar, + ImGuiColorEditFlags_DisplayMask_ = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex, + ImGuiColorEditFlags_DataTypeMask_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float, + ImGuiColorEditFlags_PickerMask_ = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar, + ImGuiColorEditFlags_InputMask_ = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV +}ImGuiColorEditFlags_; +typedef enum { + ImGuiSliderFlags_None = 0, + ImGuiSliderFlags_AlwaysClamp = 1 << 4, + ImGuiSliderFlags_Logarithmic = 1 << 5, + ImGuiSliderFlags_NoRoundToFormat = 1 << 6, + ImGuiSliderFlags_NoInput = 1 << 7, + ImGuiSliderFlags_InvalidMask_ = 0x7000000F +}ImGuiSliderFlags_; +typedef enum { + ImGuiMouseButton_Left = 0, + ImGuiMouseButton_Right = 1, + ImGuiMouseButton_Middle = 2, + ImGuiMouseButton_COUNT = 5 +}ImGuiMouseButton_; +typedef enum { + ImGuiMouseCursor_None = -1, + ImGuiMouseCursor_Arrow = 0, + ImGuiMouseCursor_TextInput, + ImGuiMouseCursor_ResizeAll, + ImGuiMouseCursor_ResizeNS, + ImGuiMouseCursor_ResizeEW, + ImGuiMouseCursor_ResizeNESW, + ImGuiMouseCursor_ResizeNWSE, + ImGuiMouseCursor_Hand, + ImGuiMouseCursor_NotAllowed, + ImGuiMouseCursor_COUNT +}ImGuiMouseCursor_; +typedef enum { + ImGuiCond_None = 0, + ImGuiCond_Always = 1 << 0, + ImGuiCond_Once = 1 << 1, + ImGuiCond_FirstUseEver = 1 << 2, + ImGuiCond_Appearing = 1 << 3 +}ImGuiCond_; +struct ImGuiStyle +{ + float Alpha; + float DisabledAlpha; + ImVec2 WindowPadding; + float WindowRounding; + float WindowBorderSize; + ImVec2 WindowMinSize; + ImVec2 WindowTitleAlign; + ImGuiDir WindowMenuButtonPosition; + float ChildRounding; + float ChildBorderSize; + float PopupRounding; + float PopupBorderSize; + ImVec2 FramePadding; + float FrameRounding; + float FrameBorderSize; + ImVec2 ItemSpacing; + ImVec2 ItemInnerSpacing; + ImVec2 CellPadding; + ImVec2 TouchExtraPadding; + float IndentSpacing; + float ColumnsMinSpacing; + float ScrollbarSize; + float ScrollbarRounding; + float GrabMinSize; + float GrabRounding; + float LogSliderDeadzone; + float TabRounding; + float TabBorderSize; + float TabMinWidthForCloseButton; + ImGuiDir ColorButtonPosition; + ImVec2 ButtonTextAlign; + ImVec2 SelectableTextAlign; + ImVec2 DisplayWindowPadding; + ImVec2 DisplaySafeAreaPadding; + float MouseCursorScale; + bool AntiAliasedLines; + bool AntiAliasedLinesUseTex; + bool AntiAliasedFill; + float CurveTessellationTol; + float CircleTessellationMaxError; + ImVec4 Colors[ImGuiCol_COUNT]; +}; +struct ImGuiIO +{ + ImGuiConfigFlags ConfigFlags; + ImGuiBackendFlags BackendFlags; + ImVec2 DisplaySize; + float DeltaTime; + float IniSavingRate; + const char* IniFilename; + const char* LogFilename; + float MouseDoubleClickTime; + float MouseDoubleClickMaxDist; + float MouseDragThreshold; + int KeyMap[ImGuiKey_COUNT]; + float KeyRepeatDelay; + float KeyRepeatRate; + void* UserData; + ImFontAtlas*Fonts; + float FontGlobalScale; + bool FontAllowUserScaling; + ImFont* FontDefault; + ImVec2 DisplayFramebufferScale; + bool MouseDrawCursor; + bool ConfigMacOSXBehaviors; + bool ConfigInputTextCursorBlink; + bool ConfigDragClickToInputText; + bool ConfigWindowsResizeFromEdges; + bool ConfigWindowsMoveFromTitleBarOnly; + float ConfigMemoryCompactTimer; + const char* BackendPlatformName; + const char* BackendRendererName; + void* BackendPlatformUserData; + void* BackendRendererUserData; + void* BackendLanguageUserData; + const char* (*GetClipboardTextFn)(void* user_data); + void (*SetClipboardTextFn)(void* user_data, const char* text); + void* ClipboardUserData; + void (*ImeSetInputScreenPosFn)(int x, int y); + void* ImeWindowHandle; + ImVec2 MousePos; + bool MouseDown[5]; + float MouseWheel; + float MouseWheelH; + bool KeyCtrl; + bool KeyShift; + bool KeyAlt; + bool KeySuper; + bool KeysDown[512]; + float NavInputs[ImGuiNavInput_COUNT]; + bool WantCaptureMouse; + bool WantCaptureKeyboard; + bool WantTextInput; + bool WantSetMousePos; + bool WantSaveIniSettings; + bool NavActive; + bool NavVisible; + float Framerate; + int MetricsRenderVertices; + int MetricsRenderIndices; + int MetricsRenderWindows; + int MetricsActiveWindows; + int MetricsActiveAllocations; + ImVec2 MouseDelta; + ImGuiKeyModFlags KeyMods; + ImGuiKeyModFlags KeyModsPrev; + ImVec2 MousePosPrev; + ImVec2 MouseClickedPos[5]; + double MouseClickedTime[5]; + bool MouseClicked[5]; + bool MouseDoubleClicked[5]; + bool MouseReleased[5]; + bool MouseDownOwned[5]; + bool MouseDownWasDoubleClick[5]; + float MouseDownDuration[5]; + float MouseDownDurationPrev[5]; + ImVec2 MouseDragMaxDistanceAbs[5]; + float MouseDragMaxDistanceSqr[5]; + float KeysDownDuration[512]; + float KeysDownDurationPrev[512]; + float NavInputsDownDuration[ImGuiNavInput_COUNT]; + float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; + float PenPressure; + ImWchar16 InputQueueSurrogate; + ImVector_ImWchar InputQueueCharacters; +}; +struct ImGuiInputTextCallbackData +{ + ImGuiInputTextFlags EventFlag; + ImGuiInputTextFlags Flags; + void* UserData; + ImWchar EventChar; + ImGuiKey EventKey; + char* Buf; + int BufTextLen; + int BufSize; + bool BufDirty; + int CursorPos; + int SelectionStart; + int SelectionEnd; +}; +struct ImGuiSizeCallbackData +{ + void* UserData; + ImVec2 Pos; + ImVec2 CurrentSize; + ImVec2 DesiredSize; +}; +struct ImGuiPayload +{ + void* Data; + int DataSize; + ImGuiID SourceId; + ImGuiID SourceParentId; + int DataFrameCount; + char DataType[32 + 1]; + bool Preview; + bool Delivery; +}; +struct ImGuiTableColumnSortSpecs +{ + ImGuiID ColumnUserID; + ImS16 ColumnIndex; + ImS16 SortOrder; + ImGuiSortDirection SortDirection : 8; +}; +struct ImGuiTableSortSpecs +{ + const ImGuiTableColumnSortSpecs* Specs; + int SpecsCount; + bool SpecsDirty; +}; +struct ImGuiOnceUponAFrame +{ + int RefFrame; +}; +struct ImGuiTextRange +{ + const char* b; + const char* e; +}; +struct ImGuiTextFilter +{ + char InputBuf[256]; + ImVector_ImGuiTextRange Filters; + int CountGrep; +}; +struct ImGuiTextBuffer +{ + ImVector_char Buf; +}; +struct ImGuiStoragePair +{ + ImGuiID key; + union { int val_i; float val_f; void* val_p; }; +}; +struct ImGuiStorage +{ + ImVector_ImGuiStoragePair Data; +}; +typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar; +typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; +typedef struct ImVector_ImGuiTable {int Size;int Capacity;ImGuiTable* Data;} ImVector_ImGuiTable; +typedef struct ImPool_ImGuiTable {ImVector_ImGuiTable Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTable; +struct ImGuiListClipper +{ + int DisplayStart; + int DisplayEnd; + int ItemsCount; + int StepNo; + int ItemsFrozen; + float ItemsHeight; + float StartPosY; +}; +struct ImColor +{ + ImVec4 Value; +}; +struct ImDrawCmd +{ + ImVec4 ClipRect; + ImTextureID TextureId; + unsigned int VtxOffset; + unsigned int IdxOffset; + unsigned int ElemCount; + ImDrawCallback UserCallback; + void* UserCallbackData; +}; +struct ImDrawVert +{ + ImVec2 pos; + ImVec2 uv; + ImU32 col; +}; +struct ImDrawCmdHeader +{ + ImVec4 ClipRect; + ImTextureID TextureId; + unsigned int VtxOffset; +}; +struct ImDrawChannel +{ + ImVector_ImDrawCmd _CmdBuffer; + ImVector_ImDrawIdx _IdxBuffer; +}; +struct ImDrawListSplitter +{ + int _Current; + int _Count; + ImVector_ImDrawChannel _Channels; +}; +typedef enum { + ImDrawFlags_None = 0, + ImDrawFlags_Closed = 1 << 0, + ImDrawFlags_RoundCornersTopLeft = 1 << 4, + ImDrawFlags_RoundCornersTopRight = 1 << 5, + ImDrawFlags_RoundCornersBottomLeft = 1 << 6, + ImDrawFlags_RoundCornersBottomRight = 1 << 7, + ImDrawFlags_RoundCornersNone = 1 << 8, + ImDrawFlags_RoundCornersTop = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight, + ImDrawFlags_RoundCornersBottom = ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersBottomRight, + ImDrawFlags_RoundCornersLeft = ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersTopLeft, + ImDrawFlags_RoundCornersRight = ImDrawFlags_RoundCornersBottomRight | ImDrawFlags_RoundCornersTopRight, + ImDrawFlags_RoundCornersAll = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight | ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersBottomRight, + ImDrawFlags_RoundCornersDefault_ = ImDrawFlags_RoundCornersAll, + ImDrawFlags_RoundCornersMask_ = ImDrawFlags_RoundCornersAll | ImDrawFlags_RoundCornersNone +}ImDrawFlags_; +typedef enum { + ImDrawListFlags_None = 0, + ImDrawListFlags_AntiAliasedLines = 1 << 0, + ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, + ImDrawListFlags_AntiAliasedFill = 1 << 2, + ImDrawListFlags_AllowVtxOffset = 1 << 3 +}ImDrawListFlags_; +struct ImDrawList +{ + ImVector_ImDrawCmd CmdBuffer; + ImVector_ImDrawIdx IdxBuffer; + ImVector_ImDrawVert VtxBuffer; + ImDrawListFlags Flags; + unsigned int _VtxCurrentIdx; + const ImDrawListSharedData* _Data; + const char* _OwnerName; + ImDrawVert* _VtxWritePtr; + ImDrawIdx* _IdxWritePtr; + ImVector_ImVec4 _ClipRectStack; + ImVector_ImTextureID _TextureIdStack; + ImVector_ImVec2 _Path; + ImDrawCmdHeader _CmdHeader; + ImDrawListSplitter _Splitter; + float _FringeScale; +}; +struct ImDrawData +{ + bool Valid; + int CmdListsCount; + int TotalIdxCount; + int TotalVtxCount; + ImDrawList** CmdLists; + ImVec2 DisplayPos; + ImVec2 DisplaySize; + ImVec2 FramebufferScale; +}; +struct ImFontConfig +{ + void* FontData; + int FontDataSize; + bool FontDataOwnedByAtlas; + int FontNo; + float SizePixels; + int OversampleH; + int OversampleV; + bool PixelSnapH; + ImVec2 GlyphExtraSpacing; + ImVec2 GlyphOffset; + const ImWchar* GlyphRanges; + float GlyphMinAdvanceX; + float GlyphMaxAdvanceX; + bool MergeMode; + unsigned int FontBuilderFlags; + float RasterizerMultiply; + ImWchar EllipsisChar; + char Name[40]; + ImFont* DstFont; +}; +struct ImFontGlyph +{ + unsigned int Colored : 1; + unsigned int Visible : 1; + unsigned int Codepoint : 30; + float AdvanceX; + float X0, Y0, X1, Y1; + float U0, V0, U1, V1; +}; +struct ImFontGlyphRangesBuilder +{ + ImVector_ImU32 UsedChars; +}; +struct ImFontAtlasCustomRect +{ + unsigned short Width, Height; + unsigned short X, Y; + unsigned int GlyphID; + float GlyphAdvanceX; + ImVec2 GlyphOffset; + ImFont* Font; +}; +typedef enum { + ImFontAtlasFlags_None = 0, + ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, + ImFontAtlasFlags_NoMouseCursors = 1 << 1, + ImFontAtlasFlags_NoBakedLines = 1 << 2 +}ImFontAtlasFlags_; +struct ImFontAtlas +{ + ImFontAtlasFlags Flags; + ImTextureID TexID; + int TexDesiredWidth; + int TexGlyphPadding; + bool Locked; + bool TexReady; + bool TexPixelsUseColors; + unsigned char* TexPixelsAlpha8; + unsigned int* TexPixelsRGBA32; + int TexWidth; + int TexHeight; + ImVec2 TexUvScale; + ImVec2 TexUvWhitePixel; + ImVector_ImFontPtr Fonts; + ImVector_ImFontAtlasCustomRect CustomRects; + ImVector_ImFontConfig ConfigData; + ImVec4 TexUvLines[(63) + 1]; + const ImFontBuilderIO* FontBuilderIO; + unsigned int FontBuilderFlags; + int PackIdMouseCursors; + int PackIdLines; +}; +struct ImFont +{ + ImVector_float IndexAdvanceX; + float FallbackAdvanceX; + float FontSize; + ImVector_ImWchar IndexLookup; + ImVector_ImFontGlyph Glyphs; + const ImFontGlyph* FallbackGlyph; + ImFontAtlas* ContainerAtlas; + const ImFontConfig* ConfigData; + short ConfigDataCount; + ImWchar FallbackChar; + ImWchar EllipsisChar; + ImWchar DotChar; + bool DirtyLookupTables; + float Scale; + float Ascent, Descent; + int MetricsTotalSurface; + ImU8 Used4kPagesMap[(0xFFFF +1)/4096/8]; +}; +typedef enum { + ImGuiViewportFlags_None = 0, + ImGuiViewportFlags_IsPlatformWindow = 1 << 0, + ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, + ImGuiViewportFlags_OwnedByApp = 1 << 2 +}ImGuiViewportFlags_; +struct ImGuiViewport +{ + ImGuiViewportFlags Flags; + ImVec2 Pos; + ImVec2 Size; + ImVec2 WorkPos; + ImVec2 WorkSize; +}; +struct StbUndoRecord +{ + int where; + int insert_length; + int delete_length; + int char_storage; +}; +struct StbUndoState +{ + StbUndoRecord undo_rec [99]; + ImWchar undo_char[999]; + short undo_point, redo_point; + int undo_char_point, redo_char_point; +}; +struct STB_TexteditState +{ + int cursor; + int select_start; + int select_end; + unsigned char insert_mode; + int row_count_per_page; + unsigned char cursor_at_end_of_line; + unsigned char initialized; + unsigned char has_preferred_x; + unsigned char single_line; + unsigned char padding1, padding2, padding3; + float preferred_x; + StbUndoState undostate; +}; +struct StbTexteditRow +{ + float x0,x1; + float baseline_y_delta; + float ymin,ymax; + int num_chars; +}; +struct ImVec1 +{ + float x; +}; +struct ImVec2ih +{ + short x, y; +}; +struct ImRect +{ + ImVec2 Min; + ImVec2 Max; +}; +struct ImBitVector +{ + ImVector_ImU32 Storage; +}; +struct ImDrawListSharedData +{ + ImVec2 TexUvWhitePixel; + ImFont* Font; + float FontSize; + float CurveTessellationTol; + float CircleSegmentMaxError; + ImVec4 ClipRectFullscreen; + ImDrawListFlags InitialFlags; + ImVec2 ArcFastVtx[48]; + float ArcFastRadiusCutoff; + ImU8 CircleSegmentCounts[64]; + const ImVec4* TexUvLines; +}; +struct ImDrawDataBuilder +{ + ImVector_ImDrawListPtr Layers[2]; +}; +typedef enum { + ImGuiItemFlags_None = 0, + ImGuiItemFlags_NoTabStop = 1 << 0, + ImGuiItemFlags_ButtonRepeat = 1 << 1, + ImGuiItemFlags_Disabled = 1 << 2, + ImGuiItemFlags_NoNav = 1 << 3, + ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, + ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, + ImGuiItemFlags_MixedValue = 1 << 6, + ImGuiItemFlags_ReadOnly = 1 << 7 +}ImGuiItemFlags_; +typedef enum { + ImGuiItemAddFlags_None = 0, + ImGuiItemAddFlags_Focusable = 1 << 0 +}ImGuiItemAddFlags_; +typedef enum { + ImGuiItemStatusFlags_None = 0, + ImGuiItemStatusFlags_HoveredRect = 1 << 0, + ImGuiItemStatusFlags_HasDisplayRect = 1 << 1, + ImGuiItemStatusFlags_Edited = 1 << 2, + ImGuiItemStatusFlags_ToggledSelection = 1 << 3, + ImGuiItemStatusFlags_ToggledOpen = 1 << 4, + ImGuiItemStatusFlags_HasDeactivated = 1 << 5, + ImGuiItemStatusFlags_Deactivated = 1 << 6, + ImGuiItemStatusFlags_HoveredWindow = 1 << 7, + ImGuiItemStatusFlags_FocusedByCode = 1 << 8, + ImGuiItemStatusFlags_FocusedByTabbing = 1 << 9, + ImGuiItemStatusFlags_Focused = ImGuiItemStatusFlags_FocusedByCode | ImGuiItemStatusFlags_FocusedByTabbing +}ImGuiItemStatusFlags_; +typedef enum { + ImGuiInputTextFlags_Multiline = 1 << 26, + ImGuiInputTextFlags_NoMarkEdited = 1 << 27, + ImGuiInputTextFlags_MergedItem = 1 << 28 +}ImGuiInputTextFlagsPrivate_; +typedef enum { + ImGuiButtonFlags_PressedOnClick = 1 << 4, + ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, + ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, + ImGuiButtonFlags_PressedOnRelease = 1 << 7, + ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, + ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, + ImGuiButtonFlags_Repeat = 1 << 10, + ImGuiButtonFlags_FlattenChildren = 1 << 11, + ImGuiButtonFlags_AllowItemOverlap = 1 << 12, + ImGuiButtonFlags_DontClosePopups = 1 << 13, + ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, + ImGuiButtonFlags_NoKeyModifiers = 1 << 16, + ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, + ImGuiButtonFlags_NoNavFocus = 1 << 18, + ImGuiButtonFlags_NoHoveredOnFocus = 1 << 19, + ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold, + ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease +}ImGuiButtonFlagsPrivate_; +typedef enum { + ImGuiComboFlags_CustomPreview = 1 << 20 +}ImGuiComboFlagsPrivate_; +typedef enum { + ImGuiSliderFlags_Vertical = 1 << 20, + ImGuiSliderFlags_ReadOnly = 1 << 21 +}ImGuiSliderFlagsPrivate_; +typedef enum { + ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20, + ImGuiSelectableFlags_SelectOnNav = 1 << 21, + ImGuiSelectableFlags_SelectOnClick = 1 << 22, + ImGuiSelectableFlags_SelectOnRelease = 1 << 23, + ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, + ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 25, + ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26, + ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 27 +}ImGuiSelectableFlagsPrivate_; +typedef enum { + ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20 +}ImGuiTreeNodeFlagsPrivate_; +typedef enum { + ImGuiSeparatorFlags_None = 0, + ImGuiSeparatorFlags_Horizontal = 1 << 0, + ImGuiSeparatorFlags_Vertical = 1 << 1, + ImGuiSeparatorFlags_SpanAllColumns = 1 << 2 +}ImGuiSeparatorFlags_; +typedef enum { + ImGuiTextFlags_None = 0, + ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0 +}ImGuiTextFlags_; +typedef enum { + ImGuiTooltipFlags_None = 0, + ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0 +}ImGuiTooltipFlags_; +typedef enum { + ImGuiLayoutType_Horizontal = 0, + ImGuiLayoutType_Vertical = 1 +}ImGuiLayoutType_; +typedef enum { + ImGuiLogType_None = 0, + ImGuiLogType_TTY, + ImGuiLogType_File, + ImGuiLogType_Buffer, + ImGuiLogType_Clipboard +}ImGuiLogType; +typedef enum { + ImGuiAxis_None = -1, + ImGuiAxis_X = 0, + ImGuiAxis_Y = 1 +}ImGuiAxis; +typedef enum { + ImGuiPlotType_Lines, + ImGuiPlotType_Histogram +}ImGuiPlotType; +typedef enum { + ImGuiInputSource_None = 0, + ImGuiInputSource_Mouse, + ImGuiInputSource_Keyboard, + ImGuiInputSource_Gamepad, + ImGuiInputSource_Nav, + ImGuiInputSource_Clipboard, + ImGuiInputSource_COUNT +}ImGuiInputSource; +typedef enum { + ImGuiInputReadMode_Down, + ImGuiInputReadMode_Pressed, + ImGuiInputReadMode_Released, + ImGuiInputReadMode_Repeat, + ImGuiInputReadMode_RepeatSlow, + ImGuiInputReadMode_RepeatFast +}ImGuiInputReadMode; +typedef enum { + ImGuiNavHighlightFlags_None = 0, + ImGuiNavHighlightFlags_TypeDefault = 1 << 0, + ImGuiNavHighlightFlags_TypeThin = 1 << 1, + ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, + ImGuiNavHighlightFlags_NoRounding = 1 << 3 +}ImGuiNavHighlightFlags_; +typedef enum { + ImGuiNavDirSourceFlags_None = 0, + ImGuiNavDirSourceFlags_Keyboard = 1 << 0, + ImGuiNavDirSourceFlags_PadDPad = 1 << 1, + ImGuiNavDirSourceFlags_PadLStick = 1 << 2 +}ImGuiNavDirSourceFlags_; +typedef enum { + ImGuiNavMoveFlags_None = 0, + ImGuiNavMoveFlags_LoopX = 1 << 0, + ImGuiNavMoveFlags_LoopY = 1 << 1, + ImGuiNavMoveFlags_WrapX = 1 << 2, + ImGuiNavMoveFlags_WrapY = 1 << 3, + ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, + ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, + ImGuiNavMoveFlags_ScrollToEdge = 1 << 6 +}ImGuiNavMoveFlags_; +typedef enum { + ImGuiNavForward_None, + ImGuiNavForward_ForwardQueued, + ImGuiNavForward_ForwardActive +}ImGuiNavForward; +typedef enum { + ImGuiNavLayer_Main = 0, + ImGuiNavLayer_Menu = 1, + ImGuiNavLayer_COUNT +}ImGuiNavLayer; +typedef enum { + ImGuiPopupPositionPolicy_Default, + ImGuiPopupPositionPolicy_ComboBox, + ImGuiPopupPositionPolicy_Tooltip +}ImGuiPopupPositionPolicy; +struct ImGuiDataTypeTempStorage +{ + ImU8 Data[8]; +}; +struct ImGuiDataTypeInfo +{ + size_t Size; + const char* Name; + const char* PrintFmt; + const char* ScanFmt; +}; +typedef enum { + ImGuiDataType_String = ImGuiDataType_COUNT + 1, + ImGuiDataType_Pointer, + ImGuiDataType_ID +}ImGuiDataTypePrivate_; +struct ImGuiColorMod +{ + ImGuiCol Col; + ImVec4 BackupValue; +}; +struct ImGuiStyleMod +{ + ImGuiStyleVar VarIdx; + union { int BackupInt[2]; float BackupFloat[2]; }; +}; +struct ImGuiComboPreviewData +{ + ImRect PreviewRect; + ImVec2 BackupCursorPos; + ImVec2 BackupCursorMaxPos; + ImVec2 BackupCursorPosPrevLine; + float BackupPrevLineTextBaseOffset; + ImGuiLayoutType BackupLayout; +}; +struct ImGuiGroupData +{ + ImGuiID WindowID; + ImVec2 BackupCursorPos; + ImVec2 BackupCursorMaxPos; + ImVec1 BackupIndent; + ImVec1 BackupGroupOffset; + ImVec2 BackupCurrLineSize; + float BackupCurrLineTextBaseOffset; + ImGuiID BackupActiveIdIsAlive; + bool BackupActiveIdPreviousFrameIsAlive; + bool BackupHoveredIdIsAlive; + bool EmitItem; +}; +struct ImGuiMenuColumns +{ + ImU32 TotalWidth; + ImU32 NextTotalWidth; + ImU16 Spacing; + ImU16 OffsetIcon; + ImU16 OffsetLabel; + ImU16 OffsetShortcut; + ImU16 OffsetMark; + ImU16 Widths[4]; +}; +struct ImGuiInputTextState +{ + ImGuiID ID; + int CurLenW, CurLenA; + ImVector_ImWchar TextW; + ImVector_char TextA; + ImVector_char InitialTextA; + bool TextAIsValid; + int BufCapacityA; + float ScrollX; + STB_TexteditState Stb; + float CursorAnim; + bool CursorFollow; + bool SelectedAllMouseLock; + bool Edited; + ImGuiInputTextFlags Flags; + ImGuiInputTextCallback UserCallback; + void* UserCallbackData; +}; +struct ImGuiPopupData +{ + ImGuiID PopupId; + ImGuiWindow* Window; + ImGuiWindow* SourceWindow; + int OpenFrameCount; + ImGuiID OpenParentId; + ImVec2 OpenPopupPos; + ImVec2 OpenMousePos; +}; +struct ImGuiNavItemData +{ + ImGuiWindow* Window; + ImGuiID ID; + ImGuiID FocusScopeId; + ImRect RectRel; + float DistBox; + float DistCenter; + float DistAxial; +}; +typedef enum { + ImGuiNextWindowDataFlags_None = 0, + ImGuiNextWindowDataFlags_HasPos = 1 << 0, + ImGuiNextWindowDataFlags_HasSize = 1 << 1, + ImGuiNextWindowDataFlags_HasContentSize = 1 << 2, + ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3, + ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4, + ImGuiNextWindowDataFlags_HasFocus = 1 << 5, + ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6, + ImGuiNextWindowDataFlags_HasScroll = 1 << 7 +}ImGuiNextWindowDataFlags_; +struct ImGuiNextWindowData +{ + ImGuiNextWindowDataFlags Flags; + ImGuiCond PosCond; + ImGuiCond SizeCond; + ImGuiCond CollapsedCond; + ImVec2 PosVal; + ImVec2 PosPivotVal; + ImVec2 SizeVal; + ImVec2 ContentSizeVal; + ImVec2 ScrollVal; + bool CollapsedVal; + ImRect SizeConstraintRect; + ImGuiSizeCallback SizeCallback; + void* SizeCallbackUserData; + float BgAlphaVal; + ImVec2 MenuBarOffsetMinVal; +}; +typedef enum { + ImGuiNextItemDataFlags_None = 0, + ImGuiNextItemDataFlags_HasWidth = 1 << 0, + ImGuiNextItemDataFlags_HasOpen = 1 << 1 +}ImGuiNextItemDataFlags_; +struct ImGuiNextItemData +{ + ImGuiNextItemDataFlags Flags; + float Width; + ImGuiID FocusScopeId; + ImGuiCond OpenCond; + bool OpenVal; +}; +struct ImGuiLastItemData +{ + ImGuiID ID; + ImGuiItemFlags InFlags; + ImGuiItemStatusFlags StatusFlags; + ImRect Rect; + ImRect DisplayRect; +}; +struct ImGuiWindowStackData +{ + ImGuiWindow* Window; + ImGuiLastItemData ParentLastItemDataBackup; +}; +struct ImGuiShrinkWidthItem +{ + int Index; + float Width; +}; +struct ImGuiPtrOrIndex +{ + void* Ptr; + int Index; +}; +typedef enum { + ImGuiOldColumnFlags_None = 0, + ImGuiOldColumnFlags_NoBorder = 1 << 0, + ImGuiOldColumnFlags_NoResize = 1 << 1, + ImGuiOldColumnFlags_NoPreserveWidths = 1 << 2, + ImGuiOldColumnFlags_NoForceWithinWindow = 1 << 3, + ImGuiOldColumnFlags_GrowParentContentsSize = 1 << 4 +}ImGuiOldColumnFlags_; +struct ImGuiOldColumnData +{ + float OffsetNorm; + float OffsetNormBeforeResize; + ImGuiOldColumnFlags Flags; + ImRect ClipRect; +}; +struct ImGuiOldColumns +{ + ImGuiID ID; + ImGuiOldColumnFlags Flags; + bool IsFirstFrame; + bool IsBeingResized; + int Current; + int Count; + float OffMinX, OffMaxX; + float LineMinY, LineMaxY; + float HostCursorPosY; + float HostCursorMaxPosX; + ImRect HostInitialClipRect; + ImRect HostBackupClipRect; + ImRect HostBackupParentWorkRect; + ImVector_ImGuiOldColumnData Columns; + ImDrawListSplitter Splitter; +}; +struct ImGuiViewportP +{ + ImGuiViewport _ImGuiViewport; + int DrawListsLastFrame[2]; + ImDrawList* DrawLists[2]; + ImDrawData DrawDataP; + ImDrawDataBuilder DrawDataBuilder; + ImVec2 WorkOffsetMin; + ImVec2 WorkOffsetMax; + ImVec2 BuildWorkOffsetMin; + ImVec2 BuildWorkOffsetMax; +}; +struct ImGuiWindowSettings +{ + ImGuiID ID; + ImVec2ih Pos; + ImVec2ih Size; + bool Collapsed; + bool WantApply; +}; +struct ImGuiSettingsHandler +{ + const char* TypeName; + ImGuiID TypeHash; + void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); + void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); + void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); + void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); + void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); + void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); + void* UserData; +}; +struct ImGuiMetricsConfig +{ + bool ShowWindowsRects; + bool ShowWindowsBeginOrder; + bool ShowTablesRects; + bool ShowDrawCmdMesh; + bool ShowDrawCmdBoundingBoxes; + int ShowWindowsRectsType; + int ShowTablesRectsType; +}; +struct ImGuiStackSizes +{ + short SizeOfIDStack; + short SizeOfColorStack; + short SizeOfStyleVarStack; + short SizeOfFontStack; + short SizeOfFocusScopeStack; + short SizeOfGroupStack; + short SizeOfBeginPopupStack; +}; +typedef enum { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_ }ImGuiContextHookType; +struct ImGuiContextHook +{ + ImGuiID HookId; + ImGuiContextHookType Type; + ImGuiID Owner; + ImGuiContextHookCallback Callback; + void* UserData; +}; +struct ImGuiContext +{ + bool Initialized; + bool FontAtlasOwnedByContext; + ImGuiIO IO; + ImGuiStyle Style; + ImFont* Font; + float FontSize; + float FontBaseSize; + ImDrawListSharedData DrawListSharedData; + double Time; + int FrameCount; + int FrameCountEnded; + int FrameCountRendered; + bool WithinFrameScope; + bool WithinFrameScopeWithImplicitWindow; + bool WithinEndChild; + bool GcCompactAll; + bool TestEngineHookItems; + ImGuiID TestEngineHookIdInfo; + void* TestEngine; + ImVector_ImGuiWindowPtr Windows; + ImVector_ImGuiWindowPtr WindowsFocusOrder; + ImVector_ImGuiWindowPtr WindowsTempSortBuffer; + ImVector_ImGuiWindowStackData CurrentWindowStack; + ImGuiStorage WindowsById; + int WindowsActiveCount; + ImVec2 WindowsHoverPadding; + ImGuiWindow* CurrentWindow; + ImGuiWindow* HoveredWindow; + ImGuiWindow* HoveredWindowUnderMovingWindow; + ImGuiWindow* MovingWindow; + ImGuiWindow* WheelingWindow; + ImVec2 WheelingWindowRefMousePos; + float WheelingWindowTimer; + ImGuiID HoveredId; + ImGuiID HoveredIdPreviousFrame; + bool HoveredIdAllowOverlap; + bool HoveredIdUsingMouseWheel; + bool HoveredIdPreviousFrameUsingMouseWheel; + bool HoveredIdDisabled; + float HoveredIdTimer; + float HoveredIdNotActiveTimer; + ImGuiID ActiveId; + ImGuiID ActiveIdIsAlive; + float ActiveIdTimer; + bool ActiveIdIsJustActivated; + bool ActiveIdAllowOverlap; + bool ActiveIdNoClearOnFocusLoss; + bool ActiveIdHasBeenPressedBefore; + bool ActiveIdHasBeenEditedBefore; + bool ActiveIdHasBeenEditedThisFrame; + bool ActiveIdUsingMouseWheel; + ImU32 ActiveIdUsingNavDirMask; + ImU32 ActiveIdUsingNavInputMask; + ImU64 ActiveIdUsingKeyInputMask; + ImVec2 ActiveIdClickOffset; + ImGuiWindow* ActiveIdWindow; + ImGuiInputSource ActiveIdSource; + int ActiveIdMouseButton; + ImGuiID ActiveIdPreviousFrame; + bool ActiveIdPreviousFrameIsAlive; + bool ActiveIdPreviousFrameHasBeenEditedBefore; + ImGuiWindow* ActiveIdPreviousFrameWindow; + ImGuiID LastActiveId; + float LastActiveIdTimer; + ImGuiItemFlags CurrentItemFlags; + ImGuiNextItemData NextItemData; + ImGuiLastItemData LastItemData; + ImGuiNextWindowData NextWindowData; + ImVector_ImGuiColorMod ColorStack; + ImVector_ImGuiStyleMod StyleVarStack; + ImVector_ImFontPtr FontStack; + ImVector_ImGuiID FocusScopeStack; + ImVector_ImGuiItemFlags ItemFlagsStack; + ImVector_ImGuiGroupData GroupStack; + ImVector_ImGuiPopupData OpenPopupStack; + ImVector_ImGuiPopupData BeginPopupStack; + ImVector_ImGuiViewportPPtr Viewports; + ImGuiWindow* NavWindow; + ImGuiID NavId; + ImGuiID NavFocusScopeId; + ImGuiID NavActivateId; + ImGuiID NavActivateDownId; + ImGuiID NavActivatePressedId; + ImGuiID NavInputId; + ImGuiID NavJustTabbedId; + ImGuiID NavJustMovedToId; + ImGuiID NavJustMovedToFocusScopeId; + ImGuiKeyModFlags NavJustMovedToKeyMods; + ImGuiID NavNextActivateId; + ImGuiInputSource NavInputSource; + ImRect NavScoringRect; + int NavScoringCount; + ImGuiNavLayer NavLayer; + int NavIdTabCounter; + bool NavIdIsAlive; + bool NavMousePosDirty; + bool NavDisableHighlight; + bool NavDisableMouseHover; + bool NavAnyRequest; + bool NavInitRequest; + bool NavInitRequestFromMove; + ImGuiID NavInitResultId; + ImRect NavInitResultRectRel; + bool NavMoveRequest; + ImGuiNavMoveFlags NavMoveRequestFlags; + ImGuiNavForward NavMoveRequestForward; + ImGuiKeyModFlags NavMoveRequestKeyMods; + ImGuiDir NavMoveDir, NavMoveDirLast; + ImGuiDir NavMoveClipDir; + ImGuiNavItemData NavMoveResultLocal; + ImGuiNavItemData NavMoveResultLocalVisibleSet; + ImGuiNavItemData NavMoveResultOther; + ImGuiWindow* NavWrapRequestWindow; + ImGuiNavMoveFlags NavWrapRequestFlags; + ImGuiWindow* NavWindowingTarget; + ImGuiWindow* NavWindowingTargetAnim; + ImGuiWindow* NavWindowingListWindow; + float NavWindowingTimer; + float NavWindowingHighlightAlpha; + bool NavWindowingToggleLayer; + ImGuiWindow* TabFocusRequestCurrWindow; + ImGuiWindow* TabFocusRequestNextWindow; + int TabFocusRequestCurrCounterRegular; + int TabFocusRequestCurrCounterTabStop; + int TabFocusRequestNextCounterRegular; + int TabFocusRequestNextCounterTabStop; + bool TabFocusPressed; + float DimBgRatio; + ImGuiMouseCursor MouseCursor; + bool DragDropActive; + bool DragDropWithinSource; + bool DragDropWithinTarget; + ImGuiDragDropFlags DragDropSourceFlags; + int DragDropSourceFrameCount; + int DragDropMouseButton; + ImGuiPayload DragDropPayload; + ImRect DragDropTargetRect; + ImGuiID DragDropTargetId; + ImGuiDragDropFlags DragDropAcceptFlags; + float DragDropAcceptIdCurrRectSurface; + ImGuiID DragDropAcceptIdCurr; + ImGuiID DragDropAcceptIdPrev; + int DragDropAcceptFrameCount; + ImGuiID DragDropHoldJustPressedId; + ImVector_unsigned_char DragDropPayloadBufHeap; + unsigned char DragDropPayloadBufLocal[16]; + ImGuiTable* CurrentTable; + int CurrentTableStackIdx; + ImPool_ImGuiTable Tables; + ImVector_ImGuiTableTempData TablesTempDataStack; + ImVector_float TablesLastTimeActive; + ImVector_ImDrawChannel DrawChannelsTempMergeBuffer; + ImGuiTabBar* CurrentTabBar; + ImPool_ImGuiTabBar TabBars; + ImVector_ImGuiPtrOrIndex CurrentTabBarStack; + ImVector_ImGuiShrinkWidthItem ShrinkWidthBuffer; + ImVec2 LastValidMousePos; + ImGuiInputTextState InputTextState; + ImFont InputTextPasswordFont; + ImGuiID TempInputId; + ImGuiColorEditFlags ColorEditOptions; + float ColorEditLastHue; + float ColorEditLastSat; + float ColorEditLastColor[3]; + ImVec4 ColorPickerRef; + ImGuiComboPreviewData ComboPreviewData; + float SliderCurrentAccum; + bool SliderCurrentAccumDirty; + bool DragCurrentAccumDirty; + float DragCurrentAccum; + float DragSpeedDefaultRatio; + float DisabledAlphaBackup; + float ScrollbarClickDeltaToGrabCenter; + int TooltipOverrideCount; + float TooltipSlowDelay; + ImVector_char ClipboardHandlerData; + ImVector_ImGuiID MenusIdSubmittedThisFrame; + ImVec2 PlatformImePos; + ImVec2 PlatformImeLastPos; + char PlatformLocaleDecimalPoint; + bool SettingsLoaded; + float SettingsDirtyTimer; + ImGuiTextBuffer SettingsIniData; + ImVector_ImGuiSettingsHandler SettingsHandlers; + ImChunkStream_ImGuiWindowSettings SettingsWindows; + ImChunkStream_ImGuiTableSettings SettingsTables; + ImVector_ImGuiContextHook Hooks; + ImGuiID HookIdNext; + bool LogEnabled; + ImGuiLogType LogType; + ImFileHandle LogFile; + ImGuiTextBuffer LogBuffer; + const char* LogNextPrefix; + const char* LogNextSuffix; + float LogLinePosY; + bool LogLineFirstItem; + int LogDepthRef; + int LogDepthToExpand; + int LogDepthToExpandDefault; + bool DebugItemPickerActive; + ImGuiID DebugItemPickerBreakId; + ImGuiMetricsConfig DebugMetricsConfig; + float FramerateSecPerFrame[120]; + int FramerateSecPerFrameIdx; + int FramerateSecPerFrameCount; + float FramerateSecPerFrameAccum; + int WantCaptureMouseNextFrame; + int WantCaptureKeyboardNextFrame; + int WantTextInputNextFrame; + char TempBuffer[1024 * 3 + 1]; +}; +struct ImGuiWindowTempData +{ + ImVec2 CursorPos; + ImVec2 CursorPosPrevLine; + ImVec2 CursorStartPos; + ImVec2 CursorMaxPos; + ImVec2 IdealMaxPos; + ImVec2 CurrLineSize; + ImVec2 PrevLineSize; + float CurrLineTextBaseOffset; + float PrevLineTextBaseOffset; + ImVec1 Indent; + ImVec1 ColumnsOffset; + ImVec1 GroupOffset; + ImGuiNavLayer NavLayerCurrent; + short NavLayersActiveMask; + short NavLayersActiveMaskNext; + ImGuiID NavFocusScopeIdCurrent; + bool NavHideHighlightOneFrame; + bool NavHasScroll; + bool MenuBarAppending; + ImVec2 MenuBarOffset; + ImGuiMenuColumns MenuColumns; + int TreeDepth; + ImU32 TreeJumpToParentOnPopMask; + ImVector_ImGuiWindowPtr ChildWindows; + ImGuiStorage* StateStorage; + ImGuiOldColumns* CurrentColumns; + int CurrentTableIdx; + ImGuiLayoutType LayoutType; + ImGuiLayoutType ParentLayoutType; + int FocusCounterRegular; + int FocusCounterTabStop; + float ItemWidth; + float TextWrapPos; + ImVector_float ItemWidthStack; + ImVector_float TextWrapPosStack; + ImGuiStackSizes StackSizesOnBegin; +}; +struct ImGuiWindow +{ + char* Name; + ImGuiID ID; + ImGuiWindowFlags Flags; + ImVec2 Pos; + ImVec2 Size; + ImVec2 SizeFull; + ImVec2 ContentSize; + ImVec2 ContentSizeIdeal; + ImVec2 ContentSizeExplicit; + ImVec2 WindowPadding; + float WindowRounding; + float WindowBorderSize; + int NameBufLen; + ImGuiID MoveId; + ImGuiID ChildId; + ImVec2 Scroll; + ImVec2 ScrollMax; + ImVec2 ScrollTarget; + ImVec2 ScrollTargetCenterRatio; + ImVec2 ScrollTargetEdgeSnapDist; + ImVec2 ScrollbarSizes; + bool ScrollbarX, ScrollbarY; + bool Active; + bool WasActive; + bool WriteAccessed; + bool Collapsed; + bool WantCollapseToggle; + bool SkipItems; + bool Appearing; + bool Hidden; + bool IsFallbackWindow; + bool HasCloseButton; + signed char ResizeBorderHeld; + short BeginCount; + short BeginOrderWithinParent; + short BeginOrderWithinContext; + short FocusOrder; + ImGuiID PopupId; + ImS8 AutoFitFramesX, AutoFitFramesY; + ImS8 AutoFitChildAxises; + bool AutoFitOnlyGrows; + ImGuiDir AutoPosLastDirection; + ImS8 HiddenFramesCanSkipItems; + ImS8 HiddenFramesCannotSkipItems; + ImS8 HiddenFramesForRenderOnly; + ImS8 DisableInputsFrames; + ImGuiCond SetWindowPosAllowFlags : 8; + ImGuiCond SetWindowSizeAllowFlags : 8; + ImGuiCond SetWindowCollapsedAllowFlags : 8; + ImVec2 SetWindowPosVal; + ImVec2 SetWindowPosPivot; + ImVector_ImGuiID IDStack; + ImGuiWindowTempData DC; + ImRect OuterRectClipped; + ImRect InnerRect; + ImRect InnerClipRect; + ImRect WorkRect; + ImRect ParentWorkRect; + ImRect ClipRect; + ImRect ContentRegionRect; + ImVec2ih HitTestHoleSize; + ImVec2ih HitTestHoleOffset; + int LastFrameActive; + float LastTimeActive; + float ItemWidthDefault; + ImGuiStorage StateStorage; + ImVector_ImGuiOldColumns ColumnsStorage; + float FontWindowScale; + int SettingsOffset; + ImDrawList* DrawList; + ImDrawList DrawListInst; + ImGuiWindow* ParentWindow; + ImGuiWindow* RootWindow; + ImGuiWindow* RootWindowForTitleBarHighlight; + ImGuiWindow* RootWindowForNav; + ImGuiWindow* NavLastChildNavWindow; + ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; + ImRect NavRectRel[ImGuiNavLayer_COUNT]; + int MemoryDrawListIdxCapacity; + int MemoryDrawListVtxCapacity; + bool MemoryCompacted; +}; +typedef enum { + ImGuiTabBarFlags_DockNode = 1 << 20, + ImGuiTabBarFlags_IsFocused = 1 << 21, + ImGuiTabBarFlags_SaveSettings = 1 << 22 +}ImGuiTabBarFlagsPrivate_; +typedef enum { + ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing, + ImGuiTabItemFlags_NoCloseButton = 1 << 20, + ImGuiTabItemFlags_Button = 1 << 21 +}ImGuiTabItemFlagsPrivate_; +struct ImGuiTabItem +{ + ImGuiID ID; + ImGuiTabItemFlags Flags; + int LastFrameVisible; + int LastFrameSelected; + float Offset; + float Width; + float ContentWidth; + ImS32 NameOffset; + ImS16 BeginOrder; + ImS16 IndexDuringLayout; + bool WantClose; +}; +struct ImGuiTabBar +{ + ImVector_ImGuiTabItem Tabs; + ImGuiTabBarFlags Flags; + ImGuiID ID; + ImGuiID SelectedTabId; + ImGuiID NextSelectedTabId; + ImGuiID VisibleTabId; + int CurrFrameVisible; + int PrevFrameVisible; + ImRect BarRect; + float CurrTabsContentsHeight; + float PrevTabsContentsHeight; + float WidthAllTabs; + float WidthAllTabsIdeal; + float ScrollingAnim; + float ScrollingTarget; + float ScrollingTargetDistToVisibility; + float ScrollingSpeed; + float ScrollingRectMinX; + float ScrollingRectMaxX; + ImGuiID ReorderRequestTabId; + ImS16 ReorderRequestOffset; + ImS8 BeginCount; + bool WantLayout; + bool VisibleTabWasSubmitted; + bool TabsAddedNew; + ImS16 TabsActiveCount; + ImS16 LastTabItemIdx; + float ItemSpacingY; + ImVec2 FramePadding; + ImVec2 BackupCursorPos; + ImGuiTextBuffer TabsNames; +}; +struct ImGuiTableColumn +{ + ImGuiTableColumnFlags Flags; + float WidthGiven; + float MinX; + float MaxX; + float WidthRequest; + float WidthAuto; + float StretchWeight; + float InitStretchWeightOrWidth; + ImRect ClipRect; + ImGuiID UserID; + float WorkMinX; + float WorkMaxX; + float ItemWidth; + float ContentMaxXFrozen; + float ContentMaxXUnfrozen; + float ContentMaxXHeadersUsed; + float ContentMaxXHeadersIdeal; + ImS16 NameOffset; + ImGuiTableColumnIdx DisplayOrder; + ImGuiTableColumnIdx IndexWithinEnabledSet; + ImGuiTableColumnIdx PrevEnabledColumn; + ImGuiTableColumnIdx NextEnabledColumn; + ImGuiTableColumnIdx SortOrder; + ImGuiTableDrawChannelIdx DrawChannelCurrent; + ImGuiTableDrawChannelIdx DrawChannelFrozen; + ImGuiTableDrawChannelIdx DrawChannelUnfrozen; + bool IsEnabled; + bool IsUserEnabled; + bool IsUserEnabledNextFrame; + bool IsVisibleX; + bool IsVisibleY; + bool IsRequestOutput; + bool IsSkipItems; + bool IsPreserveWidthAuto; + ImS8 NavLayerCurrent; + ImU8 AutoFitQueue; + ImU8 CannotSkipItemsQueue; + ImU8 SortDirection : 2; + ImU8 SortDirectionsAvailCount : 2; + ImU8 SortDirectionsAvailMask : 4; + ImU8 SortDirectionsAvailList; +}; +struct ImGuiTableCellData +{ + ImU32 BgColor; + ImGuiTableColumnIdx Column; +}; +struct ImGuiTable +{ + ImGuiID ID; + ImGuiTableFlags Flags; + void* RawData; + ImGuiTableTempData* TempData; + ImSpan_ImGuiTableColumn Columns; + ImSpan_ImGuiTableColumnIdx DisplayOrderToIndex; + ImSpan_ImGuiTableCellData RowCellData; + ImU64 EnabledMaskByDisplayOrder; + ImU64 EnabledMaskByIndex; + ImU64 VisibleMaskByIndex; + ImU64 RequestOutputMaskByIndex; + ImGuiTableFlags SettingsLoadedFlags; + int SettingsOffset; + int LastFrameActive; + int ColumnsCount; + int CurrentRow; + int CurrentColumn; + ImS16 InstanceCurrent; + ImS16 InstanceInteracted; + float RowPosY1; + float RowPosY2; + float RowMinHeight; + float RowTextBaseline; + float RowIndentOffsetX; + ImGuiTableRowFlags RowFlags : 16; + ImGuiTableRowFlags LastRowFlags : 16; + int RowBgColorCounter; + ImU32 RowBgColor[2]; + ImU32 BorderColorStrong; + ImU32 BorderColorLight; + float BorderX1; + float BorderX2; + float HostIndentX; + float MinColumnWidth; + float OuterPaddingX; + float CellPaddingX; + float CellPaddingY; + float CellSpacingX1; + float CellSpacingX2; + float LastOuterHeight; + float LastFirstRowHeight; + float InnerWidth; + float ColumnsGivenWidth; + float ColumnsAutoFitWidth; + float ResizedColumnNextWidth; + float ResizeLockMinContentsX2; + float RefScale; + ImRect OuterRect; + ImRect InnerRect; + ImRect WorkRect; + ImRect InnerClipRect; + ImRect BgClipRect; + ImRect Bg0ClipRectForDrawCmd; + ImRect Bg2ClipRectForDrawCmd; + ImRect HostClipRect; + ImRect HostBackupInnerClipRect; + ImGuiWindow* OuterWindow; + ImGuiWindow* InnerWindow; + ImGuiTextBuffer ColumnsNames; + ImDrawListSplitter* DrawSplitter; + ImGuiTableColumnSortSpecs SortSpecsSingle; + ImVector_ImGuiTableColumnSortSpecs SortSpecsMulti; + ImGuiTableSortSpecs SortSpecs; + ImGuiTableColumnIdx SortSpecsCount; + ImGuiTableColumnIdx ColumnsEnabledCount; + ImGuiTableColumnIdx ColumnsEnabledFixedCount; + ImGuiTableColumnIdx DeclColumnsCount; + ImGuiTableColumnIdx HoveredColumnBody; + ImGuiTableColumnIdx HoveredColumnBorder; + ImGuiTableColumnIdx AutoFitSingleColumn; + ImGuiTableColumnIdx ResizedColumn; + ImGuiTableColumnIdx LastResizedColumn; + ImGuiTableColumnIdx HeldHeaderColumn; + ImGuiTableColumnIdx ReorderColumn; + ImGuiTableColumnIdx ReorderColumnDir; + ImGuiTableColumnIdx LeftMostEnabledColumn; + ImGuiTableColumnIdx RightMostEnabledColumn; + ImGuiTableColumnIdx LeftMostStretchedColumn; + ImGuiTableColumnIdx RightMostStretchedColumn; + ImGuiTableColumnIdx ContextPopupColumn; + ImGuiTableColumnIdx FreezeRowsRequest; + ImGuiTableColumnIdx FreezeRowsCount; + ImGuiTableColumnIdx FreezeColumnsRequest; + ImGuiTableColumnIdx FreezeColumnsCount; + ImGuiTableColumnIdx RowCellDataCurrent; + ImGuiTableDrawChannelIdx DummyDrawChannel; + ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; + ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen; + bool IsLayoutLocked; + bool IsInsideRow; + bool IsInitializing; + bool IsSortSpecsDirty; + bool IsUsingHeaders; + bool IsContextPopupOpen; + bool IsSettingsRequestLoad; + bool IsSettingsDirty; + bool IsDefaultDisplayOrder; + bool IsResetAllRequest; + bool IsResetDisplayOrderRequest; + bool IsUnfrozenRows; + bool IsDefaultSizingPolicy; + bool MemoryCompacted; + bool HostSkipItems; +}; +struct ImGuiTableTempData +{ + int TableIndex; + float LastTimeActive; + ImVec2 UserOuterSize; + ImDrawListSplitter DrawSplitter; + ImRect HostBackupWorkRect; + ImRect HostBackupParentWorkRect; + ImVec2 HostBackupPrevLineSize; + ImVec2 HostBackupCurrLineSize; + ImVec2 HostBackupCursorMaxPos; + ImVec1 HostBackupColumnsOffset; + float HostBackupItemWidth; + int HostBackupItemWidthStackSize; +}; +struct ImGuiTableColumnSettings +{ + float WidthOrWeight; + ImGuiID UserID; + ImGuiTableColumnIdx Index; + ImGuiTableColumnIdx DisplayOrder; + ImGuiTableColumnIdx SortOrder; + ImU8 SortDirection : 2; + ImU8 IsEnabled : 1; + ImU8 IsStretch : 1; +}; +struct ImGuiTableSettings +{ + ImGuiID ID; + ImGuiTableFlags SaveFlags; + float RefScale; + ImGuiTableColumnIdx ColumnsCount; + ImGuiTableColumnIdx ColumnsCountMax; + bool WantApply; +}; +struct ImFontBuilderIO +{ + bool (*FontBuilder_Build)(ImFontAtlas* atlas); +}; +#else +struct GLFWwindow; +struct SDL_Window; +typedef union SDL_Event SDL_Event; +#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS + +#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS +typedef struct ImGuiStorage::ImGuiStoragePair ImGuiStoragePair; +typedef struct ImGuiTextFilter::ImGuiTextRange ImGuiTextRange; +typedef ImStb::STB_TexteditState STB_TexteditState; +typedef ImStb::StbTexteditRow StbTexteditRow; +typedef ImStb::StbUndoRecord StbUndoRecord; +typedef ImStb::StbUndoState StbUndoState; +typedef ImChunkStream ImChunkStream_ImGuiTableSettings; +typedef ImChunkStream ImChunkStream_ImGuiWindowSettings; +typedef ImPool ImPool_ImGuiTabBar; +typedef ImPool ImPool_ImGuiTable; +typedef ImSpan ImSpan_ImGuiTableCellData; +typedef ImSpan ImSpan_ImGuiTableColumn; +typedef ImSpan ImSpan_ImGuiTableColumnIdx; +typedef ImVector ImVector_ImDrawChannel; +typedef ImVector ImVector_ImDrawCmd; +typedef ImVector ImVector_ImDrawIdx; +typedef ImVector ImVector_ImDrawListPtr; +typedef ImVector ImVector_ImDrawVert; +typedef ImVector ImVector_ImFontPtr; +typedef ImVector ImVector_ImFontAtlasCustomRect; +typedef ImVector ImVector_ImFontConfig; +typedef ImVector ImVector_ImFontGlyph; +typedef ImVector ImVector_ImGuiColorMod; +typedef ImVector ImVector_ImGuiContextHook; +typedef ImVector ImVector_ImGuiGroupData; +typedef ImVector ImVector_ImGuiID; +typedef ImVector ImVector_ImGuiItemFlags; +typedef ImVector ImVector_ImGuiOldColumnData; +typedef ImVector ImVector_ImGuiOldColumns; +typedef ImVector ImVector_ImGuiPopupData; +typedef ImVector ImVector_ImGuiPtrOrIndex; +typedef ImVector ImVector_ImGuiSettingsHandler; +typedef ImVector ImVector_ImGuiShrinkWidthItem; +typedef ImVector ImVector_ImGuiStoragePair; +typedef ImVector ImVector_ImGuiStyleMod; +typedef ImVector ImVector_ImGuiTabItem; +typedef ImVector ImVector_ImGuiTableColumnSortSpecs; +typedef ImVector ImVector_ImGuiTableTempData; +typedef ImVector ImVector_ImGuiTextRange; +typedef ImVector ImVector_ImGuiViewportPPtr; +typedef ImVector ImVector_ImGuiWindowPtr; +typedef ImVector ImVector_ImGuiWindowStackData; +typedef ImVector ImVector_ImTextureID; +typedef ImVector ImVector_ImU32; +typedef ImVector ImVector_ImVec2; +typedef ImVector ImVector_ImVec4; +typedef ImVector ImVector_ImWchar; +typedef ImVector ImVector_char; +typedef ImVector ImVector_float; +typedef ImVector ImVector_unsigned_char; +#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS +CIMGUI_API ImVec2* ImVec2_ImVec2_Nil(void); +CIMGUI_API void ImVec2_destroy(ImVec2* self); +CIMGUI_API ImVec2* ImVec2_ImVec2_Float(float _x,float _y); +CIMGUI_API ImVec4* ImVec4_ImVec4_Nil(void); +CIMGUI_API void ImVec4_destroy(ImVec4* self); +CIMGUI_API ImVec4* ImVec4_ImVec4_Float(float _x,float _y,float _z,float _w); +CIMGUI_API ImGuiContext* igCreateContext(ImFontAtlas* shared_font_atlas); +CIMGUI_API void igDestroyContext(ImGuiContext* ctx); +CIMGUI_API ImGuiContext* igGetCurrentContext(void); +CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx); +CIMGUI_API ImGuiIO* igGetIO(void); +CIMGUI_API ImGuiStyle* igGetStyle(void); +CIMGUI_API void igNewFrame(void); +CIMGUI_API void igEndFrame(void); +CIMGUI_API void igRender(void); +CIMGUI_API ImDrawData* igGetDrawData(void); +CIMGUI_API void igShowDemoWindow(bool* p_open); +CIMGUI_API void igShowMetricsWindow(bool* p_open); +CIMGUI_API void igShowAboutWindow(bool* p_open); +CIMGUI_API void igShowStyleEditor(ImGuiStyle* ref); +CIMGUI_API bool igShowStyleSelector(const char* label); +CIMGUI_API void igShowFontSelector(const char* label); +CIMGUI_API void igShowUserGuide(void); +CIMGUI_API const char* igGetVersion(void); +CIMGUI_API void igStyleColorsDark(ImGuiStyle* dst); +CIMGUI_API void igStyleColorsLight(ImGuiStyle* dst); +CIMGUI_API void igStyleColorsClassic(ImGuiStyle* dst); +CIMGUI_API bool igBegin(const char* name,bool* p_open,ImGuiWindowFlags flags); +CIMGUI_API void igEnd(void); +CIMGUI_API bool igBeginChild_Str(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags); +CIMGUI_API bool igBeginChild_ID(ImGuiID id,const ImVec2 size,bool border,ImGuiWindowFlags flags); +CIMGUI_API void igEndChild(void); +CIMGUI_API bool igIsWindowAppearing(void); +CIMGUI_API bool igIsWindowCollapsed(void); +CIMGUI_API bool igIsWindowFocused(ImGuiFocusedFlags flags); +CIMGUI_API bool igIsWindowHovered(ImGuiHoveredFlags flags); +CIMGUI_API ImDrawList* igGetWindowDrawList(void); +CIMGUI_API void igGetWindowPos(ImVec2 *pOut); +CIMGUI_API void igGetWindowSize(ImVec2 *pOut); +CIMGUI_API float igGetWindowWidth(void); +CIMGUI_API float igGetWindowHeight(void); +CIMGUI_API void igSetNextWindowPos(const ImVec2 pos,ImGuiCond cond,const ImVec2 pivot); +CIMGUI_API void igSetNextWindowSize(const ImVec2 size,ImGuiCond cond); +CIMGUI_API void igSetNextWindowSizeConstraints(const ImVec2 size_min,const ImVec2 size_max,ImGuiSizeCallback custom_callback,void* custom_callback_data); +CIMGUI_API void igSetNextWindowContentSize(const ImVec2 size); +CIMGUI_API void igSetNextWindowCollapsed(bool collapsed,ImGuiCond cond); +CIMGUI_API void igSetNextWindowFocus(void); +CIMGUI_API void igSetNextWindowBgAlpha(float alpha); +CIMGUI_API void igSetWindowPos_Vec2(const ImVec2 pos,ImGuiCond cond); +CIMGUI_API void igSetWindowSize_Vec2(const ImVec2 size,ImGuiCond cond); +CIMGUI_API void igSetWindowCollapsed_Bool(bool collapsed,ImGuiCond cond); +CIMGUI_API void igSetWindowFocus_Nil(void); +CIMGUI_API void igSetWindowFontScale(float scale); +CIMGUI_API void igSetWindowPos_Str(const char* name,const ImVec2 pos,ImGuiCond cond); +CIMGUI_API void igSetWindowSize_Str(const char* name,const ImVec2 size,ImGuiCond cond); +CIMGUI_API void igSetWindowCollapsed_Str(const char* name,bool collapsed,ImGuiCond cond); +CIMGUI_API void igSetWindowFocus_Str(const char* name); +CIMGUI_API void igGetContentRegionAvail(ImVec2 *pOut); +CIMGUI_API void igGetContentRegionMax(ImVec2 *pOut); +CIMGUI_API void igGetWindowContentRegionMin(ImVec2 *pOut); +CIMGUI_API void igGetWindowContentRegionMax(ImVec2 *pOut); +CIMGUI_API float igGetWindowContentRegionWidth(void); +CIMGUI_API float igGetScrollX(void); +CIMGUI_API float igGetScrollY(void); +CIMGUI_API void igSetScrollX(float scroll_x); +CIMGUI_API void igSetScrollY(float scroll_y); +CIMGUI_API float igGetScrollMaxX(void); +CIMGUI_API float igGetScrollMaxY(void); +CIMGUI_API void igSetScrollHereX(float center_x_ratio); +CIMGUI_API void igSetScrollHereY(float center_y_ratio); +CIMGUI_API void igSetScrollFromPosX(float local_x,float center_x_ratio); +CIMGUI_API void igSetScrollFromPosY(float local_y,float center_y_ratio); +CIMGUI_API void igPushFont(ImFont* font); +CIMGUI_API void igPopFont(void); +CIMGUI_API void igPushStyleColor_U32(ImGuiCol idx,ImU32 col); +CIMGUI_API void igPushStyleColor_Vec4(ImGuiCol idx,const ImVec4 col); +CIMGUI_API void igPopStyleColor(int count); +CIMGUI_API void igPushStyleVar_Float(ImGuiStyleVar idx,float val); +CIMGUI_API void igPushStyleVar_Vec2(ImGuiStyleVar idx,const ImVec2 val); +CIMGUI_API void igPopStyleVar(int count); +CIMGUI_API void igPushAllowKeyboardFocus(bool allow_keyboard_focus); +CIMGUI_API void igPopAllowKeyboardFocus(void); +CIMGUI_API void igPushButtonRepeat(bool repeat); +CIMGUI_API void igPopButtonRepeat(void); +CIMGUI_API void igPushItemWidth(float item_width); +CIMGUI_API void igPopItemWidth(void); +CIMGUI_API void igSetNextItemWidth(float item_width); +CIMGUI_API float igCalcItemWidth(void); +CIMGUI_API void igPushTextWrapPos(float wrap_local_pos_x); +CIMGUI_API void igPopTextWrapPos(void); +CIMGUI_API ImFont* igGetFont(void); +CIMGUI_API float igGetFontSize(void); +CIMGUI_API void igGetFontTexUvWhitePixel(ImVec2 *pOut); +CIMGUI_API ImU32 igGetColorU32_Col(ImGuiCol idx,float alpha_mul); +CIMGUI_API ImU32 igGetColorU32_Vec4(const ImVec4 col); +CIMGUI_API ImU32 igGetColorU32_U32(ImU32 col); +CIMGUI_API const ImVec4* igGetStyleColorVec4(ImGuiCol idx); +CIMGUI_API void igSeparator(void); +CIMGUI_API void igSameLine(float offset_from_start_x,float spacing); +CIMGUI_API void igNewLine(void); +CIMGUI_API void igSpacing(void); +CIMGUI_API void igDummy(const ImVec2 size); +CIMGUI_API void igIndent(float indent_w); +CIMGUI_API void igUnindent(float indent_w); +CIMGUI_API void igBeginGroup(void); +CIMGUI_API void igEndGroup(void); +CIMGUI_API void igGetCursorPos(ImVec2 *pOut); +CIMGUI_API float igGetCursorPosX(void); +CIMGUI_API float igGetCursorPosY(void); +CIMGUI_API void igSetCursorPos(const ImVec2 local_pos); +CIMGUI_API void igSetCursorPosX(float local_x); +CIMGUI_API void igSetCursorPosY(float local_y); +CIMGUI_API void igGetCursorStartPos(ImVec2 *pOut); +CIMGUI_API void igGetCursorScreenPos(ImVec2 *pOut); +CIMGUI_API void igSetCursorScreenPos(const ImVec2 pos); +CIMGUI_API void igAlignTextToFramePadding(void); +CIMGUI_API float igGetTextLineHeight(void); +CIMGUI_API float igGetTextLineHeightWithSpacing(void); +CIMGUI_API float igGetFrameHeight(void); +CIMGUI_API float igGetFrameHeightWithSpacing(void); +CIMGUI_API void igPushID_Str(const char* str_id); +CIMGUI_API void igPushID_StrStr(const char* str_id_begin,const char* str_id_end); +CIMGUI_API void igPushID_Ptr(const void* ptr_id); +CIMGUI_API void igPushID_Int(int int_id); +CIMGUI_API void igPopID(void); +CIMGUI_API ImGuiID igGetID_Str(const char* str_id); +CIMGUI_API ImGuiID igGetID_StrStr(const char* str_id_begin,const char* str_id_end); +CIMGUI_API ImGuiID igGetID_Ptr(const void* ptr_id); +CIMGUI_API void igTextUnformatted(const char* text,const char* text_end); +CIMGUI_API void igText(const char* fmt,...); +CIMGUI_API void igTextV(const char* fmt,va_list args); +CIMGUI_API void igTextColored(const ImVec4 col,const char* fmt,...); +CIMGUI_API void igTextColoredV(const ImVec4 col,const char* fmt,va_list args); +CIMGUI_API void igTextDisabled(const char* fmt,...); +CIMGUI_API void igTextDisabledV(const char* fmt,va_list args); +CIMGUI_API void igTextWrapped(const char* fmt,...); +CIMGUI_API void igTextWrappedV(const char* fmt,va_list args); +CIMGUI_API void igLabelText(const char* label,const char* fmt,...); +CIMGUI_API void igLabelTextV(const char* label,const char* fmt,va_list args); +CIMGUI_API void igBulletText(const char* fmt,...); +CIMGUI_API void igBulletTextV(const char* fmt,va_list args); +CIMGUI_API bool igButton(const char* label,const ImVec2 size); +CIMGUI_API bool igSmallButton(const char* label); +CIMGUI_API bool igInvisibleButton(const char* str_id,const ImVec2 size,ImGuiButtonFlags flags); +CIMGUI_API bool igArrowButton(const char* str_id,ImGuiDir dir); +CIMGUI_API void igImage(ImTextureID user_texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,const ImVec4 tint_col,const ImVec4 border_col); +CIMGUI_API bool igImageButton(ImTextureID user_texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,int frame_padding,const ImVec4 bg_col,const ImVec4 tint_col); +CIMGUI_API bool igCheckbox(const char* label,bool* v); +CIMGUI_API bool igCheckboxFlags_IntPtr(const char* label,int* flags,int flags_value); +CIMGUI_API bool igCheckboxFlags_UintPtr(const char* label,unsigned int* flags,unsigned int flags_value); +CIMGUI_API bool igRadioButton_Bool(const char* label,bool active); +CIMGUI_API bool igRadioButton_IntPtr(const char* label,int* v,int v_button); +CIMGUI_API void igProgressBar(float fraction,const ImVec2 size_arg,const char* overlay); +CIMGUI_API void igBullet(void); +CIMGUI_API bool igBeginCombo(const char* label,const char* preview_value,ImGuiComboFlags flags); +CIMGUI_API void igEndCombo(void); +CIMGUI_API bool igCombo_Str_arr(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items); +CIMGUI_API bool igCombo_Str(const char* label,int* current_item,const char* items_separated_by_zeros,int popup_max_height_in_items); +CIMGUI_API bool igCombo_FnBoolPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int popup_max_height_in_items); +CIMGUI_API bool igDragFloat(const char* label,float* v,float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragFloat2(const char* label,float v[2],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragFloat3(const char* label,float v[3],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragFloat4(const char* label,float v[4],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragFloatRange2(const char* label,float* v_current_min,float* v_current_max,float v_speed,float v_min,float v_max,const char* format,const char* format_max,ImGuiSliderFlags flags); +CIMGUI_API bool igDragInt(const char* label,int* v,float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragInt2(const char* label,int v[2],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragInt3(const char* label,int v[3],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragInt4(const char* label,int v[4],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragIntRange2(const char* label,int* v_current_min,int* v_current_max,float v_speed,int v_min,int v_max,const char* format,const char* format_max,ImGuiSliderFlags flags); +CIMGUI_API bool igDragScalar(const char* label,ImGuiDataType data_type,void* p_data,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igDragScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderFloat(const char* label,float* v,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderFloat2(const char* label,float v[2],float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderFloat3(const char* label,float v[3],float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderFloat4(const char* label,float v[4],float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderAngle(const char* label,float* v_rad,float v_degrees_min,float v_degrees_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderInt(const char* label,int* v,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderInt2(const char* label,int v[2],int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderInt3(const char* label,int v[3],int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderInt4(const char* label,int v[4],int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderScalar(const char* label,ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igVSliderFloat(const char* label,const ImVec2 size,float* v,float v_min,float v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igVSliderInt(const char* label,const ImVec2 size,int* v,int v_min,int v_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igVSliderScalar(const char* label,const ImVec2 size,ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igInputText(const char* label,char* buf,size_t buf_size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data); +CIMGUI_API bool igInputTextMultiline(const char* label,char* buf,size_t buf_size,const ImVec2 size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data); +CIMGUI_API bool igInputTextWithHint(const char* label,const char* hint,char* buf,size_t buf_size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data); +CIMGUI_API bool igInputFloat(const char* label,float* v,float step,float step_fast,const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputFloat2(const char* label,float v[2],const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputFloat3(const char* label,float v[3],const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputFloat4(const char* label,float v[4],const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputInt(const char* label,int* v,int step,int step_fast,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputInt2(const char* label,int v[2],ImGuiInputTextFlags flags); +CIMGUI_API bool igInputInt3(const char* label,int v[3],ImGuiInputTextFlags flags); +CIMGUI_API bool igInputInt4(const char* label,int v[4],ImGuiInputTextFlags flags); +CIMGUI_API bool igInputDouble(const char* label,double* v,double step,double step_fast,const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputScalar(const char* label,ImGuiDataType data_type,void* p_data,const void* p_step,const void* p_step_fast,const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igInputScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,const void* p_step,const void* p_step_fast,const char* format,ImGuiInputTextFlags flags); +CIMGUI_API bool igColorEdit3(const char* label,float col[3],ImGuiColorEditFlags flags); +CIMGUI_API bool igColorEdit4(const char* label,float col[4],ImGuiColorEditFlags flags); +CIMGUI_API bool igColorPicker3(const char* label,float col[3],ImGuiColorEditFlags flags); +CIMGUI_API bool igColorPicker4(const char* label,float col[4],ImGuiColorEditFlags flags,const float* ref_col); +CIMGUI_API bool igColorButton(const char* desc_id,const ImVec4 col,ImGuiColorEditFlags flags,ImVec2 size); +CIMGUI_API void igSetColorEditOptions(ImGuiColorEditFlags flags); +CIMGUI_API bool igTreeNode_Str(const char* label); +CIMGUI_API bool igTreeNode_StrStr(const char* str_id,const char* fmt,...); +CIMGUI_API bool igTreeNode_Ptr(const void* ptr_id,const char* fmt,...); +CIMGUI_API bool igTreeNodeV_Str(const char* str_id,const char* fmt,va_list args); +CIMGUI_API bool igTreeNodeV_Ptr(const void* ptr_id,const char* fmt,va_list args); +CIMGUI_API bool igTreeNodeEx_Str(const char* label,ImGuiTreeNodeFlags flags); +CIMGUI_API bool igTreeNodeEx_StrStr(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,...); +CIMGUI_API bool igTreeNodeEx_Ptr(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,...); +CIMGUI_API bool igTreeNodeExV_Str(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args); +CIMGUI_API bool igTreeNodeExV_Ptr(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args); +CIMGUI_API void igTreePush_Str(const char* str_id); +CIMGUI_API void igTreePush_Ptr(const void* ptr_id); +CIMGUI_API void igTreePop(void); +CIMGUI_API float igGetTreeNodeToLabelSpacing(void); +CIMGUI_API bool igCollapsingHeader_TreeNodeFlags(const char* label,ImGuiTreeNodeFlags flags); +CIMGUI_API bool igCollapsingHeader_BoolPtr(const char* label,bool* p_visible,ImGuiTreeNodeFlags flags); +CIMGUI_API void igSetNextItemOpen(bool is_open,ImGuiCond cond); +CIMGUI_API bool igSelectable_Bool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size); +CIMGUI_API bool igSelectable_BoolPtr(const char* label,bool* p_selected,ImGuiSelectableFlags flags,const ImVec2 size); +CIMGUI_API bool igBeginListBox(const char* label,const ImVec2 size); +CIMGUI_API void igEndListBox(void); +CIMGUI_API bool igListBox_Str_arr(const char* label,int* current_item,const char* const items[],int items_count,int height_in_items); +CIMGUI_API bool igListBox_FnBoolPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int height_in_items); +CIMGUI_API void igPlotLines_FloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride); +CIMGUI_API void igPlotLines_FnFloatPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size); +CIMGUI_API void igPlotHistogram_FloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride); +CIMGUI_API void igPlotHistogram_FnFloatPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size); +CIMGUI_API void igValue_Bool(const char* prefix,bool b); +CIMGUI_API void igValue_Int(const char* prefix,int v); +CIMGUI_API void igValue_Uint(const char* prefix,unsigned int v); +CIMGUI_API void igValue_Float(const char* prefix,float v,const char* float_format); +CIMGUI_API bool igBeginMenuBar(void); +CIMGUI_API void igEndMenuBar(void); +CIMGUI_API bool igBeginMainMenuBar(void); +CIMGUI_API void igEndMainMenuBar(void); +CIMGUI_API bool igBeginMenu(const char* label,bool enabled); +CIMGUI_API void igEndMenu(void); +CIMGUI_API bool igMenuItem_Bool(const char* label,const char* shortcut,bool selected,bool enabled); +CIMGUI_API bool igMenuItem_BoolPtr(const char* label,const char* shortcut,bool* p_selected,bool enabled); +CIMGUI_API void igBeginTooltip(void); +CIMGUI_API void igEndTooltip(void); +CIMGUI_API void igSetTooltip(const char* fmt,...); +CIMGUI_API void igSetTooltipV(const char* fmt,va_list args); +CIMGUI_API bool igBeginPopup(const char* str_id,ImGuiWindowFlags flags); +CIMGUI_API bool igBeginPopupModal(const char* name,bool* p_open,ImGuiWindowFlags flags); +CIMGUI_API void igEndPopup(void); +CIMGUI_API void igOpenPopup_Str(const char* str_id,ImGuiPopupFlags popup_flags); +CIMGUI_API void igOpenPopup_ID(ImGuiID id,ImGuiPopupFlags popup_flags); +CIMGUI_API void igOpenPopupOnItemClick(const char* str_id,ImGuiPopupFlags popup_flags); +CIMGUI_API void igCloseCurrentPopup(void); +CIMGUI_API bool igBeginPopupContextItem(const char* str_id,ImGuiPopupFlags popup_flags); +CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,ImGuiPopupFlags popup_flags); +CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,ImGuiPopupFlags popup_flags); +CIMGUI_API bool igIsPopupOpen_Str(const char* str_id,ImGuiPopupFlags flags); +CIMGUI_API bool igBeginTable(const char* str_id,int column,ImGuiTableFlags flags,const ImVec2 outer_size,float inner_width); +CIMGUI_API void igEndTable(void); +CIMGUI_API void igTableNextRow(ImGuiTableRowFlags row_flags,float min_row_height); +CIMGUI_API bool igTableNextColumn(void); +CIMGUI_API bool igTableSetColumnIndex(int column_n); +CIMGUI_API void igTableSetupColumn(const char* label,ImGuiTableColumnFlags flags,float init_width_or_weight,ImGuiID user_id); +CIMGUI_API void igTableSetupScrollFreeze(int cols,int rows); +CIMGUI_API void igTableHeadersRow(void); +CIMGUI_API void igTableHeader(const char* label); +CIMGUI_API ImGuiTableSortSpecs* igTableGetSortSpecs(void); +CIMGUI_API int igTableGetColumnCount(void); +CIMGUI_API int igTableGetColumnIndex(void); +CIMGUI_API int igTableGetRowIndex(void); +CIMGUI_API const char* igTableGetColumnName_Int(int column_n); +CIMGUI_API ImGuiTableColumnFlags igTableGetColumnFlags(int column_n); +CIMGUI_API void igTableSetColumnEnabled(int column_n,bool v); +CIMGUI_API void igTableSetBgColor(ImGuiTableBgTarget target,ImU32 color,int column_n); +CIMGUI_API void igColumns(int count,const char* id,bool border); +CIMGUI_API void igNextColumn(void); +CIMGUI_API int igGetColumnIndex(void); +CIMGUI_API float igGetColumnWidth(int column_index); +CIMGUI_API void igSetColumnWidth(int column_index,float width); +CIMGUI_API float igGetColumnOffset(int column_index); +CIMGUI_API void igSetColumnOffset(int column_index,float offset_x); +CIMGUI_API int igGetColumnsCount(void); +CIMGUI_API bool igBeginTabBar(const char* str_id,ImGuiTabBarFlags flags); +CIMGUI_API void igEndTabBar(void); +CIMGUI_API bool igBeginTabItem(const char* label,bool* p_open,ImGuiTabItemFlags flags); +CIMGUI_API void igEndTabItem(void); +CIMGUI_API bool igTabItemButton(const char* label,ImGuiTabItemFlags flags); +CIMGUI_API void igSetTabItemClosed(const char* tab_or_docked_window_label); +CIMGUI_API void igLogToTTY(int auto_open_depth); +CIMGUI_API void igLogToFile(int auto_open_depth,const char* filename); +CIMGUI_API void igLogToClipboard(int auto_open_depth); +CIMGUI_API void igLogFinish(void); +CIMGUI_API void igLogButtons(void); +CIMGUI_API void igLogTextV(const char* fmt,va_list args); +CIMGUI_API bool igBeginDragDropSource(ImGuiDragDropFlags flags); +CIMGUI_API bool igSetDragDropPayload(const char* type,const void* data,size_t sz,ImGuiCond cond); +CIMGUI_API void igEndDragDropSource(void); +CIMGUI_API bool igBeginDragDropTarget(void); +CIMGUI_API const ImGuiPayload* igAcceptDragDropPayload(const char* type,ImGuiDragDropFlags flags); +CIMGUI_API void igEndDragDropTarget(void); +CIMGUI_API const ImGuiPayload* igGetDragDropPayload(void); +CIMGUI_API void igBeginDisabled(bool disabled); +CIMGUI_API void igEndDisabled(void); +CIMGUI_API void igPushClipRect(const ImVec2 clip_rect_min,const ImVec2 clip_rect_max,bool intersect_with_current_clip_rect); +CIMGUI_API void igPopClipRect(void); +CIMGUI_API void igSetItemDefaultFocus(void); +CIMGUI_API void igSetKeyboardFocusHere(int offset); +CIMGUI_API bool igIsItemHovered(ImGuiHoveredFlags flags); +CIMGUI_API bool igIsItemActive(void); +CIMGUI_API bool igIsItemFocused(void); +CIMGUI_API bool igIsItemClicked(ImGuiMouseButton mouse_button); +CIMGUI_API bool igIsItemVisible(void); +CIMGUI_API bool igIsItemEdited(void); +CIMGUI_API bool igIsItemActivated(void); +CIMGUI_API bool igIsItemDeactivated(void); +CIMGUI_API bool igIsItemDeactivatedAfterEdit(void); +CIMGUI_API bool igIsItemToggledOpen(void); +CIMGUI_API bool igIsAnyItemHovered(void); +CIMGUI_API bool igIsAnyItemActive(void); +CIMGUI_API bool igIsAnyItemFocused(void); +CIMGUI_API void igGetItemRectMin(ImVec2 *pOut); +CIMGUI_API void igGetItemRectMax(ImVec2 *pOut); +CIMGUI_API void igGetItemRectSize(ImVec2 *pOut); +CIMGUI_API void igSetItemAllowOverlap(void); +CIMGUI_API ImGuiViewport* igGetMainViewport(void); +CIMGUI_API bool igIsRectVisible_Nil(const ImVec2 size); +CIMGUI_API bool igIsRectVisible_Vec2(const ImVec2 rect_min,const ImVec2 rect_max); +CIMGUI_API double igGetTime(void); +CIMGUI_API int igGetFrameCount(void); +CIMGUI_API ImDrawList* igGetBackgroundDrawList(void); +CIMGUI_API ImDrawList* igGetForegroundDrawList(void); +CIMGUI_API ImDrawListSharedData* igGetDrawListSharedData(void); +CIMGUI_API const char* igGetStyleColorName(ImGuiCol idx); +CIMGUI_API void igSetStateStorage(ImGuiStorage* storage); +CIMGUI_API ImGuiStorage* igGetStateStorage(void); +CIMGUI_API void igCalcListClipping(int items_count,float items_height,int* out_items_display_start,int* out_items_display_end); +CIMGUI_API bool igBeginChildFrame(ImGuiID id,const ImVec2 size,ImGuiWindowFlags flags); +CIMGUI_API void igEndChildFrame(void); +CIMGUI_API void igCalcTextSize(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width); +CIMGUI_API void igColorConvertU32ToFloat4(ImVec4 *pOut,ImU32 in); +CIMGUI_API ImU32 igColorConvertFloat4ToU32(const ImVec4 in); +CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float* out_h,float* out_s,float* out_v); +CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float* out_r,float* out_g,float* out_b); +CIMGUI_API int igGetKeyIndex(ImGuiKey imgui_key); +CIMGUI_API bool igIsKeyDown(int user_key_index); +CIMGUI_API bool igIsKeyPressed(int user_key_index,bool repeat); +CIMGUI_API bool igIsKeyReleased(int user_key_index); +CIMGUI_API int igGetKeyPressedAmount(int key_index,float repeat_delay,float rate); +CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value); +CIMGUI_API bool igIsMouseDown(ImGuiMouseButton button); +CIMGUI_API bool igIsMouseClicked(ImGuiMouseButton button,bool repeat); +CIMGUI_API bool igIsMouseReleased(ImGuiMouseButton button); +CIMGUI_API bool igIsMouseDoubleClicked(ImGuiMouseButton button); +CIMGUI_API bool igIsMouseHoveringRect(const ImVec2 r_min,const ImVec2 r_max,bool clip); +CIMGUI_API bool igIsMousePosValid(const ImVec2* mouse_pos); +CIMGUI_API bool igIsAnyMouseDown(void); +CIMGUI_API void igGetMousePos(ImVec2 *pOut); +CIMGUI_API void igGetMousePosOnOpeningCurrentPopup(ImVec2 *pOut); +CIMGUI_API bool igIsMouseDragging(ImGuiMouseButton button,float lock_threshold); +CIMGUI_API void igGetMouseDragDelta(ImVec2 *pOut,ImGuiMouseButton button,float lock_threshold); +CIMGUI_API void igResetMouseDragDelta(ImGuiMouseButton button); +CIMGUI_API ImGuiMouseCursor igGetMouseCursor(void); +CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor cursor_type); +CIMGUI_API void igCaptureMouseFromApp(bool want_capture_mouse_value); +CIMGUI_API const char* igGetClipboardText(void); +CIMGUI_API void igSetClipboardText(const char* text); +CIMGUI_API void igLoadIniSettingsFromDisk(const char* ini_filename); +CIMGUI_API void igLoadIniSettingsFromMemory(const char* ini_data,size_t ini_size); +CIMGUI_API void igSaveIniSettingsToDisk(const char* ini_filename); +CIMGUI_API const char* igSaveIniSettingsToMemory(size_t* out_ini_size); +CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx); +CIMGUI_API void igSetAllocatorFunctions(ImGuiMemAllocFunc alloc_func,ImGuiMemFreeFunc free_func,void* user_data); +CIMGUI_API void igGetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func,ImGuiMemFreeFunc* p_free_func,void** p_user_data); +CIMGUI_API void* igMemAlloc(size_t size); +CIMGUI_API void igMemFree(void* ptr); +CIMGUI_API ImGuiStyle* ImGuiStyle_ImGuiStyle(void); +CIMGUI_API void ImGuiStyle_destroy(ImGuiStyle* self); +CIMGUI_API void ImGuiStyle_ScaleAllSizes(ImGuiStyle* self,float scale_factor); +CIMGUI_API void ImGuiIO_AddInputCharacter(ImGuiIO* self,unsigned int c); +CIMGUI_API void ImGuiIO_AddInputCharacterUTF16(ImGuiIO* self,ImWchar16 c); +CIMGUI_API void ImGuiIO_AddInputCharactersUTF8(ImGuiIO* self,const char* str); +CIMGUI_API void ImGuiIO_ClearInputCharacters(ImGuiIO* self); +CIMGUI_API void ImGuiIO_AddFocusEvent(ImGuiIO* self,bool focused); +CIMGUI_API ImGuiIO* ImGuiIO_ImGuiIO(void); +CIMGUI_API void ImGuiIO_destroy(ImGuiIO* self); +CIMGUI_API ImGuiInputTextCallbackData* ImGuiInputTextCallbackData_ImGuiInputTextCallbackData(void); +CIMGUI_API void ImGuiInputTextCallbackData_destroy(ImGuiInputTextCallbackData* self); +CIMGUI_API void ImGuiInputTextCallbackData_DeleteChars(ImGuiInputTextCallbackData* self,int pos,int bytes_count); +CIMGUI_API void ImGuiInputTextCallbackData_InsertChars(ImGuiInputTextCallbackData* self,int pos,const char* text,const char* text_end); +CIMGUI_API void ImGuiInputTextCallbackData_SelectAll(ImGuiInputTextCallbackData* self); +CIMGUI_API void ImGuiInputTextCallbackData_ClearSelection(ImGuiInputTextCallbackData* self); +CIMGUI_API bool ImGuiInputTextCallbackData_HasSelection(ImGuiInputTextCallbackData* self); +CIMGUI_API ImGuiPayload* ImGuiPayload_ImGuiPayload(void); +CIMGUI_API void ImGuiPayload_destroy(ImGuiPayload* self); +CIMGUI_API void ImGuiPayload_Clear(ImGuiPayload* self); +CIMGUI_API bool ImGuiPayload_IsDataType(ImGuiPayload* self,const char* type); +CIMGUI_API bool ImGuiPayload_IsPreview(ImGuiPayload* self); +CIMGUI_API bool ImGuiPayload_IsDelivery(ImGuiPayload* self); +CIMGUI_API ImGuiTableColumnSortSpecs* ImGuiTableColumnSortSpecs_ImGuiTableColumnSortSpecs(void); +CIMGUI_API void ImGuiTableColumnSortSpecs_destroy(ImGuiTableColumnSortSpecs* self); +CIMGUI_API ImGuiTableSortSpecs* ImGuiTableSortSpecs_ImGuiTableSortSpecs(void); +CIMGUI_API void ImGuiTableSortSpecs_destroy(ImGuiTableSortSpecs* self); +CIMGUI_API ImGuiOnceUponAFrame* ImGuiOnceUponAFrame_ImGuiOnceUponAFrame(void); +CIMGUI_API void ImGuiOnceUponAFrame_destroy(ImGuiOnceUponAFrame* self); +CIMGUI_API ImGuiTextFilter* ImGuiTextFilter_ImGuiTextFilter(const char* default_filter); +CIMGUI_API void ImGuiTextFilter_destroy(ImGuiTextFilter* self); +CIMGUI_API bool ImGuiTextFilter_Draw(ImGuiTextFilter* self,const char* label,float width); +CIMGUI_API bool ImGuiTextFilter_PassFilter(ImGuiTextFilter* self,const char* text,const char* text_end); +CIMGUI_API void ImGuiTextFilter_Build(ImGuiTextFilter* self); +CIMGUI_API void ImGuiTextFilter_Clear(ImGuiTextFilter* self); +CIMGUI_API bool ImGuiTextFilter_IsActive(ImGuiTextFilter* self); +CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange_Nil(void); +CIMGUI_API void ImGuiTextRange_destroy(ImGuiTextRange* self); +CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange_Str(const char* _b,const char* _e); +CIMGUI_API bool ImGuiTextRange_empty(ImGuiTextRange* self); +CIMGUI_API void ImGuiTextRange_split(ImGuiTextRange* self,char separator,ImVector_ImGuiTextRange* out); +CIMGUI_API ImGuiTextBuffer* ImGuiTextBuffer_ImGuiTextBuffer(void); +CIMGUI_API void ImGuiTextBuffer_destroy(ImGuiTextBuffer* self); +CIMGUI_API const char* ImGuiTextBuffer_begin(ImGuiTextBuffer* self); +CIMGUI_API const char* ImGuiTextBuffer_end(ImGuiTextBuffer* self); +CIMGUI_API int ImGuiTextBuffer_size(ImGuiTextBuffer* self); +CIMGUI_API bool ImGuiTextBuffer_empty(ImGuiTextBuffer* self); +CIMGUI_API void ImGuiTextBuffer_clear(ImGuiTextBuffer* self); +CIMGUI_API void ImGuiTextBuffer_reserve(ImGuiTextBuffer* self,int capacity); +CIMGUI_API const char* ImGuiTextBuffer_c_str(ImGuiTextBuffer* self); +CIMGUI_API void ImGuiTextBuffer_append(ImGuiTextBuffer* self,const char* str,const char* str_end); +CIMGUI_API void ImGuiTextBuffer_appendfv(ImGuiTextBuffer* self,const char* fmt,va_list args); +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Int(ImGuiID _key,int _val_i); +CIMGUI_API void ImGuiStoragePair_destroy(ImGuiStoragePair* self); +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Float(ImGuiID _key,float _val_f); +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Ptr(ImGuiID _key,void* _val_p); +CIMGUI_API void ImGuiStorage_Clear(ImGuiStorage* self); +CIMGUI_API int ImGuiStorage_GetInt(ImGuiStorage* self,ImGuiID key,int default_val); +CIMGUI_API void ImGuiStorage_SetInt(ImGuiStorage* self,ImGuiID key,int val); +CIMGUI_API bool ImGuiStorage_GetBool(ImGuiStorage* self,ImGuiID key,bool default_val); +CIMGUI_API void ImGuiStorage_SetBool(ImGuiStorage* self,ImGuiID key,bool val); +CIMGUI_API float ImGuiStorage_GetFloat(ImGuiStorage* self,ImGuiID key,float default_val); +CIMGUI_API void ImGuiStorage_SetFloat(ImGuiStorage* self,ImGuiID key,float val); +CIMGUI_API void* ImGuiStorage_GetVoidPtr(ImGuiStorage* self,ImGuiID key); +CIMGUI_API void ImGuiStorage_SetVoidPtr(ImGuiStorage* self,ImGuiID key,void* val); +CIMGUI_API int* ImGuiStorage_GetIntRef(ImGuiStorage* self,ImGuiID key,int default_val); +CIMGUI_API bool* ImGuiStorage_GetBoolRef(ImGuiStorage* self,ImGuiID key,bool default_val); +CIMGUI_API float* ImGuiStorage_GetFloatRef(ImGuiStorage* self,ImGuiID key,float default_val); +CIMGUI_API void** ImGuiStorage_GetVoidPtrRef(ImGuiStorage* self,ImGuiID key,void* default_val); +CIMGUI_API void ImGuiStorage_SetAllInt(ImGuiStorage* self,int val); +CIMGUI_API void ImGuiStorage_BuildSortByKey(ImGuiStorage* self); +CIMGUI_API ImGuiListClipper* ImGuiListClipper_ImGuiListClipper(void); +CIMGUI_API void ImGuiListClipper_destroy(ImGuiListClipper* self); +CIMGUI_API void ImGuiListClipper_Begin(ImGuiListClipper* self,int items_count,float items_height); +CIMGUI_API void ImGuiListClipper_End(ImGuiListClipper* self); +CIMGUI_API bool ImGuiListClipper_Step(ImGuiListClipper* self); +CIMGUI_API ImColor* ImColor_ImColor_Nil(void); +CIMGUI_API void ImColor_destroy(ImColor* self); +CIMGUI_API ImColor* ImColor_ImColor_Int(int r,int g,int b,int a); +CIMGUI_API ImColor* ImColor_ImColor_U32(ImU32 rgba); +CIMGUI_API ImColor* ImColor_ImColor_Float(float r,float g,float b,float a); +CIMGUI_API ImColor* ImColor_ImColor_Vec4(const ImVec4 col); +CIMGUI_API void ImColor_SetHSV(ImColor* self,float h,float s,float v,float a); +CIMGUI_API void ImColor_HSV(ImColor *pOut,float h,float s,float v,float a); +CIMGUI_API ImDrawCmd* ImDrawCmd_ImDrawCmd(void); +CIMGUI_API void ImDrawCmd_destroy(ImDrawCmd* self); +CIMGUI_API ImTextureID ImDrawCmd_GetTexID(ImDrawCmd* self); +CIMGUI_API ImDrawListSplitter* ImDrawListSplitter_ImDrawListSplitter(void); +CIMGUI_API void ImDrawListSplitter_destroy(ImDrawListSplitter* self); +CIMGUI_API void ImDrawListSplitter_Clear(ImDrawListSplitter* self); +CIMGUI_API void ImDrawListSplitter_ClearFreeMemory(ImDrawListSplitter* self); +CIMGUI_API void ImDrawListSplitter_Split(ImDrawListSplitter* self,ImDrawList* draw_list,int count); +CIMGUI_API void ImDrawListSplitter_Merge(ImDrawListSplitter* self,ImDrawList* draw_list); +CIMGUI_API void ImDrawListSplitter_SetCurrentChannel(ImDrawListSplitter* self,ImDrawList* draw_list,int channel_idx); +CIMGUI_API ImDrawList* ImDrawList_ImDrawList(const ImDrawListSharedData* shared_data); +CIMGUI_API void ImDrawList_destroy(ImDrawList* self); +CIMGUI_API void ImDrawList_PushClipRect(ImDrawList* self,ImVec2 clip_rect_min,ImVec2 clip_rect_max,bool intersect_with_current_clip_rect); +CIMGUI_API void ImDrawList_PushClipRectFullScreen(ImDrawList* self); +CIMGUI_API void ImDrawList_PopClipRect(ImDrawList* self); +CIMGUI_API void ImDrawList_PushTextureID(ImDrawList* self,ImTextureID texture_id); +CIMGUI_API void ImDrawList_PopTextureID(ImDrawList* self); +CIMGUI_API void ImDrawList_GetClipRectMin(ImVec2 *pOut,ImDrawList* self); +CIMGUI_API void ImDrawList_GetClipRectMax(ImVec2 *pOut,ImDrawList* self); +CIMGUI_API void ImDrawList_AddLine(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,ImU32 col,float thickness); +CIMGUI_API void ImDrawList_AddRect(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawFlags flags,float thickness); +CIMGUI_API void ImDrawList_AddRectFilled(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawFlags flags); +CIMGUI_API void ImDrawList_AddRectFilledMultiColor(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col_upr_left,ImU32 col_upr_right,ImU32 col_bot_right,ImU32 col_bot_left); +CIMGUI_API void ImDrawList_AddQuad(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness); +CIMGUI_API void ImDrawList_AddQuadFilled(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col); +CIMGUI_API void ImDrawList_AddTriangle(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col,float thickness); +CIMGUI_API void ImDrawList_AddTriangleFilled(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col); +CIMGUI_API void ImDrawList_AddCircle(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness); +CIMGUI_API void ImDrawList_AddCircleFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments); +CIMGUI_API void ImDrawList_AddNgon(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness); +CIMGUI_API void ImDrawList_AddNgonFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments); +CIMGUI_API void ImDrawList_AddText_Vec2(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end); +CIMGUI_API void ImDrawList_AddText_FontPtr(ImDrawList* self,const ImFont* font,float font_size,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end,float wrap_width,const ImVec4* cpu_fine_clip_rect); +CIMGUI_API void ImDrawList_AddPolyline(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col,ImDrawFlags flags,float thickness); +CIMGUI_API void ImDrawList_AddConvexPolyFilled(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col); +CIMGUI_API void ImDrawList_AddBezierCubic(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness,int num_segments); +CIMGUI_API void ImDrawList_AddBezierQuadratic(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col,float thickness,int num_segments); +CIMGUI_API void ImDrawList_AddImage(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col); +CIMGUI_API void ImDrawList_AddImageQuad(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 uv1,const ImVec2 uv2,const ImVec2 uv3,const ImVec2 uv4,ImU32 col); +CIMGUI_API void ImDrawList_AddImageRounded(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col,float rounding,ImDrawFlags flags); +CIMGUI_API void ImDrawList_PathClear(ImDrawList* self); +CIMGUI_API void ImDrawList_PathLineTo(ImDrawList* self,const ImVec2 pos); +CIMGUI_API void ImDrawList_PathLineToMergeDuplicate(ImDrawList* self,const ImVec2 pos); +CIMGUI_API void ImDrawList_PathFillConvex(ImDrawList* self,ImU32 col); +CIMGUI_API void ImDrawList_PathStroke(ImDrawList* self,ImU32 col,ImDrawFlags flags,float thickness); +CIMGUI_API void ImDrawList_PathArcTo(ImDrawList* self,const ImVec2 center,float radius,float a_min,float a_max,int num_segments); +CIMGUI_API void ImDrawList_PathArcToFast(ImDrawList* self,const ImVec2 center,float radius,int a_min_of_12,int a_max_of_12); +CIMGUI_API void ImDrawList_PathBezierCubicCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,int num_segments); +CIMGUI_API void ImDrawList_PathBezierQuadraticCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,int num_segments); +CIMGUI_API void ImDrawList_PathRect(ImDrawList* self,const ImVec2 rect_min,const ImVec2 rect_max,float rounding,ImDrawFlags flags); +CIMGUI_API void ImDrawList_AddCallback(ImDrawList* self,ImDrawCallback callback,void* callback_data); +CIMGUI_API void ImDrawList_AddDrawCmd(ImDrawList* self); +CIMGUI_API ImDrawList* ImDrawList_CloneOutput(ImDrawList* self); +CIMGUI_API void ImDrawList_ChannelsSplit(ImDrawList* self,int count); +CIMGUI_API void ImDrawList_ChannelsMerge(ImDrawList* self); +CIMGUI_API void ImDrawList_ChannelsSetCurrent(ImDrawList* self,int n); +CIMGUI_API void ImDrawList_PrimReserve(ImDrawList* self,int idx_count,int vtx_count); +CIMGUI_API void ImDrawList_PrimUnreserve(ImDrawList* self,int idx_count,int vtx_count); +CIMGUI_API void ImDrawList_PrimRect(ImDrawList* self,const ImVec2 a,const ImVec2 b,ImU32 col); +CIMGUI_API void ImDrawList_PrimRectUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,ImU32 col); +CIMGUI_API void ImDrawList_PrimQuadUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 d,const ImVec2 uv_a,const ImVec2 uv_b,const ImVec2 uv_c,const ImVec2 uv_d,ImU32 col); +CIMGUI_API void ImDrawList_PrimWriteVtx(ImDrawList* self,const ImVec2 pos,const ImVec2 uv,ImU32 col); +CIMGUI_API void ImDrawList_PrimWriteIdx(ImDrawList* self,ImDrawIdx idx); +CIMGUI_API void ImDrawList_PrimVtx(ImDrawList* self,const ImVec2 pos,const ImVec2 uv,ImU32 col); +CIMGUI_API void ImDrawList__ResetForNewFrame(ImDrawList* self); +CIMGUI_API void ImDrawList__ClearFreeMemory(ImDrawList* self); +CIMGUI_API void ImDrawList__PopUnusedDrawCmd(ImDrawList* self); +CIMGUI_API void ImDrawList__TryMergeDrawCmds(ImDrawList* self); +CIMGUI_API void ImDrawList__OnChangedClipRect(ImDrawList* self); +CIMGUI_API void ImDrawList__OnChangedTextureID(ImDrawList* self); +CIMGUI_API void ImDrawList__OnChangedVtxOffset(ImDrawList* self); +CIMGUI_API int ImDrawList__CalcCircleAutoSegmentCount(ImDrawList* self,float radius); +CIMGUI_API void ImDrawList__PathArcToFastEx(ImDrawList* self,const ImVec2 center,float radius,int a_min_sample,int a_max_sample,int a_step); +CIMGUI_API void ImDrawList__PathArcToN(ImDrawList* self,const ImVec2 center,float radius,float a_min,float a_max,int num_segments); +CIMGUI_API ImDrawData* ImDrawData_ImDrawData(void); +CIMGUI_API void ImDrawData_destroy(ImDrawData* self); +CIMGUI_API void ImDrawData_Clear(ImDrawData* self); +CIMGUI_API void ImDrawData_DeIndexAllBuffers(ImDrawData* self); +CIMGUI_API void ImDrawData_ScaleClipRects(ImDrawData* self,const ImVec2 fb_scale); +CIMGUI_API ImFontConfig* ImFontConfig_ImFontConfig(void); +CIMGUI_API void ImFontConfig_destroy(ImFontConfig* self); +CIMGUI_API ImFontGlyphRangesBuilder* ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder(void); +CIMGUI_API void ImFontGlyphRangesBuilder_destroy(ImFontGlyphRangesBuilder* self); +CIMGUI_API void ImFontGlyphRangesBuilder_Clear(ImFontGlyphRangesBuilder* self); +CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,size_t n); +CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,size_t n); +CIMGUI_API void ImFontGlyphRangesBuilder_AddChar(ImFontGlyphRangesBuilder* self,ImWchar c); +CIMGUI_API void ImFontGlyphRangesBuilder_AddText(ImFontGlyphRangesBuilder* self,const char* text,const char* text_end); +CIMGUI_API void ImFontGlyphRangesBuilder_AddRanges(ImFontGlyphRangesBuilder* self,const ImWchar* ranges); +CIMGUI_API void ImFontGlyphRangesBuilder_BuildRanges(ImFontGlyphRangesBuilder* self,ImVector_ImWchar* out_ranges); +CIMGUI_API ImFontAtlasCustomRect* ImFontAtlasCustomRect_ImFontAtlasCustomRect(void); +CIMGUI_API void ImFontAtlasCustomRect_destroy(ImFontAtlasCustomRect* self); +CIMGUI_API bool ImFontAtlasCustomRect_IsPacked(ImFontAtlasCustomRect* self); +CIMGUI_API ImFontAtlas* ImFontAtlas_ImFontAtlas(void); +CIMGUI_API void ImFontAtlas_destroy(ImFontAtlas* self); +CIMGUI_API ImFont* ImFontAtlas_AddFont(ImFontAtlas* self,const ImFontConfig* font_cfg); +CIMGUI_API ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* self,const ImFontConfig* font_cfg); +CIMGUI_API ImFont* ImFontAtlas_AddFontFromFileTTF(ImFontAtlas* self,const char* filename,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges); +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas* self,void* font_data,int font_size,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges); +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryCompressedTTF(ImFontAtlas* self,const void* compressed_font_data,int compressed_font_size,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges); +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas* self,const char* compressed_font_data_base85,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges); +CIMGUI_API void ImFontAtlas_ClearInputData(ImFontAtlas* self); +CIMGUI_API void ImFontAtlas_ClearTexData(ImFontAtlas* self); +CIMGUI_API void ImFontAtlas_ClearFonts(ImFontAtlas* self); +CIMGUI_API void ImFontAtlas_Clear(ImFontAtlas* self); +CIMGUI_API bool ImFontAtlas_Build(ImFontAtlas* self); +CIMGUI_API void ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* self,unsigned char** out_pixels,int* out_width,int* out_height,int* out_bytes_per_pixel); +CIMGUI_API void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* self,unsigned char** out_pixels,int* out_width,int* out_height,int* out_bytes_per_pixel); +CIMGUI_API bool ImFontAtlas_IsBuilt(ImFontAtlas* self); +CIMGUI_API void ImFontAtlas_SetTexID(ImFontAtlas* self,ImTextureID id); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesDefault(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesKorean(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesChineseFull(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesThai(ImFontAtlas* self); +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesVietnamese(ImFontAtlas* self); +CIMGUI_API int ImFontAtlas_AddCustomRectRegular(ImFontAtlas* self,int width,int height); +CIMGUI_API int ImFontAtlas_AddCustomRectFontGlyph(ImFontAtlas* self,ImFont* font,ImWchar id,int width,int height,float advance_x,const ImVec2 offset); +CIMGUI_API ImFontAtlasCustomRect* ImFontAtlas_GetCustomRectByIndex(ImFontAtlas* self,int index); +CIMGUI_API void ImFontAtlas_CalcCustomRectUV(ImFontAtlas* self,const ImFontAtlasCustomRect* rect,ImVec2* out_uv_min,ImVec2* out_uv_max); +CIMGUI_API bool ImFontAtlas_GetMouseCursorTexData(ImFontAtlas* self,ImGuiMouseCursor cursor,ImVec2* out_offset,ImVec2* out_size,ImVec2 out_uv_border[2],ImVec2 out_uv_fill[2]); +CIMGUI_API ImFont* ImFont_ImFont(void); +CIMGUI_API void ImFont_destroy(ImFont* self); +CIMGUI_API const ImFontGlyph* ImFont_FindGlyph(ImFont* self,ImWchar c); +CIMGUI_API const ImFontGlyph* ImFont_FindGlyphNoFallback(ImFont* self,ImWchar c); +CIMGUI_API float ImFont_GetCharAdvance(ImFont* self,ImWchar c); +CIMGUI_API bool ImFont_IsLoaded(ImFont* self); +CIMGUI_API const char* ImFont_GetDebugName(ImFont* self); +CIMGUI_API void ImFont_CalcTextSizeA(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining); +CIMGUI_API const char* ImFont_CalcWordWrapPositionA(ImFont* self,float scale,const char* text,const char* text_end,float wrap_width); +CIMGUI_API void ImFont_RenderChar(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,ImWchar c); +CIMGUI_API void ImFont_RenderText(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,const ImVec4 clip_rect,const char* text_begin,const char* text_end,float wrap_width,bool cpu_fine_clip); +CIMGUI_API void ImFont_BuildLookupTable(ImFont* self); +CIMGUI_API void ImFont_ClearOutputData(ImFont* self); +CIMGUI_API void ImFont_GrowIndex(ImFont* self,int new_size); +CIMGUI_API void ImFont_AddGlyph(ImFont* self,const ImFontConfig* src_cfg,ImWchar c,float x0,float y0,float x1,float y1,float u0,float v0,float u1,float v1,float advance_x); +CIMGUI_API void ImFont_AddRemapChar(ImFont* self,ImWchar dst,ImWchar src,bool overwrite_dst); +CIMGUI_API void ImFont_SetGlyphVisible(ImFont* self,ImWchar c,bool visible); +CIMGUI_API bool ImFont_IsGlyphRangeUnused(ImFont* self,unsigned int c_begin,unsigned int c_last); +CIMGUI_API ImGuiViewport* ImGuiViewport_ImGuiViewport(void); +CIMGUI_API void ImGuiViewport_destroy(ImGuiViewport* self); +CIMGUI_API void ImGuiViewport_GetCenter(ImVec2 *pOut,ImGuiViewport* self); +CIMGUI_API void ImGuiViewport_GetWorkCenter(ImVec2 *pOut,ImGuiViewport* self); +CIMGUI_API ImGuiID igImHashData(const void* data,size_t data_size,ImU32 seed); +CIMGUI_API ImGuiID igImHashStr(const char* data,size_t data_size,ImU32 seed); +CIMGUI_API ImU32 igImAlphaBlendColors(ImU32 col_a,ImU32 col_b); +CIMGUI_API bool igImIsPowerOfTwo_Int(int v); +CIMGUI_API bool igImIsPowerOfTwo_U64(ImU64 v); +CIMGUI_API int igImUpperPowerOfTwo(int v); +CIMGUI_API int igImStricmp(const char* str1,const char* str2); +CIMGUI_API int igImStrnicmp(const char* str1,const char* str2,size_t count); +CIMGUI_API void igImStrncpy(char* dst,const char* src,size_t count); +CIMGUI_API char* igImStrdup(const char* str); +CIMGUI_API char* igImStrdupcpy(char* dst,size_t* p_dst_size,const char* str); +CIMGUI_API const char* igImStrchrRange(const char* str_begin,const char* str_end,char c); +CIMGUI_API int igImStrlenW(const ImWchar* str); +CIMGUI_API const char* igImStreolRange(const char* str,const char* str_end); +CIMGUI_API const ImWchar* igImStrbolW(const ImWchar* buf_mid_line,const ImWchar* buf_begin); +CIMGUI_API const char* igImStristr(const char* haystack,const char* haystack_end,const char* needle,const char* needle_end); +CIMGUI_API void igImStrTrimBlanks(char* str); +CIMGUI_API const char* igImStrSkipBlank(const char* str); +CIMGUI_API int igImFormatString(char* buf,size_t buf_size,const char* fmt,...); +CIMGUI_API int igImFormatStringV(char* buf,size_t buf_size,const char* fmt,va_list args); +CIMGUI_API const char* igImParseFormatFindStart(const char* format); +CIMGUI_API const char* igImParseFormatFindEnd(const char* format); +CIMGUI_API const char* igImParseFormatTrimDecorations(const char* format,char* buf,size_t buf_size); +CIMGUI_API int igImParseFormatPrecision(const char* format,int default_value); +CIMGUI_API bool igImCharIsBlankA(char c); +CIMGUI_API bool igImCharIsBlankW(unsigned int c); +CIMGUI_API const char* igImTextCharToUtf8(char out_buf[5],unsigned int c); +CIMGUI_API int igImTextStrToUtf8(char* out_buf,int out_buf_size,const ImWchar* in_text,const ImWchar* in_text_end); +CIMGUI_API int igImTextCharFromUtf8(unsigned int* out_char,const char* in_text,const char* in_text_end); +CIMGUI_API int igImTextStrFromUtf8(ImWchar* out_buf,int out_buf_size,const char* in_text,const char* in_text_end,const char** in_remaining); +CIMGUI_API int igImTextCountCharsFromUtf8(const char* in_text,const char* in_text_end); +CIMGUI_API int igImTextCountUtf8BytesFromChar(const char* in_text,const char* in_text_end); +CIMGUI_API int igImTextCountUtf8BytesFromStr(const ImWchar* in_text,const ImWchar* in_text_end); +CIMGUI_API ImFileHandle igImFileOpen(const char* filename,const char* mode); +CIMGUI_API bool igImFileClose(ImFileHandle file); +CIMGUI_API ImU64 igImFileGetSize(ImFileHandle file); +CIMGUI_API ImU64 igImFileRead(void* data,ImU64 size,ImU64 count,ImFileHandle file); +CIMGUI_API ImU64 igImFileWrite(const void* data,ImU64 size,ImU64 count,ImFileHandle file); +CIMGUI_API void* igImFileLoadToMemory(const char* filename,const char* mode,size_t* out_file_size,int padding_bytes); +CIMGUI_API float igImPow_Float(float x,float y); +CIMGUI_API double igImPow_double(double x,double y); +CIMGUI_API float igImLog_Float(float x); +CIMGUI_API double igImLog_double(double x); +CIMGUI_API int igImAbs_Int(int x); +CIMGUI_API float igImAbs_Float(float x); +CIMGUI_API double igImAbs_double(double x); +CIMGUI_API float igImSign_Float(float x); +CIMGUI_API double igImSign_double(double x); +CIMGUI_API float igImRsqrt_Float(float x); +CIMGUI_API double igImRsqrt_double(double x); +CIMGUI_API void igImMin(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs); +CIMGUI_API void igImMax(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs); +CIMGUI_API void igImClamp(ImVec2 *pOut,const ImVec2 v,const ImVec2 mn,ImVec2 mx); +CIMGUI_API void igImLerp_Vec2Float(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,float t); +CIMGUI_API void igImLerp_Vec2Vec2(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 t); +CIMGUI_API void igImLerp_Vec4(ImVec4 *pOut,const ImVec4 a,const ImVec4 b,float t); +CIMGUI_API float igImSaturate(float f); +CIMGUI_API float igImLengthSqr_Vec2(const ImVec2 lhs); +CIMGUI_API float igImLengthSqr_Vec4(const ImVec4 lhs); +CIMGUI_API float igImInvLength(const ImVec2 lhs,float fail_value); +CIMGUI_API float igImFloor_Float(float f); +CIMGUI_API float igImFloorSigned(float f); +CIMGUI_API void igImFloor_Vec2(ImVec2 *pOut,const ImVec2 v); +CIMGUI_API int igImModPositive(int a,int b); +CIMGUI_API float igImDot(const ImVec2 a,const ImVec2 b); +CIMGUI_API void igImRotate(ImVec2 *pOut,const ImVec2 v,float cos_a,float sin_a); +CIMGUI_API float igImLinearSweep(float current,float target,float speed); +CIMGUI_API void igImMul(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs); +CIMGUI_API void igImBezierCubicCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,float t); +CIMGUI_API void igImBezierCubicClosestPoint(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,int num_segments); +CIMGUI_API void igImBezierCubicClosestPointCasteljau(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,float tess_tol); +CIMGUI_API void igImBezierQuadraticCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,float t); +CIMGUI_API void igImLineClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 p); +CIMGUI_API bool igImTriangleContainsPoint(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p); +CIMGUI_API void igImTriangleClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p); +CIMGUI_API void igImTriangleBarycentricCoords(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p,float* out_u,float* out_v,float* out_w); +CIMGUI_API float igImTriangleArea(const ImVec2 a,const ImVec2 b,const ImVec2 c); +CIMGUI_API ImGuiDir igImGetDirQuadrantFromDelta(float dx,float dy); +CIMGUI_API ImVec1* ImVec1_ImVec1_Nil(void); +CIMGUI_API void ImVec1_destroy(ImVec1* self); +CIMGUI_API ImVec1* ImVec1_ImVec1_Float(float _x); +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_Nil(void); +CIMGUI_API void ImVec2ih_destroy(ImVec2ih* self); +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_short(short _x,short _y); +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_Vec2(const ImVec2 rhs); +CIMGUI_API ImRect* ImRect_ImRect_Nil(void); +CIMGUI_API void ImRect_destroy(ImRect* self); +CIMGUI_API ImRect* ImRect_ImRect_Vec2(const ImVec2 min,const ImVec2 max); +CIMGUI_API ImRect* ImRect_ImRect_Vec4(const ImVec4 v); +CIMGUI_API ImRect* ImRect_ImRect_Float(float x1,float y1,float x2,float y2); +CIMGUI_API void ImRect_GetCenter(ImVec2 *pOut,ImRect* self); +CIMGUI_API void ImRect_GetSize(ImVec2 *pOut,ImRect* self); +CIMGUI_API float ImRect_GetWidth(ImRect* self); +CIMGUI_API float ImRect_GetHeight(ImRect* self); +CIMGUI_API float ImRect_GetArea(ImRect* self); +CIMGUI_API void ImRect_GetTL(ImVec2 *pOut,ImRect* self); +CIMGUI_API void ImRect_GetTR(ImVec2 *pOut,ImRect* self); +CIMGUI_API void ImRect_GetBL(ImVec2 *pOut,ImRect* self); +CIMGUI_API void ImRect_GetBR(ImVec2 *pOut,ImRect* self); +CIMGUI_API bool ImRect_Contains_Vec2(ImRect* self,const ImVec2 p); +CIMGUI_API bool ImRect_Contains_Rect(ImRect* self,const ImRect r); +CIMGUI_API bool ImRect_Overlaps(ImRect* self,const ImRect r); +CIMGUI_API void ImRect_Add_Vec2(ImRect* self,const ImVec2 p); +CIMGUI_API void ImRect_Add_Rect(ImRect* self,const ImRect r); +CIMGUI_API void ImRect_Expand_Float(ImRect* self,const float amount); +CIMGUI_API void ImRect_Expand_Vec2(ImRect* self,const ImVec2 amount); +CIMGUI_API void ImRect_Translate(ImRect* self,const ImVec2 d); +CIMGUI_API void ImRect_TranslateX(ImRect* self,float dx); +CIMGUI_API void ImRect_TranslateY(ImRect* self,float dy); +CIMGUI_API void ImRect_ClipWith(ImRect* self,const ImRect r); +CIMGUI_API void ImRect_ClipWithFull(ImRect* self,const ImRect r); +CIMGUI_API void ImRect_Floor(ImRect* self); +CIMGUI_API bool ImRect_IsInverted(ImRect* self); +CIMGUI_API void ImRect_ToVec4(ImVec4 *pOut,ImRect* self); +CIMGUI_API bool igImBitArrayTestBit(const ImU32* arr,int n); +CIMGUI_API void igImBitArrayClearBit(ImU32* arr,int n); +CIMGUI_API void igImBitArraySetBit(ImU32* arr,int n); +CIMGUI_API void igImBitArraySetBitRange(ImU32* arr,int n,int n2); +CIMGUI_API void ImBitVector_Create(ImBitVector* self,int sz); +CIMGUI_API void ImBitVector_Clear(ImBitVector* self); +CIMGUI_API bool ImBitVector_TestBit(ImBitVector* self,int n); +CIMGUI_API void ImBitVector_SetBit(ImBitVector* self,int n); +CIMGUI_API void ImBitVector_ClearBit(ImBitVector* self,int n); +CIMGUI_API ImDrawListSharedData* ImDrawListSharedData_ImDrawListSharedData(void); +CIMGUI_API void ImDrawListSharedData_destroy(ImDrawListSharedData* self); +CIMGUI_API void ImDrawListSharedData_SetCircleTessellationMaxError(ImDrawListSharedData* self,float max_error); +CIMGUI_API void ImDrawDataBuilder_Clear(ImDrawDataBuilder* self); +CIMGUI_API void ImDrawDataBuilder_ClearFreeMemory(ImDrawDataBuilder* self); +CIMGUI_API int ImDrawDataBuilder_GetDrawListCount(ImDrawDataBuilder* self); +CIMGUI_API void ImDrawDataBuilder_FlattenIntoSingleLayer(ImDrawDataBuilder* self); +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Int(ImGuiStyleVar idx,int v); +CIMGUI_API void ImGuiStyleMod_destroy(ImGuiStyleMod* self); +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Float(ImGuiStyleVar idx,float v); +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Vec2(ImGuiStyleVar idx,ImVec2 v); +CIMGUI_API ImGuiComboPreviewData* ImGuiComboPreviewData_ImGuiComboPreviewData(void); +CIMGUI_API void ImGuiComboPreviewData_destroy(ImGuiComboPreviewData* self); +CIMGUI_API ImGuiMenuColumns* ImGuiMenuColumns_ImGuiMenuColumns(void); +CIMGUI_API void ImGuiMenuColumns_destroy(ImGuiMenuColumns* self); +CIMGUI_API void ImGuiMenuColumns_Update(ImGuiMenuColumns* self,float spacing,bool window_reappearing); +CIMGUI_API float ImGuiMenuColumns_DeclColumns(ImGuiMenuColumns* self,float w_icon,float w_label,float w_shortcut,float w_mark); +CIMGUI_API void ImGuiMenuColumns_CalcNextTotalWidth(ImGuiMenuColumns* self,bool update_offsets); +CIMGUI_API ImGuiInputTextState* ImGuiInputTextState_ImGuiInputTextState(void); +CIMGUI_API void ImGuiInputTextState_destroy(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_ClearText(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_ClearFreeMemory(ImGuiInputTextState* self); +CIMGUI_API int ImGuiInputTextState_GetUndoAvailCount(ImGuiInputTextState* self); +CIMGUI_API int ImGuiInputTextState_GetRedoAvailCount(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_OnKeyPressed(ImGuiInputTextState* self,int key); +CIMGUI_API void ImGuiInputTextState_CursorAnimReset(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_CursorClamp(ImGuiInputTextState* self); +CIMGUI_API bool ImGuiInputTextState_HasSelection(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_ClearSelection(ImGuiInputTextState* self); +CIMGUI_API int ImGuiInputTextState_GetCursorPos(ImGuiInputTextState* self); +CIMGUI_API int ImGuiInputTextState_GetSelectionStart(ImGuiInputTextState* self); +CIMGUI_API int ImGuiInputTextState_GetSelectionEnd(ImGuiInputTextState* self); +CIMGUI_API void ImGuiInputTextState_SelectAll(ImGuiInputTextState* self); +CIMGUI_API ImGuiPopupData* ImGuiPopupData_ImGuiPopupData(void); +CIMGUI_API void ImGuiPopupData_destroy(ImGuiPopupData* self); +CIMGUI_API ImGuiNavItemData* ImGuiNavItemData_ImGuiNavItemData(void); +CIMGUI_API void ImGuiNavItemData_destroy(ImGuiNavItemData* self); +CIMGUI_API void ImGuiNavItemData_Clear(ImGuiNavItemData* self); +CIMGUI_API ImGuiNextWindowData* ImGuiNextWindowData_ImGuiNextWindowData(void); +CIMGUI_API void ImGuiNextWindowData_destroy(ImGuiNextWindowData* self); +CIMGUI_API void ImGuiNextWindowData_ClearFlags(ImGuiNextWindowData* self); +CIMGUI_API ImGuiNextItemData* ImGuiNextItemData_ImGuiNextItemData(void); +CIMGUI_API void ImGuiNextItemData_destroy(ImGuiNextItemData* self); +CIMGUI_API void ImGuiNextItemData_ClearFlags(ImGuiNextItemData* self); +CIMGUI_API ImGuiLastItemData* ImGuiLastItemData_ImGuiLastItemData(void); +CIMGUI_API void ImGuiLastItemData_destroy(ImGuiLastItemData* self); +CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndex_Ptr(void* ptr); +CIMGUI_API void ImGuiPtrOrIndex_destroy(ImGuiPtrOrIndex* self); +CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndex_Int(int index); +CIMGUI_API ImGuiOldColumnData* ImGuiOldColumnData_ImGuiOldColumnData(void); +CIMGUI_API void ImGuiOldColumnData_destroy(ImGuiOldColumnData* self); +CIMGUI_API ImGuiOldColumns* ImGuiOldColumns_ImGuiOldColumns(void); +CIMGUI_API void ImGuiOldColumns_destroy(ImGuiOldColumns* self); +CIMGUI_API ImGuiViewportP* ImGuiViewportP_ImGuiViewportP(void); +CIMGUI_API void ImGuiViewportP_destroy(ImGuiViewportP* self); +CIMGUI_API void ImGuiViewportP_CalcWorkRectPos(ImVec2 *pOut,ImGuiViewportP* self,const ImVec2 off_min); +CIMGUI_API void ImGuiViewportP_CalcWorkRectSize(ImVec2 *pOut,ImGuiViewportP* self,const ImVec2 off_min,const ImVec2 off_max); +CIMGUI_API void ImGuiViewportP_UpdateWorkRect(ImGuiViewportP* self); +CIMGUI_API void ImGuiViewportP_GetMainRect(ImRect *pOut,ImGuiViewportP* self); +CIMGUI_API void ImGuiViewportP_GetWorkRect(ImRect *pOut,ImGuiViewportP* self); +CIMGUI_API void ImGuiViewportP_GetBuildWorkRect(ImRect *pOut,ImGuiViewportP* self); +CIMGUI_API ImGuiWindowSettings* ImGuiWindowSettings_ImGuiWindowSettings(void); +CIMGUI_API void ImGuiWindowSettings_destroy(ImGuiWindowSettings* self); +CIMGUI_API char* ImGuiWindowSettings_GetName(ImGuiWindowSettings* self); +CIMGUI_API ImGuiSettingsHandler* ImGuiSettingsHandler_ImGuiSettingsHandler(void); +CIMGUI_API void ImGuiSettingsHandler_destroy(ImGuiSettingsHandler* self); +CIMGUI_API ImGuiMetricsConfig* ImGuiMetricsConfig_ImGuiMetricsConfig(void); +CIMGUI_API void ImGuiMetricsConfig_destroy(ImGuiMetricsConfig* self); +CIMGUI_API ImGuiStackSizes* ImGuiStackSizes_ImGuiStackSizes(void); +CIMGUI_API void ImGuiStackSizes_destroy(ImGuiStackSizes* self); +CIMGUI_API void ImGuiStackSizes_SetToCurrentState(ImGuiStackSizes* self); +CIMGUI_API void ImGuiStackSizes_CompareWithCurrentState(ImGuiStackSizes* self); +CIMGUI_API ImGuiContextHook* ImGuiContextHook_ImGuiContextHook(void); +CIMGUI_API void ImGuiContextHook_destroy(ImGuiContextHook* self); +CIMGUI_API ImGuiContext* ImGuiContext_ImGuiContext(ImFontAtlas* shared_font_atlas); +CIMGUI_API void ImGuiContext_destroy(ImGuiContext* self); +CIMGUI_API ImGuiWindow* ImGuiWindow_ImGuiWindow(ImGuiContext* context,const char* name); +CIMGUI_API void ImGuiWindow_destroy(ImGuiWindow* self); +CIMGUI_API ImGuiID ImGuiWindow_GetID_Str(ImGuiWindow* self,const char* str,const char* str_end); +CIMGUI_API ImGuiID ImGuiWindow_GetID_Ptr(ImGuiWindow* self,const void* ptr); +CIMGUI_API ImGuiID ImGuiWindow_GetID_Int(ImGuiWindow* self,int n); +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Str(ImGuiWindow* self,const char* str,const char* str_end); +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Ptr(ImGuiWindow* self,const void* ptr); +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Int(ImGuiWindow* self,int n); +CIMGUI_API ImGuiID ImGuiWindow_GetIDFromRectangle(ImGuiWindow* self,const ImRect r_abs); +CIMGUI_API void ImGuiWindow_Rect(ImRect *pOut,ImGuiWindow* self); +CIMGUI_API float ImGuiWindow_CalcFontSize(ImGuiWindow* self); +CIMGUI_API float ImGuiWindow_TitleBarHeight(ImGuiWindow* self); +CIMGUI_API void ImGuiWindow_TitleBarRect(ImRect *pOut,ImGuiWindow* self); +CIMGUI_API float ImGuiWindow_MenuBarHeight(ImGuiWindow* self); +CIMGUI_API void ImGuiWindow_MenuBarRect(ImRect *pOut,ImGuiWindow* self); +CIMGUI_API ImGuiTabItem* ImGuiTabItem_ImGuiTabItem(void); +CIMGUI_API void ImGuiTabItem_destroy(ImGuiTabItem* self); +CIMGUI_API ImGuiTabBar* ImGuiTabBar_ImGuiTabBar(void); +CIMGUI_API void ImGuiTabBar_destroy(ImGuiTabBar* self); +CIMGUI_API int ImGuiTabBar_GetTabOrder(ImGuiTabBar* self,const ImGuiTabItem* tab); +CIMGUI_API const char* ImGuiTabBar_GetTabName(ImGuiTabBar* self,const ImGuiTabItem* tab); +CIMGUI_API ImGuiTableColumn* ImGuiTableColumn_ImGuiTableColumn(void); +CIMGUI_API void ImGuiTableColumn_destroy(ImGuiTableColumn* self); +CIMGUI_API ImGuiTable* ImGuiTable_ImGuiTable(void); +CIMGUI_API void ImGuiTable_destroy(ImGuiTable* self); +CIMGUI_API ImGuiTableTempData* ImGuiTableTempData_ImGuiTableTempData(void); +CIMGUI_API void ImGuiTableTempData_destroy(ImGuiTableTempData* self); +CIMGUI_API ImGuiTableColumnSettings* ImGuiTableColumnSettings_ImGuiTableColumnSettings(void); +CIMGUI_API void ImGuiTableColumnSettings_destroy(ImGuiTableColumnSettings* self); +CIMGUI_API ImGuiTableSettings* ImGuiTableSettings_ImGuiTableSettings(void); +CIMGUI_API void ImGuiTableSettings_destroy(ImGuiTableSettings* self); +CIMGUI_API ImGuiTableColumnSettings* ImGuiTableSettings_GetColumnSettings(ImGuiTableSettings* self); +CIMGUI_API ImGuiWindow* igGetCurrentWindowRead(void); +CIMGUI_API ImGuiWindow* igGetCurrentWindow(void); +CIMGUI_API ImGuiWindow* igFindWindowByID(ImGuiID id); +CIMGUI_API ImGuiWindow* igFindWindowByName(const char* name); +CIMGUI_API void igUpdateWindowParentAndRootLinks(ImGuiWindow* window,ImGuiWindowFlags flags,ImGuiWindow* parent_window); +CIMGUI_API void igCalcWindowNextAutoFitSize(ImVec2 *pOut,ImGuiWindow* window); +CIMGUI_API bool igIsWindowChildOf(ImGuiWindow* window,ImGuiWindow* potential_parent); +CIMGUI_API bool igIsWindowAbove(ImGuiWindow* potential_above,ImGuiWindow* potential_below); +CIMGUI_API bool igIsWindowNavFocusable(ImGuiWindow* window); +CIMGUI_API void igSetWindowPos_WindowPtr(ImGuiWindow* window,const ImVec2 pos,ImGuiCond cond); +CIMGUI_API void igSetWindowSize_WindowPtr(ImGuiWindow* window,const ImVec2 size,ImGuiCond cond); +CIMGUI_API void igSetWindowCollapsed_WindowPtr(ImGuiWindow* window,bool collapsed,ImGuiCond cond); +CIMGUI_API void igSetWindowHitTestHole(ImGuiWindow* window,const ImVec2 pos,const ImVec2 size); +CIMGUI_API void igFocusWindow(ImGuiWindow* window); +CIMGUI_API void igFocusTopMostWindowUnderOne(ImGuiWindow* under_this_window,ImGuiWindow* ignore_window); +CIMGUI_API void igBringWindowToFocusFront(ImGuiWindow* window); +CIMGUI_API void igBringWindowToDisplayFront(ImGuiWindow* window); +CIMGUI_API void igBringWindowToDisplayBack(ImGuiWindow* window); +CIMGUI_API void igSetCurrentFont(ImFont* font); +CIMGUI_API ImFont* igGetDefaultFont(void); +CIMGUI_API ImDrawList* igGetForegroundDrawList_WindowPtr(ImGuiWindow* window); +CIMGUI_API ImDrawList* igGetBackgroundDrawList_ViewportPtr(ImGuiViewport* viewport); +CIMGUI_API ImDrawList* igGetForegroundDrawList_ViewportPtr(ImGuiViewport* viewport); +CIMGUI_API void igInitialize(ImGuiContext* context); +CIMGUI_API void igShutdown(ImGuiContext* context); +CIMGUI_API void igUpdateHoveredWindowAndCaptureFlags(void); +CIMGUI_API void igStartMouseMovingWindow(ImGuiWindow* window); +CIMGUI_API void igUpdateMouseMovingWindowNewFrame(void); +CIMGUI_API void igUpdateMouseMovingWindowEndFrame(void); +CIMGUI_API ImGuiID igAddContextHook(ImGuiContext* context,const ImGuiContextHook* hook); +CIMGUI_API void igRemoveContextHook(ImGuiContext* context,ImGuiID hook_to_remove); +CIMGUI_API void igCallContextHooks(ImGuiContext* context,ImGuiContextHookType type); +CIMGUI_API void igMarkIniSettingsDirty_Nil(void); +CIMGUI_API void igMarkIniSettingsDirty_WindowPtr(ImGuiWindow* window); +CIMGUI_API void igClearIniSettings(void); +CIMGUI_API ImGuiWindowSettings* igCreateNewWindowSettings(const char* name); +CIMGUI_API ImGuiWindowSettings* igFindWindowSettings(ImGuiID id); +CIMGUI_API ImGuiWindowSettings* igFindOrCreateWindowSettings(const char* name); +CIMGUI_API ImGuiSettingsHandler* igFindSettingsHandler(const char* type_name); +CIMGUI_API void igSetNextWindowScroll(const ImVec2 scroll); +CIMGUI_API void igSetScrollX_WindowPtr(ImGuiWindow* window,float scroll_x); +CIMGUI_API void igSetScrollY_WindowPtr(ImGuiWindow* window,float scroll_y); +CIMGUI_API void igSetScrollFromPosX_WindowPtr(ImGuiWindow* window,float local_x,float center_x_ratio); +CIMGUI_API void igSetScrollFromPosY_WindowPtr(ImGuiWindow* window,float local_y,float center_y_ratio); +CIMGUI_API void igScrollToBringRectIntoView(ImVec2 *pOut,ImGuiWindow* window,const ImRect item_rect); +CIMGUI_API ImGuiID igGetItemID(void); +CIMGUI_API ImGuiItemStatusFlags igGetItemStatusFlags(void); +CIMGUI_API ImGuiItemFlags igGetItemFlags(void); +CIMGUI_API ImGuiID igGetActiveID(void); +CIMGUI_API ImGuiID igGetFocusID(void); +CIMGUI_API void igSetActiveID(ImGuiID id,ImGuiWindow* window); +CIMGUI_API void igSetFocusID(ImGuiID id,ImGuiWindow* window); +CIMGUI_API void igClearActiveID(void); +CIMGUI_API ImGuiID igGetHoveredID(void); +CIMGUI_API void igSetHoveredID(ImGuiID id); +CIMGUI_API void igKeepAliveID(ImGuiID id); +CIMGUI_API void igMarkItemEdited(ImGuiID id); +CIMGUI_API void igPushOverrideID(ImGuiID id); +CIMGUI_API ImGuiID igGetIDWithSeed(const char* str_id_begin,const char* str_id_end,ImGuiID seed); +CIMGUI_API void igItemSize_Vec2(const ImVec2 size,float text_baseline_y); +CIMGUI_API void igItemSize_Rect(const ImRect bb,float text_baseline_y); +CIMGUI_API bool igItemAdd(const ImRect bb,ImGuiID id,const ImRect* nav_bb,ImGuiItemAddFlags flags); +CIMGUI_API bool igItemHoverable(const ImRect bb,ImGuiID id); +CIMGUI_API void igItemFocusable(ImGuiWindow* window,ImGuiID id); +CIMGUI_API bool igIsClippedEx(const ImRect bb,ImGuiID id,bool clip_even_when_logged); +CIMGUI_API void igCalcItemSize(ImVec2 *pOut,ImVec2 size,float default_w,float default_h); +CIMGUI_API float igCalcWrapWidthForPos(const ImVec2 pos,float wrap_pos_x); +CIMGUI_API void igPushMultiItemsWidths(int components,float width_full); +CIMGUI_API bool igIsItemToggledSelection(void); +CIMGUI_API void igGetContentRegionMaxAbs(ImVec2 *pOut); +CIMGUI_API void igShrinkWidths(ImGuiShrinkWidthItem* items,int count,float width_excess); +CIMGUI_API void igPushItemFlag(ImGuiItemFlags option,bool enabled); +CIMGUI_API void igPopItemFlag(void); +CIMGUI_API void igLogBegin(ImGuiLogType type,int auto_open_depth); +CIMGUI_API void igLogToBuffer(int auto_open_depth); +CIMGUI_API void igLogRenderedText(const ImVec2* ref_pos,const char* text,const char* text_end); +CIMGUI_API void igLogSetNextTextDecoration(const char* prefix,const char* suffix); +CIMGUI_API bool igBeginChildEx(const char* name,ImGuiID id,const ImVec2 size_arg,bool border,ImGuiWindowFlags flags); +CIMGUI_API void igOpenPopupEx(ImGuiID id,ImGuiPopupFlags popup_flags); +CIMGUI_API void igClosePopupToLevel(int remaining,bool restore_focus_to_window_under_popup); +CIMGUI_API void igClosePopupsOverWindow(ImGuiWindow* ref_window,bool restore_focus_to_window_under_popup); +CIMGUI_API bool igIsPopupOpen_ID(ImGuiID id,ImGuiPopupFlags popup_flags); +CIMGUI_API bool igBeginPopupEx(ImGuiID id,ImGuiWindowFlags extra_flags); +CIMGUI_API void igBeginTooltipEx(ImGuiWindowFlags extra_flags,ImGuiTooltipFlags tooltip_flags); +CIMGUI_API void igGetPopupAllowedExtentRect(ImRect *pOut,ImGuiWindow* window); +CIMGUI_API ImGuiWindow* igGetTopMostPopupModal(void); +CIMGUI_API void igFindBestWindowPosForPopup(ImVec2 *pOut,ImGuiWindow* window); +CIMGUI_API void igFindBestWindowPosForPopupEx(ImVec2 *pOut,const ImVec2 ref_pos,const ImVec2 size,ImGuiDir* last_dir,const ImRect r_outer,const ImRect r_avoid,ImGuiPopupPositionPolicy policy); +CIMGUI_API bool igBeginViewportSideBar(const char* name,ImGuiViewport* viewport,ImGuiDir dir,float size,ImGuiWindowFlags window_flags); +CIMGUI_API bool igMenuItemEx(const char* label,const char* icon,const char* shortcut,bool selected,bool enabled); +CIMGUI_API bool igBeginComboPopup(ImGuiID popup_id,const ImRect bb,ImGuiComboFlags flags); +CIMGUI_API bool igBeginComboPreview(void); +CIMGUI_API void igEndComboPreview(void); +CIMGUI_API void igNavInitWindow(ImGuiWindow* window,bool force_reinit); +CIMGUI_API bool igNavMoveRequestButNoResultYet(void); +CIMGUI_API void igNavMoveRequestCancel(void); +CIMGUI_API void igNavMoveRequestForward(ImGuiDir move_dir,ImGuiDir clip_dir,const ImRect bb_rel,ImGuiNavMoveFlags move_flags); +CIMGUI_API void igNavMoveRequestTryWrapping(ImGuiWindow* window,ImGuiNavMoveFlags move_flags); +CIMGUI_API float igGetNavInputAmount(ImGuiNavInput n,ImGuiInputReadMode mode); +CIMGUI_API void igGetNavInputAmount2d(ImVec2 *pOut,ImGuiNavDirSourceFlags dir_sources,ImGuiInputReadMode mode,float slow_factor,float fast_factor); +CIMGUI_API int igCalcTypematicRepeatAmount(float t0,float t1,float repeat_delay,float repeat_rate); +CIMGUI_API void igActivateItem(ImGuiID id); +CIMGUI_API void igSetNavID(ImGuiID id,ImGuiNavLayer nav_layer,ImGuiID focus_scope_id,const ImRect rect_rel); +CIMGUI_API void igPushFocusScope(ImGuiID id); +CIMGUI_API void igPopFocusScope(void); +CIMGUI_API ImGuiID igGetFocusedFocusScope(void); +CIMGUI_API ImGuiID igGetFocusScope(void); +CIMGUI_API void igSetItemUsingMouseWheel(void); +CIMGUI_API void igSetActiveIdUsingNavAndKeys(void); +CIMGUI_API bool igIsActiveIdUsingNavDir(ImGuiDir dir); +CIMGUI_API bool igIsActiveIdUsingNavInput(ImGuiNavInput input); +CIMGUI_API bool igIsActiveIdUsingKey(ImGuiKey key); +CIMGUI_API bool igIsMouseDragPastThreshold(ImGuiMouseButton button,float lock_threshold); +CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat); +CIMGUI_API bool igIsNavInputDown(ImGuiNavInput n); +CIMGUI_API bool igIsNavInputTest(ImGuiNavInput n,ImGuiInputReadMode rm); +CIMGUI_API ImGuiKeyModFlags igGetMergedKeyModFlags(void); +CIMGUI_API bool igBeginDragDropTargetCustom(const ImRect bb,ImGuiID id); +CIMGUI_API void igClearDragDrop(void); +CIMGUI_API bool igIsDragDropPayloadBeingAccepted(void); +CIMGUI_API void igSetWindowClipRectBeforeSetChannel(ImGuiWindow* window,const ImRect clip_rect); +CIMGUI_API void igBeginColumns(const char* str_id,int count,ImGuiOldColumnFlags flags); +CIMGUI_API void igEndColumns(void); +CIMGUI_API void igPushColumnClipRect(int column_index); +CIMGUI_API void igPushColumnsBackground(void); +CIMGUI_API void igPopColumnsBackground(void); +CIMGUI_API ImGuiID igGetColumnsID(const char* str_id,int count); +CIMGUI_API ImGuiOldColumns* igFindOrCreateColumns(ImGuiWindow* window,ImGuiID id); +CIMGUI_API float igGetColumnOffsetFromNorm(const ImGuiOldColumns* columns,float offset_norm); +CIMGUI_API float igGetColumnNormFromOffset(const ImGuiOldColumns* columns,float offset); +CIMGUI_API void igTableOpenContextMenu(int column_n); +CIMGUI_API void igTableSetColumnWidth(int column_n,float width); +CIMGUI_API void igTableSetColumnSortDirection(int column_n,ImGuiSortDirection sort_direction,bool append_to_sort_specs); +CIMGUI_API int igTableGetHoveredColumn(void); +CIMGUI_API float igTableGetHeaderRowHeight(void); +CIMGUI_API void igTablePushBackgroundChannel(void); +CIMGUI_API void igTablePopBackgroundChannel(void); +CIMGUI_API ImGuiTable* igGetCurrentTable(void); +CIMGUI_API ImGuiTable* igTableFindByID(ImGuiID id); +CIMGUI_API bool igBeginTableEx(const char* name,ImGuiID id,int columns_count,ImGuiTableFlags flags,const ImVec2 outer_size,float inner_width); +CIMGUI_API void igTableBeginInitMemory(ImGuiTable* table,int columns_count); +CIMGUI_API void igTableBeginApplyRequests(ImGuiTable* table); +CIMGUI_API void igTableSetupDrawChannels(ImGuiTable* table); +CIMGUI_API void igTableUpdateLayout(ImGuiTable* table); +CIMGUI_API void igTableUpdateBorders(ImGuiTable* table); +CIMGUI_API void igTableUpdateColumnsWeightFromWidth(ImGuiTable* table); +CIMGUI_API void igTableDrawBorders(ImGuiTable* table); +CIMGUI_API void igTableDrawContextMenu(ImGuiTable* table); +CIMGUI_API void igTableMergeDrawChannels(ImGuiTable* table); +CIMGUI_API void igTableSortSpecsSanitize(ImGuiTable* table); +CIMGUI_API void igTableSortSpecsBuild(ImGuiTable* table); +CIMGUI_API ImGuiSortDirection igTableGetColumnNextSortDirection(ImGuiTableColumn* column); +CIMGUI_API void igTableFixColumnSortDirection(ImGuiTable* table,ImGuiTableColumn* column); +CIMGUI_API float igTableGetColumnWidthAuto(ImGuiTable* table,ImGuiTableColumn* column); +CIMGUI_API void igTableBeginRow(ImGuiTable* table); +CIMGUI_API void igTableEndRow(ImGuiTable* table); +CIMGUI_API void igTableBeginCell(ImGuiTable* table,int column_n); +CIMGUI_API void igTableEndCell(ImGuiTable* table); +CIMGUI_API void igTableGetCellBgRect(ImRect *pOut,const ImGuiTable* table,int column_n); +CIMGUI_API const char* igTableGetColumnName_TablePtr(const ImGuiTable* table,int column_n); +CIMGUI_API ImGuiID igTableGetColumnResizeID(const ImGuiTable* table,int column_n,int instance_no); +CIMGUI_API float igTableGetMaxColumnWidth(const ImGuiTable* table,int column_n); +CIMGUI_API void igTableSetColumnWidthAutoSingle(ImGuiTable* table,int column_n); +CIMGUI_API void igTableSetColumnWidthAutoAll(ImGuiTable* table); +CIMGUI_API void igTableRemove(ImGuiTable* table); +CIMGUI_API void igTableGcCompactTransientBuffers_TablePtr(ImGuiTable* table); +CIMGUI_API void igTableGcCompactTransientBuffers_TableTempDataPtr(ImGuiTableTempData* table); +CIMGUI_API void igTableGcCompactSettings(void); +CIMGUI_API void igTableLoadSettings(ImGuiTable* table); +CIMGUI_API void igTableSaveSettings(ImGuiTable* table); +CIMGUI_API void igTableResetSettings(ImGuiTable* table); +CIMGUI_API ImGuiTableSettings* igTableGetBoundSettings(ImGuiTable* table); +CIMGUI_API void igTableSettingsInstallHandler(ImGuiContext* context); +CIMGUI_API ImGuiTableSettings* igTableSettingsCreate(ImGuiID id,int columns_count); +CIMGUI_API ImGuiTableSettings* igTableSettingsFindByID(ImGuiID id); +CIMGUI_API bool igBeginTabBarEx(ImGuiTabBar* tab_bar,const ImRect bb,ImGuiTabBarFlags flags,ImGuiDockNode* dock_node); +CIMGUI_API ImGuiTabItem* igTabBarFindTabByID(ImGuiTabBar* tab_bar,ImGuiID tab_id); +CIMGUI_API void igTabBarRemoveTab(ImGuiTabBar* tab_bar,ImGuiID tab_id); +CIMGUI_API void igTabBarCloseTab(ImGuiTabBar* tab_bar,ImGuiTabItem* tab); +CIMGUI_API void igTabBarQueueReorder(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,int offset); +CIMGUI_API void igTabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,ImVec2 mouse_pos); +CIMGUI_API bool igTabBarProcessReorder(ImGuiTabBar* tab_bar); +CIMGUI_API bool igTabItemEx(ImGuiTabBar* tab_bar,const char* label,bool* p_open,ImGuiTabItemFlags flags,ImGuiWindow* docked_window); +CIMGUI_API void igTabItemCalcSize(ImVec2 *pOut,const char* label,bool has_close_button); +CIMGUI_API void igTabItemBackground(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImU32 col); +CIMGUI_API void igTabItemLabelAndCloseButton(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImVec2 frame_padding,const char* label,ImGuiID tab_id,ImGuiID close_button_id,bool is_contents_visible,bool* out_just_closed,bool* out_text_clipped); +CIMGUI_API void igRenderText(ImVec2 pos,const char* text,const char* text_end,bool hide_text_after_hash); +CIMGUI_API void igRenderTextWrapped(ImVec2 pos,const char* text,const char* text_end,float wrap_width); +CIMGUI_API void igRenderTextClipped(const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect); +CIMGUI_API void igRenderTextClippedEx(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect); +CIMGUI_API void igRenderTextEllipsis(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,float clip_max_x,float ellipsis_max_x,const char* text,const char* text_end,const ImVec2* text_size_if_known); +CIMGUI_API void igRenderFrame(ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,bool border,float rounding); +CIMGUI_API void igRenderFrameBorder(ImVec2 p_min,ImVec2 p_max,float rounding); +CIMGUI_API void igRenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list,ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,float grid_step,ImVec2 grid_off,float rounding,ImDrawFlags flags); +CIMGUI_API void igRenderNavHighlight(const ImRect bb,ImGuiID id,ImGuiNavHighlightFlags flags); +CIMGUI_API const char* igFindRenderedTextEnd(const char* text,const char* text_end); +CIMGUI_API void igRenderArrow(ImDrawList* draw_list,ImVec2 pos,ImU32 col,ImGuiDir dir,float scale); +CIMGUI_API void igRenderBullet(ImDrawList* draw_list,ImVec2 pos,ImU32 col); +CIMGUI_API void igRenderCheckMark(ImDrawList* draw_list,ImVec2 pos,ImU32 col,float sz); +CIMGUI_API void igRenderMouseCursor(ImDrawList* draw_list,ImVec2 pos,float scale,ImGuiMouseCursor mouse_cursor,ImU32 col_fill,ImU32 col_border,ImU32 col_shadow); +CIMGUI_API void igRenderArrowPointingAt(ImDrawList* draw_list,ImVec2 pos,ImVec2 half_sz,ImGuiDir direction,ImU32 col); +CIMGUI_API void igRenderRectFilledRangeH(ImDrawList* draw_list,const ImRect rect,ImU32 col,float x_start_norm,float x_end_norm,float rounding); +CIMGUI_API void igRenderRectFilledWithHole(ImDrawList* draw_list,ImRect outer,ImRect inner,ImU32 col,float rounding); +CIMGUI_API void igTextEx(const char* text,const char* text_end,ImGuiTextFlags flags); +CIMGUI_API bool igButtonEx(const char* label,const ImVec2 size_arg,ImGuiButtonFlags flags); +CIMGUI_API bool igCloseButton(ImGuiID id,const ImVec2 pos); +CIMGUI_API bool igCollapseButton(ImGuiID id,const ImVec2 pos,ImGuiDockNode* dock_node); +CIMGUI_API bool igArrowButtonEx(const char* str_id,ImGuiDir dir,ImVec2 size_arg,ImGuiButtonFlags flags); +CIMGUI_API void igScrollbar(ImGuiAxis axis); +CIMGUI_API bool igScrollbarEx(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* p_scroll_v,float avail_v,float contents_v,ImDrawFlags flags); +CIMGUI_API bool igImageButtonEx(ImGuiID id,ImTextureID texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,const ImVec2 padding,const ImVec4 bg_col,const ImVec4 tint_col); +CIMGUI_API void igGetWindowScrollbarRect(ImRect *pOut,ImGuiWindow* window,ImGuiAxis axis); +CIMGUI_API ImGuiID igGetWindowScrollbarID(ImGuiWindow* window,ImGuiAxis axis); +CIMGUI_API ImGuiID igGetWindowResizeCornerID(ImGuiWindow* window,int n); +CIMGUI_API ImGuiID igGetWindowResizeBorderID(ImGuiWindow* window,ImGuiDir dir); +CIMGUI_API void igSeparatorEx(ImGuiSeparatorFlags flags); +CIMGUI_API bool igCheckboxFlags_S64Ptr(const char* label,ImS64* flags,ImS64 flags_value); +CIMGUI_API bool igCheckboxFlags_U64Ptr(const char* label,ImU64* flags,ImU64 flags_value); +CIMGUI_API bool igButtonBehavior(const ImRect bb,ImGuiID id,bool* out_hovered,bool* out_held,ImGuiButtonFlags flags); +CIMGUI_API bool igDragBehavior(ImGuiID id,ImGuiDataType data_type,void* p_v,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags); +CIMGUI_API bool igSliderBehavior(const ImRect bb,ImGuiID id,ImGuiDataType data_type,void* p_v,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags,ImRect* out_grab_bb); +CIMGUI_API bool igSplitterBehavior(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* size1,float* size2,float min_size1,float min_size2,float hover_extend,float hover_visibility_delay); +CIMGUI_API bool igTreeNodeBehavior(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end); +CIMGUI_API bool igTreeNodeBehaviorIsOpen(ImGuiID id,ImGuiTreeNodeFlags flags); +CIMGUI_API void igTreePushOverrideID(ImGuiID id); +CIMGUI_API const ImGuiDataTypeInfo* igDataTypeGetInfo(ImGuiDataType data_type); +CIMGUI_API int igDataTypeFormatString(char* buf,int buf_size,ImGuiDataType data_type,const void* p_data,const char* format); +CIMGUI_API void igDataTypeApplyOp(ImGuiDataType data_type,int op,void* output,const void* arg_1,const void* arg_2); +CIMGUI_API bool igDataTypeApplyOpFromText(const char* buf,const char* initial_value_buf,ImGuiDataType data_type,void* p_data,const char* format); +CIMGUI_API int igDataTypeCompare(ImGuiDataType data_type,const void* arg_1,const void* arg_2); +CIMGUI_API bool igDataTypeClamp(ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max); +CIMGUI_API bool igInputTextEx(const char* label,const char* hint,char* buf,int buf_size,const ImVec2 size_arg,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data); +CIMGUI_API bool igTempInputText(const ImRect bb,ImGuiID id,const char* label,char* buf,int buf_size,ImGuiInputTextFlags flags); +CIMGUI_API bool igTempInputScalar(const ImRect bb,ImGuiID id,const char* label,ImGuiDataType data_type,void* p_data,const char* format,const void* p_clamp_min,const void* p_clamp_max); +CIMGUI_API bool igTempInputIsActive(ImGuiID id); +CIMGUI_API ImGuiInputTextState* igGetInputTextState(ImGuiID id); +CIMGUI_API void igColorTooltip(const char* text,const float* col,ImGuiColorEditFlags flags); +CIMGUI_API void igColorEditOptionsPopup(const float* col,ImGuiColorEditFlags flags); +CIMGUI_API void igColorPickerOptionsPopup(const float* ref_col,ImGuiColorEditFlags flags); +CIMGUI_API int igPlotEx(ImGuiPlotType plot_type,const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 frame_size); +CIMGUI_API void igShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,ImVec2 gradient_p0,ImVec2 gradient_p1,ImU32 col0,ImU32 col1); +CIMGUI_API void igShadeVertsLinearUV(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,bool clamp); +CIMGUI_API void igGcCompactTransientMiscBuffers(void); +CIMGUI_API void igGcCompactTransientWindowBuffers(ImGuiWindow* window); +CIMGUI_API void igGcAwakeTransientWindowBuffers(ImGuiWindow* window); +CIMGUI_API void igErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback,void* user_data); +CIMGUI_API void igDebugDrawItemRect(ImU32 col); +CIMGUI_API void igDebugStartItemPicker(void); +CIMGUI_API void igShowFontAtlas(ImFontAtlas* atlas); +CIMGUI_API void igDebugNodeColumns(ImGuiOldColumns* columns); +CIMGUI_API void igDebugNodeDrawList(ImGuiWindow* window,ImGuiViewportP* viewport,const ImDrawList* draw_list,const char* label); +CIMGUI_API void igDebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list,const ImDrawList* draw_list,const ImDrawCmd* draw_cmd,bool show_mesh,bool show_aabb); +CIMGUI_API void igDebugNodeFont(ImFont* font); +CIMGUI_API void igDebugNodeStorage(ImGuiStorage* storage,const char* label); +CIMGUI_API void igDebugNodeTabBar(ImGuiTabBar* tab_bar,const char* label); +CIMGUI_API void igDebugNodeTable(ImGuiTable* table); +CIMGUI_API void igDebugNodeTableSettings(ImGuiTableSettings* settings); +CIMGUI_API void igDebugNodeWindow(ImGuiWindow* window,const char* label); +CIMGUI_API void igDebugNodeWindowSettings(ImGuiWindowSettings* settings); +CIMGUI_API void igDebugNodeWindowsList(ImVector_ImGuiWindowPtr* windows,const char* label); +CIMGUI_API void igDebugNodeViewport(ImGuiViewportP* viewport); +CIMGUI_API void igDebugRenderViewportThumbnail(ImDrawList* draw_list,ImGuiViewportP* viewport,const ImRect bb); +CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype(void); +CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas); +CIMGUI_API void igImFontAtlasBuildSetupFont(ImFontAtlas* atlas,ImFont* font,ImFontConfig* font_config,float ascent,float descent); +CIMGUI_API void igImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas,void* stbrp_context_opaque); +CIMGUI_API void igImFontAtlasBuildFinish(ImFontAtlas* atlas); +CIMGUI_API void igImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned char in_marker_pixel_value); +CIMGUI_API void igImFontAtlasBuildRender32bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned int in_marker_pixel_value); +CIMGUI_API void igImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256],float in_multiply_factor); +CIMGUI_API void igImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256],unsigned char* pixels,int x,int y,int w,int h,int stride); + + +/////////////////////////hand written functions +//no LogTextV +CIMGUI_API void igLogText(CONST char *fmt, ...); +//no appendfV +CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...); +//for getting FLT_MAX in bindings +CIMGUI_API float igGET_FLT_MAX(); +//for getting FLT_MIN in bindings +CIMGUI_API float igGET_FLT_MIN(); + + +CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create(); +CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self); +CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p); +CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p); + + +#endif //CIMGUI_INCLUDED + + + + diff --git a/external/ImGui/source/cimgui.cpp b/external/ImGui/source/cimgui.cpp new file mode 100644 index 000000000..13eac1748 --- /dev/null +++ b/external/ImGui/source/cimgui.cpp @@ -0,0 +1,4598 @@ +//This file is automatically generated by generator.lua from https://github.com/cimgui/cimgui +//based on imgui.h file version "1.84.1" from Dear ImGui https://github.com/ocornut/imgui +//with imgui_internal.h api + +#include "imgui.h" +#ifdef CIMGUI_FREETYPE +#include "./imgui/misc/freetype/imgui_freetype.h" +#endif +#include "imgui_internal.h" +#include "cimgui.h" + + + +CIMGUI_API ImVec2* ImVec2_ImVec2_Nil(void) +{ + return IM_NEW(ImVec2)(); +} +CIMGUI_API void ImVec2_destroy(ImVec2* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImVec2* ImVec2_ImVec2_Float(float _x,float _y) +{ + return IM_NEW(ImVec2)(_x,_y); +} +CIMGUI_API ImVec4* ImVec4_ImVec4_Nil(void) +{ + return IM_NEW(ImVec4)(); +} +CIMGUI_API void ImVec4_destroy(ImVec4* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImVec4* ImVec4_ImVec4_Float(float _x,float _y,float _z,float _w) +{ + return IM_NEW(ImVec4)(_x,_y,_z,_w); +} +CIMGUI_API ImGuiContext* igCreateContext(ImFontAtlas* shared_font_atlas) +{ + return ImGui::CreateContext(shared_font_atlas); +} +CIMGUI_API void igDestroyContext(ImGuiContext* ctx) +{ + return ImGui::DestroyContext(ctx); +} +CIMGUI_API ImGuiContext* igGetCurrentContext() +{ + return ImGui::GetCurrentContext(); +} +CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx) +{ + return ImGui::SetCurrentContext(ctx); +} +CIMGUI_API ImGuiIO* igGetIO() +{ + return &ImGui::GetIO(); +} +CIMGUI_API ImGuiStyle* igGetStyle() +{ + return &ImGui::GetStyle(); +} +CIMGUI_API void igNewFrame() +{ + return ImGui::NewFrame(); +} +CIMGUI_API void igEndFrame() +{ + return ImGui::EndFrame(); +} +CIMGUI_API void igRender() +{ + return ImGui::Render(); +} +CIMGUI_API ImDrawData* igGetDrawData() +{ + return ImGui::GetDrawData(); +} +CIMGUI_API void igShowDemoWindow(bool* p_open) +{ + return ImGui::ShowDemoWindow(p_open); +} +CIMGUI_API void igShowMetricsWindow(bool* p_open) +{ + return ImGui::ShowMetricsWindow(p_open); +} +CIMGUI_API void igShowAboutWindow(bool* p_open) +{ + return ImGui::ShowAboutWindow(p_open); +} +CIMGUI_API void igShowStyleEditor(ImGuiStyle* ref) +{ + return ImGui::ShowStyleEditor(ref); +} +CIMGUI_API bool igShowStyleSelector(const char* label) +{ + return ImGui::ShowStyleSelector(label); +} +CIMGUI_API void igShowFontSelector(const char* label) +{ + return ImGui::ShowFontSelector(label); +} +CIMGUI_API void igShowUserGuide() +{ + return ImGui::ShowUserGuide(); +} +CIMGUI_API const char* igGetVersion() +{ + return ImGui::GetVersion(); +} +CIMGUI_API void igStyleColorsDark(ImGuiStyle* dst) +{ + return ImGui::StyleColorsDark(dst); +} +CIMGUI_API void igStyleColorsLight(ImGuiStyle* dst) +{ + return ImGui::StyleColorsLight(dst); +} +CIMGUI_API void igStyleColorsClassic(ImGuiStyle* dst) +{ + return ImGui::StyleColorsClassic(dst); +} +CIMGUI_API bool igBegin(const char* name,bool* p_open,ImGuiWindowFlags flags) +{ + return ImGui::Begin(name,p_open,flags); +} +CIMGUI_API void igEnd() +{ + return ImGui::End(); +} +CIMGUI_API bool igBeginChild_Str(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags) +{ + return ImGui::BeginChild(str_id,size,border,flags); +} +CIMGUI_API bool igBeginChild_ID(ImGuiID id,const ImVec2 size,bool border,ImGuiWindowFlags flags) +{ + return ImGui::BeginChild(id,size,border,flags); +} +CIMGUI_API void igEndChild() +{ + return ImGui::EndChild(); +} +CIMGUI_API bool igIsWindowAppearing() +{ + return ImGui::IsWindowAppearing(); +} +CIMGUI_API bool igIsWindowCollapsed() +{ + return ImGui::IsWindowCollapsed(); +} +CIMGUI_API bool igIsWindowFocused(ImGuiFocusedFlags flags) +{ + return ImGui::IsWindowFocused(flags); +} +CIMGUI_API bool igIsWindowHovered(ImGuiHoveredFlags flags) +{ + return ImGui::IsWindowHovered(flags); +} +CIMGUI_API ImDrawList* igGetWindowDrawList() +{ + return ImGui::GetWindowDrawList(); +} +CIMGUI_API void igGetWindowPos(ImVec2 *pOut) +{ + *pOut = ImGui::GetWindowPos(); +} +CIMGUI_API void igGetWindowSize(ImVec2 *pOut) +{ + *pOut = ImGui::GetWindowSize(); +} +CIMGUI_API float igGetWindowWidth() +{ + return ImGui::GetWindowWidth(); +} +CIMGUI_API float igGetWindowHeight() +{ + return ImGui::GetWindowHeight(); +} +CIMGUI_API void igSetNextWindowPos(const ImVec2 pos,ImGuiCond cond,const ImVec2 pivot) +{ + return ImGui::SetNextWindowPos(pos,cond,pivot); +} +CIMGUI_API void igSetNextWindowSize(const ImVec2 size,ImGuiCond cond) +{ + return ImGui::SetNextWindowSize(size,cond); +} +CIMGUI_API void igSetNextWindowSizeConstraints(const ImVec2 size_min,const ImVec2 size_max,ImGuiSizeCallback custom_callback,void* custom_callback_data) +{ + return ImGui::SetNextWindowSizeConstraints(size_min,size_max,custom_callback,custom_callback_data); +} +CIMGUI_API void igSetNextWindowContentSize(const ImVec2 size) +{ + return ImGui::SetNextWindowContentSize(size); +} +CIMGUI_API void igSetNextWindowCollapsed(bool collapsed,ImGuiCond cond) +{ + return ImGui::SetNextWindowCollapsed(collapsed,cond); +} +CIMGUI_API void igSetNextWindowFocus() +{ + return ImGui::SetNextWindowFocus(); +} +CIMGUI_API void igSetNextWindowBgAlpha(float alpha) +{ + return ImGui::SetNextWindowBgAlpha(alpha); +} +CIMGUI_API void igSetWindowPos_Vec2(const ImVec2 pos,ImGuiCond cond) +{ + return ImGui::SetWindowPos(pos,cond); +} +CIMGUI_API void igSetWindowSize_Vec2(const ImVec2 size,ImGuiCond cond) +{ + return ImGui::SetWindowSize(size,cond); +} +CIMGUI_API void igSetWindowCollapsed_Bool(bool collapsed,ImGuiCond cond) +{ + return ImGui::SetWindowCollapsed(collapsed,cond); +} +CIMGUI_API void igSetWindowFocus_Nil() +{ + return ImGui::SetWindowFocus(); +} +CIMGUI_API void igSetWindowFontScale(float scale) +{ + return ImGui::SetWindowFontScale(scale); +} +CIMGUI_API void igSetWindowPos_Str(const char* name,const ImVec2 pos,ImGuiCond cond) +{ + return ImGui::SetWindowPos(name,pos,cond); +} +CIMGUI_API void igSetWindowSize_Str(const char* name,const ImVec2 size,ImGuiCond cond) +{ + return ImGui::SetWindowSize(name,size,cond); +} +CIMGUI_API void igSetWindowCollapsed_Str(const char* name,bool collapsed,ImGuiCond cond) +{ + return ImGui::SetWindowCollapsed(name,collapsed,cond); +} +CIMGUI_API void igSetWindowFocus_Str(const char* name) +{ + return ImGui::SetWindowFocus(name); +} +CIMGUI_API void igGetContentRegionAvail(ImVec2 *pOut) +{ + *pOut = ImGui::GetContentRegionAvail(); +} +CIMGUI_API void igGetContentRegionMax(ImVec2 *pOut) +{ + *pOut = ImGui::GetContentRegionMax(); +} +CIMGUI_API void igGetWindowContentRegionMin(ImVec2 *pOut) +{ + *pOut = ImGui::GetWindowContentRegionMin(); +} +CIMGUI_API void igGetWindowContentRegionMax(ImVec2 *pOut) +{ + *pOut = ImGui::GetWindowContentRegionMax(); +} +CIMGUI_API float igGetWindowContentRegionWidth() +{ + return ImGui::GetWindowContentRegionWidth(); +} +CIMGUI_API float igGetScrollX() +{ + return ImGui::GetScrollX(); +} +CIMGUI_API float igGetScrollY() +{ + return ImGui::GetScrollY(); +} +CIMGUI_API void igSetScrollX(float scroll_x) +{ + return ImGui::SetScrollX(scroll_x); +} +CIMGUI_API void igSetScrollY(float scroll_y) +{ + return ImGui::SetScrollY(scroll_y); +} +CIMGUI_API float igGetScrollMaxX() +{ + return ImGui::GetScrollMaxX(); +} +CIMGUI_API float igGetScrollMaxY() +{ + return ImGui::GetScrollMaxY(); +} +CIMGUI_API void igSetScrollHereX(float center_x_ratio) +{ + return ImGui::SetScrollHereX(center_x_ratio); +} +CIMGUI_API void igSetScrollHereY(float center_y_ratio) +{ + return ImGui::SetScrollHereY(center_y_ratio); +} +CIMGUI_API void igSetScrollFromPosX(float local_x,float center_x_ratio) +{ + return ImGui::SetScrollFromPosX(local_x,center_x_ratio); +} +CIMGUI_API void igSetScrollFromPosY(float local_y,float center_y_ratio) +{ + return ImGui::SetScrollFromPosY(local_y,center_y_ratio); +} +CIMGUI_API void igPushFont(ImFont* font) +{ + return ImGui::PushFont(font); +} +CIMGUI_API void igPopFont() +{ + return ImGui::PopFont(); +} +CIMGUI_API void igPushStyleColor_U32(ImGuiCol idx,ImU32 col) +{ + return ImGui::PushStyleColor(idx,col); +} +CIMGUI_API void igPushStyleColor_Vec4(ImGuiCol idx,const ImVec4 col) +{ + return ImGui::PushStyleColor(idx,col); +} +CIMGUI_API void igPopStyleColor(int count) +{ + return ImGui::PopStyleColor(count); +} +CIMGUI_API void igPushStyleVar_Float(ImGuiStyleVar idx,float val) +{ + return ImGui::PushStyleVar(idx,val); +} +CIMGUI_API void igPushStyleVar_Vec2(ImGuiStyleVar idx,const ImVec2 val) +{ + return ImGui::PushStyleVar(idx,val); +} +CIMGUI_API void igPopStyleVar(int count) +{ + return ImGui::PopStyleVar(count); +} +CIMGUI_API void igPushAllowKeyboardFocus(bool allow_keyboard_focus) +{ + return ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); +} +CIMGUI_API void igPopAllowKeyboardFocus() +{ + return ImGui::PopAllowKeyboardFocus(); +} +CIMGUI_API void igPushButtonRepeat(bool repeat) +{ + return ImGui::PushButtonRepeat(repeat); +} +CIMGUI_API void igPopButtonRepeat() +{ + return ImGui::PopButtonRepeat(); +} +CIMGUI_API void igPushItemWidth(float item_width) +{ + return ImGui::PushItemWidth(item_width); +} +CIMGUI_API void igPopItemWidth() +{ + return ImGui::PopItemWidth(); +} +CIMGUI_API void igSetNextItemWidth(float item_width) +{ + return ImGui::SetNextItemWidth(item_width); +} +CIMGUI_API float igCalcItemWidth() +{ + return ImGui::CalcItemWidth(); +} +CIMGUI_API void igPushTextWrapPos(float wrap_local_pos_x) +{ + return ImGui::PushTextWrapPos(wrap_local_pos_x); +} +CIMGUI_API void igPopTextWrapPos() +{ + return ImGui::PopTextWrapPos(); +} +CIMGUI_API ImFont* igGetFont() +{ + return ImGui::GetFont(); +} +CIMGUI_API float igGetFontSize() +{ + return ImGui::GetFontSize(); +} +CIMGUI_API void igGetFontTexUvWhitePixel(ImVec2 *pOut) +{ + *pOut = ImGui::GetFontTexUvWhitePixel(); +} +CIMGUI_API ImU32 igGetColorU32_Col(ImGuiCol idx,float alpha_mul) +{ + return ImGui::GetColorU32(idx,alpha_mul); +} +CIMGUI_API ImU32 igGetColorU32_Vec4(const ImVec4 col) +{ + return ImGui::GetColorU32(col); +} +CIMGUI_API ImU32 igGetColorU32_U32(ImU32 col) +{ + return ImGui::GetColorU32(col); +} +CIMGUI_API const ImVec4* igGetStyleColorVec4(ImGuiCol idx) +{ + return &ImGui::GetStyleColorVec4(idx); +} +CIMGUI_API void igSeparator() +{ + return ImGui::Separator(); +} +CIMGUI_API void igSameLine(float offset_from_start_x,float spacing) +{ + return ImGui::SameLine(offset_from_start_x,spacing); +} +CIMGUI_API void igNewLine() +{ + return ImGui::NewLine(); +} +CIMGUI_API void igSpacing() +{ + return ImGui::Spacing(); +} +CIMGUI_API void igDummy(const ImVec2 size) +{ + return ImGui::Dummy(size); +} +CIMGUI_API void igIndent(float indent_w) +{ + return ImGui::Indent(indent_w); +} +CIMGUI_API void igUnindent(float indent_w) +{ + return ImGui::Unindent(indent_w); +} +CIMGUI_API void igBeginGroup() +{ + return ImGui::BeginGroup(); +} +CIMGUI_API void igEndGroup() +{ + return ImGui::EndGroup(); +} +CIMGUI_API void igGetCursorPos(ImVec2 *pOut) +{ + *pOut = ImGui::GetCursorPos(); +} +CIMGUI_API float igGetCursorPosX() +{ + return ImGui::GetCursorPosX(); +} +CIMGUI_API float igGetCursorPosY() +{ + return ImGui::GetCursorPosY(); +} +CIMGUI_API void igSetCursorPos(const ImVec2 local_pos) +{ + return ImGui::SetCursorPos(local_pos); +} +CIMGUI_API void igSetCursorPosX(float local_x) +{ + return ImGui::SetCursorPosX(local_x); +} +CIMGUI_API void igSetCursorPosY(float local_y) +{ + return ImGui::SetCursorPosY(local_y); +} +CIMGUI_API void igGetCursorStartPos(ImVec2 *pOut) +{ + *pOut = ImGui::GetCursorStartPos(); +} +CIMGUI_API void igGetCursorScreenPos(ImVec2 *pOut) +{ + *pOut = ImGui::GetCursorScreenPos(); +} +CIMGUI_API void igSetCursorScreenPos(const ImVec2 pos) +{ + return ImGui::SetCursorScreenPos(pos); +} +CIMGUI_API void igAlignTextToFramePadding() +{ + return ImGui::AlignTextToFramePadding(); +} +CIMGUI_API float igGetTextLineHeight() +{ + return ImGui::GetTextLineHeight(); +} +CIMGUI_API float igGetTextLineHeightWithSpacing() +{ + return ImGui::GetTextLineHeightWithSpacing(); +} +CIMGUI_API float igGetFrameHeight() +{ + return ImGui::GetFrameHeight(); +} +CIMGUI_API float igGetFrameHeightWithSpacing() +{ + return ImGui::GetFrameHeightWithSpacing(); +} +CIMGUI_API void igPushID_Str(const char* str_id) +{ + return ImGui::PushID(str_id); +} +CIMGUI_API void igPushID_StrStr(const char* str_id_begin,const char* str_id_end) +{ + return ImGui::PushID(str_id_begin,str_id_end); +} +CIMGUI_API void igPushID_Ptr(const void* ptr_id) +{ + return ImGui::PushID(ptr_id); +} +CIMGUI_API void igPushID_Int(int int_id) +{ + return ImGui::PushID(int_id); +} +CIMGUI_API void igPopID() +{ + return ImGui::PopID(); +} +CIMGUI_API ImGuiID igGetID_Str(const char* str_id) +{ + return ImGui::GetID(str_id); +} +CIMGUI_API ImGuiID igGetID_StrStr(const char* str_id_begin,const char* str_id_end) +{ + return ImGui::GetID(str_id_begin,str_id_end); +} +CIMGUI_API ImGuiID igGetID_Ptr(const void* ptr_id) +{ + return ImGui::GetID(ptr_id); +} +CIMGUI_API void igTextUnformatted(const char* text,const char* text_end) +{ + return ImGui::TextUnformatted(text,text_end); +} +CIMGUI_API void igText(const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::TextV(fmt,args); + va_end(args); +} +CIMGUI_API void igTextV(const char* fmt,va_list args) +{ + return ImGui::TextV(fmt,args); +} +CIMGUI_API void igTextColored(const ImVec4 col,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::TextColoredV(col,fmt,args); + va_end(args); +} +CIMGUI_API void igTextColoredV(const ImVec4 col,const char* fmt,va_list args) +{ + return ImGui::TextColoredV(col,fmt,args); +} +CIMGUI_API void igTextDisabled(const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::TextDisabledV(fmt,args); + va_end(args); +} +CIMGUI_API void igTextDisabledV(const char* fmt,va_list args) +{ + return ImGui::TextDisabledV(fmt,args); +} +CIMGUI_API void igTextWrapped(const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::TextWrappedV(fmt,args); + va_end(args); +} +CIMGUI_API void igTextWrappedV(const char* fmt,va_list args) +{ + return ImGui::TextWrappedV(fmt,args); +} +CIMGUI_API void igLabelText(const char* label,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::LabelTextV(label,fmt,args); + va_end(args); +} +CIMGUI_API void igLabelTextV(const char* label,const char* fmt,va_list args) +{ + return ImGui::LabelTextV(label,fmt,args); +} +CIMGUI_API void igBulletText(const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::BulletTextV(fmt,args); + va_end(args); +} +CIMGUI_API void igBulletTextV(const char* fmt,va_list args) +{ + return ImGui::BulletTextV(fmt,args); +} +CIMGUI_API bool igButton(const char* label,const ImVec2 size) +{ + return ImGui::Button(label,size); +} +CIMGUI_API bool igSmallButton(const char* label) +{ + return ImGui::SmallButton(label); +} +CIMGUI_API bool igInvisibleButton(const char* str_id,const ImVec2 size,ImGuiButtonFlags flags) +{ + return ImGui::InvisibleButton(str_id,size,flags); +} +CIMGUI_API bool igArrowButton(const char* str_id,ImGuiDir dir) +{ + return ImGui::ArrowButton(str_id,dir); +} +CIMGUI_API void igImage(ImTextureID user_texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,const ImVec4 tint_col,const ImVec4 border_col) +{ + return ImGui::Image(user_texture_id,size,uv0,uv1,tint_col,border_col); +} +CIMGUI_API bool igImageButton(ImTextureID user_texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,int frame_padding,const ImVec4 bg_col,const ImVec4 tint_col) +{ + return ImGui::ImageButton(user_texture_id,size,uv0,uv1,frame_padding,bg_col,tint_col); +} +CIMGUI_API bool igCheckbox(const char* label,bool* v) +{ + return ImGui::Checkbox(label,v); +} +CIMGUI_API bool igCheckboxFlags_IntPtr(const char* label,int* flags,int flags_value) +{ + return ImGui::CheckboxFlags(label,flags,flags_value); +} +CIMGUI_API bool igCheckboxFlags_UintPtr(const char* label,unsigned int* flags,unsigned int flags_value) +{ + return ImGui::CheckboxFlags(label,flags,flags_value); +} +CIMGUI_API bool igRadioButton_Bool(const char* label,bool active) +{ + return ImGui::RadioButton(label,active); +} +CIMGUI_API bool igRadioButton_IntPtr(const char* label,int* v,int v_button) +{ + return ImGui::RadioButton(label,v,v_button); +} +CIMGUI_API void igProgressBar(float fraction,const ImVec2 size_arg,const char* overlay) +{ + return ImGui::ProgressBar(fraction,size_arg,overlay); +} +CIMGUI_API void igBullet() +{ + return ImGui::Bullet(); +} +CIMGUI_API bool igBeginCombo(const char* label,const char* preview_value,ImGuiComboFlags flags) +{ + return ImGui::BeginCombo(label,preview_value,flags); +} +CIMGUI_API void igEndCombo() +{ + return ImGui::EndCombo(); +} +CIMGUI_API bool igCombo_Str_arr(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items) +{ + return ImGui::Combo(label,current_item,items,items_count,popup_max_height_in_items); +} +CIMGUI_API bool igCombo_Str(const char* label,int* current_item,const char* items_separated_by_zeros,int popup_max_height_in_items) +{ + return ImGui::Combo(label,current_item,items_separated_by_zeros,popup_max_height_in_items); +} +CIMGUI_API bool igCombo_FnBoolPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int popup_max_height_in_items) +{ + return ImGui::Combo(label,current_item,items_getter,data,items_count,popup_max_height_in_items); +} +CIMGUI_API bool igDragFloat(const char* label,float* v,float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragFloat(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragFloat2(const char* label,float v[2],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragFloat2(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragFloat3(const char* label,float v[3],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragFloat3(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragFloat4(const char* label,float v[4],float v_speed,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragFloat4(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragFloatRange2(const char* label,float* v_current_min,float* v_current_max,float v_speed,float v_min,float v_max,const char* format,const char* format_max,ImGuiSliderFlags flags) +{ + return ImGui::DragFloatRange2(label,v_current_min,v_current_max,v_speed,v_min,v_max,format,format_max,flags); +} +CIMGUI_API bool igDragInt(const char* label,int* v,float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragInt(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragInt2(const char* label,int v[2],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragInt2(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragInt3(const char* label,int v[3],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragInt3(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragInt4(const char* label,int v[4],float v_speed,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragInt4(label,v,v_speed,v_min,v_max,format,flags); +} +CIMGUI_API bool igDragIntRange2(const char* label,int* v_current_min,int* v_current_max,float v_speed,int v_min,int v_max,const char* format,const char* format_max,ImGuiSliderFlags flags) +{ + return ImGui::DragIntRange2(label,v_current_min,v_current_max,v_speed,v_min,v_max,format,format_max,flags); +} +CIMGUI_API bool igDragScalar(const char* label,ImGuiDataType data_type,void* p_data,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragScalar(label,data_type,p_data,v_speed,p_min,p_max,format,flags); +} +CIMGUI_API bool igDragScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragScalarN(label,data_type,p_data,components,v_speed,p_min,p_max,format,flags); +} +CIMGUI_API bool igSliderFloat(const char* label,float* v,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderFloat(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderFloat2(const char* label,float v[2],float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderFloat2(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderFloat3(const char* label,float v[3],float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderFloat3(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderFloat4(const char* label,float v[4],float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderFloat4(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderAngle(const char* label,float* v_rad,float v_degrees_min,float v_degrees_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderAngle(label,v_rad,v_degrees_min,v_degrees_max,format,flags); +} +CIMGUI_API bool igSliderInt(const char* label,int* v,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderInt(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderInt2(const char* label,int v[2],int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderInt2(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderInt3(const char* label,int v[3],int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderInt3(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderInt4(const char* label,int v[4],int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderInt4(label,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igSliderScalar(const char* label,ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderScalar(label,data_type,p_data,p_min,p_max,format,flags); +} +CIMGUI_API bool igSliderScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::SliderScalarN(label,data_type,p_data,components,p_min,p_max,format,flags); +} +CIMGUI_API bool igVSliderFloat(const char* label,const ImVec2 size,float* v,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::VSliderFloat(label,size,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igVSliderInt(const char* label,const ImVec2 size,int* v,int v_min,int v_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::VSliderInt(label,size,v,v_min,v_max,format,flags); +} +CIMGUI_API bool igVSliderScalar(const char* label,const ImVec2 size,ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::VSliderScalar(label,size,data_type,p_data,p_min,p_max,format,flags); +} +CIMGUI_API bool igInputText(const char* label,char* buf,size_t buf_size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data) +{ + return ImGui::InputText(label,buf,buf_size,flags,callback,user_data); +} +CIMGUI_API bool igInputTextMultiline(const char* label,char* buf,size_t buf_size,const ImVec2 size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data) +{ + return ImGui::InputTextMultiline(label,buf,buf_size,size,flags,callback,user_data); +} +CIMGUI_API bool igInputTextWithHint(const char* label,const char* hint,char* buf,size_t buf_size,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data) +{ + return ImGui::InputTextWithHint(label,hint,buf,buf_size,flags,callback,user_data); +} +CIMGUI_API bool igInputFloat(const char* label,float* v,float step,float step_fast,const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputFloat(label,v,step,step_fast,format,flags); +} +CIMGUI_API bool igInputFloat2(const char* label,float v[2],const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputFloat2(label,v,format,flags); +} +CIMGUI_API bool igInputFloat3(const char* label,float v[3],const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputFloat3(label,v,format,flags); +} +CIMGUI_API bool igInputFloat4(const char* label,float v[4],const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputFloat4(label,v,format,flags); +} +CIMGUI_API bool igInputInt(const char* label,int* v,int step,int step_fast,ImGuiInputTextFlags flags) +{ + return ImGui::InputInt(label,v,step,step_fast,flags); +} +CIMGUI_API bool igInputInt2(const char* label,int v[2],ImGuiInputTextFlags flags) +{ + return ImGui::InputInt2(label,v,flags); +} +CIMGUI_API bool igInputInt3(const char* label,int v[3],ImGuiInputTextFlags flags) +{ + return ImGui::InputInt3(label,v,flags); +} +CIMGUI_API bool igInputInt4(const char* label,int v[4],ImGuiInputTextFlags flags) +{ + return ImGui::InputInt4(label,v,flags); +} +CIMGUI_API bool igInputDouble(const char* label,double* v,double step,double step_fast,const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputDouble(label,v,step,step_fast,format,flags); +} +CIMGUI_API bool igInputScalar(const char* label,ImGuiDataType data_type,void* p_data,const void* p_step,const void* p_step_fast,const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputScalar(label,data_type,p_data,p_step,p_step_fast,format,flags); +} +CIMGUI_API bool igInputScalarN(const char* label,ImGuiDataType data_type,void* p_data,int components,const void* p_step,const void* p_step_fast,const char* format,ImGuiInputTextFlags flags) +{ + return ImGui::InputScalarN(label,data_type,p_data,components,p_step,p_step_fast,format,flags); +} +CIMGUI_API bool igColorEdit3(const char* label,float col[3],ImGuiColorEditFlags flags) +{ + return ImGui::ColorEdit3(label,col,flags); +} +CIMGUI_API bool igColorEdit4(const char* label,float col[4],ImGuiColorEditFlags flags) +{ + return ImGui::ColorEdit4(label,col,flags); +} +CIMGUI_API bool igColorPicker3(const char* label,float col[3],ImGuiColorEditFlags flags) +{ + return ImGui::ColorPicker3(label,col,flags); +} +CIMGUI_API bool igColorPicker4(const char* label,float col[4],ImGuiColorEditFlags flags,const float* ref_col) +{ + return ImGui::ColorPicker4(label,col,flags,ref_col); +} +CIMGUI_API bool igColorButton(const char* desc_id,const ImVec4 col,ImGuiColorEditFlags flags,ImVec2 size) +{ + return ImGui::ColorButton(desc_id,col,flags,size); +} +CIMGUI_API void igSetColorEditOptions(ImGuiColorEditFlags flags) +{ + return ImGui::SetColorEditOptions(flags); +} +CIMGUI_API bool igTreeNode_Str(const char* label) +{ + return ImGui::TreeNode(label); +} +CIMGUI_API bool igTreeNode_StrStr(const char* str_id,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + bool ret = ImGui::TreeNodeV(str_id,fmt,args); + va_end(args); + return ret; +} +CIMGUI_API bool igTreeNode_Ptr(const void* ptr_id,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + bool ret = ImGui::TreeNodeV(ptr_id,fmt,args); + va_end(args); + return ret; +} +CIMGUI_API bool igTreeNodeV_Str(const char* str_id,const char* fmt,va_list args) +{ + return ImGui::TreeNodeV(str_id,fmt,args); +} +CIMGUI_API bool igTreeNodeV_Ptr(const void* ptr_id,const char* fmt,va_list args) +{ + return ImGui::TreeNodeV(ptr_id,fmt,args); +} +CIMGUI_API bool igTreeNodeEx_Str(const char* label,ImGuiTreeNodeFlags flags) +{ + return ImGui::TreeNodeEx(label,flags); +} +CIMGUI_API bool igTreeNodeEx_StrStr(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + bool ret = ImGui::TreeNodeExV(str_id,flags,fmt,args); + va_end(args); + return ret; +} +CIMGUI_API bool igTreeNodeEx_Ptr(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + bool ret = ImGui::TreeNodeExV(ptr_id,flags,fmt,args); + va_end(args); + return ret; +} +CIMGUI_API bool igTreeNodeExV_Str(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args) +{ + return ImGui::TreeNodeExV(str_id,flags,fmt,args); +} +CIMGUI_API bool igTreeNodeExV_Ptr(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args) +{ + return ImGui::TreeNodeExV(ptr_id,flags,fmt,args); +} +CIMGUI_API void igTreePush_Str(const char* str_id) +{ + return ImGui::TreePush(str_id); +} +CIMGUI_API void igTreePush_Ptr(const void* ptr_id) +{ + return ImGui::TreePush(ptr_id); +} +CIMGUI_API void igTreePop() +{ + return ImGui::TreePop(); +} +CIMGUI_API float igGetTreeNodeToLabelSpacing() +{ + return ImGui::GetTreeNodeToLabelSpacing(); +} +CIMGUI_API bool igCollapsingHeader_TreeNodeFlags(const char* label,ImGuiTreeNodeFlags flags) +{ + return ImGui::CollapsingHeader(label,flags); +} +CIMGUI_API bool igCollapsingHeader_BoolPtr(const char* label,bool* p_visible,ImGuiTreeNodeFlags flags) +{ + return ImGui::CollapsingHeader(label,p_visible,flags); +} +CIMGUI_API void igSetNextItemOpen(bool is_open,ImGuiCond cond) +{ + return ImGui::SetNextItemOpen(is_open,cond); +} +CIMGUI_API bool igSelectable_Bool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size) +{ + return ImGui::Selectable(label,selected,flags,size); +} +CIMGUI_API bool igSelectable_BoolPtr(const char* label,bool* p_selected,ImGuiSelectableFlags flags,const ImVec2 size) +{ + return ImGui::Selectable(label,p_selected,flags,size); +} +CIMGUI_API bool igBeginListBox(const char* label,const ImVec2 size) +{ + return ImGui::BeginListBox(label,size); +} +CIMGUI_API void igEndListBox() +{ + return ImGui::EndListBox(); +} +CIMGUI_API bool igListBox_Str_arr(const char* label,int* current_item,const char* const items[],int items_count,int height_in_items) +{ + return ImGui::ListBox(label,current_item,items,items_count,height_in_items); +} +CIMGUI_API bool igListBox_FnBoolPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int height_in_items) +{ + return ImGui::ListBox(label,current_item,items_getter,data,items_count,height_in_items); +} +CIMGUI_API void igPlotLines_FloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride) +{ + return ImGui::PlotLines(label,values,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size,stride); +} +CIMGUI_API void igPlotLines_FnFloatPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size) +{ + return ImGui::PlotLines(label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size); +} +CIMGUI_API void igPlotHistogram_FloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride) +{ + return ImGui::PlotHistogram(label,values,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size,stride); +} +CIMGUI_API void igPlotHistogram_FnFloatPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size) +{ + return ImGui::PlotHistogram(label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size); +} +CIMGUI_API void igValue_Bool(const char* prefix,bool b) +{ + return ImGui::Value(prefix,b); +} +CIMGUI_API void igValue_Int(const char* prefix,int v) +{ + return ImGui::Value(prefix,v); +} +CIMGUI_API void igValue_Uint(const char* prefix,unsigned int v) +{ + return ImGui::Value(prefix,v); +} +CIMGUI_API void igValue_Float(const char* prefix,float v,const char* float_format) +{ + return ImGui::Value(prefix,v,float_format); +} +CIMGUI_API bool igBeginMenuBar() +{ + return ImGui::BeginMenuBar(); +} +CIMGUI_API void igEndMenuBar() +{ + return ImGui::EndMenuBar(); +} +CIMGUI_API bool igBeginMainMenuBar() +{ + return ImGui::BeginMainMenuBar(); +} +CIMGUI_API void igEndMainMenuBar() +{ + return ImGui::EndMainMenuBar(); +} +CIMGUI_API bool igBeginMenu(const char* label,bool enabled) +{ + return ImGui::BeginMenu(label,enabled); +} +CIMGUI_API void igEndMenu() +{ + return ImGui::EndMenu(); +} +CIMGUI_API bool igMenuItem_Bool(const char* label,const char* shortcut,bool selected,bool enabled) +{ + return ImGui::MenuItem(label,shortcut,selected,enabled); +} +CIMGUI_API bool igMenuItem_BoolPtr(const char* label,const char* shortcut,bool* p_selected,bool enabled) +{ + return ImGui::MenuItem(label,shortcut,p_selected,enabled); +} +CIMGUI_API void igBeginTooltip() +{ + return ImGui::BeginTooltip(); +} +CIMGUI_API void igEndTooltip() +{ + return ImGui::EndTooltip(); +} +CIMGUI_API void igSetTooltip(const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + ImGui::SetTooltipV(fmt,args); + va_end(args); +} +CIMGUI_API void igSetTooltipV(const char* fmt,va_list args) +{ + return ImGui::SetTooltipV(fmt,args); +} +CIMGUI_API bool igBeginPopup(const char* str_id,ImGuiWindowFlags flags) +{ + return ImGui::BeginPopup(str_id,flags); +} +CIMGUI_API bool igBeginPopupModal(const char* name,bool* p_open,ImGuiWindowFlags flags) +{ + return ImGui::BeginPopupModal(name,p_open,flags); +} +CIMGUI_API void igEndPopup() +{ + return ImGui::EndPopup(); +} +CIMGUI_API void igOpenPopup_Str(const char* str_id,ImGuiPopupFlags popup_flags) +{ + return ImGui::OpenPopup(str_id,popup_flags); +} +CIMGUI_API void igOpenPopup_ID(ImGuiID id,ImGuiPopupFlags popup_flags) +{ + return ImGui::OpenPopup(id,popup_flags); +} +CIMGUI_API void igOpenPopupOnItemClick(const char* str_id,ImGuiPopupFlags popup_flags) +{ + return ImGui::OpenPopupOnItemClick(str_id,popup_flags); +} +CIMGUI_API void igCloseCurrentPopup() +{ + return ImGui::CloseCurrentPopup(); +} +CIMGUI_API bool igBeginPopupContextItem(const char* str_id,ImGuiPopupFlags popup_flags) +{ + return ImGui::BeginPopupContextItem(str_id,popup_flags); +} +CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,ImGuiPopupFlags popup_flags) +{ + return ImGui::BeginPopupContextWindow(str_id,popup_flags); +} +CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,ImGuiPopupFlags popup_flags) +{ + return ImGui::BeginPopupContextVoid(str_id,popup_flags); +} +CIMGUI_API bool igIsPopupOpen_Str(const char* str_id,ImGuiPopupFlags flags) +{ + return ImGui::IsPopupOpen(str_id,flags); +} +CIMGUI_API bool igBeginTable(const char* str_id,int column,ImGuiTableFlags flags,const ImVec2 outer_size,float inner_width) +{ + return ImGui::BeginTable(str_id,column,flags,outer_size,inner_width); +} +CIMGUI_API void igEndTable() +{ + return ImGui::EndTable(); +} +CIMGUI_API void igTableNextRow(ImGuiTableRowFlags row_flags,float min_row_height) +{ + return ImGui::TableNextRow(row_flags,min_row_height); +} +CIMGUI_API bool igTableNextColumn() +{ + return ImGui::TableNextColumn(); +} +CIMGUI_API bool igTableSetColumnIndex(int column_n) +{ + return ImGui::TableSetColumnIndex(column_n); +} +CIMGUI_API void igTableSetupColumn(const char* label,ImGuiTableColumnFlags flags,float init_width_or_weight,ImGuiID user_id) +{ + return ImGui::TableSetupColumn(label,flags,init_width_or_weight,user_id); +} +CIMGUI_API void igTableSetupScrollFreeze(int cols,int rows) +{ + return ImGui::TableSetupScrollFreeze(cols,rows); +} +CIMGUI_API void igTableHeadersRow() +{ + return ImGui::TableHeadersRow(); +} +CIMGUI_API void igTableHeader(const char* label) +{ + return ImGui::TableHeader(label); +} +CIMGUI_API ImGuiTableSortSpecs* igTableGetSortSpecs() +{ + return ImGui::TableGetSortSpecs(); +} +CIMGUI_API int igTableGetColumnCount() +{ + return ImGui::TableGetColumnCount(); +} +CIMGUI_API int igTableGetColumnIndex() +{ + return ImGui::TableGetColumnIndex(); +} +CIMGUI_API int igTableGetRowIndex() +{ + return ImGui::TableGetRowIndex(); +} +CIMGUI_API const char* igTableGetColumnName_Int(int column_n) +{ + return ImGui::TableGetColumnName(column_n); +} +CIMGUI_API ImGuiTableColumnFlags igTableGetColumnFlags(int column_n) +{ + return ImGui::TableGetColumnFlags(column_n); +} +CIMGUI_API void igTableSetColumnEnabled(int column_n,bool v) +{ + return ImGui::TableSetColumnEnabled(column_n,v); +} +CIMGUI_API void igTableSetBgColor(ImGuiTableBgTarget target,ImU32 color,int column_n) +{ + return ImGui::TableSetBgColor(target,color,column_n); +} +CIMGUI_API void igColumns(int count,const char* id,bool border) +{ + return ImGui::Columns(count,id,border); +} +CIMGUI_API void igNextColumn() +{ + return ImGui::NextColumn(); +} +CIMGUI_API int igGetColumnIndex() +{ + return ImGui::GetColumnIndex(); +} +CIMGUI_API float igGetColumnWidth(int column_index) +{ + return ImGui::GetColumnWidth(column_index); +} +CIMGUI_API void igSetColumnWidth(int column_index,float width) +{ + return ImGui::SetColumnWidth(column_index,width); +} +CIMGUI_API float igGetColumnOffset(int column_index) +{ + return ImGui::GetColumnOffset(column_index); +} +CIMGUI_API void igSetColumnOffset(int column_index,float offset_x) +{ + return ImGui::SetColumnOffset(column_index,offset_x); +} +CIMGUI_API int igGetColumnsCount() +{ + return ImGui::GetColumnsCount(); +} +CIMGUI_API bool igBeginTabBar(const char* str_id,ImGuiTabBarFlags flags) +{ + return ImGui::BeginTabBar(str_id,flags); +} +CIMGUI_API void igEndTabBar() +{ + return ImGui::EndTabBar(); +} +CIMGUI_API bool igBeginTabItem(const char* label,bool* p_open,ImGuiTabItemFlags flags) +{ + return ImGui::BeginTabItem(label,p_open,flags); +} +CIMGUI_API void igEndTabItem() +{ + return ImGui::EndTabItem(); +} +CIMGUI_API bool igTabItemButton(const char* label,ImGuiTabItemFlags flags) +{ + return ImGui::TabItemButton(label,flags); +} +CIMGUI_API void igSetTabItemClosed(const char* tab_or_docked_window_label) +{ + return ImGui::SetTabItemClosed(tab_or_docked_window_label); +} +CIMGUI_API void igLogToTTY(int auto_open_depth) +{ + return ImGui::LogToTTY(auto_open_depth); +} +CIMGUI_API void igLogToFile(int auto_open_depth,const char* filename) +{ + return ImGui::LogToFile(auto_open_depth,filename); +} +CIMGUI_API void igLogToClipboard(int auto_open_depth) +{ + return ImGui::LogToClipboard(auto_open_depth); +} +CIMGUI_API void igLogFinish() +{ + return ImGui::LogFinish(); +} +CIMGUI_API void igLogButtons() +{ + return ImGui::LogButtons(); +} +CIMGUI_API void igLogTextV(const char* fmt,va_list args) +{ + return ImGui::LogTextV(fmt,args); +} +CIMGUI_API bool igBeginDragDropSource(ImGuiDragDropFlags flags) +{ + return ImGui::BeginDragDropSource(flags); +} +CIMGUI_API bool igSetDragDropPayload(const char* type,const void* data,size_t sz,ImGuiCond cond) +{ + return ImGui::SetDragDropPayload(type,data,sz,cond); +} +CIMGUI_API void igEndDragDropSource() +{ + return ImGui::EndDragDropSource(); +} +CIMGUI_API bool igBeginDragDropTarget() +{ + return ImGui::BeginDragDropTarget(); +} +CIMGUI_API const ImGuiPayload* igAcceptDragDropPayload(const char* type,ImGuiDragDropFlags flags) +{ + return ImGui::AcceptDragDropPayload(type,flags); +} +CIMGUI_API void igEndDragDropTarget() +{ + return ImGui::EndDragDropTarget(); +} +CIMGUI_API const ImGuiPayload* igGetDragDropPayload() +{ + return ImGui::GetDragDropPayload(); +} +CIMGUI_API void igBeginDisabled(bool disabled) +{ + return ImGui::BeginDisabled(disabled); +} +CIMGUI_API void igEndDisabled() +{ + return ImGui::EndDisabled(); +} +CIMGUI_API void igPushClipRect(const ImVec2 clip_rect_min,const ImVec2 clip_rect_max,bool intersect_with_current_clip_rect) +{ + return ImGui::PushClipRect(clip_rect_min,clip_rect_max,intersect_with_current_clip_rect); +} +CIMGUI_API void igPopClipRect() +{ + return ImGui::PopClipRect(); +} +CIMGUI_API void igSetItemDefaultFocus() +{ + return ImGui::SetItemDefaultFocus(); +} +CIMGUI_API void igSetKeyboardFocusHere(int offset) +{ + return ImGui::SetKeyboardFocusHere(offset); +} +CIMGUI_API bool igIsItemHovered(ImGuiHoveredFlags flags) +{ + return ImGui::IsItemHovered(flags); +} +CIMGUI_API bool igIsItemActive() +{ + return ImGui::IsItemActive(); +} +CIMGUI_API bool igIsItemFocused() +{ + return ImGui::IsItemFocused(); +} +CIMGUI_API bool igIsItemClicked(ImGuiMouseButton mouse_button) +{ + return ImGui::IsItemClicked(mouse_button); +} +CIMGUI_API bool igIsItemVisible() +{ + return ImGui::IsItemVisible(); +} +CIMGUI_API bool igIsItemEdited() +{ + return ImGui::IsItemEdited(); +} +CIMGUI_API bool igIsItemActivated() +{ + return ImGui::IsItemActivated(); +} +CIMGUI_API bool igIsItemDeactivated() +{ + return ImGui::IsItemDeactivated(); +} +CIMGUI_API bool igIsItemDeactivatedAfterEdit() +{ + return ImGui::IsItemDeactivatedAfterEdit(); +} +CIMGUI_API bool igIsItemToggledOpen() +{ + return ImGui::IsItemToggledOpen(); +} +CIMGUI_API bool igIsAnyItemHovered() +{ + return ImGui::IsAnyItemHovered(); +} +CIMGUI_API bool igIsAnyItemActive() +{ + return ImGui::IsAnyItemActive(); +} +CIMGUI_API bool igIsAnyItemFocused() +{ + return ImGui::IsAnyItemFocused(); +} +CIMGUI_API void igGetItemRectMin(ImVec2 *pOut) +{ + *pOut = ImGui::GetItemRectMin(); +} +CIMGUI_API void igGetItemRectMax(ImVec2 *pOut) +{ + *pOut = ImGui::GetItemRectMax(); +} +CIMGUI_API void igGetItemRectSize(ImVec2 *pOut) +{ + *pOut = ImGui::GetItemRectSize(); +} +CIMGUI_API void igSetItemAllowOverlap() +{ + return ImGui::SetItemAllowOverlap(); +} +CIMGUI_API ImGuiViewport* igGetMainViewport() +{ + return ImGui::GetMainViewport(); +} +CIMGUI_API bool igIsRectVisible_Nil(const ImVec2 size) +{ + return ImGui::IsRectVisible(size); +} +CIMGUI_API bool igIsRectVisible_Vec2(const ImVec2 rect_min,const ImVec2 rect_max) +{ + return ImGui::IsRectVisible(rect_min,rect_max); +} +CIMGUI_API double igGetTime() +{ + return ImGui::GetTime(); +} +CIMGUI_API int igGetFrameCount() +{ + return ImGui::GetFrameCount(); +} +CIMGUI_API ImDrawList* igGetBackgroundDrawList() +{ + return ImGui::GetBackgroundDrawList(); +} +CIMGUI_API ImDrawList* igGetForegroundDrawList() +{ + return ImGui::GetForegroundDrawList(); +} +CIMGUI_API ImDrawListSharedData* igGetDrawListSharedData() +{ + return ImGui::GetDrawListSharedData(); +} +CIMGUI_API const char* igGetStyleColorName(ImGuiCol idx) +{ + return ImGui::GetStyleColorName(idx); +} +CIMGUI_API void igSetStateStorage(ImGuiStorage* storage) +{ + return ImGui::SetStateStorage(storage); +} +CIMGUI_API ImGuiStorage* igGetStateStorage() +{ + return ImGui::GetStateStorage(); +} +CIMGUI_API void igCalcListClipping(int items_count,float items_height,int* out_items_display_start,int* out_items_display_end) +{ + return ImGui::CalcListClipping(items_count,items_height,out_items_display_start,out_items_display_end); +} +CIMGUI_API bool igBeginChildFrame(ImGuiID id,const ImVec2 size,ImGuiWindowFlags flags) +{ + return ImGui::BeginChildFrame(id,size,flags); +} +CIMGUI_API void igEndChildFrame() +{ + return ImGui::EndChildFrame(); +} +CIMGUI_API void igCalcTextSize(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width) +{ + *pOut = ImGui::CalcTextSize(text,text_end,hide_text_after_double_hash,wrap_width); +} +CIMGUI_API void igColorConvertU32ToFloat4(ImVec4 *pOut,ImU32 in) +{ + *pOut = ImGui::ColorConvertU32ToFloat4(in); +} +CIMGUI_API ImU32 igColorConvertFloat4ToU32(const ImVec4 in) +{ + return ImGui::ColorConvertFloat4ToU32(in); +} +CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float* out_h,float* out_s,float* out_v) +{ + return ImGui::ColorConvertRGBtoHSV(r,g,b,*out_h,*out_s,*out_v); +} +CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float* out_r,float* out_g,float* out_b) +{ + return ImGui::ColorConvertHSVtoRGB(h,s,v,*out_r,*out_g,*out_b); +} +CIMGUI_API int igGetKeyIndex(ImGuiKey imgui_key) +{ + return ImGui::GetKeyIndex(imgui_key); +} +CIMGUI_API bool igIsKeyDown(int user_key_index) +{ + return ImGui::IsKeyDown(user_key_index); +} +CIMGUI_API bool igIsKeyPressed(int user_key_index,bool repeat) +{ + return ImGui::IsKeyPressed(user_key_index,repeat); +} +CIMGUI_API bool igIsKeyReleased(int user_key_index) +{ + return ImGui::IsKeyReleased(user_key_index); +} +CIMGUI_API int igGetKeyPressedAmount(int key_index,float repeat_delay,float rate) +{ + return ImGui::GetKeyPressedAmount(key_index,repeat_delay,rate); +} +CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value) +{ + return ImGui::CaptureKeyboardFromApp(want_capture_keyboard_value); +} +CIMGUI_API bool igIsMouseDown(ImGuiMouseButton button) +{ + return ImGui::IsMouseDown(button); +} +CIMGUI_API bool igIsMouseClicked(ImGuiMouseButton button,bool repeat) +{ + return ImGui::IsMouseClicked(button,repeat); +} +CIMGUI_API bool igIsMouseReleased(ImGuiMouseButton button) +{ + return ImGui::IsMouseReleased(button); +} +CIMGUI_API bool igIsMouseDoubleClicked(ImGuiMouseButton button) +{ + return ImGui::IsMouseDoubleClicked(button); +} +CIMGUI_API bool igIsMouseHoveringRect(const ImVec2 r_min,const ImVec2 r_max,bool clip) +{ + return ImGui::IsMouseHoveringRect(r_min,r_max,clip); +} +CIMGUI_API bool igIsMousePosValid(const ImVec2* mouse_pos) +{ + return ImGui::IsMousePosValid(mouse_pos); +} +CIMGUI_API bool igIsAnyMouseDown() +{ + return ImGui::IsAnyMouseDown(); +} +CIMGUI_API void igGetMousePos(ImVec2 *pOut) +{ + *pOut = ImGui::GetMousePos(); +} +CIMGUI_API void igGetMousePosOnOpeningCurrentPopup(ImVec2 *pOut) +{ + *pOut = ImGui::GetMousePosOnOpeningCurrentPopup(); +} +CIMGUI_API bool igIsMouseDragging(ImGuiMouseButton button,float lock_threshold) +{ + return ImGui::IsMouseDragging(button,lock_threshold); +} +CIMGUI_API void igGetMouseDragDelta(ImVec2 *pOut,ImGuiMouseButton button,float lock_threshold) +{ + *pOut = ImGui::GetMouseDragDelta(button,lock_threshold); +} +CIMGUI_API void igResetMouseDragDelta(ImGuiMouseButton button) +{ + return ImGui::ResetMouseDragDelta(button); +} +CIMGUI_API ImGuiMouseCursor igGetMouseCursor() +{ + return ImGui::GetMouseCursor(); +} +CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor cursor_type) +{ + return ImGui::SetMouseCursor(cursor_type); +} +CIMGUI_API void igCaptureMouseFromApp(bool want_capture_mouse_value) +{ + return ImGui::CaptureMouseFromApp(want_capture_mouse_value); +} +CIMGUI_API const char* igGetClipboardText() +{ + return ImGui::GetClipboardText(); +} +CIMGUI_API void igSetClipboardText(const char* text) +{ + return ImGui::SetClipboardText(text); +} +CIMGUI_API void igLoadIniSettingsFromDisk(const char* ini_filename) +{ + return ImGui::LoadIniSettingsFromDisk(ini_filename); +} +CIMGUI_API void igLoadIniSettingsFromMemory(const char* ini_data,size_t ini_size) +{ + return ImGui::LoadIniSettingsFromMemory(ini_data,ini_size); +} +CIMGUI_API void igSaveIniSettingsToDisk(const char* ini_filename) +{ + return ImGui::SaveIniSettingsToDisk(ini_filename); +} +CIMGUI_API const char* igSaveIniSettingsToMemory(size_t* out_ini_size) +{ + return ImGui::SaveIniSettingsToMemory(out_ini_size); +} +CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx) +{ + return ImGui::DebugCheckVersionAndDataLayout(version_str,sz_io,sz_style,sz_vec2,sz_vec4,sz_drawvert,sz_drawidx); +} +CIMGUI_API void igSetAllocatorFunctions(ImGuiMemAllocFunc alloc_func,ImGuiMemFreeFunc free_func,void* user_data) +{ + return ImGui::SetAllocatorFunctions(alloc_func,free_func,user_data); +} +CIMGUI_API void igGetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func,ImGuiMemFreeFunc* p_free_func,void** p_user_data) +{ + return ImGui::GetAllocatorFunctions(p_alloc_func,p_free_func,p_user_data); +} +CIMGUI_API void* igMemAlloc(size_t size) +{ + return ImGui::MemAlloc(size); +} +CIMGUI_API void igMemFree(void* ptr) +{ + return ImGui::MemFree(ptr); +} +CIMGUI_API ImGuiStyle* ImGuiStyle_ImGuiStyle(void) +{ + return IM_NEW(ImGuiStyle)(); +} +CIMGUI_API void ImGuiStyle_destroy(ImGuiStyle* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiStyle_ScaleAllSizes(ImGuiStyle* self,float scale_factor) +{ + return self->ScaleAllSizes(scale_factor); +} +CIMGUI_API void ImGuiIO_AddInputCharacter(ImGuiIO* self,unsigned int c) +{ + return self->AddInputCharacter(c); +} +CIMGUI_API void ImGuiIO_AddInputCharacterUTF16(ImGuiIO* self,ImWchar16 c) +{ + return self->AddInputCharacterUTF16(c); +} +CIMGUI_API void ImGuiIO_AddInputCharactersUTF8(ImGuiIO* self,const char* str) +{ + return self->AddInputCharactersUTF8(str); +} +CIMGUI_API void ImGuiIO_ClearInputCharacters(ImGuiIO* self) +{ + return self->ClearInputCharacters(); +} +CIMGUI_API void ImGuiIO_AddFocusEvent(ImGuiIO* self,bool focused) +{ + return self->AddFocusEvent(focused); +} +CIMGUI_API ImGuiIO* ImGuiIO_ImGuiIO(void) +{ + return IM_NEW(ImGuiIO)(); +} +CIMGUI_API void ImGuiIO_destroy(ImGuiIO* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiInputTextCallbackData* ImGuiInputTextCallbackData_ImGuiInputTextCallbackData(void) +{ + return IM_NEW(ImGuiInputTextCallbackData)(); +} +CIMGUI_API void ImGuiInputTextCallbackData_destroy(ImGuiInputTextCallbackData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiInputTextCallbackData_DeleteChars(ImGuiInputTextCallbackData* self,int pos,int bytes_count) +{ + return self->DeleteChars(pos,bytes_count); +} +CIMGUI_API void ImGuiInputTextCallbackData_InsertChars(ImGuiInputTextCallbackData* self,int pos,const char* text,const char* text_end) +{ + return self->InsertChars(pos,text,text_end); +} +CIMGUI_API void ImGuiInputTextCallbackData_SelectAll(ImGuiInputTextCallbackData* self) +{ + return self->SelectAll(); +} +CIMGUI_API void ImGuiInputTextCallbackData_ClearSelection(ImGuiInputTextCallbackData* self) +{ + return self->ClearSelection(); +} +CIMGUI_API bool ImGuiInputTextCallbackData_HasSelection(ImGuiInputTextCallbackData* self) +{ + return self->HasSelection(); +} +CIMGUI_API ImGuiPayload* ImGuiPayload_ImGuiPayload(void) +{ + return IM_NEW(ImGuiPayload)(); +} +CIMGUI_API void ImGuiPayload_destroy(ImGuiPayload* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiPayload_Clear(ImGuiPayload* self) +{ + return self->Clear(); +} +CIMGUI_API bool ImGuiPayload_IsDataType(ImGuiPayload* self,const char* type) +{ + return self->IsDataType(type); +} +CIMGUI_API bool ImGuiPayload_IsPreview(ImGuiPayload* self) +{ + return self->IsPreview(); +} +CIMGUI_API bool ImGuiPayload_IsDelivery(ImGuiPayload* self) +{ + return self->IsDelivery(); +} +CIMGUI_API ImGuiTableColumnSortSpecs* ImGuiTableColumnSortSpecs_ImGuiTableColumnSortSpecs(void) +{ + return IM_NEW(ImGuiTableColumnSortSpecs)(); +} +CIMGUI_API void ImGuiTableColumnSortSpecs_destroy(ImGuiTableColumnSortSpecs* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTableSortSpecs* ImGuiTableSortSpecs_ImGuiTableSortSpecs(void) +{ + return IM_NEW(ImGuiTableSortSpecs)(); +} +CIMGUI_API void ImGuiTableSortSpecs_destroy(ImGuiTableSortSpecs* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiOnceUponAFrame* ImGuiOnceUponAFrame_ImGuiOnceUponAFrame(void) +{ + return IM_NEW(ImGuiOnceUponAFrame)(); +} +CIMGUI_API void ImGuiOnceUponAFrame_destroy(ImGuiOnceUponAFrame* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTextFilter* ImGuiTextFilter_ImGuiTextFilter(const char* default_filter) +{ + return IM_NEW(ImGuiTextFilter)(default_filter); +} +CIMGUI_API void ImGuiTextFilter_destroy(ImGuiTextFilter* self) +{ + IM_DELETE(self); +} +CIMGUI_API bool ImGuiTextFilter_Draw(ImGuiTextFilter* self,const char* label,float width) +{ + return self->Draw(label,width); +} +CIMGUI_API bool ImGuiTextFilter_PassFilter(ImGuiTextFilter* self,const char* text,const char* text_end) +{ + return self->PassFilter(text,text_end); +} +CIMGUI_API void ImGuiTextFilter_Build(ImGuiTextFilter* self) +{ + return self->Build(); +} +CIMGUI_API void ImGuiTextFilter_Clear(ImGuiTextFilter* self) +{ + return self->Clear(); +} +CIMGUI_API bool ImGuiTextFilter_IsActive(ImGuiTextFilter* self) +{ + return self->IsActive(); +} +CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange_Nil(void) +{ + return IM_NEW(ImGuiTextRange)(); +} +CIMGUI_API void ImGuiTextRange_destroy(ImGuiTextRange* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange_Str(const char* _b,const char* _e) +{ + return IM_NEW(ImGuiTextRange)(_b,_e); +} +CIMGUI_API bool ImGuiTextRange_empty(ImGuiTextRange* self) +{ + return self->empty(); +} +CIMGUI_API void ImGuiTextRange_split(ImGuiTextRange* self,char separator,ImVector_ImGuiTextRange* out) +{ + return self->split(separator,out); +} +CIMGUI_API ImGuiTextBuffer* ImGuiTextBuffer_ImGuiTextBuffer(void) +{ + return IM_NEW(ImGuiTextBuffer)(); +} +CIMGUI_API void ImGuiTextBuffer_destroy(ImGuiTextBuffer* self) +{ + IM_DELETE(self); +} +CIMGUI_API const char* ImGuiTextBuffer_begin(ImGuiTextBuffer* self) +{ + return self->begin(); +} +CIMGUI_API const char* ImGuiTextBuffer_end(ImGuiTextBuffer* self) +{ + return self->end(); +} +CIMGUI_API int ImGuiTextBuffer_size(ImGuiTextBuffer* self) +{ + return self->size(); +} +CIMGUI_API bool ImGuiTextBuffer_empty(ImGuiTextBuffer* self) +{ + return self->empty(); +} +CIMGUI_API void ImGuiTextBuffer_clear(ImGuiTextBuffer* self) +{ + return self->clear(); +} +CIMGUI_API void ImGuiTextBuffer_reserve(ImGuiTextBuffer* self,int capacity) +{ + return self->reserve(capacity); +} +CIMGUI_API const char* ImGuiTextBuffer_c_str(ImGuiTextBuffer* self) +{ + return self->c_str(); +} +CIMGUI_API void ImGuiTextBuffer_append(ImGuiTextBuffer* self,const char* str,const char* str_end) +{ + return self->append(str,str_end); +} +CIMGUI_API void ImGuiTextBuffer_appendfv(ImGuiTextBuffer* self,const char* fmt,va_list args) +{ + return self->appendfv(fmt,args); +} +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Int(ImGuiID _key,int _val_i) +{ + return IM_NEW(ImGuiStoragePair)(_key,_val_i); +} +CIMGUI_API void ImGuiStoragePair_destroy(ImGuiStoragePair* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Float(ImGuiID _key,float _val_f) +{ + return IM_NEW(ImGuiStoragePair)(_key,_val_f); +} +CIMGUI_API ImGuiStoragePair* ImGuiStoragePair_ImGuiStoragePair_Ptr(ImGuiID _key,void* _val_p) +{ + return IM_NEW(ImGuiStoragePair)(_key,_val_p); +} +CIMGUI_API void ImGuiStorage_Clear(ImGuiStorage* self) +{ + return self->Clear(); +} +CIMGUI_API int ImGuiStorage_GetInt(ImGuiStorage* self,ImGuiID key,int default_val) +{ + return self->GetInt(key,default_val); +} +CIMGUI_API void ImGuiStorage_SetInt(ImGuiStorage* self,ImGuiID key,int val) +{ + return self->SetInt(key,val); +} +CIMGUI_API bool ImGuiStorage_GetBool(ImGuiStorage* self,ImGuiID key,bool default_val) +{ + return self->GetBool(key,default_val); +} +CIMGUI_API void ImGuiStorage_SetBool(ImGuiStorage* self,ImGuiID key,bool val) +{ + return self->SetBool(key,val); +} +CIMGUI_API float ImGuiStorage_GetFloat(ImGuiStorage* self,ImGuiID key,float default_val) +{ + return self->GetFloat(key,default_val); +} +CIMGUI_API void ImGuiStorage_SetFloat(ImGuiStorage* self,ImGuiID key,float val) +{ + return self->SetFloat(key,val); +} +CIMGUI_API void* ImGuiStorage_GetVoidPtr(ImGuiStorage* self,ImGuiID key) +{ + return self->GetVoidPtr(key); +} +CIMGUI_API void ImGuiStorage_SetVoidPtr(ImGuiStorage* self,ImGuiID key,void* val) +{ + return self->SetVoidPtr(key,val); +} +CIMGUI_API int* ImGuiStorage_GetIntRef(ImGuiStorage* self,ImGuiID key,int default_val) +{ + return self->GetIntRef(key,default_val); +} +CIMGUI_API bool* ImGuiStorage_GetBoolRef(ImGuiStorage* self,ImGuiID key,bool default_val) +{ + return self->GetBoolRef(key,default_val); +} +CIMGUI_API float* ImGuiStorage_GetFloatRef(ImGuiStorage* self,ImGuiID key,float default_val) +{ + return self->GetFloatRef(key,default_val); +} +CIMGUI_API void** ImGuiStorage_GetVoidPtrRef(ImGuiStorage* self,ImGuiID key,void* default_val) +{ + return self->GetVoidPtrRef(key,default_val); +} +CIMGUI_API void ImGuiStorage_SetAllInt(ImGuiStorage* self,int val) +{ + return self->SetAllInt(val); +} +CIMGUI_API void ImGuiStorage_BuildSortByKey(ImGuiStorage* self) +{ + return self->BuildSortByKey(); +} +CIMGUI_API ImGuiListClipper* ImGuiListClipper_ImGuiListClipper(void) +{ + return IM_NEW(ImGuiListClipper)(); +} +CIMGUI_API void ImGuiListClipper_destroy(ImGuiListClipper* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiListClipper_Begin(ImGuiListClipper* self,int items_count,float items_height) +{ + return self->Begin(items_count,items_height); +} +CIMGUI_API void ImGuiListClipper_End(ImGuiListClipper* self) +{ + return self->End(); +} +CIMGUI_API bool ImGuiListClipper_Step(ImGuiListClipper* self) +{ + return self->Step(); +} +CIMGUI_API ImColor* ImColor_ImColor_Nil(void) +{ + return IM_NEW(ImColor)(); +} +CIMGUI_API void ImColor_destroy(ImColor* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImColor* ImColor_ImColor_Int(int r,int g,int b,int a) +{ + return IM_NEW(ImColor)(r,g,b,a); +} +CIMGUI_API ImColor* ImColor_ImColor_U32(ImU32 rgba) +{ + return IM_NEW(ImColor)(rgba); +} +CIMGUI_API ImColor* ImColor_ImColor_Float(float r,float g,float b,float a) +{ + return IM_NEW(ImColor)(r,g,b,a); +} +CIMGUI_API ImColor* ImColor_ImColor_Vec4(const ImVec4 col) +{ + return IM_NEW(ImColor)(col); +} +CIMGUI_API void ImColor_SetHSV(ImColor* self,float h,float s,float v,float a) +{ + return self->SetHSV(h,s,v,a); +} +CIMGUI_API void ImColor_HSV(ImColor *pOut,float h,float s,float v,float a) +{ + *pOut = ImColor::HSV(h,s,v,a); +} +CIMGUI_API ImDrawCmd* ImDrawCmd_ImDrawCmd(void) +{ + return IM_NEW(ImDrawCmd)(); +} +CIMGUI_API void ImDrawCmd_destroy(ImDrawCmd* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImTextureID ImDrawCmd_GetTexID(ImDrawCmd* self) +{ + return self->GetTexID(); +} +CIMGUI_API ImDrawListSplitter* ImDrawListSplitter_ImDrawListSplitter(void) +{ + return IM_NEW(ImDrawListSplitter)(); +} +CIMGUI_API void ImDrawListSplitter_destroy(ImDrawListSplitter* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImDrawListSplitter_Clear(ImDrawListSplitter* self) +{ + return self->Clear(); +} +CIMGUI_API void ImDrawListSplitter_ClearFreeMemory(ImDrawListSplitter* self) +{ + return self->ClearFreeMemory(); +} +CIMGUI_API void ImDrawListSplitter_Split(ImDrawListSplitter* self,ImDrawList* draw_list,int count) +{ + return self->Split(draw_list,count); +} +CIMGUI_API void ImDrawListSplitter_Merge(ImDrawListSplitter* self,ImDrawList* draw_list) +{ + return self->Merge(draw_list); +} +CIMGUI_API void ImDrawListSplitter_SetCurrentChannel(ImDrawListSplitter* self,ImDrawList* draw_list,int channel_idx) +{ + return self->SetCurrentChannel(draw_list,channel_idx); +} +CIMGUI_API ImDrawList* ImDrawList_ImDrawList(const ImDrawListSharedData* shared_data) +{ + return IM_NEW(ImDrawList)(shared_data); +} +CIMGUI_API void ImDrawList_destroy(ImDrawList* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImDrawList_PushClipRect(ImDrawList* self,ImVec2 clip_rect_min,ImVec2 clip_rect_max,bool intersect_with_current_clip_rect) +{ + return self->PushClipRect(clip_rect_min,clip_rect_max,intersect_with_current_clip_rect); +} +CIMGUI_API void ImDrawList_PushClipRectFullScreen(ImDrawList* self) +{ + return self->PushClipRectFullScreen(); +} +CIMGUI_API void ImDrawList_PopClipRect(ImDrawList* self) +{ + return self->PopClipRect(); +} +CIMGUI_API void ImDrawList_PushTextureID(ImDrawList* self,ImTextureID texture_id) +{ + return self->PushTextureID(texture_id); +} +CIMGUI_API void ImDrawList_PopTextureID(ImDrawList* self) +{ + return self->PopTextureID(); +} +CIMGUI_API void ImDrawList_GetClipRectMin(ImVec2 *pOut,ImDrawList* self) +{ + *pOut = self->GetClipRectMin(); +} +CIMGUI_API void ImDrawList_GetClipRectMax(ImVec2 *pOut,ImDrawList* self) +{ + *pOut = self->GetClipRectMax(); +} +CIMGUI_API void ImDrawList_AddLine(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,ImU32 col,float thickness) +{ + return self->AddLine(p1,p2,col,thickness); +} +CIMGUI_API void ImDrawList_AddRect(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawFlags flags,float thickness) +{ + return self->AddRect(p_min,p_max,col,rounding,flags,thickness); +} +CIMGUI_API void ImDrawList_AddRectFilled(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawFlags flags) +{ + return self->AddRectFilled(p_min,p_max,col,rounding,flags); +} +CIMGUI_API void ImDrawList_AddRectFilledMultiColor(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col_upr_left,ImU32 col_upr_right,ImU32 col_bot_right,ImU32 col_bot_left) +{ + return self->AddRectFilledMultiColor(p_min,p_max,col_upr_left,col_upr_right,col_bot_right,col_bot_left); +} +CIMGUI_API void ImDrawList_AddQuad(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness) +{ + return self->AddQuad(p1,p2,p3,p4,col,thickness); +} +CIMGUI_API void ImDrawList_AddQuadFilled(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col) +{ + return self->AddQuadFilled(p1,p2,p3,p4,col); +} +CIMGUI_API void ImDrawList_AddTriangle(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col,float thickness) +{ + return self->AddTriangle(p1,p2,p3,col,thickness); +} +CIMGUI_API void ImDrawList_AddTriangleFilled(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col) +{ + return self->AddTriangleFilled(p1,p2,p3,col); +} +CIMGUI_API void ImDrawList_AddCircle(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness) +{ + return self->AddCircle(center,radius,col,num_segments,thickness); +} +CIMGUI_API void ImDrawList_AddCircleFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments) +{ + return self->AddCircleFilled(center,radius,col,num_segments); +} +CIMGUI_API void ImDrawList_AddNgon(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness) +{ + return self->AddNgon(center,radius,col,num_segments,thickness); +} +CIMGUI_API void ImDrawList_AddNgonFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments) +{ + return self->AddNgonFilled(center,radius,col,num_segments); +} +CIMGUI_API void ImDrawList_AddText_Vec2(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end) +{ + return self->AddText(pos,col,text_begin,text_end); +} +CIMGUI_API void ImDrawList_AddText_FontPtr(ImDrawList* self,const ImFont* font,float font_size,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end,float wrap_width,const ImVec4* cpu_fine_clip_rect) +{ + return self->AddText(font,font_size,pos,col,text_begin,text_end,wrap_width,cpu_fine_clip_rect); +} +CIMGUI_API void ImDrawList_AddPolyline(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col,ImDrawFlags flags,float thickness) +{ + return self->AddPolyline(points,num_points,col,flags,thickness); +} +CIMGUI_API void ImDrawList_AddConvexPolyFilled(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col) +{ + return self->AddConvexPolyFilled(points,num_points,col); +} +CIMGUI_API void ImDrawList_AddBezierCubic(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness,int num_segments) +{ + return self->AddBezierCubic(p1,p2,p3,p4,col,thickness,num_segments); +} +CIMGUI_API void ImDrawList_AddBezierQuadratic(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col,float thickness,int num_segments) +{ + return self->AddBezierQuadratic(p1,p2,p3,col,thickness,num_segments); +} +CIMGUI_API void ImDrawList_AddImage(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col) +{ + return self->AddImage(user_texture_id,p_min,p_max,uv_min,uv_max,col); +} +CIMGUI_API void ImDrawList_AddImageQuad(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 uv1,const ImVec2 uv2,const ImVec2 uv3,const ImVec2 uv4,ImU32 col) +{ + return self->AddImageQuad(user_texture_id,p1,p2,p3,p4,uv1,uv2,uv3,uv4,col); +} +CIMGUI_API void ImDrawList_AddImageRounded(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col,float rounding,ImDrawFlags flags) +{ + return self->AddImageRounded(user_texture_id,p_min,p_max,uv_min,uv_max,col,rounding,flags); +} +CIMGUI_API void ImDrawList_PathClear(ImDrawList* self) +{ + return self->PathClear(); +} +CIMGUI_API void ImDrawList_PathLineTo(ImDrawList* self,const ImVec2 pos) +{ + return self->PathLineTo(pos); +} +CIMGUI_API void ImDrawList_PathLineToMergeDuplicate(ImDrawList* self,const ImVec2 pos) +{ + return self->PathLineToMergeDuplicate(pos); +} +CIMGUI_API void ImDrawList_PathFillConvex(ImDrawList* self,ImU32 col) +{ + return self->PathFillConvex(col); +} +CIMGUI_API void ImDrawList_PathStroke(ImDrawList* self,ImU32 col,ImDrawFlags flags,float thickness) +{ + return self->PathStroke(col,flags,thickness); +} +CIMGUI_API void ImDrawList_PathArcTo(ImDrawList* self,const ImVec2 center,float radius,float a_min,float a_max,int num_segments) +{ + return self->PathArcTo(center,radius,a_min,a_max,num_segments); +} +CIMGUI_API void ImDrawList_PathArcToFast(ImDrawList* self,const ImVec2 center,float radius,int a_min_of_12,int a_max_of_12) +{ + return self->PathArcToFast(center,radius,a_min_of_12,a_max_of_12); +} +CIMGUI_API void ImDrawList_PathBezierCubicCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,int num_segments) +{ + return self->PathBezierCubicCurveTo(p2,p3,p4,num_segments); +} +CIMGUI_API void ImDrawList_PathBezierQuadraticCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,int num_segments) +{ + return self->PathBezierQuadraticCurveTo(p2,p3,num_segments); +} +CIMGUI_API void ImDrawList_PathRect(ImDrawList* self,const ImVec2 rect_min,const ImVec2 rect_max,float rounding,ImDrawFlags flags) +{ + return self->PathRect(rect_min,rect_max,rounding,flags); +} +CIMGUI_API void ImDrawList_AddCallback(ImDrawList* self,ImDrawCallback callback,void* callback_data) +{ + return self->AddCallback(callback,callback_data); +} +CIMGUI_API void ImDrawList_AddDrawCmd(ImDrawList* self) +{ + return self->AddDrawCmd(); +} +CIMGUI_API ImDrawList* ImDrawList_CloneOutput(ImDrawList* self) +{ + return self->CloneOutput(); +} +CIMGUI_API void ImDrawList_ChannelsSplit(ImDrawList* self,int count) +{ + return self->ChannelsSplit(count); +} +CIMGUI_API void ImDrawList_ChannelsMerge(ImDrawList* self) +{ + return self->ChannelsMerge(); +} +CIMGUI_API void ImDrawList_ChannelsSetCurrent(ImDrawList* self,int n) +{ + return self->ChannelsSetCurrent(n); +} +CIMGUI_API void ImDrawList_PrimReserve(ImDrawList* self,int idx_count,int vtx_count) +{ + return self->PrimReserve(idx_count,vtx_count); +} +CIMGUI_API void ImDrawList_PrimUnreserve(ImDrawList* self,int idx_count,int vtx_count) +{ + return self->PrimUnreserve(idx_count,vtx_count); +} +CIMGUI_API void ImDrawList_PrimRect(ImDrawList* self,const ImVec2 a,const ImVec2 b,ImU32 col) +{ + return self->PrimRect(a,b,col); +} +CIMGUI_API void ImDrawList_PrimRectUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,ImU32 col) +{ + return self->PrimRectUV(a,b,uv_a,uv_b,col); +} +CIMGUI_API void ImDrawList_PrimQuadUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 d,const ImVec2 uv_a,const ImVec2 uv_b,const ImVec2 uv_c,const ImVec2 uv_d,ImU32 col) +{ + return self->PrimQuadUV(a,b,c,d,uv_a,uv_b,uv_c,uv_d,col); +} +CIMGUI_API void ImDrawList_PrimWriteVtx(ImDrawList* self,const ImVec2 pos,const ImVec2 uv,ImU32 col) +{ + return self->PrimWriteVtx(pos,uv,col); +} +CIMGUI_API void ImDrawList_PrimWriteIdx(ImDrawList* self,ImDrawIdx idx) +{ + return self->PrimWriteIdx(idx); +} +CIMGUI_API void ImDrawList_PrimVtx(ImDrawList* self,const ImVec2 pos,const ImVec2 uv,ImU32 col) +{ + return self->PrimVtx(pos,uv,col); +} +CIMGUI_API void ImDrawList__ResetForNewFrame(ImDrawList* self) +{ + return self->_ResetForNewFrame(); +} +CIMGUI_API void ImDrawList__ClearFreeMemory(ImDrawList* self) +{ + return self->_ClearFreeMemory(); +} +CIMGUI_API void ImDrawList__PopUnusedDrawCmd(ImDrawList* self) +{ + return self->_PopUnusedDrawCmd(); +} +CIMGUI_API void ImDrawList__TryMergeDrawCmds(ImDrawList* self) +{ + return self->_TryMergeDrawCmds(); +} +CIMGUI_API void ImDrawList__OnChangedClipRect(ImDrawList* self) +{ + return self->_OnChangedClipRect(); +} +CIMGUI_API void ImDrawList__OnChangedTextureID(ImDrawList* self) +{ + return self->_OnChangedTextureID(); +} +CIMGUI_API void ImDrawList__OnChangedVtxOffset(ImDrawList* self) +{ + return self->_OnChangedVtxOffset(); +} +CIMGUI_API int ImDrawList__CalcCircleAutoSegmentCount(ImDrawList* self,float radius) +{ + return self->_CalcCircleAutoSegmentCount(radius); +} +CIMGUI_API void ImDrawList__PathArcToFastEx(ImDrawList* self,const ImVec2 center,float radius,int a_min_sample,int a_max_sample,int a_step) +{ + return self->_PathArcToFastEx(center,radius,a_min_sample,a_max_sample,a_step); +} +CIMGUI_API void ImDrawList__PathArcToN(ImDrawList* self,const ImVec2 center,float radius,float a_min,float a_max,int num_segments) +{ + return self->_PathArcToN(center,radius,a_min,a_max,num_segments); +} +CIMGUI_API ImDrawData* ImDrawData_ImDrawData(void) +{ + return IM_NEW(ImDrawData)(); +} +CIMGUI_API void ImDrawData_destroy(ImDrawData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImDrawData_Clear(ImDrawData* self) +{ + return self->Clear(); +} +CIMGUI_API void ImDrawData_DeIndexAllBuffers(ImDrawData* self) +{ + return self->DeIndexAllBuffers(); +} +CIMGUI_API void ImDrawData_ScaleClipRects(ImDrawData* self,const ImVec2 fb_scale) +{ + return self->ScaleClipRects(fb_scale); +} +CIMGUI_API ImFontConfig* ImFontConfig_ImFontConfig(void) +{ + return IM_NEW(ImFontConfig)(); +} +CIMGUI_API void ImFontConfig_destroy(ImFontConfig* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImFontGlyphRangesBuilder* ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder(void) +{ + return IM_NEW(ImFontGlyphRangesBuilder)(); +} +CIMGUI_API void ImFontGlyphRangesBuilder_destroy(ImFontGlyphRangesBuilder* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImFontGlyphRangesBuilder_Clear(ImFontGlyphRangesBuilder* self) +{ + return self->Clear(); +} +CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,size_t n) +{ + return self->GetBit(n); +} +CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,size_t n) +{ + return self->SetBit(n); +} +CIMGUI_API void ImFontGlyphRangesBuilder_AddChar(ImFontGlyphRangesBuilder* self,ImWchar c) +{ + return self->AddChar(c); +} +CIMGUI_API void ImFontGlyphRangesBuilder_AddText(ImFontGlyphRangesBuilder* self,const char* text,const char* text_end) +{ + return self->AddText(text,text_end); +} +CIMGUI_API void ImFontGlyphRangesBuilder_AddRanges(ImFontGlyphRangesBuilder* self,const ImWchar* ranges) +{ + return self->AddRanges(ranges); +} +CIMGUI_API void ImFontGlyphRangesBuilder_BuildRanges(ImFontGlyphRangesBuilder* self,ImVector_ImWchar* out_ranges) +{ + return self->BuildRanges(out_ranges); +} +CIMGUI_API ImFontAtlasCustomRect* ImFontAtlasCustomRect_ImFontAtlasCustomRect(void) +{ + return IM_NEW(ImFontAtlasCustomRect)(); +} +CIMGUI_API void ImFontAtlasCustomRect_destroy(ImFontAtlasCustomRect* self) +{ + IM_DELETE(self); +} +CIMGUI_API bool ImFontAtlasCustomRect_IsPacked(ImFontAtlasCustomRect* self) +{ + return self->IsPacked(); +} +CIMGUI_API ImFontAtlas* ImFontAtlas_ImFontAtlas(void) +{ + return IM_NEW(ImFontAtlas)(); +} +CIMGUI_API void ImFontAtlas_destroy(ImFontAtlas* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImFont* ImFontAtlas_AddFont(ImFontAtlas* self,const ImFontConfig* font_cfg) +{ + return self->AddFont(font_cfg); +} +CIMGUI_API ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* self,const ImFontConfig* font_cfg) +{ + return self->AddFontDefault(font_cfg); +} +CIMGUI_API ImFont* ImFontAtlas_AddFontFromFileTTF(ImFontAtlas* self,const char* filename,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges) +{ + return self->AddFontFromFileTTF(filename,size_pixels,font_cfg,glyph_ranges); +} +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas* self,void* font_data,int font_size,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges) +{ + return self->AddFontFromMemoryTTF(font_data,font_size,size_pixels,font_cfg,glyph_ranges); +} +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryCompressedTTF(ImFontAtlas* self,const void* compressed_font_data,int compressed_font_size,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges) +{ + return self->AddFontFromMemoryCompressedTTF(compressed_font_data,compressed_font_size,size_pixels,font_cfg,glyph_ranges); +} +CIMGUI_API ImFont* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas* self,const char* compressed_font_data_base85,float size_pixels,const ImFontConfig* font_cfg,const ImWchar* glyph_ranges) +{ + return self->AddFontFromMemoryCompressedBase85TTF(compressed_font_data_base85,size_pixels,font_cfg,glyph_ranges); +} +CIMGUI_API void ImFontAtlas_ClearInputData(ImFontAtlas* self) +{ + return self->ClearInputData(); +} +CIMGUI_API void ImFontAtlas_ClearTexData(ImFontAtlas* self) +{ + return self->ClearTexData(); +} +CIMGUI_API void ImFontAtlas_ClearFonts(ImFontAtlas* self) +{ + return self->ClearFonts(); +} +CIMGUI_API void ImFontAtlas_Clear(ImFontAtlas* self) +{ + return self->Clear(); +} +CIMGUI_API bool ImFontAtlas_Build(ImFontAtlas* self) +{ + return self->Build(); +} +CIMGUI_API void ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* self,unsigned char** out_pixels,int* out_width,int* out_height,int* out_bytes_per_pixel) +{ + return self->GetTexDataAsAlpha8(out_pixels,out_width,out_height,out_bytes_per_pixel); +} +CIMGUI_API void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* self,unsigned char** out_pixels,int* out_width,int* out_height,int* out_bytes_per_pixel) +{ + return self->GetTexDataAsRGBA32(out_pixels,out_width,out_height,out_bytes_per_pixel); +} +CIMGUI_API bool ImFontAtlas_IsBuilt(ImFontAtlas* self) +{ + return self->IsBuilt(); +} +CIMGUI_API void ImFontAtlas_SetTexID(ImFontAtlas* self,ImTextureID id) +{ + return self->SetTexID(id); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesDefault(ImFontAtlas* self) +{ + return self->GetGlyphRangesDefault(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesKorean(ImFontAtlas* self) +{ + return self->GetGlyphRangesKorean(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas* self) +{ + return self->GetGlyphRangesJapanese(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesChineseFull(ImFontAtlas* self) +{ + return self->GetGlyphRangesChineseFull(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(ImFontAtlas* self) +{ + return self->GetGlyphRangesChineseSimplifiedCommon(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas* self) +{ + return self->GetGlyphRangesCyrillic(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesThai(ImFontAtlas* self) +{ + return self->GetGlyphRangesThai(); +} +CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesVietnamese(ImFontAtlas* self) +{ + return self->GetGlyphRangesVietnamese(); +} +CIMGUI_API int ImFontAtlas_AddCustomRectRegular(ImFontAtlas* self,int width,int height) +{ + return self->AddCustomRectRegular(width,height); +} +CIMGUI_API int ImFontAtlas_AddCustomRectFontGlyph(ImFontAtlas* self,ImFont* font,ImWchar id,int width,int height,float advance_x,const ImVec2 offset) +{ + return self->AddCustomRectFontGlyph(font,id,width,height,advance_x,offset); +} +CIMGUI_API ImFontAtlasCustomRect* ImFontAtlas_GetCustomRectByIndex(ImFontAtlas* self,int index) +{ + return self->GetCustomRectByIndex(index); +} +CIMGUI_API void ImFontAtlas_CalcCustomRectUV(ImFontAtlas* self,const ImFontAtlasCustomRect* rect,ImVec2* out_uv_min,ImVec2* out_uv_max) +{ + return self->CalcCustomRectUV(rect,out_uv_min,out_uv_max); +} +CIMGUI_API bool ImFontAtlas_GetMouseCursorTexData(ImFontAtlas* self,ImGuiMouseCursor cursor,ImVec2* out_offset,ImVec2* out_size,ImVec2 out_uv_border[2],ImVec2 out_uv_fill[2]) +{ + return self->GetMouseCursorTexData(cursor,out_offset,out_size,out_uv_border,out_uv_fill); +} +CIMGUI_API ImFont* ImFont_ImFont(void) +{ + return IM_NEW(ImFont)(); +} +CIMGUI_API void ImFont_destroy(ImFont* self) +{ + IM_DELETE(self); +} +CIMGUI_API const ImFontGlyph* ImFont_FindGlyph(ImFont* self,ImWchar c) +{ + return self->FindGlyph(c); +} +CIMGUI_API const ImFontGlyph* ImFont_FindGlyphNoFallback(ImFont* self,ImWchar c) +{ + return self->FindGlyphNoFallback(c); +} +CIMGUI_API float ImFont_GetCharAdvance(ImFont* self,ImWchar c) +{ + return self->GetCharAdvance(c); +} +CIMGUI_API bool ImFont_IsLoaded(ImFont* self) +{ + return self->IsLoaded(); +} +CIMGUI_API const char* ImFont_GetDebugName(ImFont* self) +{ + return self->GetDebugName(); +} +CIMGUI_API void ImFont_CalcTextSizeA(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining) +{ + *pOut = self->CalcTextSizeA(size,max_width,wrap_width,text_begin,text_end,remaining); +} +CIMGUI_API const char* ImFont_CalcWordWrapPositionA(ImFont* self,float scale,const char* text,const char* text_end,float wrap_width) +{ + return self->CalcWordWrapPositionA(scale,text,text_end,wrap_width); +} +CIMGUI_API void ImFont_RenderChar(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,ImWchar c) +{ + return self->RenderChar(draw_list,size,pos,col,c); +} +CIMGUI_API void ImFont_RenderText(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,const ImVec4 clip_rect,const char* text_begin,const char* text_end,float wrap_width,bool cpu_fine_clip) +{ + return self->RenderText(draw_list,size,pos,col,clip_rect,text_begin,text_end,wrap_width,cpu_fine_clip); +} +CIMGUI_API void ImFont_BuildLookupTable(ImFont* self) +{ + return self->BuildLookupTable(); +} +CIMGUI_API void ImFont_ClearOutputData(ImFont* self) +{ + return self->ClearOutputData(); +} +CIMGUI_API void ImFont_GrowIndex(ImFont* self,int new_size) +{ + return self->GrowIndex(new_size); +} +CIMGUI_API void ImFont_AddGlyph(ImFont* self,const ImFontConfig* src_cfg,ImWchar c,float x0,float y0,float x1,float y1,float u0,float v0,float u1,float v1,float advance_x) +{ + return self->AddGlyph(src_cfg,c,x0,y0,x1,y1,u0,v0,u1,v1,advance_x); +} +CIMGUI_API void ImFont_AddRemapChar(ImFont* self,ImWchar dst,ImWchar src,bool overwrite_dst) +{ + return self->AddRemapChar(dst,src,overwrite_dst); +} +CIMGUI_API void ImFont_SetGlyphVisible(ImFont* self,ImWchar c,bool visible) +{ + return self->SetGlyphVisible(c,visible); +} +CIMGUI_API bool ImFont_IsGlyphRangeUnused(ImFont* self,unsigned int c_begin,unsigned int c_last) +{ + return self->IsGlyphRangeUnused(c_begin,c_last); +} +CIMGUI_API ImGuiViewport* ImGuiViewport_ImGuiViewport(void) +{ + return IM_NEW(ImGuiViewport)(); +} +CIMGUI_API void ImGuiViewport_destroy(ImGuiViewport* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiViewport_GetCenter(ImVec2 *pOut,ImGuiViewport* self) +{ + *pOut = self->GetCenter(); +} +CIMGUI_API void ImGuiViewport_GetWorkCenter(ImVec2 *pOut,ImGuiViewport* self) +{ + *pOut = self->GetWorkCenter(); +} +CIMGUI_API ImGuiID igImHashData(const void* data,size_t data_size,ImU32 seed) +{ + return ImHashData(data,data_size,seed); +} +CIMGUI_API ImGuiID igImHashStr(const char* data,size_t data_size,ImU32 seed) +{ + return ImHashStr(data,data_size,seed); +} +CIMGUI_API ImU32 igImAlphaBlendColors(ImU32 col_a,ImU32 col_b) +{ + return ImAlphaBlendColors(col_a,col_b); +} +CIMGUI_API bool igImIsPowerOfTwo_Int(int v) +{ + return ImIsPowerOfTwo(v); +} +CIMGUI_API bool igImIsPowerOfTwo_U64(ImU64 v) +{ + return ImIsPowerOfTwo(v); +} +CIMGUI_API int igImUpperPowerOfTwo(int v) +{ + return ImUpperPowerOfTwo(v); +} +CIMGUI_API int igImStricmp(const char* str1,const char* str2) +{ + return ImStricmp(str1,str2); +} +CIMGUI_API int igImStrnicmp(const char* str1,const char* str2,size_t count) +{ + return ImStrnicmp(str1,str2,count); +} +CIMGUI_API void igImStrncpy(char* dst,const char* src,size_t count) +{ + return ImStrncpy(dst,src,count); +} +CIMGUI_API char* igImStrdup(const char* str) +{ + return ImStrdup(str); +} +CIMGUI_API char* igImStrdupcpy(char* dst,size_t* p_dst_size,const char* str) +{ + return ImStrdupcpy(dst,p_dst_size,str); +} +CIMGUI_API const char* igImStrchrRange(const char* str_begin,const char* str_end,char c) +{ + return ImStrchrRange(str_begin,str_end,c); +} +CIMGUI_API int igImStrlenW(const ImWchar* str) +{ + return ImStrlenW(str); +} +CIMGUI_API const char* igImStreolRange(const char* str,const char* str_end) +{ + return ImStreolRange(str,str_end); +} +CIMGUI_API const ImWchar* igImStrbolW(const ImWchar* buf_mid_line,const ImWchar* buf_begin) +{ + return ImStrbolW(buf_mid_line,buf_begin); +} +CIMGUI_API const char* igImStristr(const char* haystack,const char* haystack_end,const char* needle,const char* needle_end) +{ + return ImStristr(haystack,haystack_end,needle,needle_end); +} +CIMGUI_API void igImStrTrimBlanks(char* str) +{ + return ImStrTrimBlanks(str); +} +CIMGUI_API const char* igImStrSkipBlank(const char* str) +{ + return ImStrSkipBlank(str); +} +CIMGUI_API int igImFormatString(char* buf,size_t buf_size,const char* fmt,...) +{ + va_list args; + va_start(args, fmt); + int ret = ImFormatStringV(buf,buf_size,fmt,args); + va_end(args); + return ret; +} +CIMGUI_API int igImFormatStringV(char* buf,size_t buf_size,const char* fmt,va_list args) +{ + return ImFormatStringV(buf,buf_size,fmt,args); +} +CIMGUI_API const char* igImParseFormatFindStart(const char* format) +{ + return ImParseFormatFindStart(format); +} +CIMGUI_API const char* igImParseFormatFindEnd(const char* format) +{ + return ImParseFormatFindEnd(format); +} +CIMGUI_API const char* igImParseFormatTrimDecorations(const char* format,char* buf,size_t buf_size) +{ + return ImParseFormatTrimDecorations(format,buf,buf_size); +} +CIMGUI_API int igImParseFormatPrecision(const char* format,int default_value) +{ + return ImParseFormatPrecision(format,default_value); +} +CIMGUI_API bool igImCharIsBlankA(char c) +{ + return ImCharIsBlankA(c); +} +CIMGUI_API bool igImCharIsBlankW(unsigned int c) +{ + return ImCharIsBlankW(c); +} +CIMGUI_API const char* igImTextCharToUtf8(char out_buf[5],unsigned int c) +{ + return ImTextCharToUtf8(out_buf,c); +} +CIMGUI_API int igImTextStrToUtf8(char* out_buf,int out_buf_size,const ImWchar* in_text,const ImWchar* in_text_end) +{ + return ImTextStrToUtf8(out_buf,out_buf_size,in_text,in_text_end); +} +CIMGUI_API int igImTextCharFromUtf8(unsigned int* out_char,const char* in_text,const char* in_text_end) +{ + return ImTextCharFromUtf8(out_char,in_text,in_text_end); +} +CIMGUI_API int igImTextStrFromUtf8(ImWchar* out_buf,int out_buf_size,const char* in_text,const char* in_text_end,const char** in_remaining) +{ + return ImTextStrFromUtf8(out_buf,out_buf_size,in_text,in_text_end,in_remaining); +} +CIMGUI_API int igImTextCountCharsFromUtf8(const char* in_text,const char* in_text_end) +{ + return ImTextCountCharsFromUtf8(in_text,in_text_end); +} +CIMGUI_API int igImTextCountUtf8BytesFromChar(const char* in_text,const char* in_text_end) +{ + return ImTextCountUtf8BytesFromChar(in_text,in_text_end); +} +CIMGUI_API int igImTextCountUtf8BytesFromStr(const ImWchar* in_text,const ImWchar* in_text_end) +{ + return ImTextCountUtf8BytesFromStr(in_text,in_text_end); +} +CIMGUI_API ImFileHandle igImFileOpen(const char* filename,const char* mode) +{ + return ImFileOpen(filename,mode); +} +CIMGUI_API bool igImFileClose(ImFileHandle file) +{ + return ImFileClose(file); +} +CIMGUI_API ImU64 igImFileGetSize(ImFileHandle file) +{ + return ImFileGetSize(file); +} +CIMGUI_API ImU64 igImFileRead(void* data,ImU64 size,ImU64 count,ImFileHandle file) +{ + return ImFileRead(data,size,count,file); +} +CIMGUI_API ImU64 igImFileWrite(const void* data,ImU64 size,ImU64 count,ImFileHandle file) +{ + return ImFileWrite(data,size,count,file); +} +CIMGUI_API void* igImFileLoadToMemory(const char* filename,const char* mode,size_t* out_file_size,int padding_bytes) +{ + return ImFileLoadToMemory(filename,mode,out_file_size,padding_bytes); +} +CIMGUI_API float igImPow_Float(float x,float y) +{ + return ImPow(x,y); +} +CIMGUI_API double igImPow_double(double x,double y) +{ + return ImPow(x,y); +} +CIMGUI_API float igImLog_Float(float x) +{ + return ImLog(x); +} +CIMGUI_API double igImLog_double(double x) +{ + return ImLog(x); +} +CIMGUI_API int igImAbs_Int(int x) +{ + return ImAbs(x); +} +CIMGUI_API float igImAbs_Float(float x) +{ + return ImAbs(x); +} +CIMGUI_API double igImAbs_double(double x) +{ + return ImAbs(x); +} +CIMGUI_API float igImSign_Float(float x) +{ + return ImSign(x); +} +CIMGUI_API double igImSign_double(double x) +{ + return ImSign(x); +} +CIMGUI_API float igImRsqrt_Float(float x) +{ + return ImRsqrt(x); +} +CIMGUI_API double igImRsqrt_double(double x) +{ + return ImRsqrt(x); +} +CIMGUI_API void igImMin(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs) +{ + *pOut = ImMin(lhs,rhs); +} +CIMGUI_API void igImMax(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs) +{ + *pOut = ImMax(lhs,rhs); +} +CIMGUI_API void igImClamp(ImVec2 *pOut,const ImVec2 v,const ImVec2 mn,ImVec2 mx) +{ + *pOut = ImClamp(v,mn,mx); +} +CIMGUI_API void igImLerp_Vec2Float(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,float t) +{ + *pOut = ImLerp(a,b,t); +} +CIMGUI_API void igImLerp_Vec2Vec2(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 t) +{ + *pOut = ImLerp(a,b,t); +} +CIMGUI_API void igImLerp_Vec4(ImVec4 *pOut,const ImVec4 a,const ImVec4 b,float t) +{ + *pOut = ImLerp(a,b,t); +} +CIMGUI_API float igImSaturate(float f) +{ + return ImSaturate(f); +} +CIMGUI_API float igImLengthSqr_Vec2(const ImVec2 lhs) +{ + return ImLengthSqr(lhs); +} +CIMGUI_API float igImLengthSqr_Vec4(const ImVec4 lhs) +{ + return ImLengthSqr(lhs); +} +CIMGUI_API float igImInvLength(const ImVec2 lhs,float fail_value) +{ + return ImInvLength(lhs,fail_value); +} +CIMGUI_API float igImFloor_Float(float f) +{ + return ImFloor(f); +} +CIMGUI_API float igImFloorSigned(float f) +{ + return ImFloorSigned(f); +} +CIMGUI_API void igImFloor_Vec2(ImVec2 *pOut,const ImVec2 v) +{ + *pOut = ImFloor(v); +} +CIMGUI_API int igImModPositive(int a,int b) +{ + return ImModPositive(a,b); +} +CIMGUI_API float igImDot(const ImVec2 a,const ImVec2 b) +{ + return ImDot(a,b); +} +CIMGUI_API void igImRotate(ImVec2 *pOut,const ImVec2 v,float cos_a,float sin_a) +{ + *pOut = ImRotate(v,cos_a,sin_a); +} +CIMGUI_API float igImLinearSweep(float current,float target,float speed) +{ + return ImLinearSweep(current,target,speed); +} +CIMGUI_API void igImMul(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs) +{ + *pOut = ImMul(lhs,rhs); +} +CIMGUI_API void igImBezierCubicCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,float t) +{ + *pOut = ImBezierCubicCalc(p1,p2,p3,p4,t); +} +CIMGUI_API void igImBezierCubicClosestPoint(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,int num_segments) +{ + *pOut = ImBezierCubicClosestPoint(p1,p2,p3,p4,p,num_segments); +} +CIMGUI_API void igImBezierCubicClosestPointCasteljau(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,float tess_tol) +{ + *pOut = ImBezierCubicClosestPointCasteljau(p1,p2,p3,p4,p,tess_tol); +} +CIMGUI_API void igImBezierQuadraticCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,float t) +{ + *pOut = ImBezierQuadraticCalc(p1,p2,p3,t); +} +CIMGUI_API void igImLineClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 p) +{ + *pOut = ImLineClosestPoint(a,b,p); +} +CIMGUI_API bool igImTriangleContainsPoint(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p) +{ + return ImTriangleContainsPoint(a,b,c,p); +} +CIMGUI_API void igImTriangleClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p) +{ + *pOut = ImTriangleClosestPoint(a,b,c,p); +} +CIMGUI_API void igImTriangleBarycentricCoords(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p,float* out_u,float* out_v,float* out_w) +{ + return ImTriangleBarycentricCoords(a,b,c,p,*out_u,*out_v,*out_w); +} +CIMGUI_API float igImTriangleArea(const ImVec2 a,const ImVec2 b,const ImVec2 c) +{ + return ImTriangleArea(a,b,c); +} +CIMGUI_API ImGuiDir igImGetDirQuadrantFromDelta(float dx,float dy) +{ + return ImGetDirQuadrantFromDelta(dx,dy); +} +CIMGUI_API ImVec1* ImVec1_ImVec1_Nil(void) +{ + return IM_NEW(ImVec1)(); +} +CIMGUI_API void ImVec1_destroy(ImVec1* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImVec1* ImVec1_ImVec1_Float(float _x) +{ + return IM_NEW(ImVec1)(_x); +} +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_Nil(void) +{ + return IM_NEW(ImVec2ih)(); +} +CIMGUI_API void ImVec2ih_destroy(ImVec2ih* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_short(short _x,short _y) +{ + return IM_NEW(ImVec2ih)(_x,_y); +} +CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ih_Vec2(const ImVec2 rhs) +{ + return IM_NEW(ImVec2ih)(rhs); +} +CIMGUI_API ImRect* ImRect_ImRect_Nil(void) +{ + return IM_NEW(ImRect)(); +} +CIMGUI_API void ImRect_destroy(ImRect* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImRect* ImRect_ImRect_Vec2(const ImVec2 min,const ImVec2 max) +{ + return IM_NEW(ImRect)(min,max); +} +CIMGUI_API ImRect* ImRect_ImRect_Vec4(const ImVec4 v) +{ + return IM_NEW(ImRect)(v); +} +CIMGUI_API ImRect* ImRect_ImRect_Float(float x1,float y1,float x2,float y2) +{ + return IM_NEW(ImRect)(x1,y1,x2,y2); +} +CIMGUI_API void ImRect_GetCenter(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetCenter(); +} +CIMGUI_API void ImRect_GetSize(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetSize(); +} +CIMGUI_API float ImRect_GetWidth(ImRect* self) +{ + return self->GetWidth(); +} +CIMGUI_API float ImRect_GetHeight(ImRect* self) +{ + return self->GetHeight(); +} +CIMGUI_API float ImRect_GetArea(ImRect* self) +{ + return self->GetArea(); +} +CIMGUI_API void ImRect_GetTL(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetTL(); +} +CIMGUI_API void ImRect_GetTR(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetTR(); +} +CIMGUI_API void ImRect_GetBL(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetBL(); +} +CIMGUI_API void ImRect_GetBR(ImVec2 *pOut,ImRect* self) +{ + *pOut = self->GetBR(); +} +CIMGUI_API bool ImRect_Contains_Vec2(ImRect* self,const ImVec2 p) +{ + return self->Contains(p); +} +CIMGUI_API bool ImRect_Contains_Rect(ImRect* self,const ImRect r) +{ + return self->Contains(r); +} +CIMGUI_API bool ImRect_Overlaps(ImRect* self,const ImRect r) +{ + return self->Overlaps(r); +} +CIMGUI_API void ImRect_Add_Vec2(ImRect* self,const ImVec2 p) +{ + return self->Add(p); +} +CIMGUI_API void ImRect_Add_Rect(ImRect* self,const ImRect r) +{ + return self->Add(r); +} +CIMGUI_API void ImRect_Expand_Float(ImRect* self,const float amount) +{ + return self->Expand(amount); +} +CIMGUI_API void ImRect_Expand_Vec2(ImRect* self,const ImVec2 amount) +{ + return self->Expand(amount); +} +CIMGUI_API void ImRect_Translate(ImRect* self,const ImVec2 d) +{ + return self->Translate(d); +} +CIMGUI_API void ImRect_TranslateX(ImRect* self,float dx) +{ + return self->TranslateX(dx); +} +CIMGUI_API void ImRect_TranslateY(ImRect* self,float dy) +{ + return self->TranslateY(dy); +} +CIMGUI_API void ImRect_ClipWith(ImRect* self,const ImRect r) +{ + return self->ClipWith(r); +} +CIMGUI_API void ImRect_ClipWithFull(ImRect* self,const ImRect r) +{ + return self->ClipWithFull(r); +} +CIMGUI_API void ImRect_Floor(ImRect* self) +{ + return self->Floor(); +} +CIMGUI_API bool ImRect_IsInverted(ImRect* self) +{ + return self->IsInverted(); +} +CIMGUI_API void ImRect_ToVec4(ImVec4 *pOut,ImRect* self) +{ + *pOut = self->ToVec4(); +} +CIMGUI_API bool igImBitArrayTestBit(const ImU32* arr,int n) +{ + return ImBitArrayTestBit(arr,n); +} +CIMGUI_API void igImBitArrayClearBit(ImU32* arr,int n) +{ + return ImBitArrayClearBit(arr,n); +} +CIMGUI_API void igImBitArraySetBit(ImU32* arr,int n) +{ + return ImBitArraySetBit(arr,n); +} +CIMGUI_API void igImBitArraySetBitRange(ImU32* arr,int n,int n2) +{ + return ImBitArraySetBitRange(arr,n,n2); +} +CIMGUI_API void ImBitVector_Create(ImBitVector* self,int sz) +{ + return self->Create(sz); +} +CIMGUI_API void ImBitVector_Clear(ImBitVector* self) +{ + return self->Clear(); +} +CIMGUI_API bool ImBitVector_TestBit(ImBitVector* self,int n) +{ + return self->TestBit(n); +} +CIMGUI_API void ImBitVector_SetBit(ImBitVector* self,int n) +{ + return self->SetBit(n); +} +CIMGUI_API void ImBitVector_ClearBit(ImBitVector* self,int n) +{ + return self->ClearBit(n); +} +CIMGUI_API ImDrawListSharedData* ImDrawListSharedData_ImDrawListSharedData(void) +{ + return IM_NEW(ImDrawListSharedData)(); +} +CIMGUI_API void ImDrawListSharedData_destroy(ImDrawListSharedData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImDrawListSharedData_SetCircleTessellationMaxError(ImDrawListSharedData* self,float max_error) +{ + return self->SetCircleTessellationMaxError(max_error); +} +CIMGUI_API void ImDrawDataBuilder_Clear(ImDrawDataBuilder* self) +{ + return self->Clear(); +} +CIMGUI_API void ImDrawDataBuilder_ClearFreeMemory(ImDrawDataBuilder* self) +{ + return self->ClearFreeMemory(); +} +CIMGUI_API int ImDrawDataBuilder_GetDrawListCount(ImDrawDataBuilder* self) +{ + return self->GetDrawListCount(); +} +CIMGUI_API void ImDrawDataBuilder_FlattenIntoSingleLayer(ImDrawDataBuilder* self) +{ + return self->FlattenIntoSingleLayer(); +} +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Int(ImGuiStyleVar idx,int v) +{ + return IM_NEW(ImGuiStyleMod)(idx,v); +} +CIMGUI_API void ImGuiStyleMod_destroy(ImGuiStyleMod* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Float(ImGuiStyleVar idx,float v) +{ + return IM_NEW(ImGuiStyleMod)(idx,v); +} +CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleMod_Vec2(ImGuiStyleVar idx,ImVec2 v) +{ + return IM_NEW(ImGuiStyleMod)(idx,v); +} +CIMGUI_API ImGuiComboPreviewData* ImGuiComboPreviewData_ImGuiComboPreviewData(void) +{ + return IM_NEW(ImGuiComboPreviewData)(); +} +CIMGUI_API void ImGuiComboPreviewData_destroy(ImGuiComboPreviewData* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiMenuColumns* ImGuiMenuColumns_ImGuiMenuColumns(void) +{ + return IM_NEW(ImGuiMenuColumns)(); +} +CIMGUI_API void ImGuiMenuColumns_destroy(ImGuiMenuColumns* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiMenuColumns_Update(ImGuiMenuColumns* self,float spacing,bool window_reappearing) +{ + return self->Update(spacing,window_reappearing); +} +CIMGUI_API float ImGuiMenuColumns_DeclColumns(ImGuiMenuColumns* self,float w_icon,float w_label,float w_shortcut,float w_mark) +{ + return self->DeclColumns(w_icon,w_label,w_shortcut,w_mark); +} +CIMGUI_API void ImGuiMenuColumns_CalcNextTotalWidth(ImGuiMenuColumns* self,bool update_offsets) +{ + return self->CalcNextTotalWidth(update_offsets); +} +CIMGUI_API ImGuiInputTextState* ImGuiInputTextState_ImGuiInputTextState(void) +{ + return IM_NEW(ImGuiInputTextState)(); +} +CIMGUI_API void ImGuiInputTextState_destroy(ImGuiInputTextState* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiInputTextState_ClearText(ImGuiInputTextState* self) +{ + return self->ClearText(); +} +CIMGUI_API void ImGuiInputTextState_ClearFreeMemory(ImGuiInputTextState* self) +{ + return self->ClearFreeMemory(); +} +CIMGUI_API int ImGuiInputTextState_GetUndoAvailCount(ImGuiInputTextState* self) +{ + return self->GetUndoAvailCount(); +} +CIMGUI_API int ImGuiInputTextState_GetRedoAvailCount(ImGuiInputTextState* self) +{ + return self->GetRedoAvailCount(); +} +CIMGUI_API void ImGuiInputTextState_OnKeyPressed(ImGuiInputTextState* self,int key) +{ + return self->OnKeyPressed(key); +} +CIMGUI_API void ImGuiInputTextState_CursorAnimReset(ImGuiInputTextState* self) +{ + return self->CursorAnimReset(); +} +CIMGUI_API void ImGuiInputTextState_CursorClamp(ImGuiInputTextState* self) +{ + return self->CursorClamp(); +} +CIMGUI_API bool ImGuiInputTextState_HasSelection(ImGuiInputTextState* self) +{ + return self->HasSelection(); +} +CIMGUI_API void ImGuiInputTextState_ClearSelection(ImGuiInputTextState* self) +{ + return self->ClearSelection(); +} +CIMGUI_API int ImGuiInputTextState_GetCursorPos(ImGuiInputTextState* self) +{ + return self->GetCursorPos(); +} +CIMGUI_API int ImGuiInputTextState_GetSelectionStart(ImGuiInputTextState* self) +{ + return self->GetSelectionStart(); +} +CIMGUI_API int ImGuiInputTextState_GetSelectionEnd(ImGuiInputTextState* self) +{ + return self->GetSelectionEnd(); +} +CIMGUI_API void ImGuiInputTextState_SelectAll(ImGuiInputTextState* self) +{ + return self->SelectAll(); +} +CIMGUI_API ImGuiPopupData* ImGuiPopupData_ImGuiPopupData(void) +{ + return IM_NEW(ImGuiPopupData)(); +} +CIMGUI_API void ImGuiPopupData_destroy(ImGuiPopupData* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiNavItemData* ImGuiNavItemData_ImGuiNavItemData(void) +{ + return IM_NEW(ImGuiNavItemData)(); +} +CIMGUI_API void ImGuiNavItemData_destroy(ImGuiNavItemData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiNavItemData_Clear(ImGuiNavItemData* self) +{ + return self->Clear(); +} +CIMGUI_API ImGuiNextWindowData* ImGuiNextWindowData_ImGuiNextWindowData(void) +{ + return IM_NEW(ImGuiNextWindowData)(); +} +CIMGUI_API void ImGuiNextWindowData_destroy(ImGuiNextWindowData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiNextWindowData_ClearFlags(ImGuiNextWindowData* self) +{ + return self->ClearFlags(); +} +CIMGUI_API ImGuiNextItemData* ImGuiNextItemData_ImGuiNextItemData(void) +{ + return IM_NEW(ImGuiNextItemData)(); +} +CIMGUI_API void ImGuiNextItemData_destroy(ImGuiNextItemData* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiNextItemData_ClearFlags(ImGuiNextItemData* self) +{ + return self->ClearFlags(); +} +CIMGUI_API ImGuiLastItemData* ImGuiLastItemData_ImGuiLastItemData(void) +{ + return IM_NEW(ImGuiLastItemData)(); +} +CIMGUI_API void ImGuiLastItemData_destroy(ImGuiLastItemData* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndex_Ptr(void* ptr) +{ + return IM_NEW(ImGuiPtrOrIndex)(ptr); +} +CIMGUI_API void ImGuiPtrOrIndex_destroy(ImGuiPtrOrIndex* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndex_Int(int index) +{ + return IM_NEW(ImGuiPtrOrIndex)(index); +} +CIMGUI_API ImGuiOldColumnData* ImGuiOldColumnData_ImGuiOldColumnData(void) +{ + return IM_NEW(ImGuiOldColumnData)(); +} +CIMGUI_API void ImGuiOldColumnData_destroy(ImGuiOldColumnData* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiOldColumns* ImGuiOldColumns_ImGuiOldColumns(void) +{ + return IM_NEW(ImGuiOldColumns)(); +} +CIMGUI_API void ImGuiOldColumns_destroy(ImGuiOldColumns* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiViewportP* ImGuiViewportP_ImGuiViewportP(void) +{ + return IM_NEW(ImGuiViewportP)(); +} +CIMGUI_API void ImGuiViewportP_destroy(ImGuiViewportP* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiViewportP_CalcWorkRectPos(ImVec2 *pOut,ImGuiViewportP* self,const ImVec2 off_min) +{ + *pOut = self->CalcWorkRectPos(off_min); +} +CIMGUI_API void ImGuiViewportP_CalcWorkRectSize(ImVec2 *pOut,ImGuiViewportP* self,const ImVec2 off_min,const ImVec2 off_max) +{ + *pOut = self->CalcWorkRectSize(off_min,off_max); +} +CIMGUI_API void ImGuiViewportP_UpdateWorkRect(ImGuiViewportP* self) +{ + return self->UpdateWorkRect(); +} +CIMGUI_API void ImGuiViewportP_GetMainRect(ImRect *pOut,ImGuiViewportP* self) +{ + *pOut = self->GetMainRect(); +} +CIMGUI_API void ImGuiViewportP_GetWorkRect(ImRect *pOut,ImGuiViewportP* self) +{ + *pOut = self->GetWorkRect(); +} +CIMGUI_API void ImGuiViewportP_GetBuildWorkRect(ImRect *pOut,ImGuiViewportP* self) +{ + *pOut = self->GetBuildWorkRect(); +} +CIMGUI_API ImGuiWindowSettings* ImGuiWindowSettings_ImGuiWindowSettings(void) +{ + return IM_NEW(ImGuiWindowSettings)(); +} +CIMGUI_API void ImGuiWindowSettings_destroy(ImGuiWindowSettings* self) +{ + IM_DELETE(self); +} +CIMGUI_API char* ImGuiWindowSettings_GetName(ImGuiWindowSettings* self) +{ + return self->GetName(); +} +CIMGUI_API ImGuiSettingsHandler* ImGuiSettingsHandler_ImGuiSettingsHandler(void) +{ + return IM_NEW(ImGuiSettingsHandler)(); +} +CIMGUI_API void ImGuiSettingsHandler_destroy(ImGuiSettingsHandler* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiMetricsConfig* ImGuiMetricsConfig_ImGuiMetricsConfig(void) +{ + return IM_NEW(ImGuiMetricsConfig)(); +} +CIMGUI_API void ImGuiMetricsConfig_destroy(ImGuiMetricsConfig* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiStackSizes* ImGuiStackSizes_ImGuiStackSizes(void) +{ + return IM_NEW(ImGuiStackSizes)(); +} +CIMGUI_API void ImGuiStackSizes_destroy(ImGuiStackSizes* self) +{ + IM_DELETE(self); +} +CIMGUI_API void ImGuiStackSizes_SetToCurrentState(ImGuiStackSizes* self) +{ + return self->SetToCurrentState(); +} +CIMGUI_API void ImGuiStackSizes_CompareWithCurrentState(ImGuiStackSizes* self) +{ + return self->CompareWithCurrentState(); +} +CIMGUI_API ImGuiContextHook* ImGuiContextHook_ImGuiContextHook(void) +{ + return IM_NEW(ImGuiContextHook)(); +} +CIMGUI_API void ImGuiContextHook_destroy(ImGuiContextHook* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiContext* ImGuiContext_ImGuiContext(ImFontAtlas* shared_font_atlas) +{ + return IM_NEW(ImGuiContext)(shared_font_atlas); +} +CIMGUI_API void ImGuiContext_destroy(ImGuiContext* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiWindow* ImGuiWindow_ImGuiWindow(ImGuiContext* context,const char* name) +{ + return IM_NEW(ImGuiWindow)(context,name); +} +CIMGUI_API void ImGuiWindow_destroy(ImGuiWindow* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiID ImGuiWindow_GetID_Str(ImGuiWindow* self,const char* str,const char* str_end) +{ + return self->GetID(str,str_end); +} +CIMGUI_API ImGuiID ImGuiWindow_GetID_Ptr(ImGuiWindow* self,const void* ptr) +{ + return self->GetID(ptr); +} +CIMGUI_API ImGuiID ImGuiWindow_GetID_Int(ImGuiWindow* self,int n) +{ + return self->GetID(n); +} +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Str(ImGuiWindow* self,const char* str,const char* str_end) +{ + return self->GetIDNoKeepAlive(str,str_end); +} +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Ptr(ImGuiWindow* self,const void* ptr) +{ + return self->GetIDNoKeepAlive(ptr); +} +CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlive_Int(ImGuiWindow* self,int n) +{ + return self->GetIDNoKeepAlive(n); +} +CIMGUI_API ImGuiID ImGuiWindow_GetIDFromRectangle(ImGuiWindow* self,const ImRect r_abs) +{ + return self->GetIDFromRectangle(r_abs); +} +CIMGUI_API void ImGuiWindow_Rect(ImRect *pOut,ImGuiWindow* self) +{ + *pOut = self->Rect(); +} +CIMGUI_API float ImGuiWindow_CalcFontSize(ImGuiWindow* self) +{ + return self->CalcFontSize(); +} +CIMGUI_API float ImGuiWindow_TitleBarHeight(ImGuiWindow* self) +{ + return self->TitleBarHeight(); +} +CIMGUI_API void ImGuiWindow_TitleBarRect(ImRect *pOut,ImGuiWindow* self) +{ + *pOut = self->TitleBarRect(); +} +CIMGUI_API float ImGuiWindow_MenuBarHeight(ImGuiWindow* self) +{ + return self->MenuBarHeight(); +} +CIMGUI_API void ImGuiWindow_MenuBarRect(ImRect *pOut,ImGuiWindow* self) +{ + *pOut = self->MenuBarRect(); +} +CIMGUI_API ImGuiTabItem* ImGuiTabItem_ImGuiTabItem(void) +{ + return IM_NEW(ImGuiTabItem)(); +} +CIMGUI_API void ImGuiTabItem_destroy(ImGuiTabItem* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTabBar* ImGuiTabBar_ImGuiTabBar(void) +{ + return IM_NEW(ImGuiTabBar)(); +} +CIMGUI_API void ImGuiTabBar_destroy(ImGuiTabBar* self) +{ + IM_DELETE(self); +} +CIMGUI_API int ImGuiTabBar_GetTabOrder(ImGuiTabBar* self,const ImGuiTabItem* tab) +{ + return self->GetTabOrder(tab); +} +CIMGUI_API const char* ImGuiTabBar_GetTabName(ImGuiTabBar* self,const ImGuiTabItem* tab) +{ + return self->GetTabName(tab); +} +CIMGUI_API ImGuiTableColumn* ImGuiTableColumn_ImGuiTableColumn(void) +{ + return IM_NEW(ImGuiTableColumn)(); +} +CIMGUI_API void ImGuiTableColumn_destroy(ImGuiTableColumn* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTable* ImGuiTable_ImGuiTable(void) +{ + return IM_NEW(ImGuiTable)(); +} +CIMGUI_API void ImGuiTable_destroy(ImGuiTable* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTableTempData* ImGuiTableTempData_ImGuiTableTempData(void) +{ + return IM_NEW(ImGuiTableTempData)(); +} +CIMGUI_API void ImGuiTableTempData_destroy(ImGuiTableTempData* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTableColumnSettings* ImGuiTableColumnSettings_ImGuiTableColumnSettings(void) +{ + return IM_NEW(ImGuiTableColumnSettings)(); +} +CIMGUI_API void ImGuiTableColumnSettings_destroy(ImGuiTableColumnSettings* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTableSettings* ImGuiTableSettings_ImGuiTableSettings(void) +{ + return IM_NEW(ImGuiTableSettings)(); +} +CIMGUI_API void ImGuiTableSettings_destroy(ImGuiTableSettings* self) +{ + IM_DELETE(self); +} +CIMGUI_API ImGuiTableColumnSettings* ImGuiTableSettings_GetColumnSettings(ImGuiTableSettings* self) +{ + return self->GetColumnSettings(); +} +CIMGUI_API ImGuiWindow* igGetCurrentWindowRead() +{ + return ImGui::GetCurrentWindowRead(); +} +CIMGUI_API ImGuiWindow* igGetCurrentWindow() +{ + return ImGui::GetCurrentWindow(); +} +CIMGUI_API ImGuiWindow* igFindWindowByID(ImGuiID id) +{ + return ImGui::FindWindowByID(id); +} +CIMGUI_API ImGuiWindow* igFindWindowByName(const char* name) +{ + return ImGui::FindWindowByName(name); +} +CIMGUI_API void igUpdateWindowParentAndRootLinks(ImGuiWindow* window,ImGuiWindowFlags flags,ImGuiWindow* parent_window) +{ + return ImGui::UpdateWindowParentAndRootLinks(window,flags,parent_window); +} +CIMGUI_API void igCalcWindowNextAutoFitSize(ImVec2 *pOut,ImGuiWindow* window) +{ + *pOut = ImGui::CalcWindowNextAutoFitSize(window); +} +CIMGUI_API bool igIsWindowChildOf(ImGuiWindow* window,ImGuiWindow* potential_parent) +{ + return ImGui::IsWindowChildOf(window,potential_parent); +} +CIMGUI_API bool igIsWindowAbove(ImGuiWindow* potential_above,ImGuiWindow* potential_below) +{ + return ImGui::IsWindowAbove(potential_above,potential_below); +} +CIMGUI_API bool igIsWindowNavFocusable(ImGuiWindow* window) +{ + return ImGui::IsWindowNavFocusable(window); +} +CIMGUI_API void igSetWindowPos_WindowPtr(ImGuiWindow* window,const ImVec2 pos,ImGuiCond cond) +{ + return ImGui::SetWindowPos(window,pos,cond); +} +CIMGUI_API void igSetWindowSize_WindowPtr(ImGuiWindow* window,const ImVec2 size,ImGuiCond cond) +{ + return ImGui::SetWindowSize(window,size,cond); +} +CIMGUI_API void igSetWindowCollapsed_WindowPtr(ImGuiWindow* window,bool collapsed,ImGuiCond cond) +{ + return ImGui::SetWindowCollapsed(window,collapsed,cond); +} +CIMGUI_API void igSetWindowHitTestHole(ImGuiWindow* window,const ImVec2 pos,const ImVec2 size) +{ + return ImGui::SetWindowHitTestHole(window,pos,size); +} +CIMGUI_API void igFocusWindow(ImGuiWindow* window) +{ + return ImGui::FocusWindow(window); +} +CIMGUI_API void igFocusTopMostWindowUnderOne(ImGuiWindow* under_this_window,ImGuiWindow* ignore_window) +{ + return ImGui::FocusTopMostWindowUnderOne(under_this_window,ignore_window); +} +CIMGUI_API void igBringWindowToFocusFront(ImGuiWindow* window) +{ + return ImGui::BringWindowToFocusFront(window); +} +CIMGUI_API void igBringWindowToDisplayFront(ImGuiWindow* window) +{ + return ImGui::BringWindowToDisplayFront(window); +} +CIMGUI_API void igBringWindowToDisplayBack(ImGuiWindow* window) +{ + return ImGui::BringWindowToDisplayBack(window); +} +CIMGUI_API void igSetCurrentFont(ImFont* font) +{ + return ImGui::SetCurrentFont(font); +} +CIMGUI_API ImFont* igGetDefaultFont() +{ + return ImGui::GetDefaultFont(); +} +CIMGUI_API ImDrawList* igGetForegroundDrawList_WindowPtr(ImGuiWindow* window) +{ + return ImGui::GetForegroundDrawList(window); +} +CIMGUI_API ImDrawList* igGetBackgroundDrawList_ViewportPtr(ImGuiViewport* viewport) +{ + return ImGui::GetBackgroundDrawList(viewport); +} +CIMGUI_API ImDrawList* igGetForegroundDrawList_ViewportPtr(ImGuiViewport* viewport) +{ + return ImGui::GetForegroundDrawList(viewport); +} +CIMGUI_API void igInitialize(ImGuiContext* context) +{ + return ImGui::Initialize(context); +} +CIMGUI_API void igShutdown(ImGuiContext* context) +{ + return ImGui::Shutdown(context); +} +CIMGUI_API void igUpdateHoveredWindowAndCaptureFlags() +{ + return ImGui::UpdateHoveredWindowAndCaptureFlags(); +} +CIMGUI_API void igStartMouseMovingWindow(ImGuiWindow* window) +{ + return ImGui::StartMouseMovingWindow(window); +} +CIMGUI_API void igUpdateMouseMovingWindowNewFrame() +{ + return ImGui::UpdateMouseMovingWindowNewFrame(); +} +CIMGUI_API void igUpdateMouseMovingWindowEndFrame() +{ + return ImGui::UpdateMouseMovingWindowEndFrame(); +} +CIMGUI_API ImGuiID igAddContextHook(ImGuiContext* context,const ImGuiContextHook* hook) +{ + return ImGui::AddContextHook(context,hook); +} +CIMGUI_API void igRemoveContextHook(ImGuiContext* context,ImGuiID hook_to_remove) +{ + return ImGui::RemoveContextHook(context,hook_to_remove); +} +CIMGUI_API void igCallContextHooks(ImGuiContext* context,ImGuiContextHookType type) +{ + return ImGui::CallContextHooks(context,type); +} +CIMGUI_API void igMarkIniSettingsDirty_Nil() +{ + return ImGui::MarkIniSettingsDirty(); +} +CIMGUI_API void igMarkIniSettingsDirty_WindowPtr(ImGuiWindow* window) +{ + return ImGui::MarkIniSettingsDirty(window); +} +CIMGUI_API void igClearIniSettings() +{ + return ImGui::ClearIniSettings(); +} +CIMGUI_API ImGuiWindowSettings* igCreateNewWindowSettings(const char* name) +{ + return ImGui::CreateNewWindowSettings(name); +} +CIMGUI_API ImGuiWindowSettings* igFindWindowSettings(ImGuiID id) +{ + return ImGui::FindWindowSettings(id); +} +CIMGUI_API ImGuiWindowSettings* igFindOrCreateWindowSettings(const char* name) +{ + return ImGui::FindOrCreateWindowSettings(name); +} +CIMGUI_API ImGuiSettingsHandler* igFindSettingsHandler(const char* type_name) +{ + return ImGui::FindSettingsHandler(type_name); +} +CIMGUI_API void igSetNextWindowScroll(const ImVec2 scroll) +{ + return ImGui::SetNextWindowScroll(scroll); +} +CIMGUI_API void igSetScrollX_WindowPtr(ImGuiWindow* window,float scroll_x) +{ + return ImGui::SetScrollX(window,scroll_x); +} +CIMGUI_API void igSetScrollY_WindowPtr(ImGuiWindow* window,float scroll_y) +{ + return ImGui::SetScrollY(window,scroll_y); +} +CIMGUI_API void igSetScrollFromPosX_WindowPtr(ImGuiWindow* window,float local_x,float center_x_ratio) +{ + return ImGui::SetScrollFromPosX(window,local_x,center_x_ratio); +} +CIMGUI_API void igSetScrollFromPosY_WindowPtr(ImGuiWindow* window,float local_y,float center_y_ratio) +{ + return ImGui::SetScrollFromPosY(window,local_y,center_y_ratio); +} +CIMGUI_API void igScrollToBringRectIntoView(ImVec2 *pOut,ImGuiWindow* window,const ImRect item_rect) +{ + *pOut = ImGui::ScrollToBringRectIntoView(window,item_rect); +} +CIMGUI_API ImGuiID igGetItemID() +{ + return ImGui::GetItemID(); +} +CIMGUI_API ImGuiItemStatusFlags igGetItemStatusFlags() +{ + return ImGui::GetItemStatusFlags(); +} +CIMGUI_API ImGuiItemFlags igGetItemFlags() +{ + return ImGui::GetItemFlags(); +} +CIMGUI_API ImGuiID igGetActiveID() +{ + return ImGui::GetActiveID(); +} +CIMGUI_API ImGuiID igGetFocusID() +{ + return ImGui::GetFocusID(); +} +CIMGUI_API void igSetActiveID(ImGuiID id,ImGuiWindow* window) +{ + return ImGui::SetActiveID(id,window); +} +CIMGUI_API void igSetFocusID(ImGuiID id,ImGuiWindow* window) +{ + return ImGui::SetFocusID(id,window); +} +CIMGUI_API void igClearActiveID() +{ + return ImGui::ClearActiveID(); +} +CIMGUI_API ImGuiID igGetHoveredID() +{ + return ImGui::GetHoveredID(); +} +CIMGUI_API void igSetHoveredID(ImGuiID id) +{ + return ImGui::SetHoveredID(id); +} +CIMGUI_API void igKeepAliveID(ImGuiID id) +{ + return ImGui::KeepAliveID(id); +} +CIMGUI_API void igMarkItemEdited(ImGuiID id) +{ + return ImGui::MarkItemEdited(id); +} +CIMGUI_API void igPushOverrideID(ImGuiID id) +{ + return ImGui::PushOverrideID(id); +} +CIMGUI_API ImGuiID igGetIDWithSeed(const char* str_id_begin,const char* str_id_end,ImGuiID seed) +{ + return ImGui::GetIDWithSeed(str_id_begin,str_id_end,seed); +} +CIMGUI_API void igItemSize_Vec2(const ImVec2 size,float text_baseline_y) +{ + return ImGui::ItemSize(size,text_baseline_y); +} +CIMGUI_API void igItemSize_Rect(const ImRect bb,float text_baseline_y) +{ + return ImGui::ItemSize(bb,text_baseline_y); +} +CIMGUI_API bool igItemAdd(const ImRect bb,ImGuiID id,const ImRect* nav_bb,ImGuiItemAddFlags flags) +{ + return ImGui::ItemAdd(bb,id,nav_bb,flags); +} +CIMGUI_API bool igItemHoverable(const ImRect bb,ImGuiID id) +{ + return ImGui::ItemHoverable(bb,id); +} +CIMGUI_API void igItemFocusable(ImGuiWindow* window,ImGuiID id) +{ + return ImGui::ItemFocusable(window,id); +} +CIMGUI_API bool igIsClippedEx(const ImRect bb,ImGuiID id,bool clip_even_when_logged) +{ + return ImGui::IsClippedEx(bb,id,clip_even_when_logged); +} +CIMGUI_API void igCalcItemSize(ImVec2 *pOut,ImVec2 size,float default_w,float default_h) +{ + *pOut = ImGui::CalcItemSize(size,default_w,default_h); +} +CIMGUI_API float igCalcWrapWidthForPos(const ImVec2 pos,float wrap_pos_x) +{ + return ImGui::CalcWrapWidthForPos(pos,wrap_pos_x); +} +CIMGUI_API void igPushMultiItemsWidths(int components,float width_full) +{ + return ImGui::PushMultiItemsWidths(components,width_full); +} +CIMGUI_API bool igIsItemToggledSelection() +{ + return ImGui::IsItemToggledSelection(); +} +CIMGUI_API void igGetContentRegionMaxAbs(ImVec2 *pOut) +{ + *pOut = ImGui::GetContentRegionMaxAbs(); +} +CIMGUI_API void igShrinkWidths(ImGuiShrinkWidthItem* items,int count,float width_excess) +{ + return ImGui::ShrinkWidths(items,count,width_excess); +} +CIMGUI_API void igPushItemFlag(ImGuiItemFlags option,bool enabled) +{ + return ImGui::PushItemFlag(option,enabled); +} +CIMGUI_API void igPopItemFlag() +{ + return ImGui::PopItemFlag(); +} +CIMGUI_API void igLogBegin(ImGuiLogType type,int auto_open_depth) +{ + return ImGui::LogBegin(type,auto_open_depth); +} +CIMGUI_API void igLogToBuffer(int auto_open_depth) +{ + return ImGui::LogToBuffer(auto_open_depth); +} +CIMGUI_API void igLogRenderedText(const ImVec2* ref_pos,const char* text,const char* text_end) +{ + return ImGui::LogRenderedText(ref_pos,text,text_end); +} +CIMGUI_API void igLogSetNextTextDecoration(const char* prefix,const char* suffix) +{ + return ImGui::LogSetNextTextDecoration(prefix,suffix); +} +CIMGUI_API bool igBeginChildEx(const char* name,ImGuiID id,const ImVec2 size_arg,bool border,ImGuiWindowFlags flags) +{ + return ImGui::BeginChildEx(name,id,size_arg,border,flags); +} +CIMGUI_API void igOpenPopupEx(ImGuiID id,ImGuiPopupFlags popup_flags) +{ + return ImGui::OpenPopupEx(id,popup_flags); +} +CIMGUI_API void igClosePopupToLevel(int remaining,bool restore_focus_to_window_under_popup) +{ + return ImGui::ClosePopupToLevel(remaining,restore_focus_to_window_under_popup); +} +CIMGUI_API void igClosePopupsOverWindow(ImGuiWindow* ref_window,bool restore_focus_to_window_under_popup) +{ + return ImGui::ClosePopupsOverWindow(ref_window,restore_focus_to_window_under_popup); +} +CIMGUI_API bool igIsPopupOpen_ID(ImGuiID id,ImGuiPopupFlags popup_flags) +{ + return ImGui::IsPopupOpen(id,popup_flags); +} +CIMGUI_API bool igBeginPopupEx(ImGuiID id,ImGuiWindowFlags extra_flags) +{ + return ImGui::BeginPopupEx(id,extra_flags); +} +CIMGUI_API void igBeginTooltipEx(ImGuiWindowFlags extra_flags,ImGuiTooltipFlags tooltip_flags) +{ + return ImGui::BeginTooltipEx(extra_flags,tooltip_flags); +} +CIMGUI_API void igGetPopupAllowedExtentRect(ImRect *pOut,ImGuiWindow* window) +{ + *pOut = ImGui::GetPopupAllowedExtentRect(window); +} +CIMGUI_API ImGuiWindow* igGetTopMostPopupModal() +{ + return ImGui::GetTopMostPopupModal(); +} +CIMGUI_API void igFindBestWindowPosForPopup(ImVec2 *pOut,ImGuiWindow* window) +{ + *pOut = ImGui::FindBestWindowPosForPopup(window); +} +CIMGUI_API void igFindBestWindowPosForPopupEx(ImVec2 *pOut,const ImVec2 ref_pos,const ImVec2 size,ImGuiDir* last_dir,const ImRect r_outer,const ImRect r_avoid,ImGuiPopupPositionPolicy policy) +{ + *pOut = ImGui::FindBestWindowPosForPopupEx(ref_pos,size,last_dir,r_outer,r_avoid,policy); +} +CIMGUI_API bool igBeginViewportSideBar(const char* name,ImGuiViewport* viewport,ImGuiDir dir,float size,ImGuiWindowFlags window_flags) +{ + return ImGui::BeginViewportSideBar(name,viewport,dir,size,window_flags); +} +CIMGUI_API bool igMenuItemEx(const char* label,const char* icon,const char* shortcut,bool selected,bool enabled) +{ + return ImGui::MenuItemEx(label,icon,shortcut,selected,enabled); +} +CIMGUI_API bool igBeginComboPopup(ImGuiID popup_id,const ImRect bb,ImGuiComboFlags flags) +{ + return ImGui::BeginComboPopup(popup_id,bb,flags); +} +CIMGUI_API bool igBeginComboPreview() +{ + return ImGui::BeginComboPreview(); +} +CIMGUI_API void igEndComboPreview() +{ + return ImGui::EndComboPreview(); +} +CIMGUI_API void igNavInitWindow(ImGuiWindow* window,bool force_reinit) +{ + return ImGui::NavInitWindow(window,force_reinit); +} +CIMGUI_API bool igNavMoveRequestButNoResultYet() +{ + return ImGui::NavMoveRequestButNoResultYet(); +} +CIMGUI_API void igNavMoveRequestCancel() +{ + return ImGui::NavMoveRequestCancel(); +} +CIMGUI_API void igNavMoveRequestForward(ImGuiDir move_dir,ImGuiDir clip_dir,const ImRect bb_rel,ImGuiNavMoveFlags move_flags) +{ + return ImGui::NavMoveRequestForward(move_dir,clip_dir,bb_rel,move_flags); +} +CIMGUI_API void igNavMoveRequestTryWrapping(ImGuiWindow* window,ImGuiNavMoveFlags move_flags) +{ + return ImGui::NavMoveRequestTryWrapping(window,move_flags); +} +CIMGUI_API float igGetNavInputAmount(ImGuiNavInput n,ImGuiInputReadMode mode) +{ + return ImGui::GetNavInputAmount(n,mode); +} +CIMGUI_API void igGetNavInputAmount2d(ImVec2 *pOut,ImGuiNavDirSourceFlags dir_sources,ImGuiInputReadMode mode,float slow_factor,float fast_factor) +{ + *pOut = ImGui::GetNavInputAmount2d(dir_sources,mode,slow_factor,fast_factor); +} +CIMGUI_API int igCalcTypematicRepeatAmount(float t0,float t1,float repeat_delay,float repeat_rate) +{ + return ImGui::CalcTypematicRepeatAmount(t0,t1,repeat_delay,repeat_rate); +} +CIMGUI_API void igActivateItem(ImGuiID id) +{ + return ImGui::ActivateItem(id); +} +CIMGUI_API void igSetNavID(ImGuiID id,ImGuiNavLayer nav_layer,ImGuiID focus_scope_id,const ImRect rect_rel) +{ + return ImGui::SetNavID(id,nav_layer,focus_scope_id,rect_rel); +} +CIMGUI_API void igPushFocusScope(ImGuiID id) +{ + return ImGui::PushFocusScope(id); +} +CIMGUI_API void igPopFocusScope() +{ + return ImGui::PopFocusScope(); +} +CIMGUI_API ImGuiID igGetFocusedFocusScope() +{ + return ImGui::GetFocusedFocusScope(); +} +CIMGUI_API ImGuiID igGetFocusScope() +{ + return ImGui::GetFocusScope(); +} +CIMGUI_API void igSetItemUsingMouseWheel() +{ + return ImGui::SetItemUsingMouseWheel(); +} +CIMGUI_API void igSetActiveIdUsingNavAndKeys() +{ + return ImGui::SetActiveIdUsingNavAndKeys(); +} +CIMGUI_API bool igIsActiveIdUsingNavDir(ImGuiDir dir) +{ + return ImGui::IsActiveIdUsingNavDir(dir); +} +CIMGUI_API bool igIsActiveIdUsingNavInput(ImGuiNavInput input) +{ + return ImGui::IsActiveIdUsingNavInput(input); +} +CIMGUI_API bool igIsActiveIdUsingKey(ImGuiKey key) +{ + return ImGui::IsActiveIdUsingKey(key); +} +CIMGUI_API bool igIsMouseDragPastThreshold(ImGuiMouseButton button,float lock_threshold) +{ + return ImGui::IsMouseDragPastThreshold(button,lock_threshold); +} +CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat) +{ + return ImGui::IsKeyPressedMap(key,repeat); +} +CIMGUI_API bool igIsNavInputDown(ImGuiNavInput n) +{ + return ImGui::IsNavInputDown(n); +} +CIMGUI_API bool igIsNavInputTest(ImGuiNavInput n,ImGuiInputReadMode rm) +{ + return ImGui::IsNavInputTest(n,rm); +} +CIMGUI_API ImGuiKeyModFlags igGetMergedKeyModFlags() +{ + return ImGui::GetMergedKeyModFlags(); +} +CIMGUI_API bool igBeginDragDropTargetCustom(const ImRect bb,ImGuiID id) +{ + return ImGui::BeginDragDropTargetCustom(bb,id); +} +CIMGUI_API void igClearDragDrop() +{ + return ImGui::ClearDragDrop(); +} +CIMGUI_API bool igIsDragDropPayloadBeingAccepted() +{ + return ImGui::IsDragDropPayloadBeingAccepted(); +} +CIMGUI_API void igSetWindowClipRectBeforeSetChannel(ImGuiWindow* window,const ImRect clip_rect) +{ + return ImGui::SetWindowClipRectBeforeSetChannel(window,clip_rect); +} +CIMGUI_API void igBeginColumns(const char* str_id,int count,ImGuiOldColumnFlags flags) +{ + return ImGui::BeginColumns(str_id,count,flags); +} +CIMGUI_API void igEndColumns() +{ + return ImGui::EndColumns(); +} +CIMGUI_API void igPushColumnClipRect(int column_index) +{ + return ImGui::PushColumnClipRect(column_index); +} +CIMGUI_API void igPushColumnsBackground() +{ + return ImGui::PushColumnsBackground(); +} +CIMGUI_API void igPopColumnsBackground() +{ + return ImGui::PopColumnsBackground(); +} +CIMGUI_API ImGuiID igGetColumnsID(const char* str_id,int count) +{ + return ImGui::GetColumnsID(str_id,count); +} +CIMGUI_API ImGuiOldColumns* igFindOrCreateColumns(ImGuiWindow* window,ImGuiID id) +{ + return ImGui::FindOrCreateColumns(window,id); +} +CIMGUI_API float igGetColumnOffsetFromNorm(const ImGuiOldColumns* columns,float offset_norm) +{ + return ImGui::GetColumnOffsetFromNorm(columns,offset_norm); +} +CIMGUI_API float igGetColumnNormFromOffset(const ImGuiOldColumns* columns,float offset) +{ + return ImGui::GetColumnNormFromOffset(columns,offset); +} +CIMGUI_API void igTableOpenContextMenu(int column_n) +{ + return ImGui::TableOpenContextMenu(column_n); +} +CIMGUI_API void igTableSetColumnWidth(int column_n,float width) +{ + return ImGui::TableSetColumnWidth(column_n,width); +} +CIMGUI_API void igTableSetColumnSortDirection(int column_n,ImGuiSortDirection sort_direction,bool append_to_sort_specs) +{ + return ImGui::TableSetColumnSortDirection(column_n,sort_direction,append_to_sort_specs); +} +CIMGUI_API int igTableGetHoveredColumn() +{ + return ImGui::TableGetHoveredColumn(); +} +CIMGUI_API float igTableGetHeaderRowHeight() +{ + return ImGui::TableGetHeaderRowHeight(); +} +CIMGUI_API void igTablePushBackgroundChannel() +{ + return ImGui::TablePushBackgroundChannel(); +} +CIMGUI_API void igTablePopBackgroundChannel() +{ + return ImGui::TablePopBackgroundChannel(); +} +CIMGUI_API ImGuiTable* igGetCurrentTable() +{ + return ImGui::GetCurrentTable(); +} +CIMGUI_API ImGuiTable* igTableFindByID(ImGuiID id) +{ + return ImGui::TableFindByID(id); +} +CIMGUI_API bool igBeginTableEx(const char* name,ImGuiID id,int columns_count,ImGuiTableFlags flags,const ImVec2 outer_size,float inner_width) +{ + return ImGui::BeginTableEx(name,id,columns_count,flags,outer_size,inner_width); +} +CIMGUI_API void igTableBeginInitMemory(ImGuiTable* table,int columns_count) +{ + return ImGui::TableBeginInitMemory(table,columns_count); +} +CIMGUI_API void igTableBeginApplyRequests(ImGuiTable* table) +{ + return ImGui::TableBeginApplyRequests(table); +} +CIMGUI_API void igTableSetupDrawChannels(ImGuiTable* table) +{ + return ImGui::TableSetupDrawChannels(table); +} +CIMGUI_API void igTableUpdateLayout(ImGuiTable* table) +{ + return ImGui::TableUpdateLayout(table); +} +CIMGUI_API void igTableUpdateBorders(ImGuiTable* table) +{ + return ImGui::TableUpdateBorders(table); +} +CIMGUI_API void igTableUpdateColumnsWeightFromWidth(ImGuiTable* table) +{ + return ImGui::TableUpdateColumnsWeightFromWidth(table); +} +CIMGUI_API void igTableDrawBorders(ImGuiTable* table) +{ + return ImGui::TableDrawBorders(table); +} +CIMGUI_API void igTableDrawContextMenu(ImGuiTable* table) +{ + return ImGui::TableDrawContextMenu(table); +} +CIMGUI_API void igTableMergeDrawChannels(ImGuiTable* table) +{ + return ImGui::TableMergeDrawChannels(table); +} +CIMGUI_API void igTableSortSpecsSanitize(ImGuiTable* table) +{ + return ImGui::TableSortSpecsSanitize(table); +} +CIMGUI_API void igTableSortSpecsBuild(ImGuiTable* table) +{ + return ImGui::TableSortSpecsBuild(table); +} +CIMGUI_API ImGuiSortDirection igTableGetColumnNextSortDirection(ImGuiTableColumn* column) +{ + return ImGui::TableGetColumnNextSortDirection(column); +} +CIMGUI_API void igTableFixColumnSortDirection(ImGuiTable* table,ImGuiTableColumn* column) +{ + return ImGui::TableFixColumnSortDirection(table,column); +} +CIMGUI_API float igTableGetColumnWidthAuto(ImGuiTable* table,ImGuiTableColumn* column) +{ + return ImGui::TableGetColumnWidthAuto(table,column); +} +CIMGUI_API void igTableBeginRow(ImGuiTable* table) +{ + return ImGui::TableBeginRow(table); +} +CIMGUI_API void igTableEndRow(ImGuiTable* table) +{ + return ImGui::TableEndRow(table); +} +CIMGUI_API void igTableBeginCell(ImGuiTable* table,int column_n) +{ + return ImGui::TableBeginCell(table,column_n); +} +CIMGUI_API void igTableEndCell(ImGuiTable* table) +{ + return ImGui::TableEndCell(table); +} +CIMGUI_API void igTableGetCellBgRect(ImRect *pOut,const ImGuiTable* table,int column_n) +{ + *pOut = ImGui::TableGetCellBgRect(table,column_n); +} +CIMGUI_API const char* igTableGetColumnName_TablePtr(const ImGuiTable* table,int column_n) +{ + return ImGui::TableGetColumnName(table,column_n); +} +CIMGUI_API ImGuiID igTableGetColumnResizeID(const ImGuiTable* table,int column_n,int instance_no) +{ + return ImGui::TableGetColumnResizeID(table,column_n,instance_no); +} +CIMGUI_API float igTableGetMaxColumnWidth(const ImGuiTable* table,int column_n) +{ + return ImGui::TableGetMaxColumnWidth(table,column_n); +} +CIMGUI_API void igTableSetColumnWidthAutoSingle(ImGuiTable* table,int column_n) +{ + return ImGui::TableSetColumnWidthAutoSingle(table,column_n); +} +CIMGUI_API void igTableSetColumnWidthAutoAll(ImGuiTable* table) +{ + return ImGui::TableSetColumnWidthAutoAll(table); +} +CIMGUI_API void igTableRemove(ImGuiTable* table) +{ + return ImGui::TableRemove(table); +} +CIMGUI_API void igTableGcCompactTransientBuffers_TablePtr(ImGuiTable* table) +{ + return ImGui::TableGcCompactTransientBuffers(table); +} +CIMGUI_API void igTableGcCompactTransientBuffers_TableTempDataPtr(ImGuiTableTempData* table) +{ + return ImGui::TableGcCompactTransientBuffers(table); +} +CIMGUI_API void igTableGcCompactSettings() +{ + return ImGui::TableGcCompactSettings(); +} +CIMGUI_API void igTableLoadSettings(ImGuiTable* table) +{ + return ImGui::TableLoadSettings(table); +} +CIMGUI_API void igTableSaveSettings(ImGuiTable* table) +{ + return ImGui::TableSaveSettings(table); +} +CIMGUI_API void igTableResetSettings(ImGuiTable* table) +{ + return ImGui::TableResetSettings(table); +} +CIMGUI_API ImGuiTableSettings* igTableGetBoundSettings(ImGuiTable* table) +{ + return ImGui::TableGetBoundSettings(table); +} +CIMGUI_API void igTableSettingsInstallHandler(ImGuiContext* context) +{ + return ImGui::TableSettingsInstallHandler(context); +} +CIMGUI_API ImGuiTableSettings* igTableSettingsCreate(ImGuiID id,int columns_count) +{ + return ImGui::TableSettingsCreate(id,columns_count); +} +CIMGUI_API ImGuiTableSettings* igTableSettingsFindByID(ImGuiID id) +{ + return ImGui::TableSettingsFindByID(id); +} +CIMGUI_API bool igBeginTabBarEx(ImGuiTabBar* tab_bar,const ImRect bb,ImGuiTabBarFlags flags,ImGuiDockNode* dock_node) +{ + return ImGui::BeginTabBarEx(tab_bar,bb,flags,dock_node); +} +CIMGUI_API ImGuiTabItem* igTabBarFindTabByID(ImGuiTabBar* tab_bar,ImGuiID tab_id) +{ + return ImGui::TabBarFindTabByID(tab_bar,tab_id); +} +CIMGUI_API void igTabBarRemoveTab(ImGuiTabBar* tab_bar,ImGuiID tab_id) +{ + return ImGui::TabBarRemoveTab(tab_bar,tab_id); +} +CIMGUI_API void igTabBarCloseTab(ImGuiTabBar* tab_bar,ImGuiTabItem* tab) +{ + return ImGui::TabBarCloseTab(tab_bar,tab); +} +CIMGUI_API void igTabBarQueueReorder(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,int offset) +{ + return ImGui::TabBarQueueReorder(tab_bar,tab,offset); +} +CIMGUI_API void igTabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,ImVec2 mouse_pos) +{ + return ImGui::TabBarQueueReorderFromMousePos(tab_bar,tab,mouse_pos); +} +CIMGUI_API bool igTabBarProcessReorder(ImGuiTabBar* tab_bar) +{ + return ImGui::TabBarProcessReorder(tab_bar); +} +CIMGUI_API bool igTabItemEx(ImGuiTabBar* tab_bar,const char* label,bool* p_open,ImGuiTabItemFlags flags,ImGuiWindow* docked_window) +{ + return ImGui::TabItemEx(tab_bar,label,p_open,flags,docked_window); +} +CIMGUI_API void igTabItemCalcSize(ImVec2 *pOut,const char* label,bool has_close_button) +{ + *pOut = ImGui::TabItemCalcSize(label,has_close_button); +} +CIMGUI_API void igTabItemBackground(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImU32 col) +{ + return ImGui::TabItemBackground(draw_list,bb,flags,col); +} +CIMGUI_API void igTabItemLabelAndCloseButton(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImVec2 frame_padding,const char* label,ImGuiID tab_id,ImGuiID close_button_id,bool is_contents_visible,bool* out_just_closed,bool* out_text_clipped) +{ + return ImGui::TabItemLabelAndCloseButton(draw_list,bb,flags,frame_padding,label,tab_id,close_button_id,is_contents_visible,out_just_closed,out_text_clipped); +} +CIMGUI_API void igRenderText(ImVec2 pos,const char* text,const char* text_end,bool hide_text_after_hash) +{ + return ImGui::RenderText(pos,text,text_end,hide_text_after_hash); +} +CIMGUI_API void igRenderTextWrapped(ImVec2 pos,const char* text,const char* text_end,float wrap_width) +{ + return ImGui::RenderTextWrapped(pos,text,text_end,wrap_width); +} +CIMGUI_API void igRenderTextClipped(const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect) +{ + return ImGui::RenderTextClipped(pos_min,pos_max,text,text_end,text_size_if_known,align,clip_rect); +} +CIMGUI_API void igRenderTextClippedEx(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect) +{ + return ImGui::RenderTextClippedEx(draw_list,pos_min,pos_max,text,text_end,text_size_if_known,align,clip_rect); +} +CIMGUI_API void igRenderTextEllipsis(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,float clip_max_x,float ellipsis_max_x,const char* text,const char* text_end,const ImVec2* text_size_if_known) +{ + return ImGui::RenderTextEllipsis(draw_list,pos_min,pos_max,clip_max_x,ellipsis_max_x,text,text_end,text_size_if_known); +} +CIMGUI_API void igRenderFrame(ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,bool border,float rounding) +{ + return ImGui::RenderFrame(p_min,p_max,fill_col,border,rounding); +} +CIMGUI_API void igRenderFrameBorder(ImVec2 p_min,ImVec2 p_max,float rounding) +{ + return ImGui::RenderFrameBorder(p_min,p_max,rounding); +} +CIMGUI_API void igRenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list,ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,float grid_step,ImVec2 grid_off,float rounding,ImDrawFlags flags) +{ + return ImGui::RenderColorRectWithAlphaCheckerboard(draw_list,p_min,p_max,fill_col,grid_step,grid_off,rounding,flags); +} +CIMGUI_API void igRenderNavHighlight(const ImRect bb,ImGuiID id,ImGuiNavHighlightFlags flags) +{ + return ImGui::RenderNavHighlight(bb,id,flags); +} +CIMGUI_API const char* igFindRenderedTextEnd(const char* text,const char* text_end) +{ + return ImGui::FindRenderedTextEnd(text,text_end); +} +CIMGUI_API void igRenderArrow(ImDrawList* draw_list,ImVec2 pos,ImU32 col,ImGuiDir dir,float scale) +{ + return ImGui::RenderArrow(draw_list,pos,col,dir,scale); +} +CIMGUI_API void igRenderBullet(ImDrawList* draw_list,ImVec2 pos,ImU32 col) +{ + return ImGui::RenderBullet(draw_list,pos,col); +} +CIMGUI_API void igRenderCheckMark(ImDrawList* draw_list,ImVec2 pos,ImU32 col,float sz) +{ + return ImGui::RenderCheckMark(draw_list,pos,col,sz); +} +CIMGUI_API void igRenderMouseCursor(ImDrawList* draw_list,ImVec2 pos,float scale,ImGuiMouseCursor mouse_cursor,ImU32 col_fill,ImU32 col_border,ImU32 col_shadow) +{ + return ImGui::RenderMouseCursor(draw_list,pos,scale,mouse_cursor,col_fill,col_border,col_shadow); +} +CIMGUI_API void igRenderArrowPointingAt(ImDrawList* draw_list,ImVec2 pos,ImVec2 half_sz,ImGuiDir direction,ImU32 col) +{ + return ImGui::RenderArrowPointingAt(draw_list,pos,half_sz,direction,col); +} +CIMGUI_API void igRenderRectFilledRangeH(ImDrawList* draw_list,const ImRect rect,ImU32 col,float x_start_norm,float x_end_norm,float rounding) +{ + return ImGui::RenderRectFilledRangeH(draw_list,rect,col,x_start_norm,x_end_norm,rounding); +} +CIMGUI_API void igRenderRectFilledWithHole(ImDrawList* draw_list,ImRect outer,ImRect inner,ImU32 col,float rounding) +{ + return ImGui::RenderRectFilledWithHole(draw_list,outer,inner,col,rounding); +} +CIMGUI_API void igTextEx(const char* text,const char* text_end,ImGuiTextFlags flags) +{ + return ImGui::TextEx(text,text_end,flags); +} +CIMGUI_API bool igButtonEx(const char* label,const ImVec2 size_arg,ImGuiButtonFlags flags) +{ + return ImGui::ButtonEx(label,size_arg,flags); +} +CIMGUI_API bool igCloseButton(ImGuiID id,const ImVec2 pos) +{ + return ImGui::CloseButton(id,pos); +} +CIMGUI_API bool igCollapseButton(ImGuiID id,const ImVec2 pos,ImGuiDockNode* dock_node) +{ + return ImGui::CollapseButton(id,pos,dock_node); +} +CIMGUI_API bool igArrowButtonEx(const char* str_id,ImGuiDir dir,ImVec2 size_arg,ImGuiButtonFlags flags) +{ + return ImGui::ArrowButtonEx(str_id,dir,size_arg,flags); +} +CIMGUI_API void igScrollbar(ImGuiAxis axis) +{ + return ImGui::Scrollbar(axis); +} +CIMGUI_API bool igScrollbarEx(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* p_scroll_v,float avail_v,float contents_v,ImDrawFlags flags) +{ + return ImGui::ScrollbarEx(bb,id,axis,p_scroll_v,avail_v,contents_v,flags); +} +CIMGUI_API bool igImageButtonEx(ImGuiID id,ImTextureID texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,const ImVec2 padding,const ImVec4 bg_col,const ImVec4 tint_col) +{ + return ImGui::ImageButtonEx(id,texture_id,size,uv0,uv1,padding,bg_col,tint_col); +} +CIMGUI_API void igGetWindowScrollbarRect(ImRect *pOut,ImGuiWindow* window,ImGuiAxis axis) +{ + *pOut = ImGui::GetWindowScrollbarRect(window,axis); +} +CIMGUI_API ImGuiID igGetWindowScrollbarID(ImGuiWindow* window,ImGuiAxis axis) +{ + return ImGui::GetWindowScrollbarID(window,axis); +} +CIMGUI_API ImGuiID igGetWindowResizeCornerID(ImGuiWindow* window,int n) +{ + return ImGui::GetWindowResizeCornerID(window,n); +} +CIMGUI_API ImGuiID igGetWindowResizeBorderID(ImGuiWindow* window,ImGuiDir dir) +{ + return ImGui::GetWindowResizeBorderID(window,dir); +} +CIMGUI_API void igSeparatorEx(ImGuiSeparatorFlags flags) +{ + return ImGui::SeparatorEx(flags); +} +CIMGUI_API bool igCheckboxFlags_S64Ptr(const char* label,ImS64* flags,ImS64 flags_value) +{ + return ImGui::CheckboxFlags(label,flags,flags_value); +} +CIMGUI_API bool igCheckboxFlags_U64Ptr(const char* label,ImU64* flags,ImU64 flags_value) +{ + return ImGui::CheckboxFlags(label,flags,flags_value); +} +CIMGUI_API bool igButtonBehavior(const ImRect bb,ImGuiID id,bool* out_hovered,bool* out_held,ImGuiButtonFlags flags) +{ + return ImGui::ButtonBehavior(bb,id,out_hovered,out_held,flags); +} +CIMGUI_API bool igDragBehavior(ImGuiID id,ImGuiDataType data_type,void* p_v,float v_speed,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags) +{ + return ImGui::DragBehavior(id,data_type,p_v,v_speed,p_min,p_max,format,flags); +} +CIMGUI_API bool igSliderBehavior(const ImRect bb,ImGuiID id,ImGuiDataType data_type,void* p_v,const void* p_min,const void* p_max,const char* format,ImGuiSliderFlags flags,ImRect* out_grab_bb) +{ + return ImGui::SliderBehavior(bb,id,data_type,p_v,p_min,p_max,format,flags,out_grab_bb); +} +CIMGUI_API bool igSplitterBehavior(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* size1,float* size2,float min_size1,float min_size2,float hover_extend,float hover_visibility_delay) +{ + return ImGui::SplitterBehavior(bb,id,axis,size1,size2,min_size1,min_size2,hover_extend,hover_visibility_delay); +} +CIMGUI_API bool igTreeNodeBehavior(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end) +{ + return ImGui::TreeNodeBehavior(id,flags,label,label_end); +} +CIMGUI_API bool igTreeNodeBehaviorIsOpen(ImGuiID id,ImGuiTreeNodeFlags flags) +{ + return ImGui::TreeNodeBehaviorIsOpen(id,flags); +} +CIMGUI_API void igTreePushOverrideID(ImGuiID id) +{ + return ImGui::TreePushOverrideID(id); +} +CIMGUI_API const ImGuiDataTypeInfo* igDataTypeGetInfo(ImGuiDataType data_type) +{ + return ImGui::DataTypeGetInfo(data_type); +} +CIMGUI_API int igDataTypeFormatString(char* buf,int buf_size,ImGuiDataType data_type,const void* p_data,const char* format) +{ + return ImGui::DataTypeFormatString(buf,buf_size,data_type,p_data,format); +} +CIMGUI_API void igDataTypeApplyOp(ImGuiDataType data_type,int op,void* output,const void* arg_1,const void* arg_2) +{ + return ImGui::DataTypeApplyOp(data_type,op,output,arg_1,arg_2); +} +CIMGUI_API bool igDataTypeApplyOpFromText(const char* buf,const char* initial_value_buf,ImGuiDataType data_type,void* p_data,const char* format) +{ + return ImGui::DataTypeApplyOpFromText(buf,initial_value_buf,data_type,p_data,format); +} +CIMGUI_API int igDataTypeCompare(ImGuiDataType data_type,const void* arg_1,const void* arg_2) +{ + return ImGui::DataTypeCompare(data_type,arg_1,arg_2); +} +CIMGUI_API bool igDataTypeClamp(ImGuiDataType data_type,void* p_data,const void* p_min,const void* p_max) +{ + return ImGui::DataTypeClamp(data_type,p_data,p_min,p_max); +} +CIMGUI_API bool igInputTextEx(const char* label,const char* hint,char* buf,int buf_size,const ImVec2 size_arg,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data) +{ + return ImGui::InputTextEx(label,hint,buf,buf_size,size_arg,flags,callback,user_data); +} +CIMGUI_API bool igTempInputText(const ImRect bb,ImGuiID id,const char* label,char* buf,int buf_size,ImGuiInputTextFlags flags) +{ + return ImGui::TempInputText(bb,id,label,buf,buf_size,flags); +} +CIMGUI_API bool igTempInputScalar(const ImRect bb,ImGuiID id,const char* label,ImGuiDataType data_type,void* p_data,const char* format,const void* p_clamp_min,const void* p_clamp_max) +{ + return ImGui::TempInputScalar(bb,id,label,data_type,p_data,format,p_clamp_min,p_clamp_max); +} +CIMGUI_API bool igTempInputIsActive(ImGuiID id) +{ + return ImGui::TempInputIsActive(id); +} +CIMGUI_API ImGuiInputTextState* igGetInputTextState(ImGuiID id) +{ + return ImGui::GetInputTextState(id); +} +CIMGUI_API void igColorTooltip(const char* text,const float* col,ImGuiColorEditFlags flags) +{ + return ImGui::ColorTooltip(text,col,flags); +} +CIMGUI_API void igColorEditOptionsPopup(const float* col,ImGuiColorEditFlags flags) +{ + return ImGui::ColorEditOptionsPopup(col,flags); +} +CIMGUI_API void igColorPickerOptionsPopup(const float* ref_col,ImGuiColorEditFlags flags) +{ + return ImGui::ColorPickerOptionsPopup(ref_col,flags); +} +CIMGUI_API int igPlotEx(ImGuiPlotType plot_type,const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 frame_size) +{ + return ImGui::PlotEx(plot_type,label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,frame_size); +} +CIMGUI_API void igShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,ImVec2 gradient_p0,ImVec2 gradient_p1,ImU32 col0,ImU32 col1) +{ + return ImGui::ShadeVertsLinearColorGradientKeepAlpha(draw_list,vert_start_idx,vert_end_idx,gradient_p0,gradient_p1,col0,col1); +} +CIMGUI_API void igShadeVertsLinearUV(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,bool clamp) +{ + return ImGui::ShadeVertsLinearUV(draw_list,vert_start_idx,vert_end_idx,a,b,uv_a,uv_b,clamp); +} +CIMGUI_API void igGcCompactTransientMiscBuffers() +{ + return ImGui::GcCompactTransientMiscBuffers(); +} +CIMGUI_API void igGcCompactTransientWindowBuffers(ImGuiWindow* window) +{ + return ImGui::GcCompactTransientWindowBuffers(window); +} +CIMGUI_API void igGcAwakeTransientWindowBuffers(ImGuiWindow* window) +{ + return ImGui::GcAwakeTransientWindowBuffers(window); +} +CIMGUI_API void igErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback,void* user_data) +{ + return ImGui::ErrorCheckEndFrameRecover(log_callback,user_data); +} +CIMGUI_API void igDebugDrawItemRect(ImU32 col) +{ + return ImGui::DebugDrawItemRect(col); +} +CIMGUI_API void igDebugStartItemPicker() +{ + return ImGui::DebugStartItemPicker(); +} +CIMGUI_API void igShowFontAtlas(ImFontAtlas* atlas) +{ + return ImGui::ShowFontAtlas(atlas); +} +CIMGUI_API void igDebugNodeColumns(ImGuiOldColumns* columns) +{ + return ImGui::DebugNodeColumns(columns); +} +CIMGUI_API void igDebugNodeDrawList(ImGuiWindow* window,ImGuiViewportP* viewport,const ImDrawList* draw_list,const char* label) +{ + return ImGui::DebugNodeDrawList(window,viewport,draw_list,label); +} +CIMGUI_API void igDebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list,const ImDrawList* draw_list,const ImDrawCmd* draw_cmd,bool show_mesh,bool show_aabb) +{ + return ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(out_draw_list,draw_list,draw_cmd,show_mesh,show_aabb); +} +CIMGUI_API void igDebugNodeFont(ImFont* font) +{ + return ImGui::DebugNodeFont(font); +} +CIMGUI_API void igDebugNodeStorage(ImGuiStorage* storage,const char* label) +{ + return ImGui::DebugNodeStorage(storage,label); +} +CIMGUI_API void igDebugNodeTabBar(ImGuiTabBar* tab_bar,const char* label) +{ + return ImGui::DebugNodeTabBar(tab_bar,label); +} +CIMGUI_API void igDebugNodeTable(ImGuiTable* table) +{ + return ImGui::DebugNodeTable(table); +} +CIMGUI_API void igDebugNodeTableSettings(ImGuiTableSettings* settings) +{ + return ImGui::DebugNodeTableSettings(settings); +} +CIMGUI_API void igDebugNodeWindow(ImGuiWindow* window,const char* label) +{ + return ImGui::DebugNodeWindow(window,label); +} +CIMGUI_API void igDebugNodeWindowSettings(ImGuiWindowSettings* settings) +{ + return ImGui::DebugNodeWindowSettings(settings); +} +CIMGUI_API void igDebugNodeWindowsList(ImVector_ImGuiWindowPtr* windows,const char* label) +{ + return ImGui::DebugNodeWindowsList(windows,label); +} +CIMGUI_API void igDebugNodeViewport(ImGuiViewportP* viewport) +{ + return ImGui::DebugNodeViewport(viewport); +} +CIMGUI_API void igDebugRenderViewportThumbnail(ImDrawList* draw_list,ImGuiViewportP* viewport,const ImRect bb) +{ + return ImGui::DebugRenderViewportThumbnail(draw_list,viewport,bb); +} +CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype() +{ + return ImFontAtlasGetBuilderForStbTruetype(); +} +CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas) +{ + return ImFontAtlasBuildInit(atlas); +} +CIMGUI_API void igImFontAtlasBuildSetupFont(ImFontAtlas* atlas,ImFont* font,ImFontConfig* font_config,float ascent,float descent) +{ + return ImFontAtlasBuildSetupFont(atlas,font,font_config,ascent,descent); +} +CIMGUI_API void igImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas,void* stbrp_context_opaque) +{ + return ImFontAtlasBuildPackCustomRects(atlas,stbrp_context_opaque); +} +CIMGUI_API void igImFontAtlasBuildFinish(ImFontAtlas* atlas) +{ + return ImFontAtlasBuildFinish(atlas); +} +CIMGUI_API void igImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned char in_marker_pixel_value) +{ + return ImFontAtlasBuildRender8bppRectFromString(atlas,x,y,w,h,in_str,in_marker_char,in_marker_pixel_value); +} +CIMGUI_API void igImFontAtlasBuildRender32bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned int in_marker_pixel_value) +{ + return ImFontAtlasBuildRender32bppRectFromString(atlas,x,y,w,h,in_str,in_marker_char,in_marker_pixel_value); +} +CIMGUI_API void igImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256],float in_multiply_factor) +{ + return ImFontAtlasBuildMultiplyCalcLookupTable(out_table,in_multiply_factor); +} +CIMGUI_API void igImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256],unsigned char* pixels,int x,int y,int w,int h,int stride) +{ + return ImFontAtlasBuildMultiplyRectAlpha8(table,pixels,x,y,w,h,stride); +} + + + +/////////////////////////////manual written functions +CIMGUI_API void igLogText(CONST char *fmt, ...) +{ + char buffer[256]; + va_list args; + va_start(args, fmt); + vsnprintf(buffer, 256, fmt, args); + va_end(args); + + ImGui::LogText("%s", buffer); +} +CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + buffer->appendfv(fmt, args); + va_end(args); +} + +CIMGUI_API float igGET_FLT_MAX() +{ + return FLT_MAX; +} + +CIMGUI_API float igGET_FLT_MIN() +{ + return FLT_MIN; +} + + +CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create() +{ + return IM_NEW(ImVector) (); +} + +CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self) +{ + IM_DELETE(self); +} + +CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p) +{ + IM_PLACEMENT_NEW(p) ImVector(); +} +CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p) +{ + p->~ImVector(); +} + + +#ifdef IMGUI_HAS_DOCK + +// NOTE: Some function pointers in the ImGuiPlatformIO structure are not C-compatible because of their +// use of a complex return type. To work around this, we store a custom CimguiStorage object inside +// ImGuiIO::BackendLanguageUserData, which contains C-compatible function pointer variants for these +// functions. When a user function pointer is provided, we hook up the underlying ImGuiPlatformIO +// function pointer to a thunk which accesses the user function pointer through CimguiStorage. + +struct CimguiStorage +{ + void(*Platform_GetWindowPos)(ImGuiViewport* vp, ImVec2* out_pos); + void(*Platform_GetWindowSize)(ImGuiViewport* vp, ImVec2* out_pos); +}; + +// Gets a reference to the CimguiStorage object stored in the current ImGui context's BackendLanguageUserData. +CimguiStorage& GetCimguiStorage() +{ + ImGuiIO& io = ImGui::GetIO(); + if (io.BackendLanguageUserData == NULL) + { + io.BackendLanguageUserData = new CimguiStorage(); + } + + return *(CimguiStorage*)io.BackendLanguageUserData; +} + +// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowPos. +ImVec2 Platform_GetWindowPos_hook(ImGuiViewport* vp) +{ + ImVec2 pos; + GetCimguiStorage().Platform_GetWindowPos(vp, &pos); + return pos; +}; + +// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowPos. +CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowPos(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_pos)) +{ + CimguiStorage& storage = GetCimguiStorage(); + storage.Platform_GetWindowPos = user_callback; + platform_io->Platform_GetWindowPos = &Platform_GetWindowPos_hook; +} + +// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowSize. +ImVec2 Platform_GetWindowSize_hook(ImGuiViewport* vp) +{ + ImVec2 size; + GetCimguiStorage().Platform_GetWindowSize(vp, &size); + return size; +}; + +// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowSize. +CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowSize(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_size)) +{ + CimguiStorage& storage = GetCimguiStorage(); + storage.Platform_GetWindowSize = user_callback; + platform_io->Platform_GetWindowSize = &Platform_GetWindowSize_hook; +} + +#endif diff --git a/plugins/example/CMakeLists.txt b/plugins/example_cpp/CMakeLists.txt similarity index 96% rename from plugins/example/CMakeLists.txt rename to plugins/example_cpp/CMakeLists.txt index 99c662fe1..d57340d7e 100644 --- a/plugins/example/CMakeLists.txt +++ b/plugins/example_cpp/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) # Change this to the name of your plugin # -project(example) +project(example_cpp) # Add your source files here # add_library(${PROJECT_NAME} SHARED diff --git a/plugins/example/source/plugin_example.cpp b/plugins/example_cpp/source/plugin_example.cpp similarity index 79% rename from plugins/example/source/plugin_example.cpp rename to plugins/example_cpp/source/plugin_example.cpp index 28b54d436..ef0428d0a 100644 --- a/plugins/example/source/plugin_example.cpp +++ b/plugins/example_cpp/source/plugin_example.cpp @@ -15,7 +15,7 @@ public: } }; -IMHEX_PLUGIN_SETUP("Example", "WerWolv", "Example plugin used as template for plugin devs") { +IMHEX_PLUGIN_SETUP("Example C++", "WerWolv", "Example C++ plugin used as template for plugin devs") { ContentRegistry::Views::add(); diff --git a/plugins/example_rust/CMakeLists.txt b/plugins/example_rust/CMakeLists.txt new file mode 100644 index 000000000..388b4287e --- /dev/null +++ b/plugins/example_rust/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.16) + +# Change this to the name of your plugin # +project(example_rust) + +# ---- No need to change anything from here downwards unless you know what you're doing ---- # + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CARGO_CMD ${RUST_PATH}cargo build) + set(TARGET_DIR "debug") +else () + set(CARGO_CMD ${RUST_PATH}cargo build --release) + set(TARGET_DIR "release") +endif () + +if (WIN32) + set(PLUGIN_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_DIR}/${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") +else () + set(PLUGIN_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") +endif () + +get_target_property(LIBIMHEX_SOURCE_DIRECTORY libimhex SOURCE_DIR) + +add_custom_target(${PROJECT_NAME} ALL + COMMAND ${CMAKE_COMMAND} -E env + CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} + LIBIMHEX_SOURCE_DIRECTORY=${LIBIMHEX_SOURCE_DIRECTORY} + LIBIMHEX_OUTPUT_DIRECTORY=$ + CXX_COMPILER=${CMAKE_CXX_COMPILER} + ${CARGO_CMD} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PLUGIN_OUTPUT_PATH} "${CMAKE_CURRENT_BINARY_DIR}/../${PROJECT_NAME}.hexplug" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + USES_TERMINAL +) +set_target_properties(${PROJECT_NAME} PROPERTIES LOCATION ${CMAKE_CURRENT_BINARY_DIR}) +set_target_properties(${PROJECT_NAME} PROPERTIES RUST_PROJECT 1) +set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE Rust) + +add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME}) + +if (NOT TARGET libimhex) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libimhex ${CMAKE_CURRENT_BINARY_DIR}/plugins/libimhex) +endif() \ No newline at end of file diff --git a/plugins/example_rust/Cargo.lock b/plugins/example_rust/Cargo.lock new file mode 100644 index 000000000..4b83728b9 --- /dev/null +++ b/plugins/example_rust/Cargo.lock @@ -0,0 +1,295 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cc" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chlorine" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd650552110e39b7c5058986cf177decd3365841836578ac50a286094eac0be6" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "638fb099591b763a988ca69e5f0ee4b82bedb8bc762b3c6cfbfdd3a6dc6b54b4" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83363b96cfd226eb820e37a21088c30c55e47f9fc8299c2d08a6090d50414ccc" +dependencies = [ + "cc", + "codespan-reporting", + "lazy_static", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d4bde25840be4cf0eb1d7e3a74634105189d5609b855bcc8d601ffb037f5f4" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3869bf8972075de8f0446b433d40026f2dfdbd8a9edbc24e9d645ca2ebf2f93a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "example_rust" +version = "0.1.0" +dependencies = [ + "hex", +] + +[[package]] +name = "hex" +version = "0.1.0" +dependencies = [ + "cxx", + "cxx-build", + "imgui", + "macros", +] + +[[package]] +name = "imgui" +version = "0.8.0" +dependencies = [ + "bitflags", + "imgui-sys", + "parking_lot", +] + +[[package]] +name = "imgui-sys" +version = "0.8.0" +dependencies = [ + "cc", + "chlorine", +] + +[[package]] +name = "instant" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" + +[[package]] +name = "link-cplusplus" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1becd27d473556dc610b8afa1636ef90747b574a84553bc11e82371d5ef2d1" +dependencies = [ + "cc", +] + +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "macros" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e114536316b51a5aa7a0e59fc49661fd263c5507dd08bd28de052e57626ce69" + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" + +[[package]] +name = "syn" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/plugins/example_rust/Cargo.toml b/plugins/example_rust/Cargo.toml new file mode 100644 index 000000000..bbccbf3cf --- /dev/null +++ b/plugins/example_rust/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "example_rust" +version = "0.1.0" +authors = ["Marc-André Moreau "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] +path = "source/plugin_example.rs" + +[dependencies] +hex = { path = "../libimhex-rust" } + +[profile.release] +lto = true \ No newline at end of file diff --git a/plugins/example_rust/source/plugin_example.rs b/plugins/example_rust/source/plugin_example.rs new file mode 100644 index 000000000..1e2e823e9 --- /dev/null +++ b/plugins/example_rust/source/plugin_example.rs @@ -0,0 +1,7 @@ +extern crate hex; + +#[hex::plugin_setup("Example Rust", "WerWolv", "Example Rust plugin used as template for plugin devs")] +fn init() { + +} + diff --git a/plugins/libimhex-rust/Cargo.lock b/plugins/libimhex-rust/Cargo.lock new file mode 100644 index 000000000..41a2733aa --- /dev/null +++ b/plugins/libimhex-rust/Cargo.lock @@ -0,0 +1,288 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cc" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chlorine" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd650552110e39b7c5058986cf177decd3365841836578ac50a286094eac0be6" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "638fb099591b763a988ca69e5f0ee4b82bedb8bc762b3c6cfbfdd3a6dc6b54b4" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83363b96cfd226eb820e37a21088c30c55e47f9fc8299c2d08a6090d50414ccc" +dependencies = [ + "cc", + "codespan-reporting", + "lazy_static", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d4bde25840be4cf0eb1d7e3a74634105189d5609b855bcc8d601ffb037f5f4" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3869bf8972075de8f0446b433d40026f2dfdbd8a9edbc24e9d645ca2ebf2f93a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "hex" +version = "0.1.0" +dependencies = [ + "cxx", + "cxx-build", + "imgui", + "macros", +] + +[[package]] +name = "imgui" +version = "0.8.0" +dependencies = [ + "bitflags", + "imgui-sys", + "parking_lot", +] + +[[package]] +name = "imgui-sys" +version = "0.8.0" +dependencies = [ + "cc", + "chlorine", +] + +[[package]] +name = "instant" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" + +[[package]] +name = "link-cplusplus" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1becd27d473556dc610b8afa1636ef90747b574a84553bc11e82371d5ef2d1" +dependencies = [ + "cc", +] + +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "macros" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e114536316b51a5aa7a0e59fc49661fd263c5507dd08bd28de052e57626ce69" + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" + +[[package]] +name = "syn" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/plugins/libimhex-rust/Cargo.toml b/plugins/libimhex-rust/Cargo.toml new file mode 100644 index 000000000..ff8ff8573 --- /dev/null +++ b/plugins/libimhex-rust/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "hex" +version = "0.1.0" +edition = "2018" +build = "build.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +macros = { path = "proc_macros" } +imgui = { path = "imgui-rs" } + +cxx = "1.0.55" + +[build-dependencies] +cxx-build = "1.0.55" diff --git a/plugins/libimhex-rust/build.rs b/plugins/libimhex-rust/build.rs new file mode 100644 index 000000000..fd0234bb5 --- /dev/null +++ b/plugins/libimhex-rust/build.rs @@ -0,0 +1,15 @@ +fn main() { + println!("cargo:rustc-link-lib=dylib=imhex"); + println!("cargo:rustc-link-search=all={}", env!("LIBIMHEX_OUTPUT_DIRECTORY")); + + println!("cargo:rerun-if-changed=src/lib.rs"); + println!("cargo:rerun-if-changed=src/imhex_api.rs"); + + cxx_build::bridge("src/imhex_api.rs") + .include(format!("{}/include", env!("LIBIMHEX_SOURCE_DIRECTORY"))) + .flag_if_supported("-std=gnu++20") + .flag_if_supported("-std=gnu++2a") + .flag_if_supported("-fconcepts") + .compiler(env!("CXX_COMPILER")) + .compile("libimhex-bridge"); +} \ No newline at end of file diff --git a/plugins/libimhex-rust/imgui-rs/Cargo.lock b/plugins/libimhex-rust/imgui-rs/Cargo.lock new file mode 100644 index 000000000..ee9245916 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/Cargo.lock @@ -0,0 +1,159 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cc" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chlorine" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd650552110e39b7c5058986cf177decd3365841836578ac50a286094eac0be6" + +[[package]] +name = "imgui" +version = "0.8.0" +dependencies = [ + "bitflags", + "imgui-sys", + "memoffset", + "parking_lot", +] + +[[package]] +name = "imgui-sys" +version = "0.8.0" +dependencies = [ + "cc", + "chlorine", + "pkg-config", +] + +[[package]] +name = "instant" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "libc" +version = "0.2.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" + +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "pkg-config" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/plugins/libimhex-rust/imgui-rs/Cargo.toml b/plugins/libimhex-rust/imgui-rs/Cargo.toml new file mode 100644 index 000000000..1bcce1ed0 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "imgui" +version = "0.8.0" +edition = "2018" +authors = ["The imgui-rs Developers"] +description = "High-level Rust bindings to dear imgui" +homepage = "https://github.com/imgui-rs/imgui-rs" +repository = "https://github.com/imgui-rs/imgui-rs" +license = "MIT/Apache-2.0" +categories = ["gui", "api-bindings"] +readme = "../README.markdown" + +exclude = ["/resources"] + +[dependencies] +bitflags = "1" +imgui-sys = { path = "../imgui-sys" } +parking_lot = "0.11" + +[features] +default = ["min-const-generics"] + +wasm = ["imgui-sys/wasm"] +freetype = ["imgui-sys/freetype"] +min-const-generics = [] +# this api is in beta in the upstream imgui crate. See issue #524 for more info. +# it should be stable and fine to use though. +tables-api = [] + +[dev-dependencies] +memoffset = "0.6" diff --git a/plugins/libimhex-rust/imgui-rs/LICENSE-APACHE b/plugins/libimhex-rust/imgui-rs/LICENSE-APACHE new file mode 100644 index 000000000..8f71f43fe --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/LICENSE-APACHE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/plugins/libimhex-rust/imgui-rs/LICENSE-MIT b/plugins/libimhex-rust/imgui-rs/LICENSE-MIT new file mode 100644 index 000000000..ea896c1f8 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2015-2020 The imgui-rs Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/libimhex-rust/imgui-rs/README.markdown b/plugins/libimhex-rust/imgui-rs/README.markdown new file mode 120000 index 000000000..1691050d1 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/README.markdown @@ -0,0 +1 @@ +../README.markdown \ No newline at end of file diff --git a/plugins/libimhex-rust/imgui-rs/src/clipboard.rs b/plugins/libimhex-rust/imgui-rs/src/clipboard.rs new file mode 100644 index 000000000..38ebc975e --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/clipboard.rs @@ -0,0 +1,142 @@ +use std::ffi::{CStr, CString}; +use std::fmt; +use std::os::raw::{c_char, c_void}; +use std::panic::catch_unwind; +use std::process; +use std::ptr; + +// use crate::string::{ImStr, ImString}; +use crate::Ui; + +/// Trait for clipboard backends +pub trait ClipboardBackend: 'static { + /// Returns the current clipboard contents as an owned imgui-rs string, or None if the + /// clipboard is empty or inaccessible + fn get(&mut self) -> Option; + /// Sets the clipboard contents to the given imgui-rs string slice. + fn set(&mut self, value: &str); +} + +pub(crate) struct ClipboardContext { + backend: Box, + // this is needed to keep ownership of the value when the raw C callback is called + last_value: CString, +} + +impl ClipboardContext { + /// Creates a new [ClipboardContext]. This function previously took a `Box`, but now + /// is generic over the T it takes and boxes itself (which should be less strange). + pub fn new(backend: T) -> ClipboardContext { + ClipboardContext { + backend: Box::new(backend) as Box, + last_value: CString::default(), + } + } + + pub fn dummy() -> ClipboardContext { + Self { + backend: Box::new(DummyClipboardContext), + last_value: CString::default(), + } + } +} + +pub struct DummyClipboardContext; +impl ClipboardBackend for DummyClipboardContext { + fn get(&mut self) -> Option { + None + } + + fn set(&mut self, _: &str) { + // empty + } +} + +impl fmt::Debug for ClipboardContext { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ClipboardContext") + // beautiful code, no? + .field("backend", &(&(*self.backend) as *const _)) + .field("last_value", &self.last_value) + .finish() + } +} + +pub(crate) unsafe extern "C" fn get_clipboard_text(user_data: *mut c_void) -> *const c_char { + let result = catch_unwind(|| { + let ctx = &mut *(user_data as *mut ClipboardContext); + match ctx.backend.get() { + Some(text) => { + ctx.last_value = CString::new(text).unwrap(); + ctx.last_value.as_ptr() + } + None => ptr::null(), + } + }); + result.unwrap_or_else(|_| { + eprintln!("Clipboard getter panicked"); + process::abort(); + }) +} + +pub(crate) unsafe extern "C" fn set_clipboard_text(user_data: *mut c_void, text: *const c_char) { + let result = catch_unwind(|| { + let ctx = &mut *(user_data as *mut ClipboardContext); + let text = CStr::from_ptr(text).to_owned(); + ctx.backend.set(text.to_str().unwrap()); + }); + result.unwrap_or_else(|_| { + eprintln!("Clipboard setter panicked"); + process::abort(); + }); +} + +/// # Clipboard +#[allow(clippy::fn_address_comparisons)] // This is allowed because although function addresses wont be unique, we just care if its OURS +impl<'ui> Ui<'ui> { + /// Returns the current clipboard contents as text, or None if the clipboard is empty or cannot + /// be accessed + pub fn clipboard_text(&self) -> Option { + let io = self.io(); + io.get_clipboard_text_fn.and_then(|get_clipboard_text_fn| { + // Bypass FFI if we end up calling our own function anyway + if get_clipboard_text_fn == get_clipboard_text { + let ctx = unsafe { &mut *(io.clipboard_user_data as *mut ClipboardContext) }; + ctx.backend.get() + } else { + unsafe { + let text_ptr = get_clipboard_text_fn(io.clipboard_user_data); + if text_ptr.is_null() || *text_ptr == b'\0' as c_char { + None + } else { + Some( + CStr::from_ptr(text_ptr) + .to_owned() + .to_str() + .ok()? + .to_owned(), + ) + } + } + } + }) + } + + /// Sets the clipboard contents. + /// + /// Does nothing if the clipboard cannot be accessed. + pub fn set_clipboard_text(&self, text: impl AsRef) { + let io = self.io(); + if let Some(set_clipboard_text_fn) = io.set_clipboard_text_fn { + // Bypass FFI if we end up calling our own function anyway + if set_clipboard_text_fn == set_clipboard_text { + let ctx = unsafe { &mut *(io.clipboard_user_data as *mut ClipboardContext) }; + ctx.backend.set(text.as_ref()); + } else { + unsafe { + set_clipboard_text_fn(io.clipboard_user_data, self.scratch_txt(text)); + } + } + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/color.rs b/plugins/libimhex-rust/imgui-rs/src/color.rs new file mode 100644 index 000000000..a5bed56a8 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/color.rs @@ -0,0 +1,370 @@ +/// Wraps u32 that represents a packed RGBA color. Mostly used by types in the +/// low level custom drawing API, such as [`DrawListMut`](crate::DrawListMut). +/// +/// The bits of a color are in "`0xAABBGGRR`" format (e.g. RGBA as little endian +/// bytes). For clarity: we don't support an equivalent to the +/// `IMGUI_USE_BGRA_PACKED_COLOR` define. +/// +/// This used to be named `ImColor32`, but was renamed to avoid confusion with +/// the type with that name in the C++ API (which uses 32 bits per channel). +/// +/// While it doesn't provide methods to access the fields, they can be accessed +/// via the `Deref`/`DerefMut` impls it provides targeting +/// [`imgui::color::ImColor32Fields`](crate::color::ImColor32Fields), which has +/// no other meaningful uses. +/// +/// # Example +/// ``` +/// let mut c = imgui::ImColor32::from_rgba(0x80, 0xc0, 0x40, 0xff); +/// assert_eq!(c.to_bits(), 0xff_40_c0_80); // Note: 0xAA_BB_GG_RR +/// // Field access +/// assert_eq!(c.r, 0x80); +/// assert_eq!(c.g, 0xc0); +/// assert_eq!(c.b, 0x40); +/// assert_eq!(c.a, 0xff); +/// c.b = 0xbb; +/// assert_eq!(c.to_bits(), 0xff_bb_c0_80); +/// ``` +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[repr(transparent)] +pub struct ImColor32(u32); // TBH maybe the wrapped field should be `pub`. + +impl ImColor32 { + /// Convenience constant for solid black. + pub const BLACK: Self = Self(0xff_00_00_00); + + /// Convenience constant for solid white. + pub const WHITE: Self = Self(0xff_ff_ff_ff); + + /// Convenience constant for full transparency. + pub const TRANSPARENT: Self = Self(0); + + /// Construct a color from 4 single-byte `u8` channel values, which should + /// be between 0 and 255. + #[inline] + pub const fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self { + Self( + ((a as u32) << Self::A_SHIFT) + | ((r as u32) << Self::R_SHIFT) + | ((g as u32) << Self::G_SHIFT) + | ((b as u32) << Self::B_SHIFT), + ) + } + + /// Construct a fully opaque color from 3 single-byte `u8` channel values. + /// Same as [`Self::from_rgba`] with a == 255 + #[inline] + pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self { + Self::from_rgba(r, g, b, 0xff) + } + + /// Construct a fully opaque color from 4 `f32` channel values in the range + /// `0.0 ..= 1.0` (values outside this range are clamped to it, with NaN + /// mapped to 0.0). + /// + /// Note: No alpha premultiplication is done, so your input should be have + /// premultiplied alpha if needed. + #[inline] + // not const fn because no float math in const eval yet 😩 + pub fn from_rgba_f32s(r: f32, g: f32, b: f32, a: f32) -> Self { + Self::from_rgba( + f32_to_u8_sat(r), + f32_to_u8_sat(g), + f32_to_u8_sat(b), + f32_to_u8_sat(a), + ) + } + + /// Return the channels as an array of f32 in `[r, g, b, a]` order. + #[inline] + pub fn to_rgba_f32s(self) -> [f32; 4] { + let &ImColor32Fields { r, g, b, a } = &*self; + [ + u8_to_f32_sat(r), + u8_to_f32_sat(g), + u8_to_f32_sat(b), + u8_to_f32_sat(a), + ] + } + + /// Return the channels as an array of u8 in `[r, g, b, a]` order. + #[inline] + pub fn to_rgba(self) -> [u8; 4] { + let &ImColor32Fields { r, g, b, a } = &*self; + [r, g, b, a] + } + + /// Equivalent to [`Self::from_rgba_f32s`], but with an alpha of 1.0 (e.g. + /// opaque). + #[inline] + pub fn from_rgb_f32s(r: f32, g: f32, b: f32) -> Self { + Self::from_rgba(f32_to_u8_sat(r), f32_to_u8_sat(g), f32_to_u8_sat(b), 0xff) + } + + /// Construct a color from the `u32` that makes up the bits in `0xAABBGGRR` + /// format. + /// + /// Specifically, this takes the RGBA values as a little-endian u32 with 8 + /// bits per channel. + /// + /// Note that [`ImColor32::from_rgba`] may be a bit easier to use. + #[inline] + pub const fn from_bits(u: u32) -> Self { + Self(u) + } + + /// Return the bits of the color as a u32. These are in "`0xAABBGGRR`" format, that + /// is, little-endian RGBA with 8 bits per channel. + #[inline] + pub const fn to_bits(self) -> u32 { + self.0 + } + + // These are public in C++ ImGui, should they be public here? + /// The number of bits to shift the byte of the red channel. Always 0. + const R_SHIFT: u32 = 0; + /// The number of bits to shift the byte of the green channel. Always 8. + const G_SHIFT: u32 = 8; + /// The number of bits to shift the byte of the blue channel. Always 16. + const B_SHIFT: u32 = 16; + /// The number of bits to shift the byte of the alpha channel. Always 24. + const A_SHIFT: u32 = 24; +} + +impl Default for ImColor32 { + #[inline] + fn default() -> Self { + Self::TRANSPARENT + } +} + +impl std::fmt::Debug for ImColor32 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ImColor32") + .field("r", &self.r) + .field("g", &self.g) + .field("b", &self.b) + .field("a", &self.a) + .finish() + } +} + +/// A struct that exists to allow field access to [`ImColor32`]. It essentially +/// exists to be a `Deref`/`DerefMut` target and provide field access. +/// +/// Note that while this is repr(C), be aware that on big-endian machines +/// (`cfg(target_endian = "big")`) the order of the fields is reversed, as this +/// is a view into a packed u32. +/// +/// Generally should not be used, except as the target of the `Deref` impl of +/// [`ImColor32`]. +#[derive(Copy, Clone, Debug)] +#[repr(C, align(4))] +// Should this be #[non_exhaustive] to discourage direct use? +#[rustfmt::skip] +pub struct ImColor32Fields { + #[cfg(target_endian = "little")] pub r: u8, + #[cfg(target_endian = "little")] pub g: u8, + #[cfg(target_endian = "little")] pub b: u8, + #[cfg(target_endian = "little")] pub a: u8, + // TODO(someday): i guess we should have BE tests, but for now I verified + // this locally. + #[cfg(target_endian = "big")] pub a: u8, + #[cfg(target_endian = "big")] pub b: u8, + #[cfg(target_endian = "big")] pub g: u8, + #[cfg(target_endian = "big")] pub r: u8, +} + +// We assume that big and little are the only endiannesses, and that exactly one +// is set. That is, PDP endian is not in use, and the we aren't using a +// completely broken custom target json or something. +#[cfg(any( + all(target_endian = "little", target_endian = "big"), + all(not(target_endian = "little"), not(target_endian = "big")), +))] +compile_error!("`cfg(target_endian = \"little\")` must be `cfg(not(target_endian = \"big\")`"); + +// static assert sizes match +const _: [(); core::mem::size_of::()] = [(); core::mem::size_of::()]; +const _: [(); core::mem::align_of::()] = [(); core::mem::align_of::()]; + +impl core::ops::Deref for ImColor32 { + type Target = ImColor32Fields; + #[inline] + fn deref(&self) -> &ImColor32Fields { + // Safety: we statically assert the size and align match, and neither + // type has any special invariants. + unsafe { &*(self as *const Self as *const ImColor32Fields) } + } +} +impl core::ops::DerefMut for ImColor32 { + #[inline] + fn deref_mut(&mut self) -> &mut ImColor32Fields { + // Safety: we statically assert the size and align match, and neither + // type has any special invariants. + unsafe { &mut *(self as *mut Self as *mut ImColor32Fields) } + } +} + +impl From for u32 { + #[inline] + fn from(color: ImColor32) -> Self { + color.0 + } +} + +impl From for ImColor32 { + #[inline] + fn from(color: u32) -> Self { + ImColor32(color) + } +} + +impl From<[f32; 4]> for ImColor32 { + #[inline] + fn from(v: [f32; 4]) -> Self { + Self::from_rgba_f32s(v[0], v[1], v[2], v[3]) + } +} + +impl From<(f32, f32, f32, f32)> for ImColor32 { + #[inline] + fn from(v: (f32, f32, f32, f32)) -> Self { + Self::from_rgba_f32s(v.0, v.1, v.2, v.3) + } +} + +impl From<[f32; 3]> for ImColor32 { + #[inline] + fn from(v: [f32; 3]) -> Self { + Self::from_rgb_f32s(v[0], v[1], v[2]) + } +} + +impl From<(f32, f32, f32)> for ImColor32 { + fn from(v: (f32, f32, f32)) -> Self { + Self::from_rgb_f32s(v.0, v.1, v.2) + } +} + +impl From for [f32; 4] { + #[inline] + fn from(v: ImColor32) -> Self { + v.to_rgba_f32s() + } +} +impl From for (f32, f32, f32, f32) { + #[inline] + fn from(color: ImColor32) -> Self { + let [r, g, b, a]: [f32; 4] = color.into(); + (r, g, b, a) + } +} + +// These utilities might be worth making `pub` as free functions in +// `crate::color` so user code can ensure their numeric handling is +// consistent... + +/// Clamp `v` to between 0.0 and 1.0, always returning a value between those. +/// +/// Never returns NaN, or -0.0 — instead returns +0.0 for these (We differ from +/// C++ Dear ImGUI here which probably is just ignoring values like these). +#[inline] +pub(crate) fn saturate(v: f32) -> f32 { + // Note: written strangely so that special values (NaN/-0.0) are handled + // automatically with no extra checks. + if v > 0.0 { + if v <= 1.0 { + v + } else { + 1.0 + } + } else { + 0.0 + } +} + +/// Quantize a value in `0.0..=1.0` to `0..=u8::MAX`. Input outside 0.0..=1.0 is +/// clamped. Uses a bias of 0.5, because we assume centered quantization is used +/// (and because C++ imgui does it too). See: +/// - https://github.com/ocornut/imgui/blob/e28b51786eae60f32c18214658c15952639085a2/imgui_internal.h#L218 +/// - https://cbloomrants.blogspot.com/2020/09/topics-in-quantization-for-games.html +/// (see `quantize_centered`) +#[inline] +pub(crate) fn f32_to_u8_sat(f: f32) -> u8 { + let f = saturate(f) * 255.0 + 0.5; + // Safety: `saturate`'s result is between 0.0 and 1.0 (never NaN even for + // NaN input), and so for all inputs, `saturate(f) * 255.0 + 0.5` is inside + // `0.5 ..= 255.5`. + // + // This is verified for all f32 in `test_f32_to_u8_sat_exhaustive`. + // + // Also note that LLVM doesn't bother trying to figure this out so the + // unchecked does actually help. (That said, this likely doesn't matter + // for imgui-rs, but I had this code in another project and it felt + // silly to needlessly pessimize it). + unsafe { f.to_int_unchecked() } +} + +/// Opposite of `f32_to_u8_sat`. Since we assume centered quantization, this is +/// equivalent to dividing by 255 (or, multiplying by 1.0/255.0) +#[inline] +pub(crate) fn u8_to_f32_sat(u: u8) -> f32 { + (u as f32) * (1.0 / 255.0) +} + +#[test] +fn check_sat() { + assert_eq!(saturate(1.0), 1.0); + assert_eq!(saturate(0.5), 0.5); + assert_eq!(saturate(0.0), 0.0); + assert_eq!(saturate(-1.0), 0.0); + // next float from 1.0 + assert_eq!(saturate(1.0 + f32::EPSILON), 1.0); + // prev float from 0.0 (Well, from -0.0) + assert_eq!(saturate(-f32::MIN_POSITIVE), 0.0); + // some NaNs. + assert_eq!(saturate(f32::NAN), 0.0); + assert_eq!(saturate(-f32::NAN), 0.0); + // neg zero comes through as +0 + assert_eq!(saturate(-0.0).to_bits(), 0.0f32.to_bits()); +} + +// Check that the unsafe in `f32_to_u8_sat` is fine for all f32 (and that the +// comments I wrote about `saturate` are actually true). This is way too slow in +// debug mode, but finishes in ~15s on my machine for release (just this test). +// This is tested in CI, but will only run if invoked manually with something +// like: `cargo test -p imgui --release -- --ignored`. +#[test] +#[ignore] +fn test_f32_to_u8_sat_exhaustive() { + for f in (0..=u32::MAX).map(f32::from_bits) { + let v = saturate(f); + assert!( + (0.0..=1.0).contains(&v) && (v.to_bits() != (-0.0f32).to_bits()), + "sat({} [e.g. {:#x}]) => {} [e.g {:#x}]", + f, + f.to_bits(), + v, + v.to_bits(), + ); + let sat = v * 255.0 + 0.5; + // Note: This checks what's required by is the safety predicate for + // `f32::to_int_unchecked`: + // https://doc.rust-lang.org/std/primitive.f32.html#method.to_int_unchecked + assert!( + sat.trunc() >= 0.0 && sat.trunc() <= (u8::MAX as f32) && sat.is_finite(), + "f32_to_u8_sat({} [e.g. {:#x}]) would be UB!", + f, + f.to_bits(), + ); + } +} + +#[test] +fn test_saturate_all_u8s() { + for u in 0..=u8::MAX { + let v = f32_to_u8_sat(u8_to_f32_sat(u)); + assert_eq!(u, v); + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/columns.rs b/plugins/libimhex-rust/imgui-rs/src/columns.rs new file mode 100644 index 000000000..b282e91e0 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/columns.rs @@ -0,0 +1,68 @@ +use crate::sys; +use crate::Ui; + +/// # Columns +impl<'ui> Ui<'ui> { + #[doc(alias = "Columns")] + pub fn columns(&self, count: i32, id: impl AsRef, border: bool) { + unsafe { sys::igColumns(count, self.scratch_txt(id), border) } + } + /// Switches to the next column. + /// + /// If the current row is finished, switches to first column of the next row + #[doc(alias = "NextColumn")] + pub fn next_column(&self) { + unsafe { sys::igNextColumn() } + } + /// Returns the index of the current column + #[doc(alias = "GetColumnIndex")] + pub fn current_column_index(&self) -> i32 { + unsafe { sys::igGetColumnIndex() } + } + /// Returns the width of the current column (in pixels) + #[doc(alias = "GetColumnWidth")] + pub fn current_column_width(&self) -> f32 { + unsafe { sys::igGetColumnWidth(-1) } + } + #[doc(alias = "GetColumnWidth")] + /// Returns the width of the given column (in pixels) + pub fn column_width(&self, column_index: i32) -> f32 { + unsafe { sys::igGetColumnWidth(column_index) } + } + #[doc(alias = "SetColumnWidth")] + /// Sets the width of the current column (in pixels) + pub fn set_current_column_width(&self, width: f32) { + unsafe { sys::igSetColumnWidth(-1, width) }; + } + #[doc(alias = "SetColumnWidth")] + /// Sets the width of the given column (in pixels) + pub fn set_column_width(&self, column_index: i32, width: f32) { + unsafe { sys::igSetColumnWidth(column_index, width) }; + } + /// Returns the offset of the current column (in pixels from the left side of the content + /// region) + #[doc(alias = "GetColumnOffset")] + pub fn current_column_offset(&self) -> f32 { + unsafe { sys::igGetColumnOffset(-1) } + } + /// Returns the offset of the given column (in pixels from the left side of the content region) + #[doc(alias = "GetColumnOffset")] + pub fn column_offset(&self, column_index: i32) -> f32 { + unsafe { sys::igGetColumnOffset(column_index) } + } + /// Sets the offset of the current column (in pixels from the left side of the content region) + #[doc(alias = "SetColumnOffset")] + pub fn set_current_column_offset(&self, offset_x: f32) { + unsafe { sys::igSetColumnOffset(-1, offset_x) }; + } + /// Sets the offset of the given column (in pixels from the left side of the content region) + #[doc(alias = "SetColumnOffset")] + pub fn set_column_offset(&self, column_index: i32, offset_x: f32) { + unsafe { sys::igSetColumnOffset(column_index, offset_x) }; + } + /// Returns the current amount of columns + #[doc(alias = "GetColumnCount")] + pub fn column_count(&self) -> i32 { + unsafe { sys::igGetColumnsCount() } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/context.rs b/plugins/libimhex-rust/imgui-rs/src/context.rs new file mode 100644 index 000000000..b0846caf7 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/context.rs @@ -0,0 +1,582 @@ +use parking_lot::ReentrantMutex; +use std::cell::{RefCell, UnsafeCell}; +use std::ffi::{CStr, CString}; +use std::mem::ManuallyDrop; +use std::ops::Drop; +use std::path::PathBuf; +use std::ptr; +use std::rc::Rc; + +use crate::clipboard::{ClipboardBackend, ClipboardContext}; +use crate::fonts::atlas::{FontAtlas, FontAtlasRefMut, FontId, SharedFontAtlas}; +use crate::io::Io; +use crate::style::Style; +use crate::sys; +use crate::Ui; + +/// An imgui-rs context. +/// +/// A context needs to be created to access most library functions. Due to current Dear ImGui +/// design choices, at most one active Context can exist at any time. This limitation will likely +/// be removed in a future Dear ImGui version. +/// +/// If you need more than one context, you can use suspended contexts. As long as only one context +/// is active at a time, it's possible to have multiple independent contexts. +/// +/// # Examples +/// +/// Creating a new active context: +/// ``` +/// let ctx = imgui::Context::create(); +/// // ctx is dropped naturally when it goes out of scope, which deactivates and destroys the +/// // context +/// ``` +/// +/// Never try to create an active context when another one is active: +/// +/// ```should_panic +/// let ctx1 = imgui::Context::create(); +/// +/// let ctx2 = imgui::Context::create(); // PANIC +/// ``` +/// +/// Suspending an active context allows you to create another active context: +/// +/// ``` +/// let ctx1 = imgui::Context::create(); +/// let suspended1 = ctx1.suspend(); +/// let ctx2 = imgui::Context::create(); // this is now OK +/// ``` + +#[derive(Debug)] +pub struct Context { + raw: *mut sys::ImGuiContext, + shared_font_atlas: Option>>, + ini_filename: Option, + log_filename: Option, + platform_name: Option, + renderer_name: Option, + // we need to box this because we hand imgui a pointer to it, + // and we don't want to deal with finding `clipboard_ctx`. + // we also put it in an unsafecell since we're going to give + // imgui a mutable pointer to it. + clipboard_ctx: Box>, +} + +// This mutex needs to be used to guard all public functions that can affect the underlying +// Dear ImGui active context +static CTX_MUTEX: ReentrantMutex<()> = parking_lot::const_reentrant_mutex(()); + +fn clear_current_context() { + unsafe { + sys::igSetCurrentContext(ptr::null_mut()); + } +} +fn no_current_context() -> bool { + let ctx = unsafe { sys::igGetCurrentContext() }; + ctx.is_null() +} + +impl Context { + /// Creates a new active imgui-rs context. + /// + /// # Panics + /// + /// Panics if an active context already exists + #[doc(alias = "CreateContext")] + pub fn create() -> Self { + Self::create_internal(None) + } + /// Creates a new active imgui-rs context with a shared font atlas. + /// + /// # Panics + /// + /// Panics if an active context already exists + #[doc(alias = "CreateContext")] + pub fn create_with_shared_font_atlas(shared_font_atlas: Rc>) -> Self { + Self::create_internal(Some(shared_font_atlas)) + } + /// Suspends this context so another context can be the active context. + #[doc(alias = "CreateContext")] + pub fn suspend(self) -> SuspendedContext { + let _guard = CTX_MUTEX.lock(); + assert!( + self.is_current_context(), + "context to be suspended is not the active context" + ); + clear_current_context(); + SuspendedContext(self) + } + /// Returns the path to the ini file, or None if not set + pub fn ini_filename(&self) -> Option { + let io = self.io(); + if io.ini_filename.is_null() { + None + } else { + let s = unsafe { CStr::from_ptr(io.ini_filename) }; + Some(PathBuf::from(s.to_str().ok()?)) + } + } + /// Sets the path to the ini file (default is "imgui.ini") + /// + /// Pass None to disable automatic .Ini saving. + pub fn set_ini_filename>>(&mut self, ini_filename: T) { + let ini_filename: Option = ini_filename.into(); + let ini_filename = ini_filename.and_then(|v| CString::new(v.to_str()?).ok()); + + self.io_mut().ini_filename = ini_filename + .as_ref() + .map(|x| x.as_ptr()) + .unwrap_or(ptr::null()); + self.ini_filename = ini_filename; + } + /// Returns the path to the log file, or None if not set + // TODO: why do we return an `Option` instead of an `Option<&Path>`? + pub fn log_filename(&self) -> Option { + let io = self.io(); + if io.log_filename.is_null() { + None + } else { + let cstr = unsafe { CStr::from_ptr(io.log_filename) }; + Some(PathBuf::from(cstr.to_str().ok()?)) + } + } + /// Sets the log filename (default is "imgui_log.txt"). + pub fn set_log_filename>>(&mut self, log_filename: T) { + let log_filename = log_filename + .into() + .and_then(|v| CString::new(v.to_str()?).ok()); + + self.io_mut().log_filename = log_filename + .as_ref() + .map(|x| x.as_ptr()) + .unwrap_or(ptr::null()); + self.log_filename = log_filename; + } + /// Returns the backend platform name, or None if not set + pub fn platform_name(&self) -> Option<&str> { + let io = self.io(); + if io.backend_platform_name.is_null() { + None + } else { + let cstr = unsafe { CStr::from_ptr(io.backend_platform_name) }; + cstr.to_str().ok() + } + } + /// Sets the backend platform name + pub fn set_platform_name>>(&mut self, platform_name: T) { + let platform_name: Option = + platform_name.into().and_then(|v| CString::new(v).ok()); + self.io_mut().backend_platform_name = platform_name + .as_ref() + .map(|x| x.as_ptr()) + .unwrap_or(ptr::null()); + self.platform_name = platform_name; + } + /// Returns the backend renderer name, or None if not set + pub fn renderer_name(&self) -> Option<&str> { + let io = self.io(); + if io.backend_renderer_name.is_null() { + None + } else { + let cstr = unsafe { CStr::from_ptr(io.backend_renderer_name) }; + cstr.to_str().ok() + } + } + /// Sets the backend renderer name + pub fn set_renderer_name>>(&mut self, renderer_name: T) { + let renderer_name: Option = + renderer_name.into().and_then(|v| CString::new(v).ok()); + + self.io_mut().backend_renderer_name = renderer_name + .as_ref() + .map(|x| x.as_ptr()) + .unwrap_or(ptr::null()); + + self.renderer_name = renderer_name; + } + /// Loads settings from a string slice containing settings in .Ini file format + #[doc(alias = "LoadIniSettingsFromMemory")] + pub fn load_ini_settings(&mut self, data: &str) { + unsafe { sys::igLoadIniSettingsFromMemory(data.as_ptr() as *const _, data.len()) } + } + /// Saves settings to a mutable string buffer in .Ini file format + #[doc(alias = "SaveInitSettingsToMemory")] + pub fn save_ini_settings(&mut self, buf: &mut String) { + let data = unsafe { CStr::from_ptr(sys::igSaveIniSettingsToMemory(ptr::null_mut())) }; + buf.push_str(&data.to_string_lossy()); + } + /// Sets the clipboard backend used for clipboard operations + pub fn set_clipboard_backend(&mut self, backend: T) { + let clipboard_ctx: Box> = Box::new(ClipboardContext::new(backend).into()); + let io = self.io_mut(); + io.set_clipboard_text_fn = Some(crate::clipboard::set_clipboard_text); + io.get_clipboard_text_fn = Some(crate::clipboard::get_clipboard_text); + + io.clipboard_user_data = clipboard_ctx.get() as *mut _; + self.clipboard_ctx = clipboard_ctx; + } + fn create_internal(shared_font_atlas: Option>>) -> Self { + let _guard = CTX_MUTEX.lock(); + assert!( + no_current_context(), + "A new active context cannot be created, because another one already exists" + ); + + let shared_font_atlas_ptr = match &shared_font_atlas { + Some(shared_font_atlas) => { + let borrowed_font_atlas = shared_font_atlas.borrow(); + borrowed_font_atlas.0 + } + None => ptr::null_mut(), + }; + // Dear ImGui implicitly sets the current context during igCreateContext if the current + // context doesn't exist + let raw = unsafe { sys::igCreateContext(shared_font_atlas_ptr) }; + + Context { + raw, + shared_font_atlas, + ini_filename: None, + log_filename: None, + platform_name: None, + renderer_name: None, + clipboard_ctx: Box::new(ClipboardContext::dummy().into()), + } + } + fn is_current_context(&self) -> bool { + let ctx = unsafe { sys::igGetCurrentContext() }; + self.raw == ctx + } + + /// Get a reference to the current context + pub fn current() -> Option { + let _guard = CTX_MUTEX.lock(); + + let raw = unsafe { sys::igGetCurrentContext() }; + + if raw.is_null() { + None + } else { + Some(ContextRef(ManuallyDrop::new(Context { + raw, + shared_font_atlas: None, // XXX: this might be needed tbh + ini_filename: None, + log_filename: None, + platform_name: None, + renderer_name: None, + clipboard_ctx: Box::new(ClipboardContext::dummy().into()), + }))) + } + } +} + +/// A reference to a [`Context`] object +#[derive(Debug)] +pub struct ContextRef(ManuallyDrop); + +impl core::ops::Deref for ContextRef { + type Target = Context; + + fn deref(&self) -> &Context { + &*self.0 + } +} + +impl core::ops::DerefMut for ContextRef { + fn deref_mut(&mut self) -> &mut Context { + &mut *self.0 + } +} + +impl Drop for Context { + #[doc(alias = "DestroyContext")] + fn drop(&mut self) { + let _guard = CTX_MUTEX.lock(); + // If this context is the active context, Dear ImGui automatically deactivates it during + // destruction + unsafe { + sys::igDestroyContext(self.raw); + } + } +} + +/// A suspended imgui-rs context. +/// +/// A suspended context retains its state, but is not usable without activating it first. +/// +/// # Examples +/// +/// Suspended contexts are not directly very useful, but you can activate them: +/// +/// ``` +/// let suspended = imgui::SuspendedContext::create(); +/// match suspended.activate() { +/// Ok(ctx) => { +/// // ctx is now the active context +/// }, +/// Err(suspended) => { +/// // activation failed, so you get the suspended context back +/// } +/// } +/// ``` +#[derive(Debug)] +pub struct SuspendedContext(Context); + +impl SuspendedContext { + /// Creates a new suspended imgui-rs context. + #[doc(alias = "CreateContext")] + pub fn create() -> Self { + Self::create_internal(None) + } + /// Creates a new suspended imgui-rs context with a shared font atlas. + pub fn create_with_shared_font_atlas(shared_font_atlas: Rc>) -> Self { + Self::create_internal(Some(shared_font_atlas)) + } + /// Attempts to activate this suspended context. + /// + /// If there is no active context, this suspended context is activated and `Ok` is returned, + /// containing the activated context. + /// If there is already an active context, nothing happens and `Err` is returned, containing + /// the original suspended context. + #[doc(alias = "SetCurrentContext")] + pub fn activate(self) -> Result { + let _guard = CTX_MUTEX.lock(); + if no_current_context() { + unsafe { + sys::igSetCurrentContext(self.0.raw); + } + Ok(self.0) + } else { + Err(self) + } + } + fn create_internal(shared_font_atlas: Option>>) -> Self { + let _guard = CTX_MUTEX.lock(); + let raw = unsafe { sys::igCreateContext(ptr::null_mut()) }; + let ctx = Context { + raw, + shared_font_atlas, + ini_filename: None, + log_filename: None, + platform_name: None, + renderer_name: None, + clipboard_ctx: Box::new(ClipboardContext::dummy().into()), + }; + if ctx.is_current_context() { + // Oops, the context was activated -> deactivate + clear_current_context(); + } + SuspendedContext(ctx) + } +} + +#[test] +fn test_one_context() { + let _guard = crate::test::TEST_MUTEX.lock(); + let _ctx = Context::create(); + assert!(!no_current_context()); +} + +#[test] +fn test_drop_clears_current_context() { + let _guard = crate::test::TEST_MUTEX.lock(); + { + let _ctx1 = Context::create(); + assert!(!no_current_context()); + } + assert!(no_current_context()); + { + let _ctx2 = Context::create(); + assert!(!no_current_context()); + } + assert!(no_current_context()); +} + +#[test] +fn test_new_suspended() { + let _guard = crate::test::TEST_MUTEX.lock(); + let ctx = Context::create(); + let _suspended = SuspendedContext::create(); + assert!(ctx.is_current_context()); + ::std::mem::drop(_suspended); + assert!(ctx.is_current_context()); +} + +#[test] +fn test_suspend() { + let _guard = crate::test::TEST_MUTEX.lock(); + let ctx = Context::create(); + assert!(!no_current_context()); + let _suspended = ctx.suspend(); + assert!(no_current_context()); + let _ctx2 = Context::create(); +} + +#[test] +fn test_drop_suspended() { + let _guard = crate::test::TEST_MUTEX.lock(); + let suspended = Context::create().suspend(); + assert!(no_current_context()); + let ctx2 = Context::create(); + ::std::mem::drop(suspended); + assert!(ctx2.is_current_context()); +} + +#[test] +fn test_suspend_activate() { + let _guard = crate::test::TEST_MUTEX.lock(); + let suspended = Context::create().suspend(); + assert!(no_current_context()); + let ctx = suspended.activate().unwrap(); + assert!(ctx.is_current_context()); +} + +#[test] +fn test_suspend_failure() { + let _guard = crate::test::TEST_MUTEX.lock(); + let suspended = Context::create().suspend(); + let _ctx = Context::create(); + assert!(suspended.activate().is_err()); +} + +#[test] +fn test_shared_font_atlas() { + let _guard = crate::test::TEST_MUTEX.lock(); + let atlas = Rc::new(RefCell::new(SharedFontAtlas::create())); + let suspended1 = SuspendedContext::create_with_shared_font_atlas(atlas.clone()); + let mut ctx2 = Context::create_with_shared_font_atlas(atlas); + { + let _borrow = ctx2.fonts(); + } + let _suspended2 = ctx2.suspend(); + let mut ctx = suspended1.activate().unwrap(); + let _borrow = ctx.fonts(); +} + +#[test] +#[should_panic] +fn test_shared_font_atlas_borrow_panic() { + let _guard = crate::test::TEST_MUTEX.lock(); + let atlas = Rc::new(RefCell::new(SharedFontAtlas::create())); + let _suspended = SuspendedContext::create_with_shared_font_atlas(atlas.clone()); + let mut ctx = Context::create_with_shared_font_atlas(atlas.clone()); + let _borrow1 = atlas.borrow(); + let _borrow2 = ctx.fonts(); +} + +#[test] +fn test_ini_load_save() { + let (_guard, mut ctx) = crate::test::test_ctx(); + let data = "[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0"; + ctx.load_ini_settings(data); + let mut buf = String::new(); + ctx.save_ini_settings(&mut buf); + assert_eq!(data.trim(), buf.trim()); +} + +#[test] +fn test_default_ini_filename() { + let _guard = crate::test::TEST_MUTEX.lock(); + let ctx = Context::create(); + assert_eq!(ctx.ini_filename(), Some(PathBuf::from("imgui.ini"))); +} + +#[test] +fn test_set_ini_filename() { + let (_guard, mut ctx) = crate::test::test_ctx(); + ctx.set_ini_filename(Some(PathBuf::from("test.ini"))); + assert_eq!(ctx.ini_filename(), Some(PathBuf::from("test.ini"))); +} + +#[test] +fn test_default_log_filename() { + let _guard = crate::test::TEST_MUTEX.lock(); + let ctx = Context::create(); + assert_eq!(ctx.log_filename(), Some(PathBuf::from("imgui_log.txt"))); +} + +#[test] +fn test_set_log_filename() { + let (_guard, mut ctx) = crate::test::test_ctx(); + ctx.set_log_filename(Some(PathBuf::from("test.log"))); + assert_eq!(ctx.log_filename(), Some(PathBuf::from("test.log"))); +} + +impl Context { + /// Returns an immutable reference to the inputs/outputs object + pub fn io(&self) -> &Io { + unsafe { + // safe because Io is a transparent wrapper around sys::ImGuiIO + &*(sys::igGetIO() as *const Io) + } + } + /// Returns a mutable reference to the inputs/outputs object + pub fn io_mut(&mut self) -> &mut Io { + unsafe { + // safe because Io is a transparent wrapper around sys::ImGuiIO + &mut *(sys::igGetIO() as *mut Io) + } + } + /// Returns an immutable reference to the user interface style + #[doc(alias = "GetStyle")] + pub fn style(&self) -> &Style { + unsafe { + // safe because Style is a transparent wrapper around sys::ImGuiStyle + &*(sys::igGetStyle() as *const Style) + } + } + /// Returns a mutable reference to the user interface style + #[doc(alias = "GetStyle")] + pub fn style_mut(&mut self) -> &mut Style { + unsafe { + // safe because Style is a transparent wrapper around sys::ImGuiStyle + &mut *(sys::igGetStyle() as *mut Style) + } + } + /// Returns a mutable reference to the font atlas. + /// + /// # Panics + /// + /// Panics if the context uses a shared font atlas that is already borrowed + pub fn fonts(&mut self) -> FontAtlasRefMut<'_> { + match self.shared_font_atlas { + Some(ref font_atlas) => FontAtlasRefMut::Shared(font_atlas.borrow_mut()), + None => unsafe { + // safe because FontAtlas is a transparent wrapper around sys::ImFontAtlas + let fonts = &mut *(self.io_mut().fonts as *mut FontAtlas); + FontAtlasRefMut::Owned(fonts) + }, + } + } + /// Starts a new frame and returns an `Ui` instance for constructing a user interface. + /// + /// # Panics + /// + /// Panics if the context uses a shared font atlas that is already borrowed + #[doc(alias = "NewFame")] + pub fn frame(&mut self) -> Ui<'_> { + // Clear default font if it no longer exists. This could be an error in the future + let default_font = self.io().font_default; + if !default_font.is_null() && self.fonts().get_font(FontId(default_font)).is_none() { + self.io_mut().font_default = ptr::null_mut(); + } + // NewFrame/Render/EndFrame mutate the font atlas so we need exclusive access to it + let font_atlas = self + .shared_font_atlas + .as_ref() + .map(|font_atlas| font_atlas.borrow_mut()); + // TODO: precondition checks + unsafe { + sys::igNewFrame(); + } + Ui { + ctx: self, + font_atlas, + buffer: crate::UiBuffer::new(1024).into(), + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/drag_drop.rs b/plugins/libimhex-rust/imgui-rs/src/drag_drop.rs new file mode 100644 index 000000000..2fbf0b5cd --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/drag_drop.rs @@ -0,0 +1,594 @@ +//! Structs to create a Drag and Drop sequence. Almost all structs are re-exported +//! and can be accessed from the crate root; some additional utilities can be found in here. +//! +//! A DragDrop is a UI mechanism where users can appear to "drag" +//! some data from one [source](DragDropSource) to one [target](DragDropTarget). +//! A source and a target must both have some `name` identifier, which is declared when they +//! are created. If these names are equal, then a `payload` of some kind +//! will be given to the target caller whne the user releases their mouse button over +//! the target (additionally, the UI will reflect that the payload *can* be deposited +//! in the target). +//! +//! The complexity of this implementation is primarily in managing this payload. Users +//! can provide three different kinds of payloads: +//! +//! 1. Users can give an [empty payload](DragDropPayloadEmpty) with [begin](DragDropSource::begin). +//! This payload type is essentially just a notification system, but using some shared state, +//! this can be reasonably powerful, and is the safest way to transfer non-Copy data offered +//! right now. +//! 2. Users can give a [simple Copy payload](DragDropPayloadPod) with [begin](DragDropSource::begin_payload). +//! This allows users to copy data to Dear ImGui, which will take ownership over it, and then be given +//! it back to the Target. Please note: users are of course free to not drop any drag (cancel a drag), +//! so this data could easily be lost forever. Our `'static + Copy` bound is intended to keep users +//! to simplistic types. +//! 3. An unsafe implementation is provided which allows for any data to be unsafely copied. Note that once +//! you use this method, the safe implementations in #1 and #2 can create memory unsafety problems; notably, +//! they both assume that a payload has certain header information within it. +//! +//! For examples of each payload type, see [DragDropSource]. +use std::{any, ffi, marker::PhantomData}; + +use crate::{sys, Condition, Ui}; +use bitflags::bitflags; + +bitflags!( + /// Flags for igBeginDragDropSource(), igAcceptDragDropPayload() + #[repr(transparent)] + pub struct DragDropFlags: u32 { + /// 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 SOURCE_NO_PREVIEW_TOOLTIP = sys::ImGuiDragDropFlags_SourceNoPreviewTooltip; + /// 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 SOURCE_NO_DISABLE_HOVER = sys::ImGuiDragDropFlags_SourceNoDisableHover; + /// Disable the behavior that allows to open tree nodes and collapsing header by holding + /// over them while dragging a source item. + const SOURCE_NO_HOLD_TO_OPEN_OTHERS = sys::ImGuiDragDropFlags_SourceNoHoldToOpenOthers; + /// 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 SOURCE_ALLOW_NULL_ID = sys::ImGuiDragDropFlags_SourceAllowNullID; + /// 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 SOURCE_EXTERN = sys::ImGuiDragDropFlags_SourceExtern; + /// Automatically expire the payload if the source ceases to be submitted (otherwise + /// payloads are persisting while being dragged) + const SOURCE_AUTO_EXPIRE_PAYLOAD = sys::ImGuiDragDropFlags_SourceAutoExpirePayload; + /// 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 ACCEPT_BEFORE_DELIVERY = sys::ImGuiDragDropFlags_AcceptBeforeDelivery; + /// Do not draw the default highlight rectangle when hovering over target. + const ACCEPT_NO_DRAW_DEFAULT_RECT = sys::ImGuiDragDropFlags_AcceptNoDrawDefaultRect; + /// Request hiding the igBeginDragDropSource tooltip from the igBeginDragDropTarget site. + const ACCEPT_NO_PREVIEW_TOOLTIP = sys::ImGuiDragDropFlags_AcceptNoPreviewTooltip; + /// For peeking ahead and inspecting the payload before delivery. This is just a convenience + /// flag for the intersection of `ACCEPT_BEFORE_DELIVERY` and `ACCEPT_NO_DRAW_DEFAULT_RECT` + const ACCEPT_PEEK_ONLY = sys::ImGuiDragDropFlags_AcceptPeekOnly; + } +); + +/// Creates a source for drag drop data out of the last ID created. +/// +/// ```no_run +/// # use imgui::*; +/// fn show_ui(ui: &Ui<'_>) { +/// ui.button("Hello, I am a drag source!"); +/// +/// // Creates an empty DragSource with no tooltip +/// DragDropSource::new("BUTTON_DRAG").begin(ui); +/// } +/// ``` +/// +/// Notice especially the `"BUTTON_DRAG"` name -- this is the identifier of this +/// DragDropSource; [DragDropTarget]'s will specify an identifier to *receive*, and these +/// names must match up. A single item should only have one [DragDropSource], though +/// a target may have multiple different targets. +/// +/// DropDropSources don't do anything until you use one of the three `begin_` methods +/// on this struct. Each of these methods describes how you handle the Payload which ImGui +/// will manage, and then give to a [DragDropTarget], which will received the payload. The +/// simplest and safest Payload is the empty payload, created with [begin](Self::begin). +#[derive(Debug)] +pub struct DragDropSource { + name: T, + flags: DragDropFlags, + cond: Condition, +} + +impl> DragDropSource { + /// Creates a new [DragDropSource] with no flags and the `Condition::Always` with the given name. + /// ImGui refers to this `name` field as a `type`, but really it's just an identifier to match up + /// Source/Target for DragDrop. + pub fn new(name: T) -> Self { + Self { + name, + flags: DragDropFlags::empty(), + cond: Condition::Always, + } + } + + /// Sets the flags on the [DragDropSource]. Only the flags `SOURCE_NO_PREVIEW_TOOLTIP`, + /// `SOURCE_NO_DISABLE_HOVER`, `SOURCE_NO_HOLD_TO_OPEN_OTHERS`, `SOURCE_ALLOW_NULL_ID`, + /// `SOURCE_EXTERN`, `SOURCE_AUTO_EXPIRE_PAYLOAD` make semantic sense, but any other flags will + /// be accepted without panic. + #[inline] + pub fn flags(mut self, flags: DragDropFlags) -> Self { + self.flags = flags; + self + } + + /// Sets the condition on the [DragDropSource]. Defaults to [Always](Condition::Always). + #[inline] + pub fn condition(mut self, cond: Condition) -> Self { + self.cond = cond; + self + } + + /// Creates the source of a drag and returns a handle on the tooltip. + /// This handle can be immediately dropped without binding it, in which case a default empty + /// circle will be used for the "blank" tooltip as this item is being dragged around. + /// + /// Otherwise, use this tooltip to add data which will display as this item is dragged. + /// If `SOURCE_NO_PREVIEW_TOOLTIP` is enabled, however, no preview will be displayed + /// and this returned token does nothing. Additionally, a given target may use the flag + /// `ACCEPT_NO_PREVIEW_TOOLTIP`, which will also prevent this tooltip from being shown. + /// + /// This drag has no payload, but is still probably the most useful way in imgui-rs to handle payloads. + /// Using `once_cell` or some shared data, this pattern can be very powerful: + /// + /// ```no_run + /// # use imgui::*; + /// fn show_ui(ui: &Ui<'_>, drop_message: &mut Option) { + /// ui.button("Drag me!"); + /// + /// let drag_drop_name = "Test Drag"; + /// + /// // drag drop SOURCE + /// if DragDropSource::new(drag_drop_name).begin(ui).is_some() { + /// // warning -- this would allocate every frame if `DragDropSource` has + /// // condition `Always`, which it does by default. We're okay with that for + /// // this example, but real code probably wouldn't want to allocate so much. + /// *drop_message = Some("Test Payload".to_string()); + /// } + /// + /// ui.button("Target me!"); + /// + /// // drag drop TARGET + /// if let Some(target) = imgui::DragDropTarget::new(ui) { + /// if target + /// .accept_payload_empty(drag_drop_name, DragDropFlags::empty()) + /// .is_some() + /// { + /// let msg = drop_message.take().unwrap(); + /// assert_eq!(msg, "Test Payload"); + /// } + /// + /// target.pop(); + /// } + /// } + /// ``` + /// + /// In the above, you'll see how the payload is really just a message passing service. + /// If you want to pass a simple integer or other "plain old data", take a look at + /// [begin_payload](Self::begin_payload). + #[inline] + pub fn begin<'ui>(self, ui: &Ui<'ui>) -> Option> { + self.begin_payload(ui, ()) + } + + /// Creates the source of a drag and returns a handle on the tooltip. + /// This handle can be immediately dropped without binding it, in which case a default empty + /// circle will be used for the "blank" tooltip as this item is being dragged around. + /// + /// Otherwise, use this tooltip to add data which will display as this item is dragged. + /// If `SOURCE_NO_PREVIEW_TOOLTIP` is enabled, however, no preview will be displayed + /// and this returned token does nothing. Additionally, a given target may use the flag + /// `ACCEPT_NO_PREVIEW_TOOLTIP`, which will also prevent this tooltip from being shown. + /// + /// This function also takes a payload in the form of `T: Copy + 'static`. ImGui will + /// memcpy this data immediately to an internally held buffer, and will return the data + /// to [DragDropTarget]. + /// + /// ```no_run + /// # use imgui::*; + /// fn show_ui(ui: &Ui<'_>) { + /// ui.button("Drag me!"); + /// + /// let drag_drop_name = "Test Drag"; + /// let msg_to_send = "hello there sailor"; + /// + /// // drag drop SOURCE + /// if let Some(tooltip) = DragDropSource::new(drag_drop_name).begin_payload(ui, msg_to_send) { + /// ui.text("Sending message!"); + /// tooltip.end(); + /// } + /// + /// ui.button("Target me!"); + /// + /// // drag drop TARGET + /// if let Some(target) = imgui::DragDropTarget::new(ui) { + /// if let Some(Ok(payload_data)) = target + /// .accept_payload::<&'static str, _>(drag_drop_name, DragDropFlags::empty()) + /// { + /// let msg = payload_data.data; + /// assert_eq!(msg, msg_to_send); + /// } + /// + /// target.pop(); + /// } + /// } + /// ``` + #[inline] + pub fn begin_payload<'ui, P: Copy + 'static>( + self, + ui: &Ui<'ui>, + payload: P, + ) -> Option> { + unsafe { + let payload = TypedPayload::new(payload); + self.begin_payload_unchecked( + ui, + &payload as *const _ as *const ffi::c_void, + std::mem::size_of::>(), + ) + } + } + + /// Creates the source of a drag and returns a handle on the tooltip. + /// This handle can be immediately dropped without binding it, in which case a default empty + /// circle will be used for the "blank" tooltip as this item is being dragged around. + /// + /// Otherwise, use this tooltip to add data which will display as this item is dragged. + /// If `SOURCE_NO_PREVIEW_TOOLTIP` is enabled, however, no preview will be displayed + /// and this returned token does nothing. Additionally, a given target may use the flag + /// `ACCEPT_NO_PREVIEW_TOOLTIP`, which will also prevent this tooltip from being shown. + /// + /// This function also takes a payload of any `*const T`. ImGui will + /// memcpy this data immediately to an internally held buffer, and will return the data + /// to [DragDropTarget]. + /// + /// ## Safety + /// This function itself will not cause a panic, but using it directly opts you into + /// managing the lifetime of the pointer provided yourself. Dear ImGui will execute a memcpy on + /// the data passed in with the size (in bytes) given, but this is, of course, just a copy, + /// so if you pass in an `&String`, for example, the underlying String data will not be cloned, + /// and could easily dangle if the `String` is dropped. + /// + /// Moreover, if `Condition::Always` is set (as it is by default), you will be copying in your data + /// every time this function is ran in your update loop, which if it involves an allocating and then + /// handing the allocation to ImGui, would result in a significant amount of data created. + /// + /// Overall, users should be very sure that this function is needed before they reach for it, and instead + /// should consider either [begin](Self::begin) or [begin_payload](Self::begin_payload). + #[inline] + pub unsafe fn begin_payload_unchecked<'ui>( + &self, + ui: &Ui<'ui>, + ptr: *const ffi::c_void, + size: usize, + ) -> Option> { + let should_begin = sys::igBeginDragDropSource(self.flags.bits() as i32); + + if should_begin { + sys::igSetDragDropPayload(ui.scratch_txt(&self.name), ptr, size, self.cond as i32); + + Some(DragDropSourceToolTip::push()) + } else { + None + } + } +} + +/// A helper struct for RAII drap-drop support. +pub struct DragDropSourceToolTip<'ui>(PhantomData>); + +impl DragDropSourceToolTip<'_> { + /// Creates a new tooltip internally. + #[inline] + fn push() -> Self { + Self(PhantomData) + } + + /// Ends the tooltip directly. You could choose to simply allow this to drop + /// by not calling this, which will also be fine. + #[inline] + pub fn end(self) { + // left empty to invoke drop... + } +} + +impl Drop for DragDropSourceToolTip<'_> { + fn drop(&mut self) { + unsafe { sys::igEndDragDropSource() } + } +} + +/// Creates a target for drag drop data out of the last ID created. +/// +/// ```no_run +/// # use imgui::*; +/// fn show_ui(ui: &Ui<'_>) { +/// // Drop something on this button please! +/// ui.button("Hello, I am a drag Target!"); +/// +/// if let Some(target) = DragDropTarget::new(ui) { +/// // accepting an empty payload (which is really just raising an event) +/// if let Some(_payload_data) = target.accept_payload_empty("BUTTON_DRAG", DragDropFlags::empty()) { +/// println!("Nice job getting on the payload!"); +/// } +/// +/// // and we can accept multiple, different types of payloads with one drop target. +/// // this is a good pattern for handling different kinds of drag/drop situations with +/// // different kinds of data in them. +/// if let Some(Ok(payload_data)) = target.accept_payload::("BUTTON_ID", DragDropFlags::empty()) { +/// println!("Our payload's data was {}", payload_data.data); +/// } +/// } +/// } +/// ``` +/// +/// Notice especially the `"BUTTON_DRAG"` and `"BUTTON_ID"` name -- this is the identifier of this +/// DragDropTarget; [DragDropSource]s will specify an identifier when they send a payload, and these +/// names must match up. Notice how a target can have multiple acceptances on them -- this is a good +/// pattern to handle multiple kinds of data which could be passed around. +/// +/// DropDropTargets don't do anything until you use one of the three `accept_` methods +/// on this struct. Each of these methods will spit out a _Payload struct with an increasing +/// amount of information on the Payload. The absolute safest solution is [accept_payload_empty](Self::accept_payload_empty). +#[derive(Debug)] +pub struct DragDropTarget<'ui>(&'ui Ui<'ui>); + +impl<'ui> DragDropTarget<'ui> { + /// Creates a new DragDropTarget, holding the [Ui]'s lifetime for the duration + /// of its existence. This is required since this struct runs some code on its Drop + /// to end the DragDropTarget code. + #[doc(alias = "BeginDragDropTarget")] + pub fn new(ui: &'ui Ui<'ui>) -> Option { + let should_begin = unsafe { sys::igBeginDragDropTarget() }; + if should_begin { + Some(Self(ui)) + } else { + None + } + } + + /// Accepts an empty payload. This is the safest option for raising named events + /// in the DragDrop API. See [DragDropSource::begin] for more information on how you + /// might use this pattern. + /// + /// Note: If you began this operation with `begin_payload_unchecked` it always incorrect + /// to use this function. Use `accept_payload_unchecked` instead + pub fn accept_payload_empty( + &self, + name: impl AsRef, + flags: DragDropFlags, + ) -> Option { + self.accept_payload(name, flags)? + .ok() + .map(|payload_pod: DragDropPayloadPod<()>| DragDropPayloadEmpty { + preview: payload_pod.preview, + delivery: payload_pod.delivery, + }) + } + + /// Accepts a payload with plain old data in it. This returns a Result, since you can specify any + /// type. The sent type must match the return type (via TypeId) to receive an `Ok`. + /// + /// Note: If you began this operation with `begin_payload_unchecked` it always incorrect + /// to use this function. Use `accept_payload_unchecked` instead + pub fn accept_payload>( + &self, + name: Name, + flags: DragDropFlags, + ) -> Option, PayloadIsWrongType>> { + let output = unsafe { self.accept_payload_unchecked(name, flags) }; + + // convert the unsafe payload to our Result + output.map(|unsafe_payload| { + // sheering off the typeid... + let received = + unsafe { (unsafe_payload.data as *const TypedPayloadHeader).read_unaligned() }; + let expected = any::TypeId::of::(); + + if received.type_id == expected { + let data = + unsafe { (unsafe_payload.data as *const TypedPayload).read_unaligned() } + .data; + Ok(DragDropPayloadPod { + data, + preview: unsafe_payload.preview, + delivery: unsafe_payload.delivery, + }) + } else { + Err(PayloadIsWrongType { + received, + expected: TypedPayloadHeader::new::(), + }) + } + }) + } + + /// Accepts a drag and drop payload which contains a raw pointer to [c_void](std::ffi::c_void) + /// and a size in bytes. Users should generally avoid using this function + /// if one of the safer variants is acceptable. + /// + /// ## Safety + /// + /// Because this pointer comes from ImGui, absolutely no promises can be made on its + /// contents, alignment, or lifetime. Interacting with it is therefore extremely unsafe. + /// **Important:** a special note needs to be made to the [ACCEPT_BEFORE_DELIVERY](DragDropFlags::ACCEPT_BEFORE_DELIVERY) flag -- + /// passing this flag will make this function return `Some(DragDropPayload)` **even before + /// the user has actually "dropped" the payload by release their mouse button.** + /// + /// In safe functions, this works just fine, since the data can be freely copied + /// (or doesn't exist at all!). However, if you are working with your own data, you must + /// be extremely careful with this data, as you may, effectively, only have immutable access to it. + /// + /// Moreover, if the `DragDropSource` has also used `Condition::Once` or similar when they sent the data, + /// ImGui will assume its data is still valid even after your preview, so corrupting that data could + /// lead to all sorts of unsafe behvaior on ImGui's side. In summary, using this function for any data + /// which isn't truly `Copy` or "plain old data" is difficult, and requires substantial knowledge + /// of the various edge cases. + pub unsafe fn accept_payload_unchecked( + &self, + name: impl AsRef, + flags: DragDropFlags, + ) -> Option { + let inner = sys::igAcceptDragDropPayload(self.0.scratch_txt(name), flags.bits() as i32); + if inner.is_null() { + None + } else { + let inner = *inner; + + // @fixme: there are actually other fields on `inner` which I have shorn -- they're + // considered internal to imgui (such as id of who sent this), so i've left it for + // now this way. + Some(DragDropPayload { + data: inner.Data, + size: inner.DataSize as usize, + preview: inner.Preview, + delivery: inner.Delivery, + }) + } + } + + /// Ends the current target. Ironically, this doesn't really do anything in ImGui + /// or in imgui-rs, but it might in the future. + pub fn pop(self) { + // omitted...exists just to run Drop. + } +} + +impl Drop for DragDropTarget<'_> { + fn drop(&mut self) { + unsafe { sys::igEndDragDropTarget() } + } +} + +/// An empty DragDropPayload. It has no data in it, and just includes +/// two bools with status information. +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub struct DragDropPayloadEmpty { + /// Set when [`accept_payload_empty`](DragDropTarget::accept_payload_empty) was called + /// and mouse has been hovering the target item. + pub preview: bool, + + /// Set when [`accept_payload_empty`](DragDropTarget::accept_payload_empty) was + /// called and mouse button is released over the target item. + pub delivery: bool, +} + +/// A DragDropPayload with status information and some POD, or plain old data, +/// in it. +#[derive(Debug, Copy, Clone)] +#[non_exhaustive] +pub struct DragDropPayloadPod { + /// The kind data which was requested. + pub data: T, + + /// Set when [`accept_payload`](DragDropTarget::accept_payload) was called + /// and mouse has been hovering the target item. + pub preview: bool, + + /// Set when [`accept_payload`](DragDropTarget::accept_payload) was + /// called and mouse button is released over the target item. + pub delivery: bool, +} + +#[derive(Debug)] +#[non_exhaustive] +pub struct DragDropPayload { + /// Data which is copied and owned by ImGui. If you have accepted the payload, you can + /// take ownership of the data; otherwise, view it immutably. Interacting with `data` is + /// very unsafe. + pub data: *const ffi::c_void, + + /// The size of the data in bytes. + pub size: usize, + + /// Set when [`accept_payload_unchecked`](DragDropTarget::accept_payload_unchecked) was called + /// and mouse has been hovering the target item. + pub preview: bool, + + /// Set when [`accept_payload_unchecked`](DragDropTarget::accept_payload_unchecked) was + /// called and mouse button is released over the target item. If this is set to false, then you + /// set DragDropFlags::ACCEPT_BEFORE_DELIVERY and shouldn't mutate `data`. + pub delivery: bool, +} + +/// A typed payload. +#[derive(Debug, Clone, Copy)] +#[repr(C)] +struct TypedPayload { + header: TypedPayloadHeader, + data: T, +} + +impl TypedPayload { + /// Creates a new typed payload which contains this data. + fn new(data: T) -> Self { + Self { + header: TypedPayloadHeader::new::(), + data, + } + } +} + +/// A header for a typed payload. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)] +#[repr(C)] +struct TypedPayloadHeader { + type_id: any::TypeId, + #[cfg(debug_assertions)] + type_name: &'static str, +} + +impl TypedPayloadHeader { + #[cfg(debug_assertions)] + fn new() -> Self { + Self { + type_id: any::TypeId::of::(), + type_name: any::type_name::(), + } + } + + #[cfg(not(debug_assertions))] + fn new() -> Self { + Self { + type_id: any::TypeId::of::(), + } + } +} + +/// Indicates that an incorrect payload type was received. It is opaque, +/// but you can view useful information with Debug formatting when +/// `debug_assertions` are enabled. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)] +pub struct PayloadIsWrongType { + expected: TypedPayloadHeader, + received: TypedPayloadHeader, +} + +#[cfg(debug_assertions)] +impl std::fmt::Display for PayloadIsWrongType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "Payload is {} -- expected {}", + self.received.type_name, self.expected.type_name + ) + } +} + +#[cfg(not(debug_assertions))] +impl std::fmt::Display for PayloadIsWrongType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.pad("Payload is wrong type") + } +} + +impl std::error::Error for PayloadIsWrongType {} diff --git a/plugins/libimhex-rust/imgui-rs/src/draw_list.rs b/plugins/libimhex-rust/imgui-rs/src/draw_list.rs new file mode 100644 index 000000000..e6882e56a --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/draw_list.rs @@ -0,0 +1,1041 @@ +//! The draw list lets you create custom graphics within a window. +//! +//! Each dear imgui window contains its own draw list. You can use +//! [`Ui::get_window_draw_list`] to access the current window draw +//! list and draw custom primitives. You can interleave normal widget +//! calls and adding primitives to the current draw list. +//! +//! Interaction is mostly through the mtehods [`DrawListMut`] struct, +//! such as [`DrawListMut::add_line`], however you can also construct +//! structs like [`Line`] directly, then call +//! `Line::build` with a reference to your draw list +//! +//! There are examples such as `draw_list.rs` and `custom_textures.rs` +//! within the `imgui-examples` directory + +use bitflags::bitflags; + +use crate::ImColor32; +use sys::ImDrawList; + +use super::Ui; +use crate::render::renderer::TextureId; + +use std::marker::PhantomData; + +bitflags!( + /// Options for some DrawList operations. + #[repr(C)] + pub struct DrawFlags: u32 { + const NONE = sys::ImDrawFlags_None; + const CLOSED = sys::ImDrawFlags_Closed; + const ROUND_CORNERS_TOP_LEFT = sys::ImDrawFlags_RoundCornersTopLeft; + const ROUND_CORNERS_TOP_RIGHT = sys::ImDrawFlags_RoundCornersTopRight; + const ROUND_CORNERS_BOT_LEFT = sys::ImDrawFlags_RoundCornersBottomLeft; + const ROUND_CORNERS_BOT_RIGHT = sys::ImDrawFlags_RoundCornersBottomRight; + const ROUND_CORNERS_TOP = sys::ImDrawFlags_RoundCornersTop; + const ROUND_CORNERS_BOT = sys::ImDrawFlags_RoundCornersBottom; + const ROUND_CORNERS_LEFT = sys::ImDrawFlags_RoundCornersLeft; + const ROUND_CORNERS_RIGHT = sys::ImDrawFlags_RoundCornersRight; + const ROUND_CORNERS_ALL = sys::ImDrawFlags_RoundCornersAll; + const ROUND_CORNERS_NONE = sys::ImDrawFlags_RoundCornersNone; + } +); + +bitflags!( + /// Draw list flags + #[repr(C)] + pub struct DrawListFlags: u32 { + const NONE = sys::ImDrawListFlags_None; + /// Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines + /// thin enough to be drawn using textures, otherwise *3 the number of triangles) + const ANTI_ALIASED_LINES = sys::ImDrawListFlags_AntiAliasedLines; + /// Enable anti-aliased lines/borders using textures when possible. Require backend to render + /// with bilinear filtering. + const ANTI_ALIASED_LINES_USE_TEX = sys::ImDrawListFlags_AntiAliasedLinesUseTex; + /// Enable anti-aliased edge around filled shapes (rounded rectangles, circles). + const ANTI_ALIASED_FILL = sys::ImDrawListFlags_AntiAliasedFill; + /// Can emit 'VtxOffset > 0' to allow large meshes. Set when + /// [`BackendFlags::RENDERER_HAS_VTX_OFFSET`] is enabled. + const ALLOW_VTX_OFFSET = sys::ImDrawListFlags_AllowVtxOffset; + } +); + +enum DrawListType { + Window, + Background, + Foreground, +} + +/// Object implementing the custom draw API. +/// +/// Called from [`Ui::get_window_draw_list`], [`Ui::get_background_draw_list`] or [`Ui::get_foreground_draw_list`]. +/// No more than one instance of this structure can live in a program at the same time. +/// The program will panic on creating a second instance. +pub struct DrawListMut<'ui> { + draw_list_type: DrawListType, + draw_list: *mut ImDrawList, + _phantom: PhantomData<&'ui Ui<'ui>>, +} + +// Lock for each variant of draw list. See https://github.com/imgui-rs/imgui-rs/issues/488 +static DRAW_LIST_LOADED_WINDOW: std::sync::atomic::AtomicBool = + std::sync::atomic::AtomicBool::new(false); +static DRAW_LIST_LOADED_BACKGROUND: std::sync::atomic::AtomicBool = + std::sync::atomic::AtomicBool::new(false); +static DRAW_LIST_LOADED_FOREGROUND: std::sync::atomic::AtomicBool = + std::sync::atomic::AtomicBool::new(false); + +impl<'ui> Drop for DrawListMut<'ui> { + fn drop(&mut self) { + match self.draw_list_type { + DrawListType::Window => &DRAW_LIST_LOADED_WINDOW, + DrawListType::Background => &DRAW_LIST_LOADED_BACKGROUND, + DrawListType::Foreground => &DRAW_LIST_LOADED_FOREGROUND, + } + .store(false, std::sync::atomic::Ordering::Release); + } +} + +impl<'ui> DrawListMut<'ui> { + fn lock_draw_list(t: DrawListType) { + let lock = match t { + DrawListType::Window => &DRAW_LIST_LOADED_WINDOW, + DrawListType::Background => &DRAW_LIST_LOADED_BACKGROUND, + DrawListType::Foreground => &DRAW_LIST_LOADED_FOREGROUND, + }; + + let already_loaded = lock + .compare_exchange( + false, + true, + std::sync::atomic::Ordering::Acquire, + std::sync::atomic::Ordering::Relaxed, + ) + .is_err(); + if already_loaded { + let name = match t { + DrawListType::Window => "window", + DrawListType::Background => "background", + DrawListType::Foreground => "foreground", + }; + panic!("The DrawListMut instance for the {} draw list is already loaded! You can only load one instance of it!", name) + } + } + + #[doc(alias = "GetWindowDrawList")] + pub(crate) fn window(_: &Ui<'ui>) -> Self { + Self::lock_draw_list(DrawListType::Window); + + Self { + draw_list: unsafe { sys::igGetWindowDrawList() }, + draw_list_type: DrawListType::Window, + _phantom: PhantomData, + } + } + + #[doc(alias = "GetBackgroundDrawList")] + pub(crate) fn background(_: &Ui<'ui>) -> Self { + Self::lock_draw_list(DrawListType::Background); + Self { + draw_list: unsafe { sys::igGetBackgroundDrawList() }, + draw_list_type: DrawListType::Background, + _phantom: PhantomData, + } + } + + #[doc(alias = "GetForegroundDrawList")] + pub(crate) fn foreground(_: &Ui<'ui>) -> Self { + Self::lock_draw_list(DrawListType::Foreground); + Self { + draw_list: unsafe { sys::igGetForegroundDrawList() }, + draw_list_type: DrawListType::Foreground, + _phantom: PhantomData, + } + } + + /// Split into *channels_count* drawing channels. + /// At the end of the closure, the channels are merged. The objects + /// are then drawn in the increasing order of their channel number, and not + /// in the order they were called. + /// + /// # Example + /// + /// ```rust,no_run + /// # use imgui::*; + /// fn custom_drawing(ui: &Ui) { + /// let draw_list = ui.get_window_draw_list(); + /// draw_list.channels_split(2, |channels| { + /// channels.set_current(1); + /// // ... Draw channel 1 + /// channels.set_current(0); + /// // ... Draw channel 0 + /// }); + /// } + /// ``` + #[doc(alias = "ChannelsSplit")] + pub fn channels_split)>(&self, channels_count: u32, f: F) { + unsafe { sys::ImDrawList_ChannelsSplit(self.draw_list, channels_count as i32) }; + f(&ChannelsSplit { + draw_list: self, + channels_count, + }); + unsafe { sys::ImDrawList_ChannelsMerge(self.draw_list) }; + } +} + +/// Represent the drawing interface within a call to [`channels_split`]. +/// +/// [`channels_split`]: DrawListMut::channels_split +pub struct ChannelsSplit<'ui> { + draw_list: &'ui DrawListMut<'ui>, + channels_count: u32, +} + +impl<'ui> ChannelsSplit<'ui> { + /// Change current channel. + /// + /// Panic if channel_index overflows the number of channels. + #[doc(alias = "ChannelsSetCurrent")] + pub fn set_current(&self, channel_index: u32) { + assert!( + channel_index < self.channels_count, + "Channel cannot be set! Provided channel index ({}) is higher than channel count ({}).", + channel_index, + self.channels_count + ); + unsafe { + sys::ImDrawList_ChannelsSetCurrent(self.draw_list.draw_list, channel_index as i32) + }; + } +} + +/// Drawing functions +impl<'ui> DrawListMut<'ui> { + /// Returns a line from point `p1` to `p2` with color `c`. + #[doc(alias = "AddLine")] + pub fn add_line(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Line<'ui> + where + C: Into, + { + Line::new(self, p1, p2, c) + } + + /// Returns a rectangle whose upper-left corner is at point `p1` + /// and lower-right corner is at point `p2`, with color `c`. + #[doc(alias = "AddRectFilled", alias = "AddRect")] + pub fn add_rect(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Rect<'ui> + where + C: Into, + { + Rect::new(self, p1, p2, c) + } + + /// Draw a rectangle whose upper-left corner is at point `p1` + /// and lower-right corner is at point `p2`. + /// The remains parameters are the respective color of the corners + /// in the counter-clockwise starting from the upper-left corner + /// first. + #[doc(alias = "AddRectFilledMultiColor")] + pub fn add_rect_filled_multicolor( + &self, + p1: [f32; 2], + p2: [f32; 2], + col_upr_left: C1, + col_upr_right: C2, + col_bot_right: C3, + col_bot_left: C4, + ) where + C1: Into, + C2: Into, + C3: Into, + C4: Into, + { + unsafe { + sys::ImDrawList_AddRectFilledMultiColor( + self.draw_list, + p1.into(), + p2.into(), + col_upr_left.into().into(), + col_upr_right.into().into(), + col_bot_right.into().into(), + col_bot_left.into().into(), + ); + } + } + + /// Returns a triangle with the given 3 vertices `p1`, `p2` and `p3` + /// and color `c`. + #[doc(alias = "AddTriangleFilled", alias = "AddTriangle")] + pub fn add_triangle( + &'ui self, + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + c: C, + ) -> Triangle<'ui> + where + C: Into, + { + Triangle::new(self, p1, p2, p3, c) + } + + /// Returns a circle with the given `center`, `radius` and `color`. + #[doc(alias = "AddCircleFilled", alias = "AddCircle")] + pub fn add_circle(&'ui self, center: [f32; 2], radius: f32, color: C) -> Circle<'ui> + where + C: Into, + { + Circle::new(self, center, radius, color) + } + + /// Draw a text whose upper-left corner is at point `pos`. + #[doc(alias = "AddText")] + pub fn add_text(&self, pos: [f32; 2], col: C, text: T) + where + C: Into, + T: AsRef, + { + use std::os::raw::c_char; + + let text = text.as_ref(); + unsafe { + let start = text.as_ptr() as *const c_char; + let end = (start as usize + text.len()) as *const c_char; + sys::ImDrawList_AddText_Vec2(self.draw_list, pos.into(), col.into().into(), start, end) + } + } + + /// Returns a Bezier curve stretching from `pos0` to `pos1`, whose + /// curvature is defined by `cp0` and `cp1`. + #[doc(alias = "AddBezier", alias = "AddBezierCubic")] + pub fn add_bezier_curve( + &'ui self, + pos0: [f32; 2], + cp0: [f32; 2], + cp1: [f32; 2], + pos1: [f32; 2], + color: C, + ) -> BezierCurve<'ui> + where + C: Into, + { + BezierCurve::new(self, pos0, cp0, cp1, pos1, color) + } + + /// Push a clipping rectangle on the stack, run `f` and pop it. + /// + /// Clip all drawings done within the closure `f` in the given + /// rectangle. + #[doc(alias = "PushClipRect", alias = "PopClipRect")] + pub fn with_clip_rect(&self, min: [f32; 2], max: [f32; 2], f: F) + where + F: FnOnce(), + { + unsafe { sys::ImDrawList_PushClipRect(self.draw_list, min.into(), max.into(), false) } + f(); + unsafe { sys::ImDrawList_PopClipRect(self.draw_list) } + } + + /// Push a clipping rectangle on the stack, run `f` and pop it. + /// + /// Clip all drawings done within the closure `f` in the given + /// rectangle. Intersect with all clipping rectangle previously on + /// the stack. + #[doc(alias = "PushClipRect", alias = "PopClipRect")] + pub fn with_clip_rect_intersect(&self, min: [f32; 2], max: [f32; 2], f: F) + where + F: FnOnce(), + { + unsafe { sys::ImDrawList_PushClipRect(self.draw_list, min.into(), max.into(), true) } + f(); + unsafe { sys::ImDrawList_PopClipRect(self.draw_list) } + } +} + +/// # Images +impl<'ui> DrawListMut<'ui> { + /// Draw the specified image in the rect specified by `p_min` to + /// `p_max`. + /// + /// # Examples + /// + /// ``` + /// # use imgui::*; + /// fn custom_button(ui: &Ui, img_id: TextureId) { + /// // Invisible button is good widget to customise with image + /// ui.invisible_button(im_str!("custom_button"), [100.0, 20.0]); + /// + /// // Get draw list and draw image over invisible button + /// let draw_list = ui.get_window_draw_list(); + /// draw_list + /// .add_image(img_id, ui.item_rect_min(), ui.item_rect_max()) + /// .build(); + /// } + /// ``` + pub fn add_image( + &'ui self, + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + ) -> Image<'_> { + Image::new(self, texture_id, p_min, p_max) + } + + /// Draw the specified image to a quad with the specified + /// coordinates. Similar to [`DrawListMut::add_image`] but this + /// method is able to draw non-rectangle images. + pub fn add_image_quad( + &'ui self, + texture_id: TextureId, + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + p4: [f32; 2], + ) -> ImageQuad<'_> { + ImageQuad::new(self, texture_id, p1, p2, p3, p4) + } + + /// Draw the speciied image, with rounded corners + pub fn add_image_rounded( + &'ui self, + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + rounding: f32, + ) -> ImageRounded<'_> { + ImageRounded::new(self, texture_id, p_min, p_max, rounding) + } +} + +/// Represents a line about to be drawn +#[must_use = "should call .build() to draw the object"] +pub struct Line<'ui> { + p1: [f32; 2], + p2: [f32; 2], + color: ImColor32, + thickness: f32, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> Line<'ui> { + fn new(draw_list: &'ui DrawListMut<'_>, p1: [f32; 2], p2: [f32; 2], c: C) -> Self + where + C: Into, + { + Self { + p1, + p2, + color: c.into(), + thickness: 1.0, + draw_list, + } + } + + /// Set line's thickness (default to 1.0 pixel) + pub fn thickness(mut self, thickness: f32) -> Self { + self.thickness = thickness; + self + } + + /// Draw the line on the window + pub fn build(self) { + unsafe { + sys::ImDrawList_AddLine( + self.draw_list.draw_list, + self.p1.into(), + self.p2.into(), + self.color.into(), + self.thickness, + ) + } + } +} + +/// Represents a rectangle about to be drawn +#[must_use = "should call .build() to draw the object"] +pub struct Rect<'ui> { + p1: [f32; 2], + p2: [f32; 2], + color: ImColor32, + rounding: f32, + flags: DrawFlags, + thickness: f32, + filled: bool, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> Rect<'ui> { + fn new(draw_list: &'ui DrawListMut<'_>, p1: [f32; 2], p2: [f32; 2], c: C) -> Self + where + C: Into, + { + Self { + p1, + p2, + color: c.into(), + rounding: 0.0, + flags: DrawFlags::ROUND_CORNERS_ALL, + thickness: 1.0, + filled: false, + draw_list, + } + } + + /// Set rectangle's corner rounding (default to 0.0: no rounding). + /// By default all corners are rounded if this value is set. + pub fn rounding(mut self, rounding: f32) -> Self { + self.rounding = rounding; + self + } + + /// Set flag to indicate if rectangle's top-left corner will be rounded. + pub fn round_top_left(mut self, value: bool) -> Self { + self.flags.set(DrawFlags::ROUND_CORNERS_TOP_LEFT, value); + self + } + + /// Set flag to indicate if rectangle's top-right corner will be rounded. + pub fn round_top_right(mut self, value: bool) -> Self { + self.flags.set(DrawFlags::ROUND_CORNERS_TOP_RIGHT, value); + self + } + + /// Set flag to indicate if rectangle's bottom-left corner will be rounded. + pub fn round_bot_left(mut self, value: bool) -> Self { + self.flags.set(DrawFlags::ROUND_CORNERS_BOT_LEFT, value); + self + } + + /// Set flag to indicate if rectangle's bottom-right corner will be rounded. + pub fn round_bot_right(mut self, value: bool) -> Self { + self.flags.set(DrawFlags::ROUND_CORNERS_BOT_RIGHT, value); + self + } + + /// Set rectangle's thickness (default to 1.0 pixel). + pub fn thickness(mut self, thickness: f32) -> Self { + self.thickness = thickness; + self + } + + /// Set to `true` to make a filled rectangle (default to `false`). + pub fn filled(mut self, filled: bool) -> Self { + self.filled = filled; + self + } + + /// Draw the rectangle on the window. + pub fn build(self) { + if self.filled { + unsafe { + sys::ImDrawList_AddRectFilled( + self.draw_list.draw_list, + self.p1.into(), + self.p2.into(), + self.color.into(), + self.rounding, + self.flags.bits() as i32, + ); + } + } else { + unsafe { + sys::ImDrawList_AddRect( + self.draw_list.draw_list, + self.p1.into(), + self.p2.into(), + self.color.into(), + self.rounding, + self.flags.bits() as i32, + self.thickness, + ); + } + } + } +} + +/// Represents a triangle about to be drawn on the window +#[must_use = "should call .build() to draw the object"] +pub struct Triangle<'ui> { + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + color: ImColor32, + thickness: f32, + filled: bool, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> Triangle<'ui> { + fn new( + draw_list: &'ui DrawListMut<'_>, + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + c: C, + ) -> Self + where + C: Into, + { + Self { + p1, + p2, + p3, + color: c.into(), + thickness: 1.0, + filled: false, + draw_list, + } + } + + /// Set triangle's thickness (default to 1.0 pixel) + pub fn thickness(mut self, thickness: f32) -> Self { + self.thickness = thickness; + self + } + + /// Set to `true` to make a filled triangle (default to `false`). + pub fn filled(mut self, filled: bool) -> Self { + self.filled = filled; + self + } + + /// Draw the triangle on the window. + pub fn build(self) { + if self.filled { + unsafe { + sys::ImDrawList_AddTriangleFilled( + self.draw_list.draw_list, + self.p1.into(), + self.p2.into(), + self.p3.into(), + self.color.into(), + ) + } + } else { + unsafe { + sys::ImDrawList_AddTriangle( + self.draw_list.draw_list, + self.p1.into(), + self.p2.into(), + self.p3.into(), + self.color.into(), + self.thickness, + ) + } + } + } +} + +/// Represents a circle about to be drawn +#[must_use = "should call .build() to draw the object"] +pub struct Circle<'ui> { + center: [f32; 2], + radius: f32, + color: ImColor32, + num_segments: u32, + thickness: f32, + filled: bool, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> Circle<'ui> { + /// Typically constructed by [`DrawListMut::add_circle`] + pub fn new(draw_list: &'ui DrawListMut<'_>, center: [f32; 2], radius: f32, color: C) -> Self + where + C: Into, + { + Self { + center, + radius, + color: color.into(), + num_segments: 0, + thickness: 1.0, + filled: false, + draw_list, + } + } + + /// Set number of segment used to draw the circle, default to 0. + /// Add more segments if you want a smoother circle. + pub fn num_segments(mut self, num_segments: u32) -> Self { + self.num_segments = num_segments; + self + } + + /// Set circle's thickness (default to 1.0 pixel) + pub fn thickness(mut self, thickness: f32) -> Self { + self.thickness = thickness; + self + } + + /// Set to `true` to make a filled circle (default to `false`). + pub fn filled(mut self, filled: bool) -> Self { + self.filled = filled; + self + } + + /// Draw the circle on the window. + pub fn build(self) { + if self.filled { + unsafe { + sys::ImDrawList_AddCircleFilled( + self.draw_list.draw_list, + self.center.into(), + self.radius, + self.color.into(), + self.num_segments as i32, + ) + } + } else { + unsafe { + sys::ImDrawList_AddCircle( + self.draw_list.draw_list, + self.center.into(), + self.radius, + self.color.into(), + self.num_segments as i32, + self.thickness, + ) + } + } + } +} + +/// Represents a Bezier curve about to be drawn +#[must_use = "should call .build() to draw the object"] +pub struct BezierCurve<'ui> { + pos0: [f32; 2], + cp0: [f32; 2], + pos1: [f32; 2], + cp1: [f32; 2], + color: ImColor32, + thickness: f32, + /// If num_segments is not set, the bezier curve is auto-tessalated. + num_segments: Option, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> BezierCurve<'ui> { + /// Typically constructed by [`DrawListMut::add_bezier_curve`] + pub fn new( + draw_list: &'ui DrawListMut<'_>, + pos0: [f32; 2], + cp0: [f32; 2], + cp1: [f32; 2], + pos1: [f32; 2], + c: C, + ) -> Self + where + C: Into, + { + Self { + pos0, + cp0, + cp1, + pos1, + color: c.into(), + thickness: 1.0, + num_segments: None, + draw_list, + } + } + + /// Set curve's thickness (default to 1.0 pixel) + pub fn thickness(mut self, thickness: f32) -> Self { + self.thickness = thickness; + self + } + + /// Set number of segments used to draw the Bezier curve. If not set, the + /// bezier curve is auto-tessalated. + pub fn num_segments(mut self, num_segments: u32) -> Self { + self.num_segments = Some(num_segments); + self + } + + /// Draw the curve on the window. + pub fn build(self) { + unsafe { + sys::ImDrawList_AddBezierCubic( + self.draw_list.draw_list, + self.pos0.into(), + self.cp0.into(), + self.cp1.into(), + self.pos1.into(), + self.color.into(), + self.thickness, + self.num_segments.unwrap_or(0) as i32, + ) + } + } +} + +/// Image draw list primitive, not to be confused with the widget +/// [`imgui::Image`](crate::Image). +#[must_use = "should call .build() to draw the object"] +pub struct Image<'ui> { + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + uv_min: [f32; 2], + uv_max: [f32; 2], + col: ImColor32, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> Image<'ui> { + /// Typically constructed by [`DrawListMut::add_image`] + pub fn new( + draw_list: &'ui DrawListMut<'_>, + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + ) -> Self { + Self { + texture_id, + p_min, + p_max, + uv_min: [0.0, 0.0], + uv_max: [1.0, 1.0], + col: [1.0, 1.0, 1.0, 1.0].into(), + draw_list, + } + } + + /// Set uv_min (default `[0.0, 0.0]`) + pub fn uv_min(mut self, uv_min: [f32; 2]) -> Self { + self.uv_min = uv_min; + self + } + /// Set uv_max (default `[1.0, 1.0]`) + pub fn uv_max(mut self, uv_max: [f32; 2]) -> Self { + self.uv_max = uv_max; + self + } + + /// Set color tint (default: no tint/white `[1.0, 1.0, 1.0, 1.0]`) + pub fn col(mut self, col: C) -> Self + where + C: Into, + { + self.col = col.into(); + self + } + + /// Draw the image on the window. + pub fn build(self) { + use std::os::raw::c_void; + + unsafe { + sys::ImDrawList_AddImage( + self.draw_list.draw_list, + self.texture_id.id() as *mut c_void, + self.p_min.into(), + self.p_max.into(), + self.uv_min.into(), + self.uv_max.into(), + self.col.into(), + ); + } + } +} + +/// Represents a image about to be drawn +#[must_use = "should call .build() to draw the object"] +pub struct ImageQuad<'ui> { + texture_id: TextureId, + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + p4: [f32; 2], + uv1: [f32; 2], + uv2: [f32; 2], + uv3: [f32; 2], + uv4: [f32; 2], + col: ImColor32, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> ImageQuad<'ui> { + /// Typically constructed by [`DrawListMut::add_image_quad`] + pub fn new( + draw_list: &'ui DrawListMut<'_>, + texture_id: TextureId, + p1: [f32; 2], + p2: [f32; 2], + p3: [f32; 2], + p4: [f32; 2], + ) -> Self { + Self { + texture_id, + p1, + p2, + p3, + p4, + uv1: [0.0, 0.0], + uv2: [1.0, 0.0], + uv3: [1.0, 1.0], + uv4: [0.0, 1.0], + col: [1.0, 1.0, 1.0, 1.0].into(), + draw_list, + } + } + + /// Set uv coordinates of each point of the quad. If not called, defaults are: + /// + /// ```text + /// uv1: [0.0, 0.0], + /// uv2: [1, 0], + /// uv3: [1, 1], + /// uv4: [0, 1], + /// ``` + pub fn uv(mut self, uv1: [f32; 2], uv2: [f32; 2], uv3: [f32; 2], uv4: [f32; 2]) -> Self { + self.uv1 = uv1; + self.uv2 = uv2; + self.uv3 = uv3; + self.uv4 = uv4; + self + } + + /// Set color tint (default: no tint/white `[1.0, 1.0, 1.0, 1.0]`) + pub fn col(mut self, col: C) -> Self + where + C: Into, + { + self.col = col.into(); + self + } + + /// Draw the image on the window. + pub fn build(self) { + use std::os::raw::c_void; + + unsafe { + sys::ImDrawList_AddImageQuad( + self.draw_list.draw_list, + self.texture_id.id() as *mut c_void, + self.p1.into(), + self.p2.into(), + self.p3.into(), + self.p4.into(), + self.uv1.into(), + self.uv2.into(), + self.uv3.into(), + self.uv4.into(), + self.col.into(), + ); + } + } +} + +/// Represents a image about to be drawn. Similar to [`Image`] but +/// with corners rounded with a given radius +#[must_use = "should call .build() to draw the object"] +pub struct ImageRounded<'ui> { + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + uv_min: [f32; 2], + uv_max: [f32; 2], + col: ImColor32, + rounding: f32, + draw_flags: DrawFlags, + draw_list: &'ui DrawListMut<'ui>, +} + +impl<'ui> ImageRounded<'ui> { + /// Typically constructed by [`DrawListMut::add_image_rounded`] + pub fn new( + draw_list: &'ui DrawListMut<'_>, + texture_id: TextureId, + p_min: [f32; 2], + p_max: [f32; 2], + rounding: f32, + ) -> Self { + Self { + texture_id, + p_min, + p_max, + uv_min: [0.0, 0.0], + uv_max: [1.0, 1.0], + col: [1.0, 1.0, 1.0, 1.0].into(), + rounding, + draw_flags: DrawFlags::ROUND_CORNERS_ALL, + draw_list, + } + } + + /// Set uv_min (default `[0.0, 0.0]`) + pub fn uv_min(mut self, uv_min: [f32; 2]) -> Self { + self.uv_min = uv_min; + self + } + /// Set uv_max (default `[1.0, 1.0]`) + pub fn uv_max(mut self, uv_max: [f32; 2]) -> Self { + self.uv_max = uv_max; + self + } + + /// Set color tint (default: no tint/white `[1.0, 1.0, 1.0, 1.0]`) + pub fn col(mut self, col: C) -> Self + where + C: Into, + { + self.col = col.into(); + self + } + + /// Set flag to indicate rounding on all all corners. + pub fn round_all(mut self, value: bool) -> Self { + self.draw_flags.set(DrawFlags::ROUND_CORNERS_ALL, value); + self + } + + /// Set flag to indicate if image's top-left corner will be rounded. + pub fn round_top_left(mut self, value: bool) -> Self { + self.draw_flags + .set(DrawFlags::ROUND_CORNERS_TOP_LEFT, value); + self + } + + /// Set flag to indicate if image's top-right corner will be rounded. + pub fn round_top_right(mut self, value: bool) -> Self { + self.draw_flags + .set(DrawFlags::ROUND_CORNERS_TOP_RIGHT, value); + self + } + + /// Set flag to indicate if image's bottom-left corner will be rounded. + pub fn round_bot_left(mut self, value: bool) -> Self { + self.draw_flags + .set(DrawFlags::ROUND_CORNERS_BOT_LEFT, value); + self + } + + /// Set flag to indicate if image's bottom-right corner will be rounded. + pub fn round_bot_right(mut self, value: bool) -> Self { + self.draw_flags + .set(DrawFlags::ROUND_CORNERS_BOT_RIGHT, value); + self + } + + /// Draw the image on the window. + pub fn build(self) { + use std::os::raw::c_void; + + unsafe { + sys::ImDrawList_AddImageRounded( + self.draw_list.draw_list, + self.texture_id.id() as *mut c_void, + self.p_min.into(), + self.p_max.into(), + self.uv_min.into(), + self.uv_max.into(), + self.col.into(), + self.rounding, + self.draw_flags.bits() as i32, + ); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/fonts/atlas.rs b/plugins/libimhex-rust/imgui-rs/src/fonts/atlas.rs new file mode 100644 index 000000000..708b4945e --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/fonts/atlas.rs @@ -0,0 +1,508 @@ +use bitflags::bitflags; +use std::cell; +use std::f32; +use std::ops::{Deref, DerefMut}; +use std::os::raw::{c_int, c_uchar, c_void}; +use std::ptr; +use std::slice; + +use crate::fonts::font::Font; +use crate::fonts::glyph_ranges::FontGlyphRanges; +use crate::internal::{ImVector, RawCast}; +use crate::sys; +use crate::TextureId; + +bitflags! { + /// Font atlas configuration flags + #[repr(transparent)] + pub struct FontAtlasFlags: u32 { + /// Don't round the height to next power of two + const NO_POWER_OF_TWO_HEIGHT = sys::ImFontAtlasFlags_NoPowerOfTwoHeight; + /// Don't build software mouse cursors into the atlas + const NO_MOUSE_CURSORS = sys::ImFontAtlasFlags_NoMouseCursors; + /// Don't build thick line textures into the atlas + const NO_BAKED_LINES = sys::ImFontAtlasFlags_NoBakedLines; + } +} + +/// A font identifier +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct FontId(pub(crate) *const Font); + +/// A font atlas that builds a single texture +#[repr(C)] +pub struct FontAtlas { + /// Configuration flags + pub flags: FontAtlasFlags, + /// Texture identifier + pub tex_id: TextureId, + /// Texture width desired by user before building the atlas. + /// + /// Must be a power-of-two. If you have many glyphs and your graphics API has texture size + /// restrictions, you may want to increase texture width to decrease the height. + pub tex_desired_width: i32, + /// Padding between glyphs within texture in pixels. + /// + /// Defaults to 1. If your rendering method doesn't rely on bilinear filtering, you may set + /// this to 0. + pub tex_glyph_padding: i32, + + locked: bool, + text_ready: bool, + tex_pixels_use_colors: bool, + tex_pixels_alpha8: *mut u8, + tex_pixels_rgba32: *mut u32, + tex_width: i32, + tex_height: i32, + tex_uv_scale: [f32; 2], + tex_uv_white_pixel: [f32; 2], + fonts: ImVector<*mut Font>, + custom_rects: sys::ImVector_ImFontAtlasCustomRect, + config_data: sys::ImVector_ImFontConfig, + tex_uv_lines: [[f32; 4]; 64], + font_builder_io: *const sys::ImFontBuilderIO, + font_builder_flags: i32, + pack_id_mouse_cursors: i32, + pack_id_lines: i32, +} + +unsafe impl RawCast for FontAtlas {} + +impl FontAtlas { + #[doc(alias = "AddFontDefault", alias = "AddFont")] + pub fn add_font(&mut self, font_sources: &[FontSource<'_>]) -> FontId { + let (head, tail) = font_sources.split_first().unwrap(); + let font_id = self.add_font_internal(head, false); + for font in tail { + self.add_font_internal(font, true); + } + font_id + } + fn add_font_internal(&mut self, font_source: &FontSource<'_>, merge_mode: bool) -> FontId { + let mut raw_config = sys_font_config_default(); + raw_config.MergeMode = merge_mode; + let raw_font = match font_source { + FontSource::DefaultFontData { config } => unsafe { + if let Some(config) = config { + config.apply_to_raw_config(&mut raw_config, self.raw_mut()); + } + sys::ImFontAtlas_AddFontDefault(self.raw_mut(), &raw_config) + }, + FontSource::TtfData { + data, + size_pixels, + config, + } => { + if let Some(config) = config { + unsafe { + config.apply_to_raw_config(&mut raw_config, self.raw_mut()); + } + } + // We can't guarantee `data` is alive when the font atlas is built, so + // make a copy and move ownership of the data to the atlas + let data_copy = unsafe { + let ptr = sys::igMemAlloc(data.len()) as *mut u8; + assert!(!ptr.is_null()); + slice::from_raw_parts_mut(ptr, data.len()) + }; + data_copy.copy_from_slice(data); + raw_config.FontData = data_copy.as_mut_ptr() as *mut c_void; + raw_config.FontDataSize = data_copy.len() as i32; + raw_config.FontDataOwnedByAtlas = true; + raw_config.SizePixels = *size_pixels; + unsafe { sys::ImFontAtlas_AddFont(self.raw_mut(), &raw_config) } + } + }; + FontId(raw_font as *const _) + } + pub fn fonts(&self) -> Vec { + let mut result = Vec::new(); + unsafe { + for &font in self.fonts.as_slice() { + result.push((*font).id()); + } + } + result + } + pub fn get_font(&self, id: FontId) -> Option<&Font> { + unsafe { + for &font in self.fonts.as_slice() { + if id == FontId(font) { + return Some(&*(font as *const Font)); + } + } + } + None + } + /// Returns true if the font atlas has been built + #[doc(alias = "IsBuilt")] + pub fn is_built(&self) -> bool { + unsafe { sys::ImFontAtlas_IsBuilt(self.raw() as *const sys::ImFontAtlas as *mut _) } + } + /// Builds a 1 byte per-pixel font atlas texture + #[doc(alias = "GetTextDataAsAlpha8")] + pub fn build_alpha8_texture(&mut self) -> FontAtlasTexture<'_> { + let mut pixels: *mut c_uchar = ptr::null_mut(); + let mut width: c_int = 0; + let mut height: c_int = 0; + let mut bytes_per_pixel: c_int = 0; + unsafe { + sys::ImFontAtlas_GetTexDataAsAlpha8( + self.raw_mut(), + &mut pixels, + &mut width, + &mut height, + &mut bytes_per_pixel, + ); + assert!(width >= 0, "font texture width must be positive"); + assert!(height >= 0, "font texture height must be positive"); + assert!( + bytes_per_pixel >= 0, + "font texture bytes per pixel must be positive" + ); + let height = height as usize; + // Check multiplication to avoid constructing an invalid slice in case of overflow + let pitch = width + .checked_mul(bytes_per_pixel) + .expect("Overflow in font texture pitch calculation") + as usize; + FontAtlasTexture { + width: width as u32, + height: height as u32, + data: slice::from_raw_parts(pixels, pitch * height), + } + } + } + /// Builds a 4 byte per-pixel font atlas texture + #[doc(alias = "GetTextDataAsRGBA32")] + pub fn build_rgba32_texture(&mut self) -> FontAtlasTexture<'_> { + let mut pixels: *mut c_uchar = ptr::null_mut(); + let mut width: c_int = 0; + let mut height: c_int = 0; + let mut bytes_per_pixel: c_int = 0; + unsafe { + sys::ImFontAtlas_GetTexDataAsRGBA32( + self.raw_mut(), + &mut pixels, + &mut width, + &mut height, + &mut bytes_per_pixel, + ); + assert!(width >= 0, "font texture width must be positive"); + assert!(height >= 0, "font texture height must be positive"); + assert!( + bytes_per_pixel >= 0, + "font texture bytes per pixel must be positive" + ); + let height = height as usize; + // Check multiplication to avoid constructing an invalid slice in case of overflow + let pitch = width + .checked_mul(bytes_per_pixel) + .expect("Overflow in font texture pitch calculation") + as usize; + FontAtlasTexture { + width: width as u32, + height: height as u32, + data: slice::from_raw_parts(pixels, pitch * height), + } + } + } + /// Clears the font atlas completely (both input and output data) + #[doc(alias = "Clear")] + pub fn clear(&mut self) { + unsafe { + sys::ImFontAtlas_Clear(self.raw_mut()); + } + } + /// Clears output font data (glyph storage, UV coordinates) + #[doc(alias = "ClearFonts")] + pub fn clear_fonts(&mut self) { + unsafe { + sys::ImFontAtlas_ClearFonts(self.raw_mut()); + } + } + /// Clears output texture data. + /// + /// Can be used to save RAM once the texture has been transferred to the GPU. + #[doc(alias = "ClearTexData")] + pub fn clear_tex_data(&mut self) { + unsafe { + sys::ImFontAtlas_ClearTexData(self.raw_mut()); + } + } + /// Clears all the data used to build the textures and fonts + #[doc(alias = "ClearInputData")] + pub fn clear_input_data(&mut self) { + unsafe { + sys::ImFontAtlas_ClearInputData(self.raw_mut()); + } + } +} + +#[test] +#[cfg(test)] +fn test_font_atlas_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::(), + mem::align_of::() + ); + use sys::ImFontAtlas; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(FontAtlas, $l), + memoffset::offset_of!(ImFontAtlas, $r) + ); + }; + } + assert_field_offset!(locked, Locked); + assert_field_offset!(flags, Flags); + assert_field_offset!(tex_id, TexID); + assert_field_offset!(tex_desired_width, TexDesiredWidth); + assert_field_offset!(tex_glyph_padding, TexGlyphPadding); + assert_field_offset!(tex_pixels_use_colors, TexPixelsUseColors); + assert_field_offset!(tex_pixels_alpha8, TexPixelsAlpha8); + assert_field_offset!(tex_pixels_rgba32, TexPixelsRGBA32); + assert_field_offset!(tex_width, TexWidth); + assert_field_offset!(tex_height, TexHeight); + assert_field_offset!(tex_uv_scale, TexUvScale); + assert_field_offset!(tex_uv_white_pixel, TexUvWhitePixel); + assert_field_offset!(fonts, Fonts); + assert_field_offset!(custom_rects, CustomRects); + assert_field_offset!(config_data, ConfigData); + assert_field_offset!(tex_uv_lines, TexUvLines); + assert_field_offset!(pack_id_mouse_cursors, PackIdMouseCursors); + assert_field_offset!(pack_id_lines, PackIdLines); +} + +/// A source for binary font data +#[derive(Clone, Debug)] +pub enum FontSource<'a> { + /// Default font included with the library (ProggyClean.ttf) + DefaultFontData { config: Option }, + /// Binary TTF/OTF font data + TtfData { + data: &'a [u8], + size_pixels: f32, + config: Option, + }, +} + +/// Configuration settings for a font +#[derive(Clone, Debug)] +pub struct FontConfig { + /// Size in pixels for the rasterizer + pub size_pixels: f32, + /// Horizontal oversampling + pub oversample_h: i32, + /// Vertical oversampling + pub oversample_v: i32, + /// Align every glyph to pixel boundary + pub pixel_snap_h: bool, + /// Extra spacing (in pixels) between glyphs + pub glyph_extra_spacing: [f32; 2], + /// Offset for all glyphs in this font + pub glyph_offset: [f32; 2], + /// Unicode ranges to use from this font + pub glyph_ranges: FontGlyphRanges, + /// Minimum advance_x for glyphs + pub glyph_min_advance_x: f32, + /// Maximum advance_x for glyphs + pub glyph_max_advance_x: f32, + /// Settings for a custom font rasterizer if used + pub font_builder_flags: u32, + /// Brighten (>1.0) or darken (<1.0) font output + pub rasterizer_multiply: f32, + /// Explicitly specify the ellipsis character. + /// + /// With multiple font sources the first specified ellipsis is used. + pub ellipsis_char: Option, + pub name: Option, +} + +impl Default for FontConfig { + fn default() -> FontConfig { + FontConfig { + size_pixels: 0.0, + oversample_h: 3, + oversample_v: 1, + pixel_snap_h: false, + glyph_extra_spacing: [0.0, 0.0], + glyph_offset: [0.0, 0.0], + glyph_ranges: FontGlyphRanges::default(), + glyph_min_advance_x: 0.0, + glyph_max_advance_x: f32::MAX, + font_builder_flags: 0, + rasterizer_multiply: 1.0, + ellipsis_char: None, + name: None, + } + } +} + +impl FontConfig { + fn apply_to_raw_config(&self, raw: &mut sys::ImFontConfig, atlas: *mut sys::ImFontAtlas) { + raw.SizePixels = self.size_pixels; + raw.OversampleH = self.oversample_h; + raw.OversampleV = self.oversample_v; + raw.PixelSnapH = self.pixel_snap_h; + raw.GlyphExtraSpacing = self.glyph_extra_spacing.into(); + raw.GlyphOffset = self.glyph_offset.into(); + raw.GlyphRanges = unsafe { self.glyph_ranges.to_ptr(atlas) }; + raw.GlyphMinAdvanceX = self.glyph_min_advance_x; + raw.GlyphMaxAdvanceX = self.glyph_max_advance_x; + raw.FontBuilderFlags = self.font_builder_flags; + raw.RasterizerMultiply = self.rasterizer_multiply; + // char is used as "unset" for EllipsisChar + raw.EllipsisChar = self.ellipsis_char.map(|c| c as u32).unwrap_or(!0); + if let Some(name) = self.name.as_ref() { + let bytes = name.as_bytes(); + let mut len = bytes.len().min(raw.Name.len() - 1); + while !name.is_char_boundary(len) { + len -= 1; + } + unsafe { + bytes.as_ptr().copy_to(raw.Name.as_mut_ptr() as _, len); + raw.Name[len] = 0; + } + } + } +} + +fn sys_font_config_default() -> sys::ImFontConfig { + unsafe { + let heap_allocated = sys::ImFontConfig_ImFontConfig(); + let copy = *heap_allocated; + sys::ImFontConfig_destroy(heap_allocated); + copy + } +} + +#[test] +fn test_font_config_default() { + let sys_font_config = sys_font_config_default(); + let font_config = FontConfig::default(); + assert_eq!(font_config.size_pixels, sys_font_config.SizePixels); + assert_eq!(font_config.oversample_h, sys_font_config.OversampleH); + assert_eq!(font_config.oversample_v, sys_font_config.OversampleV); + assert_eq!(font_config.pixel_snap_h, sys_font_config.PixelSnapH); + assert_eq!( + font_config.glyph_extra_spacing[0], + sys_font_config.GlyphExtraSpacing.x + ); + assert_eq!( + font_config.glyph_extra_spacing[1], + sys_font_config.GlyphExtraSpacing.y + ); + assert_eq!(font_config.glyph_offset[0], sys_font_config.GlyphOffset.x); + assert_eq!(font_config.glyph_offset[1], sys_font_config.GlyphOffset.y); + assert_eq!( + font_config.glyph_min_advance_x, + sys_font_config.GlyphMinAdvanceX + ); + assert_eq!( + font_config.glyph_max_advance_x, + sys_font_config.GlyphMaxAdvanceX + ); + assert_eq!( + font_config.font_builder_flags, + sys_font_config.FontBuilderFlags + ); + assert_eq!( + font_config.rasterizer_multiply, + sys_font_config.RasterizerMultiply + ); +} + +/// Handle to a font atlas texture +#[derive(Clone, Debug)] +pub struct FontAtlasTexture<'a> { + /// Texture width (in pixels) + pub width: u32, + /// Texture height (in pixels) + pub height: u32, + /// Raw texture data (in bytes). + /// + /// The format depends on which function was called to obtain this data. + pub data: &'a [u8], +} + +/// A font atlas that can be shared between contexts +#[derive(Debug)] +pub struct SharedFontAtlas(pub(crate) *mut sys::ImFontAtlas); + +impl SharedFontAtlas { + #[doc(alias = "ImFontAtlas", alias = "ImFontAtlas::ImFontAtlas")] + pub fn create() -> SharedFontAtlas { + SharedFontAtlas(unsafe { sys::ImFontAtlas_ImFontAtlas() }) + } +} + +impl Drop for SharedFontAtlas { + #[doc(alias = "ImFontAtlas::Destory")] + fn drop(&mut self) { + unsafe { sys::ImFontAtlas_destroy(self.0) }; + } +} + +impl Deref for SharedFontAtlas { + type Target = FontAtlas; + fn deref(&self) -> &FontAtlas { + unsafe { &*(self.0 as *const FontAtlas) } + } +} + +impl DerefMut for SharedFontAtlas { + fn deref_mut(&mut self) -> &mut FontAtlas { + unsafe { &mut *(self.0 as *mut FontAtlas) } + } +} + +/// An immutably borrowed reference to a (possibly shared) font atlas +pub enum FontAtlasRef<'a> { + Owned(&'a FontAtlas), + Shared(&'a cell::RefMut<'a, SharedFontAtlas>), +} + +impl<'a> Deref for FontAtlasRef<'a> { + type Target = FontAtlas; + fn deref(&self) -> &FontAtlas { + use self::FontAtlasRef::*; + match self { + Owned(atlas) => atlas, + Shared(cell) => cell, + } + } +} + +/// A mutably borrowed reference to a (possibly shared) font atlas +pub enum FontAtlasRefMut<'a> { + Owned(&'a mut FontAtlas), + Shared(cell::RefMut<'a, SharedFontAtlas>), +} + +impl<'a> Deref for FontAtlasRefMut<'a> { + type Target = FontAtlas; + fn deref(&self) -> &FontAtlas { + use self::FontAtlasRefMut::*; + match self { + Owned(atlas) => atlas, + Shared(cell) => cell, + } + } +} + +impl<'a> DerefMut for FontAtlasRefMut<'a> { + fn deref_mut(&mut self) -> &mut FontAtlas { + use self::FontAtlasRefMut::*; + match self { + Owned(atlas) => atlas, + Shared(cell) => cell, + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/fonts/font.rs b/plugins/libimhex-rust/imgui-rs/src/fonts/font.rs new file mode 100644 index 000000000..66e8ab202 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/fonts/font.rs @@ -0,0 +1,71 @@ +use std::os::raw::c_int; + +use crate::fonts::atlas::{FontAtlas, FontId}; +use crate::fonts::glyph::FontGlyph; +use crate::internal::{ImVector, RawCast}; +use crate::sys; + +/// Runtime data for a single font within a font atlas +#[repr(C)] +pub struct Font { + index_advance_x: ImVector, + pub fallback_advance_x: f32, + pub font_size: f32, + index_lookup: ImVector, + glyphs: ImVector, + fallback_glyph: *const FontGlyph, + container_atlas: *mut FontAtlas, + config_data: *const sys::ImFontConfig, + pub config_data_count: i16, + pub fallback_char: sys::ImWchar, + pub ellipsis_char: sys::ImWchar, + pub dot_char: sys::ImWchar, + pub dirty_lookup_tables: bool, + pub scale: f32, + pub ascent: f32, + pub descent: f32, + pub metrics_total_surface: c_int, + pub used_4k_pages_map: [u8; 34], +} + +unsafe impl RawCast for Font {} + +impl Font { + /// Returns the identifier of this font + pub fn id(&self) -> FontId { + FontId(self as *const _) + } +} + +#[test] +fn test_font_memory_layout() { + use std::mem; + assert_eq!(mem::size_of::(), mem::size_of::()); + assert_eq!(mem::align_of::(), mem::align_of::()); + use sys::ImFont; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(Font, $l), + memoffset::offset_of!(ImFont, $r) + ); + }; + } + assert_field_offset!(index_advance_x, IndexAdvanceX); + assert_field_offset!(fallback_advance_x, FallbackAdvanceX); + assert_field_offset!(font_size, FontSize); + assert_field_offset!(index_lookup, IndexLookup); + assert_field_offset!(glyphs, Glyphs); + assert_field_offset!(fallback_glyph, FallbackGlyph); + assert_field_offset!(container_atlas, ContainerAtlas); + assert_field_offset!(config_data, ConfigData); + assert_field_offset!(config_data_count, ConfigDataCount); + assert_field_offset!(fallback_char, FallbackChar); + assert_field_offset!(ellipsis_char, EllipsisChar); + assert_field_offset!(dirty_lookup_tables, DirtyLookupTables); + assert_field_offset!(scale, Scale); + assert_field_offset!(ascent, Ascent); + assert_field_offset!(descent, Descent); + assert_field_offset!(metrics_total_surface, MetricsTotalSurface); + assert_field_offset!(used_4k_pages_map, Used4kPagesMap); +} diff --git a/plugins/libimhex-rust/imgui-rs/src/fonts/glyph.rs b/plugins/libimhex-rust/imgui-rs/src/fonts/glyph.rs new file mode 100644 index 000000000..e99525a6c --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/fonts/glyph.rs @@ -0,0 +1,67 @@ +use crate::internal::RawCast; +use crate::sys; + +/// A single font glyph +#[derive(Copy, Clone, Debug, PartialEq)] +#[repr(C)] +pub struct FontGlyph { + bitfields: u32, + pub advance_x: f32, + pub x0: f32, + pub y0: f32, + pub x1: f32, + pub y1: f32, + pub u0: f32, + pub v0: f32, + pub u1: f32, + pub v1: f32, +} + +impl FontGlyph { + pub fn codepoint(&self) -> u32 { + unsafe { self.raw().Codepoint() } + } + pub fn set_codepoint(&mut self, codepoint: u32) { + unsafe { self.raw_mut().set_Codepoint(codepoint) }; + } + pub fn visible(&self) -> bool { + unsafe { self.raw().Visible() != 0 } + } + pub fn set_visible(&mut self, visible: bool) { + unsafe { self.raw_mut().set_Visible(visible as u32) } + } +} + +unsafe impl RawCast for FontGlyph {} + +#[test] +fn test_font_glyph_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::(), + mem::align_of::() + ); + use sys::ImFontGlyph; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(FontGlyph, $l), + memoffset::offset_of!(ImFontGlyph, $r) + ); + }; + } + assert_field_offset!(bitfields, _bitfield_1); + assert_field_offset!(advance_x, AdvanceX); + assert_field_offset!(x0, X0); + assert_field_offset!(y0, Y0); + assert_field_offset!(x1, X1); + assert_field_offset!(y1, Y1); + assert_field_offset!(u0, U0); + assert_field_offset!(v0, V0); + assert_field_offset!(u1, U1); + assert_field_offset!(v1, V1); +} diff --git a/plugins/libimhex-rust/imgui-rs/src/fonts/glyph_ranges.rs b/plugins/libimhex-rust/imgui-rs/src/fonts/glyph_ranges.rs new file mode 100644 index 000000000..b22ae5067 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/fonts/glyph_ranges.rs @@ -0,0 +1,164 @@ +use crate::sys; + +#[derive(Clone, Eq, PartialEq, Debug)] +enum FontGlyphRangeData { + ChineseSimplifiedCommon, + ChineseFull, + Cyrillic, + Default, + Japanese, + Korean, + Thai, + Vietnamese, + Custom(*const sys::ImWchar), +} + +/// A set of Unicode codepoints +#[derive(Clone, Eq, PartialEq, Debug)] +pub struct FontGlyphRanges(FontGlyphRangeData); +impl FontGlyphRanges { + /// The default set of glyph ranges used by imgui. + pub fn default() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Default) + } + /// A set of glyph ranges appropriate for use with simplified common Chinese text. + pub fn chinese_simplified_common() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::ChineseSimplifiedCommon) + } + /// A set of glyph ranges appropriate for use with Chinese text. + pub fn chinese_full() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::ChineseFull) + } + /// A set of glyph ranges appropriate for use with Cyrillic text. + pub fn cyrillic() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Cyrillic) + } + /// A set of glyph ranges appropriate for use with Japanese text. + pub fn japanese() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Japanese) + } + /// A set of glyph ranges appropriate for use with Korean text. + pub fn korean() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Korean) + } + /// A set of glyph ranges appropriate for use with Thai text. + pub fn thai() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Thai) + } + /// A set of glyph ranges appropriate for use with Vietnamese text. + pub fn vietnamese() -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Vietnamese) + } + + /// Creates a glyph range from a static slice. The expected format is a series of pairs of + /// non-zero codepoints, each representing an inclusive range, followed by a single + /// zero terminating the range. The ranges must not overlap. + /// + /// As the slice is expected to last as long as a font is used, and is written into global + /// state, it must be `'static`. + /// + /// Panics + /// ====== + /// + /// This function will panic if the given slice is not a valid font range. + // TODO(thom): This takes `u32` for now, since I believe it's fine for it to + // contain surrogates? (It seems plausible that font data can describe what + // to show for unpaired surrogates) Would be nice to be sure, if so, this + // should accept `char` (we'd still have to check that the range doesn't + // fully contain the surrogate range though) + pub fn from_slice(slice: &'static [u32]) -> FontGlyphRanges { + assert_eq!( + slice.len() % 2, + 1, + "The length of a glyph range must be odd." + ); + assert_eq!( + slice.last(), + Some(&0), + "A glyph range must be zero-terminated." + ); + + for (i, &glyph) in slice.iter().enumerate().take(slice.len() - 1) { + assert_ne!( + glyph, 0, + "A glyph in a range cannot be zero. \ + (Glyph is zero at index {})", + i + ); + assert!( + glyph <= core::char::MAX as u32, + "A glyph in a range cannot exceed the maximum codepoint. \ + (Glyph is {:#x} at index {})", + glyph, + i, + ); + } + + let mut ranges = Vec::new(); + for i in 0..slice.len() / 2 { + let (start, end) = (slice[i * 2], slice[i * 2 + 1]); + assert!( + start <= end, + "The start of a range cannot be larger than its end. \ + (At index {}, {} > {})", + i * 2, + start, + end + ); + ranges.push((start, end)); + } + ranges.sort_unstable_by_key(|x| x.0); + for i in 0..ranges.len() - 1 { + let (range_a, range_b) = (ranges[i], ranges[i + 1]); + if range_a.1 >= range_b.0 { + panic!( + "The glyph ranges {:?} and {:?} overlap between {:?}.", + range_a, + range_b, + (range_a.1, range_b.0) + ); + } + } + + unsafe { FontGlyphRanges::from_slice_unchecked(slice) } + } + + /// Creates a glyph range from a static slice without checking its validity. + /// + /// See [`FontGlyphRanges::from_slice`] for more information. + /// + /// # Safety + /// + /// It is up to the caller to guarantee the slice contents are valid. + pub unsafe fn from_slice_unchecked(slice: &'static [u32]) -> FontGlyphRanges { + FontGlyphRanges::from_ptr(slice.as_ptr()) + } + + /// Creates a glyph range from a pointer, without checking its validity or enforcing its + /// lifetime. The memory the pointer points to must be valid for as long as the font is + /// in use. + /// + /// # Safety + /// + /// It is up to the caller to guarantee the pointer is not null, remains valid forever, and + /// points to valid data. + pub unsafe fn from_ptr(ptr: *const u32) -> FontGlyphRanges { + FontGlyphRanges(FontGlyphRangeData::Custom(ptr)) + } + + pub(crate) unsafe fn to_ptr(&self, atlas: *mut sys::ImFontAtlas) -> *const sys::ImWchar { + match self.0 { + 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), + FontGlyphRangeData::Korean => sys::ImFontAtlas_GetGlyphRangesKorean(atlas), + FontGlyphRangeData::Thai => sys::ImFontAtlas_GetGlyphRangesThai(atlas), + FontGlyphRangeData::Vietnamese => sys::ImFontAtlas_GetGlyphRangesVietnamese(atlas), + FontGlyphRangeData::Custom(ptr) => ptr, + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/fonts/mod.rs b/plugins/libimhex-rust/imgui-rs/src/fonts/mod.rs new file mode 100644 index 000000000..3f69efe27 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/fonts/mod.rs @@ -0,0 +1,36 @@ +use crate::fonts::font::Font; +use crate::internal::RawCast; +use crate::Ui; + +pub mod atlas; +pub mod font; +pub mod glyph; +pub mod glyph_ranges; + +/// # Fonts +impl<'ui> Ui<'ui> { + /// Returns the current font + #[doc(alias = "GetFont")] + pub fn current_font(&self) -> &Font { + unsafe { Font::from_raw(&*sys::igGetFont()) } + } + /// Returns the current font size (= height in pixels) with font scale applied + #[doc(alias = "GetFontSize")] + pub fn current_font_size(&self) -> f32 { + unsafe { sys::igGetFontSize() } + } + /// Returns the UV coordinate for a white pixel. + /// + /// Useful for drawing custom shapes with the draw list API. + #[doc(alias = "FontTexUvWhitePixel")] + pub fn font_tex_uv_white_pixel(&self) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetFontTexUvWhitePixel(&mut out) }; + out.into() + } + /// Sets the font scale of the current window + #[doc(alias = "SetWindowFontScale")] + pub fn set_window_font_scale(&self, scale: f32) { + unsafe { sys::igSetWindowFontScale(scale) } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/input/keyboard.rs b/plugins/libimhex-rust/imgui-rs/src/input/keyboard.rs new file mode 100644 index 000000000..bab12f406 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/input/keyboard.rs @@ -0,0 +1,215 @@ +use crate::sys; +use crate::Ui; + +/// A key identifier +#[repr(u32)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +pub enum Key { + Tab = sys::ImGuiKey_Tab, + LeftArrow = sys::ImGuiKey_LeftArrow, + RightArrow = sys::ImGuiKey_RightArrow, + UpArrow = sys::ImGuiKey_UpArrow, + DownArrow = sys::ImGuiKey_DownArrow, + PageUp = sys::ImGuiKey_PageUp, + PageDown = sys::ImGuiKey_PageDown, + Home = sys::ImGuiKey_Home, + End = sys::ImGuiKey_End, + Insert = sys::ImGuiKey_Insert, + Delete = sys::ImGuiKey_Delete, + Backspace = sys::ImGuiKey_Backspace, + Space = sys::ImGuiKey_Space, + Enter = sys::ImGuiKey_Enter, + Escape = sys::ImGuiKey_Escape, + KeyPadEnter = sys::ImGuiKey_KeyPadEnter, + A = sys::ImGuiKey_A, + C = sys::ImGuiKey_C, + V = sys::ImGuiKey_V, + X = sys::ImGuiKey_X, + Y = sys::ImGuiKey_Y, + Z = sys::ImGuiKey_Z, +} + +impl Key { + /// All possible `Key` variants + pub const VARIANTS: [Key; Key::COUNT] = [ + Key::Tab, + Key::LeftArrow, + Key::RightArrow, + Key::UpArrow, + Key::DownArrow, + Key::PageUp, + Key::PageDown, + Key::Home, + Key::End, + Key::Insert, + Key::Delete, + Key::Backspace, + Key::Space, + Key::Enter, + Key::Escape, + Key::KeyPadEnter, + Key::A, + Key::C, + Key::V, + Key::X, + Key::Y, + Key::Z, + ]; + /// Total count of `Key` variants + pub const COUNT: usize = sys::ImGuiKey_COUNT as usize; +} + +#[test] +fn test_key_variants() { + for (idx, &value) in Key::VARIANTS.iter().enumerate() { + assert_eq!(idx, value as usize); + } +} + +/// Target widget selection for keyboard focus +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +pub enum FocusedWidget { + /// Previous widget + Previous, + /// Next widget + Next, + /// Widget using a relative positive offset (0 is the next widget). + /// + /// Use this to access sub components of a multiple component widget. + Offset(u32), +} + +impl FocusedWidget { + #[inline] + fn as_offset(self) -> i32 { + match self { + FocusedWidget::Previous => -1, + FocusedWidget::Next => 0, + FocusedWidget::Offset(offset) => offset as i32, + } + } +} + +/// # Input: Keyboard +impl<'ui> Ui<'ui> { + /// Returns the key index of the given key identifier. + /// + /// Equivalent to indexing the Io struct `key_map` field: `ui.io().key_map[key]` + #[inline] + #[doc(alias = "GetKeyIndex")] + fn key_index(&self, key: Key) -> i32 { + unsafe { sys::igGetKeyIndex(key as i32) } + } + /// Returns true if the key is being held. + /// + /// Equivalent to indexing the Io struct `keys_down` field: `ui.io().keys_down[key_index]` + #[inline] + #[doc(alias = "IsKeyDown")] + pub fn is_key_down(&self, key: Key) -> bool { + let key_index = self.key_index(key); + self.is_key_index_down(key_index) + } + + /// Same as [`is_key_down`](Self::is_key_down) but takes a key index. The meaning of + /// index is defined by your backend implementation. + #[inline] + #[doc(alias = "IsKeyDown")] + pub fn is_key_index_down(&self, key_index: i32) -> bool { + unsafe { sys::igIsKeyDown(key_index) } + } + + /// Returns true if the key was pressed (went from !down to down). + /// + /// Affected by key repeat settings (`io.key_repeat_delay`, `io.key_repeat_rate`) + #[inline] + #[doc(alias = "IsKeyPressed")] + pub fn is_key_pressed(&self, key: Key) -> bool { + let key_index = self.key_index(key); + self.is_key_index_pressed(key_index) + } + + /// Same as [`is_key_pressed`](Self::is_key_pressed) but takes a key index. + /// + /// The meaning of index is defined by your backend + /// implementation. + #[inline] + #[doc(alias = "IsKeyPressed")] + pub fn is_key_index_pressed(&self, key_index: i32) -> bool { + unsafe { sys::igIsKeyPressed(key_index, true) } + } + + /// Returns true if the key was pressed (went from !down to down). + /// + /// Is **not** affected by key repeat settings (`io.key_repeat_delay`, `io.key_repeat_rate`) + #[inline] + #[doc(alias = "IsKeyPressed")] + pub fn is_key_pressed_no_repeat(&self, key: Key) -> bool { + let key_index = self.key_index(key); + self.is_key_index_pressed_no_repeat(key_index) + } + + /// Same as [`is_key_pressed_no_repeat`](Self::is_key_pressed_no_repeat) + /// but takes a key index. + /// + /// The meaning of index is defined by your backend + /// implementation. + #[inline] + #[doc(alias = "IsKeyPressed")] + pub fn is_key_index_pressed_no_repeat(&self, key_index: i32) -> bool { + unsafe { sys::igIsKeyPressed(key_index, false) } + } + + /// Returns true if the key was released (went from down to !down) + #[inline] + #[doc(alias = "IsKeyReleased")] + pub fn is_key_released(&self, key: Key) -> bool { + let key_index = self.key_index(key); + self.is_key_index_released(key_index) + } + + /// Same as [`is_key_released`](Self::is_key_released) but takes a key index. + /// + /// The meaning of index is defined by your backend + /// implementation. + #[inline] + #[doc(alias = "IsKeyReleased")] + pub fn is_key_index_released(&self, key_index: i32) -> bool { + unsafe { sys::igIsKeyReleased(key_index) } + } + + /// Returns a count of key presses using the given repeat rate/delay settings. + /// + /// Usually returns 0 or 1, but might be >1 if `rate` is small enough that `io.delta_time` > + /// `rate`. + #[inline] + #[doc(alias = "GetKeyPressedAmount")] + pub fn key_pressed_amount(&self, key: Key, repeat_delay: f32, rate: f32) -> u32 { + let key_index = self.key_index(key); + self.key_index_pressed_amount(key_index, repeat_delay, rate) + } + + #[inline] + #[doc(alias = "GetKeyPressedAmount")] + pub fn key_index_pressed_amount(&self, key_index: i32, repeat_delay: f32, rate: f32) -> u32 { + unsafe { sys::igGetKeyPressedAmount(key_index, repeat_delay, rate) as u32 } + } + + /// Focuses keyboard on the next widget. + /// + /// This is the equivalent to [set_keyboard_focus_here_with_offset](Self::set_keyboard_focus_here_with_offset) + /// with `target_widget` set to `FocusedWidget::Next`. + #[inline] + #[doc(alias = "SetKeyboardFocusHere")] + pub fn set_keyboard_focus_here(&self) { + self.set_keyboard_focus_here_with_offset(FocusedWidget::Next); + } + + /// Focuses keyboard on a widget relative to current position. + #[inline] + #[doc(alias = "SetKeyboardFocusHere")] + pub fn set_keyboard_focus_here_with_offset(&self, target_widget: FocusedWidget) { + unsafe { + sys::igSetKeyboardFocusHere(target_widget.as_offset()); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/input/mod.rs b/plugins/libimhex-rust/imgui-rs/src/input/mod.rs new file mode 100644 index 000000000..73cdf761a --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/input/mod.rs @@ -0,0 +1,2 @@ +pub mod keyboard; +pub mod mouse; diff --git a/plugins/libimhex-rust/imgui-rs/src/input/mouse.rs b/plugins/libimhex-rust/imgui-rs/src/input/mouse.rs new file mode 100644 index 000000000..b92b3d0fc --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/input/mouse.rs @@ -0,0 +1,478 @@ +use std::ptr; + +use crate::sys; +use crate::Ui; + +/// Represents one of the supported mouse buttons +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub enum MouseButton { + Left = 0, + Right = 1, + Middle = 2, + Extra1 = 3, + Extra2 = 4, +} + +impl MouseButton { + /// All possible `MouseButton` varirants + pub const VARIANTS: [MouseButton; MouseButton::COUNT] = [ + MouseButton::Left, + MouseButton::Right, + MouseButton::Middle, + MouseButton::Extra1, + MouseButton::Extra2, + ]; + /// Total count of `MouseButton` variants + pub const COUNT: usize = 5; +} + +#[test] +fn test_mouse_button_variants() { + for (idx, &value) in MouseButton::VARIANTS.iter().enumerate() { + assert_eq!(idx, value as usize); + } +} + +/// Mouse cursor type identifier +#[repr(i32)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +// TODO: this should just be `#[allow(clippy::upper_case_acronyms)]`, but doing +// so in a way that works before it stabilizes is a pain (in part because +// `unknown_clippy_lints` was renamed to unknown_lints). Oh well, it's over a +// small amount of code. +#[allow(warnings)] +pub enum MouseCursor { + Arrow = sys::ImGuiMouseCursor_Arrow, + /// Automatically used when hovering over text inputs, etc. + TextInput = sys::ImGuiMouseCursor_TextInput, + /// Not used automatically + ResizeAll = sys::ImGuiMouseCursor_ResizeAll, + /// Automatically used when hovering over a horizontal border + ResizeNS = sys::ImGuiMouseCursor_ResizeNS, + /// Automatically used when hovering over a vertical border or a column + ResizeEW = sys::ImGuiMouseCursor_ResizeEW, + /// Automatically used when hovering over the bottom-left corner of a window + ResizeNESW = sys::ImGuiMouseCursor_ResizeNESW, + /// Automatically used when hovering over the bottom-right corner of a window + ResizeNWSE = sys::ImGuiMouseCursor_ResizeNWSE, + /// Not used automatically, use for e.g. hyperlinks + Hand = sys::ImGuiMouseCursor_Hand, + /// When hovering something with disallowed interactions. + /// + /// Usually a crossed circle. + NotAllowed = sys::ImGuiMouseCursor_NotAllowed, +} + +impl MouseCursor { + /// All possible `MouseCursor` varirants + pub const VARIANTS: [MouseCursor; MouseCursor::COUNT] = [ + MouseCursor::Arrow, + MouseCursor::TextInput, + MouseCursor::ResizeAll, + MouseCursor::ResizeNS, + MouseCursor::ResizeEW, + MouseCursor::ResizeNESW, + MouseCursor::ResizeNWSE, + MouseCursor::Hand, + MouseCursor::NotAllowed, + ]; + /// Total count of `MouseCursor` variants + pub const COUNT: usize = sys::ImGuiMouseCursor_COUNT as usize; +} + +#[test] +fn test_mouse_cursor_variants() { + for (idx, &value) in MouseCursor::VARIANTS.iter().enumerate() { + assert_eq!(idx, value as usize); + } +} + +/// # Input: Mouse +impl<'ui> Ui<'ui> { + /// Returns true if the given mouse button is held down. + /// + /// Equivalent to indexing the Io struct with the button, e.g. `ui.io()[button]`. + #[doc(alias = "IsMouseDown")] + pub fn is_mouse_down(&self, button: MouseButton) -> bool { + unsafe { sys::igIsMouseDown(button as i32) } + } + /// Returns true if any mouse button is held down + #[doc(alias = "IsAnyMouseDown")] + pub fn is_any_mouse_down(&self) -> bool { + unsafe { sys::igIsAnyMouseDown() } + } + /// Returns true if the given mouse button was clicked (went from !down to down) + #[doc(alias = "IsMouseClicked")] + pub fn is_mouse_clicked(&self, button: MouseButton) -> bool { + unsafe { sys::igIsMouseClicked(button as i32, false) } + } + /// Returns true if the given mouse button was double-clicked + #[doc(alias = "IsMouseDoubleClicked")] + pub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool { + unsafe { sys::igIsMouseDoubleClicked(button as i32) } + } + /// Returns true if the given mouse button was released (went from down to !down) + #[doc(alias = "IsMouseReleased")] + pub fn is_mouse_released(&self, button: MouseButton) -> bool { + unsafe { sys::igIsMouseReleased(button as i32) } + } + /// Returns true if the mouse is currently dragging with the given mouse button held down + #[doc(alias = "IsMouseDragging")] + pub fn is_mouse_dragging(&self, button: MouseButton) -> bool { + unsafe { sys::igIsMouseDragging(button as i32, -1.0) } + } + /// Returns true if the mouse is currently dragging with the given mouse button held down. + /// + /// If the given threshold is invalid or negative, the global distance threshold is used + /// (`io.mouse_drag_threshold`). + #[doc(alias = "IsMouseDragging")] + pub fn is_mouse_dragging_with_threshold(&self, button: MouseButton, threshold: f32) -> bool { + unsafe { sys::igIsMouseDragging(button as i32, threshold) } + } + /// Returns true if the mouse is hovering over the given bounding rect. + /// + /// Clipped by current clipping settings, but disregards other factors like focus, window + /// ordering, modal popup blocking. + pub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool { + unsafe { sys::igIsMouseHoveringRect(r_min.into(), r_max.into(), true) } + } + /// Returns the mouse position backed up at the time of opening a popup + #[doc(alias = "GetMousePosOnOpeningCurrentPopup")] + pub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetMousePosOnOpeningCurrentPopup(&mut out) }; + out.into() + } + + /// Returns the delta from the initial position when the left mouse button clicked. + /// + /// This is locked and returns [0.0, 0.0] until the mouse has moved past the global distance + /// threshold (`io.mouse_drag_threshold`). + /// + /// This is the same as [mouse_drag_delta_with_button](Self::mouse_drag_delta_with_button) with + /// `button` set to `MouseButton::Left`. + #[doc(alias = "GetMouseDragDelta")] + pub fn mouse_drag_delta(&self) -> [f32; 2] { + self.mouse_drag_delta_with_button(MouseButton::Left) + } + + /// Returns the delta from the initial position when the given button was clicked. + /// + /// This is locked and returns [0.0, 0.0] until the mouse has moved past the global distance + /// threshold (`io.mouse_drag_threshold`). + /// + /// This is the same as [mouse_drag_delta_with_threshold](Self::mouse_drag_delta_with_threshold) with + /// `threshold` set to `-1.0`, which uses the global threshold `io.mouse_drag_threshold`. + #[doc(alias = "GetMouseDragDelta")] + pub fn mouse_drag_delta_with_button(&self, button: MouseButton) -> [f32; 2] { + self.mouse_drag_delta_with_threshold(button, -1.0) + } + /// Returns the delta from the initial clicking position. + /// + /// This is locked and returns [0.0, 0.0] until the mouse has moved past the given threshold. + /// If the given threshold is invalid or negative, the global distance threshold is used + /// (`io.mouse_drag_threshold`). + #[doc(alias = "GetMouseDragDelta")] + pub fn mouse_drag_delta_with_threshold(&self, button: MouseButton, threshold: f32) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetMouseDragDelta(&mut out, button as i32, threshold) }; + out.into() + } + /// Resets the current delta from initial clicking position. + #[doc(alias = "ResetMouseDragDelta")] + pub fn reset_mouse_drag_delta(&self, button: MouseButton) { + // This mutates the Io struct, but targets an internal field so there can't be any + // references to it + unsafe { sys::igResetMouseDragDelta(button as i32) } + } + /// Returns the currently desired mouse cursor type. + /// + /// Returns `None` if no cursor should be displayed + #[doc(alias = "GetMouseCursor")] + pub fn mouse_cursor(&self) -> Option { + match unsafe { sys::igGetMouseCursor() } { + sys::ImGuiMouseCursor_Arrow => Some(MouseCursor::Arrow), + sys::ImGuiMouseCursor_TextInput => Some(MouseCursor::TextInput), + sys::ImGuiMouseCursor_ResizeAll => Some(MouseCursor::ResizeAll), + sys::ImGuiMouseCursor_ResizeNS => Some(MouseCursor::ResizeNS), + sys::ImGuiMouseCursor_ResizeEW => Some(MouseCursor::ResizeEW), + sys::ImGuiMouseCursor_ResizeNESW => Some(MouseCursor::ResizeNESW), + sys::ImGuiMouseCursor_ResizeNWSE => Some(MouseCursor::ResizeNWSE), + sys::ImGuiMouseCursor_Hand => Some(MouseCursor::Hand), + sys::ImGuiMouseCursor_NotAllowed => Some(MouseCursor::NotAllowed), + _ => None, + } + } + /// Sets the desired mouse cursor type. + /// + /// Passing `None` hides the mouse cursor. + #[doc(alias = "SetMouseCursor")] + pub fn set_mouse_cursor(&self, cursor_type: Option) { + unsafe { + sys::igSetMouseCursor( + cursor_type + .map(|x| x as i32) + .unwrap_or(sys::ImGuiMouseCursor_None), + ); + } + } + #[doc(alias = "IsMousePosValid")] + pub fn is_current_mouse_pos_valid(&self) -> bool { + unsafe { sys::igIsMousePosValid(ptr::null()) } + } + #[doc(alias = "IsMousePosValid")] + pub fn is_mouse_pos_valid(&self, mouse_pos: [f32; 2]) -> bool { + unsafe { sys::igIsMousePosValid(&mouse_pos.into()) } + } +} + +#[test] +fn test_mouse_down_clicked_released() { + for &button in MouseButton::VARIANTS.iter() { + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + { + ctx.io_mut().mouse_down = [false; 5]; + let ui = ctx.frame(); + assert!(!ui.is_mouse_down(button)); + assert!(!ui.is_any_mouse_down()); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_released(button)); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(ui.is_mouse_down(button)); + assert!(ui.is_any_mouse_down()); + assert!(ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_released(button)); + } + { + let ui = ctx.frame(); + assert!(ui.is_mouse_down(button)); + assert!(ui.is_any_mouse_down()); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_released(button)); + } + { + ctx.io_mut()[button] = false; + let ui = ctx.frame(); + assert!(!ui.is_mouse_down(button)); + assert!(!ui.is_any_mouse_down()); + assert!(!ui.is_mouse_clicked(button)); + assert!(ui.is_mouse_released(button)); + } + { + let ui = ctx.frame(); + assert!(!ui.is_mouse_down(button)); + assert!(!ui.is_any_mouse_down()); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_released(button)); + } + } +} + +#[test] +fn test_mouse_double_click() { + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + // Workaround for dear imgui bug/feature: + // If a button is clicked before io.mouse_double_click_time seconds has passed after the + // context is initialized, the single click is interpreted as a double-click. This happens + // because internally g.IO.MouseClickedTime is set to 0.0, so the context creation is + // considered a "click". + { + // Pass one second of time + ctx.io_mut().delta_time = 1.0; + let _ = ctx.frame(); + } + // Fast clicks + ctx.io_mut().delta_time = 1.0 / 60.0; + for &button in MouseButton::VARIANTS.iter() { + { + ctx.io_mut().mouse_down = [false; 5]; + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = false; + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(ui.is_mouse_clicked(button)); + assert!(ui.is_mouse_double_clicked(button)); + } + { + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + } + // Slow clicks + ctx.io_mut().delta_time = 1.0; + for &button in MouseButton::VARIANTS.iter() { + { + ctx.io_mut().mouse_down = [false; 5]; + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = false; + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + { + let ui = ctx.frame(); + assert!(!ui.is_mouse_clicked(button)); + assert!(!ui.is_mouse_double_clicked(button)); + } + } +} + +#[test] +fn test_set_get_mouse_cursor() { + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + let ui = ctx.frame(); + ui.set_mouse_cursor(None); + assert_eq!(None, ui.mouse_cursor()); + ui.set_mouse_cursor(Some(MouseCursor::Hand)); + assert_eq!(Some(MouseCursor::Hand), ui.mouse_cursor()); +} + +#[test] +fn test_mouse_drags() { + for &button in MouseButton::VARIANTS.iter() { + let (_guard, mut ctx) = crate::test::test_ctx_initialized(); + { + ctx.io_mut().mouse_pos = [0.0, 0.0]; + ctx.io_mut().mouse_down = [false; 5]; + let ui = ctx.frame(); + assert!(!ui.is_mouse_dragging(button)); + assert!(!ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 0.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 0.0] + ); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(!ui.is_mouse_dragging(button)); + assert!(!ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 0.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 0.0] + ); + } + { + ctx.io_mut().mouse_pos = [0.0, 100.0]; + let ui = ctx.frame(); + assert!(ui.is_mouse_dragging(button)); + assert!(!ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 100.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 0.0] + ); + } + { + ctx.io_mut().mouse_pos = [0.0, 200.0]; + let ui = ctx.frame(); + assert!(ui.is_mouse_dragging(button)); + assert!(ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 200.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 200.0] + ); + } + { + ctx.io_mut().mouse_pos = [10.0, 10.0]; + ctx.io_mut()[button] = false; + let ui = ctx.frame(); + assert!(!ui.is_mouse_dragging(button)); + assert!(!ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [10.0, 10.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [10.0, 10.0] + ); + } + { + ctx.io_mut()[button] = true; + let ui = ctx.frame(); + assert!(!ui.is_mouse_dragging(button)); + assert!(!ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 0.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 0.0] + ); + } + { + ctx.io_mut().mouse_pos = [180.0, 180.0]; + let ui = ctx.frame(); + assert!(ui.is_mouse_dragging(button)); + assert!(ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [170.0, 170.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [170.0, 170.0] + ); + ui.reset_mouse_drag_delta(button); + assert!(ui.is_mouse_dragging(button)); + assert!(ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [0.0, 0.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [0.0, 0.0] + ); + } + { + ctx.io_mut().mouse_pos = [200.0, 200.0]; + let ui = ctx.frame(); + assert!(ui.is_mouse_dragging(button)); + assert!(ui.is_mouse_dragging_with_threshold(button, 200.0)); + assert_eq!(ui.mouse_drag_delta_with_button(button), [20.0, 20.0]); + assert_eq!( + ui.mouse_drag_delta_with_threshold(button, 200.0), + [20.0, 20.0] + ); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/input_widget.rs b/plugins/libimhex-rust/imgui-rs/src/input_widget.rs new file mode 100644 index 000000000..a97252089 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/input_widget.rs @@ -0,0 +1,1023 @@ +use bitflags::bitflags; +use std::ops::Range; +use std::os::raw::{c_char, c_int, c_void}; + +use crate::sys; +use crate::Ui; + +bitflags!( + /// Flags for text inputs + #[repr(C)] + pub struct InputTextFlags: u32 { + /// Allow 0123456789.+-*/ + const CHARS_DECIMAL = sys::ImGuiInputTextFlags_CharsDecimal; + /// Allow 0123456789ABCDEFabcdef + const CHARS_HEXADECIMAL = sys::ImGuiInputTextFlags_CharsHexadecimal; + /// Turn a..z into A..Z + const CHARS_UPPERCASE = sys::ImGuiInputTextFlags_CharsUppercase; + /// Filter out spaces, tabs + const CHARS_NO_BLANK = sys::ImGuiInputTextFlags_CharsNoBlank; + /// Select entire text when first taking mouse focus + const AUTO_SELECT_ALL = sys::ImGuiInputTextFlags_AutoSelectAll; + /// Return 'true' when Enter is pressed (as opposed to when the value was modified) + const ENTER_RETURNS_TRUE = sys::ImGuiInputTextFlags_EnterReturnsTrue; + /// Call user function on pressing TAB (for completion handling) + const CALLBACK_COMPLETION = sys::ImGuiInputTextFlags_CallbackCompletion; + /// Call user function on pressing Up/Down arrows (for history handling) + const CALLBACK_HISTORY = sys::ImGuiInputTextFlags_CallbackHistory; + /// Call user function on pressing Up/Down arrows (for history handling) + const CALLBACK_EDIT = sys::ImGuiInputTextFlags_CallbackEdit; + /// Call user function every time. User code may query cursor position, modify text buffer. + const CALLBACK_ALWAYS = sys::ImGuiInputTextFlags_CallbackAlways; + /// Call user function to filter character. + const CALLBACK_CHAR_FILTER = sys::ImGuiInputTextFlags_CallbackCharFilter; + /// Pressing TAB input a '\t' character into the text field + const ALLOW_TAB_INPUT = sys::ImGuiInputTextFlags_AllowTabInput; + /// 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 CTRL_ENTER_FOR_NEW_LINE = sys::ImGuiInputTextFlags_CtrlEnterForNewLine; + /// Disable following the cursor horizontally + const NO_HORIZONTAL_SCROLL = sys::ImGuiInputTextFlags_NoHorizontalScroll; + /// Always overwrite (aka "insert mode"). + const ALWAYS_OVERWRITE = sys::ImGuiInputTextFlags_AlwaysOverwrite; + /// Read-only mode + const READ_ONLY = sys::ImGuiInputTextFlags_ReadOnly; + /// Password mode, display all characters as '*' + const PASSWORD = sys::ImGuiInputTextFlags_Password; + /// Disable undo/redo. + const NO_UNDO_REDO = sys::ImGuiInputTextFlags_NoUndoRedo; + /// Allow 0123456789.+-*/eE (Scientific notation input) + const CHARS_SCIENTIFIC = sys::ImGuiInputTextFlags_CharsScientific; + /// Allow buffer capacity resize + notify when the string wants to be resized + const CALLBACK_RESIZE = sys::ImGuiInputTextFlags_CallbackResize; + } +); + +macro_rules! impl_text_flags { + ($InputType:ident) => { + #[inline] + pub fn flags(mut self, flags: InputTextFlags) -> Self { + self.flags = flags; + self + } + + #[inline] + pub fn chars_decimal(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::CHARS_DECIMAL, value); + self + } + + #[inline] + pub fn chars_hexadecimal(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::CHARS_HEXADECIMAL, value); + self + } + + #[inline] + pub fn chars_uppercase(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::CHARS_UPPERCASE, value); + self + } + + #[inline] + pub fn chars_noblank(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::CHARS_NO_BLANK, value); + self + } + + #[inline] + pub fn auto_select_all(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::AUTO_SELECT_ALL, value); + self + } + + #[inline] + pub fn enter_returns_true(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::ENTER_RETURNS_TRUE, value); + self + } + + #[inline] + pub fn allow_tab_input(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::ALLOW_TAB_INPUT, value); + self + } + + #[inline] + pub fn no_horizontal_scroll(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::NO_HORIZONTAL_SCROLL, value); + self + } + + /// Note: this is equivalent to `always_overwrite` + #[inline] + pub fn always_insert_mode(self, value: bool) -> Self { + self.always_overwrite(value) + } + + #[inline] + #[allow(deprecated)] + pub fn always_overwrite(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::ALWAYS_OVERWRITE, value); + self + } + + #[inline] + pub fn read_only(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::READ_ONLY, value); + self + } + + #[inline] + pub fn password(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::PASSWORD, value); + self + } + + #[inline] + pub fn no_undo_redo(mut self, value: bool) -> Self { + self.flags.set(InputTextFlags::NO_UNDO_REDO, value); + self + } + }; +} + +macro_rules! impl_step_params { + ($InputType:ident, $Value:ty) => { + #[inline] + pub fn step(mut self, value: $Value) -> Self { + self.step = value; + self + } + + #[inline] + pub fn step_fast(mut self, value: $Value) -> Self { + self.step_fast = value; + self + } + }; +} + +#[must_use] +pub struct InputText<'ui, 'p, L, H = &'static str, T = PassthroughCallback> { + label: L, + hint: Option, + buf: &'p mut String, + callback_handler: T, + flags: InputTextFlags, + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, L: AsRef> InputText<'ui, 'p, L> { + /// Creates a new input text widget to edit the given string. + /// + /// # String Editing + /// + /// Please note, ImGui requires this string to be null-terminated. We accomplish this + /// by appending and then removing a null terminator (`\0`) from the String you pass in. + /// This has several consequences: + /// 1. The string's backing buffer may be resized and relocated even without edits as result + /// of this pushed char. + /// 2. **The string will appear truncated if the string contains `\0` inside it.** This will not + /// cause memory *unsafety*, but it will limit your usage. If that's the case, please pre-process + /// your string. + /// 3. Truncations by ImGui appear to be done primarily by insertions of `\0` to the truncation point. + /// We will handle this for you and edit the string "properly" too, but this might show up in callbacks. + pub fn new(ui: &'ui Ui<'ui>, label: L, buf: &'p mut String) -> Self { + InputText { + label, + hint: None, + // this is fine because no one else has access to this and imgui is single threaded. + callback_handler: PassthroughCallback, + buf, + flags: InputTextFlags::CALLBACK_RESIZE, + ui, + } + } +} + +impl<'ui, 'p, T, L, H> InputText<'ui, 'p, L, H, T> +where + L: AsRef, + H: AsRef, + T: InputTextCallbackHandler, +{ + /// Sets the hint displayed in the input text background. + #[inline] + pub fn hint>(self, hint: H2) -> InputText<'ui, 'p, L, H2, T> { + InputText { + label: self.label, + hint: Some(hint), + buf: self.buf, + callback_handler: self.callback_handler, + flags: self.flags, + ui: self.ui, + } + } + + impl_text_flags!(InputText); + + // I am commenting this ability out for now -- because we need to push `\0` for imgui, + // we may resize the buffer no matter what, and we must do that. + // The solution for this will be, I suspect, to build a second api channel that takes + // an `&mut CStr`, which is ugly! I suspect few to none will want no-resizing, so I'm deferring + // fixing the problem. -- sanbox-irl 09/15/2021, see #523 for more + // + // /// By default (as of 0.8.0), imgui-rs will automatically handle string resizes + // /// for [InputText] and [InputTextMultiline]. + // /// + // /// If, for some reason, you don't want this, you can run this function to prevent this. + // /// In that case, edits which would cause a resize will not occur. + // /// #[inline] + // pub unsafe fn do_not_resize(mut self) -> Self { + // self.flags.remove(InputTextFlags::CALLBACK_RESIZE); + // self + // } + + #[inline] + pub fn callback( + mut self, + callbacks: InputTextCallback, + callback: T2, + ) -> InputText<'ui, 'p, L, H, T2> { + if callbacks.contains(InputTextCallback::COMPLETION) { + self.flags.insert(InputTextFlags::CALLBACK_COMPLETION); + } + if callbacks.contains(InputTextCallback::HISTORY) { + self.flags.insert(InputTextFlags::CALLBACK_HISTORY); + } + if callbacks.contains(InputTextCallback::ALWAYS) { + self.flags.insert(InputTextFlags::CALLBACK_ALWAYS); + } + if callbacks.contains(InputTextCallback::CHAR_FILTER) { + self.flags.insert(InputTextFlags::CALLBACK_CHAR_FILTER); + } + if callbacks.contains(InputTextCallback::EDIT) { + self.flags.insert(InputTextFlags::CALLBACK_EDIT); + } + InputText { + callback_handler: callback, + label: self.label, + hint: self.hint, + buf: self.buf, + flags: self.flags, + ui: self.ui, + } + } + + /// Builds the string editor, performing string editing operations. + /// + /// # String Editing + /// + /// Please note, ImGui requires this string to be null-terminated. We accomplish this + /// by appending and then removing a null terminator (`\0`) from the String you pass in. + /// This has several consequences: + /// 1. The string's backing buffer may be resized and relocated even without edits as result + /// of this pushed char. + /// 2. **The string will appear truncated if the string contains `\0` inside it.** This will not + /// cause memory *unsafety*, but it will limit your usage. If that's the case, please pre-process + /// your string. + /// 3. Truncations by ImGui appear to be done primarily by insertions of `\0` to the truncation point. + /// We will handle this for you and edit the string "properly" too, but this might show up in callbacks. + pub fn build(self) -> bool { + // needs to be null-terminated! this is a hack! + self.buf.push('\0'); + + let (ptr, capacity) = (self.buf.as_mut_ptr(), self.buf.capacity()); + + let mut data = UserData { + container: self.buf, + cback_handler: self.callback_handler, + }; + let data = &mut data as *mut _ as *mut c_void; + + let o = unsafe { + if let Some(hint) = self.hint { + let (label, hint) = self.ui.scratch_txt_two(self.label, hint); + sys::igInputTextWithHint( + label, + hint, + ptr as *mut sys::cty::c_char, + capacity, + self.flags.bits() as i32, + Some(callback::), + data, + ) + } else { + let label = self.ui.scratch_txt(self.label); + + sys::igInputText( + label, + ptr as *mut sys::cty::c_char, + capacity, + self.flags.bits() as i32, + Some(callback::), + data, + ) + } + }; + + // first, pop our end buffer... + if self.buf.ends_with('\0') { + self.buf.pop(); + } + + if o { + // if a truncation occured, we'll find another one too on the end. + // this might end up deleting user `\0` though! + // this hack is working but WOW is it hacky! + if let Some(null_terminator_position) = self.buf.rfind('\0') { + self.buf.truncate(null_terminator_position); + } + } + + o + } +} + +#[must_use] +pub struct InputTextMultiline<'ui, 'p, L, T = PassthroughCallback> { + label: L, + buf: &'p mut String, + flags: InputTextFlags, + size: [f32; 2], + callback_handler: T, + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, L: AsRef> InputTextMultiline<'ui, 'p, L, PassthroughCallback> { + /// Creates a new input text widget to edit the given string. + /// + /// # String Editing + /// + /// Please note, ImGui requires this string to be null-terminated. We accomplish this + /// by appending and then removing a null terminator (`\0`) from the String you pass in. + /// This has several consequences: + /// 1. The string's backing buffer may be resized and relocated even without edits as result + /// of this pushed char. + /// 2. **The string will appear truncated if the string contains `\0` inside it.** This will not + /// cause memory *unsafety*, but it will limit your usage. If that's the case, please pre-process + /// your string. + /// 3. Truncations by ImGui appear to be done primarily by insertions of `\0` to the truncation point. + /// We will handle this for you and edit the string "properly" too, but this might show up in callbacks. + pub fn new(ui: &'ui Ui<'ui>, label: L, buf: &'p mut String, size: [f32; 2]) -> Self { + InputTextMultiline { + label, + buf, + flags: InputTextFlags::CALLBACK_RESIZE, + size, + callback_handler: PassthroughCallback, + ui, + } + } +} + +impl<'ui, 'p, T: InputTextCallbackHandler, L: AsRef> InputTextMultiline<'ui, 'p, L, T> { + impl_text_flags!(InputText); + + // I am commenting this ability out for now -- because we need to push `\0` for imgui, + // we may resize the buffer no matter what, and we must do that. + // The solution for this will be, I suspect, to build a second api channel that takes + // an `&mut CStr`, which is ugly! I suspect few to none will want no-resizing, so I'm deferring + // fixing the problem. -- sanbox-irl 09/15/2021, see #523 for more + // /// By default (as of 0.8.0), imgui-rs will automatically handle string resizes + // /// for [InputText] and [InputTextMultiline]. + // /// + // /// If, for some reason, you don't want this, you can run this function to prevent this. + // /// In that case, edits which would cause a resize will not occur. + // #[inline] + // pub fn do_not_resize(mut self) -> Self { + // self.flags.remove(InputTextFlags::CALLBACK_RESIZE); + // self + // } + + #[inline] + pub fn callback( + mut self, + callbacks: InputTextMultilineCallback, + callback_handler: T2, + ) -> InputTextMultiline<'ui, 'p, L, T2> { + if callbacks.contains(InputTextMultilineCallback::COMPLETION) { + self.flags.insert(InputTextFlags::CALLBACK_COMPLETION); + } + if callbacks.contains(InputTextMultilineCallback::ALWAYS) { + self.flags.insert(InputTextFlags::CALLBACK_ALWAYS); + } + if callbacks.contains(InputTextMultilineCallback::CHAR_FILTER) { + self.flags.insert(InputTextFlags::CALLBACK_CHAR_FILTER); + } + if callbacks.contains(InputTextMultilineCallback::EDIT) { + self.flags.insert(InputTextFlags::CALLBACK_EDIT); + } + + InputTextMultiline { + label: self.label, + buf: self.buf, + flags: self.flags, + size: self.size, + callback_handler, + ui: self.ui, + } + } + + /// Builds the string editor, performing string editing operations. + /// + /// # String Editing + /// + /// Please note, ImGui requires this string to be null-terminated. We accomplish this + /// by appending and then removing a null terminator (`\0`) from the String you pass in. + /// This has several consequences: + /// 1. The string's backing buffer may be resized and relocated even without edits as result + /// of this pushed char. + /// 2. **The string will appear truncated if the string contains `\0` inside it.** This will not + /// cause memory *unsafety*, but it will limit your usage. If that's the case, please pre-process + /// your string. + /// 3. Truncations by ImGui appear to be done primarily by insertions of `\0` to the truncation point. + /// We will handle this for you and edit the string "properly" too, but this might show up in callbacks. + pub fn build(self) -> bool { + // needs to be null-terminated! this is a hack! + self.buf.push('\0'); + let (ptr, capacity) = (self.buf.as_mut_ptr(), self.buf.capacity()); + + let mut data = UserData { + container: self.buf, + cback_handler: self.callback_handler, + }; + let data = &mut data as *mut _ as *mut c_void; + + let o = unsafe { + sys::igInputTextMultiline( + self.ui.scratch_txt(self.label), + ptr as *mut sys::cty::c_char, + capacity, + self.size.into(), + self.flags.bits() as i32, + Some(callback::), + data, + ) + }; + + // first, pop our end buffer... + if self.buf.ends_with('\0') { + self.buf.pop(); + } + + if o { + // if a truncation occured, we'll find another one too on the end. + // this might end up deleting user `\0` though! + if let Some(null_terminator_position) = self.buf.rfind('\0') { + self.buf.truncate(null_terminator_position); + } + } + + o + } +} + +#[must_use] +pub struct InputInt<'ui, 'p, L> { + label: L, + value: &'p mut i32, + step: i32, + step_fast: i32, + flags: InputTextFlags, + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, L: AsRef> InputInt<'ui, 'p, L> { + pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut i32) -> Self { + InputInt { + label, + value, + step: 1, + step_fast: 100, + flags: InputTextFlags::empty(), + ui, + } + } + + pub fn build(self) -> bool { + unsafe { + sys::igInputInt( + self.ui.scratch_txt(self.label), + self.value as *mut i32, + self.step, + self.step_fast, + self.flags.bits() as i32, + ) + } + } + + impl_step_params!(InputInt, i32); + impl_text_flags!(InputInt); +} + +#[must_use] +pub struct InputFloat<'ui, 'p, L> { + label: L, + value: &'p mut f32, + step: f32, + step_fast: f32, + flags: InputTextFlags, + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, L: AsRef> InputFloat<'ui, 'p, L> { + pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut f32) -> Self { + InputFloat { + label, + value, + step: 0.0, + step_fast: 0.0, + flags: InputTextFlags::empty(), + ui, + } + } + + pub fn build(self) -> bool { + unsafe { + sys::igInputFloat( + self.ui.scratch_txt(self.label), + self.value as *mut f32, + self.step, + self.step_fast, + b"%.3f\0".as_ptr() as *const _, + self.flags.bits() as i32, + ) + } + } + + impl_step_params!(InputFloat, f32); + impl_text_flags!(InputFloat); +} + +macro_rules! impl_input_floatn { + ($InputFloatN:ident, $N:expr, $igInputFloatN:ident) => { + #[must_use] + pub struct $InputFloatN<'ui, 'p, L> { + label: L, + value: &'p mut [f32; $N], + flags: InputTextFlags, + ui: &'ui Ui<'ui>, + } + + impl<'ui, 'p, L: AsRef> $InputFloatN<'ui, 'p, L> { + pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut [f32; $N]) -> Self { + $InputFloatN { + label, + value, + flags: InputTextFlags::empty(), + ui, + } + } + + pub fn build(self) -> bool { + unsafe { + sys::$igInputFloatN( + self.ui.scratch_txt(self.label), + self.value.as_mut_ptr(), + b"%.3f\0".as_ptr() as *const _, + self.flags.bits() as i32, + ) + } + } + + impl_text_flags!($InputFloatN); + } + }; +} + +impl_input_floatn!(InputFloat2, 2, igInputFloat2); +impl_input_floatn!(InputFloat3, 3, igInputFloat3); +impl_input_floatn!(InputFloat4, 4, igInputFloat4); + +macro_rules! impl_input_intn { + ($InputIntN:ident, $N:expr, $igInputIntN:ident) => { + #[must_use] + pub struct $InputIntN<'ui, 'p, L> { + label: L, + value: &'p mut [i32; $N], + flags: InputTextFlags, + ui: &'ui Ui<'ui>, + } + + impl<'ui, 'p, L: AsRef> $InputIntN<'ui, 'p, L> { + pub fn new(ui: &'ui Ui<'ui>, label: L, value: &'p mut [i32; $N]) -> Self { + $InputIntN { + label, + value, + flags: InputTextFlags::empty(), + ui, + } + } + + pub fn build(self) -> bool { + unsafe { + sys::$igInputIntN( + self.ui.scratch_txt(self.label), + self.value.as_mut_ptr(), + self.flags.bits() as i32, + ) + } + } + + impl_text_flags!($InputIntN); + } + }; +} + +impl_input_intn!(InputInt2, 2, igInputInt2); +impl_input_intn!(InputInt3, 3, igInputInt3); +impl_input_intn!(InputInt4, 4, igInputInt4); + +bitflags!( + /// Callback flags for an `InputText` widget. These correspond to + /// the general textflags. + pub struct InputTextCallback: u32 { + /// Call user function on pressing TAB (for completion handling) + const COMPLETION = sys::ImGuiInputTextFlags_CallbackCompletion; + /// Call user function on pressing Up/Down arrows (for history handling) + const HISTORY = sys::ImGuiInputTextFlags_CallbackHistory; + /// Call user function every time. User code may query cursor position, modify text buffer. + const ALWAYS = sys::ImGuiInputTextFlags_CallbackAlways; + /// Call user function to filter character. + const CHAR_FILTER = sys::ImGuiInputTextFlags_CallbackCharFilter; + /// Callback on buffer edit (note that InputText already returns true on edit, the + /// callback is useful mainly to manipulate the underlying buffer while focus is active) + const EDIT = sys::ImGuiInputTextFlags_CallbackEdit; + } +); + +bitflags!( + /// Callback flags for an `InputTextMultiline` widget. These correspond to the + /// general textflags. + pub struct InputTextMultilineCallback: u32 { + /// Call user function on pressing TAB (for completion handling) + const COMPLETION = sys::ImGuiInputTextFlags_CallbackCompletion; + /// Call user function every time. User code may query cursor position, modify text buffer. + const ALWAYS = sys::ImGuiInputTextFlags_CallbackAlways; + /// Call user function to filter character. + const CHAR_FILTER = sys::ImGuiInputTextFlags_CallbackCharFilter; + /// Callback on buffer edit (note that InputText already returns true on edit, the + /// callback is useful mainly to manipulate the underlying buffer while focus is active) + const EDIT = sys::ImGuiInputTextFlags_CallbackEdit; + } +); + +/// This trait provides an interface which ImGui will call on `InputText` +/// and `InputTextMultiline` callbacks. +/// +/// Each method is called *if and only if* the corresponding flag for each +/// method is passed to ImGui in the `callback` builder. +/// +/// Each method here lists the flag required to call it, and this module begins +/// with an example of callbacks being used. +pub trait InputTextCallbackHandler { + /// Filters a char -- returning a `None` means that the char is removed, + /// and returning another char substitutes it out. + /// + /// Because of upstream ImGui choices, you do not have access to the buffer + /// during this callback (for some reason). + /// + /// To make ImGui run this callback, use [InputTextCallback::CHAR_FILTER] or + /// [InputTextMultilineCallback::CHAR_FILTER]. + fn char_filter(&mut self, c: char) -> Option { + Some(c) + } + + /// Allows one to perform autocompletion work when the Tab key has been pressed. + /// + /// To make ImGui run this callback, use [InputTextCallback::COMPLETION] or + /// [InputTextMultilineCallback::COMPLETION]. + fn on_completion(&mut self, _: TextCallbackData<'_>) {} + + /// Allows one to edit the inner buffer whenever the buffer has been changed. + /// + /// To make ImGui run this callback, use [InputTextCallback::EDIT] or + /// [InputTextMultilineCallback::EDIT]. + fn on_edit(&mut self, _: TextCallbackData<'_>) {} + + /// A callback when one of the direction keys have been pressed. + /// + /// To make ImGui run this callback, use [InputTextCallback::HISTORY]. It appears + /// that this callback will not be ran in a multiline input widget at all. + fn on_history(&mut self, _: HistoryDirection, _: TextCallbackData<'_>) {} + + /// A callback which will always fire, each tick. + /// + /// To make ImGui run this callback, use [InputTextCallback::ALWAYS] or + /// [InputTextMultilineCallback::ALWAYS]. + fn on_always(&mut self, _: TextCallbackData<'_>) {} +} + +/// The arrow key a user pressed to trigger the `on_history` callback. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum HistoryDirection { + Up, + Down, +} + +/// This struct provides methods to edit the underlying text buffer that +/// Dear ImGui manipulates. Primarily, it gives [remove_chars](Self::remove_chars), +/// [insert_chars](Self::insert_chars), and mutable access to what text is selected. +pub struct TextCallbackData<'a>(&'a mut sys::ImGuiInputTextCallbackData); + +impl<'a> TextCallbackData<'a> { + /// Creates the buffer. + unsafe fn new(data: &'a mut sys::ImGuiInputTextCallbackData) -> Self { + Self(data) + } + + /// Get a reference to the text callback buffer's str. + pub fn str(&self) -> &str { + unsafe { + std::str::from_utf8(std::slice::from_raw_parts( + self.0.Buf as *const _, + self.0.BufTextLen as usize, + )) + .expect("internal imgui error -- it boofed a utf8") + } + } + + /// Gives access to the underlying byte array MUTABLY. + /// + /// ## Safety + /// + /// This is very unsafe, and the following invariants must be + /// upheld: + /// 1. Keep the data utf8 valid. + /// 2. After editing the string, call [set_dirty]. + /// + /// To truncate the string, please use [remove_chars]. To extend + /// the string, please use [insert_chars] and [push_str]. + /// + /// This function should have highly limited usage, but could be for + /// editing certain characters in the buffer based on some external condition. + /// + /// [remove_chars]: Self::remove_chars + /// [set_dirty]: Self::set_dirty + /// [insert_chars]: Self::insert_chars + /// [push_str]: Self::push_str + pub unsafe fn str_as_bytes_mut(&mut self) -> &mut [u8] { + let str = std::str::from_utf8_mut(std::slice::from_raw_parts_mut( + self.0.Buf as *const _ as *mut _, + self.0.BufTextLen as usize, + )) + .expect("internal imgui error -- it boofed a utf8"); + + str.as_bytes_mut() + } + + /// Sets the dirty flag on the text to imgui, indicating that + /// it should reapply this string to its internal state. + /// + /// **NB:** You only need to use this method if you're using `[str_as_bytes_mut]`. + /// If you use the helper methods [remove_chars] and [insert_chars], + /// this will be set for you. However, this is no downside to setting + /// the dirty flag spuriously except the minor CPU time imgui will spend. + /// + /// [str_as_bytes_mut]: Self::str_as_bytes_mut + /// [remove_chars]: Self::remove_chars + /// [insert_chars]: Self::insert_chars + pub fn set_dirty(&mut self) { + self.0.BufDirty = true; + } + + /// Gets a range of the selected text. See [selection_start_mut](Self::selection_start_mut) + /// and [selection_end_mut](Self::selection_end_mut) to mutably edit these values. + /// + /// This Range is given in `usize` so that it might be used in indexing + /// operations more easily. To quickly grab the selected text, use [selected](Self::selected). + pub fn selection(&self) -> Range { + self.0.SelectionStart as usize..self.0.SelectionEnd as usize + } + + /// Returns the selected text directly. Note that if no text is selected, + /// an empty str slice will be returned. + pub fn selected(&self) -> &str { + &self.str()[self.selection()] + } + + /// Sets the cursor to select all. + pub fn select_all(&mut self) { + unsafe { + sys::ImGuiInputTextCallbackData_SelectAll(self.0); + } + } + + /// Clears the selection. + pub fn clear_selection(&mut self) { + unsafe { + sys::ImGuiInputTextCallbackData_ClearSelection(self.0); + } + } + + /// Checks if there is a selection within the text. + pub fn has_selection(&self) -> bool { + !self.selection().is_empty() + } + + /// Pushes the given str to the end of this buffer. If this + /// would require the String to resize, it will be resized. + /// This is automatically handled. + pub fn push_str(&mut self, s: &str) { + // this is safe because the ench of a self.str is a char_boundary. + unsafe { + self.insert_chars_unsafe(self.0.BufTextLen as usize, s); + } + } + + /// Inserts the given string at the given position. If this + /// would require the String to resize, it will be resized + /// automatically. + /// + /// ## Panics + /// Panics if the `pos` is not a char_boundary. + pub fn insert_chars(&mut self, pos: usize, s: &str) { + assert!(self.str().is_char_boundary(pos)); + unsafe { + self.insert_chars_unsafe(pos, s); + } + } + + /// Inserts the given string at the given position, unsafely. If this + /// would require the String to resize, it will be resized automatically. + /// + /// ## Safety + /// + /// It is up to the caller to confirm that the `pos` is a valid byte + /// position, or use [insert_chars](Self::insert_chars) which will panic + /// if it isn't. + pub unsafe fn insert_chars_unsafe(&mut self, pos: usize, s: &str) { + let start = s.as_ptr(); + let end = start.add(s.len()); + + sys::ImGuiInputTextCallbackData_InsertChars( + self.0, + pos as i32, + start as *const c_char, + end as *const c_char, + ); + } + + /// Clears the string to an empty buffer. + pub fn clear(&mut self) { + unsafe { + self.remove_chars_unchecked(0, self.0.BufTextLen as usize); + } + } + + /// Removes the given number of characters from the string starting + /// at some byte pos. + /// + /// ## Panics + /// Panics if the `pos` is not a char boundary. + pub fn remove_chars(&mut self, pos: usize, char_count: usize) { + let inner = &self.str()[pos..]; + let byte_count = inner + .char_indices() + .nth(char_count) + .map(|v| v.0) + .unwrap_or_else(|| inner.len()); + + unsafe { + self.remove_chars_unchecked(pos, byte_count); + } + } + + /// Removes the given number of bytes from the string starting + /// at some byte pos, without checking for utf8 validity. Use + /// [remove_chars](Self::remove_chars) for a safe variant. + /// + /// ## Safety + /// + /// It is up to the caller to ensure that the position is at a valid utf8 char_boundary + /// and that there are enough bytes within the string remaining. + pub unsafe fn remove_chars_unchecked(&mut self, pos: usize, byte_count: usize) { + sys::ImGuiInputTextCallbackData_DeleteChars(self.0, pos as i32, byte_count as i32); + } + + /// Get a reference to the text callback buffer's cursor pos. + pub fn cursor_pos(&self) -> usize { + self.0.CursorPos as usize + } + + /// Set the text callback buffer's cursor pos. + pub fn set_cursor_pos(&mut self, cursor_pos: usize) { + self.0.CursorPos = cursor_pos as i32; + } + + /// Get a mutable reference to the text callback buffer's selection start. + pub fn selection_start_mut(&mut self) -> &mut i32 { + &mut self.0.SelectionStart + } + + /// Get a mutable reference to the text callback buffer's selection end.. + pub fn selection_end_mut(&mut self) -> &mut i32 { + &mut self.0.SelectionEnd + } +} + +#[repr(C)] +struct UserData<'a, T> { + container: &'a mut String, + cback_handler: T, +} + +/// This is our default callback. +extern "C" fn callback( + data: *mut sys::ImGuiInputTextCallbackData, +) -> c_int { + struct CallbackData<'a, T> { + event_flag: InputTextFlags, + user_data: &'a mut UserData<'a, T>, + } + + let callback_data = unsafe { + CallbackData { + event_flag: InputTextFlags::from_bits((*data).EventFlag as u32).unwrap(), + user_data: &mut *((*data).UserData as *mut UserData<'_, T>), + } + }; + + // check this callback. + match callback_data.event_flag { + InputTextFlags::CALLBACK_ALWAYS => { + let text_info = unsafe { TextCallbackData::new(&mut *data) }; + callback_data.user_data.cback_handler.on_always(text_info); + } + InputTextFlags::CALLBACK_EDIT => { + let text_info = unsafe { TextCallbackData::new(&mut *data) }; + + callback_data.user_data.cback_handler.on_edit(text_info); + } + InputTextFlags::CALLBACK_COMPLETION => { + let text_info = unsafe { TextCallbackData::new(&mut *data) }; + callback_data + .user_data + .cback_handler + .on_completion(text_info); + } + InputTextFlags::CALLBACK_RESIZE => { + unsafe { + let requested_size = (*data).BufTextLen as usize; + + // just confirm that we ARE working with our string. + debug_assert_eq!( + callback_data.user_data.container.as_ptr() as *const _, + (*data).Buf + ); + + if requested_size > callback_data.user_data.container.capacity() { + // reserve more data... + callback_data + .user_data + .container + .reserve(requested_size - callback_data.user_data.container.capacity()); + + (*data).Buf = callback_data.user_data.container.as_mut_ptr() as *mut _; + (*data).BufDirty = true; + } + } + } + InputTextFlags::CALLBACK_CHAR_FILTER => { + let chr = unsafe { std::char::from_u32((*data).EventChar).unwrap() }; + let new_data = match callback_data.user_data.cback_handler.char_filter(chr) { + Some(value) => u32::from(value), + // 0 means "do not use this char" in imgui docs + None => 0, + }; + // set the new char... + unsafe { + (*data).EventChar = new_data; + } + } + InputTextFlags::CALLBACK_HISTORY => { + let key = unsafe { + let key = (*data).EventKey as u32; + match key { + sys::ImGuiKey_UpArrow => HistoryDirection::Up, + sys::ImGuiKey_DownArrow => HistoryDirection::Down, + _ => panic!("Unexpected key"), + } + }; + let text_info = unsafe { TextCallbackData::new(&mut *data) }; + + callback_data + .user_data + .cback_handler + .on_history(key, text_info); + } + + _ => {} + } + + 0 +} + +/// This is a Zst which implements TextCallbackHandler as a passthrough. +/// +/// If you do not set a callback handler, this will be used (but will never +/// actually run, since you will not have pass imgui any flags). +pub struct PassthroughCallback; +impl InputTextCallbackHandler for PassthroughCallback {} diff --git a/plugins/libimhex-rust/imgui-rs/src/internal.rs b/plugins/libimhex-rust/imgui-rs/src/internal.rs new file mode 100644 index 000000000..a34613e34 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/internal.rs @@ -0,0 +1,159 @@ +//! Internal raw utilities (don't use unless you know what you're doing!) + +use std::slice; + +/// A generic version of the raw imgui-sys ImVector struct types +#[repr(C)] +pub struct ImVector { + size: i32, + capacity: i32, + pub(crate) data: *mut T, +} + +impl ImVector { + #[inline] + pub fn as_slice(&self) -> &[T] { + unsafe { slice::from_raw_parts(self.data, self.size as usize) } + } +} + +#[test] +#[cfg(test)] +fn test_imvector_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::>(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::>(), + mem::align_of::() + ); + use sys::ImVector_char; + type VectorChar = ImVector; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(VectorChar, $l), + memoffset::offset_of!(ImVector_char, $r) + ); + }; + } + assert_field_offset!(size, Size); + assert_field_offset!(capacity, Capacity); + assert_field_offset!(data, Data); +} + +/// Marks a type as a transparent wrapper over a raw type +pub trait RawWrapper { + /// Wrapped raw type + type Raw; + /// Returns an immutable reference to the wrapped raw value + /// + /// # Safety + /// + /// It is up to the caller to use the returned raw reference without causing undefined + /// behaviour or breaking safety rules. + unsafe fn raw(&self) -> &Self::Raw; + /// Returns a mutable reference to the wrapped raw value + /// + /// # Safety + /// + /// It is up to the caller to use the returned mutable raw reference without causing undefined + /// behaviour or breaking safety rules. + unsafe fn raw_mut(&mut self) -> &mut Self::Raw; +} + +/// Casting from/to a raw type that has the same layout and alignment as the target type +pub unsafe trait RawCast: Sized { + /// Casts an immutable reference from the raw type + /// + /// # Safety + /// + /// It is up to the caller to guarantee the cast is valid. + #[inline] + unsafe fn from_raw(raw: &T) -> &Self { + &*(raw as *const _ as *const Self) + } + /// Casts a mutable reference from the raw type + /// + /// # Safety + /// + /// It is up to the caller to guarantee the cast is valid. + #[inline] + unsafe fn from_raw_mut(raw: &mut T) -> &mut Self { + &mut *(raw as *mut _ as *mut Self) + } + /// Casts an immutable reference to the raw type + /// + /// # Safety + /// + /// It is up to the caller to guarantee the cast is valid. + #[inline] + unsafe fn raw(&self) -> &T { + &*(self as *const _ as *const T) + } + /// Casts a mutable reference to the raw type + /// + /// # Safety + /// + /// It is up to the caller to guarantee the cast is valid. + #[inline] + unsafe fn raw_mut(&mut self) -> &mut T { + &mut *(self as *mut _ as *mut T) + } +} + +/// A primary data type +#[repr(u32)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum DataType { + I8 = sys::ImGuiDataType_S8, + U8 = sys::ImGuiDataType_U8, + I16 = sys::ImGuiDataType_S16, + U16 = sys::ImGuiDataType_U16, + I32 = sys::ImGuiDataType_S32, + U32 = sys::ImGuiDataType_U32, + I64 = sys::ImGuiDataType_S64, + U64 = sys::ImGuiDataType_U64, + F32 = sys::ImGuiDataType_Float, + F64 = sys::ImGuiDataType_Double, +} + +/// Primitive type marker. +/// +/// If this trait is implemented for a type, it is assumed to have *exactly* the same +/// representation in memory as the primitive value described by the associated `KIND` constant. +pub unsafe trait DataTypeKind: Copy { + const KIND: DataType; +} +unsafe impl DataTypeKind for i8 { + const KIND: DataType = DataType::I8; +} +unsafe impl DataTypeKind for u8 { + const KIND: DataType = DataType::U8; +} +unsafe impl DataTypeKind for i16 { + const KIND: DataType = DataType::I16; +} +unsafe impl DataTypeKind for u16 { + const KIND: DataType = DataType::U16; +} +unsafe impl DataTypeKind for i32 { + const KIND: DataType = DataType::I32; +} +unsafe impl DataTypeKind for u32 { + const KIND: DataType = DataType::U32; +} +unsafe impl DataTypeKind for i64 { + const KIND: DataType = DataType::I64; +} +unsafe impl DataTypeKind for u64 { + const KIND: DataType = DataType::U64; +} +unsafe impl DataTypeKind for f32 { + const KIND: DataType = DataType::F32; +} +unsafe impl DataTypeKind for f64 { + const KIND: DataType = DataType::F64; +} diff --git a/plugins/libimhex-rust/imgui-rs/src/io.rs b/plugins/libimhex-rust/imgui-rs/src/io.rs new file mode 100644 index 000000000..cc01ba124 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/io.rs @@ -0,0 +1,506 @@ +use bitflags::bitflags; +use std::f32; +use std::ops::{Index, IndexMut}; +use std::os::raw::{c_char, c_int, c_void}; +use std::time::Duration; + +use crate::fonts::atlas::FontAtlas; +use crate::fonts::font::Font; +use crate::input::keyboard::Key; +use crate::input::mouse::MouseButton; +use crate::internal::{ImVector, RawCast}; +use crate::sys; + +bitflags! { + /// Configuration flags + #[repr(transparent)] + pub struct ConfigFlags: u32 { + /// Master keyboard navigation enable flag. + /// + /// `frame()` will automatically fill `io.nav_inputs` based on `io.keys_down`. + const NAV_ENABLE_KEYBOARD = sys::ImGuiConfigFlags_NavEnableKeyboard; + /// Master gamepad navigation enable flag. + /// + /// This is mostly to instruct the backend to fill `io.nav_inputs`. The backend + /// also needs to set `BackendFlags::HasGamepad`. + const NAV_ENABLE_GAMEPAD = sys::ImGuiConfigFlags_NavEnableGamepad; + /// Instruction navigation to move the mouse cursor. + /// + /// May be useful on TV/console systems where moving a virtual mouse is awkward. + /// Will update `io.mouse_pos` and set `io.want_set_mouse_pos = true`. If enabled, + /// you *must* honor `io.want_set_mouse_pos`, or imgui-rs will react as if the mouse is + /// jumping around back and forth. + const NAV_ENABLE_SET_MOUSE_POS = sys::ImGuiConfigFlags_NavEnableSetMousePos; + /// Instruction navigation to not set the `io.want_capture_keyboard` flag when + /// `io.nav_active` is set. + const NAV_NO_CAPTURE_KEYBOARD = sys::ImGuiConfigFlags_NavNoCaptureKeyboard; + /// Instruction imgui-rs to clear mouse position/buttons in `frame()`. + /// + /// This allows ignoring the mouse information set by the backend. + const NO_MOUSE = sys::ImGuiConfigFlags_NoMouse; + /// Instruction backend to not alter mouse cursor shape and visibility. + /// + /// Use if the backend cursor changes are interfering with yours and you don't want to use + /// `set_mouse_cursor` to change the mouse cursor. You may want to honor requests from + /// imgui-rs by reading `get_mouse_cursor` yourself instead. + const NO_MOUSE_CURSOR_CHANGE = sys::ImGuiConfigFlags_NoMouseCursorChange; + /// Application is SRGB-aware. + /// + /// Not used by core imgui-rs. + const IS_SRGB = sys::ImGuiConfigFlags_IsSRGB; + /// Application is using a touch screen instead of a mouse. + /// + /// Not used by core imgui-rs. + const IS_TOUCH_SCREEN = sys::ImGuiConfigFlags_IsTouchScreen; + } +} + +bitflags! { + /// Backend capabilities + #[repr(transparent)] + pub struct BackendFlags: u32 { + /// Backend supports gamepad and currently has one connected + const HAS_GAMEPAD = sys::ImGuiBackendFlags_HasGamepad; + /// Backend supports honoring `get_mouse_cursor` value to change the OS cursor shape + const HAS_MOUSE_CURSORS = sys::ImGuiBackendFlags_HasMouseCursors; + /// Backend supports `io.want_set_mouse_pos` requests to reposition the OS mouse position. + /// + /// Only used if `ConfigFlags::NavEnableSetMousePos` is set. + const HAS_SET_MOUSE_POS = sys::ImGuiBackendFlags_HasSetMousePos; + /// Backend renderer supports DrawCmd::vtx_offset. + /// + /// This enables output of large meshes (64K+ vertices) while still using 16-bits indices. + const RENDERER_HAS_VTX_OFFSET = sys::ImGuiBackendFlags_RendererHasVtxOffset; + } +} + +/// An input identifier for navigation +#[repr(u32)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +pub enum NavInput { + Activate = sys::ImGuiNavInput_Activate, + Cancel = sys::ImGuiNavInput_Cancel, + Input = sys::ImGuiNavInput_Input, + Menu = sys::ImGuiNavInput_Menu, + DpadLeft = sys::ImGuiNavInput_DpadLeft, + DpadRight = sys::ImGuiNavInput_DpadRight, + DpadUp = sys::ImGuiNavInput_DpadUp, + DpadDown = sys::ImGuiNavInput_DpadDown, + LStickLeft = sys::ImGuiNavInput_LStickLeft, + LStickRight = sys::ImGuiNavInput_LStickRight, + LStickUp = sys::ImGuiNavInput_LStickUp, + LStickDown = sys::ImGuiNavInput_LStickDown, + FocusPrev = sys::ImGuiNavInput_FocusPrev, + FocusNext = sys::ImGuiNavInput_FocusNext, + TweakSlow = sys::ImGuiNavInput_TweakSlow, + TweakFast = sys::ImGuiNavInput_TweakFast, +} + +impl NavInput { + /// All possible `NavInput` variants + pub const VARIANTS: [NavInput; NavInput::COUNT] = [ + NavInput::Activate, + NavInput::Cancel, + NavInput::Input, + NavInput::Menu, + NavInput::DpadLeft, + NavInput::DpadRight, + NavInput::DpadUp, + NavInput::DpadDown, + NavInput::LStickLeft, + NavInput::LStickRight, + NavInput::LStickUp, + NavInput::LStickDown, + NavInput::FocusPrev, + NavInput::FocusNext, + NavInput::TweakSlow, + NavInput::TweakFast, + ]; + /// Amount of internal/hidden variants (not exposed by imgui-rs) + const INTERNAL_COUNT: usize = 4; + /// Total count of `NavInput` variants + pub const COUNT: usize = sys::ImGuiNavInput_COUNT as usize - NavInput::INTERNAL_COUNT; +} + +#[test] +fn test_nav_input_variants() { + for (idx, &value) in NavInput::VARIANTS.iter().enumerate() { + assert_eq!(idx, value as usize); + } +} + +/// Settings and inputs/outputs for imgui-rs +#[repr(C)] +pub struct Io { + /// Flags set by user/application + pub config_flags: ConfigFlags, + /// Flags set by backend + pub backend_flags: BackendFlags, + /// Main display size in pixels + pub display_size: [f32; 2], + /// Time elapsed since last frame, in seconds + pub delta_time: f32, + /// Minimum time between saving positions/sizes to .ini file, in seconds + pub ini_saving_rate: f32, + + pub(crate) ini_filename: *const c_char, + pub(crate) log_filename: *const c_char, + + /// Time for a double-click, in seconds + pub mouse_double_click_time: f32, + /// Distance threshold to stay in to validate a double-click, in pixels + pub mouse_double_click_max_dist: f32, + /// Distance threshold before considering we are dragging + pub mouse_drag_threshold: f32, + /// Map of indices into the `keys_down` entries array, which represent your "native" keyboard + /// state + pub key_map: [u32; sys::ImGuiKey_COUNT as usize], + /// When holding a key/button, time before it starts repeating, in seconds + pub key_repeat_delay: f32, + /// When holding a key/button, rate at which it repeats, in seconds + pub key_repeat_rate: f32, + + user_data: *mut c_void, + pub(crate) fonts: *mut FontAtlas, + + /// Global scale for all fonts + pub font_global_scale: f32, + /// Allow user to scale text of individual window with CTRL+wheel + pub font_allow_user_scaling: bool, + + pub(crate) font_default: *mut Font, + + /// For retina display or other situations where window coordinates are different from + /// framebuffer coordinates + pub display_framebuffer_scale: [f32; 2], + + /// Request imgui-rs to draw a mouse cursor for you + pub mouse_draw_cursor: bool, + /// macOS-style input behavior. + /// + /// Defaults to true on Apple platforms. Changes in behavior: + /// + /// * Text editing cursor movement using Alt instead of Ctrl + /// * Shortcuts using Cmd/Super instead of Ctrl + /// * Line/text start and end using Cmd+Arrows instead of Home/End + /// * Double-click selects by word instead of selecting the whole text + /// * Multi-selection in lists uses Cmd/Super instead of Ctrl + pub config_mac_os_behaviors: bool, + /// Set to false to disable blinking cursor + pub config_input_text_cursor_blink: bool, + /// Enable turning DragXXX widgets into text input with a simple mouse + /// click-release (without moving). Not desirable on devices without a + /// keyboard. + pub config_drag_click_to_input_text: bool, + /// Enable resizing of windows from their edges and from the lower-left corner. + /// + /// Requires `HasMouserCursors` in `backend_flags`, because it needs mouse cursor feedback. + pub config_windows_resize_from_edges: bool, + /// Set to true to only allow moving windows when clicked+dragged from the title bar. + /// + /// Windows without a title bar are not affected. + pub config_windows_move_from_title_bar_only: bool, + /// Compact memory usage when unused. + /// + /// Set to -1.0 to disable. + pub config_memory_compact_timer: f32, + + pub(crate) backend_platform_name: *const c_char, + pub(crate) backend_renderer_name: *const c_char, + backend_platform_user_data: *mut c_void, + backend_renderer_user_data: *mut c_void, + backend_language_user_data: *mut c_void, + pub(crate) get_clipboard_text_fn: + Option *const c_char>, + pub(crate) set_clipboard_text_fn: + Option, + pub(crate) clipboard_user_data: *mut c_void, + ime_set_input_screen_pos_fn: Option, + ime_window_handle: *mut c_void, + /// Mouse position, in pixels. + /// + /// Set to [f32::MAX, f32::MAX] if mouse is unavailable (on another screen, etc.). + pub mouse_pos: [f32; 2], + /// Mouse buttons: 0=left, 1=right, 2=middle + extras + pub mouse_down: [bool; 5], + /// Mouse wheel (vertical). + /// + /// 1 unit scrolls about 5 lines of text. + pub mouse_wheel: f32, + /// Mouse wheel (horizontal). + /// + /// Most users don't have a mouse with a horizontal wheel, and may not be filled by all + /// backends. + pub mouse_wheel_h: f32, + /// Keyboard modifier pressed: Control + pub key_ctrl: bool, + /// Keyboard modifier pressed: Shift + pub key_shift: bool, + /// Keyboard modifier pressed: Alt + pub key_alt: bool, + /// Keyboard modifier pressed: Cmd/Super/Windows + pub key_super: bool, + /// Keyboard keys that are pressed (indexing defined by the user/application) + pub keys_down: [bool; 512], + /// Gamepad inputs. + /// + /// Cleared back to zero after each frame. Keyboard keys will be auto-mapped and written + /// here by `frame()`. + pub nav_inputs: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], + /// When true, imgui-rs will use the mouse inputs, so do not dispatch them to your main + /// game/application + pub want_capture_mouse: bool, + /// When true, imgui-rs will use the keyboard inputs, so do not dispatch them to your main + /// game/application + pub want_capture_keyboard: bool, + /// Mobile/console: when true, you may display an on-screen keyboard. + /// + /// This is set by imgui-rs when it wants textual keyboard input to happen. + pub want_text_input: bool, + /// Mouse position has been altered, so the backend should reposition the mouse on the next + /// frame. + /// + /// Set only when `ConfigFlags::NavEnableSetMousePos` is enabled. + pub want_set_mouse_pos: bool, + /// When manual .ini load/save is active (`ini_filename` is `None`), this will be set to notify + /// your application that you can call `save_ini_settings` and save the settings yourself. + /// + /// *Important*: You need to clear this flag yourself + pub want_save_ini_settings: bool, + /// Keyboard/Gamepad navigation is currently allowed + pub nav_active: bool, + /// Keyboard/Gamepad navigation is visible and allowed + pub nav_visible: bool, + /// Application framerate estimation, in frames per second. + /// + /// Rolling average estimation based on `io.delta_time` over 120 frames. + pub framerate: f32, + /// Vertices output during last rendering + pub metrics_render_vertices: i32, + /// Indices output during last rendering (= number of triangles * 3) + pub metrics_render_indices: i32, + /// Number of visible windows + pub metrics_render_windows: i32, + /// Number of active windows + pub metrics_active_windows: i32, + /// Number of active internal imgui-rs allocations + pub metrics_active_allocations: i32, + /// Mouse delta. + /// + /// Note that this is zero if either current or previous position is invalid ([f32::MAX, + /// f32::MAX]), so a disappearing/reappearing mouse won't have a huge delta. + pub mouse_delta: [f32; 2], + + key_mods: sys::ImGuiKeyModFlags, + key_mods_prev: sys::ImGuiKeyModFlags, + mouse_pos_prev: [f32; 2], + mouse_clicked_pos: [[f32; 2]; 5], + mouse_clicked_time: [f64; 5], + mouse_clicked: [bool; 5], + mouse_double_clicked: [bool; 5], + mouse_released: [bool; 5], + mouse_down_owned: [bool; 5], + mouse_down_was_double_click: [bool; 5], + mouse_down_duration: [f32; 5], + mouse_down_duration_prev: [f32; 5], + mouse_drag_max_distance_abs: [[f32; 2]; 5], + mouse_drag_max_distance_sqr: [f32; 5], + keys_down_duration: [f32; 512], + keys_down_duration_prev: [f32; 512], + nav_inputs_down_duration: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], + nav_inputs_down_duration_prev: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT], + pen_pressure: f32, + input_queue_surrogate: sys::ImWchar16, + input_queue_characters: ImVector, +} + +unsafe impl RawCast for Io {} + +impl Io { + /// Queue new character input + #[doc(alias = "AddInputCharactersUTF8")] + pub fn add_input_character(&mut self, character: char) { + let mut buf = [0; 5]; + character.encode_utf8(&mut buf); + unsafe { + sys::ImGuiIO_AddInputCharactersUTF8(self.raw_mut(), buf.as_ptr() as *const _); + } + } + /// Clear character input buffer + #[doc(alias = "ClearCharacters")] + pub fn clear_input_characters(&mut self) { + unsafe { + sys::ImGuiIO_ClearInputCharacters(self.raw_mut()); + } + } + /// Peek character input buffer, return a copy of entire buffer + pub fn peek_input_characters(&self) -> String { + self.input_queue_characters().collect() + } + + /// Returns a view of the data in the input queue (without copying it). + /// + /// The returned iterator is a simple mapping over a slice more or less what + /// you need for random access to the data (Rust has no + /// `RandomAccessIterator`, or we'd use that). + pub fn input_queue_characters( + &self, + ) -> impl Iterator + DoubleEndedIterator + ExactSizeIterator + Clone + '_ { + self.input_queue_characters + .as_slice() + .iter() + // TODO: are the values in the buffer guaranteed to be valid unicode + // scalar values? if so we can just expose this as a `&[char]`... + .map(|c| core::char::from_u32(*c).unwrap_or(core::char::REPLACEMENT_CHARACTER)) + } + + pub fn update_delta_time(&mut self, delta: Duration) { + let delta_s = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1_000_000_000.0; + if delta_s > 0.0 { + self.delta_time = delta_s; + } else { + self.delta_time = f32::MIN_POSITIVE; + } + self.delta_time = delta_s; + } +} + +impl Index for Io { + type Output = u32; + fn index(&self, index: Key) -> &u32 { + &self.key_map[index as usize] + } +} + +impl IndexMut for Io { + fn index_mut(&mut self, index: Key) -> &mut u32 { + &mut self.key_map[index as usize] + } +} + +impl Index for Io { + type Output = f32; + fn index(&self, index: NavInput) -> &f32 { + &self.nav_inputs[index as usize] + } +} + +impl IndexMut for Io { + fn index_mut(&mut self, index: NavInput) -> &mut f32 { + &mut self.nav_inputs[index as usize] + } +} + +impl Index for Io { + type Output = bool; + fn index(&self, index: MouseButton) -> &bool { + &self.mouse_down[index as usize] + } +} + +impl IndexMut for Io { + fn index_mut(&mut self, index: MouseButton) -> &mut bool { + &mut self.mouse_down[index as usize] + } +} + +#[test] +#[cfg(test)] +fn test_io_memory_layout() { + use std::mem; + assert_eq!(mem::size_of::(), mem::size_of::()); + assert_eq!(mem::align_of::(), mem::align_of::()); + use sys::ImGuiIO; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(Io, $l), + memoffset::offset_of!(ImGuiIO, $r) + ); + }; + } + assert_field_offset!(config_flags, ConfigFlags); + assert_field_offset!(backend_flags, BackendFlags); + assert_field_offset!(display_size, DisplaySize); + assert_field_offset!(delta_time, DeltaTime); + assert_field_offset!(ini_saving_rate, IniSavingRate); + assert_field_offset!(ini_filename, IniFilename); + assert_field_offset!(log_filename, LogFilename); + assert_field_offset!(mouse_double_click_time, MouseDoubleClickTime); + assert_field_offset!(mouse_double_click_max_dist, MouseDoubleClickMaxDist); + assert_field_offset!(mouse_drag_threshold, MouseDragThreshold); + assert_field_offset!(key_map, KeyMap); + assert_field_offset!(key_repeat_delay, KeyRepeatDelay); + assert_field_offset!(key_repeat_rate, KeyRepeatRate); + assert_field_offset!(user_data, UserData); + assert_field_offset!(fonts, Fonts); + assert_field_offset!(font_global_scale, FontGlobalScale); + assert_field_offset!(font_allow_user_scaling, FontAllowUserScaling); + assert_field_offset!(font_default, FontDefault); + assert_field_offset!(display_framebuffer_scale, DisplayFramebufferScale); + assert_field_offset!(mouse_draw_cursor, MouseDrawCursor); + assert_field_offset!(config_mac_os_behaviors, ConfigMacOSXBehaviors); + assert_field_offset!(config_input_text_cursor_blink, ConfigInputTextCursorBlink); + assert_field_offset!( + config_windows_resize_from_edges, + ConfigWindowsResizeFromEdges + ); + assert_field_offset!( + config_windows_move_from_title_bar_only, + ConfigWindowsMoveFromTitleBarOnly + ); + assert_field_offset!(backend_platform_name, BackendPlatformName); + assert_field_offset!(backend_renderer_name, BackendRendererName); + assert_field_offset!(backend_platform_user_data, BackendPlatformUserData); + assert_field_offset!(backend_renderer_user_data, BackendRendererUserData); + assert_field_offset!(backend_language_user_data, BackendLanguageUserData); + assert_field_offset!(get_clipboard_text_fn, GetClipboardTextFn); + assert_field_offset!(set_clipboard_text_fn, SetClipboardTextFn); + assert_field_offset!(clipboard_user_data, ClipboardUserData); + assert_field_offset!(ime_set_input_screen_pos_fn, ImeSetInputScreenPosFn); + assert_field_offset!(ime_window_handle, ImeWindowHandle); + assert_field_offset!(mouse_pos, MousePos); + assert_field_offset!(mouse_down, MouseDown); + assert_field_offset!(mouse_wheel, MouseWheel); + assert_field_offset!(mouse_wheel_h, MouseWheelH); + assert_field_offset!(key_ctrl, KeyCtrl); + assert_field_offset!(key_shift, KeyShift); + assert_field_offset!(key_alt, KeyAlt); + assert_field_offset!(key_super, KeySuper); + assert_field_offset!(keys_down, KeysDown); + assert_field_offset!(nav_inputs, NavInputs); + assert_field_offset!(want_capture_mouse, WantCaptureMouse); + assert_field_offset!(want_capture_keyboard, WantCaptureKeyboard); + assert_field_offset!(want_text_input, WantTextInput); + assert_field_offset!(want_set_mouse_pos, WantSetMousePos); + assert_field_offset!(want_save_ini_settings, WantSaveIniSettings); + assert_field_offset!(nav_active, NavActive); + assert_field_offset!(nav_visible, NavVisible); + assert_field_offset!(framerate, Framerate); + assert_field_offset!(metrics_render_vertices, MetricsRenderVertices); + assert_field_offset!(metrics_render_indices, MetricsRenderIndices); + assert_field_offset!(metrics_render_windows, MetricsRenderWindows); + assert_field_offset!(metrics_active_windows, MetricsActiveWindows); + assert_field_offset!(metrics_active_allocations, MetricsActiveAllocations); + assert_field_offset!(mouse_delta, MouseDelta); + assert_field_offset!(key_mods, KeyMods); + assert_field_offset!(mouse_pos_prev, MousePosPrev); + assert_field_offset!(mouse_clicked_pos, MouseClickedPos); + assert_field_offset!(mouse_clicked_time, MouseClickedTime); + assert_field_offset!(mouse_clicked, MouseClicked); + assert_field_offset!(mouse_double_clicked, MouseDoubleClicked); + assert_field_offset!(mouse_released, MouseReleased); + assert_field_offset!(mouse_down_owned, MouseDownOwned); + assert_field_offset!(mouse_down_was_double_click, MouseDownWasDoubleClick); + assert_field_offset!(mouse_down_duration, MouseDownDuration); + assert_field_offset!(mouse_down_duration_prev, MouseDownDurationPrev); + assert_field_offset!(mouse_drag_max_distance_abs, MouseDragMaxDistanceAbs); + assert_field_offset!(mouse_drag_max_distance_sqr, MouseDragMaxDistanceSqr); + assert_field_offset!(keys_down_duration, KeysDownDuration); + assert_field_offset!(keys_down_duration_prev, KeysDownDurationPrev); + assert_field_offset!(nav_inputs_down_duration, NavInputsDownDuration); + assert_field_offset!(nav_inputs_down_duration_prev, NavInputsDownDurationPrev); + assert_field_offset!(pen_pressure, PenPressure); + assert_field_offset!(input_queue_surrogate, InputQueueSurrogate); + assert_field_offset!(input_queue_characters, InputQueueCharacters); +} diff --git a/plugins/libimhex-rust/imgui-rs/src/layout.rs b/plugins/libimhex-rust/imgui-rs/src/layout.rs new file mode 100644 index 000000000..f039b17de --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/layout.rs @@ -0,0 +1,176 @@ +use crate::sys; +use crate::Ui; + +create_token!( + /// Tracks a layout group that can be ended with `end` or by dropping. + pub struct GroupToken<'ui>; + + /// Drops the layout group manually. You can also just allow this token + /// to drop on its own. + drop { sys::igEndGroup() } +); + +/// # Cursor / Layout +impl<'ui> Ui<'ui> { + /// Renders a separator (generally horizontal). + /// + /// This becomes a vertical separator inside a menu bar or in horizontal layout mode. + #[doc(alias = "Separator")] + pub fn separator(&self) { + unsafe { sys::igSeparator() } + } + + /// Call between widgets or groups to layout them horizontally. + /// + /// X position is given in window coordinates. + /// + /// This is equivalent to calling [same_line_with_pos](Self::same_line_with_pos) + /// with the `pos` set to 0.0, which uses `Style::item_spacing`. + #[doc(alias = "SameLine")] + pub fn same_line(&self) { + self.same_line_with_pos(0.0); + } + + /// Call between widgets or groups to layout them horizontally. + /// + /// X position is given in window coordinates. + /// + /// This is equivalent to calling [same_line_with_spacing](Self::same_line_with_spacing) + /// with the `spacing` set to -1.0, which means no extra spacing. + #[doc(alias = "SameLine")] + pub fn same_line_with_pos(&self, pos_x: f32) { + self.same_line_with_spacing(pos_x, -1.0) + } + + /// Call between widgets or groups to layout them horizontally. + /// + /// X position is given in window coordinates. + #[doc(alias = "SameLine")] + pub fn same_line_with_spacing(&self, pos_x: f32, spacing_w: f32) { + unsafe { sys::igSameLine(pos_x, spacing_w) } + } + + /// Undo a `same_line` call or force a new line when in horizontal layout mode + #[doc(alias = "NewLine")] + pub fn new_line(&self) { + unsafe { sys::igNewLine() } + } + /// Adds vertical spacing + #[doc(alias = "Spacing")] + pub fn spacing(&self) { + unsafe { sys::igSpacing() } + } + /// Fills a space of `size` in pixels with nothing on the current window. + /// + /// Can be used to move the cursor on the window. + #[doc(alias = "Dummy")] + pub fn dummy(&self, size: [f32; 2]) { + unsafe { sys::igDummy(size.into()) } + } + + /// Moves content position to the right by `Style::indent_spacing` + /// + /// This is equivalent to [indent_by](Self::indent_by) with `width` set to + /// `Style::ident_spacing`. + #[doc(alias = "Indent")] + pub fn indent(&self) { + self.indent_by(0.0) + } + + /// Moves content position to the right by `width` + #[doc(alias = "Indent")] + pub fn indent_by(&self, width: f32) { + unsafe { sys::igIndent(width) }; + } + /// Moves content position to the left by `Style::indent_spacing` + /// + /// This is equivalent to [unindent_by](Self::unindent_by) with `width` set to + /// `Style::ident_spacing`. + #[doc(alias = "Unindent")] + pub fn unindent(&self) { + self.unindent_by(0.0) + } + /// Moves content position to the left by `width` + #[doc(alias = "Unindent")] + pub fn unindent_by(&self, width: f32) { + unsafe { sys::igUnindent(width) }; + } + /// Groups items together as a single item. + /// + /// May be useful to handle the same mouse event on a group of items, for example. + /// + /// Returns a `GroupToken` that must be ended by calling `.end()` + #[doc(alias = "BeginGroup")] + pub fn begin_group(&self) -> GroupToken<'_> { + unsafe { sys::igBeginGroup() }; + GroupToken::new(self) + } + /// Creates a layout group and runs a closure to construct the contents. + /// + /// May be useful to handle the same mouse event on a group of items, for example. + #[doc(alias = "BeginGroup")] + pub fn group R>(&self, f: F) -> R { + let group = self.begin_group(); + let result = f(); + group.end(); + result + } + /// Returns the cursor position (in window coordinates) + #[doc(alias = "GetCursorPos")] + pub fn cursor_pos(&self) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetCursorPos(&mut out) }; + out.into() + } + /// Sets the cursor position (in window coordinates). + /// + /// This sets the point on which the next widget will be drawn. + #[doc(alias = "SetCursorPos")] + pub fn set_cursor_pos(&self, pos: [f32; 2]) { + unsafe { sys::igSetCursorPos(pos.into()) }; + } + /// Returns the initial cursor position (in window coordinates) + #[doc(alias = "GetCursorStartPos")] + pub fn cursor_start_pos(&self) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetCursorStartPos(&mut out) }; + out.into() + } + /// Returns the cursor position (in absolute screen coordinates). + /// + /// This is especially useful for drawing, as the drawing API uses screen coordinates. + #[doc(alias = "GetCursorScreenPos")] + pub fn cursor_screen_pos(&self) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + unsafe { sys::igGetCursorScreenPos(&mut out) }; + out.into() + } + /// Sets the cursor position (in absolute screen coordinates) + #[doc(alias = "SetCursorScreenPos")] + pub fn set_cursor_screen_pos(&self, pos: [f32; 2]) { + unsafe { sys::igSetCursorScreenPos(pos.into()) } + } + /// Vertically aligns text baseline so that it will align properly to regularly frame items. + /// + /// Call this if you have text on a line before a framed item. + #[doc(alias = "AlignTextToFramePadding")] + pub fn align_text_to_frame_padding(&self) { + unsafe { sys::igAlignTextToFramePadding() }; + } + #[doc(alias = "GetTextLineHeight")] + pub fn text_line_height(&self) -> f32 { + unsafe { sys::igGetTextLineHeight() } + } + #[doc(alias = "GetTextLineHeightWithSpacing")] + pub fn text_line_height_with_spacing(&self) -> f32 { + unsafe { sys::igGetTextLineHeightWithSpacing() } + } + #[doc(alias = "GetFrameHeight")] + pub fn frame_height(&self) -> f32 { + unsafe { sys::igGetFrameHeight() } + } + #[doc(alias = "GetFrameLineHeightWithSpacing")] + pub fn frame_height_with_spacing(&self) -> f32 { + unsafe { sys::igGetFrameHeightWithSpacing() } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/lib.rs b/plugins/libimhex-rust/imgui-rs/src/lib.rs new file mode 100644 index 000000000..929636ef8 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/lib.rs @@ -0,0 +1,753 @@ +#![cfg_attr(test, allow(clippy::float_cmp))] +#![deny(rust_2018_idioms)] +// #![deny(missing_docs)] + +pub extern crate imgui_sys as sys; + +use std::cell; +use std::ffi::CStr; +use std::os::raw::{c_char, c_void}; +use std::ptr; +use std::str; +use std::thread; + +pub use self::clipboard::*; +pub use self::color::ImColor32; +pub use self::context::*; +pub use self::drag_drop::{DragDropFlags, DragDropSource, DragDropTarget}; +pub use self::draw_list::{ChannelsSplit, DrawListMut}; +pub use self::fonts::atlas::*; +pub use self::fonts::font::*; +pub use self::fonts::glyph::*; +pub use self::fonts::glyph_ranges::*; +pub use self::input::keyboard::*; +pub use self::input::mouse::*; +pub use self::input_widget::*; +pub use self::io::*; +pub use self::layout::*; +pub use self::list_clipper::ListClipper; +pub use self::plothistogram::PlotHistogram; +pub use self::plotlines::PlotLines; +pub use self::popups::*; +pub use self::render::draw_data::*; +pub use self::render::renderer::*; +pub use self::stacks::*; +pub use self::string::*; +pub use self::style::*; + +#[cfg(feature = "tables-api")] +pub use self::tables::*; +pub use self::utils::*; +pub use self::widget::color_editors::*; +pub use self::widget::combo_box::*; +pub use self::widget::drag::*; +pub use self::widget::image::*; +pub use self::widget::list_box::*; +pub use self::widget::menu::*; +pub use self::widget::misc::*; +pub use self::widget::progress_bar::*; +pub use self::widget::selectable::*; +pub use self::widget::slider::*; +pub use self::widget::tab::*; +pub use self::widget::tree::*; +pub use self::window::child_window::*; +pub use self::window::*; +use internal::RawCast; + +#[macro_use] +mod string; + +#[macro_use] +mod tokens; + +mod clipboard; +pub mod color; +mod columns; +mod context; +pub mod drag_drop; +pub mod draw_list; +mod fonts; +mod input; +mod input_widget; +pub mod internal; +mod io; +mod layout; +mod list_clipper; +mod plothistogram; +mod plotlines; +mod popups; +mod render; +mod stacks; +mod style; +#[cfg(feature = "tables-api")] +mod tables; +#[cfg(test)] +mod test; +mod utils; +mod widget; +mod window; + +// Used by macros. Underscores are just to make it clear it's not part of the +// public API. +#[doc(hidden)] +pub use core as __core; + +/// Returns the underlying Dear ImGui library version +#[doc(alias = "GetVersion")] +pub fn dear_imgui_version() -> &'static str { + unsafe { + let bytes = CStr::from_ptr(sys::igGetVersion()).to_bytes(); + str::from_utf8_unchecked(bytes) + } +} + +impl Context { + /// Returns the global imgui-rs time. + /// + /// Incremented by Io::delta_time every frame. + #[doc(alias = "GetTime")] + pub fn time(&self) -> f64 { + unsafe { sys::igGetTime() } + } + /// Returns the global imgui-rs frame count. + /// + /// Incremented by 1 every frame. + #[doc(alias = "GetFrameCount")] + pub fn frame_count(&self) -> i32 { + unsafe { sys::igGetFrameCount() } + } +} + +/// A temporary reference for building the user interface for one frame +#[derive(Debug)] +pub struct Ui<'ui> { + ctx: &'ui Context, + font_atlas: Option>, + // imgui isn't mutli-threaded -- so no one will ever access twice. + buffer: cell::UnsafeCell, +} + +impl<'ui> Ui<'ui> { + /// Internal method to push a single text to our scratch buffer. + fn scratch_txt(&self, txt: impl AsRef) -> *const sys::cty::c_char { + unsafe { + let handle = &mut *self.buffer.get(); + handle.scratch_txt(txt) + } + } + + /// Internal method to push an option text to our scratch buffer. + fn scratch_txt_opt(&self, txt: Option>) -> *const sys::cty::c_char { + unsafe { + let handle = &mut *self.buffer.get(); + handle.scratch_txt_opt(txt) + } + } + + fn scratch_txt_two( + &self, + txt_0: impl AsRef, + txt_1: impl AsRef, + ) -> (*const sys::cty::c_char, *const sys::cty::c_char) { + unsafe { + let handle = &mut *self.buffer.get(); + handle.scratch_txt_two(txt_0, txt_1) + } + } + + fn scratch_txt_with_opt( + &self, + txt_0: impl AsRef, + txt_1: Option>, + ) -> (*const sys::cty::c_char, *const sys::cty::c_char) { + unsafe { + let handle = &mut *self.buffer.get(); + handle.scratch_txt_with_opt(txt_0, txt_1) + } + } + + /// Returns an immutable reference to the inputs/outputs object + #[doc(alias = "GetIO")] + pub fn io(&self) -> &Io { + unsafe { &*(sys::igGetIO() as *const Io) } + } + + /// Returns an immutable reference to the font atlas + pub fn fonts(&self) -> FontAtlasRef<'_> { + match self.font_atlas { + Some(ref font_atlas) => FontAtlasRef::Shared(font_atlas), + None => unsafe { + let fonts = &*(self.io().fonts as *const FontAtlas); + FontAtlasRef::Owned(fonts) + }, + } + } + /// Returns a clone of the user interface style + pub fn clone_style(&self) -> Style { + *self.ctx.style() + } + /// Renders the frame and returns a reference to the resulting draw data + #[doc(alias = "Render", alias = "GetDrawData")] + pub fn render(self) -> &'ui DrawData { + unsafe { + sys::igRender(); + &*(sys::igGetDrawData() as *mut DrawData) + } + } +} + +impl<'a> Drop for Ui<'a> { + #[doc(alias = "EndFrame")] + fn drop(&mut self) { + if !thread::panicking() { + unsafe { + sys::igEndFrame(); + } + } + } +} + +/// # Demo, debug, information +impl<'ui> Ui<'ui> { + /// Renders a demo window (previously called a test window), which demonstrates most + /// Dear Imgui features. + #[doc(alias = "ShowDemoWindow")] + pub fn show_demo_window(&self, opened: &mut bool) { + unsafe { + sys::igShowDemoWindow(opened); + } + } + /// Renders an about window. + /// + /// Displays the Dear ImGui version/credits, and build/system information. + #[doc(alias = "ShowAboutWindow")] + pub fn show_about_window(&self, opened: &mut bool) { + unsafe { + sys::igShowAboutWindow(opened); + } + } + /// Renders a metrics/debug window. + /// + /// Displays Dear ImGui internals: draw commands (with individual draw calls and vertices), + /// window list, basic internal state, etc. + #[doc(alias = "ShowMetricsWindow")] + pub fn show_metrics_window(&self, opened: &mut bool) { + unsafe { + sys::igShowMetricsWindow(opened); + } + } + /// Renders a style editor block (not a window) for the given `Style` structure + #[doc(alias = "ShowStyleEditor")] + pub fn show_style_editor(&self, style: &mut Style) { + unsafe { + sys::igShowStyleEditor(style.raw_mut()); + } + } + /// Renders a style editor block (not a window) for the currently active style + #[doc(alias = "ShowStyleEditor")] + pub fn show_default_style_editor(&self) { + unsafe { sys::igShowStyleEditor(ptr::null_mut()) }; + } + /// Renders a basic help/info block (not a window) + #[doc(alias = "ShowUserGuide")] + pub fn show_user_guide(&self) { + unsafe { sys::igShowUserGuide() }; + } +} + +/// Unique ID used by widgets +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Id<'a> { + Int(i32), + Str(&'a str), + Ptr(*const c_void), +} + +impl From for Id<'static> { + #[inline] + fn from(i: i32) -> Self { + Id::Int(i) + } +} + +impl<'a, T: ?Sized + AsRef> From<&'a T> for Id<'a> { + #[inline] + fn from(s: &'a T) -> Self { + Id::Str(s.as_ref()) + } +} + +impl From<*const T> for Id<'static> { + #[inline] + fn from(p: *const T) -> Self { + Id::Ptr(p as *const c_void) + } +} + +impl From<*mut T> for Id<'static> { + #[inline] + fn from(p: *mut T) -> Self { + Id::Ptr(p as *const T as *const c_void) + } +} + +impl<'a> Id<'a> { + // this is used in the tables-api and possibly elsewhere, + // but not with just default features... + #[allow(dead_code)] + fn as_imgui_id(&self) -> sys::ImGuiID { + unsafe { + match self { + Id::Ptr(p) => sys::igGetID_Ptr(*p), + Id::Str(s) => { + let s1 = s.as_ptr() as *const std::os::raw::c_char; + let s2 = s1.add(s.len()); + sys::igGetID_StrStr(s1, s2) + } + Id::Int(i) => { + let p = *i as *const std::os::raw::c_void; + sys::igGetID_Ptr(p) + } // Id::ImGuiID(n) => *n, + } + } + } +} + +impl<'a> Default for Id<'a> { + fn default() -> Self { + Self::Int(0) + } +} + +// Widgets: Input +impl<'ui> Ui<'ui> { + #[doc(alias = "InputText", alias = "InputTextWithHint")] + pub fn input_text<'p, L: AsRef>( + &'ui self, + label: L, + buf: &'p mut String, + ) -> InputText<'ui, 'p, L> { + InputText::new(self, label, buf) + } + #[doc(alias = "InputText", alias = "InputTextMultiline")] + pub fn input_text_multiline<'p, L: AsRef>( + &'ui self, + label: L, + buf: &'p mut String, + size: [f32; 2], + ) -> InputTextMultiline<'ui, 'p, L> { + InputTextMultiline::new(self, label, buf, size) + } + #[doc(alias = "InputFloat2")] + pub fn input_float<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut f32, + ) -> InputFloat<'ui, 'p, L> { + InputFloat::new(self, label, value) + } + pub fn input_float2<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [f32; 2], + ) -> InputFloat2<'ui, 'p, L> { + InputFloat2::new(self, label, value) + } + #[doc(alias = "InputFloat3")] + pub fn input_float3<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [f32; 3], + ) -> InputFloat3<'ui, 'p, L> { + InputFloat3::new(self, label, value) + } + #[doc(alias = "InputFloat4")] + pub fn input_float4<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [f32; 4], + ) -> InputFloat4<'ui, 'p, L> { + InputFloat4::new(self, label, value) + } + #[doc(alias = "InputInt")] + pub fn input_int<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut i32, + ) -> InputInt<'ui, 'p, L> { + InputInt::new(self, label, value) + } + #[doc(alias = "InputInt2")] + pub fn input_int2<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [i32; 2], + ) -> InputInt2<'ui, 'p, L> { + InputInt2::new(self, label, value) + } + #[doc(alias = "InputInt3")] + pub fn input_int3<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [i32; 3], + ) -> InputInt3<'ui, 'p, L> { + InputInt3::new(self, label, value) + } + #[doc(alias = "InputInt4")] + pub fn input_int4<'p, L: AsRef>( + &'ui self, + label: L, + value: &'p mut [i32; 4], + ) -> InputInt4<'ui, 'p, L> { + InputInt4::new(self, label, value) + } +} + +create_token!( + /// Tracks a layout tooltip that can be ended by calling `.end()` or by dropping. + pub struct TooltipToken<'ui>; + + /// Drops the layout tooltip manually. You can also just allow this token + /// to drop on its own. + drop { sys::igEndTooltip() } +); + +/// # Tooltips +impl<'ui> Ui<'ui> { + /// Construct a tooltip window that can have any kind of content. + /// + /// Typically used with `Ui::is_item_hovered()` or some other conditional check. + /// + /// # Examples + /// + /// ``` + /// # use imgui::*; + /// fn user_interface(ui: &Ui) { + /// ui.text("Hover over me"); + /// if ui.is_item_hovered() { + /// ui.tooltip(|| { + /// ui.text_colored([1.0, 0.0, 0.0, 1.0], im_str!("I'm red!")); + /// }); + /// } + /// } + /// ``` + #[doc(alias = "BeginTooltip", alias = "EndTootip")] + pub fn tooltip(&self, f: F) { + unsafe { sys::igBeginTooltip() }; + f(); + unsafe { sys::igEndTooltip() }; + } + /// Construct a tooltip window that can have any kind of content. + /// + /// Returns a `TooltipToken` that must be ended by calling `.end()` + #[doc(alias = "BeginTooltip")] + pub fn begin_tooltip(&self) -> TooltipToken<'_> { + unsafe { sys::igBeginTooltip() }; + TooltipToken::new(self) + } + /// Construct a tooltip window with simple text content. + /// + /// Typically used with `Ui::is_item_hovered()` or some other conditional check. + /// + /// # Examples + /// + /// ``` + /// # use imgui::*; + /// fn user_interface(ui: &Ui) { + /// ui.text("Hover over me"); + /// if ui.is_item_hovered() { + /// ui.tooltip_text("I'm a tooltip!"); + /// } + /// } + /// ``` + #[doc(alias = "BeginTooltip", alias = "EndTootip")] + pub fn tooltip_text>(&self, text: T) { + self.tooltip(|| self.text(text)); + } +} + +create_token!( + /// Starts a scope where interaction is disabled. Ends be calling `.end()` or when the token is dropped. + pub struct DisabledToken<'ui>; + + /// Drops the layout tooltip manually. You can also just allow this token + /// to drop on its own. + drop { sys::igEndDisabled() } +); + +/// # Disabling widgets +/// +/// imgui can disable widgets so they don't react to mouse/keyboard +/// inputs, and are displayed differently (currently dimmed by an +/// amount set in [`Style::disabled_alpha`]) +impl<'ui> Ui<'ui> { + /// Creates a scope where interactions are disabled. + /// + /// Scope ends when returned token is dropped, or `.end()` is + /// explicitly called + /// + /// # Examples + /// + /// ``` + /// # use imgui::*; + /// fn user_interface(ui: &Ui) { + /// let disable_buttons = true; + /// let _d = ui.begin_disabled(disable_buttons); + /// ui.button(im_str!("Dangerous button")); + /// } + /// ``` + + #[doc(alias = "BeginDisabled")] + pub fn begin_disabled(&self, disabled: bool) -> DisabledToken<'_> { + unsafe { sys::igBeginDisabled(disabled) }; + DisabledToken::new(self) + } + + /// Identical to [`Ui::begin_disabled`] but exists to allow avoiding a + /// double-negative, for example `begin_enabled(enable_buttons)` + /// instead of `begin_disabled(!enable_buttons)`) + #[doc(alias = "BeginDisabled")] + pub fn begin_enabled(&self, enabled: bool) -> DisabledToken<'_> { + self.begin_disabled(!enabled) + } + + /// Helper to create a disabled section of widgets + /// + /// # Examples + /// + /// ``` + /// # use imgui::*; + /// fn user_interface(ui: &Ui) { + /// let safe_mode = true; + /// ui.disabled(safe_mode, || { + /// ui.button(im_str!("Dangerous button")); + /// }); + /// } + /// ``` + #[doc(alias = "BeginDisabled", alias = "EndDisabled")] + pub fn disabled(&self, disabled: bool, f: F) { + unsafe { sys::igBeginDisabled(disabled) }; + f(); + unsafe { sys::igEndDisabled() }; + } + + /// Same as [`Ui::disabled`] but with logic reversed. See + /// [`Ui::begin_enabled`]. + #[doc(alias = "BeginDisabled", alias = "EndDisabled")] + pub fn enabled(&self, enabled: bool, f: F) { + unsafe { sys::igBeginDisabled(!enabled) }; + f(); + unsafe { sys::igEndDisabled() }; + } +} + +// Widgets: ListBox +impl<'ui> Ui<'ui> { + #[doc(alias = "ListBox")] + pub fn list_box<'p, StringType: AsRef + ?Sized>( + &self, + label: impl AsRef, + current_item: &mut i32, + items: &'p [&'p StringType], + height_in_items: i32, + ) -> bool { + let (label_ptr, items_inner) = unsafe { + let handle = &mut *self.buffer.get(); + + handle.refresh_buffer(); + let label_ptr = handle.push(label); + + let items_inner: Vec<_> = items.iter().map(|&v| handle.push(v)).collect(); + + (label_ptr, items_inner) + }; + + unsafe { + sys::igListBox_Str_arr( + label_ptr, + current_item, + items_inner.as_ptr() as *mut *const c_char, + items_inner.len() as i32, + height_in_items, + ) + } + } + + // written out for the future times... + // #[doc(alias = "ListBox")] + // pub fn list_box_const<'p, StringType: AsRef + ?Sized, const N: usize>( + // &self, + // label: impl AsRef, + // current_item: &mut i32, + // items: [&'p StringType; N], + // height_in_items: i32, + // ) -> bool { + // let (label_ptr, items_inner) = unsafe { + // let handle = &mut *self.buffer.get(); + + // handle.refresh_buffer(); + // let label_ptr = handle.push(label); + + // let mut items_inner: [*const i8; N] = [std::ptr::null(); N]; + + // for (i, item) in items.iter().enumerate() { + // items_inner[i] = handle.push(item); + // } + + // (label_ptr, items_inner) + // }; + + // unsafe { + // sys::igListBoxStr_arr( + // label_ptr, + // current_item, + // items_inner.as_ptr() as *mut *const c_char, + // items_inner.len() as i32, + // height_in_items, + // ) + // } + // } +} + +impl<'ui> Ui<'ui> { + #[doc(alias = "PlotLines")] + pub fn plot_lines<'p, Label: AsRef>( + &'ui self, + label: Label, + values: &'p [f32], + ) -> PlotLines<'ui, 'p, Label> { + PlotLines::new(self, label, values) + } +} + +impl<'ui> Ui<'ui> { + #[doc(alias = "PlotHistogram")] + pub fn plot_histogram<'p, Label: AsRef>( + &'ui self, + label: Label, + values: &'p [f32], + ) -> PlotHistogram<'ui, 'p, Label> { + PlotHistogram::new(self, label, values) + } +} + +impl<'ui> Ui<'ui> { + /// Calculate the size required for a given text string. + /// + /// This is the same as [calc_text_size_with_opts](Self::calc_text_size_with_opts) + /// with `hide_text_after_double_hash` set to false and `wrap_width` set to `-1.0`. + #[doc(alias = "CalcTextSize")] + pub fn calc_text_size>(&self, text: T) -> [f32; 2] { + self.calc_text_size_with_opts(text, false, -1.0) + } + + /// Calculate the size required for a given text string. + /// + /// hide_text_after_double_hash allows the user to insert comments into their text, using a double hash-tag prefix. + /// This is a feature of imgui. + /// + /// wrap_width allows you to request a width at which to wrap the text to a newline for the calculation. + #[doc(alias = "CalcTextSize")] + pub fn calc_text_size_with_opts>( + &self, + text: T, + hide_text_after_double_hash: bool, + wrap_width: f32, + ) -> [f32; 2] { + let mut out = sys::ImVec2::zero(); + let text = text.as_ref(); + + unsafe { + let start = text.as_ptr(); + let end = start.add(text.len()); + + sys::igCalcTextSize( + &mut out, + start as *const c_char, + end as *const c_char, + hide_text_after_double_hash, + wrap_width, + ) + }; + out.into() + } +} + +/// # Draw list for custom drawing +impl<'ui> Ui<'ui> { + /// Get access to drawing API + /// + /// # Examples + /// + /// ```rust,no_run + /// # use imgui::*; + /// fn custom_draw(ui: &Ui) { + /// let draw_list = ui.get_window_draw_list(); + /// // Draw a line + /// const WHITE: [f32; 3] = [1.0, 1.0, 1.0]; + /// draw_list.add_line([100.0, 100.0], [200.0, 200.0], WHITE).build(); + /// // Continue drawing ... + /// } + /// ``` + /// + /// This function will panic if several instances of [`DrawListMut`] + /// coexist. Before a new instance is got, a previous instance should be + /// dropped. + /// + /// ```rust + /// # use imgui::*; + /// fn custom_draw(ui: &Ui) { + /// let draw_list = ui.get_window_draw_list(); + /// // Draw something... + /// + /// // This second call will panic! + /// let draw_list = ui.get_window_draw_list(); + /// } + /// ``` + #[must_use] + #[doc(alias = "GetWindowDrawList")] + pub fn get_window_draw_list(&'ui self) -> DrawListMut<'ui> { + DrawListMut::window(self) + } + + #[must_use] + #[doc(alias = "GetBackgroundDrawList")] + pub fn get_background_draw_list(&'ui self) -> DrawListMut<'ui> { + DrawListMut::background(self) + } + + #[must_use] + #[doc(alias = "GetForegroundDrawList")] + pub fn get_foreground_draw_list(&'ui self) -> DrawListMut<'ui> { + DrawListMut::foreground(self) + } +} + +/// Condition for applying a setting +#[repr(i8)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Condition { + /// Never apply the setting + Never = -1, + /// Always apply the setting + Always = sys::ImGuiCond_Always as i8, + /// Apply the setting once per runtime session (only the first call will succeed) + Once = sys::ImGuiCond_Once as i8, + /// Apply the setting if the object/window has no persistently saved data (no entry in .ini + /// file) + FirstUseEver = sys::ImGuiCond_FirstUseEver as i8, + /// Apply the setting if the object/window is appearing after being hidden/inactive (or the + /// first time) + Appearing = sys::ImGuiCond_Appearing as i8, +} + +/// A cardinal direction +#[repr(i32)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Direction { + None = sys::ImGuiDir_None, + Left = sys::ImGuiDir_Left, + Right = sys::ImGuiDir_Right, + Up = sys::ImGuiDir_Up, + Down = sys::ImGuiDir_Down, +} diff --git a/plugins/libimhex-rust/imgui-rs/src/list_clipper.rs b/plugins/libimhex-rust/imgui-rs/src/list_clipper.rs new file mode 100644 index 000000000..d4ba021d6 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/list_clipper.rs @@ -0,0 +1,81 @@ +use std::marker::PhantomData; +use std::thread; + +use crate::sys; +use crate::Ui; + +pub struct ListClipper { + items_count: i32, + items_height: f32, +} + +impl ListClipper { + pub const fn new(items_count: i32) -> Self { + ListClipper { + items_count, + items_height: -1.0, + } + } + + pub const fn items_height(mut self, items_height: f32) -> Self { + self.items_height = items_height; + self + } + + pub fn begin<'ui>(self, ui: &Ui<'ui>) -> ListClipperToken<'ui> { + let list_clipper = unsafe { + let list_clipper = sys::ImGuiListClipper_ImGuiListClipper(); + sys::ImGuiListClipper_Begin(list_clipper, self.items_count, self.items_height); + list_clipper + }; + ListClipperToken::new(ui, list_clipper) + } +} + +pub struct ListClipperToken<'ui> { + list_clipper: *mut sys::ImGuiListClipper, + _phantom: PhantomData<&'ui Ui<'ui>>, +} + +impl<'ui> ListClipperToken<'ui> { + fn new(_: &Ui<'ui>, list_clipper: *mut sys::ImGuiListClipper) -> Self { + Self { + list_clipper, + _phantom: PhantomData, + } + } + + pub fn step(&mut self) -> bool { + unsafe { sys::ImGuiListClipper_Step(self.list_clipper) } + } + + pub fn end(&mut self) { + unsafe { + sys::ImGuiListClipper_End(self.list_clipper); + } + } + + pub fn display_start(&self) -> i32 { + unsafe { (*self.list_clipper).DisplayStart } + } + + pub fn display_end(&self) -> i32 { + unsafe { (*self.list_clipper).DisplayEnd } + } +} + +impl<'ui> Drop for ListClipperToken<'ui> { + fn drop(&mut self) { + if !self.step() { + unsafe { + sys::ImGuiListClipper_destroy(self.list_clipper); + }; + } else if !thread::panicking() { + panic!( + "Forgot to call End(), or to Step() until false? \ + This is the only token in the repository which users must call `.end()` or `.step()` \ + with. See https://github.com/imgui-rs/imgui-rs/issues/438" + ); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/plothistogram.rs b/plugins/libimhex-rust/imgui-rs/src/plothistogram.rs new file mode 100644 index 000000000..ef490a155 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/plothistogram.rs @@ -0,0 +1,87 @@ +use std::os::raw::c_float; +use std::{f32, mem}; + +use super::Ui; + +#[must_use] +pub struct PlotHistogram<'ui, 'p, Label, Overlay = &'static str> { + label: Label, + values: &'p [f32], + values_offset: usize, + overlay_text: Option, + scale_min: f32, + scale_max: f32, + graph_size: [f32; 2], + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, Label: AsRef> PlotHistogram<'ui, 'p, Label> { + pub fn new(ui: &'ui Ui<'ui>, label: Label, values: &'p [f32]) -> Self { + PlotHistogram { + label, + values, + values_offset: 0usize, + overlay_text: None, + scale_min: f32::MAX, + scale_max: f32::MAX, + graph_size: [0.0, 0.0], + ui, + } + } +} + +impl<'ui, 'p, Label: AsRef, Overlay: AsRef> PlotHistogram<'ui, 'p, Label, Overlay> { + pub fn values_offset(mut self, values_offset: usize) -> Self { + self.values_offset = values_offset; + self + } + + pub fn overlay_text>( + self, + overlay_text: NewOverlay, + ) -> PlotHistogram<'ui, 'p, Label, NewOverlay> { + PlotHistogram { + label: self.label, + values: self.values, + values_offset: self.values_offset, + overlay_text: Some(overlay_text), + scale_min: self.scale_min, + scale_max: self.scale_max, + graph_size: self.graph_size, + ui: self.ui, + } + } + + pub fn scale_min(mut self, scale_min: f32) -> Self { + self.scale_min = scale_min; + self + } + + pub fn scale_max(mut self, scale_max: f32) -> Self { + self.scale_max = scale_max; + self + } + + pub fn graph_size(mut self, graph_size: [f32; 2]) -> Self { + self.graph_size = graph_size; + self + } + + pub fn build(self) { + unsafe { + let (label, overlay_text) = self.ui.scratch_txt_with_opt(self.label, self.overlay_text); + + sys::igPlotHistogram_FloatPtr( + label, + self.values.as_ptr() as *const c_float, + self.values.len() as i32, + self.values_offset as i32, + overlay_text, + self.scale_min, + self.scale_max, + self.graph_size.into(), + mem::size_of::() as i32, + ); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/plotlines.rs b/plugins/libimhex-rust/imgui-rs/src/plotlines.rs new file mode 100644 index 000000000..5c57e8e28 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/plotlines.rs @@ -0,0 +1,87 @@ +use std::os::raw::c_float; +use std::{f32, mem}; + +use super::Ui; + +#[must_use] +pub struct PlotLines<'ui, 'p, Label, Overlay = &'static str> { + label: Label, + values: &'p [f32], + values_offset: usize, + overlay_text: Option, + scale_min: f32, + scale_max: f32, + graph_size: [f32; 2], + ui: &'ui Ui<'ui>, +} + +impl<'ui, 'p, Label: AsRef> PlotLines<'ui, 'p, Label> { + pub fn new(ui: &'ui Ui<'ui>, label: Label, values: &'p [f32]) -> Self { + PlotLines { + label, + values, + values_offset: 0usize, + overlay_text: None, + scale_min: f32::MAX, + scale_max: f32::MAX, + graph_size: [0.0, 0.0], + ui, + } + } +} + +impl<'ui, 'p, Label: AsRef, Overlay: AsRef> PlotLines<'ui, 'p, Label, Overlay> { + pub fn values_offset(mut self, values_offset: usize) -> Self { + self.values_offset = values_offset; + self + } + + pub fn overlay_text>( + self, + overlay_text: Overlay2, + ) -> PlotLines<'ui, 'p, Label, Overlay2> { + PlotLines { + label: self.label, + values: self.values, + values_offset: self.values_offset, + overlay_text: Some(overlay_text), + scale_min: self.scale_min, + scale_max: self.scale_max, + graph_size: self.graph_size, + ui: self.ui, + } + } + + pub fn scale_min(mut self, scale_min: f32) -> Self { + self.scale_min = scale_min; + self + } + + pub fn scale_max(mut self, scale_max: f32) -> Self { + self.scale_max = scale_max; + self + } + + pub fn graph_size(mut self, graph_size: [f32; 2]) -> Self { + self.graph_size = graph_size; + self + } + + pub fn build(self) { + unsafe { + let (label, overlay) = self.ui.scratch_txt_with_opt(self.label, self.overlay_text); + + sys::igPlotLines_FloatPtr( + label, + self.values.as_ptr() as *const c_float, + self.values.len() as i32, + self.values_offset as i32, + overlay, + self.scale_min, + self.scale_max, + self.graph_size.into(), + mem::size_of::() as i32, + ); + } + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/popups.rs b/plugins/libimhex-rust/imgui-rs/src/popups.rs new file mode 100644 index 000000000..e0b428850 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/popups.rs @@ -0,0 +1,214 @@ +use std::ptr; + +use crate::sys; +use crate::window::WindowFlags; +use crate::Ui; + +/// Create a modal pop-up. +/// +/// # Example +/// ```rust,no_run +/// # use imgui::*; +/// # let mut imgui = Context::create(); +/// # let ui = imgui.frame(); +/// if ui.button(im_str!("Show modal")) { +/// ui.open_popup(im_str!("modal")); +/// } +/// if let Some(_token) = PopupModal::new(im_str!("modal")).begin_popup(&ui) { +/// ui.text("Content of my modal"); +/// if ui.button(im_str!("OK")) { +/// ui.close_current_popup(); +/// } +/// }; +/// ``` +#[must_use] +pub struct PopupModal<'p, Label> { + label: Label, + opened: Option<&'p mut bool>, + flags: WindowFlags, +} + +impl<'p, Label: AsRef> PopupModal<'p, Label> { + pub fn new(label: Label) -> Self { + PopupModal { + label, + opened: None, + flags: WindowFlags::empty(), + } + } + /// Pass a mutable boolean which will be updated to refer to the current + /// "open" state of the modal. + pub fn opened(mut self, opened: &'p mut bool) -> Self { + self.opened = Some(opened); + self + } + pub fn flags(mut self, flags: WindowFlags) -> Self { + self.flags = flags; + self + } + pub fn title_bar(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_TITLE_BAR, !value); + self + } + pub fn resizable(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_RESIZE, !value); + self + } + pub fn movable(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_MOVE, !value); + self + } + pub fn scroll_bar(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_SCROLLBAR, !value); + self + } + pub fn scrollable(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_SCROLL_WITH_MOUSE, !value); + self + } + pub fn collapsible(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_COLLAPSE, !value); + self + } + pub fn always_auto_resize(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::ALWAYS_AUTO_RESIZE, value); + self + } + pub fn save_settings(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_SAVED_SETTINGS, !value); + self + } + pub fn inputs(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_INPUTS, !value); + self + } + pub fn menu_bar(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::MENU_BAR, value); + self + } + pub fn horizontal_scrollbar(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::HORIZONTAL_SCROLLBAR, value); + self + } + pub fn no_focus_on_appearing(mut self, value: bool) -> Self { + self.flags.set(WindowFlags::NO_FOCUS_ON_APPEARING, value); + self + } + pub fn no_bring_to_front_on_focus(mut self, value: bool) -> Self { + self.flags + .set(WindowFlags::NO_BRING_TO_FRONT_ON_FOCUS, value); + self + } + pub fn always_vertical_scrollbar(mut self, value: bool) -> Self { + self.flags + .set(WindowFlags::ALWAYS_VERTICAL_SCROLLBAR, value); + self + } + pub fn always_horizontal_scrollbar(mut self, value: bool) -> Self { + self.flags + .set(WindowFlags::ALWAYS_HORIZONTAL_SCROLLBAR, value); + self + } + pub fn always_use_window_padding(mut self, value: bool) -> Self { + self.flags + .set(WindowFlags::ALWAYS_USE_WINDOW_PADDING, value); + self + } + + /// Consume and draw the PopupModal. + /// Returns the result of the closure, if it is called. + #[doc(alias = "BeginPopupModal")] + pub fn build T>(self, ui: &Ui<'_>, f: F) -> Option { + self.begin_popup(ui).map(|_popup| f()) + } + + /// Consume and draw the PopupModal. + /// Construct a popup that can have any kind of content. + /// + /// This should be called *per frame*, whereas [`Ui::open_popup`] + /// should be called *once* when you want to actual create the popup. + #[doc(alias = "BeginPopupModal")] + pub fn begin_popup<'ui>(self, ui: &Ui<'ui>) -> Option> { + let render = unsafe { + sys::igBeginPopupModal( + ui.scratch_txt(self.label), + self.opened + .map(|x| x as *mut bool) + .unwrap_or(ptr::null_mut()), + self.flags.bits() as i32, + ) + }; + + if render { + Some(PopupToken::new(ui)) + } else { + None + } + } +} + +// Widgets: Popups +impl<'ui> Ui<'ui> { + /// Instructs ImGui to open a popup, which must be began with either [`begin_popup`](Self::begin_popup) + /// or [`popup`](Self::popup). You also use this function to begin [PopupModal]. + /// + /// The confusing aspect to popups is that ImGui holds "control" over the popup fundamentally, so that ImGui + /// can also force close a popup when a user clicks outside a popup. If you do not want users to be + /// able to close a popup without selected an option, use [`PopupModal`]. + #[doc(alias = "OpenPopup")] + pub fn open_popup(&self, str_id: impl AsRef) { + unsafe { sys::igOpenPopup_Str(self.scratch_txt(str_id), 0) }; + } + + /// Construct a popup that can have any kind of content. + /// + /// This should be called *per frame*, whereas [`open_popup`](Self::open_popup) should be called *once* + /// when you want to actual create the popup. + #[doc(alias = "BeginPopup")] + pub fn begin_popup(&self, str_id: impl AsRef) -> Option> { + let render = unsafe { + sys::igBeginPopup(self.scratch_txt(str_id), WindowFlags::empty().bits() as i32) + }; + + if render { + Some(PopupToken::new(self)) + } else { + None + } + } + + /// Construct a popup that can have any kind of content. + /// + /// This should be called *per frame*, whereas [`open_popup`](Self::open_popup) should be called *once* + /// when you want to actual create the popup. + #[doc(alias = "BeginPopup")] + pub fn popup(&self, str_id: impl AsRef, f: F) + where + F: FnOnce(), + { + if let Some(_t) = self.begin_popup(str_id) { + f(); + } + } + + /// Creates a PopupModal directly. + pub fn popup_modal<'p, Label: AsRef>(&self, str_id: Label) -> PopupModal<'p, Label> { + PopupModal::new(str_id) + } + + /// Close a popup. Should be called within the closure given as argument to + /// [`Ui::popup`] or [`Ui::popup_modal`]. + #[doc(alias = "CloseCurrentPopup")] + pub fn close_current_popup(&self) { + unsafe { sys::igCloseCurrentPopup() }; + } +} + +create_token!( + /// Tracks a popup token that can be ended with `end` or by dropping. + pub struct PopupToken<'ui>; + + /// Drops the popup token manually. You can also just allow this token + /// to drop on its own. + drop { sys::igEndPopup() } +); diff --git a/plugins/libimhex-rust/imgui-rs/src/render/draw_data.rs b/plugins/libimhex-rust/imgui-rs/src/render/draw_data.rs new file mode 100644 index 000000000..0bd3e4967 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/render/draw_data.rs @@ -0,0 +1,285 @@ +use std::slice; + +use crate::internal::{RawCast, RawWrapper}; +use crate::render::renderer::TextureId; +use crate::sys; + +/// All draw data to render a Dear ImGui frame. +#[repr(C)] +pub struct DrawData { + /// Only valid after render() is called and before the next new frame() is called. + valid: bool, + /// Number of DrawList to render. + cmd_lists_count: i32, + /// For convenience, sum of all draw list index buffer sizes. + pub total_idx_count: i32, + /// For convenience, sum of all draw list vertex buffer sizes. + pub total_vtx_count: i32, + // Array of DrawList. + cmd_lists: *mut *mut DrawList, + /// Upper-left position of the viewport to render. + /// + /// (= upper-left corner of the orthogonal projection matrix to use) + pub display_pos: [f32; 2], + /// Size of the viewport to render. + /// + /// (= display_pos + display_size == lower-right corner of the orthogonal matrix to use) + pub display_size: [f32; 2], + /// Amount of pixels for each unit of display_size. + /// + /// Based on io.display_frame_buffer_scale. Typically [1.0, 1.0] on normal displays, and + /// [2.0, 2.0] on Retina displays, but fractional values are also possible. + pub framebuffer_scale: [f32; 2], +} + +unsafe impl RawCast for DrawData {} + +impl DrawData { + /// Returns an iterator over the draw lists included in the draw data. + #[inline] + pub fn draw_lists(&self) -> DrawListIterator<'_> { + unsafe { + DrawListIterator { + iter: self.cmd_lists().iter(), + } + } + } + /// Returns the number of draw lists included in the draw data. + #[inline] + pub fn draw_lists_count(&self) -> usize { + use std::convert::TryInto; + self.cmd_lists_count.try_into().unwrap() + } + #[inline] + pub(crate) unsafe fn cmd_lists(&self) -> &[*const DrawList] { + slice::from_raw_parts( + self.cmd_lists as *const *const DrawList, + self.cmd_lists_count as usize, + ) + } + /// Converts all buffers from indexed to non-indexed, in case you cannot render indexed + /// buffers. + /// + /// **This is slow and most likely a waste of resources. Always prefer indexed rendering!** + #[doc(alias = "DeIndexAllBuffers")] + pub fn deindex_all_buffers(&mut self) { + unsafe { + sys::ImDrawData_DeIndexAllBuffers(self.raw_mut()); + } + } + /// Scales the clip rect of each draw command. + /// + /// Can be used if your final output buffer is at a different scale than imgui-rs expects, or + /// if there is a difference between your window resolution and framebuffer resolution. + #[doc(alias = "ScaleClipRects")] + pub fn scale_clip_rects(&mut self, fb_scale: [f32; 2]) { + unsafe { + sys::ImDrawData_ScaleClipRects(self.raw_mut(), fb_scale.into()); + } + } +} + +/// Iterator over draw lists +pub struct DrawListIterator<'a> { + iter: std::slice::Iter<'a, *const DrawList>, +} + +impl<'a> Iterator for DrawListIterator<'a> { + type Item = &'a DrawList; + + fn next(&mut self) -> Option { + self.iter.next().map(|&ptr| unsafe { &*ptr }) + } +} + +#[test] +#[cfg(test)] +fn test_drawdata_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::(), + mem::align_of::() + ); + use sys::ImDrawData; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(DrawData, $l), + memoffset::offset_of!(ImDrawData, $r) + ); + }; + } + assert_field_offset!(valid, Valid); + assert_field_offset!(cmd_lists, CmdLists); + assert_field_offset!(cmd_lists_count, CmdListsCount); + assert_field_offset!(total_idx_count, TotalIdxCount); + assert_field_offset!(total_vtx_count, TotalVtxCount); + assert_field_offset!(display_pos, DisplayPos); + assert_field_offset!(display_size, DisplaySize); + assert_field_offset!(framebuffer_scale, FramebufferScale); +} + +/// Draw command list +#[repr(transparent)] +pub struct DrawList(sys::ImDrawList); + +impl RawWrapper for DrawList { + type Raw = sys::ImDrawList; + #[inline] + unsafe fn raw(&self) -> &sys::ImDrawList { + &self.0 + } + #[inline] + unsafe fn raw_mut(&mut self) -> &mut sys::ImDrawList { + &mut self.0 + } +} + +impl DrawList { + #[inline] + pub(crate) unsafe fn cmd_buffer(&self) -> &[sys::ImDrawCmd] { + slice::from_raw_parts( + self.0.CmdBuffer.Data as *const sys::ImDrawCmd, + self.0.CmdBuffer.Size as usize, + ) + } + #[inline] + pub fn idx_buffer(&self) -> &[DrawIdx] { + unsafe { + slice::from_raw_parts( + self.0.IdxBuffer.Data as *const DrawIdx, + self.0.IdxBuffer.Size as usize, + ) + } + } + #[inline] + pub fn vtx_buffer(&self) -> &[DrawVert] { + unsafe { + slice::from_raw_parts( + self.0.VtxBuffer.Data as *const DrawVert, + self.0.VtxBuffer.Size as usize, + ) + } + } + + /// # Safety + /// This is equivalent to `transmute(self.vtx_buffer())` with a little more + /// checking, and thus inherits the safety considerations of `transmute`ing + /// slices. + pub unsafe fn transmute_vtx_buffer(&self) -> &[VTy] { + // these checks are constant and thus are removed from release builds + assert_eq!( + core::mem::size_of::(), + core::mem::size_of::(), + ); + assert!(core::mem::align_of::() <= core::mem::align_of::()); + slice::from_raw_parts(self.0.VtxBuffer.Data.cast(), self.0.VtxBuffer.Size as usize) + } + + #[inline] + pub fn commands(&self) -> DrawCmdIterator<'_> { + unsafe { + DrawCmdIterator { + iter: self.cmd_buffer().iter(), + } + } + } +} + +pub struct DrawCmdIterator<'a> { + iter: std::slice::Iter<'a, sys::ImDrawCmd>, +} + +impl<'a> Iterator for DrawCmdIterator<'a> { + type Item = DrawCmd; + + #[inline] + fn next(&mut self) -> Option { + self.iter.next().map(|cmd| { + let cmd_params = DrawCmdParams { + clip_rect: cmd.ClipRect.into(), + texture_id: TextureId::from(cmd.TextureId), + vtx_offset: cmd.VtxOffset as usize, + idx_offset: cmd.IdxOffset as usize, + }; + match cmd.UserCallback { + Some(raw_callback) if raw_callback as usize == -1isize as usize => { + DrawCmd::ResetRenderState + } + Some(raw_callback) => DrawCmd::RawCallback { + callback: raw_callback, + raw_cmd: cmd, + }, + None => DrawCmd::Elements { + count: cmd.ElemCount as usize, + cmd_params, + }, + } + }) + } +} + +/// A vertex index +pub type DrawIdx = sys::ImDrawIdx; + +#[derive(Copy, Clone, Debug, PartialEq)] +pub struct DrawCmdParams { + /// left, up, right, down + pub clip_rect: [f32; 4], + pub texture_id: TextureId, + pub vtx_offset: usize, + pub idx_offset: usize, +} + +/// A draw command +pub enum DrawCmd { + Elements { + /// The number of indices used for this draw command + count: usize, + cmd_params: DrawCmdParams, + }, + ResetRenderState, + RawCallback { + callback: unsafe extern "C" fn(*const sys::ImDrawList, cmd: *const sys::ImDrawCmd), + raw_cmd: *const sys::ImDrawCmd, + }, +} + +/// A single vertex +#[repr(C)] +#[derive(Copy, Clone, Debug, PartialEq)] +pub struct DrawVert { + pub pos: [f32; 2], + pub uv: [f32; 2], + pub col: [u8; 4], +} + +#[test] +#[cfg(test)] +fn test_drawvert_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::(), + mem::align_of::() + ); + use sys::ImDrawVert; + macro_rules! assert_field_offset { + ($l:ident, $r:ident) => { + assert_eq!( + memoffset::offset_of!(DrawVert, $l), + memoffset::offset_of!(ImDrawVert, $r) + ); + }; + } + assert_field_offset!(pos, pos); + assert_field_offset!(uv, uv); + assert_field_offset!(col, col); +} diff --git a/plugins/libimhex-rust/imgui-rs/src/render/mod.rs b/plugins/libimhex-rust/imgui-rs/src/render/mod.rs new file mode 100644 index 000000000..0ace10448 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/render/mod.rs @@ -0,0 +1,2 @@ +pub mod draw_data; +pub mod renderer; diff --git a/plugins/libimhex-rust/imgui-rs/src/render/renderer.rs b/plugins/libimhex-rust/imgui-rs/src/render/renderer.rs new file mode 100644 index 000000000..2b87e99bd --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/render/renderer.rs @@ -0,0 +1,95 @@ +use std::collections::HashMap; + +/// An opaque texture identifier +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[repr(transparent)] +pub struct TextureId(usize); + +impl TextureId { + /// Creates a new texture id with the given identifier. + #[inline] + pub const fn new(id: usize) -> Self { + Self(id) + } + + /// Returns the id of the TextureId. + #[inline] + pub const fn id(self) -> usize { + self.0 + } +} + +impl From for TextureId { + #[inline] + fn from(id: usize) -> Self { + TextureId(id) + } +} + +impl From<*const T> for TextureId { + #[inline] + fn from(ptr: *const T) -> Self { + TextureId(ptr as usize) + } +} + +impl From<*mut T> for TextureId { + #[inline] + fn from(ptr: *mut T) -> Self { + TextureId(ptr as usize) + } +} + +#[test] +fn test_texture_id_memory_layout() { + use std::mem; + assert_eq!( + mem::size_of::(), + mem::size_of::() + ); + assert_eq!( + mem::align_of::(), + mem::align_of::() + ); +} + +/// Generic texture mapping for use by renderers. +#[derive(Debug, Default)] +pub struct Textures { + textures: HashMap, + next: usize, +} + +impl Textures { + // TODO: hasher like rustc_hash::FxHashMap or something would let this be + // `const fn` + pub fn new() -> Self { + Textures { + textures: HashMap::new(), + next: 0, + } + } + + pub fn insert(&mut self, texture: T) -> TextureId { + let id = self.next; + self.textures.insert(id, texture); + self.next += 1; + TextureId::from(id) + } + + pub fn replace(&mut self, id: TextureId, texture: T) -> Option { + self.textures.insert(id.0, texture) + } + + pub fn remove(&mut self, id: TextureId) -> Option { + self.textures.remove(&id.0) + } + + pub fn get(&self, id: TextureId) -> Option<&T> { + self.textures.get(&id.0) + } + + pub fn get_mut(&mut self, id: TextureId) -> Option<&mut T> { + self.textures.get_mut(&id.0) + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/stacks.rs b/plugins/libimhex-rust/imgui-rs/src/stacks.rs new file mode 100644 index 000000000..b507741d7 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/stacks.rs @@ -0,0 +1,471 @@ +use std::mem; +use std::os::raw::{c_char, c_void}; +use std::ptr; +use std::thread; + +use crate::context::Context; +use crate::fonts::atlas::FontId; +use crate::internal::RawCast; +use crate::style::{StyleColor, StyleVar}; +use crate::sys; +use crate::{Id, Ui}; + +/// # Parameter stacks (shared) +impl<'ui> Ui<'ui> { + /// Switches to the given font by pushing it to the font stack. + /// + /// Returns a `FontStackToken` that must be popped by calling `.pop()` + /// + /// # Panics + /// + /// Panics if the font atlas does not contain the given font + /// + /// # Examples + /// + /// ```no_run + /// # use imgui::*; + /// # let mut ctx = Context::create(); + /// # let font_data_sources = []; + /// // At initialization time + /// let my_custom_font = ctx.fonts().add_font(&font_data_sources); + /// # let ui = ctx.frame(); + /// // During UI construction + /// let font = ui.push_font(my_custom_font); + /// ui.text("I use the custom font!"); + /// font.pop(); + /// ``` + #[doc(alias = "PushFont")] + pub fn push_font(&self, id: FontId) -> FontStackToken<'_> { + let fonts = self.fonts(); + let font = fonts + .get_font(id) + .expect("Font atlas did not contain the given font"); + unsafe { sys::igPushFont(font.raw() as *const _ as *mut _) }; + FontStackToken::new(self) + } + /// Changes a style color by pushing a change to the color stack. + /// + /// Returns a `ColorStackToken` that must be popped by calling `.pop()` + /// + /// # Examples + /// + /// ```no_run + /// # use imgui::*; + /// # let mut ctx = Context::create(); + /// # let ui = ctx.frame(); + /// const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; + /// let color = ui.push_style_color(StyleColor::Text, RED); + /// ui.text("I'm red!"); + /// color.pop(); + /// ``` + #[doc(alias = "PushStyleColorVec4")] + pub fn push_style_color( + &self, + style_color: StyleColor, + color: [f32; 4], + ) -> ColorStackToken<'_> { + unsafe { sys::igPushStyleColor_Vec4(style_color as i32, color.into()) }; + ColorStackToken::new(self) + } + + /// Changes style colors by pushing several changes to the color stack. + /// + /// Returns a `ColorStackToken` that must be popped by calling `.pop()` + /// + /// # Examples + /// + /// ```no_run + /// # use imgui::*; + /// # let mut ctx = Context::create(); + /// # let ui = ctx.frame(); + /// const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; + /// const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0]; + /// let colors = ui.push_style_colors(&[ + /// (StyleColor::Text, RED), + /// (StyleColor::TextDisabled, GREEN), + /// ]); + /// ui.text("I'm red!"); + /// ui.text_disabled("I'm green!"); + /// colors.pop(&ui); + /// ``` + #[deprecated = "deprecated in 0.7.0. Use `push_style_color` multiple times for similar effect."] + pub fn push_style_colors<'a, I>(&self, style_colors: I) -> MultiColorStackToken + where + I: IntoIterator, + { + let mut count = 0; + for &(style_color, color) in style_colors { + unsafe { sys::igPushStyleColor_Vec4(style_color as i32, color.into()) }; + count += 1; + } + MultiColorStackToken { + count, + ctx: self.ctx, + } + } + /// Changes a style variable by pushing a change to the style stack. + /// + /// Returns a `StyleStackToken` that can be popped by calling `.end()` + /// or by allowing to drop. + /// + /// # Examples + /// + /// ```no_run + /// # use imgui::*; + /// # let mut ctx = Context::create(); + /// # let ui = ctx.frame(); + /// let style = ui.push_style_var(StyleVar::Alpha(0.2)); + /// ui.text("I'm transparent!"); + /// style.pop(); + /// ``` + #[doc(alias = "PushStyleVar")] + pub fn push_style_var(&self, style_var: StyleVar) -> StyleStackToken<'_> { + unsafe { push_style_var(style_var) }; + StyleStackToken::new(self) + } + /// Changes style variables by pushing several changes to the style stack. + /// + /// Returns a `StyleStackToken` that must be popped by calling `.pop()` + /// + /// # Examples + /// + /// ```no_run + /// # use imgui::*; + /// # let mut ctx = Context::create(); + /// # let ui = ctx.frame(); + /// let styles = ui.push_style_vars(&[ + /// StyleVar::Alpha(0.2), + /// StyleVar::ItemSpacing([50.0, 50.0]) + /// ]); + /// ui.text("We're transparent..."); + /// ui.text("...with large spacing as well"); + /// styles.pop(&ui); + /// ``` + #[deprecated = "deprecated in 0.7.0. Use `push_style_var` multiple times for similar effect."] + pub fn push_style_vars<'a, I>(&self, style_vars: I) -> MultiStyleStackToken + where + I: IntoIterator, + { + let mut count = 0; + for &style_var in style_vars { + unsafe { push_style_var(style_var) }; + count += 1; + } + MultiStyleStackToken { + count, + ctx: self.ctx, + } + } +} + +create_token!( + /// Tracks a font pushed to the font stack that can be popped by calling `.end()` + /// or by dropping. + pub struct FontStackToken<'ui>; + + /// Pops a change from the font stack. + drop { sys::igPopFont() } +); + +impl FontStackToken<'_> { + /// Pops a change from the font stack. + pub fn pop(self) { + self.end() + } +} + +create_token!( + /// Tracks a color pushed to the color stack that can be popped by calling `.end()` + /// or by dropping. + pub struct ColorStackToken<'ui>; + + /// Pops a change from the color stack. + drop { sys::igPopStyleColor(1) } +); + +impl ColorStackToken<'_> { + /// Pops a change from the color stack. + pub fn pop(self) { + self.end() + } +} + +/// Tracks one or more changes pushed to the color stack that must be popped by calling `.pop()` +#[must_use] +pub struct MultiColorStackToken { + count: usize, + ctx: *const Context, +} + +impl MultiColorStackToken { + /// Pops changes from the color stack + #[doc(alias = "PopStyleColor")] + pub fn pop(mut self, _: &Ui<'_>) { + self.ctx = ptr::null(); + unsafe { sys::igPopStyleColor(self.count as i32) }; + } +} + +impl Drop for MultiColorStackToken { + fn drop(&mut self) { + if !self.ctx.is_null() && !thread::panicking() { + panic!("A ColorStackToken was leaked. Did you call .pop()?"); + } + } +} + +create_token!( + /// Tracks a style pushed to the style stack that can be popped by calling `.end()` + /// or by dropping. + pub struct StyleStackToken<'ui>; + + /// Pops a change from the style stack. + drop { sys::igPopStyleVar(1) } +); + +impl StyleStackToken<'_> { + /// Pops a change from the style stack. + pub fn pop(self) { + self.end() + } +} + +/// Tracks one or more changes pushed to the style stack that must be popped by calling `.pop()` +#[must_use] +pub struct MultiStyleStackToken { + count: usize, + ctx: *const Context, +} + +impl MultiStyleStackToken { + /// Pops changes from the style stack + #[doc(alias = "PopStyleVar")] + pub fn pop(mut self, _: &Ui<'_>) { + self.ctx = ptr::null(); + unsafe { sys::igPopStyleVar(self.count as i32) }; + } +} + +impl Drop for MultiStyleStackToken { + fn drop(&mut self) { + if !self.ctx.is_null() && !thread::panicking() { + panic!("A StyleStackToken was leaked. Did you call .pop()?"); + } + } +} + +#[inline] +unsafe fn push_style_var(style_var: StyleVar) { + use crate::style::StyleVar::*; + use crate::sys::{igPushStyleVar_Float, igPushStyleVar_Vec2}; + match style_var { + Alpha(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_Alpha as i32, v), + WindowPadding(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowPadding as i32, v.into()), + WindowRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_WindowRounding as i32, v), + WindowBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_WindowBorderSize as i32, v), + WindowMinSize(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowMinSize as i32, v.into()), + WindowTitleAlign(v) => { + igPushStyleVar_Vec2(sys::ImGuiStyleVar_WindowTitleAlign as i32, v.into()) + } + ChildRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ChildRounding as i32, v), + ChildBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ChildBorderSize as i32, v), + PopupRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_PopupRounding as i32, v), + PopupBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_PopupBorderSize as i32, v), + FramePadding(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_FramePadding as i32, v.into()), + FrameRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_FrameRounding as i32, v), + FrameBorderSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_FrameBorderSize as i32, v), + ItemSpacing(v) => igPushStyleVar_Vec2(sys::ImGuiStyleVar_ItemSpacing as i32, v.into()), + ItemInnerSpacing(v) => { + igPushStyleVar_Vec2(sys::ImGuiStyleVar_ItemInnerSpacing as i32, v.into()) + } + IndentSpacing(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_IndentSpacing as i32, v), + ScrollbarSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_ScrollbarSize as i32, v), + ScrollbarRounding(v) => { + igPushStyleVar_Float(sys::ImGuiStyleVar_ScrollbarRounding as i32, v) + } + GrabMinSize(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_GrabMinSize as i32, v), + GrabRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_GrabRounding as i32, v), + TabRounding(v) => igPushStyleVar_Float(sys::ImGuiStyleVar_TabRounding as i32, v), + ButtonTextAlign(v) => { + igPushStyleVar_Vec2(sys::ImGuiStyleVar_ButtonTextAlign as i32, v.into()) + } + SelectableTextAlign(v) => { + igPushStyleVar_Vec2(sys::ImGuiStyleVar_SelectableTextAlign as i32, v.into()) + } + } +} + +/// # Parameter stacks (current window) +impl<'ui> Ui<'ui> { + /// Changes the item width by pushing a change to the item width stack. + /// + /// Returns an `ItemWidthStackToken` that may be popped by calling `.pop()` + /// + /// - `> 0.0`: width is `item_width` pixels + /// - `= 0.0`: default to ~2/3 of window width + /// - `< 0.0`: `item_width` pixels relative to the right of window (-1.0 always aligns width to + /// the right side) + #[doc(alias = "PushItemWith")] + pub fn push_item_width(&self, item_width: f32) -> ItemWidthStackToken { + unsafe { sys::igPushItemWidth(item_width) }; + ItemWidthStackToken { _ctx: self.ctx } + } + /// Sets the width of the next item. + /// + /// - `> 0.0`: width is `item_width` pixels + /// - `= 0.0`: default to ~2/3 of window width + /// - `< 0.0`: `item_width` pixels relative to the right of window (-1.0 always aligns width to + /// the right side) + #[doc(alias = "SetNextItemWidth")] + pub fn set_next_item_width(&self, item_width: f32) { + unsafe { sys::igSetNextItemWidth(item_width) }; + } + /// Returns the width of the item given the pushed settings and the current cursor position. + /// + /// This is NOT necessarily the width of last item. + #[doc(alias = "CalcItemWidth")] + pub fn calc_item_width(&self) -> f32 { + unsafe { sys::igCalcItemWidth() } + } + + /// Changes the text wrapping position to the end of window (or column), which + /// is generally the default. + /// + /// This is the same as calling [push_text_wrap_pos_with_pos](Self::push_text_wrap_pos_with_pos) + /// with `wrap_pos_x` set to 0.0. + /// + /// Returns a `TextWrapPosStackToken` that may be popped by calling `.pop()` + #[doc(alias = "PushTextWrapPos")] + pub fn push_text_wrap_pos(&self) -> TextWrapPosStackToken { + self.push_text_wrap_pos_with_pos(0.0) + } + + /// Changes the text wrapping position by pushing a change to the text wrapping position stack. + /// + /// Returns a `TextWrapPosStackToken` that may be popped by calling `.pop()` + /// + /// - `> 0.0`: wrap at `wrap_pos_x` position in window local space + /// - `= 0.0`: wrap to end of window (or column) + /// - `< 0.0`: no wrapping + #[doc(alias = "PushTextWrapPos")] + pub fn push_text_wrap_pos_with_pos(&self, wrap_pos_x: f32) -> TextWrapPosStackToken { + unsafe { sys::igPushTextWrapPos(wrap_pos_x) }; + TextWrapPosStackToken { _ctx: self.ctx } + } + + /// Changes an item flag by pushing a change to the item flag stack. + /// + /// Returns a `ItemFlagsStackToken` that may be popped by calling `.pop()` + #[doc(alias = "PushItemFlag")] + pub fn push_item_flag(&self, item_flag: ItemFlag) -> ItemFlagsStackToken { + use self::ItemFlag::*; + match item_flag { + AllowKeyboardFocus(v) => unsafe { sys::igPushAllowKeyboardFocus(v) }, + ButtonRepeat(v) => unsafe { sys::igPushButtonRepeat(v) }, + } + ItemFlagsStackToken { + discriminant: mem::discriminant(&item_flag), + _ctx: self.ctx, + } + } +} + +/// A temporary change in item flags +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum ItemFlag { + AllowKeyboardFocus(bool), + ButtonRepeat(bool), +} + +pub struct ItemWidthStackToken { + _ctx: *const Context, +} + +impl ItemWidthStackToken { + /// Pops a change from the item width stack + #[doc(alias = "PopItemWidth")] + pub fn pop(mut self, _: &Ui<'_>) { + self._ctx = ptr::null(); + unsafe { sys::igPopItemWidth() }; + } +} + +/// Tracks a change pushed to the text wrap position stack +pub struct TextWrapPosStackToken { + _ctx: *const Context, +} + +impl TextWrapPosStackToken { + /// Pops a change from the text wrap position stack + #[doc(alias = "PopTextWrapPos")] + pub fn pop(mut self, _: &Ui<'_>) { + self._ctx = ptr::null(); + unsafe { sys::igPopTextWrapPos() }; + } +} + +/// Tracks a change pushed to the item flags stack +pub struct ItemFlagsStackToken { + discriminant: mem::Discriminant, + _ctx: *const Context, +} + +impl ItemFlagsStackToken { + /// Pops a change from the item flags stack + + #[doc(alias = "PopAllowKeyboardFocus", alias = "PopButtonRepeat")] + pub fn pop(mut self, _: &Ui<'_>) { + self._ctx = ptr::null(); + const ALLOW_KEYBOARD_FOCUS: ItemFlag = ItemFlag::AllowKeyboardFocus(true); + const BUTTON_REPEAT: ItemFlag = ItemFlag::ButtonRepeat(true); + + if self.discriminant == mem::discriminant(&ALLOW_KEYBOARD_FOCUS) { + unsafe { sys::igPopAllowKeyboardFocus() }; + } else if self.discriminant == mem::discriminant(&BUTTON_REPEAT) { + unsafe { sys::igPopButtonRepeat() }; + } else { + unreachable!(); + } + } +} + +create_token!( + /// Tracks an ID pushed to the ID stack that can be popped by calling `.pop()` + /// or by dropping. + pub struct IdStackToken<'ui>; + + /// Pops a change from the ID stack + drop { sys::igPopID() } +); + +impl IdStackToken<'_> { + /// Pops a change from the ID stack + pub fn pop(self) { + self.end() + } +} + +/// # ID stack +impl<'ui> Ui<'ui> { + /// Pushes an identifier to the ID stack. + /// + /// Returns an `IdStackToken` that can be popped by calling `.end()` + /// or by dropping manually. + #[doc(alias = "PushId")] + pub fn push_id<'a, I: Into>>(&self, id: I) -> IdStackToken<'ui> { + let id = id.into(); + + unsafe { + match id { + Id::Int(i) => sys::igPushID_Int(i), + Id::Str(s) => { + let start = s.as_ptr() as *const c_char; + let end = start.add(s.len()); + sys::igPushID_StrStr(start, end) + } + Id::Ptr(p) => sys::igPushID_Ptr(p as *const c_void), + } + } + IdStackToken::new(self) + } +} diff --git a/plugins/libimhex-rust/imgui-rs/src/string.rs b/plugins/libimhex-rust/imgui-rs/src/string.rs new file mode 100644 index 000000000..d124d8574 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/string.rs @@ -0,0 +1,544 @@ +use std::borrow::{Borrow, Cow}; +use std::ffi::CStr; +use std::ops::{Deref, Index, RangeFull}; +use std::os::raw::c_char; +use std::str; +use std::{fmt, ptr}; + +/// this is the unsafe cell upon which we build our abstraction. +#[derive(Debug)] +pub(crate) struct UiBuffer { + buffer: Vec, + max_len: usize, +} + +impl UiBuffer { + /// Creates a new max buffer with the given length. + pub fn new(max_len: usize) -> Self { + Self { + buffer: Vec::with_capacity(max_len), + max_len, + } + } + + /// Internal method to push a single text to our scratch buffer. + pub fn scratch_txt(&mut self, txt: impl AsRef) -> *const sys::cty::c_char { + self.refresh_buffer(); + self.push(txt) + } + + /// Internal method to push an option text to our scratch buffer. + pub fn scratch_txt_opt(&mut self, txt: Option>) -> *const sys::cty::c_char { + match txt { + Some(v) => self.scratch_txt(v), + None => ptr::null(), + } + } + + pub fn scratch_txt_two( + &mut self, + txt_0: impl AsRef, + txt_1: impl AsRef, + ) -> (*const sys::cty::c_char, *const sys::cty::c_char) { + self.refresh_buffer(); + (self.push(txt_0), self.push(txt_1)) + } + + pub fn scratch_txt_with_opt( + &mut self, + txt_0: impl AsRef, + txt_1: Option>, + ) -> (*const sys::cty::c_char, *const sys::cty::c_char) { + match txt_1 { + Some(value) => self.scratch_txt_two(txt_0, value), + None => (self.scratch_txt(txt_0), ptr::null()), + } + } + + /// Attempts to clear the buffer if it's over the maximum length allowed. + pub fn refresh_buffer(&mut self) { + if self.buffer.len() > self.max_len { + self.buffer.clear(); + } + } + + /// Pushes a new scratch sheet text, which means it's not handling any clearing at all. + pub fn push(&mut self, txt: impl AsRef) -> *const sys::cty::c_char { + unsafe { + let len = self.buffer.len(); + self.buffer.extend(txt.as_ref().as_bytes()); + self.buffer.push(b'\0'); + + self.buffer.as_ptr().add(len) as *const _ + } + } +} + +#[macro_export] +#[deprecated = "all functions take AsRef now -- use inline strings or `format` instead"] +macro_rules! im_str { + ($e:literal $(,)?) => {{ + const __INPUT: &str = concat!($e, "\0"); + { + // Trigger a compile error if there's an interior NUL character. + const _CHECK_NUL: [(); 0] = [(); { + let bytes = __INPUT.as_bytes(); + let mut i = 0; + let mut found_nul = 0; + while i < bytes.len() - 1 && found_nul == 0 { + if bytes[i] == 0 { + found_nul = 1; + } + i += 1; + } + found_nul + }]; + const RESULT: &'static $crate::ImStr = unsafe { + $crate::__core::mem::transmute::<&'static [u8], &'static $crate::ImStr>(__INPUT.as_bytes()) + }; + RESULT + } + }}; + ($e:literal, $($arg:tt)+) => ({ + $crate::ImString::new(format!($e, $($arg)*)) + }); +} + +/// A UTF-8 encoded, growable, implicitly nul-terminated string. +#[derive(Clone, Hash, Ord, Eq, PartialOrd, PartialEq)] +pub struct ImString(pub(crate) Vec); + +impl ImString { + /// Creates a new `ImString` from an existing string. + pub fn new>(value: T) -> ImString { + unsafe { + let mut s = ImString::from_utf8_unchecked(value.into().into_bytes()); + s.refresh_len(); + s + } + } + + /// Creates a new empty `ImString` with a particular capacity + #[inline] + pub fn with_capacity(capacity: usize) -> ImString { + let mut v = Vec::with_capacity(capacity + 1); + v.push(b'\0'); + ImString(v) + } + + /// Converts a vector of bytes to a `ImString` without checking that the string contains valid + /// UTF-8 + /// + /// # Safety + /// + /// It is up to the caller to guarantee the vector contains valid UTF-8 and no null terminator. + #[inline] + pub unsafe fn from_utf8_unchecked(mut v: Vec) -> ImString { + v.push(b'\0'); + ImString(v) + } + + /// Converts a vector of bytes to a `ImString` without checking that the string contains valid + /// UTF-8 + /// + /// # Safety + /// + /// It is up to the caller to guarantee the vector contains valid UTF-8 and a null terminator. + #[inline] + pub unsafe fn from_utf8_with_nul_unchecked(v: Vec) -> ImString { + ImString(v) + } + + /// Truncates this `ImString`, removing all contents + #[inline] + pub fn clear(&mut self) { + self.0.clear(); + self.0.push(b'\0'); + } + + /// Appends the given character to the end of this `ImString` + #[inline] + pub fn push(&mut self, ch: char) { + let mut buf = [0; 4]; + self.push_str(ch.encode_utf8(&mut buf)); + } + + /// Appends a given string slice to the end of this `ImString` + #[inline] + pub fn push_str(&mut self, string: &str) { + self.0.pop(); + self.0.extend(string.bytes()); + self.0.push(b'\0'); + unsafe { + self.refresh_len(); + } + } + + /// Returns the capacity of this `ImString` in bytes + #[inline] + pub fn capacity(&self) -> usize { + self.0.capacity() - 1 + } + + /// Returns the capacity of this `ImString` in bytes, including the implicit null byte + #[inline] + pub fn capacity_with_nul(&self) -> usize { + self.0.capacity() + } + + /// Ensures that the capacity of this `ImString` is at least `additional` bytes larger than the + /// current length. + /// + /// The capacity may be increased by more than `additional` bytes. + pub fn reserve(&mut self, additional: usize) { + self.0.reserve(additional); + } + + /// Ensures that the capacity of this `ImString` is at least `additional` bytes larger than the + /// current length + pub fn reserve_exact(&mut self, additional: usize) { + self.0.reserve_exact(additional); + } + + /// Returns a raw pointer to the underlying buffer + #[inline] + pub fn as_ptr(&self) -> *const c_char { + self.0.as_ptr() as *const c_char + } + + /// Returns a raw mutable pointer to the underlying buffer. + /// + /// If the underlying data is modified, `refresh_len` *must* be called afterwards. + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut c_char { + self.0.as_mut_ptr() as *mut c_char + } + + /// Updates the underlying buffer length based on the current contents. + /// + /// This function *must* be called if the underlying data is modified via a pointer + /// obtained by `as_mut_ptr`. + /// + /// # Safety + /// + /// It is up to the caller to guarantee the this ImString contains valid UTF-8 and a null + /// terminator. + #[inline] + pub unsafe fn refresh_len(&mut self) { + let len = CStr::from_ptr(self.0.as_ptr() as *const c_char) + .to_bytes_with_nul() + .len(); + self.0.set_len(len); + } +} + +impl<'a> Default for ImString { + #[inline] + fn default() -> ImString { + ImString(vec![b'\0']) + } +} + +impl From for ImString { + #[inline] + fn from(s: String) -> ImString { + ImString::new(s) + } +} + +impl<'a> From for Cow<'a, ImStr> { + #[inline] + fn from(s: ImString) -> Cow<'a, ImStr> { + Cow::Owned(s) + } +} + +impl<'a> From<&'a ImString> for Cow<'a, ImStr> { + #[inline] + fn from(s: &'a ImString) -> Cow<'a, ImStr> { + Cow::Borrowed(s) + } +} + +impl<'a, T: ?Sized + AsRef> From<&'a T> for ImString { + #[inline] + fn from(s: &'a T) -> ImString { + s.as_ref().to_owned() + } +} + +impl AsRef for ImString { + #[inline] + fn as_ref(&self) -> &ImStr { + self + } +} + +impl Borrow for ImString { + #[inline] + fn borrow(&self) -> &ImStr { + self + } +} + +impl AsRef for ImString { + #[inline] + fn as_ref(&self) -> &str { + self.to_str() + } +} + +impl Borrow for ImString { + #[inline] + fn borrow(&self) -> &str { + self.to_str() + } +} + +impl Index for ImString { + type Output = ImStr; + #[inline] + fn index(&self, _index: RangeFull) -> &ImStr { + self + } +} + +impl fmt::Debug for ImString { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(self.to_str(), f) + } +} + +impl fmt::Display for ImString { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self.to_str(), f) + } +} + +impl Deref for ImString { + type Target = ImStr; + #[inline] + fn deref(&self) -> &ImStr { + // as_ptr() is used, because we need to look at the bytes to figure out the length + // self.0.len() is incorrect, because there might be more than one nul byte in the end, or + // some interior nuls in the data + unsafe { + &*(CStr::from_ptr(self.0.as_ptr() as *const c_char) as *const CStr as *const ImStr) + } + } +} + +impl fmt::Write for ImString { + #[inline] + fn write_str(&mut self, s: &str) -> fmt::Result { + self.push_str(s); + Ok(()) + } + + #[inline] + fn write_char(&mut self, c: char) -> fmt::Result { + self.push(c); + Ok(()) + } +} + +/// A UTF-8 encoded, implicitly nul-terminated string slice. +#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)] +#[repr(transparent)] +pub struct ImStr([u8]); + +impl<'a> Default for &'a ImStr { + #[inline] + fn default() -> &'a ImStr { + static SLICE: &[u8] = &[0]; + unsafe { ImStr::from_utf8_with_nul_unchecked(SLICE) } + } +} + +impl fmt::Debug for ImStr { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.0, f) + } +} + +impl fmt::Display for ImStr { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self.to_str(), f) + } +} + +impl ImStr { + /// Wraps a raw UTF-8 encoded C string + /// + /// # Safety + /// + /// It is up to the caller to guarantee the pointer is not null and it points to a + /// null-terminated UTF-8 string valid for the duration of the arbitrary lifetime 'a. + #[inline] + pub unsafe fn from_ptr_unchecked<'a>(ptr: *const c_char) -> &'a ImStr { + ImStr::from_cstr_unchecked(CStr::from_ptr(ptr)) + } + + /// Converts a slice of bytes to an imgui-rs string slice without checking for valid UTF-8 or + /// null termination. + /// + /// # Safety + /// + /// It is up to the caller to guarantee the slice contains valid UTF-8 and a null terminator. + #[inline] + pub unsafe fn from_utf8_with_nul_unchecked(bytes: &[u8]) -> &ImStr { + &*(bytes as *const [u8] as *const ImStr) + } + + /// Converts a CStr reference to an imgui-rs string slice without checking for valid UTF-8. + /// + /// # Safety + /// + /// It is up to the caller to guarantee the CStr reference contains valid UTF-8. + #[inline] + pub unsafe fn from_cstr_unchecked(value: &CStr) -> &ImStr { + &*(value.to_bytes_with_nul() as *const [u8] as *const ImStr) + } + + /// Converts an imgui-rs string slice to a raw pointer + #[inline] + pub fn as_ptr(&self) -> *const c_char { + self.0.as_ptr() as *const c_char + } + + /// Converts an imgui-rs string slice to a normal string slice + #[inline] + pub fn to_str(&self) -> &str { + self.sanity_check(); + unsafe { str::from_utf8_unchecked(&self.0[..(self.0.len() - 1)]) } + } + + /// Returns true if the imgui-rs string slice is empty + #[inline] + pub fn is_empty(&self) -> bool { + debug_assert!(self.0.len() != 0); + self.0.len() == 1 + } + + // TODO: if this is too slow, avoid the UTF8 validation except if we'd + // already be doing O(n) stuff. + #[inline] + fn sanity_check(&self) { + debug_assert!( + str::from_utf8(&self.0).is_ok() + && !self.0.is_empty() + && !self.0[..(self.0.len() - 1)].contains(&0u8) + && self.0[self.0.len() - 1] == 0, + "bad ImStr: {:?}", + &self.0 + ); + } +} + +impl AsRef for ImStr { + #[inline] + fn as_ref(&self) -> &CStr { + // Safety: our safety requirements are a superset of CStr's, so this is fine + unsafe { CStr::from_bytes_with_nul_unchecked(&self.0) } + } +} + +impl AsRef for ImStr { + #[inline] + fn as_ref(&self) -> &ImStr { + self + } +} + +impl AsRef for ImStr { + #[inline] + fn as_ref(&self) -> &str { + self.to_str() + } +} + +impl<'a> From<&'a ImStr> for Cow<'a, ImStr> { + #[inline] + fn from(s: &'a ImStr) -> Cow<'a, ImStr> { + Cow::Borrowed(s) + } +} + +impl ToOwned for ImStr { + type Owned = ImString; + #[inline] + fn to_owned(&self) -> ImString { + self.sanity_check(); + ImString(self.0.to_owned()) + } +} + +#[test] +fn test_imstring_constructors() { + let s = ImString::new("test"); + assert_eq!(s.0, b"test\0"); + + let s = ImString::with_capacity(100); + assert_eq!(s.0, b"\0"); + + let s = unsafe { ImString::from_utf8_unchecked(vec![b't', b'e', b's', b't']) }; + assert_eq!(s.0, b"test\0"); + + let s = unsafe { ImString::from_utf8_with_nul_unchecked(vec![b't', b'e', b's', b't', b'\0']) }; + assert_eq!(s.0, b"test\0"); +} + +#[test] +fn test_imstring_operations() { + let mut s = ImString::new("test"); + s.clear(); + assert_eq!(s.0, b"\0"); + s.push('z'); + assert_eq!(s.0, b"z\0"); + s.push('ä'); + assert_eq!(s.0, b"z\xc3\xa4\0"); + s.clear(); + s.push_str("imgui-rs"); + assert_eq!(s.0, b"imgui-rs\0"); + s.push_str("öä"); + assert_eq!(s.0, b"imgui-rs\xc3\xb6\xc3\xa4\0"); +} + +#[test] +fn test_imstring_fmt_write() { + use std::fmt::Write; + let mut s = ImString::default(); + let _ = write!(s, "format {:02x}", 0x42); + assert_eq!(s.0, b"format 42\0"); +} + +#[test] +fn test_imstring_refresh_len() { + let mut s = ImString::new("testing"); + unsafe { + let mut ptr = s.as_mut_ptr() as *mut u8; + ptr = ptr.wrapping_add(2); + *ptr = b'z'; + ptr = ptr.wrapping_add(1); + *ptr = b'\0'; + } + assert_eq!(s.0, b"tez\0ing\0"); + unsafe { s.refresh_len() }; + assert_eq!(s.0, b"tez\0"); +} + +#[test] +fn test_imstring_interior_nul() { + let s = ImString::new("test\0ohno"); + assert_eq!(s.0, b"test\0"); + assert_eq!(s.to_str(), "test"); + assert!(!s.is_empty()); + + let s = ImString::new("\0ohno"); + assert_eq!(s.to_str(), ""); + assert!(s.is_empty()); +} diff --git a/plugins/libimhex-rust/imgui-rs/src/style.rs b/plugins/libimhex-rust/imgui-rs/src/style.rs new file mode 100644 index 000000000..a0f1d18e9 --- /dev/null +++ b/plugins/libimhex-rust/imgui-rs/src/style.rs @@ -0,0 +1,506 @@ +use std::ops::{Index, IndexMut}; + +use crate::internal::RawCast; +use crate::sys; +use crate::Direction; + +/// User interface style/colors +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Style { + /// Global alpha applies to everything + pub alpha: f32, + /// Additional alpha multiplier applied to disabled elements. Multiplies over current value of [`Style::alpha`]. + pub disabled_alpha: f32, + /// Padding within a window + pub window_padding: [f32; 2], + /// Rounding radius of window corners. + /// + /// Set to 0.0 to have rectangular windows. + /// Large values tend to lead to a variety of artifacts and are not recommended. + pub window_rounding: f32, + /// Thickness of border around windows. + /// + /// Generally set to 0.0 or 1.0 (other values are not well tested and cost more CPU/GPU). + pub window_border_size: f32, + /// Minimum window size + pub window_min_size: [f32; 2], + /// Alignment for title bar text. + /// + /// Defaults to [0.5, 0.5] for left-aligned, vertically centered. + pub window_title_align: [f32; 2], + /// Side of the collapsing/docking button in the title bar (left/right). + /// + /// Defaults to Direction::Left. + pub window_menu_button_position: Direction, + /// Rounding radius of child window corners. + /// + /// Set to 0.0 to have rectangular child windows. + pub child_rounding: f32, + /// Thickness of border around child windows. + /// + /// Generally set to 0.0 or 1.0 (other values are not well tested and cost more CPU/GPU). + pub child_border_size: f32, + /// Rounding radius of popup window corners. + /// + /// Note that tooltip windows use `window_rounding` instead. + pub popup_rounding: f32, + /// Thickness of border around popup/tooltip windows. + /// + /// Generally set to 0.0 or 1.0 (other values are not well tested and cost more CPU/GPU). + pub popup_border_size: f32, + /// Padding within a framed rectangle (used by most widgets) + pub frame_padding: [f32; 2], + /// Rounding radius of frame corners (used by most widgets). + /// + /// Set to 0.0 to have rectangular frames. + pub frame_rounding: f32, + /// Thickness of border around frames. + /// + /// Generally set to 0.0 or 1.0 (other values are not well tested and cost more CPU/GPU). + pub frame_border_size: f32, + /// Horizontal and vertical spacing between widgets/lines + pub item_spacing: [f32; 2], + /// Horizontal and vertical spacing between elements of a composed widget (e.g. a slider and + /// its label) + pub item_inner_spacing: [f32; 2], + /// Padding within a table cell. + pub cell_padding: [f32; 2], + /// 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: [f32; 2], + /// Horizontal indentation when e.g. entering a tree node. + /// + /// Generally equal to (font size + horizontal frame padding * 2). + pub indent_spacing: f32, + /// Minimum horizontal spacing between two columns + pub columns_min_spacing: f32, + /// Width of the vertical scrollbar, height of the horizontal scrollbar + pub scrollbar_size: f32, + /// Rounding radius of scrollbar grab corners + pub scrollbar_rounding: f32, + /// Minimum width/height of a grab box for slider/scrollbar + pub grab_min_size: f32, + /// Rounding radius of grab corners. + /// + /// Set to 0.0 to have rectangular slider grabs. + pub grab_rounding: f32, + /// The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero + pub log_slider_deadzone: f32, + /// Rounding radius of upper corners of tabs. + /// + /// Set to 0.0 to have rectangular tabs. + pub tab_rounding: f32, + /// Thickness of border around tabs + pub tab_border_size: f32, + /// Minimum width for close button to appear on an unselected tab when hovered. + /// + /// `= 0.0`: always show when hovering + /// `= f32::MAX`: never show close button unless selected + pub tab_min_width_for_close_button: f32, + /// Side of the color buttonton pubin color editor widgets (left/right). + pub color_button_position: Direction, + /// Alignment of button text when button is larger than text. + /// + /// Defaults to [0.5, 0.5] (centered). + pub button_text_align: [f32; 2], + /// Alignment of selectable text when selectable is larger than text. + /// + /// Defaults to [0.5, 0.5] (top-left aligned). + pub selectable_text_align: [f32; 2], + /// Window positions are clamped to be visible within the display area or monitors by at least + /// this amount. + /// + /// Only applies to regular windows. + pub display_window_padding: [f32; 2], + /// If you cannot see the edges of your screen (e.g. on a TV), increase the safe area padding. + /// + /// Also applies to popups/tooltips in addition to regular windows. + pub display_safe_area_padding: [f32; 2], + /// Scale software-rendered mouse cursor. + /// + /// May be removed later. + pub mouse_cursor_scale: f32, + /// Enable anti-aliased lines/borders. + /// + /// Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame. + pub anti_aliased_lines: bool, + /// Enable anti-aliased lines/borders using textures where possible. + /// + /// Require back-end to render with bilinear filtering. Latched at the beginning of the frame. + pub anti_aliased_lines_use_tex: bool, + /// Enable anti-aliased edges around filled shapes (rounded recatngles, circles, etc.). + /// + /// Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame. + pub anti_aliased_fill: bool, + /// Tessellation tolerance when using path_bezier_curve_to without a specific number of + /// segments. + /// + /// Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce + /// quality. + pub curve_tessellation_tol: f32, + /// Maximum error (in pixels) allowed when drawing circles or rounded corner rectangles with no + /// explicit segment count specified. + /// + /// Decrease for higher quality but more geometry. + pub circle_tesselation_max_error: f32, + /// Style colors. + pub colors: [[f32; 4]; StyleColor::COUNT], +} + +unsafe impl RawCast for Style {} + +impl Style { + /// Scales all sizes in the style + #[doc(alias = "ScaleAllSizes")] + pub fn scale_all_sizes(&mut self, scale_factor: f32) { + unsafe { + sys::ImGuiStyle_ScaleAllSizes(self.raw_mut(), scale_factor); + } + } + /// Replaces current colors with classic Dear ImGui style + #[doc(alias = "StyleColors", alias = "StlyeColorsClassic")] + pub fn use_classic_colors(&mut self) -> &mut Self { + unsafe { + sys::igStyleColorsClassic(self.raw_mut()); + } + self + } + /// Replaces current colors with a new, recommended style + #[doc(alias = "StyleColors", alias = "StyleColorsDark")] + pub fn use_dark_colors(&mut self) -> &mut Self { + unsafe { + sys::igStyleColorsDark(self.raw_mut()); + } + self + } + /// Replaces current colors with a light style. Best used with borders and a custom, thicker + /// font + #[doc(alias = "StyleColors", alias = "StyleColorsLight")] + pub fn use_light_colors(&mut self) -> &mut Self { + unsafe { + sys::igStyleColorsLight(self.raw_mut()); + } + self + } +} + +impl Index for Style { + type Output = [f32; 4]; + #[inline] + fn index(&self, index: StyleColor) -> &[f32; 4] { + &self.colors[index as usize] + } +} + +impl IndexMut for Style { + #[inline] + fn index_mut(&mut self, index: StyleColor) -> &mut [f32; 4] { + &mut self.colors[index as usize] + } +} + +/// A color identifier for styling +#[repr(u32)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +pub enum StyleColor { + Text = sys::ImGuiCol_Text, + TextDisabled = sys::ImGuiCol_TextDisabled, + /// Background of normal windows + WindowBg = sys::ImGuiCol_WindowBg, + /// Background of child windows + ChildBg = sys::ImGuiCol_ChildBg, + /// Background of popups, menus, tooltips windows + PopupBg = sys::ImGuiCol_PopupBg, + Border = sys::ImGuiCol_Border, + BorderShadow = sys::ImGuiCol_BorderShadow, + /// Background of checkbox, radio button, plot, slider, text input + FrameBg = sys::ImGuiCol_FrameBg, + FrameBgHovered = sys::ImGuiCol_FrameBgHovered, + FrameBgActive = sys::ImGuiCol_FrameBgActive, + TitleBg = sys::ImGuiCol_TitleBg, + TitleBgActive = sys::ImGuiCol_TitleBgActive, + TitleBgCollapsed = sys::ImGuiCol_TitleBgCollapsed, + MenuBarBg = sys::ImGuiCol_MenuBarBg, + ScrollbarBg = sys::ImGuiCol_ScrollbarBg, + ScrollbarGrab = sys::ImGuiCol_ScrollbarGrab, + ScrollbarGrabHovered = sys::ImGuiCol_ScrollbarGrabHovered, + ScrollbarGrabActive = sys::ImGuiCol_ScrollbarGrabActive, + CheckMark = sys::ImGuiCol_CheckMark, + SliderGrab = sys::ImGuiCol_SliderGrab, + SliderGrabActive = sys::ImGuiCol_SliderGrabActive, + Button = sys::ImGuiCol_Button, + ButtonHovered = sys::ImGuiCol_ButtonHovered, + ButtonActive = sys::ImGuiCol_ButtonActive, + Header = sys::ImGuiCol_Header, + HeaderHovered = sys::ImGuiCol_HeaderHovered, + HeaderActive = sys::ImGuiCol_HeaderActive, + Separator = sys::ImGuiCol_Separator, + SeparatorHovered = sys::ImGuiCol_SeparatorHovered, + SeparatorActive = sys::ImGuiCol_SeparatorActive, + ResizeGrip = sys::ImGuiCol_ResizeGrip, + ResizeGripHovered = sys::ImGuiCol_ResizeGripHovered, + ResizeGripActive = sys::ImGuiCol_ResizeGripActive, + Tab = sys::ImGuiCol_Tab, + TabHovered = sys::ImGuiCol_TabHovered, + TabActive = sys::ImGuiCol_TabActive, + TabUnfocused = sys::ImGuiCol_TabUnfocused, + TabUnfocusedActive = sys::ImGuiCol_TabUnfocusedActive, + PlotLines = sys::ImGuiCol_PlotLines, + PlotLinesHovered = sys::ImGuiCol_PlotLinesHovered, + PlotHistogram = sys::ImGuiCol_PlotHistogram, + PlotHistogramHovered = sys::ImGuiCol_PlotHistogramHovered, + TableHeaderBg = sys::ImGuiCol_TableHeaderBg, + TableBorderStrong = sys::ImGuiCol_TableBorderStrong, + TableBorderLight = sys::ImGuiCol_TableBorderLight, + TableRowBg = sys::ImGuiCol_TableRowBg, + TableRowBgAlt = sys::ImGuiCol_TableRowBgAlt, + TextSelectedBg = sys::ImGuiCol_TextSelectedBg, + DragDropTarget = sys::ImGuiCol_DragDropTarget, + /// Gamepad/keyboard: current highlighted item + NavHighlight = sys::ImGuiCol_NavHighlight, + /// Highlight window when using CTRL+TAB + NavWindowingHighlight = sys::ImGuiCol_NavWindowingHighlight, + /// Darken/colorize entire screen behind the CTRL+TAB window list, when active + NavWindowingDimBg = sys::ImGuiCol_NavWindowingDimBg, + /// Darken/colorize entire screen behind a modal window, when one is active + ModalWindowDimBg = sys::ImGuiCol_ModalWindowDimBg, +} + +impl StyleColor { + /// All possible `StyleColor` variants + pub const VARIANTS: [StyleColor; StyleColor::COUNT] = [ + StyleColor::Text, + StyleColor::TextDisabled, + StyleColor::WindowBg, + StyleColor::ChildBg, + StyleColor::PopupBg, + StyleColor::Border, + StyleColor::BorderShadow, + StyleColor::FrameBg, + StyleColor::FrameBgHovered, + StyleColor::FrameBgActive, + StyleColor::TitleBg, + StyleColor::TitleBgActive, + StyleColor::TitleBgCollapsed, + StyleColor::MenuBarBg, + StyleColor::ScrollbarBg, + StyleColor::ScrollbarGrab, + StyleColor::ScrollbarGrabHovered, + StyleColor::ScrollbarGrabActive, + StyleColor::CheckMark, + StyleColor::SliderGrab, + StyleColor::SliderGrabActive, + StyleColor::Button, + StyleColor::ButtonHovered, + StyleColor::ButtonActive, + StyleColor::Header, + StyleColor::HeaderHovered, + StyleColor::HeaderActive, + StyleColor::Separator, + StyleColor::SeparatorHovered, + StyleColor::SeparatorActive, + StyleColor::ResizeGrip, + StyleColor::ResizeGripHovered, + StyleColor::ResizeGripActive, + StyleColor::Tab, + StyleColor::TabHovered, + StyleColor::TabActive, + StyleColor::TabUnfocused, + StyleColor::TabUnfocusedActive, + StyleColor::PlotLines, + StyleColor::PlotLinesHovered, + StyleColor::PlotHistogram, + StyleColor::PlotHistogramHovered, + StyleColor::TableHeaderBg, + StyleColor::TableBorderStrong, + StyleColor::TableBorderLight, + StyleColor::TableRowBg, + StyleColor::TableRowBgAlt, + StyleColor::TextSelectedBg, + StyleColor::DragDropTarget, + StyleColor::NavHighlight, + StyleColor::NavWindowingHighlight, + StyleColor::NavWindowingDimBg, + StyleColor::ModalWindowDimBg, + ]; + /// Total count of `StyleColor` variants + pub const COUNT: usize = sys::ImGuiCol_COUNT as usize; +} + +/// A temporary change in user interface style +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum StyleVar { + /// Global alpha applies to everything + Alpha(f32), + /// Padding within a window + WindowPadding([f32; 2]), + /// Rounding radius of window corners + WindowRounding(f32), + /// Thickness of border around windows + WindowBorderSize(f32), + /// Minimum window size + WindowMinSize([f32; 2]), + /// Alignment for title bar text + WindowTitleAlign([f32; 2]), + /// Rounding radius of child window corners + ChildRounding(f32), + /// Thickness of border around child windows + ChildBorderSize(f32), + /// Rounding radius of popup window corners + PopupRounding(f32), + /// Thickness of border around popup/tooltip windows + PopupBorderSize(f32), + /// Padding within a framed rectangle (used by most widgets) + FramePadding([f32; 2]), + /// Rounding radius of frame corners (used by most widgets) + FrameRounding(f32), + /// Thickness of border around frames + FrameBorderSize(f32), + /// Horizontal and vertical spacing between widgets/lines + ItemSpacing([f32; 2]), + /// Horizontal and vertical spacing between elements of a composed widget (e.g. a slider and + /// its label) + ItemInnerSpacing([f32; 2]), + /// Horizontal indentation when e.g. entering a tree node + IndentSpacing(f32), + /// Width of the vertical scrollbar, height of the horizontal scrollbar + ScrollbarSize(f32), + /// Rounding radius of scrollbar grab corners + ScrollbarRounding(f32), + /// Minimum width/height of a grab box for slider/scrollbar + GrabMinSize(f32), + /// Rounding radius of grab corners + GrabRounding(f32), + /// Rounding radius of upper corners of tabs + TabRounding(f32), + /// Alignment of button text when button is larger than text + ButtonTextAlign([f32; 2]), + /// Alignment of selectable text when selectable is larger than text + SelectableTextAlign([f32; 2]), +} + +#[test] +fn test_style_scaling() { + let (_guard, mut ctx) = crate::test::test_ctx(); + let style = ctx.style_mut(); + style.window_padding = [1.0, 2.0]; + style.window_rounding = 3.0; + style.window_min_size = [4.0, 5.0]; + style.child_rounding = 6.0; + style.popup_rounding = 7.0; + style.frame_padding = [8.0, 9.0]; + style.frame_rounding = 10.0; + style.item_spacing = [11.0, 12.0]; + style.item_inner_spacing = [13.0, 14.0]; + style.touch_extra_padding = [15.0, 16.0]; + style.indent_spacing = 17.0; + style.columns_min_spacing = 18.0; + style.scrollbar_size = 19.0; + style.scrollbar_rounding = 20.0; + style.grab_min_size = 21.0; + style.grab_rounding = 22.0; + style.log_slider_deadzone = 29.0; + style.tab_rounding = 23.0; + style.display_window_padding = [24.0, 25.0]; + style.display_safe_area_padding = [26.0, 27.0]; + style.mouse_cursor_scale = 28.0; + style.scale_all_sizes(2.0); + assert_eq!(style.window_padding, [2.0, 4.0]); + assert_eq!(style.window_rounding, 6.0); + assert_eq!(style.window_min_size, [8.0, 10.0]); + assert_eq!(style.child_rounding, 12.0); + assert_eq!(style.popup_rounding, 14.0); + assert_eq!(style.frame_padding, [16.0, 18.0]); + assert_eq!(style.frame_rounding, 20.0); + assert_eq!(style.item_spacing, [22.0, 24.0]); + assert_eq!(style.item_inner_spacing, [26.0, 28.0]); + assert_eq!(style.touch_extra_padding, [30.0, 32.0]); + assert_eq!(style.indent_spacing, 34.0); + assert_eq!(style.columns_min_spacing, 36.0); + assert_eq!(style.scrollbar_size, 38.0); + assert_eq!(style.scrollbar_rounding, 40.0); + assert_eq!(style.grab_min_size, 42.0); + assert_eq!(style.grab_rounding, 44.0); + assert_eq!(style.log_slider_deadzone, 58.0); + assert_eq!(style.tab_rounding, 46.0); + assert_eq!(style.display_window_padding, [48.0, 50.0]); + assert_eq!(style.display_safe_area_padding, [52.0, 54.0]); + assert_eq!(style.mouse_cursor_scale, 56.0); +} + +#[test] +fn test_style_color_indexing() { + let (_guard, mut ctx) = crate::test::test_ctx(); + let style = ctx.style_mut(); + let value = [0.1, 0.2, 0.3, 1.0]; + style[StyleColor::Tab] = value; + assert_eq!(style[StyleColor::Tab], value); + assert_eq!(style.colors[StyleColor::Tab as usize], value); +} + +#[test] +#[cfg(test)] +fn test_style_memory_layout() { + use std::mem; + assert_eq!(mem::size_of::