2012-09-26 14:28:06 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
int cursor_x, cursor_y;
|
|
|
|
|
2018-06-28 17:48:00 +00:00
|
|
|
static void
|
|
|
|
motion_cb (GtkEventControllerMotion *motion,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
GtkWidget *widget)
|
2012-09-26 14:28:06 +00:00
|
|
|
{
|
2018-06-28 17:48:00 +00:00
|
|
|
float processing_ms = gtk_adjustment_get_value (adjustment);
|
|
|
|
g_usleep (processing_ms * 1000);
|
|
|
|
|
|
|
|
cursor_x = x;
|
|
|
|
cursor_y = y;
|
|
|
|
gtk_widget_queue_draw (widget);
|
2012-09-26 14:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-18 14:09:36 +00:00
|
|
|
on_draw (GtkDrawingArea *da,
|
|
|
|
cairo_t *cr,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
gpointer data)
|
2012-09-26 14:28:06 +00:00
|
|
|
{
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 0, 0.5, 0.5);
|
|
|
|
|
|
|
|
cairo_arc (cr, cursor_x, cursor_y, 10, 0, 2 * M_PI);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
static void
|
|
|
|
quit_cb (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *done = data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
|
|
|
|
g_main_context_wakeup (NULL);
|
|
|
|
}
|
|
|
|
|
2012-09-26 14:28:06 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
2016-11-18 14:09:36 +00:00
|
|
|
GtkWidget *da;
|
2018-06-28 17:48:00 +00:00
|
|
|
GtkEventController *controller;
|
2020-02-10 03:24:47 +00:00
|
|
|
gboolean done = FALSE;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2012-09-26 14:28:06 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
|
|
|
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2018-12-26 07:20:34 +00:00
|
|
|
da = gtk_drawing_area_new ();
|
|
|
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), on_draw, NULL, NULL);
|
|
|
|
gtk_widget_set_vexpand (da, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (vbox), da);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("Event processing time (ms):");
|
2014-05-13 11:28:20 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (vbox), label);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2018-12-26 07:20:34 +00:00
|
|
|
adjustment = gtk_adjustment_new (20, 0, 200, 1, 10, 0);
|
|
|
|
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (vbox), scale);
|
2018-06-28 17:48:00 +00:00
|
|
|
|
|
|
|
controller = gtk_event_controller_motion_new ();
|
|
|
|
g_signal_connect (controller, "motion",
|
|
|
|
G_CALLBACK (motion_cb), da);
|
|
|
|
gtk_widget_add_controller (da, controller);
|
|
|
|
|
2012-09-26 14:28:06 +00:00
|
|
|
g_signal_connect (window, "destroy",
|
2020-02-10 03:24:47 +00:00
|
|
|
G_CALLBACK (quit_cb), &done);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2020-02-10 03:24:47 +00:00
|
|
|
while (!done)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|