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

Function ShowPlotContextMenu

Source/3rdParty/implot/implot.cpp:1553–1622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1551}
1552
1553void ShowPlotContextMenu(ImPlotPlot& plot) {
1554 ImPlotContext& gp = *GImPlot;
1555 const bool owns_legend = gp.CurrentItems == &plot.Items;
1556 const bool equal = ImHasFlag(plot.Flags, ImPlotFlags_Equal);
1557
1558 char buf[16] = {};
1559
1560 for (int i = 0; i < IMPLOT_NUM_X_AXES; i++) {
1561 ImPlotAxis& x_axis = plot.XAxis(i);
1562 if (!x_axis.Enabled || !x_axis.HasMenus())
1563 continue;
1564 ImGui::PushID(i);
1565 ImFormatString(buf, sizeof(buf) - 1, i == 0 ? "X-Axis" : "X-Axis %d", i + 1);
1566 if (ImGui::BeginMenu(x_axis.HasLabel() ? plot.GetAxisLabel(x_axis) : buf)) {
1567 ShowAxisContextMenu(x_axis, equal ? x_axis.OrthoAxis : nullptr, false);
1568 ImGui::EndMenu();
1569 }
1570 ImGui::PopID();
1571 }
1572
1573 for (int i = 0; i < IMPLOT_NUM_Y_AXES; i++) {
1574 ImPlotAxis& y_axis = plot.YAxis(i);
1575 if (!y_axis.Enabled || !y_axis.HasMenus())
1576 continue;
1577 ImGui::PushID(i);
1578 ImFormatString(buf, sizeof(buf) - 1, i == 0 ? "Y-Axis" : "Y-Axis %d", i + 1);
1579 if (ImGui::BeginMenu(y_axis.HasLabel() ? plot.GetAxisLabel(y_axis) : buf)) {
1580 ShowAxisContextMenu(y_axis, equal ? y_axis.OrthoAxis : nullptr, false);
1581 ImGui::EndMenu();
1582 }
1583 ImGui::PopID();
1584 }
1585
1586 ImGui::Separator();
1587 if (!ImHasFlag(gp.CurrentItems->Legend.Flags, ImPlotLegendFlags_NoMenus)) {
1588 if ((ImGui::BeginMenu("Legend"))) {
1589 if (owns_legend) {
1590 if (ShowLegendContextMenu(plot.Items.Legend, !ImHasFlag(plot.Flags, ImPlotFlags_NoLegend)))
1591 ImFlipFlag(plot.Flags, ImPlotFlags_NoLegend);
1592 }
1593 else if (gp.CurrentSubplot != nullptr) {
1594 if (ShowLegendContextMenu(gp.CurrentSubplot->Items.Legend, !ImHasFlag(gp.CurrentSubplot->Flags, ImPlotSubplotFlags_NoLegend)))
1595 ImFlipFlag(gp.CurrentSubplot->Flags, ImPlotSubplotFlags_NoLegend);
1596 }
1597 ImGui::EndMenu();
1598 }
1599 }
1600 if ((ImGui::BeginMenu("Settings"))) {
1601 if (ImGui::MenuItem("Equal", nullptr, ImHasFlag(plot.Flags, ImPlotFlags_Equal)))
1602 ImFlipFlag(plot.Flags, ImPlotFlags_Equal);
1603 if (ImGui::MenuItem("Box Select",nullptr,!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect)))
1604 ImFlipFlag(plot.Flags, ImPlotFlags_NoBoxSelect);
1605 BeginDisabledControls(plot.TitleOffset == -1);
1606 if (ImGui::MenuItem("Title",nullptr,plot.HasTitle()))
1607 ImFlipFlag(plot.Flags, ImPlotFlags_NoTitle);
1608 EndDisabledControls(plot.TitleOffset == -1);
1609 if (ImGui::MenuItem("Mouse Position",nullptr,!ImHasFlag(plot.Flags, ImPlotFlags_NoMouseText)))
1610 ImFlipFlag(plot.Flags, ImPlotFlags_NoMouseText);

Callers 1

EndPlotFunction · 0.85

Calls 15

ImHasFlagFunction · 0.85
PushIDFunction · 0.85
ImFormatStringFunction · 0.85
BeginMenuFunction · 0.85
ShowAxisContextMenuFunction · 0.85
SeparatorFunction · 0.85
ShowLegendContextMenuFunction · 0.85
ImFlipFlagFunction · 0.85
MenuItemFunction · 0.85
BeginDisabledControlsFunction · 0.85
EndDisabledControlsFunction · 0.85
ShowSubplotsContextMenuFunction · 0.85

Tested by

no test coverage detected