Skip to content

Enhance boxGrob with corner radius fix and equalizeHeights feature#77

Merged
gforge merged 7 commits into
masterfrom
develop
Jun 19, 2026
Merged

Enhance boxGrob with corner radius fix and equalizeHeights feature#77
gforge merged 7 commits into
masterfrom
develop

Conversation

@gforge

@gforge gforge commented Jun 19, 2026

Copy link
Copy Markdown
Owner

This pull request introduces several new features and improvements to the flowchart and box layout system, with a focus on enhancing connector flexibility, box appearance consistency, and box selection ergonomics. The most significant changes include new axis-aligned connector types, a new way to set fixed corner radii for boxes, a new function for equalizing box heights, and improved subelement selection using regex. There are also updates to the documentation and CI configuration.

Flowchart connectors and box alignment improvements:

  • Added new "vertical_axis" and "horizontal_axis" connector types to connectGrob(), enabling strict axis-aligned connectors that preserve the source box's x- or y-axis and project it onto the target boundary, ensuring true 90-degree arrows between vertically or horizontally separated boxes. Helper functions prClampUnit, prSpansOverlap, prVerticalAxisEdges, and prHorizontalAxisEdges were added to support this logic. (NEWS.md, R/boxGrobs_connect.R, R/boxGrobs_connect_pr_helpers.R, R/boxGrobs_connect_pr_single_boxes.R) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
  • Enhanced "side" connectors with end_side, side_fan_in_route, and side_fan_in_offset arguments for more control over entry/exit sides and routing of grouped connectors. (R/boxGrobs_connect.R, R/boxGrobs_connect_pr_single_boxes.R) [1] [2] [3] [4] [5] [6] [7]

Box appearance and sizing:

  • Added a box_fn_args parameter to boxGrob(), defaulting to a fixed 5 pt corner radius for all boxes, ensuring consistent appearance regardless of box size. This can be overridden per box or globally. The implementation filters arguments to match the box function's accepted parameters. (NEWS.md, R/boxGrobs_boxGrob.R) [1] [2] [3] [4] [5]
  • Introduced equalizeHeights() for box lists, mirroring the existing equalizeWidths() function, to set selected boxes to a shared height. Exported in the namespace. (NEWS.md, NAMESPACE) [1] [2]

Box list selection and alignment:

  • Added support for regex selectors in the subelement argument of alignment functions, allowing more flexible and expressive selection of boxes within lists for alignment operations. (R/boxGrobs_align.R) [1] [2] [3]

Other updates:

  • Exported the new position() S3 generic and methods for boxes and coordinates, and updated the .Rbuildignore file and CI workflow to use the latest actions/checkout@v4. (NAMESPACE, .Rbuildignore, .github/workflows/ci.yaml) [1] [2] [3] [4]

gforge and others added 6 commits June 9, 2026 19:51
- Add box_fn_args parameter to boxGrob() forwarding extra args to the
  box drawing function. Default is list(r = unit(5, 'pt')) giving every
  roundrectGrob box a fixed 5 pt corner radius regardless of size,
  fixing the issue where larger boxes had visibly rounder corners.
  Args unsupported by the box_fn (e.g. custom shapes) are silently
  dropped via formals() inspection so existing code is unaffected.
  Override per-box or globally via options(boxGrobFnArgs = list(...)).

- Add equalizeHeights() mirroring equalizeWidths(). Sets selected boxes
  to a shared height (defaults to the tallest among the selection) and
  supports the same subelement path syntax.

- Add tests: test-boxGrob-corner-radius.R, test-equalizeHeights.R
- Add visual tests: tests/visual_tests/corner_box.R, equal_heights.R
- Export equalizeHeights() in NAMESPACE
- Update NEWS.md
Adds initial SVG reference snapshots for boxGrob and connectGrob visual
regression tests so CI no longer fails with "Adding new file snapshot".
Also upgrades actions/checkout from v3 to v4 to fix Node.js 20 deprecation
warning (forced to Node.js 24 from June 16th 2026).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `vertical_axis` and `horizontal_axis` connector types
- Preserve source x/y axes and clamp target landing points to box boundaries
- Document how axis connectors differ from `vertical` / `horizontal`
- Add examples, NEWS entry, and vignette coverage
- Add tests for axis connector geometry, errors, and list behavior
Copilot AI review requested due to automatic review settings June 19, 2026 21:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Gmisc’s grid-based flowchart/box layout utilities by adding new connector behaviors, improving box rendering consistency (fixed corner radii), and expanding box-list ergonomics (regex-based subelement selection, new equalizeHeights(), and deferred position() references).

Changes:

  • Added axis-preserving connector types (vertical_axis, horizontal_axis) plus richer side connector controls for flowcharts.
  • Introduced fixed-radius box corners via box_fn_args (defaulting to r = unit(5, "pt")) and added equalizeHeights() alongside equalizeWidths().
  • Implemented regex selectors for subelement across spread/align/move/equalize, plus a new position() helper for relative moves; updated docs/examples/tests accordingly.

Reviewed changes

Copilot reviewed 34 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vignettes/Grid-based_flowcharts.Rmd Updates vignette examples to showcase dotted return arrows, equalizeHeights(), and axis-preserving connectors; makes vignette date dynamic.
tests/visual_tests/equal_heights.R Adds a visual script demonstrating equalizeHeights() behavior.
tests/visual_tests/corner_box.R Adds a visual script demonstrating fixed corner radii via box_fn_args.
tests/testthat/test-subelement-regex.R Adds unit tests for regex-based subelement selection (and mixed selector inputs).
tests/testthat/test-flowchart-issue76-connectors.R Adds regression tests for grouped side return arrows, regex selectors in S3 pipeline calls, and position() usage.
tests/testthat/test-equalizeHeights.R Adds unit tests for equalizeHeights() behavior and invariants (center preservation).
tests/testthat/test-connectGrob-axis-connectors.R Adds tests covering new vertical_axis/horizontal_axis connector geometry and edge cases.
tests/testthat/test-boxGrob-corner-radius.R Adds tests for box_fn_args forwarding and option-based defaults.
tests/testthat/_snaps/vdiffr/basic-box.svg Updates vdiffr snapshot affected by box rendering changes.
R/boxGrobs_subelement_select.R Adds prResolveSubelementSelector() to normalize literal/list/regex selectors into canonical paths.
R/boxGrobs_spread.R Extends subelement handling to support regex selectors via prResolveSubelementSelector().
R/boxGrobs_s3_spread.R Fixes S3 spread wrapper argument construction so x is passed correctly in do.call().
R/boxGrobs_s3_connect.R Enhances S3 connect() to accept regex selectors and grouped fan-in behavior for type = "side".
R/boxGrobs_position.R Introduces position() S3 generic and deferred position references for move-time resolution.
R/boxGrobs_move.R Adds regex subelement support and resolves deferred position() references during moves.
R/boxGrobs_equalizeWidths.R Extends equalizeWidths() selector handling and adds new exported equalizeHeights().
R/boxGrobs_coords.R Expands coords() documentation and references the new position() helper.
R/boxGrobs_connect.R Adds new connector types, side-connector params, and type aliases; updates docs.
R/boxGrobs_connect_strategies.R Wires new connector types and side-connector args through the strategy dispatch.
R/boxGrobs_connect_pr_single_boxes.R Implements vertical_axis/horizontal_axis and enhances side connector entry/exit behavior.
R/boxGrobs_connect_pr_helpers.R Adds helper functions for clamping/projection and overlap detection for axis connectors.
R/boxGrobs_boxGrob.R Adds box_fn_args (default fixed radius) and filters forwarded args based on the shape function signature.
R/boxGrobs_align.R Extends subelement handling to support regex selectors via prResolveSubelementSelector().
NEWS.md Documents the new connectors, box_fn_args, equalizeHeights(), regex selectors, dotted arrows, and position().
NAMESPACE Exports equalizeHeights() and position() and registers position.* S3 methods.
man/spread.Rd Documents regex selector support for subelement; links to new helpers.
man/position.Rd Adds generated Rd documentation for the new position() generic/methods.
man/phaseLabel.Rd Updates “See also” links to include new helpers.
man/moveBox.Rd Documents regex selector support for subelement and links to new helpers.
man/move.Rd Updates “See also” links to include new helpers.
man/insert.Rd Updates “See also” links to include new helpers.
man/flowchart.Rd Updates “See also” links to include new helpers.
man/equalizeWidths.Rd Documents regex selector support for subelement; links to new helpers.
man/equalizeHeights.Rd Adds generated Rd documentation for equalizeHeights().
man/distance.Rd Updates “See also” links to include new helpers.
man/coords.Rd Expands coords documentation and links to position()/equalizeHeights().
man/connect.Rd Documents new connector types and new side arguments; expands examples.
man/boxShapes.Rd Updates “See also” links to include new helpers.
man/boxPropGrob.Rd Updates “See also” links to include new helpers.
man/boxHeaderGrob.Rd Updates “See also” links to include new helpers.
man/box.Rd Documents box_fn_args and updates “See also” links.
man/append.Rd Updates “See also” links to include new helpers.
man/align.Rd Documents regex selector support for subelement; updates “See also” links.
inst/examples/connectGrob_example.R Adds example pages demonstrating vertical_axis/horizontal_axis behavior.
.Rbuildignore Ignores generated README.html and Rplots.pdf.
.github/workflows/ci.yaml Updates CI to use actions/checkout@v4.
Files not reviewed (11)
  • man/align.Rd: Generated file
  • man/append.Rd: Generated file
  • man/box.Rd: Generated file
  • man/boxHeaderGrob.Rd: Generated file
  • man/boxPropGrob.Rd: Generated file
  • man/boxShapes.Rd: Generated file
  • man/connect.Rd: Generated file
  • man/coords.Rd: Generated file
  • man/distance.Rd: Generated file
  • man/equalizeHeights.Rd: Generated file
  • man/equalizeWidths.Rd: Generated file

Comment thread R/boxGrobs_boxGrob.R Outdated
Comment thread R/boxGrobs_boxGrob.R
Comment thread .Rbuildignore Outdated
Comment thread R/boxGrobs_connect_pr_single_boxes.R Outdated
@gforge gforge merged commit 69dcabf into master Jun 19, 2026
2 checks passed
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.

2 participants