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

Function EndSubplots

Source/3rdParty/implot/implot.cpp:3604–3707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3602}
3603
3604void EndSubplots() {
3605 IM_ASSERT_USER_ERROR(GImPlot != nullptr, "No current context. Did you call ImPlot::CreateContext() or ImPlot::SetCurrentContext()?");
3606 ImPlotContext& gp = *GImPlot;
3607 IM_ASSERT_USER_ERROR(gp.CurrentSubplot != nullptr, "Mismatched BeginSubplots()/EndSubplots()!");
3608 ImPlotSubplot& subplot = *gp.CurrentSubplot;
3609 const ImGuiIO& IO = ImGui::GetIO();
3610 // set alignments
3611 for (int r = 0; r < subplot.Rows; ++r)
3612 subplot.RowAlignmentData[r].End();
3613 for (int c = 0; c < subplot.Cols; ++c)
3614 subplot.ColAlignmentData[c].End();
3615 // pop styling
3616 PopStyleColor();
3617 PopStyleVar();
3618 PopStyleVar();
3619 ImGui::PopStyleVar();
3620 // legend
3621 subplot.Items.Legend.Hovered = false;
3622 for (int i = 0; i < subplot.Items.GetItemCount(); ++i)
3623 subplot.Items.GetItemByIndex(i)->LegendHovered = false;
3624 // render legend
3625 const bool share_items = ImHasFlag(subplot.Flags, ImPlotSubplotFlags_ShareItems);
3626 ImDrawList& DrawList = *ImGui::GetWindowDrawList();
3627 if (share_items && !ImHasFlag(subplot.Flags, ImPlotSubplotFlags_NoLegend) && subplot.Items.GetLegendCount() > 0) {
3628 ImPlotLegend& legend = subplot.Items.Legend;
3629 const bool legend_horz = ImHasFlag(legend.Flags, ImPlotLegendFlags_Horizontal);
3630 const ImVec2 legend_size = CalcLegendSize(subplot.Items, gp.Style.LegendInnerPadding, gp.Style.LegendSpacing, !legend_horz);
3631 const ImVec2 legend_pos = GetLocationPos(subplot.FrameRect, legend_size, legend.Location, gp.Style.PlotPadding);
3632 legend.Rect = ImRect(legend_pos, legend_pos + legend_size);
3633 legend.RectClamped = legend.Rect;
3634 const bool legend_scrollable = ClampLegendRect(legend.RectClamped,subplot.FrameRect, gp.Style.PlotPadding);
3635 const ImGuiButtonFlags legend_button_flags = ImGuiButtonFlags_AllowOverlap
3636 | ImGuiButtonFlags_PressedOnClick
3637 | ImGuiButtonFlags_PressedOnDoubleClick
3638 | ImGuiButtonFlags_MouseButtonLeft
3639 | ImGuiButtonFlags_MouseButtonRight
3640 | ImGuiButtonFlags_MouseButtonMiddle
3641 | ImGuiButtonFlags_FlattenChildren;
3642 ImGui::KeepAliveID(subplot.Items.ID);
3643 ImGui::ButtonBehavior(legend.RectClamped, subplot.Items.ID, &legend.Hovered, &legend.Held, legend_button_flags);
3644 legend.Hovered = legend.Hovered || (subplot.FrameHovered && legend.RectClamped.Contains(ImGui::GetIO().MousePos));
3645
3646 if (legend_scrollable) {
3647 if (legend.Hovered) {
3648 ImGui::SetKeyOwner(ImGuiKey_MouseWheelY, subplot.Items.ID);
3649 if (IO.MouseWheel != 0.0f) {
3650 ImVec2 max_step = legend.Rect.GetSize() * 0.67f;
3651#if IMGUI_VERSION_NUM < 19172
3652 float font_size = ImGui::GetCurrentWindow()->CalcFontSize();
3653#else
3654 float font_size = ImGui::GetCurrentWindow()->FontRefSize;
3655#endif
3656 float scroll_step = ImFloor(ImMin(2 * font_size, max_step.x));
3657 legend.Scroll.x += scroll_step * IO.MouseWheel;
3658 legend.Scroll.y += scroll_step * IO.MouseWheel;
3659 }
3660 }
3661 const ImVec2 min_scroll_offset = legend.RectClamped.GetSize() - legend.Rect.GetSize();

Callers 3

Demo_SubplotsSizingFunction · 0.85
Demo_SubplotItemSharingFunction · 0.85
Demo_SubplotAxisLinkingFunction · 0.85

Calls 15

PopStyleColorFunction · 0.85
PopStyleVarFunction · 0.85
ImHasFlagFunction · 0.85
CalcLegendSizeFunction · 0.85
GetLocationPosFunction · 0.85
ClampLegendRectFunction · 0.85
GetCurrentWindowFunction · 0.85
ImFloorFunction · 0.85
ImMinFunction · 0.85
ImClampFunction · 0.85
ImVec2Function · 0.85
GetStyleColorU32Function · 0.85

Tested by

no test coverage detected