mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Viewports: store Viewport field in ImGuiWindow to facilitate using code accross branches + fix PVS warnings.
This commit is contained in:
parent
dfbe938e54
commit
3587ee492b
12
imgui.cpp
12
imgui.cpp
@ -3709,7 +3709,7 @@ ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
|
||||
void ImGui::DestroyContext(ImGuiContext* ctx)
|
||||
{
|
||||
ImGuiContext* prev_ctx = GetCurrentContext();
|
||||
if (ctx == NULL)
|
||||
if (ctx == NULL) //-V1051
|
||||
ctx = prev_ctx;
|
||||
SetCurrentContext(ctx);
|
||||
Shutdown();
|
||||
@ -6179,6 +6179,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// SELECT VIEWPORT
|
||||
// FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style)
|
||||
|
||||
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport();
|
||||
SetWindowViewport(window, viewport);
|
||||
SetCurrentWindow(window);
|
||||
|
||||
// LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies)
|
||||
@ -6292,7 +6295,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// Calculate the range of allowed position for that window (to be movable and visible past safe area padding)
|
||||
// When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect.
|
||||
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport();
|
||||
ImRect viewport_rect(viewport->GetMainRect());
|
||||
ImRect viewport_work_rect(viewport->GetWorkRect());
|
||||
ImVec2 visibility_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
||||
@ -11846,6 +11848,7 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
||||
// [SECTION] VIEWPORTS, PLATFORM WINDOWS
|
||||
//-----------------------------------------------------------------------------
|
||||
// - GetMainViewport()
|
||||
// - SetWindowViewport() [Internal]
|
||||
// - UpdateViewportsNewFrame() [Internal]
|
||||
// (this section is more complete in the 'docking' branch)
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -11856,6 +11859,11 @@ ImGuiViewport* ImGui::GetMainViewport()
|
||||
return g.Viewports[0];
|
||||
}
|
||||
|
||||
void ImGui::SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
|
||||
{
|
||||
window->Viewport = viewport;
|
||||
}
|
||||
|
||||
// Update viewports and monitor infos
|
||||
static void ImGui::UpdateViewportsNewFrame()
|
||||
{
|
||||
|
2
imgui.h
2
imgui.h
@ -65,7 +65,7 @@ Index of this file:
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||
#define IMGUI_VERSION "1.88 WIP"
|
||||
#define IMGUI_VERSION_NUM 18711
|
||||
#define IMGUI_VERSION_NUM 18712
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
|
@ -2017,6 +2017,7 @@ struct IMGUI_API ImGuiWindow
|
||||
char* Name; // Window name, owned by the window.
|
||||
ImGuiID ID; // == ImHashStr(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
|
||||
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
ImVec2 SizeFull; // Size when non collapsed
|
||||
@ -2534,6 +2535,9 @@ namespace ImGui
|
||||
IMGUI_API void RemoveContextHook(ImGuiContext* context, ImGuiID hook_to_remove);
|
||||
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
||||
|
||||
// Viewports
|
||||
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||
|
||||
// Settings
|
||||
IMGUI_API void MarkIniSettingsDirty();
|
||||
IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
|
||||
|
Loading…
Reference in New Issue
Block a user