Skip to content

vjust arg for gridify Object#18

Open
Polkas wants to merge 16 commits into
mainfrom
topjust
Open

vjust arg for gridify Object#18
Polkas wants to merge 16 commits into
mainfrom
topjust

Conversation

@Polkas
Copy link
Copy Markdown
Collaborator

@Polkas Polkas commented May 10, 2026

Adds a vjust slot to gridifyObject() so users can vertically anchor the rendered object inside its layout row (e.g. vjust = 1 pins a gt/flextable to the top of a taller row instead of stretching it).

New vjust argument on gridifyObject() (default 0.5; fully backwards-compatible).
print() now sizes the object's viewport to grobHeight() for fixed-size grobs when vjust != 0.5, floored at 1 inch via grid::unit.pmax(). Flexible grobs (ggplotGrob-style gtables with null heights, recorded gTrees with childrenvp) keep the historical "fill the row" behaviour.
Detection & expression building factored into is_flexible_grob() and object_viewport_height_expr() in gridify-utils.R, with unit tests.
S4 validity rejects NA, NaN, ±Inf, non-scalar and out-of-range values.
Roxygen on vjust / object_vjust (in simple_layout(), complex_layout(), pharma_layout_*) makes the flexible-grob caveat explicit; show_spec() annotates the Vjust line accordingly.
No changes for users who don't set vjust.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.68%. Comparing base (45855f1) to head (56a2400).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   99.56%   99.68%   +0.11%     
==========================================
  Files           9        9              
  Lines         919      951      +32     
==========================================
+ Hits          915      948      +33     
+ Misses          4        3       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread R/gridify-utils.R Outdated
#' @param vjust numeric, the layout's object vjust.
#' @return a single logical.
#' @keywords internal
use_grob_height_for_object <- function(grob, vjust) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this needs to be a function as it's only 1 line and is used in one place, we could just have
use_grob_height_for_object <- vjust != 0.5 && !is_flexible_grob(grob) on line 124 above the natural_height assignment

@bethanygeorge bethanygeorge marked this pull request as ready for review May 22, 2026 13:03
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.

4 participants