Skip to contents

The L2 default-layout UI bundle for a ggpaintr formula: owns its own .ptr-app theme scope + asset bundle (nothing else to remember) and is namespaced by id. Pair with the single public ptr_server(). For a hand-composed L3 layout, use the bare ptr_ui_* pieces instead and pair them with the same ptr_server().

Usage

ptr_ui(
  formula,
  id = NULL,
  envir = parent.frame(),
  ui_text = NULL,
  expr_check = TRUE,
  css = NULL,
  shared = NULL
)

Arguments

formula

Either a single character scalar containing a ggplot expression with ggpaintr placeholders, or an unquoted ggplot expression supplied directly (the primary form). Captured with rlang::enexpr() exactly as ptr_app() / ptr_server(), so a formula stored in a variable via rlang::expr() can be passed by its bare symbol (f <- rlang::expr(ggplot(...)); ptr_ui(f, "id")) or spliced with !! (ptr_ui(!!f, "id")); a subscripted/extracted element resolves bare too (ptr_ui(plots[[1]], "id"), holder$body). See ptr_app() for the full contract (symbol resolution, wrapper unwrap, native-pipe caveat).

id

Optional module id; the namespace prefix for inputs and outputs. Defaults to NULL (identity namespace, single-instance use).

envir

Environment used to resolve a formula passed as a bare symbol and any local data objects. Defaults to the calling frame.

ui_text

Optional named list of copy overrides; see ptr_ui_text() for the full schema and current defaults.

expr_check

Controls formula-level ppExpr validation: TRUE (default) applies the built-in denylist + AST walker; FALSE disables formula-level validation; a list with deny_list/allow_list entries customises the formula-level policy. Runtime-typed ppExpr input is always screened against the built-in denylist regardless. See the safety chapter of the ggpaintr book (development-version docs): https://willju-wangqian.github.io/ggpaintr-book/safety.html.

css

Optional character vector of paths to additional CSS files; linked after ggpaintr's bundled stylesheet so its rules win. See ptr_app() for the full semantics. Defaults to NULL.

shared

Optional coordinator object from ptr_shared() for the multi-instance embedding. Forwarded verbatim to ptr_ui_controls(). When NULL (the single-instance default) the inline "Shared controls" section renders every shared = "..." placeholder in formula. When a ptr_shared_spec is supplied, its cross-formula keys (shared$panel_keys) are excluded here because they belong to the one standalone ptr_shared_panel(); only this formula's formula-local shared keys render inline. Defaults to NULL.

Value

A shiny.tag — a fluidPage shell containing the controls panel, plot output, and asset bundle.

See also

ptr_server(), ptr_css() for the css = argument and themable CSS custom properties.

Examples

# Expression form (primary): an unquoted ggplot call.
ui <- ptr_ui(ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point(), "plot1")
# Stored in a variable, spliced with `!!` (paired with ptr_server(!!f, "plot1")).
f <- rlang::expr(ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point())
ui2 <- ptr_ui(!!f, "plot1")
# String form (fallback): equivalent.
ui3 <- ptr_ui("ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point()", "plot1")