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 ce799f4 commit cdb324d
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 @@ -478,3 +478,28 @@ cog_view_is_visible(CogView *self)
CogView *visible_view = cog_viewport_get_visible_view(viewport);
return self == visible_view;
}

/**
* cog_view_set_visible:
* @self: A view.
*
* Set the view as the one visible inside of the viewport where the view is
* attached.
*
* Returns: True if the view succesfully set as visible in its viewport and
* false in any other case.
*
* 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);
g_return_val_if_fail(viewport != NULL, 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 cdb324d

Please sign in to comment.