MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / ShowAltLegend

Function ShowAltLegend

Source/3rdParty/implot/implot.cpp:4310–4344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4308}
4309
4310void ShowAltLegend(const char* title_id, bool vertical, const ImVec2 size, bool interactable) {
4311 ImPlotContext& gp = *GImPlot;
4312 ImGuiContext &G = *GImGui;
4313 ImGuiWindow * Window = G.CurrentWindow;
4314 if (Window->SkipItems)
4315 return;
4316 ImDrawList &DrawList = *Window->DrawList;
4317 ImPlotPlot* plot = GetPlot(title_id);
4318 ImVec2 legend_size;
4319 ImVec2 default_size = gp.Style.LegendPadding * 2;
4320 if (plot != nullptr) {
4321 legend_size = CalcLegendSize(plot->Items, gp.Style.LegendInnerPadding, gp.Style.LegendSpacing, vertical);
4322 default_size = legend_size + gp.Style.LegendPadding * 2;
4323 }
4324 ImVec2 frame_size = ImGui::CalcItemSize(size, default_size.x, default_size.y);
4325 ImRect bb_frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size);
4326 ImGui::ItemSize(bb_frame);
4327 if (!ImGui::ItemAdd(bb_frame, 0, &bb_frame))
4328 return;
4329 ImGui::RenderFrame(bb_frame.Min, bb_frame.Max, GetStyleColorU32(ImPlotCol_FrameBg), true, G.Style.FrameRounding);
4330 DrawList.PushClipRect(bb_frame.Min, bb_frame.Max, true);
4331 if (plot != nullptr) {
4332 const ImVec2 legend_pos = GetLocationPos(bb_frame, legend_size, 0, gp.Style.LegendPadding);
4333 const ImRect legend_bb(legend_pos, legend_pos + legend_size);
4334 interactable = interactable && bb_frame.Contains(ImGui::GetIO().MousePos);
4335 // render legend box
4336 ImU32 col_bg = GetStyleColorU32(ImPlotCol_LegendBg);
4337 ImU32 col_bd = GetStyleColorU32(ImPlotCol_LegendBorder);
4338 DrawList.AddRectFilled(legend_bb.Min, legend_bb.Max, col_bg);
4339 DrawList.AddRect(legend_bb.Min, legend_bb.Max, col_bd);
4340 // render entries
4341 ShowLegendEntries(plot->Items, legend_bb, interactable, gp.Style.LegendInnerPadding, gp.Style.LegendSpacing, vertical, DrawList);
4342 }
4343 DrawList.PopClipRect();
4344}
4345
4346//-----------------------------------------------------------------------------
4347// [SECTION] Drag and Drop Utils

Callers

nothing calls this directly

Calls 13

GetPlotFunction · 0.85
CalcLegendSizeFunction · 0.85
ItemSizeFunction · 0.85
GetStyleColorU32Function · 0.85
GetLocationPosFunction · 0.85
ShowLegendEntriesFunction · 0.85
AddRectFilledMethod · 0.80
AddRectMethod · 0.80
ImRectFunction · 0.50
RenderFrameClass · 0.50
PushClipRectMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected