| 546 | //----------------------------------------------------------------------------- |
| 547 | |
| 548 | ImVec2 GetLocationPos(const ImRect& outer_rect, const ImVec2& inner_size, ImPlotLocation loc, const ImVec2& pad) { |
| 549 | ImVec2 pos; |
| 550 | if (ImHasFlag(loc, ImPlotLocation_West) && !ImHasFlag(loc, ImPlotLocation_East)) |
| 551 | pos.x = outer_rect.Min.x + pad.x; |
| 552 | else if (!ImHasFlag(loc, ImPlotLocation_West) && ImHasFlag(loc, ImPlotLocation_East)) |
| 553 | pos.x = outer_rect.Max.x - pad.x - inner_size.x; |
| 554 | else |
| 555 | pos.x = outer_rect.GetCenter().x - inner_size.x * 0.5f; |
| 556 | // legend reference point y |
| 557 | if (ImHasFlag(loc, ImPlotLocation_North) && !ImHasFlag(loc, ImPlotLocation_South)) |
| 558 | pos.y = outer_rect.Min.y + pad.y; |
| 559 | else if (!ImHasFlag(loc, ImPlotLocation_North) && ImHasFlag(loc, ImPlotLocation_South)) |
| 560 | pos.y = outer_rect.Max.y - pad.y - inner_size.y; |
| 561 | else |
| 562 | pos.y = outer_rect.GetCenter().y - inner_size.y * 0.5f; |
| 563 | pos.x = IM_ROUND(pos.x); |
| 564 | pos.y = IM_ROUND(pos.y); |
| 565 | return pos; |
| 566 | } |
| 567 | |
| 568 | ImVec2 CalcLegendSize(ImPlotItemGroup& items, const ImVec2& pad, const ImVec2& spacing, bool vertical) { |
| 569 | // vars |
no test coverage detected