MCPcopy Create free account
hub / github.com/clementgallet/libTAS / UpdateInput

Function UpdateInput

src/external/imgui/implot.cpp:1828–2093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1826static const float BOX_SELECT_DRAG_THRESHOLD = 4.0f;
1827
1828bool UpdateInput(ImPlotPlot& plot) {
1829
1830 bool changed = false;
1831
1832 ImPlotContext& gp = *GImPlot;
1833 ImGuiIO& IO = ImGui::GetIO();
1834
1835 // BUTTON STATE -----------------------------------------------------------
1836
1837 const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowOverlap
1838 | ImGuiButtonFlags_PressedOnClick
1839 | ImGuiButtonFlags_PressedOnDoubleClick
1840 | ImGuiButtonFlags_MouseButtonLeft
1841 | ImGuiButtonFlags_MouseButtonRight
1842 | ImGuiButtonFlags_MouseButtonMiddle;
1843 const ImGuiButtonFlags axis_button_flags = ImGuiButtonFlags_FlattenChildren
1844 | plot_button_flags;
1845
1846 const bool plot_clicked = ImGui::ButtonBehavior(plot.PlotRect,plot.ID,&plot.Hovered,&plot.Held,plot_button_flags);
1847#if (IMGUI_VERSION_NUM < 18966)
1848 ImGui::SetItemAllowOverlap(); // Handled by ButtonBehavior()
1849#endif
1850
1851 if (plot_clicked) {
1852 if (!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect) && IO.MouseClicked[gp.InputMap.Select] && ImHasFlag(IO.KeyMods, gp.InputMap.SelectMod)) {
1853 plot.Selecting = true;
1854 plot.SelectStart = IO.MousePos;
1855 plot.SelectRect = ImRect(0,0,0,0);
1856 }
1857 if (IO.MouseDoubleClicked[gp.InputMap.Fit]) {
1858 plot.FitThisFrame = true;
1859 for (int i = 0; i < ImAxis_COUNT; ++i)
1860 plot.Axes[i].FitThisFrame = true;
1861 }
1862 }
1863
1864 const bool can_pan = IO.MouseDown[gp.InputMap.Pan] && ImHasFlag(IO.KeyMods, gp.InputMap.PanMod);
1865
1866 plot.Held = plot.Held && can_pan;
1867
1868 bool x_click[IMPLOT_NUM_X_AXES] = {false};
1869 bool x_held[IMPLOT_NUM_X_AXES] = {false};
1870 bool x_hov[IMPLOT_NUM_X_AXES] = {false};
1871
1872 bool y_click[IMPLOT_NUM_Y_AXES] = {false};
1873 bool y_held[IMPLOT_NUM_Y_AXES] = {false};
1874 bool y_hov[IMPLOT_NUM_Y_AXES] = {false};
1875
1876 for (int i = 0; i < IMPLOT_NUM_X_AXES; ++i) {
1877 ImPlotAxis& xax = plot.XAxis(i);
1878 if (xax.Enabled) {
1879 ImGui::KeepAliveID(xax.ID);
1880 x_click[i] = ImGui::ButtonBehavior(xax.HoverRect,xax.ID,&xax.Hovered,&xax.Held,axis_button_flags);
1881 if (x_click[i] && IO.MouseDoubleClicked[gp.InputMap.Fit])
1882 plot.FitThisFrame = xax.FitThisFrame = true;
1883 xax.Held = xax.Held && can_pan;
1884 x_hov[i] = xax.Hovered || plot.Hovered;
1885 x_held[i] = xax.Held || plot.Held;

Callers 1

SetupFinishFunction · 0.85

Calls 15

ImHasFlagFunction · 0.85
AnyAxesHoveredFunction · 0.85
AnyAxesHeldFunction · 0.85
ImLengthSqrFunction · 0.85
ImRemapFunction · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85
AllAxesInputLockedFunction · 0.85
IsInvertedMethod · 0.80
IsPanLockedMethod · 0.80
PixelsToPlotMethod · 0.80
SetMinMethod · 0.80

Tested by

no test coverage detected