| 3999 | } |
| 4000 | |
| 4001 | bool DragLineY(int n_id, double* value, const ImVec4& col, float thickness, ImPlotDragToolFlags flags, bool* out_clicked, bool* out_hovered, bool* out_held) { |
| 4002 | ImGui::PushID("#IMPLOT_DRAG_LINE_Y"); |
| 4003 | ImPlotContext& gp = *GImPlot; |
| 4004 | IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr, "DragLineY() needs to be called between BeginPlot() and EndPlot()!"); |
| 4005 | SetupLock(); |
| 4006 | |
| 4007 | if (!ImHasFlag(flags,ImPlotDragToolFlags_NoFit) && FitThisFrame()) { |
| 4008 | FitPointY(*value); |
| 4009 | } |
| 4010 | |
| 4011 | const bool input = !ImHasFlag(flags, ImPlotDragToolFlags_NoInputs); |
| 4012 | const bool show_curs = !ImHasFlag(flags, ImPlotDragToolFlags_NoCursors); |
| 4013 | const bool no_delay = !ImHasFlag(flags, ImPlotDragToolFlags_Delayed); |
| 4014 | const float grab_half_size = ImMax(DRAG_GRAB_HALF_SIZE, thickness/2); |
| 4015 | float xl = gp.CurrentPlot->PlotRect.Min.x; |
| 4016 | float xr = gp.CurrentPlot->PlotRect.Max.x; |
| 4017 | float y = IM_ROUND(PlotToPixels(0, *value,IMPLOT_AUTO,IMPLOT_AUTO).y); |
| 4018 | |
| 4019 | const ImGuiID id = ImGui::GetCurrentWindow()->GetID(n_id); |
| 4020 | ImRect rect(xl,y-grab_half_size,xr,y+grab_half_size); |
| 4021 | bool hovered = false, held = false; |
| 4022 | |
| 4023 | ImGui::KeepAliveID(id); |
| 4024 | if (input) { |
| 4025 | bool clicked = ImGui::ButtonBehavior(rect,id,&hovered,&held); |
| 4026 | if (out_clicked) *out_clicked = clicked; |
| 4027 | if (out_hovered) *out_hovered = hovered; |
| 4028 | if (out_held) *out_held = held; |
| 4029 | } |
| 4030 | |
| 4031 | if ((hovered || held) && show_curs) |
| 4032 | ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS); |
| 4033 | |
| 4034 | float len = gp.Style.MajorTickLen.y; |
| 4035 | ImVec4 color = IsColorAuto(col) ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : col; |
| 4036 | ImU32 col32 = ImGui::ColorConvertFloat4ToU32(color); |
| 4037 | |
| 4038 | bool modified = false; |
| 4039 | if (held && ImGui::IsMouseDragging(0)) { |
| 4040 | *value = ImPlot::GetPlotMousePos(IMPLOT_AUTO,IMPLOT_AUTO).y; |
| 4041 | modified = true; |
| 4042 | } |
| 4043 | |
| 4044 | PushPlotClipRect(); |
| 4045 | ImDrawList& DrawList = *GetPlotDrawList(); |
| 4046 | if (modified && no_delay) |
| 4047 | y = IM_ROUND(PlotToPixels(0, *value,IMPLOT_AUTO,IMPLOT_AUTO).y); |
| 4048 | DrawList.AddLine(ImVec2(xl,y), ImVec2(xr,y), col32, thickness); |
| 4049 | DrawList.AddLine(ImVec2(xl,y), ImVec2(xl+len,y), col32, 3*thickness); |
| 4050 | DrawList.AddLine(ImVec2(xr,y), ImVec2(xr-len,y), col32, 3*thickness); |
| 4051 | PopPlotClipRect(); |
| 4052 | |
| 4053 | ImGui::PopID(); |
| 4054 | return modified; |
| 4055 | } |
| 4056 | |
| 4057 | bool DragRect(int n_id, double* x_min, double* y_min, double* x_max, double* y_max, const ImVec4& col, ImPlotDragToolFlags flags, bool* out_clicked, bool* out_hovered, bool* out_held) { |
| 4058 | ImGui::PushID("#IMPLOT_DRAG_RECT"); |
no test coverage detected