MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / PadAndDatumAxesY

Function PadAndDatumAxesY

Source/3rdParty/implot/implot.cpp:1736–1816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1734}
1735
1736void PadAndDatumAxesY(ImPlotPlot& plot, float& pad_L, float& pad_R, ImPlotAlignmentData* align) {
1737
1738 // [ pad_L ] [ pad_R ]
1739 // .................CanvasRect................
1740 // :TPWPK.PTPWP _____PlotRect____ PWPTP.KPWPT:
1741 // :A # |- A # |- -| # A -| # A:
1742 // :X | X | | X | x:
1743 // :I # |- I # |- -| # I -| # I:
1744 // :S | S | | S | S:
1745 // :3 # |- 0 # |-_______________-| # 1 -| # 2:
1746 // :.........................................:
1747 //
1748 // T = text height
1749 // P = label padding
1750 // K = minor tick length
1751 // W = label width
1752
1753 ImPlotContext& gp = *GImPlot;
1754
1755 const float T = ImGui::GetTextLineHeight();
1756 const float P = gp.Style.LabelPadding.x;
1757 const float K = gp.Style.MinorTickLen.y;
1758
1759 int count_L = 0;
1760 int count_R = 0;
1761 float last_L = plot.AxesRect.Min.x;
1762 float last_R = plot.AxesRect.Max.x;
1763
1764 for (int i = IMPLOT_NUM_Y_AXES; i-- > 0;) { // FYI: can iterate forward
1765 ImPlotAxis& axis = plot.YAxis(i);
1766 if (!axis.Enabled)
1767 continue;
1768 const bool label = axis.HasLabel();
1769 const bool ticks = axis.HasTickLabels();
1770 const bool opp = axis.IsOpposite();
1771 if (opp) {
1772 if (count_R++ > 0)
1773 pad_R += K + P;
1774 if (label)
1775 pad_R += T + P;
1776 if (ticks)
1777 pad_R += axis.Ticker.MaxSize.x + P;
1778 axis.Datum1 = plot.CanvasRect.Max.x - pad_R;
1779 axis.Datum2 = last_R;
1780 last_R = axis.Datum1;
1781 }
1782 else {
1783 if (count_L++ > 0)
1784 pad_L += K + P;
1785 if (label)
1786 pad_L += T + P;
1787 if (ticks)
1788 pad_L += axis.Ticker.MaxSize.x + P;
1789 axis.Datum1 = plot.CanvasRect.Min.x + pad_L;
1790 axis.Datum2 = last_L;
1791 last_L = axis.Datum1;
1792 }
1793 }

Callers 1

SetupFinishFunction · 0.85

Calls 4

HasLabelMethod · 0.80
HasTickLabelsMethod · 0.80
IsOppositeMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected