Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method("$","ggplot2::class_theme")
S3method("$","ggplot2::element")
S3method("$","ggplot2::gg")
S3method("$","ggplot2::theme")
S3method("$",ggproto)
S3method("$",ggproto_parent)
S3method("$<-","ggplot2::element")
Expand Down Expand Up @@ -92,9 +92,9 @@ S3method(predictdf,default)
S3method(predictdf,glm)
S3method(predictdf,locfit)
S3method(predictdf,loess)
S3method(print,"ggplot2::class_theme")
S3method(print,"ggplot2::ggplot")
S3method(print,"ggplot2::mapping")
S3method(print,"ggplot2::theme")
S3method(print,element)
S3method(print,ggplot2_bins)
S3method(print,ggproto)
Expand Down
30 changes: 20 additions & 10 deletions R/all-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ class_scales_list <- S7::new_S3_class("ScalesList")
#' @keywords internal
#' @export
class_theme <- S7::new_class(
"theme", class_S3_gg,
"class_theme", class_S3_gg,
properties = list(
complete = S7::class_logical,
validate = S7::class_logical
),
constructor = function(elements, complete, validate) {
S7::new_object(
out <- S7::new_object(
elements,
complete = complete,
validate = validate
)
class(out) <- c("theme", class(out))
out
}
)

Expand All @@ -61,8 +63,12 @@ class_theme <- S7::new_class(
#' @keywords internal
#' @export
class_labels <- S7::new_class(
"labels", parent = class_S3_gg,
constructor = function(labels) S7::new_object(labels),
"class_labels", parent = class_S3_gg,
constructor = function(labels) {
out <- S7::new_object(labels)
class(out) <- c("labels", class(out))
out
},
validator = function(self) {
if (!is.list(self)) {
return("labels must be a list.")
Expand Down Expand Up @@ -91,12 +97,12 @@ class_labels <- S7::new_class(
#' @keywords internal
#' @export
class_mapping <- S7::new_class(
"mapping", parent = class_S3_gg,
"class_mapping", parent = class_S3_gg,
constructor = function(x, env = globalenv()) {
check_object(x, is.list, "a {.cls list}")
x <- lapply(x, new_aesthetic, env = env)
x <- S7::new_object(x)
class(x) <- union(c("ggplot2::mapping", "uneval"), class(x))
class(x) <- union(c("ggplot2::mapping", "uneval", "mapping"), class(x))
x
}
)
Expand Down Expand Up @@ -125,7 +131,7 @@ class_mapping <- S7::new_class(
#' @keywords internal
#' @export
class_ggplot <- S7::new_class(
name = "ggplot", parent = class_gg,
name = "class_ggplot", parent = class_gg,
properties = list(
data = S7::class_any,
layers = S7::class_list,
Expand All @@ -146,7 +152,7 @@ class_ggplot <- S7::new_class(
facet = facet_null(), layout = NULL,
labels = labs(), meta = list(),
plot_env = parent.frame()) {
S7::new_object(
out <- S7::new_object(
S7::S7_object(),
data = data,
layers = layers,
Expand All @@ -161,6 +167,8 @@ class_ggplot <- S7::new_class(
meta = meta,
plot_env = plot_env
)
class(out) <- c("ggplot", class(out))
out
}
)

Expand All @@ -179,7 +187,7 @@ class_ggplot <- S7::new_class(
#' @keywords internal
#' @export
class_ggplot_built <- S7::new_class(
"ggplot_built", parent = class_gg,
"class_ggplot_built", parent = class_gg,
properties = list(
data = S7::class_list,
layout = class_layout,
Expand All @@ -191,9 +199,11 @@ class_ggplot_built <- S7::new_class(
"The {.cls ggplot_built} class should be constructed by {.fn ggplot_build}."
)
}
S7::new_object(
out <- S7::new_object(
S7::S7_object(),
data = data, layout = layout, plot = plot
)
class(out) <- c("ggplot_built", class(out))
out
}
)
4 changes: 2 additions & 2 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,9 @@ combine_s3_elements <- function(e1, e2) {
}

#' @export
`$.ggplot2::theme` <- function(x, ...) {
`$.ggplot2::class_theme` <- function(x, ...) {
.subset2(x, ...)
}

#' @export
`print.ggplot2::theme` <- function(x, ...) utils::str(x)
`print.ggplot2::class_theme` <- function(x, ...) utils::str(x)
Loading