mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Added GetBackgroundDrawList() helper to quickly get access to a ImDrawList that will be rendered behind every other windows. (#2391)
This commit is contained in:
parent
beb3062dc5
commit
96b13760d4
@ -41,6 +41,8 @@ Breaking Changes:
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Added GetBackgroundDrawList() helper to quickly get access to a ImDrawList that will be rendered
|
||||
behind every other windows. (#2391)
|
||||
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigating to the menu layer.
|
||||
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
||||
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
||||
|
19
imgui.cpp
19
imgui.cpp
@ -874,7 +874,8 @@ CODE
|
||||
A: - You can create a dummy window. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags.
|
||||
(The ImGuiWindowFlags_NoDecoration flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse)
|
||||
Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
- You can call ImGui::GetOverlayDrawList() and use this draw list to display contents over every other imgui windows.
|
||||
- You can call ImGui::GetBackgroundDrawList() or ImGui::GetOverlayDrawList() and use those draw list to display contents
|
||||
behind or over every other imgui windows.
|
||||
- You can create your own ImDrawList instance. You'll need to initialize them ImGui::GetDrawListSharedData(), or create
|
||||
your own ImDrawListSharedData, and then call your rendered code with your own ImDrawList or ImDrawData data.
|
||||
|
||||
@ -3067,9 +3068,14 @@ int ImGui::GetFrameCount()
|
||||
return GImGui->FrameCount;
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetBackgroundDrawList()
|
||||
{
|
||||
return &GImGui->BackgroundDrawList;
|
||||
}
|
||||
|
||||
static ImDrawList* GetOverlayDrawList(ImGuiWindow*)
|
||||
{
|
||||
// This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'viewport' branches.
|
||||
// This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
|
||||
return &GImGui->OverlayDrawList;
|
||||
}
|
||||
|
||||
@ -3422,6 +3428,11 @@ void ImGui::NewFrame()
|
||||
g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
|
||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||
|
||||
g.BackgroundDrawList.Clear();
|
||||
g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||
g.BackgroundDrawList.PushClipRectFullScreen();
|
||||
g.BackgroundDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||
|
||||
g.OverlayDrawList.Clear();
|
||||
g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||
g.OverlayDrawList.PushClipRectFullScreen();
|
||||
@ -3603,6 +3614,7 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
g.OpenPopupStack.clear();
|
||||
g.BeginPopupStack.clear();
|
||||
g.DrawDataBuilder.ClearFreeMemory();
|
||||
g.BackgroundDrawList.ClearFreeMemory();
|
||||
g.OverlayDrawList.ClearFreeMemory();
|
||||
g.PrivateClipboard.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
@ -3860,6 +3872,9 @@ void ImGui::Render()
|
||||
// Gather ImDrawList to render (for each active window)
|
||||
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsRenderWindows = 0;
|
||||
g.DrawDataBuilder.Clear();
|
||||
if (!g.BackgroundDrawList.VtxBuffer.empty())
|
||||
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.BackgroundDrawList);
|
||||
|
||||
ImGuiWindow* windows_to_render_front_most[2];
|
||||
windows_to_render_front_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
|
||||
windows_to_render_front_most[1] = g.NavWindowingTarget ? g.NavWindowingList : NULL;
|
||||
|
3
imgui.h
3
imgui.h
@ -627,7 +627,8 @@ namespace ImGui
|
||||
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
|
||||
IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame.
|
||||
IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame.
|
||||
IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text
|
||||
IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
||||
IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
||||
IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances.
|
||||
IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.).
|
||||
IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
||||
|
@ -888,6 +888,7 @@ struct ImGuiContext
|
||||
ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user
|
||||
ImDrawDataBuilder DrawDataBuilder;
|
||||
float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
|
||||
ImDrawList BackgroundDrawList;
|
||||
ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
|
||||
ImGuiMouseCursor MouseCursor;
|
||||
|
||||
@ -962,7 +963,7 @@ struct ImGuiContext
|
||||
int WantTextInputNextFrame;
|
||||
char TempBuffer[1024*3+1]; // Temporary text buffer
|
||||
|
||||
ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
|
||||
ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(NULL), OverlayDrawList(NULL)
|
||||
{
|
||||
Initialized = false;
|
||||
FrameScopeActive = FrameScopePushedImplicitWindow = false;
|
||||
@ -1030,6 +1031,8 @@ struct ImGuiContext
|
||||
NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
|
||||
|
||||
DimBgRatio = 0.0f;
|
||||
BackgroundDrawList._Data = &DrawListSharedData;
|
||||
BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging
|
||||
OverlayDrawList._Data = &DrawListSharedData;
|
||||
OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
|
||||
MouseCursor = ImGuiMouseCursor_Arrow;
|
||||
|
Loading…
Reference in New Issue
Block a user