mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 22:26:34 +00:00
Merge branch 'viewport' into docking
# Conflicts: # docs/CHANGELOG.txt # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
ddc3f8f069
@ -56,6 +56,17 @@ HOW TO UPDATE?
|
||||
the ID, as a convenience to avoid using the ### operator.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.67 (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Examples: SDL: changed the signature of ImGui_ImplSDL2_ProcessEvent() to use a const SDL_Event*. (#2187)
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.66 (Released 2018-11-22)
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -306,14 +306,18 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
|
||||
- examples: move ImGui::NewFrame() out of the backend _NewFrame() ?
|
||||
- viewport: make it possible to have no main/hosting viewport
|
||||
- viewport: We set ImGuiViewportFlags_NoFocusOnAppearing in a way that is required for GLFW/SDL binding, but could be handled better without
|
||||
on a custom e.g. Win32 bindings. It prevents newly dragged-out viewports from taking the focus, which makes ALT+F4 more ambiguous.
|
||||
- viewport: not focusing newly undocked viewport means clicking back on previous one doesn't bring OS window to front.
|
||||
- viewport: with platform decoration enabled, platform may force constraint (e.g. minimum size)
|
||||
- viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.)
|
||||
- viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for.
|
||||
- viewport: vulkan renderer implementation.
|
||||
- viewport: implicit Debug window can hog a zombie viewport (harmless, noisy?)
|
||||
- viewport: need to clarify how to use GetMousePos() from a user point of view.
|
||||
- platform: glfw: no support for ImGuiBackendFlags_HasMouseHoveredViewport.
|
||||
- platform: sdl: no support for ImGuiBackendFlags_HasMouseHoveredViewport. maybe we could use SDL_GetMouseFocus() / SDL_WINDOW_MOUSE_FOCUS if imgui could fallback on its heuristic when NoInputs is set
|
||||
- platform: sdl: no refresh of monitor/display (SDL doesn't seem to have an event for it).
|
||||
- platform: sdl: multi-viewport + minimized window seems to break mouse wheel events (at least under Win32).
|
||||
|
||||
- inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
|
||||
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
||||
|
@ -409,6 +409,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||
data->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", NULL, share_window);
|
||||
data->WindowOwned = true;
|
||||
viewport->PlatformHandle = (void*)data->Window;
|
||||
glfwSetWindowPos(data->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
||||
|
||||
// Install callbacks for secondary viewports
|
||||
glfwSetMouseButtonCallback(data->Window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||
@ -547,6 +548,12 @@ static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)
|
||||
return glfwGetWindowAttrib(data->Window, GLFW_FOCUSED) != 0;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplGlfw_GetWindowMinimized(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
return glfwGetWindowAttrib(data->Window, GLFW_ICONIFIED) != 0;
|
||||
}
|
||||
|
||||
#if GLFW_HAS_WINDOW_ALPHA
|
||||
static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||
{
|
||||
@ -667,6 +674,7 @@ static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
|
||||
platform_io.Platform_SetWindowFocus = ImGui_ImplGlfw_SetWindowFocus;
|
||||
platform_io.Platform_GetWindowFocus = ImGui_ImplGlfw_GetWindowFocus;
|
||||
platform_io.Platform_GetWindowMinimized = ImGui_ImplGlfw_GetWindowMinimized;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
|
||||
platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow;
|
||||
platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
|
||||
|
@ -10,6 +10,7 @@
|
||||
// Missing features:
|
||||
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
||||
// [ ] Platform: Gamepad support (need to use SDL_GameController API to fill the io.NavInputs[] value when ImGuiConfigFlags_NavEnableGamepad is set).
|
||||
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
@ -18,6 +19,7 @@
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'.
|
||||
// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
|
||||
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples.
|
||||
@ -82,7 +84,8 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
|
||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
||||
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
switch (event->type)
|
||||
@ -472,6 +475,12 @@ static bool ImGui_ImplSDL2_GetWindowFocus(ImGuiViewport* viewport)
|
||||
return (SDL_GetWindowFlags(data->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplSDL2_GetWindowMinimized(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
return (SDL_GetWindowFlags(data->Window) & SDL_WINDOW_MINIMIZED) != 0;
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
{
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
@ -543,6 +552,7 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
|
||||
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL2_SetWindowFocus;
|
||||
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL2_GetWindowFocus;
|
||||
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL2_GetWindowMinimized;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
|
||||
platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow;
|
||||
platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
|
||||
|
@ -24,4 +24,4 @@ IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* s
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||
|
@ -536,6 +536,13 @@ static bool ImGui_ImplWin32_GetWindowFocus(ImGuiViewport* viewport)
|
||||
return ::GetActiveWindow() == data->Hwnd;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplWin32_GetWindowMinimized(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
return ::IsIconic(data->Hwnd) != 0;
|
||||
}
|
||||
|
||||
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||
{
|
||||
// ::SetWindowTextA() doesn't properly handle UTF-8 so we explicitely convert our string.
|
||||
@ -683,6 +690,7 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplWin32_GetWindowSize;
|
||||
platform_io.Platform_SetWindowFocus = ImGui_ImplWin32_SetWindowFocus;
|
||||
platform_io.Platform_GetWindowFocus = ImGui_ImplWin32_GetWindowFocus;
|
||||
platform_io.Platform_GetWindowMinimized = ImGui_ImplWin32_GetWindowMinimized;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
|
||||
platform_io.Platform_SetWindowAlpha = ImGui_ImplWin32_SetWindowAlpha;
|
||||
platform_io.Platform_GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale;
|
||||
|
79
imgui.cpp
79
imgui.cpp
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (main code and documentation)
|
||||
|
||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||
@ -3491,7 +3491,6 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
|
||||
viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID;
|
||||
viewport->Idx = 0;
|
||||
viewport->CreatedPlatformWindow = true; // Set this flag so DestroyPlatformWindows() gives a chance for backend to receive DestroyWindow calls for the main viewport.
|
||||
g.Viewports.push_back(viewport);
|
||||
g.PlatformIO.MainViewport = g.Viewports[0]; // Make it accessible in public-facing GetPlatformIO() immediately (before the first call to EndFrame)
|
||||
g.PlatformIO.Viewports.push_back(g.Viewports[0]);
|
||||
@ -7406,7 +7405,7 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
|
||||
static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) || window->Viewport == viewport)
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) || window->Viewport == viewport || viewport->PlatformIsMinimized)
|
||||
return false;
|
||||
if (!viewport->GetRect().Contains(window->Rect()))
|
||||
return false;
|
||||
@ -7451,7 +7450,7 @@ static ImGuiViewportP* FindViewportHoveredFromPlatformWindowStack(const ImVec2 m
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoInputs) && viewport->GetRect().Contains(mouse_platform_pos))
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoInputs) && !viewport->PlatformIsMinimized && viewport->GetRect().Contains(mouse_platform_pos))
|
||||
if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount)
|
||||
best_candidate = viewport;
|
||||
}
|
||||
@ -7502,12 +7501,18 @@ static void ImGui::UpdateViewports()
|
||||
|
||||
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||
{
|
||||
if (g.PlatformIO.Platform_GetWindowMinimized && (n == 0 || viewport->CreatedPlatformWindow))
|
||||
viewport->PlatformIsMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
|
||||
|
||||
// Apply Position and Size (from Platform Window to ImGui) if requested.
|
||||
// We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
|
||||
if (viewport->PlatformRequestMove)
|
||||
viewport->Pos = g.PlatformIO.Platform_GetWindowPos(viewport);
|
||||
if (viewport->PlatformRequestResize)
|
||||
viewport->Size = g.PlatformIO.Platform_GetWindowSize(viewport);
|
||||
if (!viewport->PlatformIsMinimized)
|
||||
{
|
||||
if (viewport->PlatformRequestMove)
|
||||
viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport);
|
||||
if (viewport->PlatformRequestResize)
|
||||
viewport->Size = viewport->LastPlatformSize = g.PlatformIO.Platform_GetWindowSize(viewport);
|
||||
}
|
||||
|
||||
// Translate imgui windows when a Host Viewport has been moved
|
||||
ImVec2 delta = viewport->Pos - viewport->LastPos;
|
||||
@ -7718,6 +7723,10 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
||||
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
|
||||
}
|
||||
|
||||
// Fallback to default viewport
|
||||
if (window->Viewport == NULL)
|
||||
window->Viewport = main_viewport;
|
||||
|
||||
// Mark window as allowed to protrude outside of its viewport and into the current monitor
|
||||
// We need to take account of the possibility that mouse may become invalid.
|
||||
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
||||
@ -7727,8 +7736,6 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
||||
bool mouse_valid = IsMousePosValid(&mouse_ref);
|
||||
if ((window->Appearing || (flags & ImGuiWindowFlags_Tooltip)) && (!use_mouse_ref || mouse_valid))
|
||||
window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos());
|
||||
else
|
||||
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
|
||||
}
|
||||
else if (window->Viewport && window != window->Viewport->Window && window->Viewport->Window && !(flags & ImGuiWindowFlags_ChildWindow))
|
||||
{
|
||||
@ -7749,11 +7756,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to default viewport
|
||||
if (window->Viewport == NULL)
|
||||
window->Viewport = main_viewport;
|
||||
|
||||
if (window->ViewportAllowPlatformMonitorExtend < 0)
|
||||
if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
|
||||
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
|
||||
|
||||
// Update flags
|
||||
@ -7822,18 +7825,20 @@ void ImGui::UpdatePlatformWindows()
|
||||
if (g.PlatformIO.Renderer_CreateWindow != NULL)
|
||||
g.PlatformIO.Renderer_CreateWindow(viewport);
|
||||
viewport->LastNameHash = 0;
|
||||
viewport->RendererLastSize = viewport->Size;
|
||||
viewport->LastPlatformPos = viewport->LastPlatformSize = ImVec2(FLT_MAX, FLT_MAX); // By clearing those we'll enforce a call to Platform_SetWindowPos/Platform_SetWindowSize before Platform_ShowWindow
|
||||
viewport->LastRendererSize = viewport->Size;
|
||||
viewport->CreatedPlatformWindow = true;
|
||||
}
|
||||
|
||||
// Apply Position and Size (from ImGui to Platform/Renderer back-ends)
|
||||
if (!viewport->PlatformRequestMove)
|
||||
if ((viewport->LastPlatformPos.x != viewport->Pos.x || viewport->LastPlatformPos.y != viewport->Pos.y) && !viewport->PlatformRequestMove)
|
||||
g.PlatformIO.Platform_SetWindowPos(viewport, viewport->Pos);
|
||||
if (!viewport->PlatformRequestResize)
|
||||
if ((viewport->LastPlatformSize.x != viewport->Size.x || viewport->LastPlatformSize.y != viewport->Size.y) && !viewport->PlatformRequestResize)
|
||||
g.PlatformIO.Platform_SetWindowSize(viewport, viewport->Size);
|
||||
if (g.PlatformIO.Renderer_SetWindowSize && (viewport->RendererLastSize.x != viewport->Size.x || viewport->RendererLastSize.y != viewport->Size.y))
|
||||
if ((viewport->LastRendererSize.x != viewport->Size.x || viewport->LastRendererSize.y != viewport->Size.y) && g.PlatformIO.Renderer_SetWindowSize)
|
||||
g.PlatformIO.Renderer_SetWindowSize(viewport, viewport->Size);
|
||||
viewport->RendererLastSize = viewport->Size;
|
||||
viewport->LastPlatformPos = viewport->Pos;
|
||||
viewport->LastPlatformSize = viewport->LastRendererSize = viewport->Size;
|
||||
|
||||
// Update title bar (if it changed)
|
||||
if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(viewport->Window))
|
||||
@ -7873,11 +7878,12 @@ void ImGui::UpdatePlatformWindows()
|
||||
}
|
||||
|
||||
// Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport.
|
||||
// When setting Platform_GetWindowFocus, it is expected that the platform back-end can handle calls without crashing if it doesn't have data stored.
|
||||
if (g.PlatformIO.Platform_GetWindowFocus != NULL)
|
||||
{
|
||||
ImGuiViewportP* focused_viewport = NULL;
|
||||
for (int i = 0; i < g.Viewports.Size && focused_viewport == NULL; i++)
|
||||
if (g.Viewports[i]->PlatformUserData != NULL || g.Viewports[i]->PlatformHandle != NULL || g.Viewports[i]->CreatedPlatformWindow)
|
||||
if (g.Viewports[i]->PlatformUserData != NULL || g.Viewports[i]->PlatformHandle != NULL)
|
||||
if (g.PlatformIO.Platform_GetWindowFocus(g.Viewports[i]))
|
||||
focused_viewport = g.Viewports[i];
|
||||
if (focused_viewport && g.PlatformLastFocusedViewport != focused_viewport->ID)
|
||||
@ -7960,9 +7966,9 @@ void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* render
|
||||
void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (viewport->CreatedPlatformWindow && g.PlatformIO.Renderer_DestroyWindow)
|
||||
if (g.PlatformIO.Renderer_DestroyWindow)
|
||||
g.PlatformIO.Renderer_DestroyWindow(viewport);
|
||||
if (viewport->CreatedPlatformWindow && g.PlatformIO.Platform_DestroyWindow)
|
||||
if (g.PlatformIO.Platform_DestroyWindow)
|
||||
g.PlatformIO.Platform_DestroyWindow(viewport);
|
||||
IM_ASSERT(viewport->RendererUserData == NULL);
|
||||
IM_ASSERT(viewport->PlatformUserData == NULL);
|
||||
@ -7973,15 +7979,15 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
|
||||
|
||||
void ImGui::DestroyPlatformWindows()
|
||||
{
|
||||
// We call the destroy window on the main viewport (index 0) to give a chance to the back-end to clear any data
|
||||
// have stored in e.g. PlatformUserData, RendererUserData. It can be convenient for the platform back-end code to
|
||||
// store something in the main viewport, in order for e.g. the mouse handling code to work in a more generic manner.
|
||||
// We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the back-end
|
||||
// to clear any data they may have stored in e.g. PlatformUserData, RendererUserData.
|
||||
// It is convenient for the platform back-end code to store something in the main viewport, in order for e.g. the mouse handling
|
||||
// code to operator a consistent manner.
|
||||
// It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without
|
||||
// crashing if it doesn't have data stored.
|
||||
ImGuiContext& g = *GImGui;
|
||||
for (int i = 0; i < g.Viewports.Size; i++)
|
||||
if (g.Viewports[i]->CreatedPlatformWindow)
|
||||
DestroyPlatformWindow(g.Viewports[i]);
|
||||
DestroyPlatformWindow(g.Viewports[i]);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -12986,7 +12992,8 @@ static void RenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewp
|
||||
|
||||
ImVec2 scale = bb.GetSize() / viewport->Size;
|
||||
ImVec2 off = bb.Min - viewport->Pos * scale;
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, 0.40f));
|
||||
float alpha_mul = viewport->PlatformIsMinimized ? 0.30f : 1.00f;
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* thumb_window = g.Windows[i];
|
||||
@ -13004,13 +13011,13 @@ static void RenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewp
|
||||
thumb_r_scaled.ClipWithFull(bb);
|
||||
title_r_scaled.ClipWithFull(bb);
|
||||
const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight);
|
||||
window->DrawList->AddRectFilled(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_WindowBg));
|
||||
window->DrawList->AddRectFilled(title_r_scaled.Min, title_r_scaled.Max, ImGui::GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg));
|
||||
window->DrawList->AddRect(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_Border));
|
||||
window->DrawList->AddRectFilled(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_WindowBg, alpha_mul));
|
||||
window->DrawList->AddRectFilled(title_r_scaled.Min, title_r_scaled.Max, ImGui::GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul));
|
||||
window->DrawList->AddRect(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
|
||||
if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(thumb_window))
|
||||
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r_scaled.Min, ImGui::GetColorU32(ImGuiCol_Text), window_for_title->Name, ImGui::FindRenderedTextEnd(window_for_title->Name));
|
||||
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r_scaled.Min, ImGui::GetColorU32(ImGuiCol_Text, alpha_mul), window_for_title->Name, ImGui::FindRenderedTextEnd(window_for_title->Name));
|
||||
}
|
||||
draw_list->AddRect(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border));
|
||||
draw_list->AddRect(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
|
||||
}
|
||||
|
||||
void ImGui::ShowViewportThumbnails()
|
||||
@ -13192,10 +13199,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGuiWindowFlags flags = viewport->Flags;
|
||||
ImGui::BulletText("Pos: (%.0f,%.0f), Size: (%.0f,%.0f), Monitor: %d, DpiScale: %.0f%%", viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, viewport->PlatformMonitor, viewport->DpiScale * 100.0f);
|
||||
if (viewport->Idx > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Reset Pos")) { viewport->Pos = ImVec2(200,200); if (viewport->Window) viewport->Window->Pos = ImVec2(200,200); } }
|
||||
ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s", viewport->Flags,
|
||||
ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s%s", viewport->Flags,
|
||||
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
|
||||
(flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "",
|
||||
(flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "");
|
||||
(flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", viewport->PlatformIsMinimized ? ", PlatformIsMinimized" : "");
|
||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
||||
Funcs::NodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
||||
|
7
imgui.h
7
imgui.h
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (headers)
|
||||
|
||||
// See imgui.cpp file for documentation.
|
||||
@ -23,8 +23,8 @@
|
||||
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY00 then bounced up to XYY01 when release tagging happens)
|
||||
#define IMGUI_VERSION "1.66"
|
||||
#define IMGUI_VERSION_NUM 16601
|
||||
#define IMGUI_VERSION "1.67 WIP"
|
||||
#define IMGUI_VERSION_NUM 16700
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
|
||||
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
||||
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
||||
@ -2139,6 +2139,7 @@ struct ImGuiPlatformIO
|
||||
ImVec2 (*Platform_GetWindowSize)(ImGuiViewport* vp);
|
||||
void (*Platform_SetWindowFocus)(ImGuiViewport* vp); // Move window to front and set input focus
|
||||
bool (*Platform_GetWindowFocus)(ImGuiViewport* vp);
|
||||
bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp);
|
||||
void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* title);
|
||||
void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha); // (Optional) Setup window transparency
|
||||
void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // (Optional) Setup for render (platform side)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (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!
|
||||
@ -224,28 +224,29 @@ static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a)
|
||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||
|
||||
// Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer
|
||||
// Creation/Erasure invalidate all pointers, but indexes are valid as long as the object lifetime.
|
||||
// Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
|
||||
// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
|
||||
typedef int ImPoolIdx;
|
||||
template<typename T>
|
||||
struct IMGUI_API ImPool
|
||||
{
|
||||
ImVector<T> Data; // Contiguous data
|
||||
ImGuiStorage Map; // ID->Index
|
||||
int FreeIdx; // Next free idx to use
|
||||
ImPoolIdx FreeIdx; // Next free idx to use
|
||||
|
||||
ImPool() { FreeIdx = 0; }
|
||||
~ImPool() { Clear(); }
|
||||
T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
|
||||
T* GetByIndex(int n) { return &Data[n]; }
|
||||
int GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (int)(p - Data.Data); }
|
||||
T* GetByIndex(ImPoolIdx n) { return &Data[n]; }
|
||||
ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
|
||||
T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
||||
void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; }
|
||||
T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
|
||||
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||||
void Remove(ImGuiID key, int idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
||||
void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
||||
void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
|
||||
int GetSize() const { return Data.Size; }
|
||||
};
|
||||
typedef int ImPoolIdx;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
@ -665,13 +666,16 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
||||
float LastAlpha;
|
||||
int PlatformMonitor;
|
||||
bool PlatformIsMinimized;
|
||||
ImGuiWindow* Window; // Set when the viewport is owned by a window
|
||||
ImDrawList* OverlayDrawList; // For convenience, a draw list we can render to that's always rendered last (we use it to draw software mouse cursor when io.MouseDrawCursor is set)
|
||||
ImDrawData DrawDataP;
|
||||
ImDrawDataBuilder DrawDataBuilder;
|
||||
ImVec2 RendererLastSize;
|
||||
ImVec2 LastPlatformPos;
|
||||
ImVec2 LastPlatformSize;
|
||||
ImVec2 LastRendererSize;
|
||||
|
||||
ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; CreatedPlatformWindow = false; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; Window = NULL; OverlayDrawList = NULL; RendererLastSize = ImVec2(-1.0f,-1.0f); }
|
||||
ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; CreatedPlatformWindow = false; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; PlatformIsMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
||||
~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); }
|
||||
ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||
ImVec2 GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66
|
||||
// dear imgui, v1.67 WIP
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user