Skip to content

Add opt-in lightweight node shadows - #534

Open
Doome161 wants to merge 9 commits into
paceholder:masterfrom
Doome161:feature/opt-in-lightweight-shadows
Open

Doome161 wants to merge 9 commits into
paceholder:masterfrom
Doome161:feature/opt-in-lightweight-shadows

Conversation

@Doome161

@Doome161 Doome161 commented Oct 25, 2026 •

Copy link
Copy Markdown

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation/refactoring

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 DefaultNodePainter using translucent rounded rectangles, avoiding the overhead of a separate graphics effect.

Changes

  • Introduced NodeStyle::FastShadowEnabled (default: false).
  • Added JSON serialization and deserialization for the new setting.
  • Updated NodeGraphicsObject to skip QGraphicsDropShadowEffect when lightweight shadows are enabled.
  • Implemented lightweight shadow rendering in DefaultNodePainter.
  • Added regression tests and documentation.

Usage

Enable lightweight shadows through NodeStyle:

QtNodes::NodeStyle style;
style.ShadowEnabled = true;
style.FastShadowEnabled = true;

Compatibility

The feature is strictly opt-in. Existing applications retain their current rendering behavior without modifications.

Trade-offs:

  • The lightweight shadows are an approximation and are not pixel-identical to Qt's drop-shadow effect.
  • Custom node painters must provide their own shadow rendering when this option is enabled.
  • No global caching behavior or embedded-widget cache modes are modified.

Testing

  • Qt version tested: Not independently verified for this PR submission.
  • Existing tests still pass
  • Added tests for new functionality (if applicable)

Added TestFastNodeShadows.cpp, covering:

  • Default behavior and backward compatibility with existing style configurations.
  • JSON serialization and deserialization.
  • Correct selection between traditional and lightweight shadows.
  • Shadow geometry and rendering boundaries.

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 FastShadowEnabled property defaults to false, 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 = false remains available.

@Doome161
Doome161 marked this pull request as draft October 25, 2026 19:31
@Doome161
Doome161 marked this pull request as ready for review October 25, 2026 19:50
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.

1 participant