[libchamplain] Remove unused functions from ChamplainAdjustment and KineticScroll
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Remove unused functions from ChamplainAdjustment and KineticScroll
- Date: Tue, 7 May 2013 21:37:56 +0000 (UTC)
commit 775c3f262805bc61a821dfcaa9e03245b3eb6609
Author: Jiří Techet <techet gmail com>
Date: Tue May 7 21:56:41 2013 +0200
Remove unused functions from ChamplainAdjustment and KineticScroll
Also improve scrolling event handling slightly
champlain/champlain-adjustment.c | 70 +++--------------------------
champlain/champlain-adjustment.h | 4 --
champlain/champlain-kinetic-scroll-view.c | 67 ++++++---------------------
3 files changed, 22 insertions(+), 119 deletions(-)
---
diff --git a/champlain/champlain-adjustment.c b/champlain/champlain-adjustment.c
index 91a3e3f..1dcf777 100644
--- a/champlain/champlain-adjustment.c
+++ b/champlain/champlain-adjustment.c
@@ -46,9 +46,6 @@ struct _ChamplainAdjustmentPrivate
gdouble dx;
gdouble old_position;
gdouble new_position;
-
- /* For elasticity */
- gboolean elastic;
};
enum
@@ -59,8 +56,6 @@ enum
PROP_UPPER,
PROP_VALUE,
PROP_STEP_INC,
-
- PROP_ELASTIC,
};
enum
@@ -105,10 +100,6 @@ champlain_adjustment_get_property (GObject *object,
g_value_set_double (value, priv->step_increment);
break;
- case PROP_ELASTIC:
- g_value_set_boolean (value, priv->elastic);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -142,10 +133,6 @@ champlain_adjustment_set_property (GObject *object,
champlain_adjustment_set_step_increment (adj, g_value_get_double (value));
break;
- case PROP_ELASTIC:
- champlain_adjustment_set_elastic (adj, g_value_get_boolean (value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -230,16 +217,6 @@ champlain_adjustment_class_init (ChamplainAdjustmentClass *klass)
G_MAXDOUBLE,
0.0,
CHAMPLAIN_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ELASTIC,
- g_param_spec_boolean ("elastic",
- "Elastic",
- "Make interpolation "
- "behave in an "
- "'elastic' way and "
- "stop clamping value.",
- FALSE,
- CHAMPLAIN_PARAM_READWRITE));
signals[CHANGED] =
g_signal_new ("changed",
@@ -295,9 +272,7 @@ champlain_adjustment_set_value (ChamplainAdjustment *adjustment,
stop_interpolation (adjustment);
- if (!priv->elastic)
- value = CLAMP (value, MIN (priv->lower, priv->upper),
- MAX (priv->lower, priv->upper));
+ value = CLAMP (value, priv->lower, priv->upper);
if (priv->value != value)
{
@@ -484,18 +459,9 @@ interpolation_new_frame_cb (ClutterTimeline *timeline,
ChamplainAdjustmentPrivate *priv = adjustment->priv;
priv->interpolation = NULL;
- if (priv->elastic)
- {
- gdouble progress = clutter_timeline_get_progress (timeline);
- gdouble dx = priv->old_position +
- (priv->new_position - priv->old_position) *
- progress;
- champlain_adjustment_set_value (adjustment, dx);
- }
- else
- champlain_adjustment_set_value (adjustment,
- priv->old_position +
- frame_num * priv->dx);
+ champlain_adjustment_set_value (adjustment,
+ priv->old_position +
+ frame_num * priv->dx);
priv->interpolation = timeline;
}
@@ -507,8 +473,7 @@ interpolation_completed_cb (ClutterTimeline *timeline,
ChamplainAdjustmentPrivate *priv = adjustment->priv;
stop_interpolation (adjustment);
- champlain_adjustment_set_value (adjustment,
- priv->new_position);
+ champlain_adjustment_set_value (adjustment, priv->new_position);
}
@@ -534,9 +499,6 @@ champlain_adjustment_interpolate (ChamplainAdjustment *adjustment,
priv->dx = (priv->new_position - priv->old_position) * n_frames;
priv->interpolation = clutter_timeline_new (((gdouble) n_frames / fps) * 1000);
- if (priv->elastic)
- clutter_timeline_set_progress_mode (priv->interpolation, CLUTTER_EASE_OUT_SINE);
-
g_signal_connect (priv->interpolation,
"new-frame",
G_CALLBACK (interpolation_new_frame_cb),
@@ -551,21 +513,6 @@ champlain_adjustment_interpolate (ChamplainAdjustment *adjustment,
gboolean
-champlain_adjustment_get_elastic (ChamplainAdjustment *adjustment)
-{
- return adjustment->priv->elastic;
-}
-
-
-void
-champlain_adjustment_set_elastic (ChamplainAdjustment *adjustment,
- gboolean elastic)
-{
- adjustment->priv->elastic = elastic;
-}
-
-
-gboolean
champlain_adjustment_clamp (ChamplainAdjustment *adjustment,
gboolean interpolate,
guint n_frames,
@@ -573,11 +520,8 @@ champlain_adjustment_clamp (ChamplainAdjustment *adjustment,
{
ChamplainAdjustmentPrivate *priv = adjustment->priv;
gdouble dest = priv->value;
-
- if (priv->value < priv->lower)
- dest = priv->lower;
- if (priv->value > priv->upper)
- dest = priv->upper;
+
+ dest = CLAMP (dest, priv->lower, priv->upper);
if (dest != priv->value)
{
diff --git a/champlain/champlain-adjustment.h b/champlain/champlain-adjustment.h
index ff138f2..b01d02a 100644
--- a/champlain/champlain-adjustment.h
+++ b/champlain/champlain-adjustment.h
@@ -105,10 +105,6 @@ void champlain_adjustment_interpolate (ChamplainAdjustment *adjustment,
guint n_frames,
guint fps);
-gboolean champlain_adjustment_get_elastic (ChamplainAdjustment *adjustment);
-void champlain_adjustment_set_elastic (ChamplainAdjustment *adjustment,
- gboolean elastic);
-
gboolean champlain_adjustment_clamp (ChamplainAdjustment *adjustment,
gboolean interpolate,
guint n_frames,
diff --git a/champlain/champlain-kinetic-scroll-view.c b/champlain/champlain-kinetic-scroll-view.c
index 14cb331..b027f6a 100644
--- a/champlain/champlain-kinetic-scroll-view.c
+++ b/champlain/champlain-kinetic-scroll-view.c
@@ -225,48 +225,26 @@ clamp_adjustments (ChamplainKineticScrollView *scroll)
if (priv->viewport)
{
- guint fps, n_frames;
ChamplainAdjustment *hadj, *vadj;
- gboolean snap;
+ gdouble d, value, lower, step_increment;
champlain_viewport_get_adjustments (CHAMPLAIN_VIEWPORT (priv->viewport),
&hadj, &vadj);
- /* FIXME: Hard-coded value here */
- fps = clutter_get_default_frame_rate ();
- n_frames = fps / 6;
-
- snap = TRUE;
- if (champlain_adjustment_get_elastic (hadj))
- snap = !champlain_adjustment_clamp (hadj, TRUE, n_frames, fps);
-
/* Snap to the nearest step increment on hadjustment */
- if (snap)
- {
- gdouble d, value, lower, step_increment;
-
- champlain_adjustment_get_values (hadj, &value, &lower, NULL,
- &step_increment);
- d = (rint ((value - lower) / step_increment) *
- step_increment) + lower;
- champlain_adjustment_set_value (hadj, d);
- }
- snap = TRUE;
- if (champlain_adjustment_get_elastic (vadj))
- snap = !champlain_adjustment_clamp (vadj, TRUE, n_frames, fps);
+ champlain_adjustment_get_values (hadj, &value, &lower, NULL,
+ &step_increment);
+ d = (rint ((value - lower) / step_increment) *
+ step_increment) + lower;
+ champlain_adjustment_set_value (hadj, d);
/* Snap to the nearest step increment on vadjustment */
- if (snap)
- {
- gdouble d, value, lower, step_increment;
-
- champlain_adjustment_get_values (vadj, &value, &lower, NULL,
- &step_increment);
- d = (rint ((value - lower) / step_increment) *
- step_increment) + lower;
- champlain_adjustment_set_value (vadj, d);
- }
+ champlain_adjustment_get_values (vadj, &value, &lower, NULL,
+ &step_increment);
+ d = (rint ((value - lower) / step_increment) *
+ step_increment) + lower;
+ champlain_adjustment_set_value (vadj, d);
}
}
@@ -280,24 +258,9 @@ motion_event_cb (ClutterActor *stage,
ClutterActor *actor = CLUTTER_ACTOR (scroll);
gfloat x, y;
- if (event->type != CLUTTER_MOTION)
+ if (event->type != CLUTTER_MOTION || !(event->modifier_state & CLUTTER_BUTTON1_MASK))
return FALSE;
-
- if (!(event->modifier_state & CLUTTER_BUTTON1_MASK))
- {
- /* It sometimes -very rarely - happens that we miss the release event for some
- * reason. This is a sanity check to disconnect the event handlers when the
- * button is not pressed. */
- g_signal_handlers_disconnect_by_func (stage,
- motion_event_cb,
- scroll);
- g_signal_handlers_disconnect_by_func (stage,
- button_release_event_cb,
- scroll);
- clamp_adjustments (scroll);
- g_signal_emit_by_name (scroll, "panning-completed", NULL);
- }
-
+
if (clutter_actor_transform_stage_point (actor,
event->x,
event->y,
@@ -426,8 +389,8 @@ button_release_event_cb (ClutterActor *stage,
ClutterActor *actor = CLUTTER_ACTOR (scroll);
gboolean decelerating = FALSE;
- if ((event->type != CLUTTER_BUTTON_RELEASE) ||
- (event->button != 1))
+ if ((event->type != CLUTTER_MOTION || event->modifier_state & CLUTTER_BUTTON1_MASK) &&
+ (event->type != CLUTTER_BUTTON_RELEASE || event->button != 1))
return FALSE;
g_signal_handlers_disconnect_by_func (stage,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]