Skip to content

Commit

Permalink
core: Add CogView::cog_view_set_visible()
Browse files Browse the repository at this point in the history
Set the view as the one visible inside of the viewport where the view is
attached.
  • Loading branch information
psaavedra committed Nov 23, 2023
1 parent 1cc58d6 commit deac0b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/cog-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions core/cog-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit deac0b9

Please sign in to comment.