From 4333758643b22a833721d5e4530dd98213c5da05 Mon Sep 17 00:00:00 2001 From: Pablo Saavedra Date: Tue, 7 Nov 2023 10:50:46 +0100 Subject: [PATCH] core: Add CogView::cog_view_set_visible() Set the view as the one visible inside of the viewport where the view is attached. --- core/cog-view.c | 25 +++++++++++++++++++++++++ core/cog-view.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/core/cog-view.c b/core/cog-view.c index 3927b9f2..d1a5db87 100644 --- a/core/cog-view.c +++ b/core/cog-view.c @@ -474,3 +474,28 @@ cog_view_is_visible(CogView *self) g_autoptr(CogViewport) viewport = cog_view_get_viewport(self); return viewport && self == cog_viewport_get_visible_view(viewport); } + +/** + * cog_view_set_visible: + * @self: A view. + * + * Set the view as visible in its viewport. + * + * Returns: %TRUE if the view was set as visible, or %FALSE if the view + * does is not attached to a viewport. + * + * Since: 0.20 + */ +gboolean +cog_view_set_visible(CogView *self) +{ + g_assert(COG_IS_VIEW(self)); + + g_autoptr(CogViewport) viewport = cog_view_get_viewport(self); + if (!viewport) + return FALSE; + + cog_viewport_set_visible_view(viewport, self); + + return TRUE; +} diff --git a/core/cog-view.h b/core/cog-view.h index 0f993b20..f51474bd 100644 --- a/core/cog-view.h +++ b/core/cog-view.h @@ -58,4 +58,7 @@ CogViewport *cog_view_get_viewport(CogView *self); COG_API gboolean cog_view_is_visible(CogView *self); +COG_API +gboolean cog_view_set_visible(CogView *self); + G_END_DECLS