MCPcopy Create free account
hub / github.com/SatDump/SatDump / ShowPlotContextMenu

Function ShowPlotContextMenu

src-core/imgui/implot/implot.cpp:1515–1584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1513}
1514
1515void ShowPlotContextMenu(ImPlotPlot& plot) {
1516 ImPlotContext& gp = *GImPlot;
1517 const bool owns_legend = gp.CurrentItems == &plot.Items;
1518 const bool equal = ImHasFlag(plot.Flags, ImPlotFlags_Equal);
1519
1520 char buf[16] = {};
1521
1522 for (int i = 0; i < IMPLOT_NUM_X_AXES; i++) {
1523 ImPlotAxis& x_axis = plot.XAxis(i);
1524 if (!x_axis.Enabled || !x_axis.HasMenus())
1525 continue;
1526 ImGui::PushID(i);
1527 ImFormatString(buf, sizeof(buf) - 1, i == 0 ? "X-Axis" : "X-Axis %d", i + 1);
1528 if (ImGui::BeginMenu(x_axis.HasLabel() ? plot.GetAxisLabel(x_axis) : buf)) {
1529 ShowAxisContextMenu(x_axis, equal ? x_axis.OrthoAxis : nullptr, false);
1530 ImGui::EndMenu();
1531 }
1532 ImGui::PopID();
1533 }
1534
1535 for (int i = 0; i < IMPLOT_NUM_Y_AXES; i++) {
1536 ImPlotAxis& y_axis = plot.YAxis(i);
1537 if (!y_axis.Enabled || !y_axis.HasMenus())
1538 continue;
1539 ImGui::PushID(i);
1540 ImFormatString(buf, sizeof(buf) - 1, i == 0 ? "Y-Axis" : "Y-Axis %d", i + 1);
1541 if (ImGui::BeginMenu(y_axis.HasLabel() ? plot.GetAxisLabel(y_axis) : buf)) {
1542 ShowAxisContextMenu(y_axis, equal ? y_axis.OrthoAxis : nullptr, false);
1543 ImGui::EndMenu();
1544 }
1545 ImGui::PopID();
1546 }
1547
1548 ImGui::Separator();
1549 if (!ImHasFlag(gp.CurrentItems->Legend.Flags, ImPlotLegendFlags_NoMenus)) {
1550 if ((ImGui::BeginMenu("Legend"))) {
1551 if (owns_legend) {
1552 if (ShowLegendContextMenu(plot.Items.Legend, !ImHasFlag(plot.Flags, ImPlotFlags_NoLegend)))
1553 ImFlipFlag(plot.Flags, ImPlotFlags_NoLegend);
1554 }
1555 else if (gp.CurrentSubplot != nullptr) {
1556 if (ShowLegendContextMenu(gp.CurrentSubplot->Items.Legend, !ImHasFlag(gp.CurrentSubplot->Flags, ImPlotSubplotFlags_NoLegend)))
1557 ImFlipFlag(gp.CurrentSubplot->Flags, ImPlotSubplotFlags_NoLegend);
1558 }
1559 ImGui::EndMenu();
1560 }
1561 }
1562 if ((ImGui::BeginMenu("Settings"))) {
1563 if (ImGui::MenuItem("Equal", nullptr, ImHasFlag(plot.Flags, ImPlotFlags_Equal)))
1564 ImFlipFlag(plot.Flags, ImPlotFlags_Equal);
1565 if (ImGui::MenuItem("Box Select",nullptr,!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect)))
1566 ImFlipFlag(plot.Flags, ImPlotFlags_NoBoxSelect);
1567 BeginDisabledControls(plot.TitleOffset == -1);
1568 if (ImGui::MenuItem("Title",nullptr,plot.HasTitle()))
1569 ImFlipFlag(plot.Flags, ImPlotFlags_NoTitle);
1570 EndDisabledControls(plot.TitleOffset == -1);
1571 if (ImGui::MenuItem("Mouse Position",nullptr,!ImHasFlag(plot.Flags, ImPlotFlags_NoMouseText)))
1572 ImFlipFlag(plot.Flags, ImPlotFlags_NoMouseText);

Callers 1

EndPlotFunction · 0.85

Calls 13

ImHasFlagFunction · 0.85
ImFormatStringFunction · 0.85
ShowAxisContextMenuFunction · 0.85
SeparatorFunction · 0.85
ShowLegendContextMenuFunction · 0.85
ImFlipFlagFunction · 0.85
BeginDisabledControlsFunction · 0.85
EndDisabledControlsFunction · 0.85
ShowSubplotsContextMenuFunction · 0.85
HasMenusMethod · 0.80
HasLabelMethod · 0.80
GetAxisLabelMethod · 0.80

Tested by

no test coverage detected