epezent / implot

Immediate Mode Plotting
MIT License
4.64k stars 516 forks source link

Dragging at the middle of DragRect and the other points behaves differently #437

Open dibalikpohon opened 1 year ago

dibalikpohon commented 1 year ago

Hi,

I am having some issue with DragRect. So I put a DragRect after box-selecting and calling ImPlot::CancelPlotSelection() but I have to round the value of ImPlot::GetPlotSelection() because I am using a integer value for the X axis as the plot.

Dragging the sides of DragRect behaves as what I expected. The DragRect "snaps" to the closest integer value from the point. I also intentionally made the DragRect to expand across Y axis.

https://user-images.githubusercontent.com/73155095/211757057-464532d1-172f-4dd1-921a-23ed1d44d81d.mp4

But I seemingly cannot drag in the middle of DragRect, it behaves like jelly! I was expecting that the DragRect would snap to the closest integer value like the video above.

https://user-images.githubusercontent.com/73155095/211757556-909eb070-fb0c-4070-9bff-712c7382f645.mp4

By the way, I Implement the DragRect like this, which I believe it is correct way to put DragRect if it is dragged

ImPlotRect selectedPlot;
if (ImPlot::DragRect(1, &(selectedPlot.X.Min), &(selectedPlot.Y.Min), &(selectedPlot.X.Max), &(selectedPlot.Y.Max), ImVec4(1,0,1,1))) 
{
        roundValue(selectedPlot);
        selectedPlot.Y.Min = notes_length;
        selectedPlot.Y.Max = 0;
}
epezent commented 1 year ago

Can you try this with the ImPlotDragToolFlags_Delayed flag passed to DragRect?