Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add IsPlotChanging() #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

SamuMazzi
Copy link
Contributor

As pointed out in the TODO.md, this PR implements a function to detect if the limits of the plots are changing.

As pointed out in the `TODO.md`
@epezent
Copy link
Owner

epezent commented Dec 24, 2024

@SamuMazzi Thanks for taking a swing at this. A couple things:

I think the following code in SetupAxis will only be called every frame if the user explicitly calls SetupAxis/SetupAxes in their plot code block. Since this is not required, this feature will not work in some scenarios (e.g. the Plot Shaded demo and others)

// cache previous range
axis.PreviousRange = ImPlotRange(axis.Range.Min, axis.Range.Max);

I think the solution here is to cache the previous range(s) in SetupFinish, just before UpdateInput. Lemme know what you think.

Second, I suggest we name this function something more descriptive and also consider if it should be callable per-axis, for instance:

bool IsAxisRangeChanging(ImAxis axis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants