Issues with gtk_gesture_get_bounding_box_center()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issues with gtk_gesture_get_bounding_box_center()

Prashant Kumar-2
Hi everyone,
I am trying the get the zoom center point for the zoom gesture. I am
 using gtk_gesture_get_bounding_box_center() for that, is there any other
alternative ?
Coming to the main question I am getting some unexpected rapid shifts while
performing zoom gesture. To keep things simple I fix with finger to one
point and stretch the other one to the right horizontally.
Following is the code that I am using:
#include <gtk/gtk.h>

static void
zoom_gesture_callback(GtkGesture *gesture, gdouble scale, void* p)
{
    gdouble x, y;
    if ( !gtk_gesture_get_bounding_box_center (gesture, &x, &y) )
      return;

    g_print("\ncenter at %f %f", x, y);
}

int
main(int argc, char **argv)
{
    gtk_init(&argc, &argv);
    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    GtkGesture* gesture_zoom = gtk_gesture_zoom_new(window);
    gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER
 (gesture_zoom), GTK_PHASE_BUBBLE);
    g_signal_connect (gesture_zoom, "scale-changed",
                      G_CALLBACK(zoom_gesture_callback), NULL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}

Output:

center at 680.000000 294.000000
center at 680.000000 294.000000
center at 680.000000 294.000000
center at 680.000000 294.000000
center at 763.000000 294.000000 // SHIFT
center at 763.000000 294.000000
center at 763.000000 294.000000
center at 763.000000 294.000000
center at 763.000000 294.000000
center at 763.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 681.000000 294.000000 //SHIFT
center at 681.000000 294.000000
center at 681.000000 294.000000
center at 681.000000 294.000000
center at 764.000000 294.000000
center at 764.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 765.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 766.000000 294.000000
center at 682.000000 294.000000 //SHIFT
center at 682.000000 294.000000
center at 682.000000 294.000000
center at 682.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 767.000000 294.000000
center at 768.000000 294.000000
center at 768.000000 294.000000
center at 768.000000 294.000000
center at 768.000000 294.000000
center at 683.000000 294.000000 //SHIFT
center at 683.000000 294.000000
center at 683.000000 294.000000

Could anyone please tell me what am I doing wrong here, please help
Thanks.
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...