[gnome-shell/wip/carlosg/appgrid-navigation: 4/5] st/scrollview: Add ::content-padding property to StScrollView




commit a5067b27b1e28c71123d22e9636573f635bfdca9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 19 16:42:34 2021 +0100

    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.

 src/st/st-scroll-view-fade.c |  8 ++++++++
 src/st/st-scroll-view.c      | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)
---
diff --git a/src/st/st-scroll-view-fade.c b/src/st/st-scroll-view-fade.c
index 38d40ed651..3ca7313372 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 5668751380..a39f506fcc 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]