Skip to content

Commit 6fd2ee9

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdl.cpp # imgui_demo.cpp
2 parents 1dc7d0e + c261dac commit 6fd2ee9

File tree

5 files changed

+70
-62
lines changed

5 files changed

+70
-62
lines changed

backends/imgui_impl_sdl.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// CHANGELOG
2222
// (minor and older changes stripped away, please see git history for details)
2323
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
24+
// 2022-09-26: Inputs: Disable SDL 2.0.22 new "auto capture" (SDL_HINT_MOUSE_AUTO_CAPTURE) which prevents drag and drop across windows for multi-viewport support + don't capture when drag and dropping. (#5710)
2425
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
2526
// 2022-03-22: Inputs: Fix mouse position issues when dragging outside of boundaries. SDL_CaptureMouse() erroneously still gives out LEAVE events when hovering OS decorations.
2627
// 2022-03-22: Inputs: Added support for extra mouse buttons (SDL_BUTTON_X1/SDL_BUTTON_X2).
@@ -80,7 +81,6 @@
8081
#else
8182
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
8283
#endif
83-
#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
8484
#define SDL_HAS_WINDOW_ALPHA SDL_VERSION_ATLEAST(2,0,5)
8585
#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
8686
#define SDL_HAS_USABLE_DISPLAY_BOUNDS SDL_VERSION_ATLEAST(2,0,5)
@@ -421,15 +421,20 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
421421
#endif
422422
}
423423

424-
// Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
424+
// From 2.0.5: Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
425425
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
426426
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
427427
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
428428
// you can ignore SDL_MOUSEBUTTONDOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
429-
#if SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH
429+
#ifdef SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
430430
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
431431
#endif
432432

433+
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
434+
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
435+
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
436+
#endif
437+
433438
// Update monitors
434439
ImGui_ImplSDL2_UpdateMonitors();
435440

@@ -503,7 +508,7 @@ static void ImGui_ImplSDL2_UpdateMouseData()
503508
// We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below)
504509
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
505510
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
506-
SDL_CaptureMouse(bd->MouseButtonsDown != 0 ? SDL_TRUE : SDL_FALSE);
511+
SDL_CaptureMouse((bd->MouseButtonsDown != 0 && ImGui::GetDragDropPayload() == NULL) ? SDL_TRUE : SDL_FALSE);
507512
SDL_Window* focused_window = SDL_GetKeyboardFocus();
508513
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
509514
#else

backends/imgui_impl_wgpu.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
#include <limits.h>
2727
#include <webgpu/webgpu.h>
2828

29-
#define HAS_EMSCRIPTEN_VERSION(major, minor, tiny) (__EMSCRIPTEN_major__ > (major) || (__EMSCRIPTEN_major__ == (major) && __EMSCRIPTEN_minor__ > (minor)) || (__EMSCRIPTEN_major__ == (major) && __EMSCRIPTEN_minor__ == (minor) && __EMSCRIPTEN_tiny__ >= (tiny)))
30-
31-
#if defined(__EMSCRIPTEN__) && !HAS_EMSCRIPTEN_VERSION(2, 0, 20)
32-
#error "Requires at least emscripten 2.0.20"
33-
#endif
34-
3529
// Dear ImGui prototypes from imgui_internal.h
3630
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0);
3731

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ Other Changes:
215215
- Demo: Added more explicit "Center window" mode to "Overlay example". (#5618)
216216
- Examples: Added all SDL examples to default VS solution.
217217
- Backends: GLFW: Honor GLFW_CURSOR_DISABLED by not setting mouse position. (#5625) [@scorpion-26]
218+
- Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows
219+
(e.g. for multi-viewport support) and don't capture mouse when drag and dropping. (#5710)
218220
- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
219221
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
220222
- Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz]

imgui_demo.cpp

+58-51
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@
5050

5151
Index of this file:
5252

53-
// [SECTION] Forward Declarations, Helpers
53+
// [SECTION] Forward Declarations
54+
// [SECTION] Helpers
5455
// [SECTION] Demo Window / ShowDemoWindow()
56+
// - ShowDemoWindow()
5557
// - sub section: ShowDemoWindowWidgets()
5658
// - sub section: ShowDemoWindowLayout()
5759
// - sub section: ShowDemoWindowPopups()
5860
// - sub section: ShowDemoWindowTables()
5961
// - sub section: ShowDemoWindowInputs()
6062
// [SECTION] About Window / ShowAboutWindow()
6163
// [SECTION] Style Editor / ShowStyleEditor()
64+
// [SECTION] User Guide / ShowUserGuide()
6265
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
6366
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
6467
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
@@ -192,6 +195,19 @@ static void ShowExampleAppWindowTitles(bool* p_open);
192195
static void ShowExampleAppCustomRendering(bool* p_open);
193196
static void ShowExampleMenuFile();
194197

198+
// We split the contents of the big ShowDemoWindow() function into smaller functions
199+
// (because the link time of very large functions grow non-linearly)
200+
static void ShowDemoWindowWidgets();
201+
static void ShowDemoWindowLayout();
202+
static void ShowDemoWindowPopups();
203+
static void ShowDemoWindowTables();
204+
static void ShowDemoWindowColumns();
205+
static void ShowDemoWindowInputs();
206+
207+
//-----------------------------------------------------------------------------
208+
// [SECTION] Helpers
209+
//-----------------------------------------------------------------------------
210+
195211
// Helper to display a little (?) mark which shows a tooltip when hovered.
196212
// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.md)
197213
static void HelpMarker(const char* desc)
@@ -219,46 +235,16 @@ static void ShowDockingDisabledMessage()
219235

220236
// Helper to wire demo markers located in code to an interactive browser
221237
typedef void (*ImGuiDemoMarkerCallback)(const char* file, int line, const char* section, void* user_data);
222-
extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback;
223-
extern void* GImGuiDemoMarkerCallbackUserData;
224-
ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback = NULL;
225-
void* GImGuiDemoMarkerCallbackUserData = NULL;
238+
extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback;
239+
extern void* GImGuiDemoMarkerCallbackUserData;
240+
ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback = NULL;
241+
void* GImGuiDemoMarkerCallbackUserData = NULL;
226242
#define IMGUI_DEMO_MARKER(section) do { if (GImGuiDemoMarkerCallback != NULL) GImGuiDemoMarkerCallback(__FILE__, __LINE__, section, GImGuiDemoMarkerCallbackUserData); } while (0)
227243

228-
// Helper to display basic user controls.
229-
void ImGui::ShowUserGuide()
230-
{
231-
ImGuiIO& io = ImGui::GetIO();
232-
ImGui::BulletText("Double-click on title bar to collapse window.");
233-
ImGui::BulletText(
234-
"Click and drag on lower corner to resize window\n"
235-
"(double-click to auto fit window to its contents).");
236-
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
237-
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
238-
ImGui::BulletText("CTRL+Tab to select a window.");
239-
if (io.FontAllowUserScaling)
240-
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
241-
ImGui::BulletText("While inputing text:\n");
242-
ImGui::Indent();
243-
ImGui::BulletText("CTRL+Left/Right to word jump.");
244-
ImGui::BulletText("CTRL+A or double-click to select all.");
245-
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
246-
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
247-
ImGui::BulletText("ESCAPE to revert.");
248-
ImGui::Unindent();
249-
ImGui::BulletText("With keyboard navigation enabled:");
250-
ImGui::Indent();
251-
ImGui::BulletText("Arrow keys to navigate.");
252-
ImGui::BulletText("Space to activate a widget.");
253-
ImGui::BulletText("Return to input text into a widget.");
254-
ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window.");
255-
ImGui::BulletText("Alt to jump to the menu layer of a window.");
256-
ImGui::Unindent();
257-
}
258-
259244
//-----------------------------------------------------------------------------
260245
// [SECTION] Demo Window / ShowDemoWindow()
261246
//-----------------------------------------------------------------------------
247+
// - ShowDemoWindow()
262248
// - ShowDemoWindowWidgets()
263249
// - ShowDemoWindowLayout()
264250
// - ShowDemoWindowPopups()
@@ -267,29 +253,19 @@ void ImGui::ShowUserGuide()
267253
// - ShowDemoWindowInputs()
268254
//-----------------------------------------------------------------------------
269255

270-
// We split the contents of the big ShowDemoWindow() function into smaller functions
271-
// (because the link time of very large functions grow non-linearly)
272-
static void ShowDemoWindowWidgets();
273-
static void ShowDemoWindowLayout();
274-
static void ShowDemoWindowPopups();
275-
static void ShowDemoWindowTables();
276-
static void ShowDemoWindowColumns();
277-
static void ShowDemoWindowInputs();
278-
279256
// Demonstrate most Dear ImGui features (this is big function!)
280257
// You may execute this function to experiment with the UI and understand what it does.
281258
// You may then search for keywords in the code when you are interested by a specific feature.
282259
void ImGui::ShowDemoWindow(bool* p_open)
283260
{
284261
// Exceptionally add an extra assert here for people confused about initial Dear ImGui setup
285-
// Most ImGui functions would normally just crash if the context is missing.
262+
// Most functions would normally just crash if the context is missing.
286263
IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing dear imgui context. Refer to examples app!");
287264

288265
// Examples Apps (accessible from the "Examples" menu)
289266
static bool show_app_main_menu_bar = false;
290267
static bool show_app_dockspace = false;
291268
static bool show_app_documents = false;
292-
293269
static bool show_app_console = false;
294270
static bool show_app_log = false;
295271
static bool show_app_layout = false;
@@ -305,7 +281,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
305281
if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
306282
if (show_app_dockspace) ShowExampleAppDockSpace(&show_app_dockspace); // Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
307283
if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); // Process the Document app next, as it may also use a DockSpace()
308-
309284
if (show_app_console) ShowExampleAppConsole(&show_app_console);
310285
if (show_app_log) ShowExampleAppLog(&show_app_log);
311286
if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
@@ -318,7 +293,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
318293
if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
319294
if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
320295

321-
// Dear ImGui Apps (accessible from the "Tools" menu)
296+
// Dear ImGui Tools/Apps (accessible from the "Tools" menu)
322297
static bool show_app_metrics = false;
323298
static bool show_app_debug_log = false;
324299
static bool show_app_stack_tool = false;
@@ -383,10 +358,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
383358
}
384359

385360
// Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details.
386-
387361
// e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align)
388362
//ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f);
389-
390363
// e.g. Leave a fixed amount of width for labels (by passing a negative value), the rest goes to widgets.
391364
ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
392365

@@ -6517,6 +6490,40 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
65176490
ImGui::PopItemWidth();
65186491
}
65196492

6493+
//-----------------------------------------------------------------------------
6494+
// [SECTION] User Guide / ShowUserGuide()
6495+
//-----------------------------------------------------------------------------
6496+
6497+
void ImGui::ShowUserGuide()
6498+
{
6499+
ImGuiIO& io = ImGui::GetIO();
6500+
ImGui::BulletText("Double-click on title bar to collapse window.");
6501+
ImGui::BulletText(
6502+
"Click and drag on lower corner to resize window\n"
6503+
"(double-click to auto fit window to its contents).");
6504+
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
6505+
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
6506+
ImGui::BulletText("CTRL+Tab to select a window.");
6507+
if (io.FontAllowUserScaling)
6508+
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
6509+
ImGui::BulletText("While inputing text:\n");
6510+
ImGui::Indent();
6511+
ImGui::BulletText("CTRL+Left/Right to word jump.");
6512+
ImGui::BulletText("CTRL+A or double-click to select all.");
6513+
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
6514+
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
6515+
ImGui::BulletText("ESCAPE to revert.");
6516+
ImGui::Unindent();
6517+
ImGui::BulletText("With keyboard navigation enabled:");
6518+
ImGui::Indent();
6519+
ImGui::BulletText("Arrow keys to navigate.");
6520+
ImGui::BulletText("Space to activate a widget.");
6521+
ImGui::BulletText("Return to input text into a widget.");
6522+
ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window.");
6523+
ImGui::BulletText("Alt to jump to the menu layer of a window.");
6524+
ImGui::Unindent();
6525+
}
6526+
65206527
//-----------------------------------------------------------------------------
65216528
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
65226529
//-----------------------------------------------------------------------------

imgui_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace ImStb
213213
#endif
214214

215215
// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
216-
#define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__);
216+
#define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__)
217217
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
218218
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
219219
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)

0 commit comments

Comments
 (0)