Skip to content

Commit

Permalink
core: Add CogView::cog_view_is_visible()
Browse files Browse the repository at this point in the history
Gets if the view is visible inside of the viewport where the view
is attached.

Returns: True if the view is visible in its viewport and false in any
other case.
  • Loading branch information
psaavedra committed Nov 23, 2023
1 parent 4b67680 commit 1cc58d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/cog-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,23 @@ cog_view_get_viewport(CogView *self)
g_return_val_if_fail(COG_IS_VIEW(self), NULL);
return g_weak_ref_get(&((CogViewPrivate *) cog_view_get_instance_private(self))->viewport);
}

/**
* cog_view_is_visible:
* @self: A view.
*
* Gets whether the view is visible in a viewport.
*
* Returns: True if the view is visible in its viewport and false in any
* other case.
*
* Since: 0.20
*/
gboolean
cog_view_is_visible(CogView *self)
{
g_return_val_if_fail(COG_IS_VIEW(self), false);

g_autoptr(CogViewport) viewport = cog_view_get_viewport(self);
return viewport && self == cog_viewport_get_visible_view(viewport);
}
3 changes: 3 additions & 0 deletions core/cog-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ gboolean cog_view_get_use_key_bindings(CogView *self);
COG_API
CogViewport *cog_view_get_viewport(CogView *self);

COG_API
gboolean cog_view_is_visible(CogView *self);

G_END_DECLS

0 comments on commit 1cc58d6

Please sign in to comment.