Commit 9f8bd7a2 authored by Carlos Garnacho's avatar Carlos Garnacho

gesturezoom: Just return a double in get_scale_delta()

Checking whether the gesture is active is a responsibility of the caller.
parent 8f7d5fb2
......@@ -96,8 +96,8 @@ drawing_area_draw (GtkWidget *widget,
angle = gtk_gesture_rotate_get_angle_delta (GTK_GESTURE_ROTATE (rotate));
cairo_matrix_rotate (&matrix, angle);
if (gtk_gesture_zoom_get_scale_delta (GTK_GESTURE_ZOOM (zoom), &scale))
cairo_matrix_scale (&matrix, scale, scale);
scale = gtk_gesture_zoom_get_scale_delta (GTK_GESTURE_ZOOM (zoom));
cairo_matrix_scale (&matrix, scale, scale);
cairo_set_matrix (cr, &matrix);
cairo_rectangle (cr, -100, -100, 200, 200);
......
......@@ -191,17 +191,16 @@ gtk_gesture_zoom_new (GtkWidget *widget)
* @gesture: a #GtkGestureZoom
* @scale: (out) (transfer none): zoom delta
*
* If @controller is active, this function returns %TRUE and fills
* in @scale with the zooming difference since the gesture was
* recognized (hence the starting point is considered 1:1).
* If @gesture is active, this function returns the zooming difference
* since the gesture was recognized (hence the starting point is
* considered 1:1). If @gesture is not active, 1 is returned.
*
* Returns: %TRUE if @controller is recognizing a zoom gesture
*
* Since: 3.14
**/
gboolean
gtk_gesture_zoom_get_scale_delta (GtkGestureZoom *gesture,
gdouble *scale)
gdouble
gtk_gesture_zoom_get_scale_delta (GtkGestureZoom *gesture)
{
GtkGestureZoomPrivate *priv;
gdouble distance;
......@@ -209,12 +208,9 @@ gtk_gesture_zoom_get_scale_delta (GtkGestureZoom *gesture,
g_return_val_if_fail (GTK_IS_GESTURE_ZOOM (gesture), FALSE);
if (!_gtk_gesture_zoom_get_distance (gesture, &distance))
return FALSE;
return 1;
priv = gtk_gesture_zoom_get_instance_private (gesture);
if (scale)
*scale = distance / priv->initial_distance;
return TRUE;
return distance / priv->initial_distance;
}
......@@ -46,8 +46,7 @@ GDK_AVAILABLE_IN_3_14
GtkGesture * gtk_gesture_zoom_new (GtkWidget *widget);
GDK_AVAILABLE_IN_3_14
gboolean gtk_gesture_zoom_get_scale_delta (GtkGestureZoom *gesture,
gdouble *scale);
gdouble gtk_gesture_zoom_get_scale_delta (GtkGestureZoom *gesture);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment