1
0
Fork 0

clutter: Remove unused ScrollActor

As GNOME Shell has a more complete solution with StScrollable /
StViewport / StScrollbar and does not make use of the Clutter actor.
We might want to "upstream" GNOME Shell infrastructure later at some
point but the current "solution" is too poor, so just drop it

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
This commit is contained in:
Bilal Elmoussaoui 2024-08-07 10:55:52 +02:00 committed by Marge Bot
parent ec028553d3
commit 334a85099d
5 changed files with 0 additions and 517 deletions

View file

@ -923,25 +923,6 @@ typedef enum
CLUTTER_ORIENTATION_VERTICAL
} ClutterOrientation;
/**
* ClutterScrollMode:
* @CLUTTER_SCROLL_NONE: Ignore scrolling
* @CLUTTER_SCROLL_HORIZONTALLY: Scroll only horizontally
* @CLUTTER_SCROLL_VERTICALLY: Scroll only vertically
* @CLUTTER_SCROLL_BOTH: Scroll in both directions
*
* Scroll modes.
*/
typedef enum /*< prefix=CLUTTER_SCROLL >*/
{
CLUTTER_SCROLL_NONE = 0,
CLUTTER_SCROLL_HORIZONTALLY = 1 << 0,
CLUTTER_SCROLL_VERTICALLY = 1 << 1,
CLUTTER_SCROLL_BOTH = CLUTTER_SCROLL_HORIZONTALLY | CLUTTER_SCROLL_VERTICALLY
} ClutterScrollMode;
/**
* ClutterGridPosition:
* @CLUTTER_GRID_POSITION_LEFT: left position

View file

@ -1,426 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that 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 library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* ClutterScrollActor:
*
* An actor for displaying a portion of its children
*
* #ClutterScrollActor is an actor that can be used to display a portion
* of the contents of its children.
*
* The extent of the area of a #ClutterScrollActor is defined by the size
* of its children; the visible region of the children of a #ClutterScrollActor
* is set by using [method@ScrollActor.scroll_to_point] or by using
* [method@ScrollActor.scroll_to_rect] to define a point or a rectangle
* acting as the origin, respectively.
*
* #ClutterScrollActor does not provide pointer or keyboard event handling,
* nor does it provide visible scroll handles.
*/
#include "config.h"
#include "clutter/clutter-scroll-actor.h"
#include "clutter/clutter-actor-private.h"
#include "clutter/clutter-animatable.h"
#include "clutter/clutter-debug.h"
#include "clutter/clutter-enum-types.h"
#include "clutter/clutter-private.h"
#include "clutter/clutter-property-transition.h"
#include "clutter/clutter-transition.h"
typedef struct _ClutterScrollActorPrivate
{
graphene_point_t scroll_to;
ClutterScrollMode scroll_mode;
ClutterTransition *transition;
} ClutterScrollActorPrivate;
enum
{
PROP_0,
PROP_SCROLL_MODE,
PROP_LAST
};
enum
{
ANIM_PROP_0,
ANIM_PROP_SCROLL_TO,
ANIM_PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST] = { NULL, };
static GParamSpec *animatable_props[ANIM_PROP_LAST] = { NULL, };
static ClutterAnimatableInterface *parent_animatable_iface = NULL;
static void clutter_animatable_iface_init (ClutterAnimatableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (ClutterScrollActor, clutter_scroll_actor, CLUTTER_TYPE_ACTOR,
G_ADD_PRIVATE (ClutterScrollActor)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_ANIMATABLE,
clutter_animatable_iface_init))
static void
clutter_scroll_actor_set_scroll_to_internal (ClutterScrollActor *self,
const graphene_point_t *point)
{
ClutterScrollActorPrivate *priv =
clutter_scroll_actor_get_instance_private (self);
ClutterActor *actor = CLUTTER_ACTOR (self);
graphene_matrix_t m;
float dx, dy;
if (graphene_point_equal (&priv->scroll_to, point))
return;
if (point == NULL)
graphene_point_init (&priv->scroll_to, 0.f, 0.f);
else
priv->scroll_to = *point;
if (priv->scroll_mode & CLUTTER_SCROLL_HORIZONTALLY)
dx = -priv->scroll_to.x;
else
dx = 0.f;
if (priv->scroll_mode & CLUTTER_SCROLL_VERTICALLY)
dy = -priv->scroll_to.y;
else
dy = 0.f;
graphene_matrix_init_translate (&m,
&GRAPHENE_POINT3D_INIT (dx, dy, 0.f));
clutter_actor_set_child_transform (actor, &m);
}
static void
clutter_scroll_actor_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterScrollActor *actor = CLUTTER_SCROLL_ACTOR (gobject);
switch (prop_id)
{
case PROP_SCROLL_MODE:
clutter_scroll_actor_set_scroll_mode (actor, g_value_get_flags (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_scroll_actor_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterScrollActor *actor = CLUTTER_SCROLL_ACTOR (gobject);
ClutterScrollActorPrivate *priv =
clutter_scroll_actor_get_instance_private (actor);
switch (prop_id)
{
case PROP_SCROLL_MODE:
g_value_set_flags (value, priv->scroll_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_scroll_actor_class_init (ClutterScrollActorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = clutter_scroll_actor_set_property;
gobject_class->get_property = clutter_scroll_actor_get_property;
/**
* ClutterScrollActor:scroll-mode:
*
* The scrolling direction.
*/
obj_props[PROP_SCROLL_MODE] =
g_param_spec_flags ("scroll-mode", NULL, NULL,
CLUTTER_TYPE_SCROLL_MODE,
CLUTTER_SCROLL_BOTH,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
static void
clutter_scroll_actor_init (ClutterScrollActor *self)
{
ClutterScrollActorPrivate *priv =
clutter_scroll_actor_get_instance_private (self);
priv->scroll_mode = CLUTTER_SCROLL_BOTH;
clutter_actor_set_clip_to_allocation (CLUTTER_ACTOR (self), TRUE);
}
static GParamSpec *
clutter_scroll_actor_find_property (ClutterAnimatable *animatable,
const char *property_name)
{
if (strcmp (property_name, "scroll-to") == 0)
return animatable_props[ANIM_PROP_SCROLL_TO];
return parent_animatable_iface->find_property (animatable, property_name);
}
static void
clutter_scroll_actor_set_final_state (ClutterAnimatable *animatable,
const char *property_name,
const GValue *value)
{
if (strcmp (property_name, "scroll-to") == 0)
{
ClutterScrollActor *self = CLUTTER_SCROLL_ACTOR (animatable);
const graphene_point_t *point = g_value_get_boxed (value);
clutter_scroll_actor_set_scroll_to_internal (self, point);
}
else
parent_animatable_iface->set_final_state (animatable, property_name, value);
}
static void
clutter_scroll_actor_get_initial_state (ClutterAnimatable *animatable,
const char *property_name,
GValue *value)
{
if (strcmp (property_name, "scroll-to") == 0)
{
ClutterScrollActor *self = CLUTTER_SCROLL_ACTOR (animatable);
ClutterScrollActorPrivate *priv =
clutter_scroll_actor_get_instance_private (self);
g_value_set_boxed (value, &priv->scroll_to);
}
else
parent_animatable_iface->get_initial_state (animatable, property_name, value);
}
static void
clutter_animatable_iface_init (ClutterAnimatableInterface *iface)
{
parent_animatable_iface = g_type_interface_peek_parent (iface);
animatable_props[ANIM_PROP_SCROLL_TO] =
g_param_spec_boxed ("scroll-to", NULL, NULL,
GRAPHENE_TYPE_POINT,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
CLUTTER_PARAM_ANIMATABLE);
iface->find_property = clutter_scroll_actor_find_property;
iface->get_initial_state = clutter_scroll_actor_get_initial_state;
iface->set_final_state = clutter_scroll_actor_set_final_state;
}
/**
* clutter_scroll_actor_new:
*
* Creates a new #ClutterScrollActor.
*
* Return value: The newly created #ClutterScrollActor
* instance.
*/
ClutterActor *
clutter_scroll_actor_new (void)
{
return g_object_new (CLUTTER_TYPE_SCROLL_ACTOR,
"accessible-name", "Scroll actor",
"accessible-role", ATK_ROLE_SCROLL_PANE,
NULL);
}
/**
* clutter_scroll_actor_set_scroll_mode:
* @actor: a #ClutterScrollActor
* @mode: a #ClutterScrollMode
*
* Sets the [property@ScrollActor:scroll-mode] property.
*/
void
clutter_scroll_actor_set_scroll_mode (ClutterScrollActor *actor,
ClutterScrollMode mode)
{
ClutterScrollActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor));
priv = clutter_scroll_actor_get_instance_private (actor);
if (priv->scroll_mode == mode)
return;
priv->scroll_mode = mode;
g_object_notify_by_pspec (G_OBJECT (actor), obj_props[PROP_SCROLL_MODE]);
}
/**
* clutter_scroll_actor_get_scroll_mode:
* @actor: a #ClutterScrollActor
*
* Retrieves the [property@ScrollActor:scroll-mode] property
*
* Return value: the scrolling mode
*/
ClutterScrollMode
clutter_scroll_actor_get_scroll_mode (ClutterScrollActor *actor)
{
ClutterScrollActorPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor), CLUTTER_SCROLL_NONE);
priv = clutter_scroll_actor_get_instance_private (actor);
return priv->scroll_mode;
}
/**
* clutter_scroll_actor_scroll_to_point:
* @actor: a #ClutterScrollActor
* @point: a #graphene_point_t
*
* Scrolls the contents of @actor so that @point is the new origin
* of the visible area.
*
* The coordinates of @point must be relative to the @actor.
*
* This function will use the currently set easing state of the @actor
* to transition from the current scroll origin to the new one.
*/
void
clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor,
const graphene_point_t *point)
{
ClutterScrollActorPrivate *priv;
const ClutterAnimationInfo *info;
g_return_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor));
g_return_if_fail (point != NULL);
priv = clutter_scroll_actor_get_instance_private (actor);
info = _clutter_actor_get_animation_info (CLUTTER_ACTOR (actor));
/* jump to the end if there is no easing state, or if the easing
* state has a duration of 0 msecs
*/
if (info->cur_state == NULL ||
info->cur_state->easing_duration == 0)
{
/* ensure that we remove any currently running transition */
if (priv->transition != NULL)
{
clutter_actor_remove_transition (CLUTTER_ACTOR (actor),
"scroll-to");
priv->transition = NULL;
}
clutter_scroll_actor_set_scroll_to_internal (actor, point);
return;
}
if (priv->transition == NULL)
{
priv->transition = clutter_property_transition_new ("scroll-to");
clutter_transition_set_animatable (priv->transition,
CLUTTER_ANIMATABLE (actor));
clutter_transition_set_remove_on_complete (priv->transition, TRUE);
/* delay only makes sense if the transition has just been created */
clutter_timeline_set_delay (CLUTTER_TIMELINE (priv->transition),
info->cur_state->easing_delay);
/* we need this to clear the priv->transition pointer */
g_object_add_weak_pointer (G_OBJECT (priv->transition), (gpointer *) &priv->transition);
clutter_actor_add_transition (CLUTTER_ACTOR (actor),
"scroll-to",
priv->transition);
/* the actor now owns the transition */
g_object_unref (priv->transition);
}
/* if a transition already exist, update its bounds */
clutter_transition_set_from (priv->transition,
GRAPHENE_TYPE_POINT,
&priv->scroll_to);
clutter_transition_set_to (priv->transition,
GRAPHENE_TYPE_POINT,
point);
/* always use the current easing state */
clutter_timeline_set_duration (CLUTTER_TIMELINE (priv->transition),
info->cur_state->easing_duration);
clutter_timeline_set_progress_mode (CLUTTER_TIMELINE (priv->transition),
info->cur_state->easing_mode);
/* ensure that we start from the beginning */
clutter_timeline_rewind (CLUTTER_TIMELINE (priv->transition));
clutter_timeline_start (CLUTTER_TIMELINE (priv->transition));
}
/**
* clutter_scroll_actor_scroll_to_rect:
* @actor: a #ClutterScrollActor
* @rect: a #ClutterRect
*
* Scrolls @actor so that @rect is in the visible portion.
*/
void
clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor,
const graphene_rect_t *rect)
{
graphene_rect_t n_rect;
g_return_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor));
g_return_if_fail (rect != NULL);
n_rect = *rect;
/* normalize, so that we have a valid origin */
graphene_rect_normalize (&n_rect);
clutter_scroll_actor_scroll_to_point (actor, &n_rect.origin);
}

View file

@ -1,69 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that 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 library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#include "clutter/clutter-types.h"
#include "clutter/clutter-actor.h"
G_BEGIN_DECLS
#define CLUTTER_TYPE_SCROLL_ACTOR (clutter_scroll_actor_get_type ())
/**
* ClutterScrollActorClass:
*
* The #ClutterScrollActor structure contains only
* private data.
*/
struct _ClutterScrollActorClass
{
/*< private >*/
ClutterActorClass parent_instance;
};
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterScrollActor,
clutter_scroll_actor,
CLUTTER, SCROLL_ACTOR,
ClutterActor)
CLUTTER_EXPORT
ClutterActor * clutter_scroll_actor_new (void);
CLUTTER_EXPORT
void clutter_scroll_actor_set_scroll_mode (ClutterScrollActor *actor,
ClutterScrollMode mode);
CLUTTER_EXPORT
ClutterScrollMode clutter_scroll_actor_get_scroll_mode (ClutterScrollActor *actor);
CLUTTER_EXPORT
void clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor,
const graphene_point_t *point);
CLUTTER_EXPORT
void clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor,
const graphene_rect_t *rect);
G_END_DECLS

View file

@ -86,7 +86,6 @@
#include "clutter/clutter-pipeline-cache.h"
#include "clutter/clutter-property-transition.h"
#include "clutter/clutter-rotate-action.h"
#include "clutter/clutter-scroll-actor.h"
#include "clutter/clutter-settings.h"
#include "clutter/clutter-shader-effect.h"
#include "clutter/clutter-shader-types.h"

View file

@ -63,7 +63,6 @@ clutter_headers = [
'clutter-pipeline-cache.h',
'clutter-property-transition.h',
'clutter-rotate-action.h',
'clutter-scroll-actor.h',
'clutter-seat.h',
'clutter-settings.h',
'clutter-shader-effect.h',
@ -153,7 +152,6 @@ clutter_sources = [
'clutter-pipeline-cache.c',
'clutter-property-transition.c',
'clutter-rotate-action.c',
'clutter-scroll-actor.c',
'clutter-seat.c',
'clutter-settings.c',
'clutter-shader-effect.c',