Skip to content

Commit

Permalink
Merge branch 'master' into docking
Browse files Browse the repository at this point in the history
# Conflicts:
#	backends/imgui_impl_metal.mm
#	imgui.cpp
#	imgui_internal.h
  • Loading branch information
ocornut committed Feb 3, 2025
2 parents 1820fe5 + 1a31e31 commit d803476
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 35 deletions.
5 changes: 3 additions & 2 deletions backends/imgui_impl_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-XX-XX: Metal: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2025-02-03: Metal: Crash fix. (#8367)
// 2025-01-08: Metal: Fixed memory leaks when using metal-cpp (#8276, #8166) or when using multiple contexts (#7419).
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
// 2022-07-05: Metal: Add dispatch synchronization.
Expand Down Expand Up @@ -323,11 +324,11 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData, id<MTLCommandBuffer> c
indexBufferOffset += (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx);
}

__block MetalContext* sharedMetalContext = bd->SharedMetalContext;
MetalContext* sharedMetalContext = bd->SharedMetalContext;
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer>)
{
dispatch_async(dispatch_get_main_queue(), ^{
@synchronized(bd->SharedMetalContext.bufferCache)
@synchronized(sharedMetalContext.bufferCache)
{
[sharedMetalContext.bufferCache addObject:vertexBuffer];
[sharedMetalContext.bufferCache addObject:indexBuffer];
Expand Down
6 changes: 6 additions & 0 deletions backends/imgui_impl_wgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
#include <limits.h>
#include <webgpu/webgpu.h>

#ifdef IMGUI_IMPL_WEBGPU_BACKEND_DAWN
// Dawn renamed WGPUProgrammableStageDescriptor to WGPUComputeState (see: https://github.com/webgpu-native/webgpu-headers/pull/413)
// Using type alias until WGPU adopts the same naming convention (#8369)
using WGPUProgrammableStageDescriptor = WGPUComputeState;
#endif

// Dear ImGui prototypes from imgui_internal.h
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0);
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
Expand Down
6 changes: 3 additions & 3 deletions backends/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ static void ImGui_ImplWin32_OnChangedViewport(ImGuiViewport* viewport)
#endif
}

namespace ImGui { extern ImGuiIO& GetIOEx(ImGuiContext*); extern ImGuiPlatformIO& GetPlatformIOEx(ImGuiContext*); }
namespace ImGui { extern ImGuiIO& GetIO(ImGuiContext*); extern ImGuiPlatformIO& GetPlatformIO(ImGuiContext*); }

static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Expand All @@ -1317,8 +1317,8 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
if (ctx == NULL)
return DefWindowProc(hWnd, msg, wParam, lParam); // unlike ImGui_ImplWin32_WndProcHandler() we are called directly by Windows, we can't just return 0.

ImGuiIO& io = ImGui::GetIOEx(ctx);
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIOEx(ctx);
ImGuiIO& io = ImGui::GetIO(ctx);
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(ctx);
LRESULT result = 0;
if (ImGui_ImplWin32_WndProcHandlerEx(hWnd, msg, wParam, lParam, io))
result = true;
Expand Down
20 changes: 20 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ HOW TO UPDATE?
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
- Please report any issue!

-----------------------------------------------------------------------
VERSION 1.91.9 WIP (In Progress)
-----------------------------------------------------------------------

Breaking changes:

- Removed ImFontConfig::GlyphExtraSpacing option which seems largely obsolete and
unused. If you were using this please report it! (#242).

Other changes:

- Fixed IsItemDeactivatedAfterEdit() signal being broken for Checkbox(),
RadioButton(), Selectable(). Regression from 2025/01/13. (#8370)
- InputTextWithHint(): Fixed buffer-overflow (luckily often with no visible effect)
when a user callback modified the buffer contents in a way that altered the
visibility of the preview/hint buffer. (#8368) [@m9710797, @ocornut]
- Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom]
- Backends: WebGPU: Fix for DAWN API rename WGPUProgrammableStageDescriptor -> WGPUComputeState.
[@PhantomCloak] (#8369)

-----------------------------------------------------------------------
VERSION 1.91.8 (Released 2025-01-31)
-----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/FONTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ImGui::PopFont();
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
```cpp
ImFontConfig config;
config.GlyphExtraSpacing.x = 1.0f;
config.RasterizerDensity = 2.0f;
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
```

Expand Down
11 changes: 8 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (main code and documentation)

// Help:
Expand Down Expand Up @@ -438,6 +438,7 @@ CODE
- likewise io.MousePos and GetMousePos() will use OS coordinates.
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.

- 2025/02/03 (1.91.9) - removed ImFontConfig::GlyphExtraSpacing option which seems largely obsolete and unused. If you were using this please report it!
- 2025/01/22 (1.91.8) - removed ImGuiColorEditFlags_AlphaPreview (made value 0): it is now the default behavior.
prior to 1.91.8: alpha was made opaque in the preview by default _unless_ using ImGuiColorEditFlags_AlphaPreview. We now display the preview as transparent by default. You can use ImGuiColorEditFlags_AlphaOpaque to use old behavior.
the new flags (ImGuiColorEditFlags_AlphaOpaque, ImGuiColorEditFlags_AlphaNoBg + existing ImGuiColorEditFlags_AlphaPreviewHalf) may be combined better and allow finer controls:
Expand Down Expand Up @@ -2072,6 +2073,7 @@ const char* ImStreolRange(const char* str, const char* str_end)

const char* ImStrbol(const char* buf_mid_line, const char* buf_begin) // find beginning-of-line
{
IM_ASSERT_PARANOID(buf_mid_line >= buf_begin && buf_mid_line <= buf_begin + strlen(buf_begin));
while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n')
buf_mid_line--;
return buf_mid_line;
Expand Down Expand Up @@ -4541,8 +4543,11 @@ void ImGui::MarkItemEdited(ImGuiID id)
return;
if (g.ActiveId == id || g.ActiveId == 0)
{
// FIXME: Can't we fully rely on LastItemData yet?
g.ActiveIdHasBeenEditedThisFrame = true;
g.ActiveIdHasBeenEditedBefore = true;
if (g.DeactivatedItemData.ID == id)
g.DeactivatedItemData.HasBeenEditedBefore = true;
}

// We accept a MarkItemEdited() on drag and drop targets (see https://github.com/ocornut/imgui/issues/1875#issuecomment-978243343)
Expand Down Expand Up @@ -4924,7 +4929,7 @@ ImGuiIO& ImGui::GetIO()
}

// This variant exists to facilitate backends experimenting with multi-threaded parallel context. (#8069, #6293, #5856)
ImGuiIO& ImGui::GetIOEx(ImGuiContext* ctx)
ImGuiIO& ImGui::GetIO(ImGuiContext* ctx)
{
IM_ASSERT(ctx != NULL);
return ctx->IO;
Expand All @@ -4937,7 +4942,7 @@ ImGuiPlatformIO& ImGui::GetPlatformIO()
}

// This variant exists to facilitate backends experimenting with multi-threaded parallel context. (#8069, #6293, #5856)
ImGuiPlatformIO& ImGui::GetPlatformIOEx(ImGuiContext* ctx)
ImGuiPlatformIO& ImGui::GetPlatformIO(ImGuiContext* ctx)
{
IM_ASSERT(ctx != NULL);
return ctx->PlatformIO;
Expand Down
11 changes: 5 additions & 6 deletions imgui.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (headers)

// Help:
Expand Down Expand Up @@ -28,8 +28,8 @@

// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.91.8"
#define IMGUI_VERSION_NUM 19180
#define IMGUI_VERSION "1.91.9 WIP"
#define IMGUI_VERSION_NUM 19182
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch
Expand Down Expand Up @@ -3372,7 +3372,7 @@ struct ImFontConfig
int OversampleH; // 0 (2) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1 or 2 depending on size. Note the difference between 2 and 3 is minimal. You can reduce this to 1 for large glyphs save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
int OversampleV; // 0 (1) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1. This is not really useful as we don't use sub-pixel positions on the Y axis.
float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs when rendered: essentially add to glyph->AdvanceX. Only X axis is supported for now.
//ImVec2 GlyphExtraSpacing; // 0, 0 // (REMOVED AT IT SEEMS LARGELY OBSOLETE. PLEASE REPORT IF YOU WERE USING THIS). Extra spacing (in pixels) between glyphs when rendered: essentially add to glyph->AdvanceX. Only X axis is supported for now.
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
const ImWchar* GlyphRanges; // NULL // THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
Expand All @@ -3396,7 +3396,7 @@ struct ImFontGlyph
unsigned int Colored : 1; // Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops)
unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
unsigned int Codepoint : 30; // 0x0000..0x10FFFF
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
float AdvanceX; // Horizontal distance to advance layout with
float X0, Y0, X1, Y1; // Glyph corners
float U0, V0, U1, V1; // Texture coordinates
};
Expand Down Expand Up @@ -3613,7 +3613,6 @@ struct ImFont
IMGUI_API void GrowIndex(int new_size);
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 SetGlyphVisible(ImWchar c, bool visible);
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
};

Expand Down
2 changes: 1 addition & 1 deletion imgui_demo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (demo code)

// Help:
Expand Down
19 changes: 6 additions & 13 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (drawing and font code)

/*
Expand Down Expand Up @@ -3355,7 +3355,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
if (r->Font == NULL || r->GlyphID == 0)
continue;

// Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH
// Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, PixelSnapH
IM_ASSERT(r->Font->ContainerAtlas == atlas);
ImVec2 uv0, uv1;
atlas->CalcCustomRectUV(r, &uv0, &uv1);
Expand Down Expand Up @@ -3776,8 +3776,10 @@ void ImFont::BuildLookupTable()
}

// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
SetGlyphVisible((ImWchar)' ', false);
SetGlyphVisible((ImWchar)'\t', false);
if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)' '))
glyph->Visible = false;
if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)'\t'))
glyph->Visible = false;

// Setup Fallback character
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
Expand Down Expand Up @@ -3833,12 +3835,6 @@ bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
return true;
}

void ImFont::SetGlyphVisible(ImWchar c, bool visible)
{
if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)c))
glyph->Visible = visible ? 1 : 0;
}

void ImFont::GrowIndex(int new_size)
{
IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
Expand Down Expand Up @@ -3868,9 +3864,6 @@ void ImFont::AddGlyph(const ImFontConfig* cfg, ImWchar codepoint, float x0, floa
// Snap to pixel
if (cfg->PixelSnapH)
advance_x = IM_ROUND(advance_x);

// Bake spacing
advance_x += cfg->GlyphExtraSpacing.x;
}

int glyph_idx = Glyphs.Size;
Expand Down
6 changes: 3 additions & 3 deletions imgui_internal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (internal structures/api)

// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
Expand Down Expand Up @@ -3218,8 +3218,8 @@ namespace ImGui
// If this ever crashes because g.CurrentWindow is NULL, it means that either:
// - ImGui::NewFrame() has never been called, which is illegal.
// - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
IMGUI_API ImGuiIO& GetIOEx(ImGuiContext* ctx);
IMGUI_API ImGuiPlatformIO& GetPlatformIOEx(ImGuiContext* ctx);
IMGUI_API ImGuiIO& GetIO(ImGuiContext* ctx);
IMGUI_API ImGuiPlatformIO& GetPlatformIO(ImGuiContext* ctx);
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
Expand Down
2 changes: 1 addition & 1 deletion imgui_tables.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (tables and columns code)

/*
Expand Down
16 changes: 14 additions & 2 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dear imgui, v1.91.8
// dear imgui, v1.91.9 WIP
// (widgets code)

/*
Expand Down Expand Up @@ -4675,7 +4675,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_

// Select the buffer to render.
const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state;
const bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0);
bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0);

// Password pushes a temporary font with only a fallback glyph
if (is_password && !is_displaying_hint)
Expand Down Expand Up @@ -5157,6 +5157,18 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
const int buf_display_max_length = 2 * 1024 * 1024;
const char* buf_display = buf_display_from_state ? state->TextA.Data : buf; //-V595
const char* buf_display_end = NULL; // We have specialized paths below for setting the length

// Display hint when contents is empty
// At this point we need to handle the possibility that a callback could have modified the underlying buffer (#8368)
const bool new_is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0);
if (new_is_displaying_hint != is_displaying_hint)
{
if (is_password && !is_displaying_hint)
PopFont();
is_displaying_hint = new_is_displaying_hint;
if (is_password && !is_displaying_hint)
PushPasswordFont();
}
if (is_displaying_hint)
{
buf_display = hint;
Expand Down

0 comments on commit d803476

Please sign in to comment.