diff options
| author | Aldrik Ramaekers <aldrik@mailbox.org> | 2026-01-09 16:15:27 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@mailbox.org> | 2026-01-09 16:15:27 +0100 |
| commit | ccacaf0582bcea4a71ec8247ade0fd75e4ca99bf (patch) | |
| tree | ded2c1096149fee09faa9707aef55fc2af4319f9 /libs/imgui/misc | |
| parent | 210404a73706993d197c1290d5a411394e176fbe (diff) | |
refactor library includes, build file
Diffstat (limited to 'libs/imgui/misc')
| -rw-r--r-- | libs/imgui/misc/README.txt | 23 | ||||
| -rw-r--r-- | libs/imgui/misc/cpp/README.txt | 13 | ||||
| -rw-r--r-- | libs/imgui/misc/cpp/imgui_stdlib.cpp | 88 | ||||
| -rw-r--r-- | libs/imgui/misc/cpp/imgui_stdlib.h | 25 | ||||
| -rw-r--r-- | libs/imgui/misc/debuggers/README.txt | 16 | ||||
| -rw-r--r-- | libs/imgui/misc/debuggers/imgui.gdb | 12 | ||||
| -rw-r--r-- | libs/imgui/misc/debuggers/imgui.natstepfilter | 31 | ||||
| -rw-r--r-- | libs/imgui/misc/debuggers/imgui.natvis | 58 | ||||
| -rw-r--r-- | libs/imgui/misc/single_file/imgui_single_file.h | 29 |
9 files changed, 295 insertions, 0 deletions
diff --git a/libs/imgui/misc/README.txt b/libs/imgui/misc/README.txt new file mode 100644 index 0000000..b4ce89f --- /dev/null +++ b/libs/imgui/misc/README.txt @@ -0,0 +1,23 @@ + +misc/cpp/ + InputText() wrappers for C++ standard library (STL) type: std::string. + This is also an example of how you may wrap your own similar types. + +misc/debuggers/ + Helper files for popular debuggers. + With the .natvis file, types like ImVector<> will be displayed nicely in Visual Studio debugger. + +misc/fonts/ + Fonts loading/merging instructions (e.g. How to handle glyph ranges, how to merge icons fonts). + Command line tool "binary_to_compressed_c" to create compressed arrays to embed data in source code. + Suggested fonts and links. + +misc/freetype/ + Font atlas builder/rasterizer using FreeType instead of stb_truetype. + Benefit from better FreeType rasterization, in particular for small fonts. + +misc/single_file/ + Single-file header stub. + We use this to validate compiling all *.cpp files in a same compilation unit. + Users of that technique (also called "Unity builds") can generally provide this themselves, + so we don't really recommend you use this in your projects. diff --git a/libs/imgui/misc/cpp/README.txt b/libs/imgui/misc/cpp/README.txt new file mode 100644 index 0000000..17f0a3c --- /dev/null +++ b/libs/imgui/misc/cpp/README.txt @@ -0,0 +1,13 @@ + +imgui_stdlib.h + imgui_stdlib.cpp + InputText() wrappers for C++ standard library (STL) type: std::string. + This is also an example of how you may wrap your own similar types. + +imgui_scoped.h + [Experimental, not currently in main repository] + Additional header file with some RAII-style wrappers for common Dear ImGui functions. + Try by merging: https://github.com/ocornut/imgui/pull/2197 + Discuss at: https://github.com/ocornut/imgui/issues/2096 + +See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki: + https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness diff --git a/libs/imgui/misc/cpp/imgui_stdlib.cpp b/libs/imgui/misc/cpp/imgui_stdlib.cpp new file mode 100644 index 0000000..d54bb6f --- /dev/null +++ b/libs/imgui/misc/cpp/imgui_stdlib.cpp @@ -0,0 +1,88 @@ +// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) +// This is also an example of how you may wrap your own similar types. + +// Changelog: +// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string + +// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki: +// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness + +#include "imgui/imgui.h" +#ifndef IMGUI_DISABLE +#include "imgui_stdlib.h" + +// Clang warnings with -Weverything +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#endif + +struct InputTextCallback_UserData +{ + std::string* Str; + ImGuiInputTextCallback ChainCallback; + void* ChainCallbackUserData; +}; + +static int InputTextCallback(ImGuiInputTextCallbackData* data) +{ + InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; + if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) + { + // Resize string callback + // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. + std::string* str = user_data->Str; + IM_ASSERT(data->Buf == str->c_str()); + str->resize(data->BufTextLen); + data->Buf = (char*)str->c_str(); + } + else if (user_data->ChainCallback) + { + // Forward to user callback, if any + data->UserData = user_data->ChainCallbackUserData; + return user_data->ChainCallback(data); + } + return 0; +} + +bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); +} + +bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); +} + +bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +{ + IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); + flags |= ImGuiInputTextFlags_CallbackResize; + + InputTextCallback_UserData cb_user_data; + cb_user_data.Str = str; + cb_user_data.ChainCallback = callback; + cb_user_data.ChainCallbackUserData = user_data; + return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); +} + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +#endif // #ifndef IMGUI_DISABLE diff --git a/libs/imgui/misc/cpp/imgui_stdlib.h b/libs/imgui/misc/cpp/imgui_stdlib.h new file mode 100644 index 0000000..697fc34 --- /dev/null +++ b/libs/imgui/misc/cpp/imgui_stdlib.h @@ -0,0 +1,25 @@ +// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) +// This is also an example of how you may wrap your own similar types. + +// Changelog: +// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string + +// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki: +// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness + +#pragma once + +#ifndef IMGUI_DISABLE + +#include <string> + +namespace ImGui +{ + // ImGui::InputText() with std::string + // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity + IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); + IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); + IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); +} + +#endif // #ifndef IMGUI_DISABLE diff --git a/libs/imgui/misc/debuggers/README.txt b/libs/imgui/misc/debuggers/README.txt new file mode 100644 index 0000000..3f4ba83 --- /dev/null +++ b/libs/imgui/misc/debuggers/README.txt @@ -0,0 +1,16 @@ + +HELPER FILES FOR POPULAR DEBUGGERS + +imgui.gdb + GDB: disable stepping into trivial functions. + (read comments inside file for details) + +imgui.natstepfilter + Visual Studio Debugger: disable stepping into trivial functions. + (read comments inside file for details) + +imgui.natvis + Visual Studio Debugger: describe Dear ImGui types for better display. + With this, types like ImVector<> will be displayed nicely in the debugger. + (read comments inside file for details) + diff --git a/libs/imgui/misc/debuggers/imgui.gdb b/libs/imgui/misc/debuggers/imgui.gdb new file mode 100644 index 0000000..000ff6e --- /dev/null +++ b/libs/imgui/misc/debuggers/imgui.gdb @@ -0,0 +1,12 @@ +# GDB configuration to aid debugging experience + +# To enable these customizations edit $HOME/.gdbinit (or ./.gdbinit if local gdbinit is enabled) and add: +# add-auto-load-safe-path /path/to/imgui.gdb +# source /path/to/imgui.gdb +# +# More Information at: +# * https://sourceware.org/gdb/current/onlinedocs/gdb/gdbinit-man.html +# * https://sourceware.org/gdb/current/onlinedocs/gdb/Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory + +# Disable stepping into trivial functions +skip -rfunction Im(Vec2|Vec4|Strv|Vector|Span)::.+ diff --git a/libs/imgui/misc/debuggers/imgui.natstepfilter b/libs/imgui/misc/debuggers/imgui.natstepfilter new file mode 100644 index 0000000..6825c93 --- /dev/null +++ b/libs/imgui/misc/debuggers/imgui.natstepfilter @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +.natstepfilter file for Visual Studio debugger. +Purpose: instruct debugger to skip some functions when using StepInto (F11) + +Since Visual Studio 2022 version 17.6 Preview 2 (currently available as a "Preview" build on March 14, 2023) +It is possible to add the .natstepfilter file to your project file and it will automatically be used. +(https://developercommunity.visualstudio.com/t/allow-natstepfilter-and-natjmc-to-be-included-as-p/561718) + +For older Visual Studio version prior to 2022 17.6 Preview 2: +* copy in %USERPROFILE%\Documents\Visual Studio XXXX\Visualizers (current user) +* or copy in %VsInstallDirectory%\Common7\Packages\Debugger\Visualizers (all users) +If you have multiple VS version installed, the version that matters is the one you are using the IDE/debugger +of (not the compiling toolset). This is supported since Visual Studio 2012. + +More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=vs-2019#BKMK_C___Just_My_Code +--> + +<StepFilter xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010"> + + <!-- Disable stepping into trivial functions --> + <Function> + <Name>(ImVec2|ImVec4|ImStrv)::.+</Name> + <Action>NoStepInto</Action> + </Function> + <Function> + <Name>(ImVector|ImSpan).*::operator.+</Name> + <Action>NoStepInto</Action> + </Function> + +</StepFilter> diff --git a/libs/imgui/misc/debuggers/imgui.natvis b/libs/imgui/misc/debuggers/imgui.natvis new file mode 100644 index 0000000..ba9680b --- /dev/null +++ b/libs/imgui/misc/debuggers/imgui.natvis @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+.natvis file for Visual Studio debugger.
+Purpose: provide nicer views on data types used by Dear ImGui.
+
+To enable:
+* include file in your VS project (most recommended: not intrusive and always kept up to date!)
+* or copy in %USERPROFILE%\Documents\Visual Studio XXXX\Visualizers (current user)
+* or copy in %VsInstallDirectory%\Common7\Packages\Debugger\Visualizers (all users)
+
+More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2019
+-->
+
+<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
+
+<Type Name="ImVector<*>">
+ <DisplayString>{{Size={Size} Capacity={Capacity}}}</DisplayString>
+ <Expand>
+ <ArrayItems>
+ <Size>Size</Size>
+ <ValuePointer>Data</ValuePointer>
+ </ArrayItems>
+ </Expand>
+</Type>
+
+<Type Name="ImSpan<*>">
+ <DisplayString>{{Size={DataEnd-Data} }}</DisplayString>
+ <Expand>
+ <ArrayItems>
+ <Size>DataEnd-Data</Size>
+ <ValuePointer>Data</ValuePointer>
+ </ArrayItems>
+ </Expand>
+</Type>
+
+<Type Name="ImVec2">
+ <DisplayString>{{x={x,g} y={y,g}}}</DisplayString>
+</Type>
+
+<Type Name="ImVec4">
+ <DisplayString>{{x={x,g} y={y,g} z={z,g} w={w,g}}}</DisplayString>
+</Type>
+
+<Type Name="ImRect">
+ <DisplayString>{{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}}</DisplayString>
+ <Expand>
+ <Item Name="Min">Min</Item>
+ <Item Name="Max">Max</Item>
+ <Item Name="[Width]">Max.x - Min.x</Item>
+ <Item Name="[Height]">Max.y - Min.y</Item>
+ </Expand>
+</Type>
+
+<Type Name="ImGuiWindow">
+ <DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
+</Type>
+
+</AutoVisualizer>
diff --git a/libs/imgui/misc/single_file/imgui_single_file.h b/libs/imgui/misc/single_file/imgui_single_file.h new file mode 100644 index 0000000..7ca31e0 --- /dev/null +++ b/libs/imgui/misc/single_file/imgui_single_file.h @@ -0,0 +1,29 @@ +// dear imgui: single-file wrapper include +// We use this to validate compiling all *.cpp files in a same compilation unit. +// Users of that technique (also called "Unity builds") can generally provide this themselves, +// so we don't really recommend you use this in your projects. + +// Do this: +// #define IMGUI_IMPLEMENTATION +// Before you include this file in *one* C++ file to create the implementation. +// Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. + +#ifdef IMGUI_IMPLEMENTATION +#define IMGUI_DEFINE_MATH_OPERATORS +#endif + +#include "../../imgui.h" +#ifdef IMGUI_ENABLE_FREETYPE +#include "../../misc/freetype/imgui_freetype.h" +#endif + +#ifdef IMGUI_IMPLEMENTATION +#include "../../imgui.cpp" +#include "../../imgui_demo.cpp" +#include "../../imgui_draw.cpp" +#include "../../imgui_tables.cpp" +#include "../../imgui_widgets.cpp" +#ifdef IMGUI_ENABLE_FREETYPE +#include "../../misc/freetype/imgui_freetype.cpp" +#endif +#endif |
