| 1868 | constexpr float BOX_SELECT_DRAG_THRESHOLD = 4.0f; |
| 1869 | |
| 1870 | bool UpdateInput(ImPlotPlot& plot) { |
| 1871 | |
| 1872 | bool changed = false; |
| 1873 | |
| 1874 | ImPlotContext& gp = *GImPlot; |
| 1875 | ImGuiIO& IO = ImGui::GetIO(); |
| 1876 | |
| 1877 | // BUTTON STATE ----------------------------------------------------------- |
| 1878 | |
| 1879 | const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowOverlap |
| 1880 | | ImGuiButtonFlags_PressedOnClick |
| 1881 | | ImGuiButtonFlags_PressedOnDoubleClick |
| 1882 | | ImGuiButtonFlags_MouseButtonLeft |
| 1883 | | ImGuiButtonFlags_MouseButtonRight |
| 1884 | | ImGuiButtonFlags_MouseButtonMiddle; |
| 1885 | const ImGuiButtonFlags axis_button_flags = ImGuiButtonFlags_FlattenChildren |
| 1886 | | plot_button_flags; |
| 1887 | |
| 1888 | const bool plot_clicked = ImGui::ButtonBehavior(plot.PlotRect,plot.ID,&plot.Hovered,&plot.Held,plot_button_flags); |
| 1889 | #if (IMGUI_VERSION_NUM < 18966) |
| 1890 | ImGui::SetItemAllowOverlap(); // Handled by ButtonBehavior() |
| 1891 | #endif |
| 1892 | |
| 1893 | if (plot_clicked) { |
| 1894 | if (!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect) && IO.MouseClicked[gp.InputMap.Select] && ImHasFlag(IO.KeyMods, gp.InputMap.SelectMod)) { |
| 1895 | plot.Selecting = true; |
| 1896 | plot.SelectStart = IO.MousePos; |
| 1897 | plot.SelectRect = ImRect(0,0,0,0); |
| 1898 | } |
| 1899 | if (IO.MouseDoubleClicked[gp.InputMap.Fit]) { |
| 1900 | plot.FitThisFrame = true; |
| 1901 | for (int i = 0; i < ImAxis_COUNT; ++i) |
| 1902 | plot.Axes[i].FitThisFrame = true; |
| 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | const bool can_pan = IO.MouseDown[gp.InputMap.Pan] && ImHasFlag(IO.KeyMods, gp.InputMap.PanMod); |
| 1907 | |
| 1908 | plot.Held = plot.Held && can_pan; |
| 1909 | |
| 1910 | bool x_click[IMPLOT_NUM_X_AXES] = {false}; |
| 1911 | bool x_held[IMPLOT_NUM_X_AXES] = {false}; |
| 1912 | bool x_hov[IMPLOT_NUM_X_AXES] = {false}; |
| 1913 | |
| 1914 | bool y_click[IMPLOT_NUM_Y_AXES] = {false}; |
| 1915 | bool y_held[IMPLOT_NUM_Y_AXES] = {false}; |
| 1916 | bool y_hov[IMPLOT_NUM_Y_AXES] = {false}; |
| 1917 | |
| 1918 | for (int i = 0; i < IMPLOT_NUM_X_AXES; ++i) { |
| 1919 | ImPlotAxis& xax = plot.XAxis(i); |
| 1920 | if (xax.Enabled) { |
| 1921 | ImGui::KeepAliveID(xax.ID); |
| 1922 | x_click[i] = ImGui::ButtonBehavior(xax.HoverRect,xax.ID,&xax.Hovered,&xax.Held,axis_button_flags); |
| 1923 | if (x_click[i] && IO.MouseDoubleClicked[gp.InputMap.Fit]) |
| 1924 | plot.FitThisFrame = xax.FitThisFrame = true; |
| 1925 | xax.Held = xax.Held && can_pan; |
| 1926 | x_hov[i] = xax.Hovered || plot.Hovered; |
| 1927 | x_held[i] = xax.Held || plot.Held; |
no test coverage detected