| 1665 | } |
| 1666 | |
| 1667 | void PadAndDatumAxesX(ImPlotPlot& plot, float& pad_T, float& pad_B, ImPlotAlignmentData* align) { |
| 1668 | |
| 1669 | ImPlotContext& gp = *GImPlot; |
| 1670 | |
| 1671 | const float T = ImGui::GetTextLineHeight(); |
| 1672 | const float P = gp.Style.LabelPadding.y; |
| 1673 | const float K = gp.Style.MinorTickLen.x; |
| 1674 | |
| 1675 | int count_T = 0; |
| 1676 | int count_B = 0; |
| 1677 | float last_T = plot.AxesRect.Min.y; |
| 1678 | float last_B = plot.AxesRect.Max.y; |
| 1679 | |
| 1680 | for (int i = IMPLOT_NUM_X_AXES; i-- > 0;) { // FYI: can iterate forward |
| 1681 | ImPlotAxis& axis = plot.XAxis(i); |
| 1682 | if (!axis.Enabled) |
| 1683 | continue; |
| 1684 | const bool label = axis.HasLabel(); |
| 1685 | const bool ticks = axis.HasTickLabels(); |
| 1686 | const bool opp = axis.IsOpposite(); |
| 1687 | const bool time = axis.Scale == ImPlotScale_Time; |
| 1688 | if (opp) { |
| 1689 | if (count_T++ > 0) |
| 1690 | pad_T += K + P; |
| 1691 | if (label) { |
| 1692 | ImVec2 label_size = ImGui::CalcTextSize(plot.GetAxisLabel(axis)); |
| 1693 | pad_T += label_size.y + P; |
| 1694 | } |
| 1695 | if (ticks) |
| 1696 | pad_T += ImMax(T, axis.Ticker.MaxSize.y) + P + (time ? T + P : 0); |
| 1697 | axis.Datum1 = plot.CanvasRect.Min.y + pad_T; |
| 1698 | axis.Datum2 = last_T; |
| 1699 | last_T = axis.Datum1; |
| 1700 | } |
| 1701 | else { |
| 1702 | if (count_B++ > 0) |
| 1703 | pad_B += K + P; |
| 1704 | if (label) { |
| 1705 | ImVec2 label_size = ImGui::CalcTextSize(plot.GetAxisLabel(axis)); |
| 1706 | pad_B += label_size.y + P; |
| 1707 | } |
| 1708 | if (ticks) |
| 1709 | pad_B += ImMax(T, axis.Ticker.MaxSize.y) + P + (time ? T + P : 0); |
| 1710 | axis.Datum1 = plot.CanvasRect.Max.y - pad_B; |
| 1711 | axis.Datum2 = last_B; |
| 1712 | last_B = axis.Datum1; |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | if (align) { |
| 1717 | count_T = count_B = 0; |
| 1718 | float delta_T, delta_B; |
| 1719 | align->Update(pad_T,pad_B,delta_T,delta_B); |
| 1720 | for (int i = IMPLOT_NUM_X_AXES; i-- > 0;) { |
| 1721 | ImPlotAxis& axis = plot.XAxis(i); |
| 1722 | if (!axis.Enabled) |
| 1723 | continue; |
| 1724 | if (axis.IsOpposite()) { |
no test coverage detected