Update imgui, random cheats, improvements
This commit is contained in:
parent
def185a237
commit
ce7641e08b
10
.vscode/c_cpp_properties.json
vendored
10
.vscode/c_cpp_properties.json
vendored
@ -6,10 +6,10 @@
|
|||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
"${PLUGIN_SDK_DIR}/*",
|
"${PLUGIN_SDK_DIR}/*",
|
||||||
"${DIRECTX9_SDK_DIR}/Include/*",
|
"${DIRECTX9_SDK_DIR}/Include/*",
|
||||||
// "${PLUGIN_SDK_DIR}/plugin_sa/*",
|
"${PLUGIN_SDK_DIR}/plugin_sa/*",
|
||||||
// "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
|
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
|
||||||
"${PLUGIN_SDK_DIR}/plugin_vc/*",
|
// "${PLUGIN_SDK_DIR}/plugin_vc/*",
|
||||||
"${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*",
|
// "${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*",
|
||||||
"${PLUGIN_SDK_DIR}/shared/*",
|
"${PLUGIN_SDK_DIR}/shared/*",
|
||||||
"${PLUGIN_SDK_DIR}/shared/game/*",
|
"${PLUGIN_SDK_DIR}/shared/game/*",
|
||||||
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*",
|
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"IS_PLATFORM_WIN",
|
"IS_PLATFORM_WIN",
|
||||||
"_CRT_SECURE_NO_WARNINGS",
|
"_CRT_SECURE_NO_WARNINGS",
|
||||||
"_CRT_NON_CONFORMING_SWPRINTFS",
|
"_CRT_NON_CONFORMING_SWPRINTFS",
|
||||||
"GTAVC",
|
"GTASA",
|
||||||
"_DX9_SDK_INSTALLED",
|
"_DX9_SDK_INSTALLED",
|
||||||
"PLUGIN_SGV_10US"
|
"PLUGIN_SGV_10US"
|
||||||
],
|
],
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
//---- Don't implement some functions to reduce linkage requirements.
|
//---- Don't implement some functions to reduce linkage requirements.
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
|
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||||
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||||
@ -45,6 +46,7 @@
|
|||||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||||
|
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||||
|
|
||||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||||
@ -68,7 +70,7 @@
|
|||||||
|
|
||||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||||
// On Windows you may use vcpkg with 'vcpkg install freetype' + 'vcpkg integrate install'.
|
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||||
//#define IMGUI_ENABLE_FREETYPE
|
//#define IMGUI_ENABLE_FREETYPE
|
||||||
|
|
||||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.83
|
// dear imgui, v1.84
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -11,7 +11,7 @@
|
|||||||
// - FAQ http://dearimgui.org/faq
|
// - FAQ http://dearimgui.org/faq
|
||||||
// - Homepage & latest https://github.com/ocornut/imgui
|
// - Homepage & latest https://github.com/ocornut/imgui
|
||||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||||
// - Gallery https://github.com/ocornut/imgui/issues/3793 (please post your screenshots/video there!)
|
// - Gallery https://github.com/ocornut/imgui/issues/4451 (please post your screenshots/video there!)
|
||||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||||
@ -60,8 +60,8 @@ Index of this file:
|
|||||||
|
|
||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.83"
|
#define IMGUI_VERSION "1.84.2"
|
||||||
#define IMGUI_VERSION_NUM 18300
|
#define IMGUI_VERSION_NUM 18405
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
||||||
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__clang__)
|
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__)
|
||||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
|
||||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
|
||||||
#elif !defined(IMGUI_USE_STB_SPRINTF) && defined(__GNUC__) && defined(__MINGW32__)
|
|
||||||
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
||||||
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
||||||
|
#elif !defined(IMGUI_USE_STB_SPRINTF) && (defined(__clang__) || defined(__GNUC__))
|
||||||
|
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||||
|
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||||
#else
|
#else
|
||||||
#define IM_FMTARGS(FMT)
|
#define IM_FMTARGS(FMT)
|
||||||
#define IM_FMTLIST(FMT)
|
#define IM_FMTLIST(FMT)
|
||||||
@ -160,7 +160,7 @@ struct ImGuiTextBuffer; // Helper to hold and append into a text buf
|
|||||||
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
|
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
|
||||||
struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor
|
struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor
|
||||||
|
|
||||||
// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file)
|
// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags without overhead, and to not pollute the top of this file)
|
||||||
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
||||||
// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
@ -200,27 +200,22 @@ typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: f
|
|||||||
typedef int ImGuiViewportFlags; // -> enum ImGuiViewportFlags_ // Flags: for ImGuiViewport
|
typedef int ImGuiViewportFlags; // -> enum ImGuiViewportFlags_ // Flags: for ImGuiViewport
|
||||||
typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild()
|
typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild()
|
||||||
|
|
||||||
// Other types
|
// ImTexture: user data for renderer backend to identify a texture [Compile-time configurable type]
|
||||||
#ifndef ImTextureID // ImTextureID [configurable type: override in imconfig.h with '#define ImTextureID xxx']
|
// - To use something else than an opaque void* pointer: override with e.g. '#define ImTextureID MyTextureType*' in your imconfig.h file.
|
||||||
typedef void* ImTextureID; // User data for rendering backend to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
|
// - This can be whatever to you want it to be! read the FAQ about ImTextureID for details.
|
||||||
#endif
|
#ifndef ImTextureID
|
||||||
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
typedef void* ImTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that)
|
||||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
|
|
||||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
|
|
||||||
typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
|
||||||
typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
|
||||||
|
|
||||||
// Character types
|
|
||||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
|
||||||
typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
|
||||||
typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
|
||||||
#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16]
|
|
||||||
typedef ImWchar32 ImWchar;
|
|
||||||
#else
|
|
||||||
typedef ImWchar16 ImWchar;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Basic scalar data types
|
// ImDrawIdx: vertex index. [Compile-time configurable type]
|
||||||
|
// - To use 16-bit indices + allow large meshes: backend need to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset (recommended).
|
||||||
|
// - To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in your imconfig.h file.
|
||||||
|
#ifndef ImDrawIdx
|
||||||
|
typedef unsigned short ImDrawIdx; // Default: 16-bit (for maximum compatibility with renderer backends)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Scalar data types
|
||||||
|
typedef unsigned int ImGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string)
|
||||||
typedef signed char ImS8; // 8-bit signed integer
|
typedef signed char ImS8; // 8-bit signed integer
|
||||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||||
typedef signed short ImS16; // 16-bit signed integer
|
typedef signed short ImS16; // 16-bit signed integer
|
||||||
@ -239,7 +234,24 @@ typedef signed long long ImS64; // 64-bit signed integer (post C++11)
|
|||||||
typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
|
typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 2D vector (often used to store positions or sizes)
|
// Character types
|
||||||
|
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||||
|
typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
||||||
|
typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
||||||
|
#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16]
|
||||||
|
typedef ImWchar32 ImWchar;
|
||||||
|
#else
|
||||||
|
typedef ImWchar16 ImWchar;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Callback and functions types
|
||||||
|
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
|
||||||
|
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
|
||||||
|
typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||||
|
typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||||
|
|
||||||
|
// ImVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type]
|
||||||
|
// This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type.
|
||||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||||
struct ImVec2
|
struct ImVec2
|
||||||
{
|
{
|
||||||
@ -253,7 +265,7 @@ struct ImVec2
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// 4D vector (often used to store floating-point colors)
|
// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
|
||||||
struct ImVec4
|
struct ImVec4
|
||||||
{
|
{
|
||||||
float x, y, z, w;
|
float x, y, z, w;
|
||||||
@ -343,7 +355,8 @@ namespace ImGui
|
|||||||
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
|
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
|
||||||
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
||||||
|
|
||||||
// Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
// Window manipulation
|
||||||
|
// - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
||||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
||||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||||
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
|
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
|
||||||
@ -355,7 +368,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||||
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
||||||
IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
||||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
|
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
|
||||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
||||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
||||||
@ -405,6 +418,7 @@ namespace ImGui
|
|||||||
IMGUI_API void PopTextWrapPos();
|
IMGUI_API void PopTextWrapPos();
|
||||||
|
|
||||||
// Style read access
|
// Style read access
|
||||||
|
// - Use the style editor (ShowStyleEditor() function) to interactively see what the colors are)
|
||||||
IMGUI_API ImFont* GetFont(); // get current font
|
IMGUI_API ImFont* GetFont(); // get current font
|
||||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
||||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||||
@ -445,11 +459,15 @@ namespace ImGui
|
|||||||
IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
|
IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
|
||||||
|
|
||||||
// ID stack/scopes
|
// ID stack/scopes
|
||||||
// - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most
|
// Read the FAQ (docs/FAQ.md or http://dearimgui.org/faq) for more details about how ID are handled in dear imgui.
|
||||||
// likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them.
|
// - Those questions are answered and impacted by understanding of the ID stack system:
|
||||||
// - The resulting ID are hashes of the entire stack.
|
// - "Q: Why is my widget not reacting when I click on it?"
|
||||||
|
// - "Q: How can I have widgets with an empty label?"
|
||||||
|
// - "Q: How can I have multiple widgets with the same label?"
|
||||||
|
// - Short version: ID are hashes of the entire ID stack. If you are creating widgets in a loop you most likely
|
||||||
|
// want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them.
|
||||||
// - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
|
// - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
|
||||||
// - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID,
|
// - In this header file we use the "label"/"name" terminology to denote a string that will be displayed + used as an ID,
|
||||||
// whereas "str_id" denote a string that is only used as an ID and not normally displayed.
|
// whereas "str_id" denote a string that is only used as an ID and not normally displayed.
|
||||||
IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string).
|
IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string).
|
||||||
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string).
|
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string).
|
||||||
@ -612,7 +630,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool ListBox(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 = -1);
|
IMGUI_API bool ListBox(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 = -1);
|
||||||
|
|
||||||
// Widgets: Data Plotting
|
// Widgets: Data Plotting
|
||||||
// - Consider using ImPlot (https://github.com/epezent/implot)
|
// - Consider using ImPlot (https://github.com/epezent/implot) which is much better!
|
||||||
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||||
IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||||
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||||
@ -654,12 +672,14 @@ namespace ImGui
|
|||||||
// - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
// - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
||||||
// - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack.
|
// - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack.
|
||||||
// This is sometimes leading to confusing mistakes. May rework this in the future.
|
// This is sometimes leading to confusing mistakes. May rework this in the future.
|
||||||
|
|
||||||
// Popups: begin/end functions
|
// Popups: begin/end functions
|
||||||
// - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window.
|
// - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window.
|
||||||
// - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar.
|
// - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar.
|
||||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
||||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||||
|
|
||||||
// Popups: open/close functions
|
// Popups: open/close functions
|
||||||
// - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options.
|
// - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options.
|
||||||
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||||
@ -671,6 +691,7 @@ namespace ImGui
|
|||||||
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
||||||
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||||
|
|
||||||
// Popups: open+begin combined functions helpers
|
// Popups: open+begin combined functions helpers
|
||||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
// - They are convenient to easily create context menus, hence the name.
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
@ -679,6 +700,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
|
|
||||||
// Popups: query functions
|
// Popups: query functions
|
||||||
// - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
|
// - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
|
||||||
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
|
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
|
||||||
@ -715,6 +737,7 @@ namespace ImGui
|
|||||||
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
|
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
|
||||||
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
|
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
|
||||||
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.
|
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.
|
||||||
|
|
||||||
// Tables: Headers & Columns declaration
|
// Tables: Headers & Columns declaration
|
||||||
// - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.
|
// - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.
|
||||||
// - Use TableHeadersRow() to create a header row and automatically submit a TableHeader() for each column.
|
// - Use TableHeadersRow() to create a header row and automatically submit a TableHeader() for each column.
|
||||||
@ -727,6 +750,7 @@ namespace ImGui
|
|||||||
IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
|
IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
|
||||||
IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
|
IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
|
||||||
IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used)
|
IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used)
|
||||||
|
|
||||||
// Tables: Sorting
|
// Tables: Sorting
|
||||||
// - Call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting.
|
// - Call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting.
|
||||||
// - When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed
|
// - When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed
|
||||||
@ -734,6 +758,7 @@ namespace ImGui
|
|||||||
// wastefully sort your data every frame!
|
// wastefully sort your data every frame!
|
||||||
// - Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
|
// - Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
|
||||||
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting).
|
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting).
|
||||||
|
|
||||||
// Tables: Miscellaneous functions
|
// Tables: Miscellaneous functions
|
||||||
// - Functions args 'int column_n' treat the default value of -1 as the same as passing the current column index.
|
// - Functions args 'int column_n' treat the default value of -1 as the same as passing the current column index.
|
||||||
IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
|
IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
|
||||||
@ -741,10 +766,10 @@ namespace ImGui
|
|||||||
IMGUI_API int TableGetRowIndex(); // return current row index.
|
IMGUI_API int TableGetRowIndex(); // return current row index.
|
||||||
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
||||||
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
||||||
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change enabled/disabled state of a column, set to false to hide the column. Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||||
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details.
|
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details.
|
||||||
|
|
||||||
// Legacy Columns API (2020: prefer using Tables!)
|
// Legacy Columns API (prefer using Tables!)
|
||||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
|
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
|
||||||
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
|
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
|
||||||
@ -786,6 +811,12 @@ namespace ImGui
|
|||||||
IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
|
IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
|
||||||
IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type.
|
IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type.
|
||||||
|
|
||||||
|
// Disabling [BETA API]
|
||||||
|
// - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors)
|
||||||
|
// - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it.
|
||||||
|
IMGUI_API void BeginDisabled(bool disabled = true);
|
||||||
|
IMGUI_API void EndDisabled();
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
// - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only.
|
// - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only.
|
||||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
||||||
@ -885,6 +916,7 @@ namespace ImGui
|
|||||||
// Settings/.Ini Utilities
|
// Settings/.Ini Utilities
|
||||||
// - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini").
|
// - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini").
|
||||||
// - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
|
// - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
|
||||||
|
// - Important: default value "imgui.ini" is relative to current working dir! Most apps will want to lock this to an absolute path (e.g. same path as executables).
|
||||||
IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
|
IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
|
||||||
IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
|
IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
|
||||||
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
|
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
|
||||||
@ -932,7 +964,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
|
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
|
||||||
ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
|
ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
|
||||||
ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
||||||
ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
|
ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
|
||||||
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
||||||
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
@ -1070,7 +1102,7 @@ enum ImGuiTabBarFlags_
|
|||||||
enum ImGuiTabItemFlags_
|
enum ImGuiTabItemFlags_
|
||||||
{
|
{
|
||||||
ImGuiTabItemFlags_None = 0,
|
ImGuiTabItemFlags_None = 0,
|
||||||
ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
|
ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Display a dot next to the title + tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
|
||||||
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
||||||
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
||||||
ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
||||||
@ -1164,28 +1196,30 @@ enum ImGuiTableColumnFlags_
|
|||||||
{
|
{
|
||||||
// Input configuration flags
|
// Input configuration flags
|
||||||
ImGuiTableColumnFlags_None = 0,
|
ImGuiTableColumnFlags_None = 0,
|
||||||
ImGuiTableColumnFlags_DefaultHide = 1 << 0, // Default as a hidden/disabled column.
|
ImGuiTableColumnFlags_Disabled = 1 << 0, // Overriding/master disable flag: hide column, won't show in context menu (unlike calling TableSetColumnEnabled() which manipulates the user accessible state)
|
||||||
ImGuiTableColumnFlags_DefaultSort = 1 << 1, // Default as a sorting column.
|
ImGuiTableColumnFlags_DefaultHide = 1 << 1, // Default as a hidden/disabled column.
|
||||||
ImGuiTableColumnFlags_WidthStretch = 1 << 2, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingStretchSame or _SizingStretchProp).
|
ImGuiTableColumnFlags_DefaultSort = 1 << 2, // Default as a sorting column.
|
||||||
ImGuiTableColumnFlags_WidthFixed = 1 << 3, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingFixedFit and table is resizable).
|
ImGuiTableColumnFlags_WidthStretch = 1 << 3, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingStretchSame or _SizingStretchProp).
|
||||||
ImGuiTableColumnFlags_NoResize = 1 << 4, // Disable manual resizing.
|
ImGuiTableColumnFlags_WidthFixed = 1 << 4, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingFixedFit and table is resizable).
|
||||||
ImGuiTableColumnFlags_NoReorder = 1 << 5, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
|
ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
|
||||||
ImGuiTableColumnFlags_NoHide = 1 << 6, // Disable ability to hide/disable this column.
|
ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
|
||||||
ImGuiTableColumnFlags_NoClip = 1 << 7, // Disable clipping for this column (all NoClip columns will render in a same draw command).
|
ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column.
|
||||||
ImGuiTableColumnFlags_NoSort = 1 << 8, // Disable ability to sort on this field (even if ImGuiTableFlags_Sortable is set on the table).
|
ImGuiTableColumnFlags_NoClip = 1 << 8, // Disable clipping for this column (all NoClip columns will render in a same draw command).
|
||||||
ImGuiTableColumnFlags_NoSortAscending = 1 << 9, // Disable ability to sort in the ascending direction.
|
ImGuiTableColumnFlags_NoSort = 1 << 9, // Disable ability to sort on this field (even if ImGuiTableFlags_Sortable is set on the table).
|
||||||
ImGuiTableColumnFlags_NoSortDescending = 1 << 10, // Disable ability to sort in the descending direction.
|
ImGuiTableColumnFlags_NoSortAscending = 1 << 10, // Disable ability to sort in the ascending direction.
|
||||||
ImGuiTableColumnFlags_NoHeaderWidth = 1 << 11, // Disable header text width contribution to automatic column width.
|
ImGuiTableColumnFlags_NoSortDescending = 1 << 11, // Disable ability to sort in the descending direction.
|
||||||
ImGuiTableColumnFlags_PreferSortAscending = 1 << 12, // Make the initial sort direction Ascending when first sorting on this column (default).
|
ImGuiTableColumnFlags_NoHeaderLabel = 1 << 12, // TableHeadersRow() will not submit label for this column. Convenient for some small columns. Name will still appear in context menu.
|
||||||
ImGuiTableColumnFlags_PreferSortDescending = 1 << 13, // Make the initial sort direction Descending when first sorting on this column.
|
ImGuiTableColumnFlags_NoHeaderWidth = 1 << 13, // Disable header text width contribution to automatic column width.
|
||||||
ImGuiTableColumnFlags_IndentEnable = 1 << 14, // Use current Indent value when entering cell (default for column 0).
|
ImGuiTableColumnFlags_PreferSortAscending = 1 << 14, // Make the initial sort direction Ascending when first sorting on this column (default).
|
||||||
ImGuiTableColumnFlags_IndentDisable = 1 << 15, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored.
|
ImGuiTableColumnFlags_PreferSortDescending = 1 << 15, // Make the initial sort direction Descending when first sorting on this column.
|
||||||
|
ImGuiTableColumnFlags_IndentEnable = 1 << 16, // Use current Indent value when entering cell (default for column 0).
|
||||||
|
ImGuiTableColumnFlags_IndentDisable = 1 << 17, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored.
|
||||||
|
|
||||||
// Output status flags, read-only via TableGetColumnFlags()
|
// Output status flags, read-only via TableGetColumnFlags()
|
||||||
ImGuiTableColumnFlags_IsEnabled = 1 << 20, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags.
|
ImGuiTableColumnFlags_IsEnabled = 1 << 24, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags.
|
||||||
ImGuiTableColumnFlags_IsVisible = 1 << 21, // Status: is visible == is enabled AND not clipped by scrolling.
|
ImGuiTableColumnFlags_IsVisible = 1 << 25, // Status: is visible == is enabled AND not clipped by scrolling.
|
||||||
ImGuiTableColumnFlags_IsSorted = 1 << 22, // Status: is currently part of the sort specs
|
ImGuiTableColumnFlags_IsSorted = 1 << 26, // Status: is currently part of the sort specs
|
||||||
ImGuiTableColumnFlags_IsHovered = 1 << 23, // Status: is hovered by mouse
|
ImGuiTableColumnFlags_IsHovered = 1 << 27, // Status: is hovered by mouse
|
||||||
|
|
||||||
// [Internal] Combinations and masks
|
// [Internal] Combinations and masks
|
||||||
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed,
|
ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed,
|
||||||
@ -1372,13 +1406,12 @@ enum ImGuiNavInput_
|
|||||||
|
|
||||||
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
|
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
|
||||||
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[].
|
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[].
|
||||||
ImGuiNavInput_KeyMenu_, // toggle menu // = io.KeyAlt
|
|
||||||
ImGuiNavInput_KeyLeft_, // move left // = Arrow keys
|
ImGuiNavInput_KeyLeft_, // move left // = Arrow keys
|
||||||
ImGuiNavInput_KeyRight_, // move right
|
ImGuiNavInput_KeyRight_, // move right
|
||||||
ImGuiNavInput_KeyUp_, // move up
|
ImGuiNavInput_KeyUp_, // move up
|
||||||
ImGuiNavInput_KeyDown_, // move down
|
ImGuiNavInput_KeyDown_, // move down
|
||||||
ImGuiNavInput_COUNT,
|
ImGuiNavInput_COUNT,
|
||||||
ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyMenu_
|
ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_
|
||||||
};
|
};
|
||||||
|
|
||||||
// Configuration flags stored in io.ConfigFlags. Set by user/application.
|
// Configuration flags stored in io.ConfigFlags. Set by user/application.
|
||||||
@ -1477,6 +1510,7 @@ enum ImGuiStyleVar_
|
|||||||
{
|
{
|
||||||
// Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
// Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
||||||
ImGuiStyleVar_Alpha, // float Alpha
|
ImGuiStyleVar_Alpha, // float Alpha
|
||||||
|
ImGuiStyleVar_DisabledAlpha, // float DisabledAlpha
|
||||||
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
||||||
ImGuiStyleVar_WindowRounding, // float WindowRounding
|
ImGuiStyleVar_WindowRounding, // float WindowRounding
|
||||||
ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize
|
ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize
|
||||||
@ -1548,13 +1582,13 @@ enum ImGuiColorEditFlags_
|
|||||||
|
|
||||||
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
||||||
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
||||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags_DefaultOptions_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar,
|
||||||
|
|
||||||
// [Internal] Masks
|
// [Internal] Masks
|
||||||
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex,
|
ImGuiColorEditFlags_DisplayMask_ = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex,
|
||||||
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float,
|
ImGuiColorEditFlags_DataTypeMask_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float,
|
||||||
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags_PickerMask_ = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar,
|
||||||
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
ImGuiColorEditFlags_InputMask_ = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
||||||
|
|
||||||
// Obsolete names (will be removed)
|
// Obsolete names (will be removed)
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
@ -1665,7 +1699,11 @@ struct ImVector
|
|||||||
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
||||||
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
||||||
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
||||||
inline ~ImVector() { if (Data) IM_FREE(Data); }
|
inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything
|
||||||
|
|
||||||
|
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything
|
||||||
|
inline void clear_delete() { for (int n = 0; n < Size; n++) IM_DELETE(Data[n]); clear(); } // Important: never called automatically! always explicit.
|
||||||
|
inline void clear_destruct() { for (int n = 0; n < Size; n++) Data[n].~T(); clear(); } // Important: never called automatically! always explicit.
|
||||||
|
|
||||||
inline bool empty() const { return Size == 0; }
|
inline bool empty() const { return Size == 0; }
|
||||||
inline int size() const { return Size; }
|
inline int size() const { return Size; }
|
||||||
@ -1675,7 +1713,6 @@ struct ImVector
|
|||||||
inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
|
|
||||||
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
|
||||||
inline T* begin() { return Data; }
|
inline T* begin() { return Data; }
|
||||||
inline const T* begin() const { return Data; }
|
inline const T* begin() const { return Data; }
|
||||||
inline T* end() { return Data + Size; }
|
inline T* end() { return Data + Size; }
|
||||||
@ -1720,6 +1757,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|||||||
struct ImGuiStyle
|
struct ImGuiStyle
|
||||||
{
|
{
|
||||||
float Alpha; // Global alpha applies to everything in Dear ImGui.
|
float Alpha; // Global alpha applies to everything in Dear ImGui.
|
||||||
|
float DisabledAlpha; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha.
|
||||||
ImVec2 WindowPadding; // Padding within a window.
|
ImVec2 WindowPadding; // Padding within a window.
|
||||||
float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended.
|
float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended.
|
||||||
float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
||||||
@ -1782,7 +1820,7 @@ struct ImGuiIO
|
|||||||
ImVec2 DisplaySize; // <unset> // Main display size, in pixels (generally == GetMainViewport()->Size)
|
ImVec2 DisplaySize; // <unset> // Main display size, in pixels (generally == GetMainViewport()->Size)
|
||||||
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
||||||
float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
|
float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
|
||||||
const char* IniFilename; // = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
|
const char* IniFilename; // = "imgui.ini" // Path to .ini file (important: default "imgui.ini" is relative to current working dir!). Set NULL to disable automatic .ini loading/saving or if you want to manually call LoadIniSettingsXXX() / SaveIniSettingsXXX() functions.
|
||||||
const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
|
const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
|
||||||
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
||||||
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
||||||
@ -1850,6 +1888,7 @@ struct ImGuiIO
|
|||||||
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate
|
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate
|
||||||
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
|
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
|
||||||
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
||||||
|
IMGUI_API void AddFocusEvent(bool focused); // Notifies Dear ImGui when hosting platform windows lose or gain input focus
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Output - Updated by NewFrame() or EndFrame()/Render()
|
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||||
@ -1877,6 +1916,7 @@ struct ImGuiIO
|
|||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
|
ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
|
||||||
|
ImGuiKeyModFlags KeyModsPrev; // Previous key mods
|
||||||
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
||||||
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
||||||
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
||||||
@ -2248,13 +2288,6 @@ struct ImDrawCmd
|
|||||||
inline ImTextureID GetTexID() const { return TextureId; }
|
inline ImTextureID GetTexID() const { return TextureId; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vertex index, default to 16-bit
|
|
||||||
// To allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer backend (recommended).
|
|
||||||
// To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in imconfig.h.
|
|
||||||
#ifndef ImDrawIdx
|
|
||||||
typedef unsigned short ImDrawIdx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Vertex layout
|
// Vertex layout
|
||||||
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
|
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
|
||||||
struct ImDrawVert
|
struct ImDrawVert
|
||||||
@ -2458,6 +2491,7 @@ struct ImDrawList
|
|||||||
IMGUI_API void _ResetForNewFrame();
|
IMGUI_API void _ResetForNewFrame();
|
||||||
IMGUI_API void _ClearFreeMemory();
|
IMGUI_API void _ClearFreeMemory();
|
||||||
IMGUI_API void _PopUnusedDrawCmd();
|
IMGUI_API void _PopUnusedDrawCmd();
|
||||||
|
IMGUI_API void _TryMergeDrawCmds();
|
||||||
IMGUI_API void _OnChangedClipRect();
|
IMGUI_API void _OnChangedClipRect();
|
||||||
IMGUI_API void _OnChangedTextureID();
|
IMGUI_API void _OnChangedTextureID();
|
||||||
IMGUI_API void _OnChangedVtxOffset();
|
IMGUI_API void _OnChangedVtxOffset();
|
||||||
@ -2608,7 +2642,7 @@ struct ImFontAtlas
|
|||||||
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||||
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
||||||
bool IsBuilt() const { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); }
|
bool IsBuilt() const { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when user didn't built texture but effectively we should check TexID != 0 except that would be backend dependent...
|
||||||
void SetTexID(ImTextureID id) { TexID = id; }
|
void SetTexID(ImTextureID id) { TexID = id; }
|
||||||
|
|
||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
@ -2658,6 +2692,7 @@ struct ImFontAtlas
|
|||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
|
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
|
||||||
|
bool TexReady; // Set when texture was built matching current font input
|
||||||
bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format.
|
bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format.
|
||||||
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
||||||
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
||||||
@ -2680,7 +2715,7 @@ struct ImFontAtlas
|
|||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
||||||
typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2702,8 +2737,9 @@ struct ImFont
|
|||||||
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
||||||
const ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData
|
const ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData
|
||||||
short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
||||||
ImWchar FallbackChar; // 2 // in // = '?' // Replacement character if a glyph isn't found. Only set via SetFallbackChar()
|
ImWchar FallbackChar; // 2 // out // = FFFD/'?' // Character used if a glyph isn't found.
|
||||||
ImWchar EllipsisChar; // 2 // out // = -1 // Character used for ellipsis rendering.
|
ImWchar EllipsisChar; // 2 // out // = '...' // Character used for ellipsis rendering.
|
||||||
|
ImWchar DotChar; // 2 // out // = '.' // Character used for ellipsis rendering (if a single '...' character isn't found)
|
||||||
bool DirtyLookupTables; // 1 // out //
|
bool DirtyLookupTables; // 1 // out //
|
||||||
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||||
@ -2733,7 +2769,6 @@ struct ImFont
|
|||||||
IMGUI_API void AddGlyph(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);
|
IMGUI_API void AddGlyph(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);
|
||||||
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
||||||
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
|
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
|
||||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
|
||||||
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
|
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2741,7 +2776,7 @@ struct ImFont
|
|||||||
// [SECTION] Viewports
|
// [SECTION] Viewports
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Flags stored in ImGuiViewport::Flags
|
// Flags stored in ImGuiViewport::Flags, giving indications to the platform backends.
|
||||||
enum ImGuiViewportFlags_
|
enum ImGuiViewportFlags_
|
||||||
{
|
{
|
||||||
ImGuiViewportFlags_None = 0,
|
ImGuiViewportFlags_None = 0,
|
||||||
@ -2810,8 +2845,18 @@ namespace ImGui
|
|||||||
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
||||||
// OBSOLETED in 1.70 (from May 2019)
|
// OBSOLETED in 1.70 (from May 2019)
|
||||||
static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; }
|
static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; }
|
||||||
// OBSOLETED in 1.69 (from Mar 2019)
|
|
||||||
static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); }
|
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
||||||
|
//static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.69 (from Mar 2019)
|
||||||
|
//static inline void SetScrollHere(float ratio = 0.5f) { SetScrollHereY(ratio); } // OBSOLETED in 1.66 (from Nov 2018)
|
||||||
|
//static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.63 (from Aug 2018)
|
||||||
|
//static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } // OBSOLETED in 1.60 (from Apr 2018)
|
||||||
|
//static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
||||||
|
//static inline void ShowTestWindow() { return ShowDemoWindow(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
|
//static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OBSOLETED in 1.82 (from Mars 2021): flags for AddRect(), AddRectFilled(), AddImageRounded(), PathRect()
|
// OBSOLETED in 1.82 (from Mars 2021): flags for AddRect(), AddRectFilled(), AddImageRounded(), PathRect()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.83
|
// dear imgui, v1.84
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -54,7 +54,6 @@ Index of this file:
|
|||||||
// - sub section: ShowDemoWindowTables()
|
// - sub section: ShowDemoWindowTables()
|
||||||
// - sub section: ShowDemoWindowMisc()
|
// - sub section: ShowDemoWindowMisc()
|
||||||
// [SECTION] About Window / ShowAboutWindow()
|
// [SECTION] About Window / ShowAboutWindow()
|
||||||
// [SECTION] Font Viewer / ShowFontAtlas()
|
|
||||||
// [SECTION] Style Editor / ShowStyleEditor()
|
// [SECTION] Style Editor / ShowStyleEditor()
|
||||||
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
||||||
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
||||||
@ -318,6 +317,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
static bool no_nav = false;
|
static bool no_nav = false;
|
||||||
static bool no_background = false;
|
static bool no_background = false;
|
||||||
static bool no_bring_to_front = false;
|
static bool no_bring_to_front = false;
|
||||||
|
static bool unsaved_document = false;
|
||||||
|
|
||||||
ImGuiWindowFlags window_flags = 0;
|
ImGuiWindowFlags window_flags = 0;
|
||||||
if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
|
if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
|
||||||
@ -329,6 +329,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
|
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
|
||||||
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
|
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
|
||||||
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
|
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
|
||||||
|
if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument;
|
||||||
if (no_close) p_open = NULL; // Don't pass our bool* to Begin
|
if (no_close) p_open = NULL; // Don't pass our bool* to Begin
|
||||||
|
|
||||||
// We specify a default position/size in case there's no data in the .ini file.
|
// We specify a default position/size in case there's no data in the .ini file.
|
||||||
@ -457,7 +458,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
{
|
{
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n"
|
"Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n"
|
||||||
"Here we expose then as read-only fields to avoid breaking interactions with your backend.");
|
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
||||||
|
|
||||||
// Make a local copy to avoid modifying actual backend flags.
|
// Make a local copy to avoid modifying actual backend flags.
|
||||||
ImGuiBackendFlags backend_flags = io.BackendFlags;
|
ImGuiBackendFlags backend_flags = io.BackendFlags;
|
||||||
@ -510,6 +511,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
|
||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
|
||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
||||||
|
ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document);
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,6 +533,10 @@ static void ShowDemoWindowWidgets()
|
|||||||
if (!ImGui::CollapsingHeader("Widgets"))
|
if (!ImGui::CollapsingHeader("Widgets"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
static bool disable_all = false; // The Checkbox for that is inside the "Disabled" section at the bottom
|
||||||
|
if (disable_all)
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
|
||||||
if (ImGui::TreeNode("Basic"))
|
if (ImGui::TreeNode("Basic"))
|
||||||
{
|
{
|
||||||
static int clicked = 0;
|
static int clicked = 0;
|
||||||
@ -1027,8 +1033,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
// stored in the object itself, etc.)
|
// stored in the object itself, etc.)
|
||||||
const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
|
const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
|
||||||
static int item_current_idx = 0; // Here we store our selection data as an index.
|
static int item_current_idx = 0; // Here we store our selection data as an index.
|
||||||
const char* combo_label = items[item_current_idx]; // Label to preview before opening the combo (technically it could be anything)
|
const char* combo_preview_value = items[item_current_idx]; // Pass in the preview value visible before opening the combo (it could be anything)
|
||||||
if (ImGui::BeginCombo("combo 1", combo_label, flags))
|
if (ImGui::BeginCombo("combo 1", combo_preview_value, flags))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
|
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
|
||||||
{
|
{
|
||||||
@ -1044,10 +1050,12 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simplified one-liner Combo() API, using values packed in a single constant string
|
// Simplified one-liner Combo() API, using values packed in a single constant string
|
||||||
|
// This is a convenience for when the selection set is small and known at compile-time.
|
||||||
static int item_current_2 = 0;
|
static int item_current_2 = 0;
|
||||||
ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
||||||
|
|
||||||
// Simplified one-liner Combo() using an array of const char*
|
// Simplified one-liner Combo() using an array of const char*
|
||||||
|
// This is not very useful (may obsolete): prefer using BeginCombo()/EndCombo() for full control.
|
||||||
static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview
|
static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview
|
||||||
ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
|
ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
|
||||||
|
|
||||||
@ -1114,7 +1122,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
static bool selection[5] = { false, true, false, false, false };
|
static bool selection[5] = { false, true, false, false, false };
|
||||||
ImGui::Selectable("1. I am selectable", &selection[0]);
|
ImGui::Selectable("1. I am selectable", &selection[0]);
|
||||||
ImGui::Selectable("2. I am selectable", &selection[1]);
|
ImGui::Selectable("2. I am selectable", &selection[1]);
|
||||||
ImGui::Text("3. I am not selectable");
|
ImGui::Text("(I am not selectable)");
|
||||||
ImGui::Selectable("4. I am selectable", &selection[3]);
|
ImGui::Selectable("4. I am selectable", &selection[3]);
|
||||||
if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
|
if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
if (ImGui::IsMouseDoubleClicked(0))
|
if (ImGui::IsMouseDoubleClicked(0))
|
||||||
@ -1164,7 +1172,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
{
|
{
|
||||||
static bool selected[10] = {};
|
static bool selected[10] = {};
|
||||||
|
|
||||||
if (ImGui::BeginTable("split1", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings))
|
if (ImGui::BeginTable("split1", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
@ -1175,8 +1183,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Spacing();
|
||||||
if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings))
|
if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
@ -2177,24 +2185,28 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Querying Status (Edited/Active/Focused/Hovered etc.)"))
|
if (ImGui::TreeNode("Querying Status (Edited/Active/Hovered etc.)"))
|
||||||
{
|
{
|
||||||
// Select an item type
|
// Select an item type
|
||||||
const char* item_names[] =
|
const char* item_names[] =
|
||||||
{
|
{
|
||||||
"Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputFloat",
|
"Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputFloat",
|
||||||
"InputFloat3", "ColorEdit4", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "Combo", "ListBox"
|
"InputFloat3", "ColorEdit4", "Selectable", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "Combo", "ListBox"
|
||||||
};
|
};
|
||||||
static int item_type = 1;
|
static int item_type = 4;
|
||||||
|
static bool item_disabled = false;
|
||||||
ImGui::Combo("Item Type", &item_type, item_names, IM_ARRAYSIZE(item_names), IM_ARRAYSIZE(item_names));
|
ImGui::Combo("Item Type", &item_type, item_names, IM_ARRAYSIZE(item_names), IM_ARRAYSIZE(item_names));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions. Note that the bool return value of most ImGui function is generally equivalent to calling ImGui::IsItemHovered().");
|
HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions. Note that the bool return value of most ImGui function is generally equivalent to calling ImGui::IsItemHovered().");
|
||||||
|
ImGui::Checkbox("Item Disabled", &item_disabled);
|
||||||
|
|
||||||
// Submit selected item item so we can query their status in the code following it.
|
// Submit selected item item so we can query their status in the code following it.
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
static bool b = false;
|
static bool b = false;
|
||||||
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
||||||
static char str[16] = {};
|
static char str[16] = {};
|
||||||
|
if (item_disabled)
|
||||||
|
ImGui::BeginDisabled(true);
|
||||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||||
if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater)
|
if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater)
|
||||||
@ -2204,11 +2216,12 @@ static void ShowDemoWindowWidgets()
|
|||||||
if (item_type == 6) { ret = ImGui::InputFloat("ITEM: InputFloat", col4f, 1.0f); } // Testing +/- buttons on scalar input
|
if (item_type == 6) { ret = ImGui::InputFloat("ITEM: InputFloat", col4f, 1.0f); } // Testing +/- buttons on scalar input
|
||||||
if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||||
if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||||
if (item_type == 9) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
|
if (item_type == 9) { ret = ImGui::Selectable("ITEM: Selectable"); } // Testing selectable item
|
||||||
if (item_type == 10){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node
|
if (item_type == 10){ ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
|
||||||
if (item_type == 11){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
|
if (item_type == 11){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node
|
||||||
if (item_type == 12){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::Combo("ITEM: Combo", ¤t, items, IM_ARRAYSIZE(items)); }
|
if (item_type == 12){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
|
||||||
if (item_type == 13){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
if (item_type == 13){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::Combo("ITEM: Combo", ¤t, items, IM_ARRAYSIZE(items)); }
|
||||||
|
if (item_type == 14){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||||
|
|
||||||
// Display the values of IsItemHovered() and other common item state functions.
|
// Display the values of IsItemHovered() and other common item state functions.
|
||||||
// Note that the ImGuiHoveredFlags_XXX flags can be combined.
|
// Note that the ImGuiHoveredFlags_XXX flags can be combined.
|
||||||
@ -2221,6 +2234,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
"IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
|
"IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
|
||||||
"IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
"IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
||||||
"IsItemHovered(_AllowWhenOverlapped) = %d\n"
|
"IsItemHovered(_AllowWhenOverlapped) = %d\n"
|
||||||
|
"IsItemHovered(_AllowWhenDisabled) = %d\n"
|
||||||
"IsItemHovered(_RectOnly) = %d\n"
|
"IsItemHovered(_RectOnly) = %d\n"
|
||||||
"IsItemActive() = %d\n"
|
"IsItemActive() = %d\n"
|
||||||
"IsItemEdited() = %d\n"
|
"IsItemEdited() = %d\n"
|
||||||
@ -2239,6 +2253,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
||||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
||||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
|
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
|
||||||
|
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled),
|
||||||
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
|
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
|
||||||
ImGui::IsItemActive(),
|
ImGui::IsItemActive(),
|
||||||
ImGui::IsItemEdited(),
|
ImGui::IsItemEdited(),
|
||||||
@ -2253,6 +2268,9 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
|
ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (item_disabled)
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
static bool embed_all_inside_a_child_window = false;
|
static bool embed_all_inside_a_child_window = false;
|
||||||
ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
|
ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
|
||||||
if (embed_all_inside_a_child_window)
|
if (embed_all_inside_a_child_window)
|
||||||
@ -2322,6 +2340,18 @@ static void ShowDemoWindowWidgets()
|
|||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Demonstrate BeginDisabled/EndDisabled using a checkbox located at the bottom of the section (which is a bit odd:
|
||||||
|
// logically we'd have this checkbox at the top of the section, but we don't want this feature to steal that space)
|
||||||
|
if (disable_all)
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Disable block"))
|
||||||
|
{
|
||||||
|
ImGui::Checkbox("Disable entire section above", &disable_all);
|
||||||
|
ImGui::SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across this section.");
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowDemoWindowLayout()
|
static void ShowDemoWindowLayout()
|
||||||
@ -2391,7 +2421,7 @@ static void ShowDemoWindowLayout()
|
|||||||
// You can also call SetNextWindowPos() to position the child window. The parent window will effectively
|
// You can also call SetNextWindowPos() to position the child window. The parent window will effectively
|
||||||
// layout from this position.
|
// layout from this position.
|
||||||
// - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from
|
// - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from
|
||||||
// the POV of the parent window). See 'Demo->Querying Status (Active/Focused/Hovered etc.)' for details.
|
// the POV of the parent window). See 'Demo->Querying Status (Edited/Active/Hovered etc.)' for details.
|
||||||
{
|
{
|
||||||
static int offset_x = 0;
|
static int offset_x = 0;
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
@ -3497,6 +3527,7 @@ static void EditTableSizingFlags(ImGuiTableFlags* p_flags)
|
|||||||
|
|
||||||
static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
|
static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
|
||||||
{
|
{
|
||||||
|
ImGui::CheckboxFlags("_Disabled", p_flags, ImGuiTableColumnFlags_Disabled); ImGui::SameLine(); HelpMarker("Master disable flag (also hide from context menu)");
|
||||||
ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide);
|
ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide);
|
||||||
ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort);
|
ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort);
|
||||||
if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch))
|
if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch))
|
||||||
@ -3510,6 +3541,7 @@ static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
|
|||||||
ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort);
|
ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort);
|
||||||
ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending);
|
ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending);
|
||||||
ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending);
|
ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending);
|
||||||
|
ImGui::CheckboxFlags("_NoHeaderLabel", p_flags, ImGuiTableColumnFlags_NoHeaderLabel);
|
||||||
ImGui::CheckboxFlags("_NoHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth);
|
ImGui::CheckboxFlags("_NoHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth);
|
||||||
ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending);
|
ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending);
|
||||||
ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending);
|
ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending);
|
||||||
@ -5744,15 +5776,15 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Font viewer / ShowFontAtlas()
|
// [SECTION] Style Editor / ShowStyleEditor()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - ShowFontSelector()
|
// - ShowFontSelector()
|
||||||
// - ShowFont()
|
// - ShowStyleSelector()
|
||||||
// - ShowFontAtlas()
|
// - ShowStyleEditor()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// This isn't worth putting in public API but we want Metrics to use it
|
// Forward declare ShowFontAtlas() which isn't worth putting in public API yet
|
||||||
namespace ImGui { void ShowFontAtlas(ImFontAtlas* atlas); }
|
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||||
|
|
||||||
// Demo helper function to select among loaded fonts.
|
// Demo helper function to select among loaded fonts.
|
||||||
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
|
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
|
||||||
@ -5780,124 +5812,6 @@ void ImGui::ShowFontSelector(const char* label)
|
|||||||
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
|
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Internal] Display details for a single font, called by ShowStyleEditor().
|
|
||||||
static void ShowFont(ImFont* font)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
bool font_details_opened = ImGui::TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
|
|
||||||
font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
|
|
||||||
ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; }
|
|
||||||
if (!font_details_opened)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Display preview text
|
|
||||||
ImGui::PushFont(font);
|
|
||||||
ImGui::Text("The quick brown fox jumps over the lazy dog");
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
// Display details
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
|
||||||
ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
|
|
||||||
ImGui::SameLine(); HelpMarker(
|
|
||||||
"Note than the default embedded font is NOT meant to be scaled.\n\n"
|
|
||||||
"Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
|
|
||||||
"You may oversample them to get some flexibility with scaling. "
|
|
||||||
"You can also render at multiple sizes and select which one to use at runtime.\n\n"
|
|
||||||
"(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
|
|
||||||
ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
|
|
||||||
ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar);
|
|
||||||
ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar);
|
|
||||||
const int surface_sqrt = (int)sqrtf((float)font->MetricsTotalSurface);
|
|
||||||
ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
|
|
||||||
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
|
|
||||||
if (font->ConfigData)
|
|
||||||
if (const ImFontConfig* cfg = &font->ConfigData[config_i])
|
|
||||||
ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
|
|
||||||
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
|
|
||||||
|
|
||||||
// Display all glyphs of the fonts in separate pages of 256 characters
|
|
||||||
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
|
||||||
{
|
|
||||||
const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text);
|
|
||||||
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
|
|
||||||
{
|
|
||||||
// Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
|
|
||||||
// This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
|
|
||||||
// is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
|
|
||||||
if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
|
|
||||||
{
|
|
||||||
base += 4096 - 256;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (unsigned int n = 0; n < 256; n++)
|
|
||||||
if (font->FindGlyphNoFallback((ImWchar)(base + n)))
|
|
||||||
count++;
|
|
||||||
if (count <= 0)
|
|
||||||
continue;
|
|
||||||
if (!ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
|
|
||||||
continue;
|
|
||||||
float cell_size = font->FontSize * 1;
|
|
||||||
float cell_spacing = style.ItemSpacing.y;
|
|
||||||
ImVec2 base_pos = ImGui::GetCursorScreenPos();
|
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
|
||||||
for (unsigned int n = 0; n < 256; n++)
|
|
||||||
{
|
|
||||||
// We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
|
|
||||||
// available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
|
|
||||||
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
|
|
||||||
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
|
||||||
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
|
|
||||||
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
|
||||||
if (glyph)
|
|
||||||
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
|
||||||
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
|
|
||||||
{
|
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::Text("Codepoint: U+%04X", base + n);
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::Text("Visible: %d", glyph->Visible);
|
|
||||||
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
|
|
||||||
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
|
|
||||||
ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
|
||||||
{
|
|
||||||
ImFont* font = atlas->Fonts[i];
|
|
||||||
ImGui::PushID(font);
|
|
||||||
ShowFont(font);
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
|
||||||
{
|
|
||||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
|
||||||
ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col);
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// [SECTION] Style Editor / ShowStyleEditor()
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// - ShowStyleSelector()
|
|
||||||
// - ShowStyleEditor()
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
||||||
// Here we use the simplified Combo() api that packs items into a single literal string.
|
// Here we use the simplified Combo() api that packs items into a single literal string.
|
||||||
// Useful for quick combo boxes where the choices are known locally.
|
// Useful for quick combo boxes where the choices are known locally.
|
||||||
@ -6152,6 +6066,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically.");
|
HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically.");
|
||||||
|
|
||||||
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
|
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
|
||||||
|
ImGui::DragFloat("Disabled Alpha", &style.DisabledAlpha, 0.005f, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha).");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
@ -6817,6 +6732,7 @@ static void ShowExampleAppLayout(bool* p_open)
|
|||||||
ImGui::BeginChild("left pane", ImVec2(150, 0), true);
|
ImGui::BeginChild("left pane", ImVec2(150, 0), true);
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
|
// FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav
|
||||||
char label[128];
|
char label[128];
|
||||||
sprintf(label, "MyObject %d", i);
|
sprintf(label, "MyObject %d", i);
|
||||||
if (ImGui::Selectable(label, selected == i))
|
if (ImGui::Selectable(label, selected == i))
|
||||||
@ -7085,12 +7001,12 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
// + a context-menu to choose which corner of the screen to use.
|
// + a context-menu to choose which corner of the screen to use.
|
||||||
static void ShowExampleAppSimpleOverlay(bool* p_open)
|
static void ShowExampleAppSimpleOverlay(bool* p_open)
|
||||||
{
|
{
|
||||||
const float PAD = 10.0f;
|
|
||||||
static int corner = 0;
|
static int corner = 0;
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||||
if (corner != -1)
|
if (corner != -1)
|
||||||
{
|
{
|
||||||
|
const float PAD = 10.0f;
|
||||||
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
|
ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
|
||||||
ImVec2 work_size = viewport->WorkSize;
|
ImVec2 work_size = viewport->WorkSize;
|
||||||
@ -7590,6 +7506,16 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// About the ImGuiWindowFlags_UnsavedDocument / ImGuiTabItemFlags_UnsavedDocument flags.
|
||||||
|
// They have multiple effects:
|
||||||
|
// - Display a dot next to the title.
|
||||||
|
// - Tab is selected when clicking the X close button.
|
||||||
|
// - Closure is not assumed (will wait for user to stop submitting the tab).
|
||||||
|
// Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
|
||||||
|
// We need to assume closure by default otherwise waiting for "lack of submission" on the next frame would leave an empty
|
||||||
|
// hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window.
|
||||||
|
// The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole.
|
||||||
|
|
||||||
// Submit Tab Bar and Tabs
|
// Submit Tab Bar and Tabs
|
||||||
{
|
{
|
||||||
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
|
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.83
|
// dear imgui, v1.84
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -491,6 +491,18 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
||||||
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
|
||||||
|
// Try to merge two last draw commands
|
||||||
|
void ImDrawList::_TryMergeDrawCmds()
|
||||||
|
{
|
||||||
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
|
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
||||||
|
{
|
||||||
|
prev_cmd->ElemCount += curr_cmd->ElemCount;
|
||||||
|
CmdBuffer.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
||||||
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
||||||
void ImDrawList::_OnChangedClipRect()
|
void ImDrawList::_OnChangedClipRect()
|
||||||
@ -693,10 +705,11 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds.
|
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds.
|
||||||
// Those macros expects l-values.
|
// - Those macros expects l-values and need to be used as their own statement.
|
||||||
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
// - Those macros are intentionally not surrounded by the 'do {} while (0)' idiom because even that translates to runtime with debug compilers.
|
||||||
|
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } (void)0
|
||||||
#define IM_FIXNORMAL2F_MAX_INVLEN2 100.0f // 500.0f (see #4053, #3366)
|
#define IM_FIXNORMAL2F_MAX_INVLEN2 100.0f // 500.0f (see #4053, #3366)
|
||||||
#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.000001f) { float inv_len2 = 1.0f / d2; if (inv_len2 > IM_FIXNORMAL2F_MAX_INVLEN2) inv_len2 = IM_FIXNORMAL2F_MAX_INVLEN2; VX *= inv_len2; VY *= inv_len2; } } while (0)
|
#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.000001f) { float inv_len2 = 1.0f / d2; if (inv_len2 > IM_FIXNORMAL2F_MAX_INVLEN2) inv_len2 = IM_FIXNORMAL2F_MAX_INVLEN2; VX *= inv_len2; VY *= inv_len2; } } (void)0
|
||||||
|
|
||||||
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
|
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
|
||||||
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
||||||
@ -1466,24 +1479,22 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
|
|||||||
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Obtain segment count
|
|
||||||
if (num_segments <= 0)
|
if (num_segments <= 0)
|
||||||
{
|
{
|
||||||
// Automatic segment count
|
// Use arc with automatic segment count
|
||||||
num_segments = _CalcCircleAutoSegmentCount(radius);
|
_PathArcToFastEx(center, radius - 0.5f, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0);
|
||||||
|
_Path.Size--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
||||||
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
||||||
|
|
||||||
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
|
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
|
||||||
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
|
||||||
if (num_segments == 12)
|
|
||||||
PathArcToFast(center, radius - 0.5f, 0, 12 - 1);
|
|
||||||
else
|
|
||||||
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
|
||||||
PathStroke(col, ImDrawFlags_Closed, thickness);
|
PathStroke(col, ImDrawFlags_Closed, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1492,24 +1503,22 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
|
|||||||
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Obtain segment count
|
|
||||||
if (num_segments <= 0)
|
if (num_segments <= 0)
|
||||||
{
|
{
|
||||||
// Automatic segment count
|
// Use arc with automatic segment count
|
||||||
num_segments = _CalcCircleAutoSegmentCount(radius);
|
_PathArcToFastEx(center, radius, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0);
|
||||||
|
_Path.Size--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
||||||
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
||||||
|
|
||||||
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
|
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
|
||||||
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
|
||||||
if (num_segments == 12)
|
|
||||||
PathArcToFast(center, radius, 0, 12 - 1);
|
|
||||||
else
|
|
||||||
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1989,6 +1998,7 @@ void ImFontAtlas::ClearInputData()
|
|||||||
ConfigData.clear();
|
ConfigData.clear();
|
||||||
CustomRects.clear();
|
CustomRects.clear();
|
||||||
PackIdMouseCursors = PackIdLines = -1;
|
PackIdMouseCursors = PackIdLines = -1;
|
||||||
|
TexReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::ClearTexData()
|
void ImFontAtlas::ClearTexData()
|
||||||
@ -2001,14 +2011,14 @@ void ImFontAtlas::ClearTexData()
|
|||||||
TexPixelsAlpha8 = NULL;
|
TexPixelsAlpha8 = NULL;
|
||||||
TexPixelsRGBA32 = NULL;
|
TexPixelsRGBA32 = NULL;
|
||||||
TexPixelsUseColors = false;
|
TexPixelsUseColors = false;
|
||||||
|
// Important: we leave TexReady untouched
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::ClearFonts()
|
void ImFontAtlas::ClearFonts()
|
||||||
{
|
{
|
||||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||||
for (int i = 0; i < Fonts.Size; i++)
|
Fonts.clear_delete();
|
||||||
IM_DELETE(Fonts[i]);
|
TexReady = false;
|
||||||
Fonts.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::Clear()
|
void ImFontAtlas::Clear()
|
||||||
@ -2022,11 +2032,7 @@ void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_wid
|
|||||||
{
|
{
|
||||||
// Build atlas on demand
|
// Build atlas on demand
|
||||||
if (TexPixelsAlpha8 == NULL)
|
if (TexPixelsAlpha8 == NULL)
|
||||||
{
|
|
||||||
if (ConfigData.empty())
|
|
||||||
AddFontDefault();
|
|
||||||
Build();
|
Build();
|
||||||
}
|
|
||||||
|
|
||||||
*out_pixels = TexPixelsAlpha8;
|
*out_pixels = TexPixelsAlpha8;
|
||||||
if (out_width) *out_width = TexWidth;
|
if (out_width) *out_width = TexWidth;
|
||||||
@ -2085,6 +2091,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
|||||||
new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar;
|
new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar;
|
||||||
|
|
||||||
// Invalidate texture
|
// Invalidate texture
|
||||||
|
TexReady = false;
|
||||||
ClearTexData();
|
ClearTexData();
|
||||||
return new_font_cfg.DstFont;
|
return new_font_cfg.DstFont;
|
||||||
}
|
}
|
||||||
@ -2156,7 +2163,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si
|
|||||||
IM_ASSERT(font_cfg.FontData == NULL);
|
IM_ASSERT(font_cfg.FontData == NULL);
|
||||||
font_cfg.FontData = ttf_data;
|
font_cfg.FontData = ttf_data;
|
||||||
font_cfg.FontDataSize = ttf_size;
|
font_cfg.FontDataSize = ttf_size;
|
||||||
font_cfg.SizePixels = size_pixels;
|
font_cfg.SizePixels = size_pixels > 0.0f ? size_pixels : font_cfg.SizePixels;
|
||||||
if (glyph_ranges)
|
if (glyph_ranges)
|
||||||
font_cfg.GlyphRanges = glyph_ranges;
|
font_cfg.GlyphRanges = glyph_ranges;
|
||||||
return AddFont(&font_cfg);
|
return AddFont(&font_cfg);
|
||||||
@ -2247,6 +2254,10 @@ bool ImFontAtlas::Build()
|
|||||||
{
|
{
|
||||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||||
|
|
||||||
|
// Default font is none are specified
|
||||||
|
if (ConfigData.Size == 0)
|
||||||
|
AddFontDefault();
|
||||||
|
|
||||||
// Select builder
|
// Select builder
|
||||||
// - Note that we do not reassign to atlas->FontBuilderIO, since it is likely to point to static data which
|
// - Note that we do not reassign to atlas->FontBuilderIO, since it is likely to point to static data which
|
||||||
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are
|
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are
|
||||||
@ -2568,9 +2579,8 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup temporary (ImVector doesn't honor destructor)
|
// Cleanup
|
||||||
for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
|
src_tmp_array.clear_destruct();
|
||||||
src_tmp_array[src_i].~ImFontBuildSrcData();
|
|
||||||
|
|
||||||
ImFontAtlasBuildFinish(atlas);
|
ImFontAtlasBuildFinish(atlas);
|
||||||
return true;
|
return true;
|
||||||
@ -2786,22 +2796,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
|||||||
if (atlas->Fonts[i]->DirtyLookupTables)
|
if (atlas->Fonts[i]->DirtyLookupTables)
|
||||||
atlas->Fonts[i]->BuildLookupTable();
|
atlas->Fonts[i]->BuildLookupTable();
|
||||||
|
|
||||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
atlas->TexReady = true;
|
||||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
|
||||||
// FIXME: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots.
|
|
||||||
for (int i = 0; i < atlas->Fonts.size(); i++)
|
|
||||||
{
|
|
||||||
ImFont* font = atlas->Fonts[i];
|
|
||||||
if (font->EllipsisChar != (ImWchar)-1)
|
|
||||||
continue;
|
|
||||||
const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
|
||||||
for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
|
|
||||||
if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
|
|
||||||
{
|
|
||||||
font->EllipsisChar = ellipsis_variants[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve list of range (2 int per range, values are inclusive)
|
// Retrieve list of range (2 int per range, values are inclusive)
|
||||||
@ -2822,6 +2817,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesKorean()
|
|||||||
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
||||||
0x3131, 0x3163, // Korean alphabets
|
0x3131, 0x3163, // Korean alphabets
|
||||||
0xAC00, 0xD7A3, // Korean characters
|
0xAC00, 0xD7A3, // Korean characters
|
||||||
|
0xFFFD, 0xFFFD, // Invalid
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
return &ranges[0];
|
return &ranges[0];
|
||||||
@ -2836,6 +2832,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull()
|
|||||||
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
||||||
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
||||||
0xFF00, 0xFFEF, // Half-width characters
|
0xFF00, 0xFFEF, // Half-width characters
|
||||||
|
0xFFFD, 0xFFFD, // Invalid
|
||||||
0x4e00, 0x9FAF, // CJK Ideograms
|
0x4e00, 0x9FAF, // CJK Ideograms
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
@ -2912,7 +2909,8 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon()
|
|||||||
0x2000, 0x206F, // General Punctuation
|
0x2000, 0x206F, // General Punctuation
|
||||||
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
||||||
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
||||||
0xFF00, 0xFFEF // Half-width characters
|
0xFF00, 0xFFEF, // Half-width characters
|
||||||
|
0xFFFD, 0xFFFD // Invalid
|
||||||
};
|
};
|
||||||
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 };
|
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 };
|
||||||
if (!full_ranges[0])
|
if (!full_ranges[0])
|
||||||
@ -3001,7 +2999,8 @@ const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
|
|||||||
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
||||||
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
|
||||||
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
0x31F0, 0x31FF, // Katakana Phonetic Extensions
|
||||||
0xFF00, 0xFFEF // Half-width characters
|
0xFF00, 0xFFEF, // Half-width characters
|
||||||
|
0xFFFD, 0xFFFD // Invalid
|
||||||
};
|
};
|
||||||
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 };
|
static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 };
|
||||||
if (!full_ranges[0])
|
if (!full_ranges[0])
|
||||||
@ -3100,8 +3099,9 @@ ImFont::ImFont()
|
|||||||
{
|
{
|
||||||
FontSize = 0.0f;
|
FontSize = 0.0f;
|
||||||
FallbackAdvanceX = 0.0f;
|
FallbackAdvanceX = 0.0f;
|
||||||
FallbackChar = (ImWchar)'?';
|
FallbackChar = (ImWchar)-1;
|
||||||
EllipsisChar = (ImWchar)-1;
|
EllipsisChar = (ImWchar)-1;
|
||||||
|
DotChar = (ImWchar)-1;
|
||||||
FallbackGlyph = NULL;
|
FallbackGlyph = NULL;
|
||||||
ContainerAtlas = NULL;
|
ContainerAtlas = NULL;
|
||||||
ConfigData = NULL;
|
ConfigData = NULL;
|
||||||
@ -3132,6 +3132,14 @@ void ImFont::ClearOutputData()
|
|||||||
MetricsTotalSurface = 0;
|
MetricsTotalSurface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ImWchar FindFirstExistingGlyph(ImFont* font, const ImWchar* candidate_chars, int candidate_chars_count)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < candidate_chars_count; n++)
|
||||||
|
if (font->FindGlyphNoFallback(candidate_chars[n]) != NULL)
|
||||||
|
return candidate_chars[n];
|
||||||
|
return (ImWchar)-1;
|
||||||
|
}
|
||||||
|
|
||||||
void ImFont::BuildLookupTable()
|
void ImFont::BuildLookupTable()
|
||||||
{
|
{
|
||||||
int max_codepoint = 0;
|
int max_codepoint = 0;
|
||||||
@ -3174,9 +3182,31 @@ void ImFont::BuildLookupTable()
|
|||||||
SetGlyphVisible((ImWchar)' ', false);
|
SetGlyphVisible((ImWchar)' ', false);
|
||||||
SetGlyphVisible((ImWchar)'\t', false);
|
SetGlyphVisible((ImWchar)'\t', false);
|
||||||
|
|
||||||
// Setup fall-backs
|
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||||
|
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||||
|
// FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||||
|
const ImWchar ellipsis_chars[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
||||||
|
const ImWchar dots_chars[] = { (ImWchar)'.', (ImWchar)0xFF0E };
|
||||||
|
if (EllipsisChar == (ImWchar)-1)
|
||||||
|
EllipsisChar = FindFirstExistingGlyph(this, ellipsis_chars, IM_ARRAYSIZE(ellipsis_chars));
|
||||||
|
if (DotChar == (ImWchar)-1)
|
||||||
|
DotChar = FindFirstExistingGlyph(this, dots_chars, IM_ARRAYSIZE(dots_chars));
|
||||||
|
|
||||||
|
// Setup fallback character
|
||||||
|
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
||||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||||
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
if (FallbackGlyph == NULL)
|
||||||
|
{
|
||||||
|
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
||||||
|
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||||
|
if (FallbackGlyph == NULL)
|
||||||
|
{
|
||||||
|
FallbackGlyph = &Glyphs.back();
|
||||||
|
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
||||||
for (int i = 0; i < max_codepoint + 1; i++)
|
for (int i = 0; i < max_codepoint + 1; i++)
|
||||||
if (IndexAdvanceX[i] < 0.0f)
|
if (IndexAdvanceX[i] < 0.0f)
|
||||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||||
@ -3201,12 +3231,6 @@ void ImFont::SetGlyphVisible(ImWchar c, bool visible)
|
|||||||
glyph->Visible = visible ? 1 : 0;
|
glyph->Visible = visible ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFont::SetFallbackChar(ImWchar c)
|
|
||||||
{
|
|
||||||
FallbackChar = c;
|
|
||||||
BuildLookupTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImFont::GrowIndex(int new_size)
|
void ImFont::GrowIndex(int new_size)
|
||||||
{
|
{
|
||||||
IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
|
IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
|
||||||
@ -3708,6 +3732,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
// - RenderMouseCursor()
|
// - RenderMouseCursor()
|
||||||
// - RenderArrowPointingAt()
|
// - RenderArrowPointingAt()
|
||||||
// - RenderRectFilledRangeH()
|
// - RenderRectFilledRangeH()
|
||||||
|
// - RenderRectFilledWithHole()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Function in need of a redesign (legacy mess)
|
// Function in need of a redesign (legacy mess)
|
||||||
// - RenderColorRectWithAlphaCheckerboard()
|
// - RenderColorRectWithAlphaCheckerboard()
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
// 2021-02-18: DirectX11: Change blending equation to preserve alpha in output buffer.
|
// 2021-02-18: DirectX11: Change blending equation to preserve alpha in output buffer.
|
||||||
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
|
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
|
||||||
@ -38,30 +40,46 @@
|
|||||||
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DirectX data
|
// DirectX11 data
|
||||||
static ID3D11Device* g_pd3dDevice = NULL;
|
struct ImGui_ImplDX11_Data
|
||||||
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
|
{
|
||||||
static IDXGIFactory* g_pFactory = NULL;
|
ID3D11Device* pd3dDevice;
|
||||||
static ID3D11Buffer* g_pVB = NULL;
|
ID3D11DeviceContext* pd3dDeviceContext;
|
||||||
static ID3D11Buffer* g_pIB = NULL;
|
IDXGIFactory* pFactory;
|
||||||
static ID3D11VertexShader* g_pVertexShader = NULL;
|
ID3D11Buffer* pVB;
|
||||||
static ID3D11InputLayout* g_pInputLayout = NULL;
|
ID3D11Buffer* pIB;
|
||||||
static ID3D11Buffer* g_pVertexConstantBuffer = NULL;
|
ID3D11VertexShader* pVertexShader;
|
||||||
static ID3D11PixelShader* g_pPixelShader = NULL;
|
ID3D11InputLayout* pInputLayout;
|
||||||
static ID3D11SamplerState* g_pFontSampler = NULL;
|
ID3D11Buffer* pVertexConstantBuffer;
|
||||||
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
|
ID3D11PixelShader* pPixelShader;
|
||||||
static ID3D11RasterizerState* g_pRasterizerState = NULL;
|
ID3D11SamplerState* pFontSampler;
|
||||||
static ID3D11BlendState* g_pBlendState = NULL;
|
ID3D11ShaderResourceView* pFontTextureView;
|
||||||
static ID3D11DepthStencilState* g_pDepthStencilState = NULL;
|
ID3D11RasterizerState* pRasterizerState;
|
||||||
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
ID3D11BlendState* pBlendState;
|
||||||
|
ID3D11DepthStencilState* pDepthStencilState;
|
||||||
|
int VertexBufferSize;
|
||||||
|
int IndexBufferSize;
|
||||||
|
|
||||||
|
ImGui_ImplDX11_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
|
||||||
|
};
|
||||||
|
|
||||||
struct VERTEX_CONSTANT_BUFFER
|
struct VERTEX_CONSTANT_BUFFER
|
||||||
{
|
{
|
||||||
float mvp[4][4];
|
float mvp[4][4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
|
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||||
|
static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
||||||
{
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D11_VIEWPORT vp;
|
D3D11_VIEWPORT vp;
|
||||||
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
|
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
|
||||||
@ -75,14 +93,14 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|||||||
// Setup shader and vertex buffers
|
// Setup shader and vertex buffers
|
||||||
unsigned int stride = sizeof(ImDrawVert);
|
unsigned int stride = sizeof(ImDrawVert);
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
ctx->IASetInputLayout(g_pInputLayout);
|
ctx->IASetInputLayout(bd->pInputLayout);
|
||||||
ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
|
ctx->IASetVertexBuffers(0, 1, &bd->pVB, &stride, &offset);
|
||||||
ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
ctx->IASetIndexBuffer(bd->pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
||||||
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
ctx->VSSetShader(g_pVertexShader, NULL, 0);
|
ctx->VSSetShader(bd->pVertexShader, NULL, 0);
|
||||||
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
||||||
ctx->PSSetShader(g_pPixelShader, NULL, 0);
|
ctx->PSSetShader(bd->pPixelShader, NULL, 0);
|
||||||
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
ctx->PSSetSamplers(0, 1, &bd->pFontSampler);
|
||||||
ctx->GSSetShader(NULL, NULL, 0);
|
ctx->GSSetShader(NULL, NULL, 0);
|
||||||
ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
@ -90,9 +108,9 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|||||||
|
|
||||||
// Setup blend state
|
// Setup blend state
|
||||||
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
|
ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
||||||
ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
|
ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
||||||
ctx->RSSetState(g_pRasterizerState);
|
ctx->RSSetState(bd->pRasterizerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
@ -102,42 +120,43 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ID3D11DeviceContext* ctx = bd->pd3dDeviceContext;
|
||||||
|
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
{
|
{
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; }
|
||||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = g_VertexBufferSize * sizeof(ImDrawVert);
|
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
desc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVB) < 0)
|
if (bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVB) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; }
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pIB) < 0)
|
if (bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pIB) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
||||||
if (ctx->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
if (ctx->Map(bd->pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
||||||
return;
|
return;
|
||||||
if (ctx->Map(g_pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
|
if (ctx->Map(bd->pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
|
||||||
return;
|
return;
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
||||||
@ -149,14 +168,14 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
vtx_dst += cmd_list->VtxBuffer.Size;
|
vtx_dst += cmd_list->VtxBuffer.Size;
|
||||||
idx_dst += cmd_list->IdxBuffer.Size;
|
idx_dst += cmd_list->IdxBuffer.Size;
|
||||||
}
|
}
|
||||||
ctx->Unmap(g_pVB, 0);
|
ctx->Unmap(bd->pVB, 0);
|
||||||
ctx->Unmap(g_pIB, 0);
|
ctx->Unmap(bd->pIB, 0);
|
||||||
|
|
||||||
// Setup orthographic projection matrix into our constant buffer
|
// Setup orthographic projection matrix into our constant buffer
|
||||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||||
{
|
{
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
||||||
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
if (ctx->Map(bd->pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
||||||
return;
|
return;
|
||||||
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData;
|
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData;
|
||||||
float L = draw_data->DisplayPos.x;
|
float L = draw_data->DisplayPos.x;
|
||||||
@ -171,7 +190,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
|
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
|
||||||
};
|
};
|
||||||
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
|
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
|
||||||
ctx->Unmap(g_pVertexConstantBuffer, 0);
|
ctx->Unmap(bd->pVertexConstantBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
||||||
@ -282,6 +301,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
@ -305,7 +325,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
subResource.pSysMem = pixels;
|
subResource.pSysMem = pixels;
|
||||||
subResource.SysMemPitch = desc.Width * 4;
|
subResource.SysMemPitch = desc.Width * 4;
|
||||||
subResource.SysMemSlicePitch = 0;
|
subResource.SysMemSlicePitch = 0;
|
||||||
g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
bd->pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||||
IM_ASSERT(pTexture != NULL);
|
IM_ASSERT(pTexture != NULL);
|
||||||
|
|
||||||
// Create texture view
|
// Create texture view
|
||||||
@ -315,12 +335,12 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||||
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
|
bd->pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &bd->pFontTextureView);
|
||||||
pTexture->Release();
|
pTexture->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->SetTexID((ImTextureID)g_pFontTextureView);
|
io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView);
|
||||||
|
|
||||||
// Create texture sampler
|
// Create texture sampler
|
||||||
{
|
{
|
||||||
@ -334,15 +354,16 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX11_CreateDeviceObjects()
|
bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
if (!bd->pd3dDevice)
|
||||||
return false;
|
return false;
|
||||||
if (g_pFontSampler)
|
if (bd->pFontSampler)
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
|
|
||||||
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
|
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
|
||||||
@ -384,7 +405,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
ID3DBlob* vertexShaderBlob;
|
ID3DBlob* vertexShaderBlob;
|
||||||
if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL)))
|
if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL)))
|
||||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
if (g_pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
|
if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), NULL, &bd->pVertexShader) != S_OK)
|
||||||
{
|
{
|
||||||
vertexShaderBlob->Release();
|
vertexShaderBlob->Release();
|
||||||
return false;
|
return false;
|
||||||
@ -397,7 +418,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK)
|
||||||
{
|
{
|
||||||
vertexShaderBlob->Release();
|
vertexShaderBlob->Release();
|
||||||
return false;
|
return false;
|
||||||
@ -412,7 +433,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
desc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVertexConstantBuffer);
|
bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVertexConstantBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +458,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
ID3DBlob* pixelShaderBlob;
|
ID3DBlob* pixelShaderBlob;
|
||||||
if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL)))
|
if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL)))
|
||||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
if (g_pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
|
if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), NULL, &bd->pPixelShader) != S_OK)
|
||||||
{
|
{
|
||||||
pixelShaderBlob->Release();
|
pixelShaderBlob->Release();
|
||||||
return false;
|
return false;
|
||||||
@ -458,7 +479,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||||
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||||
g_pd3dDevice->CreateBlendState(&desc, &g_pBlendState);
|
bd->pd3dDevice->CreateBlendState(&desc, &bd->pBlendState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the rasterizer state
|
// Create the rasterizer state
|
||||||
@ -469,7 +490,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.CullMode = D3D11_CULL_NONE;
|
desc.CullMode = D3D11_CULL_NONE;
|
||||||
desc.ScissorEnable = true;
|
desc.ScissorEnable = true;
|
||||||
desc.DepthClipEnable = true;
|
desc.DepthClipEnable = true;
|
||||||
g_pd3dDevice->CreateRasterizerState(&desc, &g_pRasterizerState);
|
bd->pd3dDevice->CreateRasterizerState(&desc, &bd->pRasterizerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create depth-stencil State
|
// Create depth-stencil State
|
||||||
@ -483,7 +504,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.BackFace = desc.FrontFace;
|
desc.BackFace = desc.FrontFace;
|
||||||
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplDX11_CreateFontsTexture();
|
ImGui_ImplDX11_CreateFontsTexture();
|
||||||
@ -493,27 +514,31 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
|
|
||||||
void ImGui_ImplDX11_InvalidateDeviceObjects()
|
void ImGui_ImplDX11_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
if (!bd->pd3dDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = NULL; }
|
||||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied data->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; }
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; }
|
||||||
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = NULL; }
|
||||||
if (g_pBlendState) { g_pBlendState->Release(); g_pBlendState = NULL; }
|
if (bd->pDepthStencilState) { bd->pDepthStencilState->Release(); bd->pDepthStencilState = NULL; }
|
||||||
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
|
if (bd->pRasterizerState) { bd->pRasterizerState->Release(); bd->pRasterizerState = NULL; }
|
||||||
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
|
if (bd->pPixelShader) { bd->pPixelShader->Release(); bd->pPixelShader = NULL; }
|
||||||
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
|
if (bd->pVertexConstantBuffer) { bd->pVertexConstantBuffer->Release(); bd->pVertexConstantBuffer = NULL; }
|
||||||
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
|
if (bd->pInputLayout) { bd->pInputLayout->Release(); bd->pInputLayout = NULL; }
|
||||||
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
|
if (bd->pVertexShader) { bd->pVertexShader->Release(); bd->pVertexShader = NULL; }
|
||||||
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
||||||
{
|
{
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplDX11_Data* bd = IM_NEW(ImGui_ImplDX11_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx11";
|
io.BackendRendererName = "imgui_impl_dx11";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
@ -526,28 +551,37 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
|
if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
|
||||||
if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
|
if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
|
||||||
{
|
{
|
||||||
g_pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
g_pd3dDeviceContext = device_context;
|
bd->pd3dDeviceContext = device_context;
|
||||||
g_pFactory = pFactory;
|
bd->pFactory = pFactory;
|
||||||
}
|
}
|
||||||
if (pDXGIDevice) pDXGIDevice->Release();
|
if (pDXGIDevice) pDXGIDevice->Release();
|
||||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
if (pDXGIAdapter) pDXGIAdapter->Release();
|
||||||
g_pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
g_pd3dDeviceContext->AddRef();
|
bd->pd3dDeviceContext->AddRef();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX11_Shutdown()
|
void ImGui_ImplDX11_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
|
if (bd->pFactory) { bd->pFactory->Release(); }
|
||||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
|
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
||||||
|
io.BackendRendererName = NULL;
|
||||||
|
io.BackendRendererUserData = NULL;
|
||||||
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX11_NewFrame()
|
void ImGui_ImplDX11_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_pFontSampler)
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX11_Init()?");
|
||||||
|
|
||||||
|
if (!bd->pFontSampler)
|
||||||
ImGui_ImplDX11_CreateDeviceObjects();
|
ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
|
// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1.
|
||||||
// 2021-05-19: DirectX9: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX9: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
// 2021-04-23: DirectX9: Explicitly setting up more graphics states to increase compatibility with unusual non-default states.
|
// 2021-04-23: DirectX9: Explicitly setting up more graphics states to increase compatibility with unusual non-default states.
|
||||||
// 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857).
|
// 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857).
|
||||||
@ -34,11 +37,17 @@
|
|||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
|
||||||
// DirectX data
|
// DirectX data
|
||||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
struct ImGui_ImplDX9_Data
|
||||||
static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
|
{
|
||||||
static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
|
LPDIRECT3DDEVICE9 pd3dDevice;
|
||||||
static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
|
LPDIRECT3DVERTEXBUFFER9 pVB;
|
||||||
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
LPDIRECT3DINDEXBUFFER9 pIB;
|
||||||
|
LPDIRECT3DTEXTURE9 FontTexture;
|
||||||
|
int VertexBufferSize;
|
||||||
|
int IndexBufferSize;
|
||||||
|
|
||||||
|
ImGui_ImplDX9_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
|
||||||
|
};
|
||||||
|
|
||||||
struct CUSTOMVERTEX
|
struct CUSTOMVERTEX
|
||||||
{
|
{
|
||||||
@ -54,8 +63,18 @@ struct CUSTOMVERTEX
|
|||||||
#define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16))
|
#define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
|
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||||
|
static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3DVIEWPORT9 vp;
|
D3DVIEWPORT9 vp;
|
||||||
vp.X = vp.Y = 0;
|
vp.X = vp.Y = 0;
|
||||||
@ -63,39 +82,41 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
|||||||
vp.Height = (DWORD)draw_data->DisplaySize.y;
|
vp.Height = (DWORD)draw_data->DisplaySize.y;
|
||||||
vp.MinZ = 0.0f;
|
vp.MinZ = 0.0f;
|
||||||
vp.MaxZ = 1.0f;
|
vp.MaxZ = 1.0f;
|
||||||
g_pd3dDevice->SetViewport(&vp);
|
bd->pd3dDevice->SetViewport(&vp);
|
||||||
|
|
||||||
// Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient)
|
// Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient)
|
||||||
g_pd3dDevice->SetPixelShader(NULL);
|
bd->pd3dDevice->SetPixelShader(NULL);
|
||||||
g_pd3dDevice->SetVertexShader(NULL);
|
bd->pd3dDevice->SetVertexShader(NULL);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
|
bd->pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
bd->pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
bd->pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
bd->pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
bd->pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
bd->pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
bd->pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
|
bd->pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE);
|
bd->pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA);
|
bd->pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
bd->pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE);
|
bd->pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
bd->pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
||||||
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
bd->pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
bd->pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
|
bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
|
bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
|
|
||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||||
@ -113,9 +134,9 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
|||||||
0.0f, 0.0f, 0.5f, 0.0f,
|
0.0f, 0.0f, 0.5f, 0.0f,
|
||||||
(L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f
|
(L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f
|
||||||
} } };
|
} } };
|
||||||
g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
|
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
|
||||||
g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
|
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
|
||||||
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
|
bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,24 +148,25 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create and grow buffers if needed
|
// Create and grow buffers if needed
|
||||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
{
|
{
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; }
|
||||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
if (bd->pd3dDevice->CreateVertexBuffer(bd->VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &bd->pVB, NULL) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; }
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
if (bd->pd3dDevice->CreateIndexBuffer(bd->IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &bd->pIB, NULL) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup the DX9 state
|
// Backup the DX9 state
|
||||||
IDirect3DStateBlock9* d3d9_state_block = NULL;
|
IDirect3DStateBlock9* d3d9_state_block = NULL;
|
||||||
if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
|
if (bd->pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
|
||||||
return;
|
return;
|
||||||
if (d3d9_state_block->Capture() < 0)
|
if (d3d9_state_block->Capture() < 0)
|
||||||
{
|
{
|
||||||
@ -154,21 +176,21 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
|
// Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
|
||||||
D3DMATRIX last_world, last_view, last_projection;
|
D3DMATRIX last_world, last_view, last_projection;
|
||||||
g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
|
||||||
g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
|
||||||
g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
bd->pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
||||||
|
|
||||||
// Allocate buffers
|
// Allocate buffers
|
||||||
CUSTOMVERTEX* vtx_dst;
|
CUSTOMVERTEX* vtx_dst;
|
||||||
ImDrawIdx* idx_dst;
|
ImDrawIdx* idx_dst;
|
||||||
if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
if (bd->pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
||||||
{
|
{
|
||||||
d3d9_state_block->Release();
|
d3d9_state_block->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
if (bd->pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
||||||
{
|
{
|
||||||
g_pVB->Unlock();
|
bd->pVB->Unlock();
|
||||||
d3d9_state_block->Release();
|
d3d9_state_block->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -195,11 +217,11 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
idx_dst += cmd_list->IdxBuffer.Size;
|
idx_dst += cmd_list->IdxBuffer.Size;
|
||||||
}
|
}
|
||||||
g_pVB->Unlock();
|
bd->pVB->Unlock();
|
||||||
g_pIB->Unlock();
|
bd->pIB->Unlock();
|
||||||
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
|
bd->pd3dDevice->SetStreamSource(0, bd->pVB, 0, sizeof(CUSTOMVERTEX));
|
||||||
g_pd3dDevice->SetIndices(g_pIB);
|
bd->pd3dDevice->SetIndices(bd->pIB);
|
||||||
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
|
bd->pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
|
||||||
|
|
||||||
// Setup desired DX state
|
// Setup desired DX state
|
||||||
ImGui_ImplDX9_SetupRenderState(draw_data);
|
ImGui_ImplDX9_SetupRenderState(draw_data);
|
||||||
@ -228,9 +250,9 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||||
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID();
|
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID();
|
||||||
g_pd3dDevice->SetTexture(0, texture);
|
bd->pd3dDevice->SetTexture(0, texture);
|
||||||
g_pd3dDevice->SetScissorRect(&r);
|
bd->pd3dDevice->SetScissorRect(&r);
|
||||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3);
|
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global_idx_offset += cmd_list->IdxBuffer.Size;
|
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||||
@ -238,9 +260,9 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore the DX9 transform
|
// Restore the DX9 transform
|
||||||
g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
||||||
g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
||||||
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
|
bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
|
||||||
|
|
||||||
// Restore the DX9 state
|
// Restore the DX9 state
|
||||||
d3d9_state_block->Apply();
|
d3d9_state_block->Apply();
|
||||||
@ -249,26 +271,38 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||||
{
|
{
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx9";
|
io.BackendRendererName = "imgui_impl_dx9";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
g_pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
g_pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX9_Shutdown()
|
void ImGui_ImplDX9_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
|
||||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
|
io.BackendRendererName = NULL;
|
||||||
|
io.BackendRendererUserData = NULL;
|
||||||
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height, bytes_per_pixel;
|
int width, height, bytes_per_pixel;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
|
||||||
@ -277,26 +311,26 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
if (io.Fonts->TexPixelsUseColors)
|
if (io.Fonts->TexPixelsUseColors)
|
||||||
{
|
{
|
||||||
ImU32* dst_start = (ImU32*)ImGui::MemAlloc(width * height * bytes_per_pixel);
|
ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
|
||||||
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + width * height; dst < dst_end; src++, dst++)
|
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
|
||||||
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
||||||
pixels = (unsigned char*)dst_start;
|
pixels = (unsigned char*)dst_start;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
g_FontTexture = NULL;
|
bd->FontTexture = NULL;
|
||||||
if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
|
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, NULL) < 0)
|
||||||
return false;
|
return false;
|
||||||
D3DLOCKED_RECT tex_locked_rect;
|
D3DLOCKED_RECT tex_locked_rect;
|
||||||
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
if (bd->FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
||||||
return false;
|
return false;
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
memcpy((unsigned char*)tex_locked_rect.pBits + (size_t)tex_locked_rect.Pitch * y, pixels + (size_t)width * bytes_per_pixel * y, (size_t)width * bytes_per_pixel);
|
||||||
g_FontTexture->UnlockRect(0);
|
bd->FontTexture->UnlockRect(0);
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->SetTexID((ImTextureID)g_FontTexture);
|
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
||||||
|
|
||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
if (io.Fonts->TexPixelsUseColors)
|
if (io.Fonts->TexPixelsUseColors)
|
||||||
@ -308,7 +342,8 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
|
|
||||||
bool ImGui_ImplDX9_CreateDeviceObjects()
|
bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
if (!bd || !bd->pd3dDevice)
|
||||||
return false;
|
return false;
|
||||||
if (!ImGui_ImplDX9_CreateFontsTexture())
|
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||||
return false;
|
return false;
|
||||||
@ -317,15 +352,19 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
|
|||||||
|
|
||||||
void ImGui_ImplDX9_InvalidateDeviceObjects()
|
void ImGui_ImplDX9_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
if (!bd || !bd->pd3dDevice)
|
||||||
return;
|
return;
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; }
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; }
|
||||||
if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX9_Init()?");
|
||||||
|
|
||||||
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
@ -21,7 +22,7 @@
|
|||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
||||||
// Configuration flags to add in your imconfig.h file:
|
// Configuration flags to add in your imconfig.h file:
|
||||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support (this used to be meaningful before <1.81) but we know load XInput dynamically so the option is less relevant now.
|
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant.
|
||||||
|
|
||||||
// Using XInput for gamepad (will load DLL dynamically)
|
// Using XInput for gamepad (will load DLL dynamically)
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
@ -32,6 +33,11 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2021-08-17: Calling io.AddFocusEvent() on WM_SETFOCUS/WM_KILLFOCUS messages.
|
||||||
|
// 2021-08-02: Inputs: Fixed keyboard modifiers being reported when host windo doesn't have focus.
|
||||||
|
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using TrackMouseEvent() to receive WM_MOUSELEAVE events).
|
||||||
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
|
// 2021-06-08: Fixed ImGui_ImplWin32_EnableDpiAwareness() and ImGui_ImplWin32_GetDpiScaleForMonitor() to handle Windows 8.1/10 features without a manifest (per-monitor DPI, and properly calls SetProcessDpiAwareness() on 8.1).
|
||||||
// 2021-03-23: Inputs: Clearing keyboard down array when losing focus (WM_KILLFOCUS).
|
// 2021-03-23: Inputs: Clearing keyboard down array when losing focus (WM_KILLFOCUS).
|
||||||
// 2021-02-18: Added ImGui_ImplWin32_EnableAlphaCompositing(). Non Visual Studio users will need to link with dwmapi.lib (MinGW/gcc: use -ldwmapi).
|
// 2021-02-18: Added ImGui_ImplWin32_EnableAlphaCompositing(). Non Visual Studio users will need to link with dwmapi.lib (MinGW/gcc: use -ldwmapi).
|
||||||
// 2021-02-17: Fixed ImGui_ImplWin32_EnableDpiAwareness() attempting to get SetProcessDpiAwareness from shcore.dll on Windows 8 whereas it is only supported on Windows 8.1.
|
// 2021-02-17: Fixed ImGui_ImplWin32_EnableDpiAwareness() attempting to get SetProcessDpiAwareness from shcore.dll on Windows 8 whereas it is only supported on Windows 8.1.
|
||||||
@ -61,35 +67,60 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
||||||
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
|
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
|
||||||
|
|
||||||
// Win32 Data
|
struct ImGui_ImplWin32_Data
|
||||||
static HWND g_hWnd = NULL;
|
{
|
||||||
static INT64 g_Time = 0;
|
HWND hWnd;
|
||||||
static INT64 g_TicksPerSecond = 0;
|
HWND MouseHwnd;
|
||||||
static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
|
bool MouseTracked;
|
||||||
static bool g_HasGamepad = false;
|
INT64 Time;
|
||||||
static bool g_WantUpdateHasGamepad = true;
|
INT64 TicksPerSecond;
|
||||||
|
ImGuiMouseCursor LastMouseCursor;
|
||||||
|
bool HasGamepad;
|
||||||
|
bool WantUpdateHasGamepad;
|
||||||
|
|
||||||
// XInput DLL and functions
|
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
static HMODULE g_XInputDLL = NULL;
|
HMODULE XInputDLL;
|
||||||
static PFN_XInputGetCapabilities g_XInputGetCapabilities = NULL;
|
PFN_XInputGetCapabilities XInputGetCapabilities;
|
||||||
static PFN_XInputGetState g_XInputGetState = NULL;
|
PFN_XInputGetState XInputGetState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ImGui_ImplWin32_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
|
||||||
|
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||||
|
// FIXME: multi-context support is not well tested and probably dysfunctional in this backend.
|
||||||
|
// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context.
|
||||||
|
static ImGui_ImplWin32_Data* ImGui_ImplWin32_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplWin32_Data*)ImGui::GetIO().BackendPlatformUserData : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplWin32_Init(void* hwnd)
|
bool ImGui_ImplWin32_Init(void* hwnd)
|
||||||
{
|
{
|
||||||
if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&g_TicksPerSecond))
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
|
||||||
|
|
||||||
|
INT64 perf_frequency, perf_counter;
|
||||||
|
if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&perf_frequency))
|
||||||
return false;
|
return false;
|
||||||
if (!::QueryPerformanceCounter((LARGE_INTEGER*)&g_Time))
|
if (!::QueryPerformanceCounter((LARGE_INTEGER*)&perf_counter))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
g_hWnd = (HWND)hwnd;
|
ImGui_ImplWin32_Data* bd = IM_NEW(ImGui_ImplWin32_Data)();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
|
io.BackendPlatformName = "imgui_impl_win32";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
io.BackendPlatformName = "imgui_impl_win32";
|
|
||||||
|
bd->hWnd = (HWND)hwnd;
|
||||||
|
bd->WantUpdateHasGamepad = true;
|
||||||
|
bd->TicksPerSecond = perf_frequency;
|
||||||
|
bd->Time = perf_counter;
|
||||||
|
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||||
|
|
||||||
io.ImeWindowHandle = hwnd;
|
io.ImeWindowHandle = hwnd;
|
||||||
|
|
||||||
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
|
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
|
||||||
@ -129,9 +160,9 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++)
|
for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++)
|
||||||
if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n]))
|
if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n]))
|
||||||
{
|
{
|
||||||
g_XInputDLL = dll;
|
bd->XInputDLL = dll;
|
||||||
g_XInputGetCapabilities = (PFN_XInputGetCapabilities)::GetProcAddress(dll, "XInputGetCapabilities");
|
bd->XInputGetCapabilities = (PFN_XInputGetCapabilities)::GetProcAddress(dll, "XInputGetCapabilities");
|
||||||
g_XInputGetState = (PFN_XInputGetState)::GetProcAddress(dll, "XInputGetState");
|
bd->XInputGetState = (PFN_XInputGetState)::GetProcAddress(dll, "XInputGetState");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
@ -141,21 +172,18 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
|
|
||||||
void ImGui_ImplWin32_Shutdown()
|
void ImGui_ImplWin32_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
|
||||||
// Unload XInput library
|
// Unload XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
if (g_XInputDLL)
|
if (bd->XInputDLL)
|
||||||
::FreeLibrary(g_XInputDLL);
|
::FreeLibrary(bd->XInputDLL);
|
||||||
g_XInputDLL = NULL;
|
|
||||||
g_XInputGetCapabilities = NULL;
|
|
||||||
g_XInputGetState = NULL;
|
|
||||||
#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
|
|
||||||
g_hWnd = NULL;
|
io.BackendPlatformName = NULL;
|
||||||
g_Time = 0;
|
io.BackendPlatformUserData = NULL;
|
||||||
g_TicksPerSecond = 0;
|
IM_DELETE(bd);
|
||||||
g_LastMouseCursor = ImGuiMouseCursor_COUNT;
|
|
||||||
g_HasGamepad = false;
|
|
||||||
g_WantUpdateHasGamepad = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplWin32_UpdateMouseCursor()
|
static bool ImGui_ImplWin32_UpdateMouseCursor()
|
||||||
@ -193,24 +221,36 @@ static bool ImGui_ImplWin32_UpdateMouseCursor()
|
|||||||
|
|
||||||
static void ImGui_ImplWin32_UpdateMousePos()
|
static void ImGui_ImplWin32_UpdateMousePos()
|
||||||
{
|
{
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(g_hWnd != 0);
|
IM_ASSERT(bd->hWnd != 0);
|
||||||
|
|
||||||
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
const ImVec2 mouse_pos_prev = io.MousePos;
|
||||||
|
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||||
|
|
||||||
|
// Obtain focused and hovered window. We forward mouse input when focused or when hovered (and no other window is capturing)
|
||||||
|
HWND focused_window = ::GetForegroundWindow();
|
||||||
|
HWND hovered_window = bd->MouseHwnd;
|
||||||
|
HWND mouse_window = NULL;
|
||||||
|
if (hovered_window && (hovered_window == bd->hWnd || ::IsChild(hovered_window, bd->hWnd)))
|
||||||
|
mouse_window = hovered_window;
|
||||||
|
else if (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd)))
|
||||||
|
mouse_window = focused_window;
|
||||||
|
if (mouse_window == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
{
|
{
|
||||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
POINT pos = { (int)mouse_pos_prev.x, (int)mouse_pos_prev.y };
|
||||||
if (::ClientToScreen(g_hWnd, &pos))
|
if (::ClientToScreen(bd->hWnd, &pos))
|
||||||
::SetCursorPos(pos.x, pos.y);
|
::SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set mouse position
|
// Set Dear ImGui mouse position from OS position
|
||||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
|
||||||
POINT pos;
|
POINT pos;
|
||||||
if (HWND active_window = ::GetForegroundWindow())
|
if (::GetCursorPos(&pos) && ::ScreenToClient(mouse_window, &pos))
|
||||||
if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd))
|
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
||||||
if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos))
|
|
||||||
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad navigation mapping
|
// Gamepad navigation mapping
|
||||||
@ -218,22 +258,23 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
{
|
{
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
|
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
|
||||||
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
||||||
if (g_WantUpdateHasGamepad)
|
if (bd->WantUpdateHasGamepad)
|
||||||
{
|
{
|
||||||
XINPUT_CAPABILITIES caps;
|
XINPUT_CAPABILITIES caps;
|
||||||
g_HasGamepad = g_XInputGetCapabilities ? (g_XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false;
|
bd->HasGamepad = bd->XInputGetCapabilities ? (bd->XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false;
|
||||||
g_WantUpdateHasGamepad = false;
|
bd->WantUpdateHasGamepad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
XINPUT_STATE xinput_state;
|
XINPUT_STATE xinput_state;
|
||||||
if (g_HasGamepad && g_XInputGetState && g_XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
|
if (bd->HasGamepad && bd->XInputGetState && bd->XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
@ -265,34 +306,28 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
void ImGui_ImplWin32_NewFrame()
|
void ImGui_ImplWin32_NewFrame()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplWin32_Init()?");
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
RECT rect = { 0, 0, 0, 0 };
|
RECT rect = { 0, 0, 0, 0 };
|
||||||
::GetClientRect(g_hWnd, &rect);
|
::GetClientRect(bd->hWnd, &rect);
|
||||||
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time = 0;
|
INT64 current_time = 0;
|
||||||
::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time);
|
::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time);
|
||||||
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
io.DeltaTime = (float)(current_time - bd->Time) / bd->TicksPerSecond;
|
||||||
g_Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
// Read keyboard modifiers inputs
|
|
||||||
io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
|
||||||
io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
|
||||||
io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
|
|
||||||
io.KeySuper = false;
|
|
||||||
// io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below.
|
|
||||||
|
|
||||||
// Update OS mouse position
|
// Update OS mouse position
|
||||||
ImGui_ImplWin32_UpdateMousePos();
|
ImGui_ImplWin32_UpdateMousePos();
|
||||||
|
|
||||||
// Update OS mouse cursor with the cursor requested by imgui
|
// Update OS mouse cursor with the cursor requested by imgui
|
||||||
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
|
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
|
||||||
if (g_LastMouseCursor != mouse_cursor)
|
if (bd->LastMouseCursor != mouse_cursor)
|
||||||
{
|
{
|
||||||
g_LastMouseCursor = mouse_cursor;
|
bd->LastMouseCursor = mouse_cursor;
|
||||||
ImGui_ImplWin32_UpdateMouseCursor();
|
ImGui_ImplWin32_UpdateMouseCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,8 +361,25 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
// We need to call TrackMouseEvent in order to receive WM_MOUSELEAVE events
|
||||||
|
bd->MouseHwnd = hwnd;
|
||||||
|
if (!bd->MouseTracked)
|
||||||
|
{
|
||||||
|
TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE, hwnd, 0 };
|
||||||
|
::TrackMouseEvent(&tme);
|
||||||
|
bd->MouseTracked = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_MOUSELEAVE:
|
||||||
|
if (bd->MouseHwnd == hwnd)
|
||||||
|
bd->MouseHwnd = NULL;
|
||||||
|
bd->MouseTracked = false;
|
||||||
|
break;
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
||||||
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
|
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
|
||||||
@ -365,17 +417,24 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
||||||
return 0;
|
return 0;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
if (wParam < 256)
|
|
||||||
io.KeysDown[wParam] = 1;
|
|
||||||
return 0;
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
|
{
|
||||||
|
bool down = (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN);
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 0;
|
io.KeysDown[wParam] = down;
|
||||||
|
if (wParam == VK_CONTROL)
|
||||||
|
io.KeyCtrl = down;
|
||||||
|
if (wParam == VK_SHIFT)
|
||||||
|
io.KeyShift = down;
|
||||||
|
if (wParam == VK_MENU)
|
||||||
|
io.KeyAlt = down;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_SETFOCUS:
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
memset(io.KeysDown, 0, sizeof(io.KeysDown));
|
io.AddFocusEvent(msg == WM_SETFOCUS);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||||
@ -388,7 +447,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
return 0;
|
return 0;
|
||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
if ((UINT)wParam == DBT_DEVNODES_CHANGED)
|
if ((UINT)wParam == DBT_DEVNODES_CHANGED)
|
||||||
g_WantUpdateHasGamepad = true;
|
bd->WantUpdateHasGamepad = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -409,21 +468,32 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
// If you are trying to implement your own backend for your own engine, you may ignore that noise.
|
// If you are trying to implement your own backend for your own engine, you may ignore that noise.
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Implement some of the functions and types normally declared in recent Windows SDK.
|
// Perform our own check with RtlVerifyVersionInfo() instead of using functions from <VersionHelpers.h> as they
|
||||||
#if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS)
|
// require a manifest to be functional for checks above 8.1. See https://github.com/ocornut/imgui/issues/4200
|
||||||
static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp)
|
static BOOL _IsWindowsVersionOrGreater(WORD major, WORD minor, WORD)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp, 0, 0, 0, 0 };
|
typedef LONG(WINAPI* PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*, ULONG, ULONGLONG);
|
||||||
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
|
static PFN_RtlVerifyVersionInfo RtlVerifyVersionInfoFn = NULL;
|
||||||
ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
if (RtlVerifyVersionInfoFn == NULL)
|
||||||
cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll"))
|
||||||
cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo");
|
||||||
return ::VerifyVersionInfoW(&osvi, mask, cond);
|
if (RtlVerifyVersionInfoFn == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
RTL_OSVERSIONINFOEXW versionInfo = { };
|
||||||
|
ULONGLONG conditionMask = 0;
|
||||||
|
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
|
||||||
|
versionInfo.dwMajorVersion = major;
|
||||||
|
versionInfo.dwMinorVersion = minor;
|
||||||
|
VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||||
|
VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
|
return (RtlVerifyVersionInfoFn(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask) == 0) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
#define IsWindowsVistaOrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0600), LOBYTE(0x0600), 0) // _WIN32_WINNT_VISTA
|
|
||||||
#define IsWindows8OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WIN8
|
#define _IsWindowsVistaOrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0600), LOBYTE(0x0600), 0) // _WIN32_WINNT_VISTA
|
||||||
#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0603), LOBYTE(0x0603), 0) // _WIN32_WINNT_WINBLUE
|
#define _IsWindows8OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WIN8
|
||||||
#endif
|
#define _IsWindows8Point1OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0603), LOBYTE(0x0603), 0) // _WIN32_WINNT_WINBLUE
|
||||||
|
#define _IsWindows10OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0A00), LOBYTE(0x0A00), 0) // _WIN32_WINNT_WINTHRESHOLD / _WIN32_WINNT_WIN10
|
||||||
|
|
||||||
#ifndef DPI_ENUMS_DECLARED
|
#ifndef DPI_ENUMS_DECLARED
|
||||||
typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
|
typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
|
||||||
@ -443,7 +513,7 @@ typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWAR
|
|||||||
// Helper function to enable DPI awareness without setting up a manifest
|
// Helper function to enable DPI awareness without setting up a manifest
|
||||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||||
{
|
{
|
||||||
// if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer!
|
if (_IsWindows10OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||||
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
||||||
@ -452,7 +522,7 @@ void ImGui_ImplWin32_EnableDpiAwareness()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IsWindows8Point1OrGreater())
|
if (_IsWindows8Point1OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||||
if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
|
if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
|
||||||
@ -473,23 +543,26 @@ void ImGui_ImplWin32_EnableDpiAwareness()
|
|||||||
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
||||||
{
|
{
|
||||||
UINT xdpi = 96, ydpi = 96;
|
UINT xdpi = 96, ydpi = 96;
|
||||||
static BOOL bIsWindows8Point1OrGreater = IsWindows8Point1OrGreater();
|
if (_IsWindows8Point1OrGreater())
|
||||||
if (bIsWindows8Point1OrGreater)
|
|
||||||
{
|
{
|
||||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||||
if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
|
static PFN_GetDpiForMonitor GetDpiForMonitorFn = NULL;
|
||||||
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
if (GetDpiForMonitorFn == NULL && shcore_dll != NULL)
|
||||||
|
GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor");
|
||||||
|
if (GetDpiForMonitorFn != NULL)
|
||||||
|
{
|
||||||
|
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||||
|
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||||
|
return xdpi / 96.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef NOGDI
|
#ifndef NOGDI
|
||||||
else
|
const HDC dc = ::GetDC(NULL);
|
||||||
{
|
xdpi = ::GetDeviceCaps(dc, LOGPIXELSX);
|
||||||
const HDC dc = ::GetDC(NULL);
|
ydpi = ::GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
xdpi = ::GetDeviceCaps(dc, LOGPIXELSX);
|
|
||||||
ydpi = ::GetDeviceCaps(dc, LOGPIXELSY);
|
|
||||||
::ReleaseDC(NULL, dc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||||
|
::ReleaseDC(NULL, dc);
|
||||||
|
#endif
|
||||||
return xdpi / 96.0f;
|
return xdpi / 96.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +585,7 @@ float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
|||||||
// (the Dwm* functions are Vista era functions but we are borrowing logic from GLFW)
|
// (the Dwm* functions are Vista era functions but we are borrowing logic from GLFW)
|
||||||
void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
||||||
{
|
{
|
||||||
if (!IsWindowsVistaOrGreater())
|
if (!_IsWindowsVistaOrGreater())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOL composition;
|
BOOL composition;
|
||||||
@ -521,7 +594,7 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
|||||||
|
|
||||||
BOOL opaque;
|
BOOL opaque;
|
||||||
DWORD color;
|
DWORD color;
|
||||||
if (IsWindows8OrGreater() || (SUCCEEDED(::DwmGetColorizationColor(&color, &opaque)) && !opaque))
|
if (_IsWindows8OrGreater() || (SUCCEEDED(::DwmGetColorizationColor(&color, &opaque)) && !opaque))
|
||||||
{
|
{
|
||||||
HRGN region = ::CreateRectRgn(0, 0, -1, -1);
|
HRGN region = ::CreateRectRgn(0, 0, -1, -1);
|
||||||
DWM_BLURBEHIND bb = {};
|
DWM_BLURBEHIND bb = {};
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.83
|
// dear imgui, v1.84
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
@ -43,7 +43,7 @@ Index of this file:
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef IMGUI_VERSION
|
#ifndef IMGUI_VERSION
|
||||||
#error Must include imgui.h before imgui_internal.h
|
#include "imgui.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h> // FILE*, sscanf
|
#include <stdio.h> // FILE*, sscanf
|
||||||
@ -52,7 +52,7 @@ Index of this file:
|
|||||||
#include <limits.h> // INT_MIN, INT_MAX
|
#include <limits.h> // INT_MIN, INT_MAX
|
||||||
|
|
||||||
// Enable SSE intrinsics if available
|
// Enable SSE intrinsics if available
|
||||||
#if defined __SSE__ || defined __x86_64__ || defined _M_X64
|
#if (defined __SSE__ || defined __x86_64__ || defined _M_X64) && !defined(IMGUI_DISABLE_SSE)
|
||||||
#define IMGUI_ENABLE_SSE
|
#define IMGUI_ENABLE_SSE
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
@ -63,7 +63,9 @@ Index of this file:
|
|||||||
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
|
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
|
||||||
#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
|
#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
|
||||||
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
||||||
|
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
// Clang/GCC warnings with -Weverything
|
||||||
@ -86,6 +88,13 @@ Index of this file:
|
|||||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Helper macros
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define IM_NORETURN __attribute__((noreturn))
|
||||||
|
#else
|
||||||
|
#define IM_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
// Legacy defines
|
// Legacy defines
|
||||||
#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
|
#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
|
||||||
#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
|
#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
|
||||||
@ -114,7 +123,7 @@ struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
|||||||
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
||||||
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||||||
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||||||
struct ImGuiLastItemDataBackup; // Backup and restore IsItemHovered() internal data
|
struct ImGuiLastItemData; // Status storage for last submitted items
|
||||||
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||||||
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
|
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
|
||||||
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
|
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
|
||||||
@ -322,12 +331,13 @@ static inline bool ImCharIsBlankA(char c) { return c == ' ' || c =
|
|||||||
static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||||
|
|
||||||
// Helpers: UTF-8 <> wchar conversions
|
// Helpers: UTF-8 <> wchar conversions
|
||||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
IMGUI_API const char* ImTextCharToUtf8(char out_buf[5], unsigned int c); // return out_buf
|
||||||
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||||
IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
||||||
IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
|
IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
||||||
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
|
||||||
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
||||||
|
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
||||||
|
|
||||||
// Helpers: ImVec2/ImVec4 operators
|
// Helpers: ImVec2/ImVec4 operators
|
||||||
// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
|
// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
|
||||||
@ -609,20 +619,30 @@ struct IMGUI_API ImPool
|
|||||||
ImVector<T> Buf; // Contiguous data
|
ImVector<T> Buf; // Contiguous data
|
||||||
ImGuiStorage Map; // ID->Index
|
ImGuiStorage Map; // ID->Index
|
||||||
ImPoolIdx FreeIdx; // Next free idx to use
|
ImPoolIdx FreeIdx; // Next free idx to use
|
||||||
|
ImPoolIdx AliveCount; // Number of active/alive items (for display purpose)
|
||||||
|
|
||||||
ImPool() { FreeIdx = 0; }
|
ImPool() { FreeIdx = AliveCount = 0; }
|
||||||
~ImPool() { Clear(); }
|
~ImPool() { Clear(); }
|
||||||
T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
|
T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
|
||||||
T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
|
T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
|
||||||
ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
|
ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
|
||||||
T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
||||||
bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
|
bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
|
||||||
void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; }
|
void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; }
|
||||||
T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; }
|
T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++; return &Buf[idx]; }
|
||||||
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||||||
void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; }
|
||||||
void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
|
void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
|
||||||
int GetSize() const { return Buf.Size; }
|
|
||||||
|
// To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... }
|
||||||
|
// Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize()
|
||||||
|
int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose)
|
||||||
|
int GetBufSize() const { return Buf.Size; }
|
||||||
|
int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
|
||||||
|
T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304)
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper: ImChunkStream<>
|
// Helper: ImChunkStream<>
|
||||||
@ -720,14 +740,14 @@ struct ImDrawDataBuilder
|
|||||||
enum ImGuiItemFlags_
|
enum ImGuiItemFlags_
|
||||||
{
|
{
|
||||||
ImGuiItemFlags_None = 0,
|
ImGuiItemFlags_None = 0,
|
||||||
ImGuiItemFlags_NoTabStop = 1 << 0, // false
|
ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing (FIXME: should merge with _NoNav)
|
||||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||||
ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
|
ImGuiItemFlags_Disabled = 1 << 2, // false // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211
|
||||||
ImGuiItemFlags_NoNav = 1 << 3, // false
|
ImGuiItemFlags_NoNav = 1 << 3, // false // Disable keyboard/gamepad directional navigation (FIXME: should merge with _NoTabStop)
|
||||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false // Disable item being a candidate for default focus (e.g. used by title bar items)
|
||||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
||||||
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||||
ImGuiItemFlags_ReadOnly = 1 << 7 // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
ImGuiItemFlags_ReadOnly = 1 << 7 // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ItemAdd()
|
// Flags for ItemAdd()
|
||||||
@ -785,7 +805,7 @@ enum ImGuiButtonFlagsPrivate_
|
|||||||
ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping
|
ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping
|
||||||
ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
||||||
ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED]
|
ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED]
|
||||||
ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions
|
//ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions -> use BeginDisabled() or ImGuiItemFlags_Disabled
|
||||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
||||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held
|
ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held
|
||||||
ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||||
@ -795,6 +815,12 @@ enum ImGuiButtonFlagsPrivate_
|
|||||||
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
|
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Extend ImGuiComboFlags_
|
||||||
|
enum ImGuiComboFlagsPrivate_
|
||||||
|
{
|
||||||
|
ImGuiComboFlags_CustomPreview = 1 << 20 // enable BeginComboPreview()
|
||||||
|
};
|
||||||
|
|
||||||
// Extend ImGuiSliderFlags_
|
// Extend ImGuiSliderFlags_
|
||||||
enum ImGuiSliderFlagsPrivate_
|
enum ImGuiSliderFlagsPrivate_
|
||||||
{
|
{
|
||||||
@ -807,12 +833,13 @@ enum ImGuiSelectableFlagsPrivate_
|
|||||||
{
|
{
|
||||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||||
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
||||||
ImGuiSelectableFlags_SelectOnClick = 1 << 21, // Override button behavior to react on Click (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
|
||||||
ImGuiSelectableFlags_SelectOnRelease = 1 << 22, // Override button behavior to react on Release (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release)
|
||||||
ImGuiSelectableFlags_SpanAvailWidth = 1 << 23, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release)
|
||||||
ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
||||||
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25, // Set Nav/Focus ID on mouse hover (used by MenuItem)
|
ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||||
ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 26 // Disable padding each side with ItemSpacing * 0.5f
|
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26, // Set Nav/Focus ID on mouse hover (used by MenuItem)
|
||||||
|
ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 27 // Disable padding each side with ItemSpacing * 0.5f
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiTreeNodeFlags_
|
// Extend ImGuiTreeNodeFlags_
|
||||||
@ -983,6 +1010,19 @@ struct ImGuiStyleMod
|
|||||||
ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
|
ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Storage data for BeginComboPreview()/EndComboPreview()
|
||||||
|
struct IMGUI_API ImGuiComboPreviewData
|
||||||
|
{
|
||||||
|
ImRect PreviewRect;
|
||||||
|
ImVec2 BackupCursorPos;
|
||||||
|
ImVec2 BackupCursorMaxPos;
|
||||||
|
ImVec2 BackupCursorPosPrevLine;
|
||||||
|
float BackupPrevLineTextBaseOffset;
|
||||||
|
ImGuiLayoutType BackupLayout;
|
||||||
|
|
||||||
|
ImGuiComboPreviewData() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
// Stacked storage data for BeginGroup()/EndGroup()
|
// Stacked storage data for BeginGroup()/EndGroup()
|
||||||
struct IMGUI_API ImGuiGroupData
|
struct IMGUI_API ImGuiGroupData
|
||||||
{
|
{
|
||||||
@ -1002,14 +1042,19 @@ struct IMGUI_API ImGuiGroupData
|
|||||||
// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
|
// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
|
||||||
struct IMGUI_API ImGuiMenuColumns
|
struct IMGUI_API ImGuiMenuColumns
|
||||||
{
|
{
|
||||||
float Spacing;
|
ImU32 TotalWidth;
|
||||||
float Width, NextWidth;
|
ImU32 NextTotalWidth;
|
||||||
float Pos[3], NextWidths[3];
|
ImU16 Spacing;
|
||||||
|
ImU16 OffsetIcon; // Always zero for now
|
||||||
|
ImU16 OffsetLabel; // Offsets are locked in Update()
|
||||||
|
ImU16 OffsetShortcut;
|
||||||
|
ImU16 OffsetMark;
|
||||||
|
ImU16 Widths[4]; // Width of: Icon, Label, Shortcut, Mark (accumulators for current frame)
|
||||||
|
|
||||||
ImGuiMenuColumns() { memset(this, 0, sizeof(*this)); }
|
ImGuiMenuColumns() { memset(this, 0, sizeof(*this)); }
|
||||||
void Update(int count, float spacing, bool clear);
|
void Update(float spacing, bool window_reappearing);
|
||||||
float DeclColumns(float w0, float w1, float w2);
|
float DeclColumns(float w_icon, float w_label, float w_shortcut, float w_mark);
|
||||||
float CalcExtraSpace(float avail_w) const;
|
void CalcNextTotalWidth(bool update_offsets);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Internal state of the currently focused/edited text input box
|
// Internal state of the currently focused/edited text input box
|
||||||
@ -1045,6 +1090,9 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); }
|
void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); }
|
||||||
bool HasSelection() const { return Stb.select_start != Stb.select_end; }
|
bool HasSelection() const { return Stb.select_start != Stb.select_end; }
|
||||||
void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
|
void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
|
||||||
|
int GetCursorPos() const { return Stb.cursor; }
|
||||||
|
int GetSelectionStart() const { return Stb.select_start; }
|
||||||
|
int GetSelectionEnd() const { return Stb.select_end; }
|
||||||
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1106,7 +1154,7 @@ struct ImGuiNextWindowData
|
|||||||
ImGuiSizeCallback SizeCallback;
|
ImGuiSizeCallback SizeCallback;
|
||||||
void* SizeCallbackUserData;
|
void* SizeCallbackUserData;
|
||||||
float BgAlphaVal; // Override background alpha
|
float BgAlphaVal; // Override background alpha
|
||||||
ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it.
|
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
|
||||||
|
|
||||||
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
||||||
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
|
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
|
||||||
@ -1131,6 +1179,25 @@ struct ImGuiNextItemData
|
|||||||
inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()!
|
inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Status storage for the last submitted item
|
||||||
|
struct ImGuiLastItemData
|
||||||
|
{
|
||||||
|
ImGuiID ID;
|
||||||
|
ImGuiItemFlags InFlags; // See ImGuiItemFlags_
|
||||||
|
ImGuiItemStatusFlags StatusFlags; // See ImGuiItemStatusFlags_
|
||||||
|
ImRect Rect;
|
||||||
|
ImRect DisplayRect;
|
||||||
|
|
||||||
|
ImGuiLastItemData() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Data saved for each window pushed into the stack
|
||||||
|
struct ImGuiWindowStackData
|
||||||
|
{
|
||||||
|
ImGuiWindow* Window;
|
||||||
|
ImGuiLastItemData ParentLastItemDataBackup;
|
||||||
|
};
|
||||||
|
|
||||||
struct ImGuiShrinkWidthItem
|
struct ImGuiShrinkWidthItem
|
||||||
{
|
{
|
||||||
int Index;
|
int Index;
|
||||||
@ -1373,7 +1440,7 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
||||||
ImVector<ImGuiWindow*> WindowsFocusOrder; // Root windows, sorted in focus order, back to front.
|
ImVector<ImGuiWindow*> WindowsFocusOrder; // Root windows, sorted in focus order, back to front.
|
||||||
ImVector<ImGuiWindow*> WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
|
ImVector<ImGuiWindow*> WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
|
||||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
ImVector<ImGuiWindowStackData> CurrentWindowStack;
|
||||||
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
||||||
int WindowsActiveCount; // Number of unique windows submitted by frame
|
int WindowsActiveCount; // Number of unique windows submitted by frame
|
||||||
ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING)
|
ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING)
|
||||||
@ -1386,7 +1453,6 @@ struct ImGuiContext
|
|||||||
float WheelingWindowTimer;
|
float WheelingWindowTimer;
|
||||||
|
|
||||||
// Item/widgets state and tracking information
|
// Item/widgets state and tracking information
|
||||||
ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back()
|
|
||||||
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
||||||
ImGuiID HoveredIdPreviousFrame;
|
ImGuiID HoveredIdPreviousFrame;
|
||||||
bool HoveredIdAllowOverlap;
|
bool HoveredIdAllowOverlap;
|
||||||
@ -1420,8 +1486,10 @@ struct ImGuiContext
|
|||||||
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
||||||
|
|
||||||
// Next window/item data
|
// Next window/item data
|
||||||
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back()
|
||||||
ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
|
ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
|
||||||
|
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
||||||
|
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
||||||
|
|
||||||
// Shared stacks
|
// Shared stacks
|
||||||
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
||||||
@ -1539,11 +1607,13 @@ struct ImGuiContext
|
|||||||
float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
|
float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
|
||||||
float ColorEditLastColor[3];
|
float ColorEditLastColor[3];
|
||||||
ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
|
ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
|
||||||
|
ImGuiComboPreviewData ComboPreviewData;
|
||||||
float SliderCurrentAccum; // Accumulated slider delta when using navigation controls.
|
float SliderCurrentAccum; // Accumulated slider delta when using navigation controls.
|
||||||
bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it?
|
bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it?
|
||||||
bool DragCurrentAccumDirty;
|
bool DragCurrentAccumDirty;
|
||||||
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
|
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
|
||||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||||
|
float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled()
|
||||||
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||||
int TooltipOverrideCount;
|
int TooltipOverrideCount;
|
||||||
float TooltipSlowDelay; // Time before slow tooltips appears (FIXME: This is temporary until we merge in tooltip timer+priority work)
|
float TooltipSlowDelay; // Time before slow tooltips appears (FIXME: This is temporary until we merge in tooltip timer+priority work)
|
||||||
@ -1617,7 +1687,6 @@ struct ImGuiContext
|
|||||||
WheelingWindow = NULL;
|
WheelingWindow = NULL;
|
||||||
WheelingWindowTimer = 0.0f;
|
WheelingWindowTimer = 0.0f;
|
||||||
|
|
||||||
CurrentItemFlags = ImGuiItemFlags_None;
|
|
||||||
HoveredId = HoveredIdPreviousFrame = 0;
|
HoveredId = HoveredIdPreviousFrame = 0;
|
||||||
HoveredIdAllowOverlap = false;
|
HoveredIdAllowOverlap = false;
|
||||||
HoveredIdUsingMouseWheel = HoveredIdPreviousFrameUsingMouseWheel = false;
|
HoveredIdUsingMouseWheel = HoveredIdPreviousFrameUsingMouseWheel = false;
|
||||||
@ -1647,6 +1716,8 @@ struct ImGuiContext
|
|||||||
LastActiveId = 0;
|
LastActiveId = 0;
|
||||||
LastActiveIdTimer = 0.0f;
|
LastActiveIdTimer = 0.0f;
|
||||||
|
|
||||||
|
CurrentItemFlags = ImGuiItemFlags_None;
|
||||||
|
|
||||||
NavWindow = NULL;
|
NavWindow = NULL;
|
||||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
|
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
|
||||||
NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
|
NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
|
||||||
@ -1702,7 +1773,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
LastValidMousePos = ImVec2(0.0f, 0.0f);
|
LastValidMousePos = ImVec2(0.0f, 0.0f);
|
||||||
TempInputId = 0;
|
TempInputId = 0;
|
||||||
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
|
||||||
ColorEditLastHue = ColorEditLastSat = 0.0f;
|
ColorEditLastHue = ColorEditLastSat = 0.0f;
|
||||||
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
|
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
|
||||||
SliderCurrentAccum = 0.0f;
|
SliderCurrentAccum = 0.0f;
|
||||||
@ -1710,6 +1781,7 @@ struct ImGuiContext
|
|||||||
DragCurrentAccumDirty = false;
|
DragCurrentAccumDirty = false;
|
||||||
DragCurrentAccum = 0.0f;
|
DragCurrentAccum = 0.0f;
|
||||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||||
|
DisabledAlphaBackup = 0.0f;
|
||||||
ScrollbarClickDeltaToGrabCenter = 0.0f;
|
ScrollbarClickDeltaToGrabCenter = 0.0f;
|
||||||
TooltipOverrideCount = 0;
|
TooltipOverrideCount = 0;
|
||||||
TooltipSlowDelay = 0.50f;
|
TooltipSlowDelay = 0.50f;
|
||||||
@ -1764,12 +1836,6 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
||||||
ImVec1 GroupOffset;
|
ImVec1 GroupOffset;
|
||||||
|
|
||||||
// Last item status
|
|
||||||
ImGuiID LastItemId; // ID for last item
|
|
||||||
ImGuiItemStatusFlags LastItemStatusFlags; // Status flags for last item (see ImGuiItemStatusFlags_)
|
|
||||||
ImRect LastItemRect; // Interaction rect for last item
|
|
||||||
ImRect LastItemDisplayRect; // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
|
|
||||||
|
|
||||||
// Keyboard/Gamepad navigation
|
// Keyboard/Gamepad navigation
|
||||||
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
||||||
short NavLayersActiveMask; // Which layers have been written to (result from previous frame)
|
short NavLayersActiveMask; // Which layers have been written to (result from previous frame)
|
||||||
@ -1916,19 +1982,6 @@ public:
|
|||||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
|
||||||
struct ImGuiLastItemDataBackup
|
|
||||||
{
|
|
||||||
ImGuiID LastItemId;
|
|
||||||
ImGuiItemStatusFlags LastItemStatusFlags;
|
|
||||||
ImRect LastItemRect;
|
|
||||||
ImRect LastItemDisplayRect;
|
|
||||||
|
|
||||||
ImGuiLastItemDataBackup() { Backup(); }
|
|
||||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
|
|
||||||
void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Tab bar, Tab item support
|
// [SECTION] Tab bar, Tab item support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1949,7 +2002,7 @@ enum ImGuiTabItemFlagsPrivate_
|
|||||||
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
|
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for one active tab item (sizeof() 28~32 bytes)
|
// Storage for one active tab item (sizeof() 40 bytes)
|
||||||
struct ImGuiTabItem
|
struct ImGuiTabItem
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
@ -1959,12 +2012,12 @@ struct ImGuiTabItem
|
|||||||
float Offset; // Position relative to beginning of tab
|
float Offset; // Position relative to beginning of tab
|
||||||
float Width; // Width currently displayed
|
float Width; // Width currently displayed
|
||||||
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
||||||
ImS16 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
||||||
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
||||||
ImS16 IndexDuringLayout; // Index only used during TabBarLayout()
|
ImS16 IndexDuringLayout; // Index only used during TabBarLayout()
|
||||||
bool WantClose; // Marked as closed by SetTabItemClosed()
|
bool WantClose; // Marked as closed by SetTabItemClosed()
|
||||||
|
|
||||||
ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = BeginOrder = IndexDuringLayout = -1; }
|
ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for a tab bar (sizeof() 152 bytes)
|
// Storage for a tab bar (sizeof() 152 bytes)
|
||||||
@ -2006,7 +2059,7 @@ struct ImGuiTabBar
|
|||||||
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
||||||
const char* GetTabName(const ImGuiTabItem* tab) const
|
const char* GetTabName(const ImGuiTabItem* tab) const
|
||||||
{
|
{
|
||||||
IM_ASSERT(tab->NameOffset != -1 && (int)tab->NameOffset < TabsNames.Buf.Size);
|
IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
|
||||||
return TabsNames.Buf.Data + tab->NameOffset;
|
return TabsNames.Buf.Data + tab->NameOffset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2053,10 +2106,11 @@ struct ImGuiTableColumn
|
|||||||
ImGuiTableColumnIdx NextEnabledColumn; // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column
|
ImGuiTableColumnIdx NextEnabledColumn; // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column
|
||||||
ImGuiTableColumnIdx SortOrder; // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort
|
ImGuiTableColumnIdx SortOrder; // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort
|
||||||
ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[]
|
ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[]
|
||||||
ImGuiTableDrawChannelIdx DrawChannelFrozen;
|
ImGuiTableDrawChannelIdx DrawChannelFrozen; // Draw channels for frozen rows (often headers)
|
||||||
ImGuiTableDrawChannelIdx DrawChannelUnfrozen;
|
ImGuiTableDrawChannelIdx DrawChannelUnfrozen; // Draw channels for unfrozen rows
|
||||||
bool IsEnabled; // Is the column not marked Hidden by the user? (even if off view, e.g. clipped by scrolling).
|
bool IsEnabled; // IsUserEnabled && (Flags & ImGuiTableColumnFlags_Disabled) == 0
|
||||||
bool IsEnabledNextFrame;
|
bool IsUserEnabled; // Is the column not marked Hidden by the user? (unrelated to being off view, e.g. clipped by scrolling).
|
||||||
|
bool IsUserEnabledNextFrame;
|
||||||
bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled).
|
bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled).
|
||||||
bool IsVisibleY;
|
bool IsVisibleY;
|
||||||
bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not.
|
bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not.
|
||||||
@ -2154,6 +2208,8 @@ struct ImGuiTable
|
|||||||
ImGuiWindow* InnerWindow; // Window holding the table data (== OuterWindow or a child window)
|
ImGuiWindow* InnerWindow; // Window holding the table data (== OuterWindow or a child window)
|
||||||
ImGuiTextBuffer ColumnsNames; // Contiguous buffer holding columns names
|
ImGuiTextBuffer ColumnsNames; // Contiguous buffer holding columns names
|
||||||
ImDrawListSplitter* DrawSplitter; // Shortcut to TempData->DrawSplitter while in table. Isolate draw commands per columns to avoid switching clip rect constantly
|
ImDrawListSplitter* DrawSplitter; // Shortcut to TempData->DrawSplitter while in table. Isolate draw commands per columns to avoid switching clip rect constantly
|
||||||
|
ImGuiTableColumnSortSpecs SortSpecsSingle;
|
||||||
|
ImVector<ImGuiTableColumnSortSpecs> SortSpecsMulti; // FIXME-OPT: Using a small-vector pattern would be good.
|
||||||
ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs()
|
ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs()
|
||||||
ImGuiTableColumnIdx SortSpecsCount;
|
ImGuiTableColumnIdx SortSpecsCount;
|
||||||
ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount)
|
ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount)
|
||||||
@ -2203,7 +2259,6 @@ struct ImGuiTable
|
|||||||
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
||||||
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
||||||
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
||||||
// FIXME-TABLE: more transient data could be stored here: DrawSplitter, incoming RowData?
|
|
||||||
struct ImGuiTableTempData
|
struct ImGuiTableTempData
|
||||||
{
|
{
|
||||||
int TableIndex; // Index in g.Tables.Buf[] pool
|
int TableIndex; // Index in g.Tables.Buf[] pool
|
||||||
@ -2211,8 +2266,6 @@ struct ImGuiTableTempData
|
|||||||
|
|
||||||
ImVec2 UserOuterSize; // outer_size.x passed to BeginTable()
|
ImVec2 UserOuterSize; // outer_size.x passed to BeginTable()
|
||||||
ImDrawListSplitter DrawSplitter;
|
ImDrawListSplitter DrawSplitter;
|
||||||
ImGuiTableColumnSortSpecs SortSpecsSingle;
|
|
||||||
ImVector<ImGuiTableColumnSortSpecs> SortSpecsMulti; // FIXME-OPT: Using a small-vector pattern would be good.
|
|
||||||
|
|
||||||
ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable()
|
ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable()
|
||||||
ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
|
ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
|
||||||
@ -2285,7 +2338,6 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
||||||
IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
|
IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
|
||||||
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
||||||
IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
|
|
||||||
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
||||||
@ -2338,11 +2390,11 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
|
IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
|
||||||
|
|
||||||
// Basic Accessors
|
// Basic Accessors
|
||||||
inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; } // Get ID of last item (~~ often same ImGui::GetID(label) beforehand)
|
inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.LastItemData.ID; } // Get ID of last item (~~ often same ImGui::GetID(label) beforehand)
|
||||||
inline ImGuiItemStatusFlags GetItemStatusFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemStatusFlags; }
|
inline ImGuiItemStatusFlags GetItemStatusFlags(){ ImGuiContext& g = *GImGui; return g.LastItemData.StatusFlags; }
|
||||||
|
inline ImGuiItemFlags GetItemFlags() { ImGuiContext& g = *GImGui; return g.LastItemData.InFlags; }
|
||||||
inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
|
inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
|
||||||
inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; }
|
inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; }
|
||||||
inline ImGuiItemFlags GetItemFlags() { ImGuiContext& g = *GImGui; return g.CurrentItemFlags; }
|
|
||||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||||
IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window);
|
IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window);
|
||||||
IMGUI_API void ClearActiveID();
|
IMGUI_API void ClearActiveID();
|
||||||
@ -2360,23 +2412,24 @@ namespace ImGui
|
|||||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||||
IMGUI_API void ItemFocusable(ImGuiWindow* window, ImGuiID id);
|
IMGUI_API void ItemFocusable(ImGuiWindow* window, ImGuiID id);
|
||||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||||
IMGUI_API void SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags status_flags, const ImRect& item_rect);
|
|
||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
||||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||||
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
|
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
|
||||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
|
||||||
IMGUI_API void PopItemFlag();
|
|
||||||
IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly)
|
IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly)
|
||||||
IMGUI_API ImVec2 GetContentRegionMaxAbs();
|
IMGUI_API ImVec2 GetContentRegionMaxAbs();
|
||||||
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
|
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
|
||||||
|
|
||||||
|
// Parameter stacks
|
||||||
|
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||||
|
IMGUI_API void PopItemFlag();
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
// If you have old/custom copy-and-pasted widgets that used FocusableItemRegister():
|
// If you have old/custom copy-and-pasted widgets that used FocusableItemRegister():
|
||||||
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool focused = FocusableItemRegister(...)'
|
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool focused = FocusableItemRegister(...)'
|
||||||
// (New) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0'
|
// (New) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0'
|
||||||
// Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText()
|
// Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText()
|
||||||
inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Focusable flag to ItemAdd()
|
inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Focusable flag to ItemAdd()
|
||||||
inline void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem
|
inline IM_NORETURN void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Logging/Capture
|
// Logging/Capture
|
||||||
@ -2393,11 +2446,20 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
||||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
||||||
|
IMGUI_API ImRect GetPopupAllowedExtentRect(ImGuiWindow* window);
|
||||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||||
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
||||||
|
|
||||||
|
// Menus
|
||||||
|
IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
|
||||||
|
|
||||||
|
// Combos
|
||||||
|
IMGUI_API bool BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags);
|
||||||
|
IMGUI_API bool BeginComboPreview();
|
||||||
|
IMGUI_API void EndComboPreview();
|
||||||
|
|
||||||
// Gamepad/Keyboard Navigation
|
// Gamepad/Keyboard Navigation
|
||||||
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
|
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
|
||||||
IMGUI_API bool NavMoveRequestButNoResultYet();
|
IMGUI_API bool NavMoveRequestButNoResultYet();
|
||||||
@ -2421,6 +2483,7 @@ namespace ImGui
|
|||||||
// Inputs
|
// Inputs
|
||||||
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
||||||
IMGUI_API void SetItemUsingMouseWheel();
|
IMGUI_API void SetItemUsingMouseWheel();
|
||||||
|
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
||||||
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
||||||
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
||||||
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
|
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
|
||||||
@ -2610,12 +2673,14 @@ namespace ImGui
|
|||||||
|
|
||||||
// Debug Tools
|
// Debug Tools
|
||||||
IMGUI_API void ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL);
|
IMGUI_API void ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL);
|
||||||
inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); }
|
inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col); }
|
||||||
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
|
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
|
||||||
|
|
||||||
|
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
||||||
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label);
|
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label);
|
||||||
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
||||||
|
IMGUI_API void DebugNodeFont(ImFont* font);
|
||||||
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
||||||
IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label);
|
IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label);
|
||||||
IMGUI_API void DebugNodeTable(ImGuiTable* table);
|
IMGUI_API void DebugNodeTable(ImGuiTable* table);
|
||||||
@ -2663,14 +2728,10 @@ extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt,
|
|||||||
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
|
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
|
||||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
|
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
|
||||||
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
|
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
|
||||||
#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA));
|
#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) if (g.TestEngineHookIdInfo == _ID) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA));
|
||||||
#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == id) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2));
|
#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) if (g.TestEngineHookIdInfo == _ID) ImGuiTestEngineHook_IdInfo(&g, _TYPE, _ID, (const void*)(_DATA), (const void*)(_DATA2));
|
||||||
#else
|
#else
|
||||||
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) do { } while (0)
|
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)0)
|
||||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) do { } while (0)
|
|
||||||
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) do { } while (0)
|
|
||||||
#define IMGUI_TEST_ENGINE_ID_INFO(_ID,_TYPE,_DATA) do { } while (0)
|
|
||||||
#define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) do { } while (0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.83
|
// dear imgui, v1.84
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -288,12 +288,7 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_w
|
|||||||
flags |= ImGuiTableFlags_NoSavedSettings;
|
flags |= ImGuiTableFlags_NoSavedSettings;
|
||||||
|
|
||||||
// Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set)
|
// Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set)
|
||||||
#ifdef IMGUI_HAS_DOCK
|
if (outer_window->RootWindow->Flags & ImGuiWindowFlags_NoSavedSettings)
|
||||||
ImGuiWindow* window_for_settings = outer_window->RootWindowDockStop;
|
|
||||||
#else
|
|
||||||
ImGuiWindow* window_for_settings = outer_window->RootWindow;
|
|
||||||
#endif
|
|
||||||
if (window_for_settings->Flags & ImGuiWindowFlags_NoSavedSettings)
|
|
||||||
flags |= ImGuiTableFlags_NoSavedSettings;
|
flags |= ImGuiTableFlags_NoSavedSettings;
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
@ -522,7 +517,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
*column = ImGuiTableColumn();
|
*column = ImGuiTableColumn();
|
||||||
column->WidthAuto = width_auto;
|
column->WidthAuto = width_auto;
|
||||||
column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker
|
column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker
|
||||||
column->IsEnabled = column->IsEnabledNextFrame = true;
|
column->IsEnabled = column->IsUserEnabled = column->IsUserEnabledNextFrame = true;
|
||||||
}
|
}
|
||||||
column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n;
|
column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n;
|
||||||
}
|
}
|
||||||
@ -756,16 +751,18 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
column->InitStretchWeightOrWidth = -1.0f;
|
column->InitStretchWeightOrWidth = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Enabled state, mark settings/sortspecs dirty
|
// Update Enabled state, mark settings and sort specs dirty
|
||||||
if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
|
if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
|
||||||
column->IsEnabledNextFrame = true;
|
column->IsUserEnabledNextFrame = true;
|
||||||
if (column->IsEnabled != column->IsEnabledNextFrame)
|
if (column->IsUserEnabled != column->IsUserEnabledNextFrame)
|
||||||
{
|
{
|
||||||
column->IsEnabled = column->IsEnabledNextFrame;
|
column->IsUserEnabled = column->IsUserEnabledNextFrame;
|
||||||
table->IsSettingsDirty = true;
|
table->IsSettingsDirty = true;
|
||||||
if (!column->IsEnabled && column->SortOrder != -1)
|
|
||||||
table->IsSortSpecsDirty = true;
|
|
||||||
}
|
}
|
||||||
|
column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
|
||||||
|
|
||||||
|
if (column->SortOrder != -1 && !column->IsEnabled)
|
||||||
|
table->IsSortSpecsDirty = true;
|
||||||
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
||||||
table->IsSortSpecsDirty = true;
|
table->IsSortSpecsDirty = true;
|
||||||
|
|
||||||
@ -1164,9 +1161,8 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
|
|||||||
if ((table->Flags & ImGuiTableFlags_NoBordersInBody) && table->IsUsingHeaders == false)
|
if ((table->Flags & ImGuiTableFlags_NoBordersInBody) && table->IsUsingHeaders == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (table->FreezeColumnsCount > 0)
|
if (!column->IsVisibleX && table->LastResizedColumn != column_n)
|
||||||
if (column->MaxX < table->Columns[table->DisplayOrderToIndex[table->FreezeColumnsCount - 1]].MaxX)
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
ImGuiID column_id = TableGetColumnResizeID(table, column_n, table->InstanceCurrent);
|
ImGuiID column_id = TableGetColumnResizeID(table, column_n, table->InstanceCurrent);
|
||||||
ImRect hit_rect(column->MaxX - hit_half_width, hit_y1, column->MaxX + hit_half_width, border_y2_hit);
|
ImRect hit_rect(column->MaxX - hit_half_width, hit_y1, column->MaxX + hit_half_width, border_y2_hit);
|
||||||
@ -1449,7 +1445,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
|||||||
|
|
||||||
// Init default visibility/sort state
|
// Init default visibility/sort state
|
||||||
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
||||||
column->IsEnabled = column->IsEnabledNextFrame = false;
|
column->IsUserEnabled = column->IsUserEnabledNextFrame = false;
|
||||||
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
||||||
{
|
{
|
||||||
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
|
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
|
||||||
@ -1476,11 +1472,22 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
|
|||||||
IM_ASSERT(columns >= 0 && columns < IMGUI_TABLE_MAX_COLUMNS);
|
IM_ASSERT(columns >= 0 && columns < IMGUI_TABLE_MAX_COLUMNS);
|
||||||
IM_ASSERT(rows >= 0 && rows < 128); // Arbitrary limit
|
IM_ASSERT(rows >= 0 && rows < 128); // Arbitrary limit
|
||||||
|
|
||||||
table->FreezeColumnsRequest = (table->Flags & ImGuiTableFlags_ScrollX) ? (ImGuiTableColumnIdx)columns : 0;
|
table->FreezeColumnsRequest = (table->Flags & ImGuiTableFlags_ScrollX) ? (ImGuiTableColumnIdx)ImMin(columns, table->ColumnsCount) : 0;
|
||||||
table->FreezeColumnsCount = (table->InnerWindow->Scroll.x != 0.0f) ? table->FreezeColumnsRequest : 0;
|
table->FreezeColumnsCount = (table->InnerWindow->Scroll.x != 0.0f) ? table->FreezeColumnsRequest : 0;
|
||||||
table->FreezeRowsRequest = (table->Flags & ImGuiTableFlags_ScrollY) ? (ImGuiTableColumnIdx)rows : 0;
|
table->FreezeRowsRequest = (table->Flags & ImGuiTableFlags_ScrollY) ? (ImGuiTableColumnIdx)rows : 0;
|
||||||
table->FreezeRowsCount = (table->InnerWindow->Scroll.y != 0.0f) ? table->FreezeRowsRequest : 0;
|
table->FreezeRowsCount = (table->InnerWindow->Scroll.y != 0.0f) ? table->FreezeRowsRequest : 0;
|
||||||
table->IsUnfrozenRows = (table->FreezeRowsCount == 0); // Make sure this is set before TableUpdateLayout() so ImGuiListClipper can benefit from it.b
|
table->IsUnfrozenRows = (table->FreezeRowsCount == 0); // Make sure this is set before TableUpdateLayout() so ImGuiListClipper can benefit from it.b
|
||||||
|
|
||||||
|
// Ensure frozen columns are ordered in their section. We still allow multiple frozen columns to be reordered.
|
||||||
|
for (int column_n = 0; column_n < table->FreezeColumnsRequest; column_n++)
|
||||||
|
{
|
||||||
|
int order_n = table->DisplayOrderToIndex[column_n];
|
||||||
|
if (order_n != column_n && order_n >= table->FreezeColumnsRequest)
|
||||||
|
{
|
||||||
|
ImSwap(table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder, table->Columns[table->DisplayOrderToIndex[column_n]].DisplayOrder);
|
||||||
|
ImSwap(table->DisplayOrderToIndex[order_n], table->DisplayOrderToIndex[column_n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1489,7 +1496,7 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
|
|||||||
// - TableGetColumnCount()
|
// - TableGetColumnCount()
|
||||||
// - TableGetColumnName()
|
// - TableGetColumnName()
|
||||||
// - TableGetColumnName() [Internal]
|
// - TableGetColumnName() [Internal]
|
||||||
// - TableSetColumnEnabled() [Internal]
|
// - TableSetColumnEnabled()
|
||||||
// - TableGetColumnFlags()
|
// - TableGetColumnFlags()
|
||||||
// - TableGetCellBgRect() [Internal]
|
// - TableGetCellBgRect() [Internal]
|
||||||
// - TableGetColumnResizeID() [Internal]
|
// - TableGetColumnResizeID() [Internal]
|
||||||
@ -1525,10 +1532,12 @@ const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n)
|
|||||||
return &table->ColumnsNames.Buf[column->NameOffset];
|
return &table->ColumnsNames.Buf[column->NameOffset];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request enabling/disabling a column (often perceived as "showing/hiding" from users point of view)
|
// Change user accessible enabled/disabled state of a column (often perceived as "showing/hiding" from users point of view)
|
||||||
// Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
// Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||||
// Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable()
|
// - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state.
|
||||||
// For the getter you can use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled)
|
// - Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable().
|
||||||
|
// - For the getter you can test (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) != 0.
|
||||||
|
// - Alternative: the ImGuiTableColumnFlags_Disabled is an overriding/master disable flag which will also hide the column from context menu.
|
||||||
void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -1536,11 +1545,12 @@ void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
|||||||
IM_ASSERT(table != NULL);
|
IM_ASSERT(table != NULL);
|
||||||
if (!table)
|
if (!table)
|
||||||
return;
|
return;
|
||||||
|
IM_ASSERT(table->Flags & ImGuiTableFlags_Hideable); // See comments above
|
||||||
if (column_n < 0)
|
if (column_n < 0)
|
||||||
column_n = table->CurrentColumn;
|
column_n = table->CurrentColumn;
|
||||||
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);
|
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);
|
||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
column->IsEnabledNextFrame = enabled;
|
column->IsUserEnabledNextFrame = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
|
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
|
||||||
@ -1946,8 +1956,9 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
|||||||
window->SkipItems = column->IsSkipItems;
|
window->SkipItems = column->IsSkipItems;
|
||||||
if (column->IsSkipItems)
|
if (column->IsSkipItems)
|
||||||
{
|
{
|
||||||
window->DC.LastItemId = 0;
|
ImGuiContext& g = *GImGui;
|
||||||
window->DC.LastItemStatusFlags = 0;
|
g.LastItemData.ID = 0;
|
||||||
|
g.LastItemData.StatusFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table->Flags & ImGuiTableFlags_NoClip)
|
if (table->Flags & ImGuiTableFlags_NoClip)
|
||||||
@ -2013,6 +2024,7 @@ float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
|
|||||||
if (table->Flags & ImGuiTableFlags_ScrollX)
|
if (table->Flags & ImGuiTableFlags_ScrollX)
|
||||||
{
|
{
|
||||||
// Frozen columns can't reach beyond visible width else scrolling will naturally break.
|
// Frozen columns can't reach beyond visible width else scrolling will naturally break.
|
||||||
|
// (we use DisplayOrder as within a set of multiple frozen column reordering is possible)
|
||||||
if (column->DisplayOrder < table->FreezeColumnsRequest)
|
if (column->DisplayOrder < table->FreezeColumnsRequest)
|
||||||
{
|
{
|
||||||
max_width = (table->InnerClipRect.Max.x - (table->FreezeColumnsRequest - column->DisplayOrder) * min_column_distance) - column->MinX;
|
max_width = (table->InnerClipRect.Max.x - (table->FreezeColumnsRequest - column->DisplayOrder) * min_column_distance) - column->MinX;
|
||||||
@ -2501,7 +2513,7 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
|
|||||||
const bool is_hovered = (table->HoveredColumnBorder == column_n);
|
const bool is_hovered = (table->HoveredColumnBorder == column_n);
|
||||||
const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent);
|
const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent);
|
||||||
const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0;
|
const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0;
|
||||||
const bool is_frozen_separator = (table->FreezeColumnsCount != -1 && table->FreezeColumnsCount == order_n + 1);
|
const bool is_frozen_separator = (table->FreezeColumnsCount == order_n + 1);
|
||||||
if (column->MaxX > table->InnerClipRect.Max.x && !is_resized)
|
if (column->MaxX > table->InnerClipRect.Max.x && !is_resized)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2597,8 +2609,7 @@ ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
|
|||||||
if (!table->IsLayoutLocked)
|
if (!table->IsLayoutLocked)
|
||||||
TableUpdateLayout(table);
|
TableUpdateLayout(table);
|
||||||
|
|
||||||
if (table->IsSortSpecsDirty)
|
TableSortSpecsBuild(table);
|
||||||
TableSortSpecsBuild(table);
|
|
||||||
|
|
||||||
return &table->SortSpecs;
|
return &table->SortSpecs;
|
||||||
}
|
}
|
||||||
@ -2737,14 +2748,18 @@ void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
|
|||||||
|
|
||||||
void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
||||||
{
|
{
|
||||||
IM_ASSERT(table->IsSortSpecsDirty);
|
bool dirty = table->IsSortSpecsDirty;
|
||||||
TableSortSpecsSanitize(table);
|
if (dirty)
|
||||||
|
{
|
||||||
|
TableSortSpecsSanitize(table);
|
||||||
|
table->SortSpecsMulti.resize(table->SortSpecsCount <= 1 ? 0 : table->SortSpecsCount);
|
||||||
|
table->SortSpecs.SpecsDirty = true; // Mark as dirty for user
|
||||||
|
table->IsSortSpecsDirty = false; // Mark as not dirty for us
|
||||||
|
}
|
||||||
|
|
||||||
// Write output
|
// Write output
|
||||||
ImGuiTableTempData* temp_data = table->TempData;
|
ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data;
|
||||||
temp_data->SortSpecsMulti.resize(table->SortSpecsCount <= 1 ? 0 : table->SortSpecsCount);
|
if (dirty && sort_specs != NULL)
|
||||||
ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &temp_data->SortSpecsSingle : temp_data->SortSpecsMulti.Data;
|
|
||||||
if (sort_specs != NULL)
|
|
||||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
{
|
{
|
||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
@ -2757,10 +2772,9 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
|||||||
sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder;
|
sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder;
|
||||||
sort_spec->SortDirection = column->SortDirection;
|
sort_spec->SortDirection = column->SortDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
table->SortSpecs.Specs = sort_specs;
|
table->SortSpecs.Specs = sort_specs;
|
||||||
table->SortSpecs.SpecsCount = table->SortSpecsCount;
|
table->SortSpecs.SpecsCount = table->SortSpecsCount;
|
||||||
table->SortSpecs.SpecsDirty = true; // Mark as dirty for user
|
|
||||||
table->IsSortSpecsDirty = false; // Mark as not dirty for us
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -2780,8 +2794,11 @@ float ImGui::TableGetHeaderRowHeight()
|
|||||||
float row_height = GetTextLineHeight();
|
float row_height = GetTextLineHeight();
|
||||||
int columns_count = TableGetColumnCount();
|
int columns_count = TableGetColumnCount();
|
||||||
for (int column_n = 0; column_n < columns_count; column_n++)
|
for (int column_n = 0; column_n < columns_count; column_n++)
|
||||||
if (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_IsEnabled)
|
{
|
||||||
|
ImGuiTableColumnFlags flags = TableGetColumnFlags(column_n);
|
||||||
|
if ((flags & ImGuiTableColumnFlags_IsEnabled) && !(flags & ImGuiTableColumnFlags_NoHeaderLabel))
|
||||||
row_height = ImMax(row_height, CalcTextSize(TableGetColumnName(column_n)).y);
|
row_height = ImMax(row_height, CalcTextSize(TableGetColumnName(column_n)).y);
|
||||||
|
}
|
||||||
row_height += GetStyle().CellPadding.y * 2.0f;
|
row_height += GetStyle().CellPadding.y * 2.0f;
|
||||||
return row_height;
|
return row_height;
|
||||||
}
|
}
|
||||||
@ -2818,7 +2835,7 @@ void ImGui::TableHeadersRow()
|
|||||||
// Push an id to allow unnamed labels (generally accidental, but let's behave nicely with them)
|
// Push an id to allow unnamed labels (generally accidental, but let's behave nicely with them)
|
||||||
// - in your own code you may omit the PushID/PopID all-together, provided you know they won't collide
|
// - in your own code you may omit the PushID/PopID all-together, provided you know they won't collide
|
||||||
// - table->InstanceCurrent is only >0 when we use multiple BeginTable/EndTable calls with same identifier.
|
// - table->InstanceCurrent is only >0 when we use multiple BeginTable/EndTable calls with same identifier.
|
||||||
const char* name = TableGetColumnName(column_n);
|
const char* name = (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_NoHeaderLabel) ? "" : TableGetColumnName(column_n);
|
||||||
PushID(table->InstanceCurrent * table->ColumnsCount + column_n);
|
PushID(table->InstanceCurrent * table->ColumnsCount + column_n);
|
||||||
TableHeader(name);
|
TableHeader(name);
|
||||||
PopID();
|
PopID();
|
||||||
@ -2900,7 +2917,6 @@ void ImGui::TableHeader(const char* label)
|
|||||||
const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
||||||
//RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
//RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
||||||
TableSetBgColor(ImGuiTableBgTarget_CellBg, col, table->CurrentColumn);
|
TableSetBgColor(ImGuiTableBgTarget_CellBg, col, table->CurrentColumn);
|
||||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2908,6 +2924,7 @@ void ImGui::TableHeader(const char* label)
|
|||||||
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
||||||
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
||||||
}
|
}
|
||||||
|
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
||||||
if (held)
|
if (held)
|
||||||
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
||||||
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
||||||
@ -3073,16 +3090,19 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|||||||
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
||||||
{
|
{
|
||||||
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
||||||
|
if (other_column->Flags & ImGuiTableColumnFlags_Disabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
const char* name = TableGetColumnName(table, other_column_n);
|
const char* name = TableGetColumnName(table, other_column_n);
|
||||||
if (name == NULL || name[0] == 0)
|
if (name == NULL || name[0] == 0)
|
||||||
name = "<Unknown>";
|
name = "<Unknown>";
|
||||||
|
|
||||||
// Make sure we can't hide the last active column
|
// Make sure we can't hide the last active column
|
||||||
bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
|
bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
|
||||||
if (other_column->IsEnabled && table->ColumnsEnabledCount <= 1)
|
if (other_column->IsUserEnabled && table->ColumnsEnabledCount <= 1)
|
||||||
menu_item_active = false;
|
menu_item_active = false;
|
||||||
if (MenuItem(name, NULL, other_column->IsEnabled, menu_item_active))
|
if (MenuItem(name, NULL, other_column->IsUserEnabled, menu_item_active))
|
||||||
other_column->IsEnabledNextFrame = !other_column->IsEnabled;
|
other_column->IsUserEnabledNextFrame = !other_column->IsUserEnabled;
|
||||||
}
|
}
|
||||||
PopItemFlag();
|
PopItemFlag();
|
||||||
}
|
}
|
||||||
@ -3207,7 +3227,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
|||||||
column_settings->DisplayOrder = column->DisplayOrder;
|
column_settings->DisplayOrder = column->DisplayOrder;
|
||||||
column_settings->SortOrder = column->SortOrder;
|
column_settings->SortOrder = column->SortOrder;
|
||||||
column_settings->SortDirection = column->SortDirection;
|
column_settings->SortDirection = column->SortDirection;
|
||||||
column_settings->IsEnabled = column->IsEnabled;
|
column_settings->IsEnabled = column->IsUserEnabled;
|
||||||
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
||||||
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
||||||
save_ref_scale = true;
|
save_ref_scale = true;
|
||||||
@ -3221,7 +3241,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
|||||||
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
||||||
if (column->SortOrder != -1)
|
if (column->SortOrder != -1)
|
||||||
settings->SaveFlags |= ImGuiTableFlags_Sortable;
|
settings->SaveFlags |= ImGuiTableFlags_Sortable;
|
||||||
if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
if (column->IsUserEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
||||||
settings->SaveFlags |= ImGuiTableFlags_Hideable;
|
settings->SaveFlags |= ImGuiTableFlags_Hideable;
|
||||||
}
|
}
|
||||||
settings->SaveFlags &= table->Flags;
|
settings->SaveFlags &= table->Flags;
|
||||||
@ -3279,7 +3299,7 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
|||||||
else
|
else
|
||||||
column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
|
column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
|
||||||
display_order_mask |= (ImU64)1 << column->DisplayOrder;
|
display_order_mask |= (ImU64)1 << column->DisplayOrder;
|
||||||
column->IsEnabled = column->IsEnabledNextFrame = column_settings->IsEnabled;
|
column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled;
|
||||||
column->SortOrder = column_settings->SortOrder;
|
column->SortOrder = column_settings->SortOrder;
|
||||||
column->SortDirection = column_settings->SortDirection;
|
column->SortDirection = column_settings->SortDirection;
|
||||||
}
|
}
|
||||||
@ -3298,8 +3318,9 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
|||||||
static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
for (int i = 0; i != g.Tables.GetSize(); i++)
|
for (int i = 0; i != g.Tables.GetMapSize(); i++)
|
||||||
g.Tables.GetByIndex(i)->SettingsOffset = -1;
|
if (ImGuiTable* table = g.Tables.TryGetMapData(i))
|
||||||
|
table->SettingsOffset = -1;
|
||||||
g.SettingsTables.clear();
|
g.SettingsTables.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3307,12 +3328,12 @@ static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandle
|
|||||||
static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
for (int i = 0; i != g.Tables.GetSize(); i++)
|
for (int i = 0; i != g.Tables.GetMapSize(); i++)
|
||||||
{
|
if (ImGuiTable* table = g.Tables.TryGetMapData(i))
|
||||||
ImGuiTable* table = g.Tables.GetByIndex(i);
|
{
|
||||||
table->IsSettingsRequestLoad = true;
|
table->IsSettingsRequestLoad = true;
|
||||||
table->SettingsOffset = -1;
|
table->SettingsOffset = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||||
@ -3442,7 +3463,8 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(table->MemoryCompacted == false);
|
IM_ASSERT(table->MemoryCompacted == false);
|
||||||
table->SortSpecs.Specs = NULL;
|
table->SortSpecs.Specs = NULL;
|
||||||
table->IsSortSpecsDirty = true;
|
table->SortSpecsMulti.clear();
|
||||||
|
table->IsSortSpecsDirty = true; // FIXME: shouldn't have to leak into user performing a sort
|
||||||
table->ColumnsNames.clear();
|
table->ColumnsNames.clear();
|
||||||
table->MemoryCompacted = true;
|
table->MemoryCompacted = true;
|
||||||
for (int n = 0; n < table->ColumnsCount; n++)
|
for (int n = 0; n < table->ColumnsCount; n++)
|
||||||
@ -3453,7 +3475,6 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
|
|||||||
void ImGui::TableGcCompactTransientBuffers(ImGuiTableTempData* temp_data)
|
void ImGui::TableGcCompactTransientBuffers(ImGuiTableTempData* temp_data)
|
||||||
{
|
{
|
||||||
temp_data->DrawSplitter.ClearFreeMemory();
|
temp_data->DrawSplitter.ClearFreeMemory();
|
||||||
temp_data->SortSpecsMulti.clear();
|
|
||||||
temp_data->LastTimeActive = -1.0f;
|
temp_data->LastTimeActive = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@
|
|||||||
// Minor features
|
// Minor features
|
||||||
// Martins Mozeiko
|
// Martins Mozeiko
|
||||||
// github:IntellectualKitty
|
// github:IntellectualKitty
|
||||||
//
|
//
|
||||||
// Bugfixes / warning fixes
|
// Bugfixes / warning fixes
|
||||||
// Jeremy Jaussaud
|
// Jeremy Jaussaud
|
||||||
// Fabian Giesen
|
// Fabian Giesen
|
||||||
@ -441,7 +441,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tail = tail->next;
|
tail = tail->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fr.prev_link = best;
|
fr.prev_link = best;
|
||||||
@ -602,38 +602,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE A - MIT License
|
ALTERNATIVE A - MIT License
|
||||||
Copyright (c) 2017 Sean Barrett
|
Copyright (c) 2017 Sean Barrett
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
the Software without restriction, including without limitation the rights to
|
the Software without restriction, including without limitation the rights to
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
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
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
so, subject to the following conditions:
|
so, subject to the following conditions:
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
This is free and unencumbered software released into the public domain.
|
This is free and unencumbered software released into the public domain.
|
||||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
software, either in source code form or as a compiled binary, for any purpose,
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
commercial or non-commercial, and by any means.
|
commercial or non-commercial, and by any means.
|
||||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
software dedicate any and all copyright interest in the software to the public
|
software dedicate any and all copyright interest in the software to the public
|
||||||
domain. We make this dedication for the benefit of the public at large and to
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
the detriment of our heirs and successors. We intend this dedication to be an
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
overt act of relinquishment in perpetuity of all present and future rights to
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
this software under copyright law.
|
this software under copyright law.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
AUTHORS 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
|
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.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// [DEAR IMGUI]
|
// [DEAR IMGUI]
|
||||||
// This is a slightly modified version of stb_textedit.h 1.13.
|
// This is a slightly modified version of stb_textedit.h 1.13.
|
||||||
// Those changes would need to be pushed into nothings/stb:
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||||
// Grep for [DEAR IMGUI] to find the changes.
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
@ -19,7 +19,7 @@
|
|||||||
// texts, as its performance does not scale and it has limited undo).
|
// texts, as its performance does not scale and it has limited undo).
|
||||||
//
|
//
|
||||||
// Non-trivial behaviors are modelled after Windows text controls.
|
// Non-trivial behaviors are modelled after Windows text controls.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
@ -217,20 +217,20 @@
|
|||||||
// call this with the mouse x,y on a mouse down; it will update the cursor
|
// call this with the mouse x,y on a mouse down; it will update the cursor
|
||||||
// and reset the selection start/end to the cursor point. the x,y must
|
// and reset the selection start/end to the cursor point. the x,y must
|
||||||
// be relative to the text widget, with (0,0) being the top left.
|
// be relative to the text widget, with (0,0) being the top left.
|
||||||
//
|
//
|
||||||
// drag:
|
// drag:
|
||||||
// call this with the mouse x,y on a mouse drag/up; it will update the
|
// call this with the mouse x,y on a mouse drag/up; it will update the
|
||||||
// cursor and the selection end point
|
// cursor and the selection end point
|
||||||
//
|
//
|
||||||
// cut:
|
// cut:
|
||||||
// call this to delete the current selection; returns true if there was
|
// call this to delete the current selection; returns true if there was
|
||||||
// one. you should FIRST copy the current selection to the system paste buffer.
|
// one. you should FIRST copy the current selection to the system paste buffer.
|
||||||
// (To copy, just copy the current selection out of the string yourself.)
|
// (To copy, just copy the current selection out of the string yourself.)
|
||||||
//
|
//
|
||||||
// paste:
|
// paste:
|
||||||
// call this to paste text at the current cursor point or over the current
|
// call this to paste text at the current cursor point or over the current
|
||||||
// selection if there is one.
|
// selection if there is one.
|
||||||
//
|
//
|
||||||
// key:
|
// key:
|
||||||
// call this for keyboard inputs sent to the textfield. you can use it
|
// call this for keyboard inputs sent to the textfield. you can use it
|
||||||
// for "key down" events or for "translated" key events. if you need to
|
// for "key down" events or for "translated" key events. if you need to
|
||||||
@ -241,7 +241,7 @@
|
|||||||
// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to
|
// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to
|
||||||
// anything other type you wante before including.
|
// anything other type you wante before including.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// When rendering, you can read the cursor position and selection state from
|
// When rendering, you can read the cursor position and selection state from
|
||||||
// the STB_TexteditState.
|
// the STB_TexteditState.
|
||||||
//
|
//
|
||||||
@ -716,9 +716,11 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta
|
|||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// remove the undo since we didn't actually insert the characters
|
// [DEAR IMGUI]
|
||||||
if (state->undostate.undo_point)
|
//// remove the undo since we didn't actually insert the characters
|
||||||
--state->undostate.undo_point;
|
//if (state->undostate.undo_point)
|
||||||
|
// --state->undostate.undo_point;
|
||||||
|
// note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +766,7 @@ retry:
|
|||||||
state->insert_mode = !state->insert_mode;
|
state->insert_mode = !state->insert_mode;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case STB_TEXTEDIT_K_UNDO:
|
case STB_TEXTEDIT_K_UNDO:
|
||||||
stb_text_undo(str, state);
|
stb_text_undo(str, state);
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
@ -779,7 +781,7 @@ retry:
|
|||||||
// if currently there's a selection, move cursor to start of selection
|
// if currently there's a selection, move cursor to start of selection
|
||||||
if (STB_TEXT_HAS_SELECTION(state))
|
if (STB_TEXT_HAS_SELECTION(state))
|
||||||
stb_textedit_move_to_first(state);
|
stb_textedit_move_to_first(state);
|
||||||
else
|
else
|
||||||
if (state->cursor > 0)
|
if (state->cursor > 0)
|
||||||
--state->cursor;
|
--state->cursor;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
@ -828,7 +830,7 @@ retry:
|
|||||||
|
|
||||||
#ifdef STB_TEXTEDIT_MOVEWORDRIGHT
|
#ifdef STB_TEXTEDIT_MOVEWORDRIGHT
|
||||||
case STB_TEXTEDIT_K_WORDRIGHT:
|
case STB_TEXTEDIT_K_WORDRIGHT:
|
||||||
if (STB_TEXT_HAS_SELECTION(state))
|
if (STB_TEXT_HAS_SELECTION(state))
|
||||||
stb_textedit_move_to_last(str, state);
|
stb_textedit_move_to_last(str, state);
|
||||||
else {
|
else {
|
||||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
|
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
|
||||||
@ -922,7 +924,7 @@ retry:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STB_TEXTEDIT_K_UP:
|
case STB_TEXTEDIT_K_UP:
|
||||||
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT:
|
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT:
|
||||||
case STB_TEXTEDIT_K_PGUP:
|
case STB_TEXTEDIT_K_PGUP:
|
||||||
@ -1014,7 +1016,7 @@ retry:
|
|||||||
}
|
}
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
||||||
case STB_TEXTEDIT_K_TEXTSTART2:
|
case STB_TEXTEDIT_K_TEXTSTART2:
|
||||||
#endif
|
#endif
|
||||||
@ -1031,7 +1033,7 @@ retry:
|
|||||||
state->select_start = state->select_end = 0;
|
state->select_start = state->select_end = 0;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
||||||
case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
|
case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
|
||||||
#endif
|
#endif
|
||||||
@ -1410,38 +1412,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE A - MIT License
|
ALTERNATIVE A - MIT License
|
||||||
Copyright (c) 2017 Sean Barrett
|
Copyright (c) 2017 Sean Barrett
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
the Software without restriction, including without limitation the rights to
|
the Software without restriction, including without limitation the rights to
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
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
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
so, subject to the following conditions:
|
so, subject to the following conditions:
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
This is free and unencumbered software released into the public domain.
|
This is free and unencumbered software released into the public domain.
|
||||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
software, either in source code form or as a compiled binary, for any purpose,
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
commercial or non-commercial, and by any means.
|
commercial or non-commercial, and by any means.
|
||||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
software dedicate any and all copyright interest in the software to the public
|
software dedicate any and all copyright interest in the software to the public
|
||||||
domain. We make this dedication for the benefit of the public at large and to
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
the detriment of our heirs and successors. We intend this dedication to be an
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
overt act of relinquishment in perpetuity of all present and future rights to
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
this software under copyright law.
|
this software under copyright law.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
AUTHORS 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
|
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.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
// Rob Loach Cort Stratton
|
// Rob Loach Cort Stratton
|
||||||
// Kenney Phillis Jr. github:oyvindjam
|
// Kenney Phillis Jr. github:oyvindjam
|
||||||
// Brian Costabile github:vassvik
|
// Brian Costabile github:vassvik
|
||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
|
// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
|
||||||
@ -212,7 +212,7 @@
|
|||||||
//
|
//
|
||||||
// Advancing for the next character:
|
// Advancing for the next character:
|
||||||
// Call GlyphHMetrics, and compute 'current_point += SF * advance'.
|
// Call GlyphHMetrics, and compute 'current_point += SF * advance'.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// ADVANCED USAGE
|
// ADVANCED USAGE
|
||||||
//
|
//
|
||||||
@ -257,7 +257,7 @@
|
|||||||
// Curve tessellation 120 LOC \__ 550 LOC Bitmap creation
|
// Curve tessellation 120 LOC \__ 550 LOC Bitmap creation
|
||||||
// Bitmap management 100 LOC /
|
// Bitmap management 100 LOC /
|
||||||
// Baked bitmap interface 70 LOC /
|
// Baked bitmap interface 70 LOC /
|
||||||
// Font name matching & access 150 LOC ---- 150
|
// Font name matching & access 150 LOC ---- 150
|
||||||
// C runtime library abstraction 60 LOC ---- 60
|
// C runtime library abstraction 60 LOC ---- 60
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -350,7 +350,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
@ -364,9 +364,9 @@ int main(int argc, char **argv)
|
|||||||
// :@@. M@M
|
// :@@. M@M
|
||||||
// @@@o@@@@
|
// @@@o@@@@
|
||||||
// :M@@V:@@.
|
// :M@@V:@@.
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Complete program: print "Hello World!" banner, with bugs
|
// Complete program: print "Hello World!" banner, with bugs
|
||||||
//
|
//
|
||||||
#if 0
|
#if 0
|
||||||
@ -667,7 +667,7 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, cons
|
|||||||
// Calling these functions in sequence is roughly equivalent to calling
|
// Calling these functions in sequence is roughly equivalent to calling
|
||||||
// stbtt_PackFontRanges(). If you more control over the packing of multiple
|
// stbtt_PackFontRanges(). If you more control over the packing of multiple
|
||||||
// fonts, or if you want to pack custom data into a font texture, take a look
|
// fonts, or if you want to pack custom data into a font texture, take a look
|
||||||
// at the source to of stbtt_PackFontRanges() and create a custom version
|
// at the source to of stbtt_PackFontRanges() and create a custom version
|
||||||
// using these functions, e.g. call GatherRects multiple times,
|
// using these functions, e.g. call GatherRects multiple times,
|
||||||
// building up a single array of rects, then call PackRects once,
|
// building up a single array of rects, then call PackRects once,
|
||||||
// then call RenderIntoRects repeatedly. This may result in a
|
// then call RenderIntoRects repeatedly. This may result in a
|
||||||
@ -975,7 +975,7 @@ STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, floa
|
|||||||
// and computing from that can allow drop-out prevention).
|
// and computing from that can allow drop-out prevention).
|
||||||
//
|
//
|
||||||
// The algorithm has not been optimized at all, so expect it to be slow
|
// The algorithm has not been optimized at all, so expect it to be slow
|
||||||
// if computing lots of characters or very large sizes.
|
// if computing lots of characters or very large sizes.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1732,7 +1732,7 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
|
|||||||
if (i != 0)
|
if (i != 0)
|
||||||
num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
|
num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
|
||||||
|
|
||||||
// now start the new one
|
// now start the new one
|
||||||
start_off = !(flags & 1);
|
start_off = !(flags & 1);
|
||||||
if (start_off) {
|
if (start_off) {
|
||||||
// if we start off with an off-curve point, then when we need to find a point on the curve
|
// if we start off with an off-curve point, then when we need to find a point on the curve
|
||||||
@ -1785,7 +1785,7 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
|
|||||||
int comp_num_verts = 0, i;
|
int comp_num_verts = 0, i;
|
||||||
stbtt_vertex *comp_verts = 0, *tmp = 0;
|
stbtt_vertex *comp_verts = 0, *tmp = 0;
|
||||||
float mtx[6] = {1,0,0,1,0,0}, m, n;
|
float mtx[6] = {1,0,0,1,0,0}, m, n;
|
||||||
|
|
||||||
flags = ttSHORT(comp); comp+=2;
|
flags = ttSHORT(comp); comp+=2;
|
||||||
gidx = ttSHORT(comp); comp+=2;
|
gidx = ttSHORT(comp); comp+=2;
|
||||||
|
|
||||||
@ -1815,7 +1815,7 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
|
|||||||
mtx[2] = ttSHORT(comp)/16384.0f; comp+=2;
|
mtx[2] = ttSHORT(comp)/16384.0f; comp+=2;
|
||||||
mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
|
mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find transformation scales.
|
// Find transformation scales.
|
||||||
m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
|
m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
|
||||||
n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
|
n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
|
||||||
@ -2746,7 +2746,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i
|
|||||||
float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
|
float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
|
||||||
STBTT_assert(z != NULL);
|
STBTT_assert(z != NULL);
|
||||||
if (!z) return z;
|
if (!z) return z;
|
||||||
|
|
||||||
// round dx down to avoid overshooting
|
// round dx down to avoid overshooting
|
||||||
if (dxdy < 0)
|
if (dxdy < 0)
|
||||||
z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy);
|
z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy);
|
||||||
@ -2824,7 +2824,7 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3554,7 +3554,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info
|
|||||||
{
|
{
|
||||||
int ix0,iy0,ix1,iy1;
|
int ix0,iy0,ix1,iy1;
|
||||||
stbtt__bitmap gbm;
|
stbtt__bitmap gbm;
|
||||||
stbtt_vertex *vertices;
|
stbtt_vertex *vertices;
|
||||||
int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
|
int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
|
||||||
|
|
||||||
if (scale_x == 0) scale_x = scale_y;
|
if (scale_x == 0) scale_x = scale_y;
|
||||||
@ -3577,7 +3577,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info
|
|||||||
if (height) *height = gbm.h;
|
if (height) *height = gbm.h;
|
||||||
if (xoff ) *xoff = ix0;
|
if (xoff ) *xoff = ix0;
|
||||||
if (yoff ) *yoff = iy0;
|
if (yoff ) *yoff = iy0;
|
||||||
|
|
||||||
if (gbm.w && gbm.h) {
|
if (gbm.w && gbm.h) {
|
||||||
gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata);
|
gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata);
|
||||||
if (gbm.pixels) {
|
if (gbm.pixels) {
|
||||||
@ -3588,7 +3588,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info
|
|||||||
}
|
}
|
||||||
STBTT_free(vertices, info->userdata);
|
STBTT_free(vertices, info->userdata);
|
||||||
return gbm.pixels;
|
return gbm.pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
||||||
{
|
{
|
||||||
@ -3600,7 +3600,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne
|
|||||||
int ix0,iy0;
|
int ix0,iy0;
|
||||||
stbtt_vertex *vertices;
|
stbtt_vertex *vertices;
|
||||||
int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
|
int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
|
||||||
stbtt__bitmap gbm;
|
stbtt__bitmap gbm;
|
||||||
|
|
||||||
stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0);
|
stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0);
|
||||||
gbm.pixels = output;
|
gbm.pixels = output;
|
||||||
@ -3622,7 +3622,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *
|
|||||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||||
{
|
{
|
||||||
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
|
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
|
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
|
||||||
{
|
{
|
||||||
@ -3637,7 +3637,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns
|
|||||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||||
{
|
{
|
||||||
return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
|
return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
|
STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
|
||||||
{
|
{
|
||||||
@ -3762,7 +3762,7 @@ static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *no
|
|||||||
con->y = 0;
|
con->y = 0;
|
||||||
con->bottom_y = 0;
|
con->bottom_y = 0;
|
||||||
STBTT__NOTUSED(nodes);
|
STBTT__NOTUSED(nodes);
|
||||||
STBTT__NOTUSED(num_nodes);
|
STBTT__NOTUSED(num_nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects)
|
static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects)
|
||||||
@ -4147,7 +4147,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char
|
|||||||
n = 0;
|
n = 0;
|
||||||
for (i=0; i < num_ranges; ++i)
|
for (i=0; i < num_ranges; ++i)
|
||||||
n += ranges[i].num_chars;
|
n += ranges[i].num_chars;
|
||||||
|
|
||||||
rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
|
rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
|
||||||
if (rects == NULL)
|
if (rects == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -4158,7 +4158,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char
|
|||||||
n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
|
n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
|
||||||
|
|
||||||
stbtt_PackFontRangesPackRects(spc, rects, n);
|
stbtt_PackFontRangesPackRects(spc, rects, n);
|
||||||
|
|
||||||
return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects);
|
return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects);
|
||||||
|
|
||||||
STBTT_free(rects, spc->user_allocator_context);
|
STBTT_free(rects, spc->user_allocator_context);
|
||||||
@ -4319,7 +4319,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
|||||||
int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y;
|
int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y;
|
||||||
if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
|
if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
|
||||||
float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
|
float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
|
||||||
if (x_inter < x)
|
if (x_inter < x)
|
||||||
winding += (y0 < y1) ? 1 : -1;
|
winding += (y0 < y1) ? 1 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4345,7 +4345,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
|||||||
y1 = (int)verts[i ].y;
|
y1 = (int)verts[i ].y;
|
||||||
if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
|
if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
|
||||||
float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
|
float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
|
||||||
if (x_inter < x)
|
if (x_inter < x)
|
||||||
winding += (y0 < y1) ? 1 : -1;
|
winding += (y0 < y1) ? 1 : -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -4357,7 +4357,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
|||||||
if (hits[1][0] < 0)
|
if (hits[1][0] < 0)
|
||||||
winding += (hits[1][1] < 0 ? -1 : 1);
|
winding += (hits[1][1] < 0 ? -1 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return winding;
|
return winding;
|
||||||
@ -4438,7 +4438,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
|||||||
|
|
||||||
// invert for y-downwards bitmaps
|
// invert for y-downwards bitmaps
|
||||||
scale_y = -scale_y;
|
scale_y = -scale_y;
|
||||||
|
|
||||||
{
|
{
|
||||||
int x,y,i,j;
|
int x,y,i,j;
|
||||||
float *precompute;
|
float *precompute;
|
||||||
@ -4587,7 +4587,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
|||||||
STBTT_free(verts, info->userdata);
|
STBTT_free(verts, info->userdata);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
|
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
|
||||||
{
|
{
|
||||||
@ -4605,7 +4605,7 @@ STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata)
|
|||||||
//
|
//
|
||||||
|
|
||||||
// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
|
// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
|
||||||
static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
|
static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
|
||||||
{
|
{
|
||||||
stbtt_int32 i=0;
|
stbtt_int32 i=0;
|
||||||
|
|
||||||
@ -4644,7 +4644,7 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, s
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
|
static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
|
||||||
{
|
{
|
||||||
return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
|
return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
|
||||||
}
|
}
|
||||||
@ -4773,7 +4773,7 @@ STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,
|
|||||||
|
|
||||||
STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
|
STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
|
||||||
{
|
{
|
||||||
return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
|
return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
|
STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
|
||||||
@ -4866,38 +4866,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE A - MIT License
|
ALTERNATIVE A - MIT License
|
||||||
Copyright (c) 2017 Sean Barrett
|
Copyright (c) 2017 Sean Barrett
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
the Software without restriction, including without limitation the rights to
|
the Software without restriction, including without limitation the rights to
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
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
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
so, subject to the following conditions:
|
so, subject to the following conditions:
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
This is free and unencumbered software released into the public domain.
|
This is free and unencumbered software released into the public domain.
|
||||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
software, either in source code form or as a compiled binary, for any purpose,
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
commercial or non-commercial, and by any means.
|
commercial or non-commercial, and by any means.
|
||||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
software dedicate any and all copyright interest in the software to the public
|
software dedicate any and all copyright interest in the software to the public
|
||||||
domain. We make this dedication for the benefit of the public at large and to
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
the detriment of our heirs and successors. We intend this dedication to be an
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
overt act of relinquishment in perpetuity of all present and future rights to
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
this software under copyright law.
|
this software under copyright law.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
AUTHORS 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
|
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.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
59
src/Game.cpp
59
src/Game.cpp
@ -4,7 +4,9 @@
|
|||||||
#include "Ui.h"
|
#include "Ui.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
#include "CIplStore.h"
|
#include <CIplStore.h>
|
||||||
|
#include <CMessages.h>
|
||||||
|
#include <CSprite2d.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool bSaveGameFlag = false;
|
static bool bSaveGameFlag = false;
|
||||||
@ -56,6 +58,27 @@ Game::Game()
|
|||||||
bSaveGameFlag = false;
|
bSaveGameFlag = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Events::drawingEvent += []()
|
||||||
|
{
|
||||||
|
if (m_RandomCheats::m_bEnabled && m_RandomCheats::m_bProgressBar)
|
||||||
|
{
|
||||||
|
// Next cheat timer bar
|
||||||
|
uint screenWidth = screen::GetScreenWidth();
|
||||||
|
uint screenHeight = screen::GetScreenHeight();
|
||||||
|
uint timer = CTimer::m_snTimeInMilliseconds;
|
||||||
|
uint totalTime = m_RandomCheats::m_nInterval;
|
||||||
|
float progress = (totalTime - (timer - m_RandomCheats::m_nTimer) / 1000.0f) / totalTime;
|
||||||
|
|
||||||
|
CRect sizeBox = CRect(0,0, screenWidth, screenHeight/50);
|
||||||
|
CRect sizeProgress = CRect(0,0, screenWidth*progress, screenHeight/50);
|
||||||
|
CRGBA colorBG = CRGBA(24, 99, 44, 255);
|
||||||
|
CRGBA colorProgress = CRGBA(33, 145, 63, 255);
|
||||||
|
|
||||||
|
CSprite2d::DrawRect(sizeBox, colorBG);
|
||||||
|
CSprite2d::DrawRect(sizeProgress, colorProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Events::processScriptsEvent += []
|
Events::processScriptsEvent += []
|
||||||
@ -149,22 +172,24 @@ Game::Game()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
if (m_RandomCheats::m_bEnabled
|
if (m_RandomCheats::m_bEnabled)
|
||||||
&& (timer - m_RandomCheats::m_nTimer) > (static_cast<uint>(m_RandomCheats::m_nInterval) * 1000))
|
|
||||||
{
|
{
|
||||||
int id = Random(0, 91);
|
if ((timer - m_RandomCheats::m_nTimer) > (static_cast<uint>(m_RandomCheats::m_nInterval) * 1000))
|
||||||
|
|
||||||
for (int i = 0; i < 92; i++)
|
|
||||||
{
|
{
|
||||||
if (i == id)
|
int id = Random(0, 91);
|
||||||
|
|
||||||
|
for (int i = 0; i < 92; i++)
|
||||||
{
|
{
|
||||||
if (m_RandomCheats::m_EnabledCheats[i][1] == "true")
|
if (i == id)
|
||||||
{
|
{
|
||||||
((void(*)(int))0x00438370)(id); // cheatEnableLegimate(int CheatID)
|
if (m_RandomCheats::m_EnabledCheats[i][1] == "true")
|
||||||
SetHelpMessage(m_RandomCheats::m_EnabledCheats[i][0].c_str(), false, false, false);
|
{
|
||||||
m_RandomCheats::m_nTimer = timer;
|
Call<0x00438370>(id); // cheatEnableLegimate(int CheatID)
|
||||||
|
CMessages::AddMessage((char*)m_RandomCheats::m_EnabledCheats[i][0].c_str(), 2000, 0, false);
|
||||||
|
m_RandomCheats::m_nTimer = timer;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,11 +413,11 @@ void Game::Draw()
|
|||||||
{
|
{
|
||||||
if (m_bDisableReplay)
|
if (m_bDisableReplay)
|
||||||
{
|
{
|
||||||
patch::SetChar(BY_GAME(0x460500, 0x624EC0), 0xC3);
|
patch::SetUChar(BY_GAME(0x460500, 0x624EC0), 0xC3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
patch::SetChar(BY_GAME(0x460500, 0x624EC0), 0x80);
|
patch::SetUChar(BY_GAME(0x460500, 0x624EC0), 0x80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,13 +715,17 @@ It's recommanded not to save after using the mission loader. Use it at your own
|
|||||||
if (ImGui::BeginTabItem("Random cheats"))
|
if (ImGui::BeginTabItem("Random cheats"))
|
||||||
{
|
{
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
ImGui::Columns(2, NULL, false);
|
||||||
ImGui::Checkbox("Enable", &m_RandomCheats::m_bEnabled);
|
ImGui::Checkbox("Enable", &m_RandomCheats::m_bEnabled);
|
||||||
|
ImGui::NextColumn();
|
||||||
|
ImGui::Checkbox("Progress bar", &m_RandomCheats::m_bProgressBar);
|
||||||
|
ImGui::Columns(1);
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
|
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
|
||||||
|
|
||||||
ImGui::SliderInt("Activate cheat timer", &m_RandomCheats::m_nInterval, 5, 60);
|
ImGui::SliderInt("Activate cheat timer", &m_RandomCheats::m_nInterval, 5, 60);
|
||||||
Ui::ShowTooltip("Wait time after a cheat is activated.");
|
Ui::ShowTooltip("Time for the next cheat activation.");
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ public:
|
|||||||
struct m_RandomCheats
|
struct m_RandomCheats
|
||||||
{
|
{
|
||||||
inline static bool m_bEnabled;
|
inline static bool m_bEnabled;
|
||||||
|
inline static bool m_bProgressBar = true;
|
||||||
inline static std::string m_EnabledCheats[92][2];
|
inline static std::string m_EnabledCheats[92][2];
|
||||||
inline static int m_nInterval = 10;
|
inline static int m_nInterval = 10;
|
||||||
inline static CJson m_Json = CJson("cheat name");
|
inline static CJson m_Json = CJson("cheat name");
|
||||||
|
@ -189,9 +189,8 @@ bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_
|
|||||||
ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg);
|
ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg);
|
||||||
std::string slabel = "##InvCheckboxBtn" + std::string(label);
|
std::string slabel = "##InvCheckboxBtn" + std::string(label);
|
||||||
|
|
||||||
if (is_disabled)
|
ImGui::BeginDisabled(is_disabled);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
|
||||||
|
|
||||||
// process the button states
|
// process the button states
|
||||||
if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled)
|
if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled)
|
||||||
{
|
{
|
||||||
@ -260,8 +259,7 @@ bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_disabled)
|
ImGui::EndDisabled();
|
||||||
ImGui::PopStyleVar();
|
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user