st-scroll-bar: Remove stepper buttons

This was a feature that was never used by the Shell.

https://bugzilla.gnome.org/show_bug.cgi?id=670034
This commit is contained in:
Jasper St. Pierre 2012-02-13 23:13:26 -05:00
parent bed50688d2
commit 88eb246b60

View File

@ -55,8 +55,6 @@ struct _StScrollBarPrivate
gfloat x_origin;
gfloat y_origin;
ClutterActor *bw_stepper;
ClutterActor *fw_stepper;
ClutterActor *trough;
ClutterActor *handle;
@ -68,9 +66,6 @@ struct _StScrollBarPrivate
guint paging_source_id;
guint paging_event_no;
gboolean stepper_forward;
guint stepper_source_id;
ClutterAnimation *paging_animation;
guint vertical : 1;
@ -144,23 +139,11 @@ st_scroll_bar_set_property (GObject *gobject,
case PROP_VERTICAL:
bar->priv->vertical = g_value_get_boolean (value);
if (bar->priv->vertical)
{
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->bw_stepper),
"up-stepper");
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->fw_stepper),
"down-stepper");
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
"vhandle");
}
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
"vhandle");
else
{
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->fw_stepper),
"forward-stepper");
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->bw_stepper),
"backward-stepper");
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
"hhandle");
}
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
"hhandle");
clutter_actor_queue_relayout ((ClutterActor*) gobject);
break;
@ -185,18 +168,6 @@ st_scroll_bar_dispose (GObject *gobject)
priv->handle = NULL;
}
if (priv->bw_stepper)
{
clutter_actor_destroy (priv->bw_stepper);
priv->bw_stepper = NULL;
}
if (priv->fw_stepper)
{
clutter_actor_destroy (priv->fw_stepper);
priv->fw_stepper = NULL;
}
if (priv->trough)
{
clutter_actor_destroy (priv->trough);
@ -213,10 +184,6 @@ st_scroll_bar_paint (ClutterActor *actor)
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->paint (actor);
clutter_actor_paint (priv->bw_stepper);
clutter_actor_paint (priv->fw_stepper);
clutter_actor_paint (priv->trough);
if (priv->handle && CLUTTER_ACTOR_IS_VISIBLE (priv->handle))
@ -231,8 +198,6 @@ st_scroll_bar_pick (ClutterActor *actor,
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->pick (actor, pick_color);
clutter_actor_paint (priv->bw_stepper);
clutter_actor_paint (priv->fw_stepper);
clutter_actor_paint (priv->trough);
if (priv->handle && priv->adjustment)
@ -254,77 +219,23 @@ scroll_bar_allocate_children (StScrollBar *bar,
{
StScrollBarPrivate *priv = bar->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (bar));
ClutterActorBox content_box, bw_box, fw_box, trough_box;
gfloat bw_stepper_size, fw_stepper_size, min_size, natural_size;
ClutterActorBox content_box, trough_box;
st_theme_node_get_content_box (theme_node, box, &content_box);
if (priv->vertical)
{
gfloat width = content_box.x2 - content_box.x1;
clutter_actor_get_preferred_height (priv->bw_stepper, width,
&min_size, &natural_size);
bw_stepper_size = MAX (min_size, natural_size);
/* Backward stepper */
bw_box.x1 = content_box.x1;
bw_box.y1 = content_box.y1;
bw_box.x2 = content_box.x2;
bw_box.y2 = bw_box.y1 + bw_stepper_size;
clutter_actor_allocate (priv->bw_stepper, &bw_box, flags);
clutter_actor_get_preferred_height (priv->fw_stepper, width,
&min_size, &natural_size);
fw_stepper_size = MAX (min_size, natural_size);
/* Forward stepper */
fw_box.x1 = content_box.x1;
fw_box.y1 = content_box.y2 - fw_stepper_size;
fw_box.x2 = content_box.x2;
fw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->fw_stepper, &fw_box, flags);
/* Trough */
trough_box.x1 = content_box.x1;
trough_box.y1 = content_box.y1 + bw_stepper_size;
trough_box.y1 = content_box.y1;
trough_box.x2 = content_box.x2;
trough_box.y2 = content_box.y2 - fw_stepper_size;
trough_box.y2 = content_box.y2;
clutter_actor_allocate (priv->trough, &trough_box, flags);
}
else
{
gfloat height = content_box.y2 - content_box.y1;
clutter_actor_get_preferred_width (priv->bw_stepper, height,
&min_size, &natural_size);
bw_stepper_size = MAX (min_size, natural_size);
/* Backward stepper */
bw_box.x1 = content_box.x1;
bw_box.y1 = content_box.y1;
bw_box.x2 = bw_box.x1 + bw_stepper_size;
bw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->bw_stepper, &bw_box, flags);
clutter_actor_get_preferred_width (priv->fw_stepper, height,
&min_size, &natural_size);
fw_stepper_size = MAX (min_size, natural_size);
/* Forward stepper */
fw_box.x1 = content_box.x2 - fw_stepper_size;
fw_box.y1 = content_box.y1;
fw_box.x2 = content_box.x2;
fw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->fw_stepper, &fw_box, flags);
/* Trough */
trough_box.x1 = content_box.x1 + bw_stepper_size;
trough_box.x1 = content_box.x1;
trough_box.y1 = content_box.y1;
trough_box.x2 = content_box.x2 - fw_stepper_size;
trough_box.x2 = content_box.x2;
trough_box.y2 = content_box.y2;
clutter_actor_allocate (priv->trough, &trough_box, flags);
}
@ -332,12 +243,10 @@ scroll_bar_allocate_children (StScrollBar *bar,
if (priv->adjustment)
{
float handle_size, position, avail_size, stepper_size;
float handle_size, position, avail_size;
gdouble value, lower, upper, page_size, increment, min_size, max_size;
ClutterActorBox handle_box = { 0, };
stepper_size = bw_stepper_size + fw_stepper_size;
st_adjustment_get_values (priv->adjustment,
&value,
&lower,
@ -364,23 +273,23 @@ scroll_bar_allocate_children (StScrollBar *bar,
if (priv->vertical)
{
avail_size = content_box.y2 - content_box.y1 - stepper_size;
avail_size = content_box.y2 - content_box.y1;
handle_size = increment * avail_size;
handle_size = CLAMP (handle_size, min_size, max_size);
handle_box.x1 = content_box.x1;
handle_box.y1 = bw_box.y2 + position * (avail_size - handle_size);
handle_box.y1 = content_box.y1 + position * (avail_size - handle_size);
handle_box.x2 = content_box.x2;
handle_box.y2 = handle_box.y1 + handle_size;
}
else
{
avail_size = content_box.x2 - content_box.x1 - stepper_size;
avail_size = content_box.x2 - content_box.x1;
handle_size = increment * avail_size;
handle_size = CLAMP (handle_size, min_size, max_size);
handle_box.x1 = bw_box.x2 + position * (avail_size - handle_size);
handle_box.x1 = content_box.x1 + position * (avail_size - handle_size);
handle_box.y1 = content_box.y1;
handle_box.x2 = handle_box.x1 + handle_size;
@ -428,8 +337,6 @@ st_scroll_bar_get_preferred_width (ClutterActor *self,
if (natural_width_p && tnatural_width_p > *natural_width_p) \
*natural_width_p = tnatural_width_p;
ADJUST_WIDTH_IF_LARGER (priv->bw_stepper);
ADJUST_WIDTH_IF_LARGER (priv->fw_stepper);
ADJUST_WIDTH_IF_LARGER (priv->trough);
ADJUST_WIDTH_IF_LARGER (priv->handle);
@ -447,8 +354,6 @@ st_scroll_bar_get_preferred_width (ClutterActor *self,
if (natural_width_p ) \
*natural_width_p += tnatural_width_p;
ADD_TO_WIDTH (priv->bw_stepper);
ADD_TO_WIDTH (priv->fw_stepper);
ADD_TO_WIDTH (priv->trough);
ADD_TO_WIDTH (priv->handle);
@ -487,8 +392,6 @@ st_scroll_bar_get_preferred_height (ClutterActor *self,
if (natural_height_p) \
*natural_height_p += tnatural_height_p;
ADD_TO_HEIGHT (priv->bw_stepper);
ADD_TO_HEIGHT (priv->fw_stepper);
ADD_TO_HEIGHT (priv->trough);
ADD_TO_HEIGHT (priv->handle);
@ -506,8 +409,6 @@ st_scroll_bar_get_preferred_height (ClutterActor *self,
if (natural_height_p && tnatural_height_p > *natural_height_p) \
*natural_height_p = tnatural_height_p;
ADJUST_HEIGHT_IF_LARGER (priv->bw_stepper);
ADJUST_HEIGHT_IF_LARGER (priv->fw_stepper);
ADJUST_HEIGHT_IF_LARGER (priv->trough);
ADJUST_HEIGHT_IF_LARGER (priv->handle);
@ -558,8 +459,6 @@ st_scroll_bar_style_changed (StWidget *widget)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (widget)->priv;
st_widget_style_changed (ST_WIDGET (priv->bw_stepper));
st_widget_style_changed (ST_WIDGET (priv->fw_stepper));
st_widget_style_changed (ST_WIDGET (priv->trough));
st_widget_style_changed (ST_WIDGET (priv->handle));
@ -1007,109 +906,6 @@ trough_leave_event_cb (ClutterActor *actor,
return FALSE;
}
static void
stepper_animation_completed_cb (ClutterAnimation *a,
gpointer data)
{
g_object_unref (a);
}
static void
stepper_move_on (StScrollBarPrivate *priv,
gint mode)
{
ClutterAnimation *a;
ClutterTimeline *t;
GValue v = { 0, };
double value, inc;
a = g_object_new (CLUTTER_TYPE_ANIMATION,
"object", priv->adjustment,
"duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
"mode", mode,
NULL);
g_signal_connect (a, "completed", G_CALLBACK (stepper_animation_completed_cb),
NULL);
g_object_get (priv->adjustment,
"step-increment", &inc,
"value", &value,
NULL);
if (priv->stepper_forward)
value = value + inc;
else
value = value - inc;
g_value_init (&v, G_TYPE_DOUBLE);
g_value_set_double (&v, value);
clutter_animation_bind (a, "value", &v);
t = clutter_animation_get_timeline (a);
clutter_timeline_start (t);
}
static gboolean
stepper_button_subsequent_timeout (StScrollBarPrivate *priv)
{
stepper_move_on (priv, CLUTTER_LINEAR);
return TRUE;
}
static gboolean
stepper_button_repeat_timeout (StScrollBarPrivate *priv)
{
priv->stepper_source_id = 0;
stepper_move_on (priv, CLUTTER_EASE_IN_CUBIC);
priv->stepper_source_id = g_timeout_add (PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
(GSourceFunc)
stepper_button_subsequent_timeout,
priv);
return FALSE;
}
static gboolean
stepper_button_press_event_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StScrollBar *bar)
{
StScrollBarPrivate *priv = bar->priv;
if (event->button != 1)
return FALSE;
if (bar->priv->adjustment == NULL)
return FALSE;
bar->priv->stepper_forward = (actor == priv->fw_stepper);
stepper_move_on (priv, CLUTTER_EASE_OUT_CUBIC);
priv->stepper_source_id = g_timeout_add (PAGING_INITIAL_REPEAT_TIMEOUT,
(GSourceFunc)
stepper_button_repeat_timeout,
priv);
return TRUE;
}
static gboolean
stepper_button_release_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StScrollBar *self)
{
if (event->button != 1)
return FALSE;
g_source_remove (self->priv->stepper_source_id);
return FALSE;
}
static void
st_scroll_bar_notify_reactive (StScrollBar *self)
{
@ -1117,8 +913,6 @@ st_scroll_bar_notify_reactive (StScrollBar *self)
gboolean reactive = CLUTTER_ACTOR_IS_REACTIVE (self);
clutter_actor_set_reactive (CLUTTER_ACTOR (priv->bw_stepper), reactive);
clutter_actor_set_reactive (CLUTTER_ACTOR (priv->fw_stepper), reactive);
clutter_actor_set_reactive (CLUTTER_ACTOR (priv->trough), reactive);
clutter_actor_set_reactive (CLUTTER_ACTOR (priv->handle), reactive);
}
@ -1128,26 +922,6 @@ st_scroll_bar_init (StScrollBar *self)
{
self->priv = ST_SCROLL_BAR_GET_PRIVATE (self);
self->priv->bw_stepper = (ClutterActor *) st_button_new ();
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->bw_stepper),
"backward-stepper");
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->bw_stepper),
CLUTTER_ACTOR (self));
g_signal_connect (self->priv->bw_stepper, "button-press-event",
G_CALLBACK (stepper_button_press_event_cb), self);
g_signal_connect (self->priv->bw_stepper, "button-release-event",
G_CALLBACK (stepper_button_release_cb), self);
self->priv->fw_stepper = (ClutterActor *) st_button_new ();
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->fw_stepper),
"forward-stepper");
clutter_actor_set_parent (CLUTTER_ACTOR (self->priv->fw_stepper),
CLUTTER_ACTOR (self));
g_signal_connect (self->priv->fw_stepper, "button-press-event",
G_CALLBACK (stepper_button_press_event_cb), self);
g_signal_connect (self->priv->fw_stepper, "button-release-event",
G_CALLBACK (stepper_button_release_cb), self);
self->priv->trough = (ClutterActor *) st_bin_new ();
clutter_actor_set_reactive ((ClutterActor *) self->priv->trough, TRUE);
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->trough), "trough");