imgui-node-editor
imgui-node-editor copied to clipboard
Allow changing the size without affecting scale
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;