st/scroll-view: Allow removing edge fade

Remove the fade effect when the css property `-st-vfade-offset` is removed
from a widget. The effect isn't added when the property never existed.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3047>
This commit is contained in:
Julian Sparber 2023-12-07 17:37:35 +01:00
parent 9f7a7ed202
commit 33c074c738

View File

@ -720,24 +720,20 @@ static void
st_scroll_view_style_changed (StWidget *widget)
{
StScrollView *self = ST_SCROLL_VIEW (widget);
gboolean has_vfade, has_hfade;
double vfade_offset = 0.0;
double hfade_offset = 0.0;
StThemeNode *theme_node = st_widget_get_theme_node (widget);
has_vfade = st_theme_node_lookup_length (theme_node, "-st-vfade-offset", FALSE, &vfade_offset);
has_hfade = st_theme_node_lookup_length (theme_node, "-st-hfade-offset", FALSE, &hfade_offset);
if (has_vfade || has_hfade)
{
st_scroll_view_update_fade_effect (self,
&(ClutterMargin) {
.top = vfade_offset,
.bottom = vfade_offset,
.left = hfade_offset,
.right = hfade_offset,
});
}
st_theme_node_lookup_length (theme_node, "-st-vfade-offset", FALSE, &vfade_offset);
st_theme_node_lookup_length (theme_node, "-st-hfade-offset", FALSE, &hfade_offset);
st_scroll_view_update_fade_effect (self,
&(ClutterMargin) {
.top = vfade_offset,
.bottom = vfade_offset,
.left = hfade_offset,
.right = hfade_offset,
});
ST_WIDGET_CLASS (st_scroll_view_parent_class)->style_changed (widget);
}