mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Shutdown: Unlock font atlas before destroying context, so we can destroy a context between NewFrame and EndFrame if we wait (facilitate main loop structures). Internals: GetWindowScrollMaxX(), GetWindowScrollMaxY()
This commit is contained in:
parent
cf0afb48ac
commit
ed4dcd9072
17
imgui.cpp
17
imgui.cpp
@ -3290,7 +3290,10 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
|
||||
ImGuiContext& g = *context;
|
||||
if (g.IO.Fonts && g.FontAtlasOwnedByContext)
|
||||
{
|
||||
g.IO.Fonts->Locked = false;
|
||||
IM_DELETE(g.IO.Fonts);
|
||||
}
|
||||
g.IO.Fonts = NULL;
|
||||
|
||||
// Cleanup of other data are conditional on actually having initialized ImGui.
|
||||
@ -4309,12 +4312,12 @@ ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window)
|
||||
return CalcSizeAfterConstraint(window, CalcSizeAutoFit(window, size_contents));
|
||||
}
|
||||
|
||||
static float GetScrollMaxX(ImGuiWindow* window)
|
||||
float ImGui::GetWindowScrollMaxX(ImGuiWindow* window)
|
||||
{
|
||||
return ImMax(0.0f, window->SizeContents.x - (window->SizeFull.x - window->ScrollbarSizes.x));
|
||||
}
|
||||
|
||||
static float GetScrollMaxY(ImGuiWindow* window)
|
||||
float ImGui::GetWindowScrollMaxY(ImGuiWindow* window)
|
||||
{
|
||||
return ImMax(0.0f, window->SizeContents.y - (window->SizeFull.y - window->ScrollbarSizes.y));
|
||||
}
|
||||
@ -4342,8 +4345,8 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool s
|
||||
scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
|
||||
if (!window->Collapsed && !window->SkipItems)
|
||||
{
|
||||
scroll.x = ImMin(scroll.x, GetScrollMaxX(window));
|
||||
scroll.y = ImMin(scroll.y, GetScrollMaxY(window));
|
||||
scroll.x = ImMin(scroll.x, ImGui::GetWindowScrollMaxX(window));
|
||||
scroll.y = ImMin(scroll.y, ImGui::GetWindowScrollMaxY(window));
|
||||
}
|
||||
return scroll;
|
||||
}
|
||||
@ -6009,12 +6012,12 @@ float ImGui::GetScrollY()
|
||||
|
||||
float ImGui::GetScrollMaxX()
|
||||
{
|
||||
return GetScrollMaxX(GImGui->CurrentWindow);
|
||||
return GetWindowScrollMaxX(GImGui->CurrentWindow);
|
||||
}
|
||||
|
||||
float ImGui::GetScrollMaxY()
|
||||
{
|
||||
return GetScrollMaxY(GImGui->CurrentWindow);
|
||||
return GetWindowScrollMaxY(GImGui->CurrentWindow);
|
||||
}
|
||||
|
||||
void ImGui::SetScrollX(float scroll_x)
|
||||
@ -8918,7 +8921,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
|
||||
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
|
||||
(flags & ImGuiWindowFlags_NoInputs) ? "NoInputs":"", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
|
||||
ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetScrollMaxX(window), window->Scroll.y, GetScrollMaxY(window));
|
||||
ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetWindowScrollMaxX(window), window->Scroll.y, GetWindowScrollMaxY(window));
|
||||
ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
|
||||
ImGui::BulletText("Appearing: %d, Hidden: %d (Reg %d Resize %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesRegular, window->HiddenFramesForResize, window->SkipItems);
|
||||
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
||||
|
@ -1125,6 +1125,8 @@ namespace ImGui
|
||||
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
||||
IMGUI_API void SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
|
||||
IMGUI_API void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||
IMGUI_API float GetWindowScrollMaxX(ImGuiWindow* window);
|
||||
IMGUI_API float GetWindowScrollMaxY(ImGuiWindow* window);
|
||||
IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
|
||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||
|
Loading…
Reference in New Issue
Block a user