Repository navigation
Conversation
Doome161
marked this pull request as draft
October 25, 2026 19:31
Doome161
marked this pull request as ready for review
October 25, 2026 19:50
3 of 6 tasks
Owner
|
Thank you for this. It is a good fix for the Qt crop bug (QTBUG-77400, #121). I squashed it into one commit and kept you as the author. It is now in #544. On top of your change I fitted the look to the Qt shadow (offset 4, blur 20), turned it on by default, renamed the option to One note: I could not confirm a performance gain. On macOS (Apple M1, Qt 6.12) the repaint time is about the same as with the Qt effect, and higher with many overlapping nodes. The approach still fixes the Qt bug, so it should be merged. The docs say this. Closing as superseded by #544. |
paceholder
pushed a commit
that referenced
this pull request
Nov 22, 2026
The Qt drop shadow effect together with the node pixmap cache crops a node that is larger than the view when the view is zoomed in. This is QTBUG-77400 and Qt has not fixed it. It was reported as #121 in 2017. The bug came back. b56a7d0 added ShadowEnabled and turned the shadow off by default, which avoided the cropping. 571499b turned it on again by default, so the cropping returned for all nodes. Doome161 proposed a shadow that needs no graphics effect in #534. This commit is based on that proposal. DefaultNodePainter draws the shadow from translucent rounded rectangles. The layers are fitted to QGraphicsDropShadowEffect with offset 4 and blur radius 20. The opacity matches within about 4 of 255 at 0 to 24 px from the node edge. NodeGraphicsObject creates no graphics effect in this mode. NodeStyle::PaintedShadowEnabled switches the mode. It is true in DefaultStyle.json. A style JSON without the key reads as false and keeps the graphics effect. Custom painters have no shadow in this mode and must draw their own, or set the key to false. The custom_painter example does that. The shadow reaches 11 px above and left, and 19 px below and right, so it fits the 20 px margins of the default geometries. Performance was not confirmed. On macOS (Apple M1, Qt 6.12) the repaint time is about the same as with the Qt effect, and higher with many overlapping nodes. The change is made for the crop fix, not for speed. The tests cover the default, the JSON round trip, the choice of mode, the footprint and the drawing. One test zooms in on a node larger than the view and checks that the node is drawn completely. It fails with the graphics effect. The docs and the FAQ describe the mode and the Qt bug. Fixes #121
paceholder
pushed a commit
that referenced
this pull request
Nov 22, 2026
The Qt drop shadow effect together with the node pixmap cache crops a node that is larger than the view when the view is zoomed in. This is QTBUG-77400 and Qt has not fixed it. It was reported as #121 in 2017. The bug came back. b56a7d0 added ShadowEnabled and turned the shadow off by default, which avoided the cropping. 571499b turned it on again by default, so the cropping returned for all nodes. Doome161 proposed a shadow that needs no graphics effect in #534. This commit is based on that proposal. DefaultNodePainter draws the shadow from translucent rounded rectangles. The layers are fitted to QGraphicsDropShadowEffect with offset 4 and blur radius 20. The opacity matches within about 4 of 255 at 0 to 24 px from the node edge. NodeGraphicsObject creates no graphics effect in this mode. NodeStyle::PaintedShadowEnabled switches the mode. It is true in DefaultStyle.json. A style JSON without the key reads as false and keeps the graphics effect. Custom painters have no shadow in this mode and must draw their own, or set the key to false. The custom_painter example does that. The shadow reaches 11 px above and left, and 19 px below and right, so it fits the 20 px margins of the default geometries. Performance was not confirmed. On macOS (Apple M1, Qt 6.12) the repaint time is about the same as with the Qt effect, and higher with many overlapping nodes. The change is made for the crop fix, not for speed. The tests cover the default, the JSON round trip, the choice of mode, the footprint and the drawing. One test zooms in on a node larger than the view and checks that the node is drawn completely. It fails with the graphics effect. The docs and the FAQ describe the mode and the Qt bug. Fixes #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
This PR introduces optional lightweight node shadows as a performance-oriented alternative to
QGraphicsDropShadowEffect.The existing shadow implementation can be expensive when rendering multiple nodes, particularly during interactive operations such as dragging and zooming.
The new implementation draws a soft shadow approximation directly in
DefaultNodePainterusing translucent rounded rectangles, avoiding the overhead of a separate graphics effect.Changes
NodeStyle::FastShadowEnabled(default:false).NodeGraphicsObjectto skipQGraphicsDropShadowEffectwhen lightweight shadows are enabled.DefaultNodePainter.Usage
Enable lightweight shadows through
NodeStyle:Compatibility
The feature is strictly opt-in. Existing applications retain their current rendering behavior without modifications.
Trade-offs:
Testing
Added
TestFastNodeShadows.cpp, covering:Note: The regression tests have been implemented but have not yet been independently executed and verified. Performance benchmarks and visual testing across different zoom levels and DPI settings are also recommended.
Breaking changes?
No breaking changes are intended.
The new
FastShadowEnabledproperty defaults tofalse, preserving existing behavior and visual appearance.Related issue
Related to #121 — Maximum Zoom In causes improper node rendering.
This PR provides an optional alternative to the existing graphics effect. It does not claim to resolve the underlying Qt caching issue (QTBUG-77400).
The existing workaround using
ShadowEnabled = falseremains available.