| 3876 | } |
| 3877 | |
| 3878 | bool DragLineY(int n_id, double* value, const ImVec4& col, float thickness, ImPlotDragToolFlags flags) { |
| 3879 | ImGui::PushID("#IMPLOT_DRAG_LINE_Y"); |
| 3880 | ImPlotContext& gp = *GImPlot; |
| 3881 | IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "DragLineY() needs to be called between BeginPlot() and EndPlot()!"); |
| 3882 | SetupLock(); |
| 3883 | |
| 3884 | if (!ImHasFlag(flags,ImPlotDragToolFlags_NoFit) && FitThisFrame()) { |
| 3885 | FitPointY(*value); |
| 3886 | } |
| 3887 | |
| 3888 | const bool input = !ImHasFlag(flags, ImPlotDragToolFlags_NoInputs); |
| 3889 | const bool show_curs = !ImHasFlag(flags, ImPlotDragToolFlags_NoCursors); |
| 3890 | const bool no_delay = !ImHasFlag(flags, ImPlotDragToolFlags_Delayed); |
| 3891 | const float grab_half_size = ImMax(DRAG_GRAB_HALF_SIZE, thickness/2); |
| 3892 | float xl = gp.CurrentPlot->PlotRect.Min.x; |
| 3893 | float xr = gp.CurrentPlot->PlotRect.Max.x; |
| 3894 | float y = IM_ROUND(PlotToPixels(0, *value,IMPLOT_AUTO,IMPLOT_AUTO).y); |
| 3895 | |
| 3896 | const ImGuiID id = ImGui::GetCurrentWindow()->GetID(n_id); |
| 3897 | ImRect rect(xl,y-grab_half_size,xr,y+grab_half_size); |
| 3898 | bool hovered = false, held = false; |
| 3899 | |
| 3900 | ImGui::KeepAliveID(id); |
| 3901 | if (input) |
| 3902 | ImGui::ButtonBehavior(rect,id,&hovered,&held); |
| 3903 | |
| 3904 | if ((hovered || held) && show_curs) |
| 3905 | ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS); |
| 3906 | |
| 3907 | float len = gp.Style.MajorTickLen.y; |
| 3908 | ImVec4 color = IsColorAuto(col) ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : col; |
| 3909 | ImU32 col32 = ImGui::ColorConvertFloat4ToU32(color); |
| 3910 | |
| 3911 | bool dragging = false; |
| 3912 | if (held && ImGui::IsMouseDragging(0)) { |
| 3913 | *value = ImPlot::GetPlotMousePos(IMPLOT_AUTO,IMPLOT_AUTO).y; |
| 3914 | dragging = true; |
| 3915 | } |
| 3916 | |
| 3917 | PushPlotClipRect(); |
| 3918 | ImDrawList& DrawList = *GetPlotDrawList(); |
| 3919 | if (dragging && no_delay) |
| 3920 | y = IM_ROUND(PlotToPixels(0, *value,IMPLOT_AUTO,IMPLOT_AUTO).y); |
| 3921 | DrawList.AddLine(ImVec2(xl,y), ImVec2(xr,y), col32, thickness); |
| 3922 | DrawList.AddLine(ImVec2(xl,y), ImVec2(xl+len,y), col32, 3*thickness); |
| 3923 | DrawList.AddLine(ImVec2(xr,y), ImVec2(xr-len,y), col32, 3*thickness); |
| 3924 | PopPlotClipRect(); |
| 3925 | |
| 3926 | ImGui::PopID(); |
| 3927 | return dragging; |
| 3928 | } |
| 3929 | |
| 3930 | bool DragRect(int n_id, double* x_min, double* y_min, double* x_max, double* y_max, const ImVec4& col, ImPlotDragToolFlags flags) { |
| 3931 | ImGui::PushID("#IMPLOT_DRAG_RECT"); |
no test coverage detected