Merge branch 'master' into docking

# Conflicts:
#	docs/CHANGELOG.txt
This commit is contained in:
ocornut 2022-11-15 15:40:54 +01:00
commit 94e850fd6f
12 changed files with 132 additions and 110 deletions

View File

@ -13,9 +13,10 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2022-11-10: Fixed rendering when a depth buffer is enabled. Added 'WGPUTextureFormat depth_format' parameter to ImGui_ImplWGPU_Init().
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-11-29: Passing explicit buffer sizes to wgpuRenderPassEncoderSetVertexBuffer()/wgpuRenderPassEncoderSetIndexBuffer().
// 2021-08-24: Fix for latest specs.
// 2021-08-24: Fixed for latest specs.
// 2021-05-24: Add support for draw_data->FramebufferScale.
// 2021-05-19: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
// 2021-05-16: Update to latest WebGPU specs (compatible with Emscripten 2.0.20 and Chrome Canary 92).
@ -34,6 +35,7 @@ extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0);
static WGPUDevice g_wgpuDevice = nullptr;
static WGPUQueue g_defaultQueue = nullptr;
static WGPUTextureFormat g_renderTargetFormat = WGPUTextureFormat_Undefined;
static WGPUTextureFormat g_depthStencilFormat = WGPUTextureFormat_Undefined;
static WGPURenderPipeline g_pipelineState = nullptr;
struct RenderResources
@ -602,12 +604,11 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
// Create depth-stencil State
WGPUDepthStencilState depth_stencil_state = {};
depth_stencil_state.depthBias = 0;
depth_stencil_state.depthBiasClamp = 0;
depth_stencil_state.depthBiasSlopeScale = 0;
depth_stencil_state.format = g_depthStencilFormat;
depth_stencil_state.depthWriteEnabled = false;
// Configure disabled depth-stencil state
graphics_pipeline_desc.depthStencil = nullptr;
graphics_pipeline_desc.depthStencil = g_depthStencilFormat == WGPUTextureFormat_Undefined ? nullptr : &depth_stencil_state;
g_pipelineState = wgpuDeviceCreateRenderPipeline(g_wgpuDevice, &graphics_pipeline_desc);
@ -658,7 +659,7 @@ void ImGui_ImplWGPU_InvalidateDeviceObjects()
SafeRelease(g_pFrameResources[i]);
}
bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format)
bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format)
{
// Setup backend capabilities flags
ImGuiIO& io = ImGui::GetIO();
@ -668,6 +669,7 @@ bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextur
g_wgpuDevice = device;
g_defaultQueue = wgpuDeviceGetQueue(g_wgpuDevice);
g_renderTargetFormat = rt_format;
g_depthStencilFormat = depth_format;
g_pFrameResources = new FrameResources[num_frames_in_flight];
g_numFramesInFlight = num_frames_in_flight;
g_frameIndex = UINT_MAX;

View File

@ -6,7 +6,7 @@
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
@ -15,7 +15,7 @@
#include "imgui.h" // IMGUI_IMPL_API
#include <webgpu/webgpu.h>
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format);
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined);
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);

View File

@ -99,11 +99,26 @@ Other changes:
-----------------------------------------------------------------------
VERSION 1.89 WIP (In Progress)
VERSION 1.89 (Released 2022-11-15)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.89
Breaking changes:
- Layout: Obsoleted using SetCursorPos()/SetCursorScreenPos() to extend parent window/cell boundaries. (#5548)
This relates to when moving the cursor position beyond current boundaries WITHOUT submitting an item.
- Previously this would make the window content size ~200x200:
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End();
- Instead, please submit an item:
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + Dummy(ImVec2(0,0)) + End();
- Alternative:
Begin(...) + Dummy(ImVec2(200,200)) + End();
Content size is now only extended when submitting an item.
With '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' this will now be detected and assert.
Without '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' this will silently be fixed until we obsolete it.
(This incorrect pattern has been mentioned or suggested in: #4510, #3355, #1760, #1490, #4152, #150,
threads have been amended to refer to this issue).
- Renamed and merged keyboard modifiers key enums and flags into a same set: (#4921, #456)
- ImGuiKey_ModCtrl and ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl
- ImGuiKey_ModShift and ImGuiModFlags_Shift -> ImGuiMod_Shift
@ -128,11 +143,11 @@ Breaking changes:
- Custom backends not writing to io.NavInputs[] -> no issue.
- Custom backends writing to io.NavInputs[] -> will build and convert gamepad inputs, unless IMGUI_DISABLE_OBSOLETE_KEYIO is defined. Need fixing!
- TL;DR: Backends should call io.AddKeyEvent()/io.AddKeyAnalogEvent() with ImGuiKey_GamepadXXX values instead of filling io.NavInput[].
That data was essentially 1.60's attempt to combine keyboard and gamepad inputs with named
The ImGuiNavInput enum was essentially 1.60's attempt to combine keyboard and gamepad inputs with named
semantic, but the additional indirection and copy added complexity and got in the way of other
incoming work. User's code (other than backends) should not be affected, unless you have custom
widgets intercepting navigation events via the named enums (in which case you can upgrade your code).
- Removed runtime patching of invalid "%f"/"%.0f" types of format strings for DragInt()/SliderInt().
- DragInt()/SliderInt(): Removed runtime patching of invalid "%f"/"%.0f" types of format strings.
This was obsoleted in 1.61 (May 2018). See 1.61 changelog for details.
- Changed signature of ImageButton() function: (#5533, #4471, #2464, #1390)
- Added 'const char* str_id' parameter + removed 'int frame_padding = -1' parameter.
@ -146,34 +161,15 @@ Breaking changes:
- Removed the bizarre legacy default argument for 'TreePush(const void* ptr = NULL)'. (#1057)
Must always pass a pointer value explicitly, NULL/nullptr is ok but require cast, e.g. TreePush((void*)nullptr);
If you used TreePush() replace with TreePush((void*)NULL);
- Commented out redirecting functions/enums names that were marked obsolete in 1.77 and 1.79 (August 2020): (#3361)
- DragScalar(), DragScalarN(), DragFloat(), DragFloat2(), DragFloat3(), DragFloat4()
- SliderScalar(), SliderScalarN(), SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4()
- For old signatures ending with (..., const char* format, float power = 1.0f) -> use (..., format ImGuiSliderFlags_Logarithmic) if power != 1.0f.
- BeginPopupContextWindow(const char*, ImGuiMouseButton, bool) -> use BeginPopupContextWindow(const char*, ImGuiPopupFlags)
- OpenPopupContextItem() (briefly existed from 1.77 to 1.79) -> use OpenPopupOnItemClick()
- Obsoleted using SetCursorPos()/SetCursorScreenPos() to extend parent window/cell boundaries. (#5548)
This relates to when moving the cursor position beyond current boundaries WITHOUT submitting an item.
- Previously this would make the window content size ~200x200:
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End();
- Instead, please submit an item:
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + Dummy(ImVec2(0,0)) + End();
- Alternative:
Begin(...) + Dummy(ImVec2(200,200)) + End();
Content size is now only extended when submitting an item.
With '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' this will now be detected and assert.
Without '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' this will silently be fixed until we obsolete it.
(This incorrect pattern has been mentioned or suggested in: #4510, #3355, #1760, #1490, #4152, #150,
threads have been amended to refer to this issue).
- Removed support for 1.42-era IMGUI_DISABLE_INCLUDE_IMCONFIG_H / IMGUI_INCLUDE_IMCONFIG_H. (#255)
They only made sense before we could use IMGUI_USER_CONFIG.
Other Changes:
- Popups & Modals: fixed nested Begin() being erroneously input-inhibited. While it is
unusual, you can nest a Begin() inside a popup or modal, it is occasionally useful to
achieve certains things (e.g. some ways to implement suggestion popup #718, #4461).
- Popups & Modals: fixed nested Begin() inside a popup being erroneously input-inhibited.
While it is unusual, you can nest a Begin() inside a popup or modal, it is occasionally
useful to achieve certain things (e.g. to implement suggestion popups #718, #4461).
- Inputs: Standard widgets now claim for key/button ownership and test for them.
- Fixes scenario where e.g. a Popup with a Selectable() reacting on mouse down
(e.g. double click) closes, and behind it is another window with an item reacting
@ -186,9 +182,11 @@ Other Changes:
systems while letting early adopters adopters toy with internals.
(#456, #2637, #2620, #2891, #3370, #3724, #4828, #5108, #5242, #5641)
- Scrolling: Tweak mouse-wheel locked window timer so it is shorter but also gets reset
whenever scrolling again (#2604).
whenever scrolling again. Modulate for small (sub-pixel) amounts. (#2604)
- Scrolling: Mitigated issue where multi-axis mouse-wheel inputs (usually from touch pad
events) are incorrectly locking scrolling in a parent window. (#4559, #3795, #2604)
- Scrolling: Exposed SetNextWindowScroll() in public API. Useful to remove a scrolling
delay in some situations where e.g. windows need to be synched. (#1526)
- InputText: added experimental io.ConfigInputTextEnterKeepActive feature to make pressing
Enter keep the input active and select all text.
- InputText: numerical fields automatically accept full-width characters (U+FF01..U+FF5E)
@ -202,7 +200,7 @@ Other Changes:
- IsItemHovered: Added ImGuiHoveredFlags_DelayNormal and ImGuiHoveredFlags_DelayShort flags,
allowing to introduce a shared delay for tooltip idioms. The delays are respectively
io.HoverDelayNormal (default to 0.30f) and io.HoverDelayFast (default to 0.10f). (#1485)
- IsItemHovered: Added ImGuiHoveredFlags_NoSharedDelay to disable sharing delays between itemm,
- IsItemHovered: Added ImGuiHoveredFlags_NoSharedDelay to disable sharing delays between items,
so moving from one item to a nearby one will requires delay to elapse again. (#1485)
- Tables: activating an ID (e.g. clicking button inside) column doesn't prevent columns
output flags from having ImGuiTableColumnFlags_IsHovered set. (#2957)
@ -231,15 +229,15 @@ Other Changes:
the gap between a menu item inside a window and a child-menu in a secondary viewport. (#5614)
- Menus: Fixed using IsItemHovered()/IsItemClicked() on BeginMenu(). (#5775)
- Menus, Popups: Experimental fix for issue where clicking on an open BeginMenu() item called from
a window which is neither a popup neither a menu used to incorrectly close and reopen the menu.
(the fix may have side-effect so labelld as experimental as we may need to revert) (#5775)
a window which is neither a popup neither a menu used to incorrectly close and reopen the menu
(the fix may have side-effect and is labelld as experimental as we may need to revert). (#5775)
- Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item
in parent window when the parent is not a popup. (#5730)
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
- Menus, Nav: Fixed using left/right navigation when appending to an existing menu (multiple
BeginMenu() call with same names). (#1207)
- Menus: Fixed a one-frame issue where SetNextWindowXXX data are not consumed by a BeginMenu()
returning false (specifically )
returning false.
- Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate.
- Nav: Pressing Space/GamepadFaceDown on a repeating button uses the same repeating rate as a mouse hold.
- Nav: Fixed an issue opening a menu with Right key from a non-menu window.
@ -271,6 +269,9 @@ Other Changes:
(e.g. for multi-viewport support) and don't capture mouse when drag and dropping. (#5710)
- Backends: Win32: Convert WM_CHAR values with MultiByteToWideChar() when window class was
registered as MBCS (not Unicode). (#5725, #1807, #471, #2815, #1060) [@or75, @ocornut]
- Backends: OSX: Fixed mouse inputs on flipped views. (#5756) [@Nemirtingas]
- Backends: OSX: Fixed mouse coordinate before clicking on the host window. (#5842) [@maezawa-akira]
- Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]
- Backends: OpenGL3: Reverted use of glBufferSubData(), too many corruptions issues were reported,
and old leaks issues seemingly can't be reproed with Intel drivers nowadays (revert earlier changes).
(#4468, #4504, #3381, #2981, #4825, #4832, #5127).
@ -278,9 +279,7 @@ Other Changes:
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
- Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz]
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738).
- Backends: OSX: Fixed mouse inputs on flipped views. (#5756) [@Nemirtingas]
- Backends: OSX: Fixed mouse coordinate before clicking on the host window. (#5842) [@maezawa-akira]
- Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
Docking+Viewports Branch:

View File

@ -506,6 +506,14 @@ This approach is relatively easy and functional but comes with two issues:
- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides.
Please note that if you are not using multi-viewports with multi-monitors using different DPI scales, you can ignore that and use the simpler technique recommended at the top.
On Windows, in addition to scaling the font size (make sure to round to an integer) and using `style.ScaleAllSizes()`, you will need to inform Windows that your application is DPI aware. If this is not done, Windows will scale the application window and the UI text will be blurry. Potential solutions to indicate DPI awareness on Windows are:
- For SDL: the flag `SDL_WINDOW_ALLOW_HIGHDPI` needs to be passed to `SDL_CreateWindow()``.
- For GLFW: this is done automatically.
- For other Windows projects with other backends, or wrapper projects:
- We provide a `ImGui_ImplWin32_EnableDpiAwareness()` helper method in the Win32 backend.
- Use an [application manifest file](https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process) to set the `<dpiAware>` property.
### Q: How can I load a different font than the default?
Use the font atlas to load the TTF/OTF file you want:

View File

@ -76,7 +76,7 @@ int main(int, char**)
// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOther(window, true);
ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm);
ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm, WGPUTextureFormat_Undefined);
// Load Fonts
// - 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.

119
imgui.cpp
View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (main code and documentation)
// Help:
@ -962,7 +962,7 @@ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend)
static const float WINDOWS_HOVER_PADDING = 4.0f; // Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow().
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 0.80f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 0.70f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
// Docking
static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
@ -4506,10 +4506,13 @@ static void ImGui::UpdateMouseInputs()
}
}
static void LockWheelingWindow(ImGuiWindow* window)
static void LockWheelingWindow(ImGuiWindow* window, float wheel_amount)
{
ImGuiContext& g = *GImGui;
g.WheelingWindowReleaseTimer = window ? WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER : 0.0f;
if (window)
g.WheelingWindowReleaseTimer = ImMin(g.WheelingWindowReleaseTimer + ImAbs(wheel_amount) * WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER, WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER);
else
g.WheelingWindowReleaseTimer = 0.0f;
if (g.WheelingWindow == window)
return;
IMGUI_DEBUG_LOG_IO("LockWheelingWindow() \"%s\"\n", window ? window->Name : "NULL");
@ -4528,7 +4531,7 @@ void ImGui::UpdateMouseWheel()
if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold)
g.WheelingWindowReleaseTimer = 0.0f;
if (g.WheelingWindowReleaseTimer <= 0.0f)
LockWheelingWindow(NULL);
LockWheelingWindow(NULL, 0.0f);
}
ImVec2 wheel;
@ -4546,7 +4549,7 @@ void ImGui::UpdateMouseWheel()
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
if (wheel.y != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
{
LockWheelingWindow(mouse_window);
LockWheelingWindow(mouse_window, wheel.y);
ImGuiWindow* window = mouse_window;
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
const float scale = new_font_scale / window->FontWindowScale;
@ -4585,7 +4588,7 @@ void ImGui::UpdateMouseWheel()
window = window->ParentWindow;
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
{
LockWheelingWindow(mouse_window);
LockWheelingWindow(mouse_window, wheel.y);
float max_step = window->InnerRect.GetHeight() * 0.67f;
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
SetScrollY(window, window->Scroll.y - wheel.y * scroll_step);
@ -4600,7 +4603,7 @@ void ImGui::UpdateMouseWheel()
window = window->ParentWindow;
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
{
LockWheelingWindow(mouse_window);
LockWheelingWindow(mouse_window, wheel.x);
float max_step = window->InnerRect.GetWidth() * 0.67f;
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
SetScrollX(window, window->Scroll.x - wheel.x * scroll_step);
@ -8650,6 +8653,53 @@ ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord)
return routing_data;
}
// Current score encoding (lower is highest priority):
// - 0: ImGuiInputFlags_RouteGlobalHigh
// - 1: ImGuiInputFlags_RouteFocused (if item active)
// - 2: ImGuiInputFlags_RouteGlobal
// - 3+: ImGuiInputFlags_RouteFocused (if window in focus-stack)
// - 254: ImGuiInputFlags_RouteGlobalLow
// - 255: never route
// 'flags' should include an explicit routing policy
static int CalcRoutingScore(ImGuiWindow* location, ImGuiID owner_id, ImGuiInputFlags flags)
{
if (flags & ImGuiInputFlags_RouteFocused)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* focused = g.NavWindow;
// ActiveID gets top priority
// (we don't check g.ActiveIdUsingAllKeys here. Routing is applied but if input ownership is tested later it may discard it)
if (owner_id != 0 && g.ActiveId == owner_id)
return 1;
// Score based on distance to focused window (lower is better)
// Assuming both windows are submitting a routing request,
// - When Window....... is focused -> Window scores 3 (best), Window/ChildB scores 255 (no match)
// - When Window/ChildB is focused -> Window scores 4, Window/ChildB scores 3 (best)
// Assuming only WindowA is submitting a routing request,
// - When Window/ChildB is focused -> Window scores 4 (best), Window/ChildB doesn't have a score.
if (focused != NULL && focused->RootWindow == location->RootWindow)
for (int next_score = 3; focused != NULL; next_score++)
{
if (focused == location)
{
IM_ASSERT(next_score < 255);
return next_score;
}
focused = (focused->RootWindow != focused) ? focused->ParentWindow : NULL; // FIXME: This could be later abstracted as a focus path
}
return 255;
}
// ImGuiInputFlags_RouteGlobalHigh is default, so calls without flags are not conditional
if (flags & ImGuiInputFlags_RouteGlobal)
return 2;
if (flags & ImGuiInputFlags_RouteGlobalLow)
return 254;
return 0;
}
// Request a desired route for an input chord (key + mods).
// Return true if the route is available this frame.
// - Routes and key ownership are attributed at the beginning of next frame based on best score and mod state.
@ -8671,54 +8721,7 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
if (flags & ImGuiInputFlags_RouteAlways)
return true;
// Current score encoding (lower is highest priority):
// - 0: ImGuiInputFlags_RouteGlobalHigh
// - 1: ImGuiInputFlags_RouteFocused (if item active)
// - 2: ImGuiInputFlags_RouteGlobal
// - 3+: ImGuiInputFlags_RouteFocused (if window in focus-stack)
// - 254: ImGuiInputFlags_RouteGlobalLow
// - 255: none
int score = 255;
if (flags & ImGuiInputFlags_RouteFocused)
{
ImGuiWindow* location = g.CurrentWindow;
ImGuiWindow* focused = g.NavWindow;
if (g.ActiveId != 0 && g.ActiveId == owner_id)
{
// ActiveID gets top priority
// (we don't check g.ActiveIdUsingAllKeys here. Routing is applied but if input ownership is tested later it may discard it)
score = 1;
}
else if (focused != NULL && focused->RootWindow == location->RootWindow) // Early out
{
// Score based on distance to focused window (lower is better)
// Assuming both windows are submitting a routing request,
// - When Window....... is focused -> Window scores 3 (best), Window/ChildB scores 255 (no match)
// - When Window/ChildB is focused -> Window scores 4, Window/ChildB scores 3 (best)
// Assuming only WindowA is submitting a routing request,
// - When Window/ChildB is focused -> Window scores 4 (best), Window/ChildB doesn't have a score.
for (int next_score = 3; focused != NULL; next_score++)
{
if (focused == location)
{
IM_ASSERT(next_score < 255);
score = (ImU8)next_score;
break;
}
focused = (focused->RootWindow != focused) ? focused->ParentWindow : NULL; // FIXME: This could be later abstracted as a focus path
}
}
}
else
{
if (flags & ImGuiInputFlags_RouteGlobal)
score = 2;
else if (flags & ImGuiInputFlags_RouteGlobalLow)
score = 254;
else // ImGuiInputFlags_RouteGlobalHigh is default, so call to SetShorcutRouting() without no flags are not conditional
score = 0;
}
const int score = CalcRoutingScore(g.CurrentWindow, owner_id, flags);
if (score == 255)
return false;
@ -8957,6 +8960,10 @@ void ImGui::ResetMouseDragDelta(ImGuiMouseButton button)
g.IO.MouseClickedPos[button] = g.IO.MousePos;
}
// Get desired mouse cursor shape.
// Important: this is meant to be used by a platform backend, it is reset in ImGui::NewFrame(),
// updated during the frame, and locked in EndFrame()/Render().
// If you use software rendering by setting io.MouseDrawCursor then Dear ImGui will render those for you
ImGuiMouseCursor ImGui::GetMouseCursor()
{
ImGuiContext& g = *GImGui;

15
imgui.h
View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (headers)
// Help:
@ -22,8 +22,8 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89 WIP"
#define IMGUI_VERSION_NUM 18837
#define IMGUI_VERSION "1.89"
#define IMGUI_VERSION_NUM 18900
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch
@ -177,7 +177,7 @@ typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor shape
typedef int ImGuiSortDirection; // -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending)
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor()
@ -370,6 +370,7 @@ namespace ImGui
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis).
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
IMGUI_API void SetNextWindowViewport(ImGuiID viewport_id); // set next window viewport
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
@ -391,6 +392,8 @@ namespace ImGui
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be overridden with SetNextWindowContentSize(), in window coordinates
// Windows Scrolling
// - Any change of Scroll will be applied at the beginning of next frame in the first call to Begin().
// - You may instead use SetNextWindowScroll() prior to calling Begin() to avoid this delay, as an alternative to using SetScrollX()/SetScrollY().
IMGUI_API float GetScrollX(); // get scrolling amount [0 .. GetScrollMaxX()]
IMGUI_API float GetScrollY(); // get scrolling amount [0 .. GetScrollMaxY()]
IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0 .. GetScrollMaxX()]
@ -940,8 +943,8 @@ namespace ImGui
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); //
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired cursor type
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired mouse cursor shape
IMGUI_API void SetNextFrameWantCaptureMouse(bool want_capture_mouse); // Override io.WantCaptureMouse flag next frame (said flag is left for your application to handle, typical when true it instucts your app to ignore inputs). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse;" after the next NewFrame() call.
// Clipboard Utilities

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (demo code)
// Help:
@ -6815,6 +6815,8 @@ struct ExampleAppConsole
if (copy_to_clipboard)
ImGui::LogFinish();
// Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame.
// Using a scrollbar or mouse-wheel will take away from the bottom edge.
if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
ImGui::SetScrollHereY(1.0f);
ScrollToBottom = false;
@ -7123,6 +7125,8 @@ struct ExampleAppLog
}
ImGui::PopStyleVar();
// Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame.
// Using a scrollbar or mouse-wheel will take away from the bottom edge.
if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
ImGui::SetScrollHereY(1.0f);
}

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (drawing and font code)
/*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (internal structures/api)
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
@ -2962,7 +2962,6 @@ namespace ImGui
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
// Scrolling
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is
IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x);
IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y);
IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio);

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (tables and columns code)
/*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89 WIP
// dear imgui, v1.89
// (widgets code)
/*