mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 13:07:01 +00:00
Renamed GetOverlayDrawList() to GetForegroundDrawList() for consistency. Kept redirection function (will obsolete). (#2391)
Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo.
This commit is contained in:
parent
96b13760d4
commit
94e794f81b
@ -38,6 +38,7 @@ Breaking Changes:
|
||||
- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
|
||||
ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is anticipation of adding new
|
||||
flags to ColorEdit/ColorPicker functions which would make those ambiguous. (#2384) [@haldean]
|
||||
- Renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). (#2391)
|
||||
|
||||
Other Changes:
|
||||
|
||||
@ -68,6 +69,7 @@ Other Changes:
|
||||
tree depth instead of a relative one.
|
||||
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
||||
- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
|
||||
- Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo.
|
||||
- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier]
|
||||
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
||||
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
||||
|
75
imgui.cpp
75
imgui.cpp
@ -364,6 +364,7 @@ CODE
|
||||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete).
|
||||
- 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
|
||||
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
||||
- 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||
@ -874,8 +875,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::GetBackgroundDrawList() or ImGui::GetOverlayDrawList() and use those draw list to display contents
|
||||
behind or over every other imgui windows.
|
||||
- You can call ImGui::GetBackgroundDrawList() or ImGui::GetForegroundDrawList() 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.
|
||||
|
||||
@ -3073,15 +3074,15 @@ ImDrawList* ImGui::GetBackgroundDrawList()
|
||||
return &GImGui->BackgroundDrawList;
|
||||
}
|
||||
|
||||
static ImDrawList* GetOverlayDrawList(ImGuiWindow*)
|
||||
static ImDrawList* GetForegroundDrawList(ImGuiWindow*)
|
||||
{
|
||||
// This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
|
||||
return &GImGui->OverlayDrawList;
|
||||
return &GImGui->ForegroundDrawList;
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetOverlayDrawList()
|
||||
ImDrawList* ImGui::GetForegroundDrawList()
|
||||
{
|
||||
return &GImGui->OverlayDrawList;
|
||||
return &GImGui->ForegroundDrawList;
|
||||
}
|
||||
|
||||
ImDrawListSharedData* ImGui::GetDrawListSharedData()
|
||||
@ -3433,10 +3434,10 @@ void ImGui::NewFrame()
|
||||
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();
|
||||
g.OverlayDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||
g.ForegroundDrawList.Clear();
|
||||
g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||
g.ForegroundDrawList.PushClipRectFullScreen();
|
||||
g.ForegroundDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||
|
||||
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
|
||||
g.DrawData.Clear();
|
||||
@ -3615,7 +3616,7 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
g.BeginPopupStack.clear();
|
||||
g.DrawDataBuilder.ClearFreeMemory();
|
||||
g.BackgroundDrawList.ClearFreeMemory();
|
||||
g.OverlayDrawList.ClearFreeMemory();
|
||||
g.ForegroundDrawList.ClearFreeMemory();
|
||||
g.PrivateClipboard.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
|
||||
@ -3891,10 +3892,10 @@ void ImGui::Render()
|
||||
|
||||
// Draw software mouse cursor if requested
|
||||
if (g.IO.MouseDrawCursor)
|
||||
RenderMouseCursor(&g.OverlayDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor);
|
||||
RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor);
|
||||
|
||||
if (!g.OverlayDrawList.VtxBuffer.empty())
|
||||
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.OverlayDrawList);
|
||||
if (!g.ForegroundDrawList.VtxBuffer.empty())
|
||||
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList);
|
||||
|
||||
// Setup ImDrawData structure for end-user
|
||||
SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData);
|
||||
@ -4739,7 +4740,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
||||
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
|
||||
bool hovered, held;
|
||||
ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
|
||||
//GetOverlayDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
//GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
if (hovered || held)
|
||||
g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
|
||||
|
||||
@ -4764,7 +4765,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
||||
bool hovered, held;
|
||||
ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS);
|
||||
ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
|
||||
//GetOverlayDrawList(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
//GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held)
|
||||
{
|
||||
g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
|
||||
@ -7037,8 +7038,8 @@ ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow*)
|
||||
ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy)
|
||||
{
|
||||
ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size);
|
||||
//GImGui->OverlayDrawList.AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
|
||||
//GImGui->OverlayDrawList.AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
|
||||
//GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
|
||||
//GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
|
||||
|
||||
// Combo Box policy (we want a connecting edge)
|
||||
if (policy == ImGuiPopupPositionPolicy_ComboBox)
|
||||
@ -7237,7 +7238,7 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
||||
if (ImGui::IsMouseHoveringRect(cand.Min, cand.Max))
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
|
||||
ImDrawList* draw_list = ImGui::GetOverlayDrawList(window);
|
||||
ImDrawList* draw_list = ImGui::GetForegroundDrawList(window);
|
||||
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
|
||||
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
|
||||
draw_list->AddRectFilled(cand.Max-ImVec2(4,4), cand.Max+ImGui::CalcTextSize(buf)+ImVec2(4,4), IM_COL32(40,0,0,150));
|
||||
@ -7249,7 +7250,7 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
||||
if (quadrant == g.NavMoveDir)
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
|
||||
ImDrawList* draw_list = ImGui::GetOverlayDrawList(window);
|
||||
ImDrawList* draw_list = ImGui::GetForegroundDrawList(window);
|
||||
draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
|
||||
draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
|
||||
}
|
||||
@ -7555,7 +7556,7 @@ ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInput
|
||||
static void NavScrollToBringItemIntoView(ImGuiWindow* window, const ImRect& item_rect)
|
||||
{
|
||||
ImRect window_rect(window->InnerMainRect.Min - ImVec2(1, 1), window->InnerMainRect.Max + ImVec2(1, 1));
|
||||
//GetOverlayDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
||||
//GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
||||
if (window_rect.Contains(item_rect))
|
||||
return;
|
||||
|
||||
@ -7845,11 +7846,15 @@ static void ImGui::NavUpdate()
|
||||
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
||||
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
||||
IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
|
||||
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||
//GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||
g.NavScoringCount = 0;
|
||||
#if IMGUI_DEBUG_NAV_RECTS
|
||||
if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) GetOverlayDrawList(g.NavWindow)->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
||||
if (g.NavWindow) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); GetOverlayDrawList(g.NavWindow)->AddCircleFilled(p, 3.0f, col); GetOverlayDrawList(g.NavWindow)->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
if (g.NavWindow)
|
||||
{
|
||||
ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
|
||||
if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
||||
if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -9356,9 +9361,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
return;
|
||||
}
|
||||
|
||||
ImDrawList* overlay_draw_list = GetOverlayDrawList(window); // Render additional visuals into the top-most draw list
|
||||
ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
|
||||
if (window && IsItemHovered())
|
||||
overlay_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
|
||||
fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
|
||||
if (!node_open)
|
||||
return;
|
||||
|
||||
@ -9380,8 +9385,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImRect vtxs_rect;
|
||||
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
|
||||
vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
|
||||
clip_rect.Floor(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,255,0,255));
|
||||
vtxs_rect.Floor(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,0,255,255));
|
||||
clip_rect.Floor(); fg_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,255,0,255));
|
||||
vtxs_rect.Floor(); fg_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,0,255,255));
|
||||
}
|
||||
if (!pcmd_node_open)
|
||||
continue;
|
||||
@ -9405,10 +9410,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Selectable(buf, false);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImDrawListFlags backup_flags = overlay_draw_list->Flags;
|
||||
overlay_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles.
|
||||
overlay_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f);
|
||||
overlay_draw_list->Flags = backup_flags;
|
||||
ImDrawListFlags backup_flags = fg_draw_list->Flags;
|
||||
fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles.
|
||||
fg_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f);
|
||||
fg_draw_list->Flags = backup_flags;
|
||||
}
|
||||
}
|
||||
ImGui::TreePop();
|
||||
@ -9545,9 +9550,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
char buf[32];
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
|
||||
float font_size = ImGui::GetFontSize() * 2;
|
||||
ImDrawList* overlay_draw_list = GetOverlayDrawList(window);
|
||||
overlay_draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
|
||||
overlay_draw_list->AddText(NULL, font_size, window->Pos, IM_COL32(255, 255, 255, 255), buf);
|
||||
ImDrawList* fg_draw_list = GetForegroundDrawList(window);
|
||||
fg_draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
|
||||
fg_draw_list->AddText(NULL, font_size, window->Pos, IM_COL32(255, 255, 255, 255), buf);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
4
imgui.h
4
imgui.h
@ -628,7 +628,7 @@ namespace ImGui
|
||||
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* 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 ImDrawList* GetForegroundDrawList(); // 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)
|
||||
@ -1500,6 +1500,8 @@ struct ImGuiPayload
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
namespace ImGui
|
||||
{
|
||||
// OBSOLETED in 1.69 (from Mar 2019)
|
||||
static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); }
|
||||
// OBSOLETED in 1.66 (from Sep 2018)
|
||||
static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); }
|
||||
// OBSOLETED in 1.63 (between Aug 2018 and Sept 2018)
|
||||
|
@ -3974,15 +3974,17 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
// In this example we are not using the maths operators!
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
|
||||
if (ImGui::BeginTabBar("##TabBar"))
|
||||
{
|
||||
// Primitives
|
||||
ImGui::Text("Primitives");
|
||||
if (ImGui::BeginTabItem("Primitives"))
|
||||
{
|
||||
static float sz = 36.0f;
|
||||
static float thickness = 4.0f;
|
||||
static ImVec4 col = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
|
||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||
ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
|
||||
ImGui::ColorEdit4("Color", &col.x);
|
||||
{
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const ImU32 col32 = ImColor(col);
|
||||
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
||||
@ -4014,12 +4016,13 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col32); x += sz; // Pixel (faster than AddLine)
|
||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
|
||||
ImGui::Dummy(ImVec2((sz + spacing) * 8, (sz + spacing) * 3));
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginTabItem("Canvas"))
|
||||
{
|
||||
static ImVector<ImVec2> points;
|
||||
static bool adding_line = false;
|
||||
ImGui::Text("Canvas example");
|
||||
if (ImGui::Button("Clear")) points.clear();
|
||||
if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } }
|
||||
ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
|
||||
@ -4064,7 +4067,28 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
draw_list->PopClipRect();
|
||||
if (adding_preview)
|
||||
points.pop_back();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("BG/FG draw lists"))
|
||||
{
|
||||
static bool draw_bg = true;
|
||||
static bool draw_fg = true;
|
||||
ImGui::Checkbox("Draw in Background draw list", &draw_bg);
|
||||
ImGui::Checkbox("Draw in Foreground draw list", &draw_fg);
|
||||
ImVec2 window_pos = ImGui::GetWindowPos();
|
||||
ImVec2 window_size = ImGui::GetWindowSize();
|
||||
ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
|
||||
if (draw_bg)
|
||||
ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 32, 10);
|
||||
if (draw_fg)
|
||||
ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 32, 10);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
@ -888,8 +888,8 @@ 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
|
||||
ImDrawList BackgroundDrawList; // First draw list to be rendered.
|
||||
ImDrawList ForegroundDrawList; // Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays.
|
||||
ImGuiMouseCursor MouseCursor;
|
||||
|
||||
// Drag and Drop
|
||||
@ -963,7 +963,7 @@ struct ImGuiContext
|
||||
int WantTextInputNextFrame;
|
||||
char TempBuffer[1024*3+1]; // Temporary text buffer
|
||||
|
||||
ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(NULL), OverlayDrawList(NULL)
|
||||
ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(NULL), ForegroundDrawList(NULL)
|
||||
{
|
||||
Initialized = false;
|
||||
FrameScopeActive = FrameScopePushedImplicitWindow = false;
|
||||
@ -1033,8 +1033,8 @@ struct ImGuiContext
|
||||
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
|
||||
ForegroundDrawList._Data = &DrawListSharedData;
|
||||
ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging
|
||||
MouseCursor = ImGuiMouseCursor_Arrow;
|
||||
|
||||
DragDropActive = DragDropWithinSourceOrTarget = false;
|
||||
|
@ -6635,7 +6635,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
{
|
||||
// Enlarge tab display when hovering
|
||||
bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f));
|
||||
display_draw_list = GetOverlayDrawList(window);
|
||||
display_draw_list = GetForegroundDrawList(window);
|
||||
TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user