Skip to content

Commit aa97252

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # imgui_internal.h
2 parents 2d403a1 + b758b82 commit aa97252

File tree

10 files changed

+45
-8
lines changed

10 files changed

+45
-8
lines changed

backends/imgui_impl_dx12.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
833833
init_info->SrvDescriptorAllocFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_handle)
834834
{
835835
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
836-
IM_ASSERT(bd->LegacySingleDescriptorUsed == false);
836+
IM_ASSERT(bd->LegacySingleDescriptorUsed == false && "Only 1 simultaneous texture allowed with legacy ImGui_ImplDX12_Init() signature!");
837837
*out_cpu_handle = bd->InitInfo.LegacySingleSrvCpuDescriptor;
838838
*out_gpu_handle = bd->InitInfo.LegacySingleSrvGpuDescriptor;
839839
bd->LegacySingleDescriptorUsed = true;

backends/imgui_impl_dx12.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct ImGui_ImplDX12_InitInfo
3535
void* UserData;
3636

3737
// Allocating SRV descriptors for textures is up to the application, so we provide callbacks.
38-
// (current version of the backend will only allocate one descriptor, future versions will need to allocate more)
38+
// (current version of the backend will only allocate one descriptor, from 1.92 the backend will need to allocate more)
3939
ID3D12DescriptorHeap* SrvDescriptorHeap;
4040
void (*SrvDescriptorAllocFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_desc_handle);
4141
void (*SrvDescriptorFreeFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_desc_handle);

backends/imgui_impl_sdl2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport* view
215215
ImGuiKey ImGui_ImplSDL2_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode scancode);
216216
ImGuiKey ImGui_ImplSDL2_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode scancode)
217217
{
218-
IM_UNUSED(scancode);
219218
switch (keycode)
220219
{
221220
case SDLK_TAB: return ImGuiKey_Tab;
@@ -355,6 +354,7 @@ ImGuiKey ImGui_ImplSDL2_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode sca
355354
case SDL_SCANCODE_COMMA: return ImGuiKey_Comma;
356355
case SDL_SCANCODE_PERIOD: return ImGuiKey_Period;
357356
case SDL_SCANCODE_SLASH: return ImGuiKey_Slash;
357+
default: break;
358358
}
359359
return ImGuiKey_None;
360360
}

backends/imgui_impl_sdl3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ ImGuiKey ImGui_ImplSDL3_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode sca
327327
case SDL_SCANCODE_COMMA: return ImGuiKey_Comma;
328328
case SDL_SCANCODE_PERIOD: return ImGuiKey_Period;
329329
case SDL_SCANCODE_SLASH: return ImGuiKey_Slash;
330+
default: break;
330331
}
331332
return ImGuiKey_None;
332333
}

docs/CHANGELOG.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,21 @@ Other changes:
7777
inner/outer padding applied to hit-testing of windows borders and detection
7878
of hovered window.
7979
- InputText: Allow CTRL+Shift+Z to redo even outside of OSX. (#8389) [@tanksdude]
80+
- InputText: Pasting a multi-line buffer into a single-line edit replaces
81+
carriage return by spaces. (#8459)
8082
- InputTextWithHint(): Fixed buffer-overflow (luckily often with no visible effect)
8183
when a user callback modified the buffer contents in a way that altered the
8284
visibility of the preview/hint buffer. (#8368) [@m9710797, @ocornut]
8385
- Scrollbar: Rework logic that fades-out scrollbar when it becomes too small,
8486
which amusingly made it disappear when using very big font/frame size.
87+
- Scrollbar: Automatically stabilize ScrollbarX visibility when detecting a
88+
feedback loop manifesting with ScrollbarX visibility toggling on and off
89+
repeatedly. (#8488, #3285, #4539)
90+
(feedback loops of this sort can manifest in various situations, but combining
91+
horizontal + vertical scrollbar + using a clipper with varying width items is
92+
one frequent cause. The better solution is to, either: (1) enforce visibility
93+
by using ImGuiWindowFlags_AlwaysHorizontalScrollbar or (2) declare stable
94+
contents width with SetNextWindowContentSize(), if you can compute it.)
8595
- Tables: fixed calling SetNextWindowScroll() on clipped scrolling table
8696
to not leak the value into a subsequent window. (#8196)
8797
- Tables: fixed an issue where Columns Visible/Width state wouldn't be correctly

examples/example_win32_directx12/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ int main(int, char**)
166166
init_info.SrvDescriptorFreeFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle) { return g_pd3dSrvDescHeapAlloc.Free(cpu_handle, gpu_handle); };
167167
ImGui_ImplDX12_Init(&init_info);
168168

169+
// Before 1.91.6: our signature was using a single descriptor. From 1.92, specifying SrvDescriptorAllocFn/SrvDescriptorFreeFn will be required to benefit from new features.
170+
//ImGui_ImplDX12_Init(g_pd3dDevice, APP_NUM_FRAMES_IN_FLIGHT, DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap, g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
171+
169172
// Load Fonts
170173
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
171174
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.

imgui.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7959,9 +7959,23 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
79597959
ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f;
79607960
float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x;
79617961
float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y;
7962+
bool scrollbar_x_prev = window->ScrollbarX;
79627963
//bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons?
79637964
window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar));
79647965
window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
7966+
7967+
// Track when ScrollbarX visibility keeps toggling, which is a sign of a feedback loop, and stabilize by enforcing visibility (#3285, #8488)
7968+
// (Feedback loops of this sort can manifest in various situations, but combining horizontal + vertical scrollbar + using a clipper with varying width items is one frequent cause.
7969+
// The better solution is to, either (1) enforce visibility by using ImGuiWindowFlags_AlwaysHorizontalScrollbar or (2) declare stable contents width with SetNextWindowContentSize(), if you can compute it)
7970+
window->ScrollbarXStabilizeToggledHistory <<= 1;
7971+
window->ScrollbarXStabilizeToggledHistory |= (scrollbar_x_prev != window->ScrollbarX) ? 0x01 : 0x00;
7972+
const bool scrollbar_x_stabilize = (window->ScrollbarXStabilizeToggledHistory != 0) && ImCountSetBits(window->ScrollbarXStabilizeToggledHistory) >= 4; // 4 == half of bits in our U8 history.
7973+
if (scrollbar_x_stabilize)
7974+
window->ScrollbarX = true;
7975+
//if (scrollbar_x_stabilize && !window->ScrollbarXStabilizeEnabled)
7976+
// IMGUI_DEBUG_LOG("[scroll] Stabilize ScrollbarX for Window '%s'\n", window->Name);
7977+
window->ScrollbarXStabilizeEnabled = scrollbar_x_stabilize;
7978+
79657979
if (window->ScrollbarX && !window->ScrollbarY)
79667980
window->ScrollbarY = (needed_size_from_last_frame.y > size_y_for_scrollbars - style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
79677981
window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);

imgui_internal.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,10 @@ static inline void ImQsort(void* base, size_t count, size_t size_of_element
378378
IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
379379

380380
// Helpers: Bit manipulation
381-
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
382-
static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
383-
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
381+
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
382+
static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
383+
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
384+
static inline unsigned int ImCountSetBits(unsigned int v) { unsigned int count = 0; while (v > 0) { v = v & (v - 1); count++; } return count; }
384385

385386
// Helpers: String
386387
#define ImStrlen strlen
@@ -2735,6 +2736,8 @@ struct IMGUI_API ImGuiWindow
27352736
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
27362737
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
27372738
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
2739+
bool ScrollbarXStabilizeEnabled; // Was ScrollbarX previously auto-stabilized?
2740+
ImU8 ScrollbarXStabilizeToggledHistory; // Used to stabilize scrollbar visibility in case of feedback loops
27382741
bool ViewportOwned;
27392742
bool Active; // Set to true on Begin(), unless Collapsed
27402743
bool WasActive;

imgui_tables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
16371637
if (table->IsInitializing)
16381638
{
16391639
ImGuiTableFlags init_flags = ~0;
1640-
if (column->WidthRequest >= 0.0f && column->StretchWeight >= 0.0f)
1640+
if (column->WidthRequest >= 0.0f || column->StretchWeight >= 0.0f)
16411641
init_flags &= ~ImGuiTableFlags_Resizable;
16421642
TableInitColumnDefaults(table, column, init_flags);
16431643
}

imgui_widgets.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4300,7 +4300,13 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
43004300
if (c < 0x20)
43014301
{
43024302
bool pass = false;
4303-
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0; // Note that an Enter KEY will emit \r and be ignored (we poll for KEY in InputText() code)
4303+
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0; // Note that an Enter KEY will emit \r and be ignored (we poll for KEY in InputText() code)
4304+
if (c == '\n' && input_source_is_clipboard && (flags & ImGuiInputTextFlags_Multiline) == 0) // In single line mode, replace \n with a space
4305+
{
4306+
c = *p_char = ' ';
4307+
pass = true;
4308+
}
4309+
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0;
43044310
pass |= (c == '\t') && (flags & ImGuiInputTextFlags_AllowTabInput) != 0;
43054311
if (!pass)
43064312
return false;

0 commit comments

Comments
 (0)