From 14749744a3ae38ebb0677d421223bac09e76ca7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Nov 2023 15:06:33 +0100 Subject: [PATCH] st/scroll-view: Add private API to query bar offsets The scroll fade effect is the only component that accesses the {v,h}scroll properties for anything other than getting access to the corresponding adjustments. Allow the effect to get what it needs via new private API instead, so we can deprecate and eventually remove the scroll bar properties. Part-of: --- src/st/st-scroll-view-private.h | 30 ++++++++++++++++++++++++++++++ src/st/st-scroll-view.c | 26 +++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/st/st-scroll-view-private.h diff --git a/src/st/st-scroll-view-private.h b/src/st/st-scroll-view-private.h new file mode 100644 index 000000000..849d8322a --- /dev/null +++ b/src/st/st-scroll-view-private.h @@ -0,0 +1,30 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* + * st-scroll-view-private.h: Private StSrollView methods + * + * Copyright 2023 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "st-scroll-view.h" + +G_BEGIN_DECLS + +void st_scroll_view_get_bar_offsets (StScrollView *scroll_view, + float *hoffset, + float *voffset); + +G_END_DECLS diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c index b12c8fd1d..2a2f19d38 100644 --- a/src/st/st-scroll-view.c +++ b/src/st/st-scroll-view.c @@ -60,7 +60,7 @@ #include "st-enum-types.h" #include "st-private.h" -#include "st-scroll-view.h" +#include "st-scroll-view-private.h" #include "st-scroll-bar.h" #include "st-scrollable.h" #include "st-scroll-view-fade.h" @@ -1494,3 +1494,27 @@ st_scroll_view_set_policy (StScrollView *scroll, g_object_thaw_notify ((GObject *) scroll); } + +void +st_scroll_view_get_bar_offsets (StScrollView *scroll, + float *hoffset, + float *voffset) +{ + StScrollViewPrivate *priv; + + g_return_if_fail (ST_IS_SCROLL_VIEW (scroll)); + + priv = st_scroll_view_get_instance_private (scroll); + + if (hoffset) + { + *hoffset = priv->vscrollbar_visible ? clutter_actor_get_width (priv->vscroll) + : 0.; + } + + if (voffset) + { + *voffset = priv->hscrollbar_visible ? clutter_actor_get_height (priv->hscroll) + : 0.; + } +}