update dear imgui from 1.92.2b-docking to 1.92.6-docking
This commit is contained in:
@@ -4,8 +4,8 @@ misc/cpp/
|
||||
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.
|
||||
Helper files for popular debuggers (Visual Studio, GDB, LLDB).
|
||||
e.g. 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).
|
||||
|
||||
@@ -9,5 +9,9 @@ imgui_scoped.h
|
||||
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:
|
||||
imgui-module:
|
||||
C++20 module binding
|
||||
https://github.com/stripe2933/imgui-module
|
||||
|
||||
See more C++ related extension (fmt, RAII, syntactic sugar) on Wiki:
|
||||
https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
// 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.
|
||||
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
|
||||
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.
|
||||
|
||||
// Changelog:
|
||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
|
||||
// Usage:
|
||||
// {
|
||||
// #include "misc/cpp/imgui_stdlib.h"
|
||||
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
|
||||
// [...]
|
||||
// std::string my_string;
|
||||
// ImGui::InputText("my string", &my_string);
|
||||
// }
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntactic sugar) on Wiki:
|
||||
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
// 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.
|
||||
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
|
||||
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.
|
||||
|
||||
// Changelog:
|
||||
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
|
||||
|
||||
// Usage:
|
||||
// {
|
||||
// #include "misc/cpp/imgui_stdlib.h"
|
||||
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
|
||||
// [...]
|
||||
// std::string my_string;
|
||||
// ImGui::InputText("my string", &my_string);
|
||||
// }
|
||||
|
||||
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
|
||||
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
|
||||
|
||||
|
||||
@@ -14,3 +14,8 @@ imgui.natvis
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
(read comments inside file for details)
|
||||
|
||||
imgui_lldb.py
|
||||
LLDB-based debuggers (*): synthetic children provider and summaries for Dear ImGui types.
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
(read comments inside file for details)
|
||||
(*) Xcode, Android Studio, may be used from VS Code, C++Builder, CLion, Eclipse etc.
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
# This file implements synthetic children providers and summaries for various Dear ImGui types for LLDB.
|
||||
# LLDB is used by Xcode, Android Studio, and may be used from VS Code, C++Builder, CLion, Eclipse etc.
|
||||
|
||||
#
|
||||
# Useful links/documentation related to the feature:
|
||||
# - https://lldb.llvm.org/use/variable.html#summary-strings
|
||||
# - https://lldb.llvm.org/use/variable.html#synthetic-children
|
||||
# - https://lldb.llvm.org/python_reference/lldb-module.html
|
||||
#
|
||||
# To use it in a debug session:
|
||||
# > (lldb) command script import <path-to-this-file>
|
||||
#
|
||||
# Alternatively you may include the above command in your ~/.lldbinit file to have the formatters
|
||||
# available in all future sessions
|
||||
|
||||
import lldb
|
||||
|
||||
class ArraySynthBase(object):
|
||||
"""
|
||||
Helper baseclass aimed to reduce the boilerplate needed for "array-like" containers
|
||||
"""
|
||||
|
||||
def __init__(self, valobj, internal_dict):
|
||||
self.valobj = valobj
|
||||
|
||||
def bind_to(self, pointer, size):
|
||||
array_p = pointer.GetType().GetPointeeType().GetArrayType(size).GetPointerType()
|
||||
self.array = pointer.Cast(array_p).Dereference()
|
||||
|
||||
def update(self):
|
||||
self.array = self.valobj
|
||||
|
||||
def num_children(self, max_children):
|
||||
return self.array.GetNumChildren(max_children)
|
||||
|
||||
def get_child_index(self, name):
|
||||
return self.array.GetIndexOfChildWithName(name)
|
||||
|
||||
def get_child_at_index(self, index):
|
||||
return self.array.GetChildAtIndex(index)
|
||||
|
||||
def has_children(self):
|
||||
return self.array.MightHaveChildren()
|
||||
|
||||
def get_value(self):
|
||||
return self.array
|
||||
|
||||
class ImVectorSynth(ArraySynthBase):
|
||||
def update(self):
|
||||
self.size = self.valobj.GetChildMemberWithName("Size").GetValueAsUnsigned()
|
||||
self.capacity = self.valobj.GetChildMemberWithName("Capacity").GetValueAsUnsigned()
|
||||
|
||||
data = self.valobj.GetChildMemberWithName("Data")
|
||||
|
||||
self.bind_to(data, self.size)
|
||||
|
||||
def get_summary(self):
|
||||
return f"Size={self.size} Capacity={self.capacity}"
|
||||
|
||||
class ImSpanSynth(ArraySynthBase):
|
||||
def update(self):
|
||||
data = self.valobj.GetChildMemberWithName("Data")
|
||||
end = self.valobj.GetChildMemberWithName("DataEnd")
|
||||
|
||||
element_size = data.GetType().GetPointeeType().GetByteSize()
|
||||
array_size = end.GetValueAsUnsigned() - data.GetValueAsUnsigned()
|
||||
|
||||
self.size = int(array_size / element_size)
|
||||
|
||||
self.bind_to(data, self.size)
|
||||
|
||||
def get_summary(self):
|
||||
return f"Size={self.size}"
|
||||
|
||||
class ImRectSummary(object):
|
||||
def __init__(self, valobj, internal_dict):
|
||||
self.valobj = valobj
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def get_summary(self):
|
||||
min = self.valobj.GetChildMemberWithName("Min")
|
||||
max = self.valobj.GetChildMemberWithName("Max")
|
||||
|
||||
minX = float(min.GetChildMemberWithName("x").GetValue())
|
||||
minY = float(min.GetChildMemberWithName("y").GetValue())
|
||||
|
||||
maxX = float(max.GetChildMemberWithName("x").GetValue())
|
||||
maxY = float(max.GetChildMemberWithName("y").GetValue())
|
||||
|
||||
return f"Min=({minX}, {minY}) Max=({maxX}, {maxY}) Size=({maxX - minX}, {maxY - minY})"
|
||||
|
||||
def get_active_enum_flags(valobj):
|
||||
flag_set = set()
|
||||
|
||||
enum_name = valobj.GetType().GetName() + "_"
|
||||
enum_type = valobj.GetTarget().FindFirstType(enum_name)
|
||||
|
||||
if not enum_type.IsValid():
|
||||
return flag_set
|
||||
|
||||
enum_members = enum_type.GetEnumMembers()
|
||||
value = valobj.GetValueAsUnsigned()
|
||||
|
||||
for i in range(0, enum_members.GetSize()):
|
||||
member = enum_members.GetTypeEnumMemberAtIndex(i)
|
||||
|
||||
if value & member.GetValueAsUnsigned():
|
||||
flag_set.add(member.GetName().removeprefix(enum_name))
|
||||
|
||||
return flag_set
|
||||
|
||||
class ImGuiWindowSummary(object):
|
||||
def __init__(self, valobj, internal_dict):
|
||||
self.valobj = valobj
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def get_summary(self):
|
||||
name = self.valobj.GetChildMemberWithName("Name").GetSummary()
|
||||
|
||||
active = self.valobj.GetChildMemberWithName("Active").GetValueAsUnsigned() != 0
|
||||
was_active = self.valobj.GetChildMemberWithName("WasActive").GetValueAsUnsigned() != 0
|
||||
hidden = self.valobj.GetChildMemberWithName("Hidden") != 0
|
||||
|
||||
flags = get_active_enum_flags(self.valobj.GetChildMemberWithName("Flags"))
|
||||
|
||||
active = 1 if active or was_active else 0
|
||||
child = 1 if "ChildWindow" in flags else 0
|
||||
popup = 1 if "Popup" in flags else 0
|
||||
hidden = 1 if hidden else 0
|
||||
|
||||
return f"Name {name} Active {active} Child {child} Popup {popup} Hidden {hidden}"
|
||||
|
||||
|
||||
def __lldb_init_module(debugger, internal_dict):
|
||||
"""
|
||||
This function will be automatically called by LLDB when the module is loaded, here
|
||||
we register the various synthetics/summaries we have build before
|
||||
"""
|
||||
|
||||
category_name = "imgui"
|
||||
category = debugger.GetCategory(category_name)
|
||||
|
||||
# Make sure we don't accidentally keep accumulating languages or override the user's
|
||||
# category enablement in Xcode, where lldb-rpc-server loads this file once for eac
|
||||
# debugging session
|
||||
if not category.IsValid():
|
||||
category = debugger.CreateCategory(category_name)
|
||||
category.AddLanguage(lldb.eLanguageTypeC_plus_plus)
|
||||
category.SetEnabled(True)
|
||||
|
||||
def add_summary(typename, impl):
|
||||
summary = None
|
||||
|
||||
if isinstance(impl, str):
|
||||
summary = lldb.SBTypeSummary.CreateWithSummaryString(impl)
|
||||
summary.SetOptions(lldb.eTypeOptionCascade)
|
||||
else:
|
||||
# Unfortunately programmatic summary string generation is an entirely different codepath
|
||||
# in LLDB. Register a convenient trampoline function which makes it look like it's part
|
||||
# of the SyntheticChildrenProvider contract
|
||||
summary = lldb.SBTypeSummary.CreateWithScriptCode(f'''
|
||||
synth = {impl.__module__}.{impl.__qualname__}(valobj.GetNonSyntheticValue(), internal_dict)
|
||||
synth.update()
|
||||
|
||||
return synth.get_summary()
|
||||
''')
|
||||
summary.SetOptions(lldb.eTypeOptionCascade | lldb.eTypeOptionFrontEndWantsDereference)
|
||||
|
||||
category.AddTypeSummary(lldb.SBTypeNameSpecifier(typename, True), summary)
|
||||
|
||||
def add_synthetic(typename, impl):
|
||||
add_summary(typename, impl)
|
||||
|
||||
synthetic = lldb.SBTypeSynthetic.CreateWithClassName(f"{impl.__module__}.{impl.__qualname__}")
|
||||
synthetic.SetOptions(lldb.eTypeOptionCascade | lldb.eTypeOptionFrontEndWantsDereference)
|
||||
|
||||
category.AddTypeSynthetic(lldb.SBTypeNameSpecifier(typename, True), synthetic)
|
||||
|
||||
add_synthetic("^ImVector<.+>$", ImVectorSynth)
|
||||
add_synthetic("^ImSpan<.+>$", ImSpanSynth)
|
||||
|
||||
add_summary("^ImVec2$", "x=${var.x} y=${var.y}")
|
||||
add_summary("^ImVec4$", "x=${var.x} y=${var.y} z=${var.z} w=${var.w}")
|
||||
add_summary("^ImRect$", ImRectSummary)
|
||||
add_summary("^ImGuiWindow$", ImGuiWindowSummary)
|
||||
@@ -7,7 +7,7 @@ Build font atlases using FreeType instead of stb_truetype (which is the default
|
||||
|
||||
1. Get latest FreeType binaries or build yourself (under Windows you may use vcpkg with `vcpkg install freetype --triplet=x64-windows`, `vcpkg integrate install`).
|
||||
2. Add imgui_freetype.h/cpp alongside your project files.
|
||||
3. Add `#define IMGUI_ENABLE_FREETYPE` in your [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) file
|
||||
3. Add `#define IMGUI_ENABLE_FREETYPE` in your [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) file to make Dear ImGui automatically use the imgui_freetype loader. If your copy Dear ImGui is precompiled, you can always enable imgui_freetype by calling ImFontAtlas::SetFontLoader().
|
||||
|
||||
### About Gamma Correct Blending
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ struct ImGui_ImplFreeType_Data
|
||||
struct ImGui_ImplFreeType_FontSrcData
|
||||
{
|
||||
// Initialize from an external data buffer. Doesn't copy data, and you must ensure it stays valid up to this object lifetime.
|
||||
bool InitFont(FT_Library ft_library, ImFontConfig* src, ImGuiFreeTypeLoaderFlags extra_user_flags);
|
||||
bool InitFont(FT_Library ft_library, const ImFontConfig* src, ImGuiFreeTypeLoaderFlags extra_user_flags);
|
||||
void CloseFont();
|
||||
ImGui_ImplFreeType_FontSrcData() { memset((void*)this, 0, sizeof(*this)); }
|
||||
~ImGui_ImplFreeType_FontSrcData() { CloseFont(); }
|
||||
@@ -172,9 +172,9 @@ struct ImGui_ImplFreeType_FontSrcBakedData
|
||||
ImGui_ImplFreeType_FontSrcBakedData() { memset((void*)this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
bool ImGui_ImplFreeType_FontSrcData::InitFont(FT_Library ft_library, ImFontConfig* src, ImGuiFreeTypeLoaderFlags extra_font_loader_flags)
|
||||
bool ImGui_ImplFreeType_FontSrcData::InitFont(FT_Library ft_library, const ImFontConfig* src, ImGuiFreeTypeLoaderFlags extra_font_loader_flags)
|
||||
{
|
||||
FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)src->FontData, (FT_Long)src->FontDataSize, (FT_Long)src->FontNo, &FtFace);
|
||||
FT_Error error = FT_New_Memory_Face(ft_library, (const FT_Byte*)src->FontData, (FT_Long)src->FontDataSize, (FT_Long)src->FontNo, &FtFace);
|
||||
if (error != 0)
|
||||
return false;
|
||||
error = FT_Select_Charmap(FtFace, FT_ENCODING_UNICODE);
|
||||
@@ -187,12 +187,8 @@ bool ImGui_ImplFreeType_FontSrcData::InitFont(FT_Library ft_library, ImFontConfi
|
||||
LoadFlags = 0;
|
||||
if ((UserFlags & ImGuiFreeTypeLoaderFlags_Bitmap) == 0)
|
||||
LoadFlags |= FT_LOAD_NO_BITMAP;
|
||||
|
||||
if (UserFlags & ImGuiFreeTypeLoaderFlags_NoHinting)
|
||||
LoadFlags |= FT_LOAD_NO_HINTING;
|
||||
else
|
||||
src->PixelSnapH = true; // FIXME: A bit weird to do this this way.
|
||||
|
||||
if (UserFlags & ImGuiFreeTypeLoaderFlags_NoAutoHint)
|
||||
LoadFlags |= FT_LOAD_NO_AUTOHINT;
|
||||
if (UserFlags & ImGuiFreeTypeLoaderFlags_ForceAutoHint)
|
||||
@@ -423,7 +419,8 @@ static bool ImGui_ImplFreeType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* s
|
||||
IM_UNUSED(atlas);
|
||||
float size = baked->Size;
|
||||
if (src->MergeMode && src->SizePixels != 0.0f)
|
||||
size *= (src->SizePixels / baked->ContainerFont->Sources[0]->SizePixels);
|
||||
size *= (src->SizePixels / baked->OwnerFont->Sources[0]->SizePixels);
|
||||
size *= src->ExtraSizeScale;
|
||||
|
||||
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
||||
bd_font_data->BakedLastActivated = baked;
|
||||
@@ -454,7 +451,7 @@ static bool ImGui_ImplFreeType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* s
|
||||
{
|
||||
// Read metrics
|
||||
FT_Size_Metrics metrics = bd_baked_data->FtSize->metrics;
|
||||
const float scale = 1.0f / rasterizer_density;
|
||||
const float scale = 1.0f / (rasterizer_density * src->ExtraSizeScale);
|
||||
baked->Ascent = (float)FT_CEIL(metrics.ascender) * scale; // The pixel extents above the baseline in pixels (typically positive).
|
||||
baked->Descent = (float)FT_CEIL(metrics.descender) * scale; // The extents below the baseline in pixels (typically negative).
|
||||
//LineSpacing = (float)FT_CEIL(metrics.height) * scale; // The baseline-to-baseline distance. Note that it usually is larger than the sum of the ascender and descender taken as absolute values. There is also no guarantee that no glyphs extend above or below subsequent baselines when using this distance. Think of it as a value the designer of the font finds appropriate.
|
||||
@@ -539,14 +536,10 @@ static bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConf
|
||||
uint32_t* temp_buffer = (uint32_t*)atlas->Builder->TempBuffer.Data;
|
||||
ImGui_ImplFreeType_BlitGlyph(ft_bitmap, temp_buffer, w);
|
||||
|
||||
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
||||
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
|
||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||
float font_off_x = (src->GlyphOffset.x * offsets_scale);
|
||||
float font_off_y = (src->GlyphOffset.y * offsets_scale) + baked->Ascent;
|
||||
if (src->PixelSnapH) // Snap scaled offset. This is to mitigate backward compatibility issues for GlyphOffset, but a better design would be welcome.
|
||||
font_off_x = IM_ROUND(font_off_x);
|
||||
if (src->PixelSnapV)
|
||||
font_off_y = IM_ROUND(font_off_y);
|
||||
float font_off_x = ImFloor(src->GlyphOffset.x * offsets_scale + 0.5f); // Snap scaled offset.
|
||||
float font_off_y = ImFloor(src->GlyphOffset.y * offsets_scale + 0.5f) + baked->Ascent;
|
||||
float recip_h = 1.0f / rasterizer_density;
|
||||
float recip_v = 1.0f / rasterizer_density;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user