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

Is there a way to Suspend/Resume Canvas zoom? #219

Closed
LittleCoinCoin opened this issue May 2, 2023 · 3 comments
Closed

Is there a way to Suspend/Resume Canvas zoom? #219

LittleCoinCoin opened this issue May 2, 2023 · 3 comments

Comments

@LittleCoinCoin
Copy link

Hello,

I would like to be able to use the mouse wheel for other things than zooming inand out in the canvas.

I am aware of the API to set custom zoom levels through the config #174
I was thinking of switching between a range of pre-defined zoom levels and an ImVector that contains only 1 zoom level (the current zoom level). That way, even if the user uses the mouse scroll, the zoom level will not change.

something along the lines of:

ed::Config& config = ed::GetConfig(ed::GetCurrentEditor());
config.CustomZoomLevels.clear();
config.CustomZoomLevels.push_back(ed::GetCurrentZoom());

but the

ed::GetConfig(ed::GetCurrentEditor());

returns a const reference
So, it seems custom zoom levels can only be set before the context is created. Is this correct?

I was also thinking of accessing the NavigateAction and try to use either StopNavigation or FinishNavigation but I couldn't find a way to use GetCurrentAction since the global API gives access to ax::NodeEditor::EditorContext and not the internal counter part ax::NodeEditor::Detail::EditorContext.

So, I'll probably go meddle in the source code and try to add a few access methods to the global API.
But, maybe I missed something (obvious?). Could anyone be kind enough to point it out?

Thank you in advance!

@LittleCoinCoin LittleCoinCoin changed the title Is there a way to Suspend/Resume Canvas zoom Is there a way to Suspend/Resume Canvas zoom? May 2, 2023
@LittleCoinCoin
Copy link
Author

Please, see #220 for a suggestion on how to implement it.

@thedmd
Copy link
Owner

thedmd commented May 2, 2023

Answer to your question depends on the version of ImGui you're using.

With ImGui 1.89 and develop version of node editor this problem may no longer exists due to ImGui implementing concept of input ownership. Child window with scroll bar might get mouse wheel event before node editor does. Might, because I didn't run a test yet. This would be best solution as it does not need to introduce any new API.

With older ImGui or node editor your workaround looks reasonable. Works for happy path. Can trip on some exotic edge cases but I didn't found any obvious way to invoke such scenarios.

Are you able to confirm update does solve your problem?

@LittleCoinCoin
Copy link
Author

Hello,

Thank you for the quick answer!

With ImGui 1.89 and develop version of node editor this problem may no longer exists due to ImGui implementing concept of input ownership. Child window with scroll bar might get mouse wheel event before node editor does. Might, because I didn't run a test yet. This would be best solution as it does not need to introduce any new API.

I had not realised v1.89 offered such feature. Thank you for sharing! My project is running under v1.88, however, and I have so many things to do that I don't see myself trying to update right now.

Are you able to confirm update does solve your problem?
The solution I suggested in #220 does solve my problem but I have not extensively tested it yet. I only use it for my list boxes as of now so.

I will close this issue and I will let you (of course) decide what to do with the pull request. After all, if v1.89 allows for a less invasive solution, you may want to go in that direction. I think I will eventually check this but it might take months before I actually do it. So, maybe, you can leave the pull request open and I will update it whether I find problems with the current implementation or switch to v1.89.

Best!

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

No branches or pull requests

2 participants