#endif
#include <glib-object.h>
-#include <clutter/clutter-alpha.h>
-#include <clutter/clutter-fixed.h>
-#include <clutter/clutter-timeline.h>
+#include <clutter/clutter.h>
#include "tidy-adjustment.h"
#include "tidy-marshal.h"
struct _TidyAdjustmentPrivate
{
- ClutterFixed lower;
- ClutterFixed upper;
- ClutterFixed value;
- ClutterFixed step_increment;
- ClutterFixed page_increment;
- ClutterFixed page_size;
+ gdouble lower;
+ gdouble upper;
+ gdouble value;
+ gdouble step_increment;
+ gdouble page_increment;
+ gdouble page_size;
/* For interpolation */
ClutterTimeline *interpolation;
- ClutterFixed dx;
- ClutterFixed old_position;
- ClutterFixed new_position;
-
+ gdouble dx;
+ gdouble old_position;
+ gdouble new_position;
+
/* For elasticity */
gboolean elastic;
ClutterAlpha *bounce_alpha;
PROP_STEP_INC,
PROP_PAGE_INC,
PROP_PAGE_SIZE,
-
+
PROP_ELASTIC,
};
switch (prop_id)
{
case PROP_LOWER:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->lower));
+ g_value_set_double (value, priv->lower);
break;
case PROP_UPPER:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->upper));
+ g_value_set_double (value, priv->upper);
break;
case PROP_VALUE:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->value));
+ g_value_set_double (value, priv->value);
break;
case PROP_STEP_INC:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->step_increment));
+ g_value_set_double (value, priv->step_increment);
break;
case PROP_PAGE_INC:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->page_increment));
+ g_value_set_double (value, priv->page_increment);
break;
case PROP_PAGE_SIZE:
- g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->page_size));
+ g_value_set_double (value, priv->page_size);
break;
-
+
case PROP_ELASTIC:
g_value_set_boolean (value, priv->elastic);
break;
case PROP_PAGE_SIZE:
tidy_adjustment_set_page_size (adj, g_value_get_double (value));
break;
-
+
case PROP_ELASTIC:
tidy_adjustment_set_elastic (adj, g_value_get_boolean (value));
break;
clutter_timeline_stop (priv->interpolation);
g_object_unref (priv->interpolation);
priv->interpolation = NULL;
-
+
if (priv->bounce_alpha)
{
g_object_unref (priv->bounce_alpha);
NULL);
}
-TidyAdjustment *
-tidy_adjustment_newx (ClutterFixed value,
- ClutterFixed lower,
- ClutterFixed upper,
- ClutterFixed step_increment,
- ClutterFixed page_increment,
- ClutterFixed page_size)
-{
- TidyAdjustment *retval;
- TidyAdjustmentPrivate *priv;
-
- retval = g_object_new (TIDY_TYPE_ADJUSTMENT, NULL);
- priv = retval->priv;
-
- priv->value = value;
- priv->lower = lower;
- priv->upper = upper;
- priv->step_increment = step_increment;
- priv->page_increment = page_increment;
- priv->page_size = page_size;
-
- return retval;
-}
-
-ClutterFixed
-tidy_adjustment_get_valuex (TidyAdjustment *adjustment)
-{
- TidyAdjustmentPrivate *priv;
-
- g_return_val_if_fail (TIDY_IS_ADJUSTMENT (adjustment), 0);
-
- priv = adjustment->priv;
-
- if (adjustment->priv->interpolation)
- {
- return MAX (priv->lower, MIN (priv->upper - priv->page_size,
- adjustment->priv->new_position));
- }
- else
- return adjustment->priv->value;
-}
-
gdouble
tidy_adjustment_get_value (TidyAdjustment *adjustment)
{
g_return_val_if_fail (TIDY_IS_ADJUSTMENT (adjustment), 0.0);
- return CLUTTER_FIXED_TO_FLOAT (adjustment->priv->value);
+ return adjustment->priv->value;
}
void
-tidy_adjustment_set_valuex (TidyAdjustment *adjustment,
- ClutterFixed value)
+tidy_adjustment_set_value (TidyAdjustment *adjustment,
+ double value)
{
TidyAdjustmentPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
+
priv = adjustment->priv;
stop_interpolation (adjustment);
}
void
-tidy_adjustment_set_value (TidyAdjustment *adjustment,
- gdouble value)
-{
- tidy_adjustment_set_valuex (adjustment, CLUTTER_FLOAT_TO_FIXED (value));
-}
-
-void
-tidy_adjustment_clamp_pagex (TidyAdjustment *adjustment,
- ClutterFixed lower,
- ClutterFixed upper)
+tidy_adjustment_clamp_page (TidyAdjustment *adjustment,
+ double lower,
+ double upper)
{
gboolean changed;
TidyAdjustmentPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
+
priv = adjustment->priv;
-
+
stop_interpolation (adjustment);
lower = CLAMP (lower, priv->lower, priv->upper - priv->page_size);
upper = CLAMP (upper, priv->lower + priv->page_size, priv->upper);
-
+
changed = FALSE;
-
+
if (priv->value + priv->page_size > upper)
{
priv->value = upper - priv->page_size;
priv->value = lower;
changed = TRUE;
}
-
+
if (changed)
g_object_notify (G_OBJECT (adjustment), "value");
}
-void
-tidy_adjustment_clamp_page (TidyAdjustment *adjustment,
- gdouble lower,
- gdouble upper)
-{
- tidy_adjustment_clamp_pagex (adjustment,
- CLUTTER_FLOAT_TO_FIXED (lower),
- CLUTTER_FLOAT_TO_FIXED (upper));
-}
-
static void
tidy_adjustment_set_lower (TidyAdjustment *adjustment,
gdouble lower)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed value = CLUTTER_FLOAT_TO_FIXED (lower);
-
- if (priv->lower != value)
+
+ if (priv->lower != lower)
{
- priv->lower = value;
+ priv->lower = lower;
g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "lower");
- tidy_adjustment_clamp_pagex (adjustment, priv->lower, priv->upper);
+ tidy_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
}
}
gdouble upper)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed value = CLUTTER_FLOAT_TO_FIXED (upper);
-
- if (priv->upper != value)
+
+ if (priv->upper != upper)
{
- priv->upper = value;
+ priv->upper = upper;
g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "upper");
-
- tidy_adjustment_clamp_pagex (adjustment, priv->lower, priv->upper);
+
+ tidy_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
}
}
gdouble step)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed value = CLUTTER_FLOAT_TO_FIXED (step);
-
- if (priv->step_increment != value)
+
+ if (priv->step_increment != step)
{
- priv->step_increment = value;
+ priv->step_increment = step;
g_signal_emit (adjustment, signals[CHANGED], 0);
gdouble page)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed value = CLUTTER_FLOAT_TO_FIXED (page);
- if (priv->page_increment != value)
+ if (priv->page_increment != page)
{
- priv->page_increment = value;
+ priv->page_increment = page;
g_signal_emit (adjustment, signals[CHANGED], 0);
gdouble size)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed value = CLUTTER_FLOAT_TO_FIXED (size);
- if (priv->page_size != value)
+ if (priv->page_size != size)
{
- priv->page_size = value;
+ priv->page_size = size;
g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "page_size");
- tidy_adjustment_clamp_pagex (adjustment, priv->lower, priv->upper);
+ tidy_adjustment_clamp_page (adjustment, priv->lower, priv->upper);
}
}
void
tidy_adjustment_set_valuesx (TidyAdjustment *adjustment,
- ClutterFixed value,
- ClutterFixed lower,
- ClutterFixed upper,
- ClutterFixed step_increment,
- ClutterFixed page_increment,
- ClutterFixed page_size)
+ gdouble value,
+ gdouble lower,
+ gdouble upper,
+ gdouble step_increment,
+ gdouble page_increment,
+ gdouble page_size)
{
TidyAdjustmentPrivate *priv;
gboolean emit_changed = FALSE;
-
+
g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
+
priv = adjustment->priv;
-
+
stop_interpolation (adjustment);
emit_changed = FALSE;
-
+
g_object_freeze_notify (G_OBJECT (adjustment));
if (priv->lower != lower)
g_object_notify (G_OBJECT (adjustment), "page-size");
}
-
- tidy_adjustment_set_valuex (adjustment, value);
+
+ tidy_adjustment_set_value (adjustment, value);
if (emit_changed)
g_signal_emit (G_OBJECT (adjustment), signals[CHANGED], 0);
g_object_thaw_notify (G_OBJECT (adjustment));
}
-void
-tidy_adjustment_set_values (TidyAdjustment *adjustment,
- gdouble value,
- gdouble lower,
- gdouble upper,
- gdouble step_increment,
- gdouble page_increment,
- gdouble page_size)
-{
- tidy_adjustment_set_valuesx (adjustment,
- CLUTTER_FLOAT_TO_FIXED (value),
- CLUTTER_FLOAT_TO_FIXED (lower),
- CLUTTER_FLOAT_TO_FIXED (upper),
- CLUTTER_FLOAT_TO_FIXED (step_increment),
- CLUTTER_FLOAT_TO_FIXED (page_increment),
- CLUTTER_FLOAT_TO_FIXED (page_size));
-}
-
void
tidy_adjustment_get_valuesx (TidyAdjustment *adjustment,
- ClutterFixed *value,
- ClutterFixed *lower,
- ClutterFixed *upper,
- ClutterFixed *step_increment,
- ClutterFixed *page_increment,
- ClutterFixed *page_size)
+ gdouble *value,
+ gdouble *lower,
+ gdouble *upper,
+ gdouble *step_increment,
+ gdouble *page_increment,
+ gdouble *page_size)
{
TidyAdjustmentPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
+
priv = adjustment->priv;
-
+
if (lower)
*lower = priv->lower;
*upper = priv->upper;
if (value)
- *value = tidy_adjustment_get_valuex (adjustment);
+ *value = tidy_adjustment_get_value (adjustment);
if (step_increment)
*step_increment = priv->step_increment;
gdouble *page_size)
{
TidyAdjustmentPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
+
priv = adjustment->priv;
-
+
if (lower)
- *lower = CLUTTER_FIXED_TO_DOUBLE (priv->lower);
+ *lower = priv->lower;
if (upper)
- *upper = CLUTTER_FIXED_TO_DOUBLE (priv->upper);
+ *upper = priv->upper;
if (value)
- *value = CLUTTER_FIXED_TO_DOUBLE (tidy_adjustment_get_valuex (adjustment));
+ *value = tidy_adjustment_get_value (adjustment);
if (step_increment)
- *step_increment = CLUTTER_FIXED_TO_DOUBLE (priv->step_increment);
+ *step_increment = priv->step_increment;
if (page_increment)
- *page_increment = CLUTTER_FIXED_TO_DOUBLE (priv->page_increment);
+ *page_increment = priv->page_increment;
if (page_size)
- *page_size = CLUTTER_FIXED_TO_DOUBLE (priv->page_size);
+ *page_size = priv->page_size;
}
static void
priv->interpolation = NULL;
if (priv->elastic && priv->bounce_alpha)
{
- gdouble progress = clutter_alpha_get_alpha (priv->bounce_alpha) /
- (gdouble)CLUTTER_ALPHA_MAX_ALPHA;
- gdouble dx = CLUTTER_FIXED_TO_FLOAT (priv->old_position) +
- CLUTTER_FIXED_TO_FLOAT (priv->new_position - priv->old_position) *
+ gdouble progress = clutter_alpha_get_alpha (priv->bounce_alpha) / 1;
+ gdouble dx = priv->old_position +
+ (priv->new_position - priv->old_position) *
progress;
tidy_adjustment_set_value (adjustment, dx);
}
else
- tidy_adjustment_set_valuex (adjustment,
+ tidy_adjustment_set_value (adjustment,
priv->old_position +
- clutter_qmulx (CLUTTER_INT_TO_FIXED (frame_num),
- priv->dx));
+ frame_num * priv->dx);
priv->interpolation = timeline;
}
TidyAdjustmentPrivate *priv = adjustment->priv;
stop_interpolation (adjustment);
- tidy_adjustment_set_valuex (adjustment,
+ tidy_adjustment_set_value (adjustment,
priv->new_position);
}
bounce_alpha_func (ClutterAlpha *alpha,
gpointer user_data)
{
- ClutterFixed progress, angle;
+ gdouble progress, angle;
ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
progress = clutter_timeline_get_progressx (timeline);
*/
void
-tidy_adjustment_interpolatex (TidyAdjustment *adjustment,
- ClutterFixed value,
+tidy_adjustment_interpolate (TidyAdjustment *adjustment,
+ gdouble value,
guint n_frames,
guint fps)
{
if (n_frames <= 1)
{
- tidy_adjustment_set_valuex (adjustment, value);
+ tidy_adjustment_set_value (adjustment, value);
return;
}
priv->old_position = priv->value;
priv->new_position = value;
- priv->dx = clutter_qdivx (priv->new_position - priv->old_position,
- CLUTTER_INT_TO_FIXED (n_frames));
+ priv->dx = (priv->new_position - priv->old_position) * n_frames;
priv->interpolation = clutter_timeline_new (n_frames, fps);
-
+
if (priv->elastic)
priv->bounce_alpha = clutter_alpha_new_full (priv->interpolation,
- CLUTTER_ALPHA_SINE_INC,
- NULL, NULL);
-
+ CLUTTER_EASE_OUT_SINE);
+
g_signal_connect (priv->interpolation,
"new-frame",
G_CALLBACK (interpolation_new_frame_cb),
"completed",
G_CALLBACK (interpolation_completed_cb),
adjustment);
-
- clutter_timeline_start (priv->interpolation);
-}
-void
-tidy_adjustment_interpolate (TidyAdjustment *adjustment,
- gdouble value,
- guint n_frames,
- guint fps)
-{
- tidy_adjustment_interpolatex (adjustment,
- CLUTTER_FLOAT_TO_FIXED (value),
- n_frames,
- fps);
+ clutter_timeline_start (priv->interpolation);
}
gboolean
guint fps)
{
TidyAdjustmentPrivate *priv = adjustment->priv;
- ClutterFixed dest = priv->value;
-
+ gdouble dest = priv->value;
+
if (priv->value < priv->lower)
dest = priv->lower;
if (priv->value > priv->upper - priv->page_size)
dest = priv->upper - priv->page_size;
-
+
if (dest != priv->value)
{
if (interpolate)
- tidy_adjustment_interpolatex (adjustment,
+ tidy_adjustment_interpolate (adjustment,
dest,
n_frames,
fps);
else
- tidy_adjustment_set_valuex (adjustment, dest);
-
+ tidy_adjustment_set_value (adjustment, dest);
+
return TRUE;
}
-
+
return FALSE;
}
#define __TIDY_ADJUSTMENT_H__
#include <glib-object.h>
-#include <clutter/clutter-fixed.h>
+#include <clutter/clutter.h>
G_BEGIN_DECLS
{
/*< private >*/
GObject parent_instance;
-
+
TidyAdjustmentPrivate *priv;
};
gdouble step_increment,
gdouble page_increment,
gdouble page_size);
-TidyAdjustment *tidy_adjustment_newx (ClutterFixed value,
- ClutterFixed lower,
- ClutterFixed upper,
- ClutterFixed step_increment,
- ClutterFixed page_increment,
- ClutterFixed page_size);
gdouble tidy_adjustment_get_value (TidyAdjustment *adjustment);
-ClutterFixed tidy_adjustment_get_valuex (TidyAdjustment *adjustment);
void tidy_adjustment_set_value (TidyAdjustment *adjustment,
gdouble value);
-void tidy_adjustment_set_valuex (TidyAdjustment *adjustment,
- ClutterFixed value);
void tidy_adjustment_clamp_page (TidyAdjustment *adjustment,
gdouble lower,
gdouble upper);
-void tidy_adjustment_clamp_pagex (TidyAdjustment *adjustment,
- ClutterFixed lower,
- ClutterFixed upper);
void tidy_adjustment_set_values (TidyAdjustment *adjustment,
gdouble value,
gdouble lower,
gdouble step_increment,
gdouble page_increment,
gdouble page_size);
-void tidy_adjustment_set_valuesx (TidyAdjustment *adjustment,
- ClutterFixed value,
- ClutterFixed lower,
- ClutterFixed upper,
- ClutterFixed step_increment,
- ClutterFixed page_increment,
- ClutterFixed page_size);
void tidy_adjustment_get_values (TidyAdjustment *adjustment,
gdouble *value,
gdouble *lower,
gdouble *step_increment,
gdouble *page_increment,
gdouble *page_size);
-void tidy_adjustment_get_valuesx (TidyAdjustment *adjustment,
- ClutterFixed *value,
- ClutterFixed *lower,
- ClutterFixed *upper,
- ClutterFixed *step_increment,
- ClutterFixed *page_increment,
- ClutterFixed *page_size);
void tidy_adjustment_interpolate (TidyAdjustment *adjustment,
gdouble value,
guint n_frames,
guint fps);
-void tidy_adjustment_interpolatex (TidyAdjustment *adjustment,
- ClutterFixed value,
- guint n_frames,
- guint fps);
gboolean tidy_adjustment_get_elastic (TidyAdjustment *adjustment);
void tidy_adjustment_set_elastic (TidyAdjustment *adjustment,
{
/* Scroll mode */
TidyFingerScrollMode mode;
-
+
GArray *motion_buffer;
guint last_motion;
-
+
/* Variables for storing acceleration information for kinetic mode */
ClutterTimeline *deceleration_timeline;
- ClutterUnit dx;
- ClutterUnit dy;
- ClutterFixed decel_rate;
-
+ gdouble dx;
+ gdouble dy;
+ gdouble decel_rate;
+
};
enum {
GValue *value, GParamSpec *pspec)
{
TidyFingerScrollPrivate *priv = TIDY_FINGER_SCROLL (object)->priv;
-
+
switch (property_id)
{
case PROP_MODE :
g_value_set_enum (value, priv->mode);
break;
case PROP_DECEL_RATE :
- g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->decel_rate));
+ g_value_set_double (value, priv->decel_rate);
break;
case PROP_BUFFER :
g_value_set_uint (value, priv->motion_buffer->len);
const GValue *value, GParamSpec *pspec)
{
TidyFingerScrollPrivate *priv = TIDY_FINGER_SCROLL (object)->priv;
-
+
switch (property_id)
{
case PROP_MODE :
g_object_notify (object, "mode");
break;
case PROP_DECEL_RATE :
- priv->decel_rate = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
+ priv->decel_rate = g_value_get_double (value);
g_object_notify (object, "decel-rate");
break;
case PROP_BUFFER :
g_object_unref (priv->deceleration_timeline);
priv->deceleration_timeline = NULL;
}
-
+
G_OBJECT_CLASS (tidy_finger_scroll_parent_class)->dispose (object);
}
TidyFingerScrollPrivate *priv = TIDY_FINGER_SCROLL (object)->priv;
g_array_free (priv->motion_buffer, TRUE);
-
+
G_OBJECT_CLASS (tidy_finger_scroll_parent_class)->finalize (object);
}
"Rate at which the view "
"will decelerate in "
"kinetic mode.",
- CLUTTER_FIXED_TO_FLOAT (CFX_ONE + CFX_MIN),
- CLUTTER_FIXED_TO_FLOAT (CFX_MAX),
+ G_MINFLOAT + 1,
+ G_MAXFLOAT,
1.1,
G_PARAM_READWRITE));
TidyFingerScroll *scroll)
{
ClutterUnit x, y;
-
+
TidyFingerScrollPrivate *priv = scroll->priv;
if (clutter_actor_transform_stage_point (actor,
TidyFingerScrollMotion *motion;
ClutterActor *child =
tidy_scroll_view_get_child (TIDY_SCROLL_VIEW(scroll));
-
+
if (child)
{
- ClutterFixed dx, dy;
+ gdouble dx, dy;
TidyAdjustment *hadjust, *vadjust;
-
+
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (child),
&hadjust,
&vadjust);
motion = &g_array_index (priv->motion_buffer,
TidyFingerScrollMotion, priv->last_motion);
- dx = CLUTTER_UNITS_TO_FIXED(motion->x - x) +
- tidy_adjustment_get_valuex (hadjust);
- dy = CLUTTER_UNITS_TO_FIXED(motion->y - y) +
- tidy_adjustment_get_valuex (vadjust);
-
- tidy_adjustment_set_valuex (hadjust, dx);
- tidy_adjustment_set_valuex (vadjust, dy);
+ dx = (motion->x - x) +
+ tidy_adjustment_get_value (hadjust);
+ dy = (motion->y - y) +
+ tidy_adjustment_get_value (vadjust);
+
+ tidy_adjustment_set_value (hadjust, dx);
+ tidy_adjustment_set_value (vadjust, dy);
}
-
+
priv->last_motion ++;
if (priv->last_motion == priv->motion_buffer->len)
{
g_array_set_size (priv->motion_buffer, priv->last_motion);
priv->last_motion --;
}
-
+
motion = &g_array_index (priv->motion_buffer,
TidyFingerScrollMotion, priv->last_motion);
motion->x = x;
clamp_adjustments (TidyFingerScroll *scroll)
{
ClutterActor *child = tidy_scroll_view_get_child (TIDY_SCROLL_VIEW (scroll));
-
+
if (child)
{
guint fps, n_frames;
TidyAdjustment *hadj, *vadj;
gboolean snap;
-
+
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (child),
&hadj, &vadj);
-
+
/* FIXME: Hard-coded value here */
fps = clutter_get_default_frame_rate ();
n_frames = fps / 6;
-
+
snap = TRUE;
if (tidy_adjustment_get_elastic (hadj))
snap = !tidy_adjustment_clamp (hadj, TRUE, n_frames, fps);
-
+
/* Snap to the nearest step increment on hadjustment */
if (snap)
{
gdouble d, value, lower, step_increment;
-
+
tidy_adjustment_get_values (hadj, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = (rint ((value - lower) / step_increment) *
step_increment) + lower;
tidy_adjustment_set_value (hadj, d);
}
-
+
snap = TRUE;
if (tidy_adjustment_get_elastic (vadj))
snap = !tidy_adjustment_clamp (vadj, TRUE, n_frames, fps);
if (snap)
{
gdouble d, value, lower, step_increment;
-
+
tidy_adjustment_get_values (vadj, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = (rint ((value - lower) / step_increment) *
{
TidyFingerScrollPrivate *priv = scroll->priv;
ClutterActor *child = tidy_scroll_view_get_child (TIDY_SCROLL_VIEW(scroll));
-
+
if (child)
{
- ClutterFixed value, lower, upper, page_size;
+ gdouble value, lower, upper, page_size;
TidyAdjustment *hadjust, *vadjust;
gint i;
gboolean stop = TRUE;
-
+
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (child),
&hadjust,
&vadjust);
-
+
for (i = 0; i < clutter_timeline_get_delta (timeline, NULL); i++)
{
- tidy_adjustment_set_valuex (hadjust,
+ tidy_adjustment_set_value (hadjust,
priv->dx +
- tidy_adjustment_get_valuex (hadjust));
- tidy_adjustment_set_valuex (vadjust,
+ tidy_adjustment_get_value (hadjust));
+ tidy_adjustment_set_value (vadjust,
priv->dy +
- tidy_adjustment_get_valuex (vadjust));
- priv->dx = clutter_qdivx (priv->dx, priv->decel_rate);
- priv->dy = clutter_qdivx (priv->dy, priv->decel_rate);
+ tidy_adjustment_get_value (vadjust));
+ priv->dx = (priv->dx / priv->decel_rate);
+ priv->dy = (priv->dy / priv->decel_rate);
}
-
+
/* Check if we've hit the upper or lower bounds and stop the timeline */
tidy_adjustment_get_valuesx (hadjust, &value, &lower, &upper,
NULL, NULL, &page_size);
if (((priv->dx > 0) && (value < upper - page_size)) ||
((priv->dx < 0) && (value > lower)))
stop = FALSE;
-
+
if (stop)
{
tidy_adjustment_get_valuesx (vadjust, &value, &lower, &upper,
((priv->dy < 0) && (value > lower)))
stop = FALSE;
}
-
+
if (stop)
{
clutter_timeline_stop (timeline);
if (event->button != 1)
return FALSE;
-
+
g_signal_handlers_disconnect_by_func (actor,
motion_event_cb,
scroll);
g_signal_handlers_disconnect_by_func (actor,
button_release_event_cb,
scroll);
-
+
clutter_ungrab_pointer ();
if ((priv->mode == TIDY_FINGER_SCROLL_MODE_KINETIC) && (child))
{
ClutterUnit x, y;
-
+
if (clutter_actor_transform_stage_point (actor,
CLUTTER_UNITS_FROM_DEVICE(event->x),
CLUTTER_UNITS_FROM_DEVICE(event->y),
TidyAdjustment *hadjust, *vadjust;
glong time_diff;
gint i;
-
+
/* Get time delta */
g_get_current_time (&release_time);
-
+
/* Get average position/time of last x mouse events */
priv->last_motion ++;
x_origin = y_origin = 0;
{
TidyFingerScrollMotion *motion =
&g_array_index (priv->motion_buffer, TidyFingerScrollMotion, i);
-
+
/* FIXME: This doesn't guard against overflows - Should
* either fix that, or calculate the correct maximum
* value for the buffer size
motion_time.tv_sec += motion->time.tv_sec;
motion_time.tv_usec += motion->time.tv_usec;
}
- x_origin = CLUTTER_UNITS_FROM_FIXED (
- clutter_qdivx (CLUTTER_UNITS_TO_FIXED (x_origin),
- CLUTTER_INT_TO_FIXED (priv->last_motion)));
- y_origin = CLUTTER_UNITS_FROM_FIXED (
- clutter_qdivx (CLUTTER_UNITS_TO_FIXED (y_origin),
- CLUTTER_INT_TO_FIXED (priv->last_motion)));
+ x_origin = x_origin / priv->last_motion;
+ y_origin = y_origin / priv->last_motion;
motion_time.tv_sec /= priv->last_motion;
motion_time.tv_usec /= priv->last_motion;
-
+
if (motion_time.tv_sec == release_time.tv_sec)
time_diff = release_time.tv_usec - motion_time.tv_usec;
else
and this causes a division by 0 when computing 'frac'. This check
avoids this error.
*/
- if (time_diff == 0)
- {
- g_print ("Preventing a division by 0 (%d / %d).\n",
- CLUTTER_FLOAT_TO_FIXED (time_diff/1000.0),
- CLUTTER_FLOAT_TO_FIXED (1000.0/60.0)
- );
- }
- else
+ if (time_diff != 0)
{
/* Work out the fraction of 1/60th of a second that has elapsed */
- frac = clutter_qdivx (CLUTTER_FLOAT_TO_FIXED (time_diff/1000.0),
- CLUTTER_FLOAT_TO_FIXED (1000.0/60.0));
+ frac = (time_diff/1000.0) / (1000.0/60.0);
+
/* See how many units to move in 1/60th of a second */
- priv->dx = CLUTTER_UNITS_FROM_FIXED(clutter_qdivx (
- CLUTTER_UNITS_TO_FIXED(x_origin - x), frac));
- priv->dy = CLUTTER_UNITS_FROM_FIXED(clutter_qdivx (
- CLUTTER_UNITS_TO_FIXED(y_origin - y), frac));
+ priv->dx = (x_origin - x) / frac;
+ priv->dy = (y_origin - y) / frac;
/* Get adjustments to do step-increment snapping */
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (child),
&hadjust,
&vadjust);
- if (ABS(CLUTTER_UNITS_TO_INT(priv->dx)) > 1 ||
- ABS(CLUTTER_UNITS_TO_INT(priv->dy)) > 1)
+ if (ABS(priv->dx) > 1 ||
+ ABS(priv->dy) > 1)
{
gdouble value, lower, step_increment, d, a, x, y, n;
* As z = 1, this will cause stops to be slightly abrupt -
* add a constant 15 frames to compensate.
*/
- x = CLUTTER_FIXED_TO_FLOAT (MAX(ABS(priv->dx), ABS(priv->dy)));
- y = CLUTTER_FIXED_TO_FLOAT (priv->decel_rate);
+ x = MAX(ABS(priv->dx), ABS(priv->dy));
+ y = priv->decel_rate;
n = logf (x) / logf (y) + 15.0;
/* Now we have n, adjust dx/dy so that we finish on a step
a = (1.0 - 1.0 / pow (y, n + 1)) / (1.0 - 1.0 / y);
/* Solving for dx */
- d = a * CLUTTER_UNITS_TO_FLOAT (priv->dx);
+ d = a * priv->dx;
tidy_adjustment_get_values (hadjust, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = ((rint (((value + d) - lower) / step_increment) *
step_increment) + lower) - value;
- priv->dx = CLUTTER_UNITS_FROM_FLOAT (d / a);
+ priv->dx = (d / a);
/* Solving for dy */
- d = a * CLUTTER_UNITS_TO_FLOAT (priv->dy);
+ d = a * (priv->dy);
tidy_adjustment_get_values (vadjust, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = ((rint (((value + d) - lower) / step_increment) *
step_increment) + lower) - value;
- priv->dy = CLUTTER_UNITS_FROM_FLOAT (d / a);
+ priv->dy = (d / a);
priv->deceleration_timeline = clutter_timeline_new ((gint)n, 60);
}
/* Start a short effects timeline to snap to the nearest step
* boundary (see equations above)
*/
- y = CLUTTER_FIXED_TO_FLOAT (priv->decel_rate);
+ y = priv->decel_rate;
a = (1.0 - 1.0 / pow (y, 4 + 1)) / (1.0 - 1.0 / y);
tidy_adjustment_get_values (hadjust, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = ((rint ((value - lower) / step_increment) *
step_increment) + lower) - value;
- priv->dx = CLUTTER_UNITS_FROM_FLOAT (d / a);
+ priv->dx = (d / a);
tidy_adjustment_get_values (vadjust, &value, &lower, NULL,
&step_increment, NULL, NULL);
d = ((rint ((value - lower) / step_increment) *
step_increment) + lower) - value;
- priv->dy = CLUTTER_UNITS_FROM_FLOAT (d / a);
+ priv->dy = (d / a);
priv->deceleration_timeline = clutter_timeline_new (4, 60);
}
if (priv->last_motion <= 1)
moved = FALSE;
priv->last_motion = 0;
-
+
if (!decelerating)
{
clamp_adjustments (scroll);
}
-
+
/* Pass through events to children.
* FIXME: this probably breaks click-count.
*/
if (moved == FALSE)
clutter_event_put ((ClutterEvent *)event);
-
+
return TRUE;
}
button_release_event_cb,
scroll);
}
-
+
return FALSE;
}
TidyFingerScroll *scroll)
{
TidyFingerScrollPrivate *priv = scroll->priv;
-
+
if (event->type == CLUTTER_BUTTON_PRESS)
{
TidyFingerScrollMotion *motion;
ClutterButtonEvent *bevent = (ClutterButtonEvent *)event;
-
+
/* Reset motion buffer */
priv->last_motion = 0;
motion = &g_array_index (priv->motion_buffer, TidyFingerScrollMotion, 0);
-
+
if ((bevent->button == 1) &&
(clutter_actor_transform_stage_point (actor,
CLUTTER_UNITS_FROM_DEVICE(bevent->x),
&motion->x, &motion->y)))
{
g_get_current_time (&motion->time);
-
+
if (priv->deceleration_timeline)
{
clutter_timeline_stop (priv->deceleration_timeline);
g_object_unref (priv->deceleration_timeline);
priv->deceleration_timeline = NULL;
}
-
+
clutter_grab_pointer (actor);
-
+
/* Add a high priority idle to check the grab after the event
* emission is finished.
*/
(GSourceFunc)after_event_cb,
scroll,
NULL);
-
+
g_signal_connect (actor,
"motion-event",
G_CALLBACK (motion_event_cb),
scroll);
}
}
-
+
return FALSE;
}
{
ClutterActor *scrollbar;
TidyFingerScrollPrivate *priv = self->priv = FINGER_SCROLL_PRIVATE (self);
-
+
priv->motion_buffer = g_array_sized_new (FALSE, TRUE,
sizeof (TidyFingerScrollMotion), 3);
g_array_set_size (priv->motion_buffer, 3);
- priv->decel_rate = CLUTTER_FLOAT_TO_FIXED (1.1f);
-
+ priv->decel_rate = 1.1f;
+
clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
g_signal_connect (CLUTTER_ACTOR (self),
"captured-event",
G_CALLBACK (captured_event_cb),
self);
-
-
+
+
}
ClutterActor *
tidy_finger_scroll_stop (TidyFingerScroll *scroll)
{
TidyFingerScrollPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_FINGER_SCROLL (scroll));
-
+
priv = scroll->priv;
if (priv->deceleration_timeline)
#define __TIDY_SCROLL_VIEW_H__
#include <glib-object.h>
-#include <clutter/clutter-actor.h>
+#include <clutter/clutter.h>
G_BEGIN_DECLS
#define __TIDY_SCROLLABLE_H__
#include <glib-object.h>
-#include <tidy/tidy-adjustment.h>
+#include "tidy-adjustment.h"
G_BEGIN_DECLS
struct _TidyScrollableInterface
{
GTypeInterface parent;
-
+
void (* set_adjustments) (TidyScrollable *scrollable,
TidyAdjustment *hadjustment,
TidyAdjustment *vadjustment);
ClutterUnit x;
ClutterUnit y;
ClutterUnit z;
-
+
TidyAdjustment *hadjustment;
TidyAdjustment *vadjustment;
-
+
gboolean sync_adjustments;
};
GParamSpec *pspec)
{
TidyAdjustment *adjustment;
-
+
TidyViewportPrivate *priv = TIDY_VIEWPORT (object)->priv;
switch (prop_id)
{
case PROP_X_ORIGIN:
- g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (priv->x));
+ g_value_set_int (value, priv->x);
break;
case PROP_Y_ORIGIN:
- g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (priv->y));
+ g_value_set_int (value, priv->y);
break;
case PROP_Z_ORIGIN:
- g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (priv->z));
+ g_value_set_int (value, priv->z);
break;
case PROP_HADJUST :
scrollable_get_adjustments (TIDY_SCROLLABLE (object), NULL, &adjustment);
g_value_set_object (value, adjustment);
break;
-
+
case PROP_SYNC_ADJUST :
g_value_set_boolean (value, priv->sync_adjustments);
break;
switch (prop_id)
{
case PROP_X_ORIGIN:
- tidy_viewport_set_originu (viewport,
+ tidy_viewport_set_origin (viewport,
g_value_get_int (value),
priv->y,
priv->z);
break;
case PROP_Y_ORIGIN:
- tidy_viewport_set_originu (viewport,
+ tidy_viewport_set_origin (viewport,
priv->x,
g_value_get_int (value),
priv->z);
break;
case PROP_Z_ORIGIN:
- tidy_viewport_set_originu (viewport,
+ tidy_viewport_set_origin (viewport,
priv->x,
priv->y,
g_value_get_int (value));
tidy_viewport_paint (ClutterActor *self)
{
TidyViewportPrivate *priv = TIDY_VIEWPORT (self)->priv;
-
+
cogl_push_matrix ();
-
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->x) * -1,
- CLUTTER_UNITS_TO_FIXED (priv->y) * -1,
- CLUTTER_UNITS_TO_FIXED (priv->z) * -1);
-
+
+ cogl_translate ((priv->x) * -1.0,
+ (priv->y) * -1.0,
+ (priv->z) * -1.0);
+
CLUTTER_ACTOR_CLASS (tidy_viewport_parent_class)->paint (self);
-
+
cogl_pop_matrix ();
}
const ClutterActorBox *box,
gboolean absolute_origin_changed)
{
- ClutterFixed prev_value;
-
+ CoglFixed prev_value;
+
TidyViewportPrivate *priv = TIDY_VIEWPORT (self)->priv;
/* Chain up */
{
g_object_set (G_OBJECT (priv->hadjustment),
"lower", 0.0,
- "upper", CLUTTER_UNITS_TO_FLOAT (box->x2 - box->x1),
+ "upper", (box->x2 - box->x1),
NULL);
-
+
/* Make sure value is clamped */
- prev_value = tidy_adjustment_get_valuex (priv->hadjustment);
- tidy_adjustment_set_valuex (priv->hadjustment, prev_value);
+ prev_value = tidy_adjustment_get_value (priv->hadjustment);
+ tidy_adjustment_set_value (priv->hadjustment, prev_value);
}
-
+
if (priv->vadjustment)
{
g_object_set (G_OBJECT (priv->vadjustment),
"lower", 0.0,
- "upper", CLUTTER_UNITS_TO_FLOAT (box->y2 - box->y1),
+ "upper", (box->y2 - box->y1),
NULL);
-
- prev_value = tidy_adjustment_get_valuex (priv->vadjustment);
- tidy_adjustment_set_valuex (priv->vadjustment, prev_value);
+
+ prev_value = tidy_adjustment_get_value (priv->vadjustment);
+ tidy_adjustment_set_value (priv->vadjustment, prev_value);
}
}
}
gobject_class->get_property = tidy_viewport_get_property;
gobject_class->set_property = tidy_viewport_set_property;
gobject_class->dispose = tidy_viewport_dispose;
-
+
actor_class->paint = tidy_viewport_paint;
actor_class->pick = tidy_viewport_pick;
actor_class->allocate = tidy_viewport_allocate;
-
+
g_object_class_install_property (gobject_class,
PROP_X_ORIGIN,
g_param_spec_int ("x-origin",
"viewport size",
TRUE,
G_PARAM_READWRITE));
-
+
g_object_class_override_property (gobject_class,
PROP_HADJUST,
"hadjustment");
TidyViewport *viewport)
{
TidyViewportPrivate *priv = viewport->priv;
- ClutterFixed value;
+ gdouble value;
+
+ value = tidy_adjustment_get_value (adjustment);
- value = tidy_adjustment_get_valuex (adjustment);
-
- tidy_viewport_set_originu (viewport,
- CLUTTER_UNITS_FROM_FIXED (value),
+ tidy_viewport_set_origin (viewport,
+ value,
priv->y,
priv->z);
}
TidyViewport *viewport)
{
TidyViewportPrivate *priv = viewport->priv;
- ClutterFixed value;
+ gdouble value;
- value = tidy_adjustment_get_valuex (adjustment);
-
- tidy_viewport_set_originu (viewport,
+ value = tidy_adjustment_get_value (adjustment);
+
+ tidy_viewport_set_origin (viewport,
priv->x,
- CLUTTER_UNITS_FROM_FIXED (value),
+ value,
priv->z);
}
TidyAdjustment *vadjustment)
{
TidyViewportPrivate *priv = TIDY_VIEWPORT (scrollable)->priv;
-
+
if (hadjustment != priv->hadjustment)
{
if (priv->hadjustment)
scrollable);
g_object_unref (priv->hadjustment);
}
-
+
if (hadjustment)
{
g_object_ref (hadjustment);
G_CALLBACK (hadjustment_value_notify_cb),
scrollable);
}
-
+
priv->hadjustment = hadjustment;
}
scrollable);
g_object_unref (priv->vadjustment);
}
-
+
if (vadjustment)
{
g_object_ref (vadjustment);
G_CALLBACK (vadjustment_value_notify_cb),
scrollable);
}
-
+
priv->vadjustment = vadjustment;
}
}
TidyAdjustment **vadjustment)
{
TidyViewportPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_VIEWPORT (scrollable));
-
+
priv = ((TidyViewport *)scrollable)->priv;
-
+
if (hadjustment)
{
if (priv->hadjustment)
else
{
TidyAdjustment *adjustment;
- ClutterFixed width, stage_width, increment;
-
- width = CLUTTER_UNITS_TO_FIXED(clutter_actor_get_widthu (CLUTTER_ACTOR(scrollable)));
- stage_width = CLUTTER_UNITS_TO_FIXED(clutter_actor_get_widthu (clutter_stage_get_default ()));
- increment = MAX (CFX_ONE, MIN(stage_width, width));
-
- adjustment = tidy_adjustment_newx (CLUTTER_UNITS_TO_FIXED(priv->x),
- 0,
- width,
- CFX_ONE,
- increment,
- increment);
+ guint width, stage_width, increment;
+
+ width = clutter_actor_get_width (CLUTTER_ACTOR(scrollable));
+ stage_width = clutter_actor_get_width (clutter_stage_get_default ());
+ increment = MAX (1, MIN(stage_width, width));
+
+ adjustment = tidy_adjustment_new (priv->x,
+ 0,
+ width,
+ 1,
+ increment,
+ increment);
scrollable_set_adjustments (scrollable,
adjustment,
priv->vadjustment);
*hadjustment = adjustment;
}
}
-
+
if (vadjustment)
{
if (priv->vadjustment)
else
{
TidyAdjustment *adjustment;
- ClutterFixed height, stage_height, increment;
-
- height = CLUTTER_UNITS_TO_FIXED(clutter_actor_get_heightu (CLUTTER_ACTOR(scrollable)));
- stage_height = CLUTTER_UNITS_TO_FIXED(clutter_actor_get_heightu (clutter_stage_get_default ()));
- increment = MAX (CFX_ONE, MIN(stage_height, height));
-
- adjustment = tidy_adjustment_newx (CLUTTER_UNITS_TO_FIXED(priv->y),
- 0,
- height,
- CFX_ONE,
- increment,
- increment);
+ guint height, stage_height, increment;
+
+ height = clutter_actor_get_height (CLUTTER_ACTOR(scrollable));
+ stage_height = clutter_actor_get_height (clutter_stage_get_default ());
+ increment = MAX (1, MIN(stage_height, height));
+
+ adjustment = tidy_adjustment_new (priv->y,
+ 0,
+ height,
+ 1,
+ increment,
+ increment);
scrollable_set_adjustments (scrollable,
priv->hadjustment,
adjustment);
{
gint width, height;
TidyViewportPrivate *priv = self->priv;
-
+
if (!priv->sync_adjustments)
return;
-
+
if (!clutter_actor_has_clip (actor))
{
if (priv->hadjustment)
g_object_set (priv->vadjustment, "page-size", (gdouble)1.0, NULL);
return;
}
-
+
clutter_actor_get_clip (actor, NULL, NULL, &width, &height);
if (priv->hadjustment)
g_object_set (priv->hadjustment, "page-size", (gdouble)width, NULL);
-
+
if (priv->vadjustment)
g_object_set (priv->vadjustment, "page-size", (gdouble)height, NULL);
}
tidy_viewport_init (TidyViewport *self)
{
self->priv = VIEWPORT_PRIVATE (self);
-
+
self->priv->sync_adjustments = TRUE;
-
+
g_signal_connect (self, "notify::clip",
G_CALLBACK (clip_notify_cb), self);
}
}
void
-tidy_viewport_set_originu (TidyViewport *viewport,
- ClutterUnit x,
- ClutterUnit y,
- ClutterUnit z)
+tidy_viewport_set_origin (TidyViewport *viewport,
+ gint x,
+ gint y,
+ gint z)
{
TidyViewportPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_VIEWPORT (viewport));
-
+
priv = viewport->priv;
g_object_freeze_notify (G_OBJECT (viewport));
-
+
if (x != priv->x)
{
priv->x = x;
g_object_notify (G_OBJECT (viewport), "x-origin");
-
+
if (priv->hadjustment)
- tidy_adjustment_set_valuex (priv->hadjustment,
- CLUTTER_UNITS_TO_FIXED (x));
+ tidy_adjustment_set_value (priv->hadjustment,
+ x);
}
if (y != priv->y)
g_object_notify (G_OBJECT (viewport), "y-origin");
if (priv->vadjustment)
- tidy_adjustment_set_valuex (priv->vadjustment,
- CLUTTER_UNITS_TO_FIXED (y));
+ tidy_adjustment_set_value (priv->vadjustment,
+ y);
}
if (z != priv->z)
priv->z = z;
g_object_notify (G_OBJECT (viewport), "z-origin");
}
-
+
g_object_thaw_notify (G_OBJECT (viewport));
clutter_actor_queue_redraw (CLUTTER_ACTOR (viewport));
}
void
-tidy_viewport_set_origin (TidyViewport *viewport,
- gint x,
- gint y,
- gint z)
-{
- g_return_if_fail (TIDY_IS_VIEWPORT (viewport));
-
- tidy_viewport_set_originu (viewport,
- CLUTTER_UNITS_FROM_DEVICE (x),
- CLUTTER_UNITS_FROM_DEVICE (y),
- CLUTTER_UNITS_FROM_DEVICE (z));
-}
-
-void
-tidy_viewport_get_originu (TidyViewport *viewport,
- ClutterUnit *x,
- ClutterUnit *y,
- ClutterUnit *z)
+tidy_viewport_get_origin (TidyViewport *viewport,
+ gint *x,
+ gint *y,
+ gint *z)
{
TidyViewportPrivate *priv;
-
+
g_return_if_fail (TIDY_IS_VIEWPORT (viewport));
-
+
priv = viewport->priv;
-
+
if (x)
*x = priv->x;
if (z)
*z = priv->z;
}
-
-void
-tidy_viewport_get_origin (TidyViewport *viewport,
- gint *x,
- gint *y,
- gint *z)
-{
- TidyViewportPrivate *priv;
-
- g_return_if_fail (TIDY_IS_VIEWPORT (viewport));
-
- priv = viewport->priv;
-
- if (x)
- *x = CLUTTER_UNITS_TO_DEVICE (priv->x);
-
- if (y)
- *y = CLUTTER_UNITS_TO_DEVICE (priv->y);
-
- if (z)
- *z = CLUTTER_UNITS_TO_DEVICE (priv->z);
-}
#define __TIDY_VIEWPORT_H__
#include <glib-object.h>
-#include <clutter/clutter-group.h>
+#include <clutter/clutter.h>
G_BEGIN_DECLS
struct _TidyViewport
{
ClutterGroup parent;
-
+
TidyViewportPrivate *priv;
};
ClutterActor * tidy_viewport_new (void);
-void tidy_viewport_set_originu (TidyViewport *viewport,
- ClutterUnit x,
- ClutterUnit y,
- ClutterUnit z);
-
void tidy_viewport_set_origin (TidyViewport *viewport,
gint x,
gint y,
gint z);
-void tidy_viewport_get_originu (TidyViewport *viewport,
- ClutterUnit *x,
- ClutterUnit *y,
- ClutterUnit *z);
-
void tidy_viewport_get_origin (TidyViewport *viewport,
- gint *x,
- gint *y,
- gint *z);
+ gfloat *x,
+ gfloat *y,
+ gfloat *z);
void tidy_viewport_stop (TidyViewport *viewport);
G_END_DECLS