| 1300 | //----------------------------------------------------------------------------- |
| 1301 | |
| 1302 | void Demo_SubplotItemSharing() { |
| 1303 | static ImPlotSubplotFlags flags = ImPlotSubplotFlags_ShareItems; |
| 1304 | ImGui::CheckboxFlags("ImPlotSubplotFlags_ShareItems", (unsigned int*)&flags, ImPlotSubplotFlags_ShareItems); |
| 1305 | ImGui::CheckboxFlags("ImPlotSubplotFlags_ColMajor", (unsigned int*)&flags, ImPlotSubplotFlags_ColMajor); |
| 1306 | ImGui::BulletText("Drag and drop items from the legend onto plots (except for 'common')"); |
| 1307 | static int rows = 2; |
| 1308 | static int cols = 3; |
| 1309 | static int id[] = {0,1,2,3,4,5}; |
| 1310 | static int curj = -1; |
| 1311 | if (ImPlot::BeginSubplots("##ItemSharing", rows, cols, ImVec2(-1,400), flags)) { |
| 1312 | ImPlot::SetupLegend(ImPlotLocation_South, ImPlotLegendFlags_Sort|ImPlotLegendFlags_Horizontal); |
| 1313 | for (int i = 0; i < rows*cols; ++i) { |
| 1314 | if (ImPlot::BeginPlot("")) { |
| 1315 | float fc = 0.01f; |
| 1316 | ImPlot::PlotLineG("common",SinewaveGetter,&fc,1000); |
| 1317 | for (int j = 0; j < 6; ++j) { |
| 1318 | if (id[j] == i) { |
| 1319 | char label[8]; |
| 1320 | float fj = 0.01f * (j+2); |
| 1321 | snprintf(label, sizeof(label), "data%d", j); |
| 1322 | ImPlot::PlotLineG(label,SinewaveGetter,&fj,1000); |
| 1323 | if (ImPlot::BeginDragDropSourceItem(label)) { |
| 1324 | curj = j; |
| 1325 | ImGui::SetDragDropPayload("MY_DND",nullptr,0); |
| 1326 | ImPlot::ItemIcon(GetLastItemColor()); ImGui::SameLine(); |
| 1327 | ImGui::TextUnformatted(label); |
| 1328 | ImPlot::EndDragDropSource(); |
| 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | if (ImPlot::BeginDragDropTargetPlot()) { |
| 1333 | if (ImGui::AcceptDragDropPayload("MY_DND")) |
| 1334 | id[curj] = i; |
| 1335 | ImPlot::EndDragDropTarget(); |
| 1336 | } |
| 1337 | ImPlot::EndPlot(); |
| 1338 | } |
| 1339 | } |
| 1340 | ImPlot::EndSubplots(); |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | //----------------------------------------------------------------------------- |
| 1345 |
nothing calls this directly
no test coverage detected