Viewport: Misc renaming.

This commit is contained in:
omar 2018-11-29 21:16:45 +01:00
parent 01f940dc9a
commit 36cbe1e521
2 changed files with 15 additions and 15 deletions

View File

@ -7187,7 +7187,7 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport) static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (!(viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) || window->Viewport == viewport || viewport->PlatformIsMinimized) if (!(viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) || window->Viewport == viewport || viewport->PlatformWindowMinimized)
return false; return false;
if (!viewport->GetRect().Contains(window->Rect())) if (!viewport->GetRect().Contains(window->Rect()))
return false; return false;
@ -7242,7 +7242,7 @@ static ImGuiViewportP* FindViewportHoveredFromPlatformWindowStack(const ImVec2 m
for (int n = 0; n < g.Viewports.Size; n++) for (int n = 0; n < g.Viewports.Size; n++)
{ {
ImGuiViewportP* viewport = g.Viewports[n]; ImGuiViewportP* viewport = g.Viewports[n];
if (!(viewport->Flags & ImGuiViewportFlags_NoInputs) && !viewport->PlatformIsMinimized && viewport->GetRect().Contains(mouse_platform_pos)) if (!(viewport->Flags & ImGuiViewportFlags_NoInputs) && !viewport->PlatformWindowMinimized && viewport->GetRect().Contains(mouse_platform_pos))
if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount) if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount)
best_candidate = viewport; best_candidate = viewport;
} }
@ -7294,12 +7294,12 @@ static void ImGui::UpdateViewports()
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable)) if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
{ {
if (g.PlatformIO.Platform_GetWindowMinimized && (n == 0 || viewport->CreatedPlatformWindow)) if (g.PlatformIO.Platform_GetWindowMinimized && (n == 0 || viewport->PlatformWindowCreated))
viewport->PlatformIsMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport); viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
// Apply Position and Size (from Platform Window to ImGui) if requested. // 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. // 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->PlatformIsMinimized) if (!viewport->PlatformWindowMinimized)
{ {
if (viewport->PlatformRequestMove) if (viewport->PlatformRequestMove)
viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport); viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport);
@ -7387,14 +7387,14 @@ static void ImGui::UpdateViewports()
const bool is_mouse_dragging_with_an_expected_destination = g.DragDropActive; const bool is_mouse_dragging_with_an_expected_destination = g.DragDropActive;
if (is_mouse_dragging_with_an_expected_destination && viewport_hovered == NULL) if (is_mouse_dragging_with_an_expected_destination && viewport_hovered == NULL)
viewport_hovered = g.MouseLastHoveredViewport; viewport_hovered = g.MouseLastHoveredViewport;
if (is_mouse_dragging_with_an_expected_destination || g.ActiveId == 0 || !ImGui::IsAnyMouseDown()) if (is_mouse_dragging_with_an_expected_destination || g.ActiveId == 0 || !IsAnyMouseDown())
if (viewport_hovered != NULL && viewport_hovered != g.MouseViewport && !(viewport_hovered->Flags & ImGuiViewportFlags_NoInputs)) if (viewport_hovered != NULL && viewport_hovered != g.MouseViewport && !(viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
g.MouseViewport = viewport_hovered; g.MouseViewport = viewport_hovered;
IM_ASSERT(g.MouseViewport != NULL); IM_ASSERT(g.MouseViewport != NULL);
} }
// FIXME: We should ideally refactor the system to call this everyframe (we currently don't) // FIXME: We should ideally refactor the system to call this every frame (we currently don't)
ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags) ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
@ -7601,7 +7601,7 @@ void ImGui::UpdatePlatformWindows()
} }
// Create window // Create window
bool is_new_window = (viewport->CreatedPlatformWindow == false); bool is_new_window = (viewport->PlatformWindowCreated == false);
if (is_new_window) if (is_new_window)
{ {
g.PlatformIO.Platform_CreateWindow(viewport); g.PlatformIO.Platform_CreateWindow(viewport);
@ -7610,7 +7610,7 @@ void ImGui::UpdatePlatformWindows()
viewport->LastNameHash = 0; viewport->LastNameHash = 0;
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->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->LastRendererSize = viewport->Size;
viewport->CreatedPlatformWindow = true; viewport->PlatformWindowCreated = true;
} }
// Apply Position and Size (from ImGui to Platform/Renderer back-ends) // Apply Position and Size (from ImGui to Platform/Renderer back-ends)
@ -7757,7 +7757,7 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
IM_ASSERT(viewport->PlatformUserData == NULL); IM_ASSERT(viewport->PlatformUserData == NULL);
viewport->PlatformHandle = NULL; viewport->PlatformHandle = NULL;
viewport->RendererUserData = viewport->PlatformHandle = NULL; viewport->RendererUserData = viewport->PlatformHandle = NULL;
viewport->CreatedPlatformWindow = false; viewport->PlatformWindowCreated = false;
} }
void ImGui::DestroyPlatformWindows() void ImGui::DestroyPlatformWindows()
@ -9897,7 +9897,7 @@ static void RenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewp
ImVec2 scale = bb.GetSize() / viewport->Size; ImVec2 scale = bb.GetSize() / viewport->Size;
ImVec2 off = bb.Min - viewport->Pos * scale; ImVec2 off = bb.Min - viewport->Pos * scale;
float alpha_mul = viewport->PlatformIsMinimized ? 0.30f : 1.00f; float alpha_mul = viewport->PlatformWindowMinimized ? 0.30f : 1.00f;
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f)); window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
for (int i = 0; i != g.Windows.Size; i++) for (int i = 0; i != g.Windows.Size; i++)
{ {
@ -10104,7 +10104,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::BulletText("Flags: 0x%04X =%s%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_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
(flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "", (flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "",
(flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", viewport->PlatformIsMinimized ? ", PlatformIsMinimized" : ""); (flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", viewport->PlatformWindowMinimized ? ", PlatformWindowMinimized" : "");
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++) 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++) 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"); Funcs::NodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");

View File

@ -627,11 +627,11 @@ struct ImGuiViewportP : public ImGuiViewport
int LastFrontMostStampCount; // Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order int LastFrontMostStampCount; // Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order
ImGuiID LastNameHash; ImGuiID LastNameHash;
ImVec2 LastPos; ImVec2 LastPos;
bool CreatedPlatformWindow;
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent) float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
float LastAlpha; float LastAlpha;
int PlatformMonitor; int PlatformMonitor;
bool PlatformIsMinimized; bool PlatformWindowCreated;
bool PlatformWindowMinimized;
ImGuiWindow* Window; ImGuiWindow* 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) 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; ImDrawData DrawDataP;
@ -640,7 +640,7 @@ struct ImGuiViewportP : public ImGuiViewport
ImVec2 LastPlatformSize; ImVec2 LastPlatformSize;
ImVec2 LastRendererSize; ImVec2 LastRendererSize;
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() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } ~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); }
ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } 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); } ImVec2 GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }