[gnome-shell/wip/carlosg/appgrid-navigation: 1/5] st/viewport: Add clip-to-view property
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/appgrid-navigation: 1/5] st/viewport: Add clip-to-view property
- Date: Wed, 3 Feb 2021 16:40:55 +0000 (UTC)
commit 4f8e7e5425bbb8c7aa0385b7d7599623cbe46982
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Feb 3 12:03:11 2021 +0100
st/viewport: Add clip-to-view property
This property controls whether the viewport clips the content to its own
allocation or not. This will be necessary in special modes that we want to
render past the viewport inside a scrollview.
src/st/st-viewport.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/src/st/st-viewport.c b/src/st/st-viewport.c
index c663ae4cd3..632e19161d 100644
--- a/src/st/st-viewport.c
+++ b/src/st/st-viewport.c
@@ -55,14 +55,19 @@ static void st_viewport_scrollable_interface_init (StScrollableInterface *iface)
enum {
PROP_0,
+ PROP_CLIP_TO_VIEW,
+ N_PROPS,
PROP_HADJUST,
PROP_VADJUST
};
+static GParamSpec *props[N_PROPS] = { 0 };
+
typedef struct
{
StAdjustment *hadjustment;
StAdjustment *vadjustment;
+ gboolean clip_to_view;
} StViewportPrivate;
G_DEFINE_TYPE_WITH_CODE (StViewport, st_viewport, ST_TYPE_WIDGET,
@@ -163,12 +168,28 @@ st_viewport_scrollable_interface_init (StScrollableInterface *iface)
iface->get_adjustments = scrollable_get_adjustments;
}
+static void
+st_viewport_set_clip_to_view (StViewport *viewport,
+ gboolean clip_to_view)
+{
+ StViewportPrivate *priv =
+ st_viewport_get_instance_private (viewport);
+
+ if (!!priv->clip_to_view != !!clip_to_view)
+ {
+ priv->clip_to_view = clip_to_view;
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (viewport));
+ }
+}
+
static void
st_viewport_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
+ StViewportPrivate *priv =
+ st_viewport_get_instance_private (ST_VIEWPORT (object));
StAdjustment *adjustment;
switch (property_id)
@@ -183,6 +204,10 @@ st_viewport_get_property (GObject *object,
g_value_set_object (value, adjustment);
break;
+ case PROP_CLIP_TO_VIEW:
+ g_value_set_boolean (value, priv->clip_to_view);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -212,6 +237,10 @@ st_viewport_set_property (GObject *object,
g_value_get_object (value));
break;
+ case PROP_CLIP_TO_VIEW:
+ st_viewport_set_clip_to_view (viewport, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -405,7 +434,7 @@ st_viewport_paint (ClutterActor *actor,
/* The content area forms the viewport into the scrolled contents, while
* the borders and background stay in place; after drawing the borders and
* background, we clip to the content area */
- if (priv->hadjustment || priv->vadjustment)
+ if (priv->clip_to_view && (priv->hadjustment || priv->vadjustment))
{
cogl_framebuffer_push_rectangle_clip (fb,
(int)content_box.x1,
@@ -419,7 +448,7 @@ st_viewport_paint (ClutterActor *actor,
child = clutter_actor_get_next_sibling (child))
clutter_actor_paint (child, paint_context);
- if (priv->hadjustment || priv->vadjustment)
+ if (priv->clip_to_view && (priv->hadjustment || priv->vadjustment))
cogl_framebuffer_pop_clip (fb);
}
@@ -480,7 +509,7 @@ st_viewport_get_paint_volume (ClutterActor *actor,
/* When have an adjustment we are clipped to the content box, so base
* our paint volume on that. */
- if (priv->hadjustment || priv->vadjustment)
+ if (priv->clip_to_view && (priv->hadjustment || priv->vadjustment))
{
double width, height;
@@ -558,6 +587,14 @@ st_viewport_class_init (StViewportClass *klass)
actor_class->get_paint_volume = st_viewport_get_paint_volume;
actor_class->pick = st_viewport_pick;
+ props[PROP_CLIP_TO_VIEW] =
+ g_param_spec_boolean ("clip-to-view",
+ "Clip to view",
+ "Clip to view",
+ TRUE,
+ ST_PARAM_READWRITE);
+ g_object_class_install_properties (object_class, N_PROPS, props);
+
/* StScrollable properties */
g_object_class_override_property (object_class,
PROP_HADJUST,
@@ -566,10 +603,13 @@ st_viewport_class_init (StViewportClass *klass)
g_object_class_override_property (object_class,
PROP_VADJUST,
"vadjustment");
-
}
static void
st_viewport_init (StViewport *self)
{
+ StViewportPrivate *priv =
+ st_viewport_get_instance_private (self);
+
+ priv->clip_to_view = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]