MCPcopy Create free account
hub / github.com/brenocq/implot3d / ShowLegendContextMenu

Function ShowLegendContextMenu

implot3d.cpp:1525–1549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1523static const char* plane_labels[3] = {"YZ-Plane", "XZ-Plane", "XY-Plane"};
1524
1525bool ShowLegendContextMenu(ImPlot3DLegend& legend, bool visible) {
1526 const float s = ImGui::GetFrameHeight();
1527 bool ret = false;
1528 if (ImGui::Checkbox("Show", &visible))
1529 ret = true;
1530 if (ImGui::RadioButton("H", ImPlot3D::ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
1531 legend.Flags |= ImPlot3DLegendFlags_Horizontal;
1532 ImGui::SameLine();
1533 if (ImGui::RadioButton("V", !ImPlot3D::ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
1534 legend.Flags &= ~ImPlot3DLegendFlags_Horizontal;
1535 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2));
1536 // clang-format off
1537 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_NorthWest),ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_NorthWest; } ImGui::SameLine();
1538 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_North) , ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_North; } ImGui::SameLine();
1539 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_NorthEast), ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_NorthEast; }
1540 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_West), ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_West; } ImGui::SameLine();
1541 if (ImGui::InvisibleButton(GetShortLegendLocationName(ImPlot3DLocation_Center), ImVec2(1.5f*s,s))) { } ImGui::SameLine();
1542 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_East), ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_East; }
1543 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_SouthWest),ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_SouthWest; } ImGui::SameLine();
1544 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_South), ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_South; } ImGui::SameLine();
1545 if (ImGui::Button(GetShortLegendLocationName(ImPlot3DLocation_SouthEast),ImVec2(1.5f*s,s))) { legend.Location = ImPlot3DLocation_SouthEast; }
1546 // clang-format on
1547 ImGui::PopStyleVar();
1548 return ret;
1549}
1550
1551void ShowAxisContextMenu(ImPlot3DPlot& plot, ImAxis3D axis_id) {
1552 ImGui::PushItemWidth(75);

Callers 2

ShowPlotContextMenuFunction · 0.85
EndPlotFunction · 0.85

Calls 4

ImHasFlagFunction · 0.85
PushStyleVarFunction · 0.85
PopStyleVarFunction · 0.85

Tested by

no test coverage detected