summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2021-02-19 16:42:34 +0100
committerMarge Bot <marge-bot@gnome.org>2021-03-02 22:02:56 +0000
commit0d62dadfbc4532953668a976a2585369d753ae01 (patch)
tree49033f388edc5f6673eb98f9b6addcaf1aec69cd
parentf60a469a34e2e3973caa83a4bd41996aa3cf2d1d (diff)
downloadgnome-shell-0d62dadfbc4532953668a976a2585369d753ae01.tar.gz
st/scrollview: Add ::content-padding property to StScrollView
This will be needed for fine tuning of the visible area for appGrid navigation purposes. We most nominally can let it happen via CSS as the size calculations happen on size allocate, so we want to avoid triggering relayouts while adapting to the given size. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1630>
-rw-r--r--src/st/st-scroll-view-fade.c8
-rw-r--r--src/st/st-scroll-view.c21
2 files changed, 29 insertions, 0 deletions
diff --git a/src/st/st-scroll-view-fade.c b/src/st/st-scroll-view-fade.c
index 38d40ed65..3ca731337 100644
--- a/src/st/st-scroll-view-fade.c
+++ b/src/st/st-scroll-view-fade.c
@@ -97,6 +97,7 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
gboolean h_scroll_visible, v_scroll_visible;
ClutterActorBox allocation, content_box, paint_box;
+ ClutterMargin *content_padding;
float fade_area_topleft[2];
float fade_area_bottomright[2];
@@ -108,6 +109,13 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
clutter_actor_get_allocation_box (self->actor, &allocation);
st_theme_node_get_content_box (st_widget_get_theme_node (ST_WIDGET (self->actor)),
(const ClutterActorBox *)&allocation, &content_box);
+ g_object_get (self->actor, "content-padding", &content_padding, NULL);
+
+ content_box.x1 += content_padding->left;
+ content_box.x2 -= content_padding->right;
+ content_box.y1 += content_padding->top;
+ content_box.y2 -= content_padding->bottom;
+ clutter_margin_free (content_padding);
/*
* The FBO is based on the paint_volume's size which can be larger then the actual
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index 3b9711ea2..606701565 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -84,6 +84,8 @@ struct _StScrollViewPrivate
StAdjustment *vadjustment;
ClutterActor *vscroll;
+ ClutterMargin content_padding;
+
StPolicyType hscrollbar_policy;
StPolicyType vscrollbar_policy;
@@ -116,6 +118,7 @@ enum {
PROP_VSCROLLBAR_VISIBLE,
PROP_MOUSE_SCROLL,
PROP_OVERLAY_SCROLLBARS,
+ PROP_CONTENT_PADDING,
N_PROPS
};
@@ -156,6 +159,9 @@ st_scroll_view_get_property (GObject *object,
case PROP_OVERLAY_SCROLLBARS:
g_value_set_boolean (value, priv->overlay_scrollbars);
break;
+ case PROP_CONTENT_PADDING:
+ g_value_set_boxed (value, &priv->content_padding);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -233,6 +239,9 @@ st_scroll_view_set_property (GObject *object,
priv->hscrollbar_policy,
g_value_get_enum (value));
break;
+ case PROP_CONTENT_PADDING:
+ priv->content_padding = * (ClutterMargin *) g_value_get_boxed (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -545,6 +554,11 @@ st_scroll_view_allocate (ClutterActor *actor,
st_theme_node_get_content_box (theme_node, box, &content_box);
+ content_box.x1 += priv->content_padding.left;
+ content_box.x2 -= priv->content_padding.right;
+ content_box.y1 += priv->content_padding.top;
+ content_box.y2 += priv->content_padding.bottom;
+
avail_width = content_box.x2 - content_box.x1;
avail_height = content_box.y2 - content_box.y1;
@@ -933,6 +947,13 @@ st_scroll_view_class_init (StScrollViewClass *klass)
FALSE,
ST_PARAM_READWRITE);
+ props[PROP_CONTENT_PADDING] =
+ g_param_spec_boxed ("content-padding",
+ "Content padding",
+ "Content padding",
+ CLUTTER_TYPE_MARGIN,
+ ST_PARAM_READWRITE);
+
g_object_class_install_properties (object_class, N_PROPS, props);
}