mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
Viewports: Renamed GetRect() to GetMainRect() in prevision for work rect. Comments
This commit is contained in:
parent
871727dd2f
commit
f032ad6b1f
28
imgui.cpp
28
imgui.cpp
@ -3851,7 +3851,7 @@ void ImGui::NewFrame()
|
||||
IM_ASSERT(g.Font->IsLoaded());
|
||||
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
virtual_space.Add(g.Viewports[n]->GetRect());
|
||||
virtual_space.Add(g.Viewports[n]->GetMainRect());
|
||||
g.DrawListSharedData.ClipRectFullscreen = ImVec4(virtual_space.Min.x, virtual_space.Min.y, virtual_space.Max.x, virtual_space.Max.y);
|
||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||
g.DrawListSharedData.SetCircleSegmentMaxError(g.Style.CircleSegmentMaxError);
|
||||
@ -4376,7 +4376,7 @@ static void ImGui::EndFrameDrawDimmedBackgrounds()
|
||||
float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
|
||||
ImRect bb = window->Rect();
|
||||
bb.Expand(g.FontSize);
|
||||
if (bb.Contains(window->Viewport->GetRect())) // If a window fits the entire viewport, adjust its highlight inward
|
||||
if (bb.Contains(window->Viewport->GetMainRect())) // If a window fits the entire viewport, adjust its highlight inward
|
||||
{
|
||||
bb.Expand(-g.FontSize - 1.0f);
|
||||
rounding = window->WindowRounding;
|
||||
@ -4523,7 +4523,7 @@ void ImGui::Render()
|
||||
if (mouse_cursor_size.x > 0.0f && mouse_cursor_size.y > 0.0f)
|
||||
{
|
||||
float scale = g.Style.MouseCursorScale * viewport->DpiScale;
|
||||
if (viewport->GetRect().Overlaps(ImRect(g.IO.MousePos, g.IO.MousePos + ImVec2(mouse_cursor_size.x + 2, mouse_cursor_size.y + 2) * scale)))
|
||||
if (viewport->GetMainRect().Overlaps(ImRect(g.IO.MousePos, g.IO.MousePos + ImVec2(mouse_cursor_size.x + 2, mouse_cursor_size.y + 2) * scale)))
|
||||
RenderMouseCursor(GetForegroundDrawList(viewport), g.IO.MousePos, scale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
|
||||
}
|
||||
|
||||
@ -4648,7 +4648,7 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
|
||||
const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
|
||||
if (!rect_for_touch.Contains(g.IO.MousePos))
|
||||
return false;
|
||||
if (!g.MouseViewport->GetRect().Overlaps(rect_clipped))
|
||||
if (!g.MouseViewport->GetMainRect().Overlaps(rect_clipped))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -6100,7 +6100,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// Late create viewport if we don't fit within our current host viewport.
|
||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_Minimized))
|
||||
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
||||
if (!window->Viewport->GetMainRect().Contains(window->Rect()))
|
||||
{
|
||||
// This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||
//ImGuiViewport* old_viewport = window->Viewport;
|
||||
@ -6182,7 +6182,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// Clamp position/size so window stays visible within its viewport or monitor
|
||||
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
||||
ImRect viewport_rect = window->Viewport->GetRect();
|
||||
ImRect viewport_rect = window->Viewport->GetMainRect();
|
||||
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
|
||||
{
|
||||
ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
||||
@ -6242,7 +6242,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->Viewport->Pos = window->Pos;
|
||||
if (!window->Viewport->PlatformRequestResize)
|
||||
window->Viewport->Size = window->Size;
|
||||
viewport_rect = window->Viewport->GetRect();
|
||||
viewport_rect = window->Viewport->GetMainRect();
|
||||
}
|
||||
|
||||
// Save last known viewport position within the window itself (so it can be saved in .ini file and restored)
|
||||
@ -8374,7 +8374,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
||||
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
|
||||
{
|
||||
ImGuiViewportP* viewport = window->WasActive ? window->Viewport : (ImGuiViewportP*)GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport?
|
||||
SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
SetNextWindowPos(viewport->GetMainRect().GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking;
|
||||
@ -9009,7 +9009,7 @@ static ImVec2 ImGui::NavCalcPreferredRefPos()
|
||||
// When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item.
|
||||
const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
|
||||
ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
|
||||
ImRect visible_rect = g.NavWindow->Viewport->GetRect();
|
||||
ImRect visible_rect = g.NavWindow->Viewport->GetMainRect();
|
||||
return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
|
||||
}
|
||||
}
|
||||
@ -10557,7 +10557,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!(viewport->Flags & (ImGuiViewportFlags_CanHostOtherWindows | ImGuiViewportFlags_Minimized)) || window->Viewport == viewport)
|
||||
return false;
|
||||
if (!viewport->GetRect().Contains(window->Rect()))
|
||||
if (!viewport->GetMainRect().Contains(window->Rect()))
|
||||
return false;
|
||||
if (GetWindowAlwaysWantOwnViewport(window))
|
||||
return false;
|
||||
@ -10568,7 +10568,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
|
||||
if (window_behind == window)
|
||||
break;
|
||||
if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow))
|
||||
if (window_behind->Viewport->GetRect().Overlaps(window->Rect()))
|
||||
if (window_behind->Viewport->GetMainRect().Overlaps(window->Rect()))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -10636,7 +10636,7 @@ static ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2 m
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_Minimized)) && viewport->GetRect().Contains(mouse_platform_pos))
|
||||
if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_Minimized)) && viewport->GetMainRect().Contains(mouse_platform_pos))
|
||||
if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount)
|
||||
best_candidate = viewport;
|
||||
}
|
||||
@ -11231,7 +11231,7 @@ static int ImGui::FindPlatformMonitorForRect(const ImRect& rect)
|
||||
// Update monitor from viewport rectangle (we'll use this info to clamp windows and save windows lost in a removed monitor)
|
||||
static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport)
|
||||
{
|
||||
viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetRect());
|
||||
viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetMainRect());
|
||||
}
|
||||
|
||||
void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
|
||||
@ -14957,7 +14957,7 @@ void ImGui::ShowViewportThumbnails()
|
||||
//for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
|
||||
// bb_full.Add(GetPlatformMonitorMainRect(g.PlatformIO.Monitors[n]));
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
bb_full.Add(g.Viewports[n]->GetRect());
|
||||
bb_full.Add(g.Viewports[n]->GetMainRect());
|
||||
ImVec2 p = window->DC.CursorPos;
|
||||
ImVec2 off = p - bb_full.Min * SCALE;
|
||||
//for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
|
||||
|
14
imgui.h
14
imgui.h
@ -716,7 +716,7 @@ namespace ImGui
|
||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||
|
||||
// Inputs Utilities: Keyboard
|
||||
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
|
||||
// - For 'int user_key_index' you can use your own indices/enums according to how your back-end/engine stored them in io.KeysDown[].
|
||||
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
|
||||
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
||||
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
|
||||
@ -2479,15 +2479,17 @@ struct ImGuiViewport
|
||||
ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
|
||||
ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows.
|
||||
|
||||
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.). If somehow everything you need can fit in the void* PlatformHandle field you may ignore this.
|
||||
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). If somehow everything you need can fit in the void* PlatformHandle field you may ignore this.
|
||||
// Our design separate the Renderer and Platform back-ends to facilitate combining default back-ends with each others.
|
||||
// When our create your own back-end for a custom engine, it is possible that both Renderer and Platform will be handled by the same system and you may not need to use all the UserData/Handle fields.
|
||||
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.).
|
||||
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context).
|
||||
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
|
||||
void* PlatformHandleRaw; // void* to hold low-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
|
||||
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
||||
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
|
||||
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
|
||||
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
|
||||
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
||||
|
||||
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; ParentViewportId = 0; RendererUserData = PlatformUserData = PlatformHandle = PlatformHandleRaw = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; ParentViewportId = 0; RendererUserData = PlatformUserData = PlatformHandle = PlatformHandleRaw = NULL; PlatformRequestMove = PlatformRequestResize = PlatformRequestClose = false; }
|
||||
~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
|
||||
};
|
||||
|
||||
|
@ -935,11 +935,10 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
ImVec2 LastPlatformSize;
|
||||
ImVec2 LastRendererSize;
|
||||
|
||||
ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameDrawLists[0] = LastFrameDrawLists[1] = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = false; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
||||
~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
|
||||
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); }
|
||||
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||
ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameDrawLists[0] = LastFrameDrawLists[1] = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = false; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
||||
~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
|
||||
ImRect GetMainRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||
};
|
||||
|
||||
struct ImGuiNavMoveResult
|
||||
|
Loading…
Reference in New Issue
Block a user