imgui-node-editor icon indicating copy to clipboard operation
imgui-node-editor copied to clipboard

Allow changing the size without affecting scale

Open gnif opened this issue 3 years ago • 0 comments

This is a feature request.

Currently the graph wont zoom if you resize it on the X axis, but will on the Y axis. Please provide a flag to allow resizing the node editor while maintaining the current central position without affecting the scale/zoom.

The following change performs this however Begin would need altering with a flags argument (or something similar) to opt into this feature.

imgui_node_editor.cpp:1130

auto currentVisibleRect = m_Canvas.ViewRect();
auto width   = currentVisibleRect.GetWidth();
auto height  = currentVisibleRect.GetHeight();
auto centerX = (previousVisibleRect.Max.x + previousVisibleRect.Min.x) * 0.5f;
auto centerY = (previousVisibleRect.Max.y + previousVisibleRect.Min.y) * 0.5f;

previousVisibleRect.Min.x = centerX - 0.5f * width;
previousVisibleRect.Min.y = centerY - 0.5f * height;
previousVisibleRect.Max.x = previousVisibleRect.Min.x + width;
previousVisibleRect.Max.y = previousVisibleRect.Min.y + height;

gnif avatar Jul 21 '22 07:07 gnif