From 0fe48cbb61e11a01ce13ee3cc2f00b23842a2720 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 12 Oct 2018 11:14:21 +0200 Subject: [PATCH] Renamed misc/stl/imgui_stl.h,.cpp to misc/cpp/imgui_stdlib.h in prevision for other files.(#2035, #2096) Added misc/README file. --- docs/CHANGELOG.txt | 4 +++- imgui.cpp | 1 + imgui.h | 4 ++-- imgui_demo.cpp | 4 ++-- imgui_widgets.cpp | 2 +- misc/README.txt | 18 ++++++++++++++++++ .../imgui_stl.cpp => cpp/imgui_stdlib.cpp} | 7 +++++-- misc/{stl/imgui_stl.h => cpp/imgui_stdlib.h} | 2 +- misc/natvis/README.txt | 5 +++-- 9 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 misc/README.txt rename misc/{stl/imgui_stl.cpp => cpp/imgui_stdlib.cpp} (94%) rename misc/{stl/imgui_stl.h => cpp/imgui_stdlib.h} (98%) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2d216d03..b9af2ce3 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -36,6 +36,7 @@ HOW TO UPDATE? Breaking Changes: - Renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). +- Renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. (#2035, #2096) Other Changes: @@ -162,6 +163,7 @@ Other Changes: - Selectable: Added ImGuiSelectableFlags_Disabled flag in the public API. (#211) - ColorEdit4: Fixed a bug when text input or drag and drop leading to unsaturated HSV values would erroneously alter the resulting color. (#2050) - Misc: Added optional misc/stl/imgui_stl.h wrapper to use with STL types (e.g. InputText with std::string). (#2006, #1443, #1008) + [*EDIT* renamed to misc/std/imgui_stdlib.h in 1.66] - Misc: Added IMGUI_VERSION_NUM for easy compile-time testing. (#2025) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. @@ -233,7 +235,7 @@ Other Changes: - Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well. - Read examples/README.txt for details. - Added IsItemDeactivated() to query if the last item was active previously and isn't anymore. Useful for Undo/Redo patterns. (#820, #956, #1875) -- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63) if the last item was active previously, +- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63] if the last item was active previously, is not anymore, and during its active state modified a value. Note that you may still get false positive (e.g. drag value and while holding return on the same value). (#820, #956, #1875) - Nav: Added support for PageUp/PageDown (explorer-style: first aim at bottom/top most item, when scroll a page worth of contents). (#787) diff --git a/imgui.cpp b/imgui.cpp index 5b49b4b8..9ddc63a8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -342,6 +342,7 @@ CODE When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. + - 2018/10/12 (1.66) - Renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h. If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths. diff --git a/imgui.h b/imgui.h index 4b320588..05ede495 100644 --- a/imgui.h +++ b/imgui.h @@ -392,7 +392,7 @@ namespace ImGui IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); // Widgets: Input with Keyboard - // If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/stl/imgui_stl.h + // If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); @@ -668,7 +668,7 @@ enum ImGuiInputTextFlags_ ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*' ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input) - ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/stl/imgui_stl.h for an example of using this) + ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this) // [Internal] ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline() }; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 18178f28..449da0a9 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -448,7 +448,7 @@ void ImGui::ShowDemoWindow(bool* p_open) static char str0[128] = "Hello, world!"; static int i0 = 123; ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0)); - ImGui::SameLine(); ShowHelpMarker("USER:\nHold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/stl/imgui_stl.h for an example (this is not demonstrated in imgui_demo.cpp)."); + ImGui::SameLine(); ShowHelpMarker("USER:\nHold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp)."); ImGui::InputInt("input int", &i0); ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n"); @@ -895,7 +895,7 @@ void ImGui::ShowDemoWindow(bool* p_open) "label:\n" "\tlock cmpxchg8b eax\n"; - ShowHelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/stl/imgui_stl.h for an example. (This is not demonstrated in imgui_demo.cpp)"); + ShowHelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)"); ImGui::Checkbox("Read-only", &read_only); ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput | (read_only ? ImGuiInputTextFlags_ReadOnly : 0); ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9cecc547..5cfad55d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3094,7 +3094,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f // This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match // Note that in std::string world, capacity() would omit 1 byte used by the zero-terminator. // - When active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while the InputText is active has no effect. -// - If you want to use ImGui::InputText() with std::string, see misc/stl/imgui_stl.h +// - If you want to use ImGui::InputText() with std::string, see misc/cpp/imgui_stdlib.h // (FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188) bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* callback_user_data) { diff --git a/misc/README.txt b/misc/README.txt new file mode 100644 index 00000000..70f835cf --- /dev/null +++ b/misc/README.txt @@ -0,0 +1,18 @@ + +misc/cpp/ + InputText() wrappers for C++ standard library (STL) types (std::string, etc.). + This is also an example of how you may wrap your own similar types. + +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/natnis/ + Natvis file to describe dear imgui types in the Visual Studio debugger. + With this, types like ImVector<> will be displayed nicely in the debugger. + You can include this file a Visual Studio project file, or install it in Visual Studio folder. diff --git a/misc/stl/imgui_stl.cpp b/misc/cpp/imgui_stdlib.cpp similarity index 94% rename from misc/stl/imgui_stl.cpp rename to misc/cpp/imgui_stdlib.cpp index 6bbd4748..790d8d80 100644 --- a/misc/stl/imgui_stl.cpp +++ b/misc/cpp/imgui_stdlib.cpp @@ -1,4 +1,4 @@ -// imgui_stl.cpp +// imgui_stdlib.cpp // Wrappers for C++ standard library (STL) types (std::string, etc.) // This is also an example of how you may wrap your own similar types. @@ -6,8 +6,11 @@ // - std::string support is only guaranteed to work from C++11. // If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) +// Changelog: +// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string + #include "imgui.h" -#include "imgui_stl.h" +#include "imgui_stdlib.h" struct InputTextCallback_UserData { diff --git a/misc/stl/imgui_stl.h b/misc/cpp/imgui_stdlib.h similarity index 98% rename from misc/stl/imgui_stl.h rename to misc/cpp/imgui_stdlib.h index 7837ff6a..200c45a5 100644 --- a/misc/stl/imgui_stl.h +++ b/misc/cpp/imgui_stdlib.h @@ -1,4 +1,4 @@ -// imgui_stl.h +// imgui_stdlib.h // Wrappers for C++ standard library (STL) types (std::string, etc.) // This is also an example of how you may wrap your own similar types. diff --git a/misc/natvis/README.txt b/misc/natvis/README.txt index 821014e2..60073874 100644 --- a/misc/natvis/README.txt +++ b/misc/natvis/README.txt @@ -1,3 +1,4 @@ -Natvis file to describe types in Visual Studio debugger. -You can include this in a project file, or install in Visual Studio folder. +Natvis file to describe dear imgui types in the Visual Studio debugger. +With this, types like ImVector<> will be displayed nicely in the debugger. +You can include this file a Visual Studio project file, or install it in Visual Studio folder.