/** @brief "motion-notify" signal callback @param widget where the signal was initiated @param event pointer to event data @param rt pointer to runtime data @return FALSE always */ static gboolean _e2_gesture_dialog_moved_cb (GtkWidget *widget, GdkEventMotion *event, E2_GestureDialogRuntime *rt) { if (rt->handle == NULL) g_return_val_if_reached (FALSE); if (rt->is_drag) { GdkWindow *win; // if (rt->handle != NULL) see test above stroke_record (rt->handle, (gint)event->x, (gint)event->y); NEEDCLOSEBGL #ifdef USE_GTK3_0 //* FIXME make this work with less overhead. Changes are often just a pixel or two GdkRectangle r; r.width = (gint)(rt->prevx - event->x); if (r.width < 0) r.width = -r.width; r.height = (gint)(rt->prevy - event->y); if (r.height < 0) r.height = -r.height; if (r.width <= 2 && r.height <= 2) return FALSE; r.x = (gint)MIN(rt->prevx, event->x); r.y = (gint)MIN(rt->prevy, event->y); win = gtk_widget_get_window (widget); cairo_t *cr = gdk_cairo_create (win); _e2_gesture_dialog_cairo_setup (cr, widget); cairo_move_to (cr, rt->prevx, rt->prevy); cairo_line_to (cr, event->x, event->y); cairo_stroke (cr); gdk_window_invalidate_rect (win, &r, FALSE); gdk_window_process_updates (win, FALSE); cairo_destroy (cr); #else if (rt->gc == NULL) { GtkStyle *style = gtk_widget_get_style (widget); rt->gc = style->black_gc; } win = # ifdef USE_GTK2_14 gtk_widget_get_window (widget); //CHECKME cache this ? # else widget->window; # endif gdk_draw_line (GDK_DRAWABLE (win), rt->gc, (gint)rt->prevx, (gint)rt->prevy, (gint)event->x, (gint)event->y); #endif rt->prevx = event->x; rt->prevy = event->y; NEEDOPENBGL }
/*! \brief Records a new point for the stroke. * \par Function Description * This function adds the point (<B>x</B>,<B>y</B>) as a new point in * the stroke. * * The footprint is updated and the new point is drawn on the drawing area. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] x The X coord of the new point. * \param [in] Y The X coord of the new point. */ void x_stroke_record (GSCHEM_TOPLEVEL *w_current, gint x, gint y) { g_assert (stroke_points != NULL); stroke_record (x, y); if (stroke_points->len < STROKE_MAX_POINTS) { StrokePoint point = { x, y }; g_array_append_val (stroke_points, point); gdk_gc_set_foreground (w_current->gc, x_get_color (STROKE_COLOR)); gdk_draw_point (w_current->window, w_current->gc, x, y); } }
/*! \brief Records a new point for the stroke. * \par Function Description * This function adds the point (<B>x</B>,<B>y</B>) as a new point in * the stroke. * * The footprint is updated and the new point is drawn on the drawing area. * * \param [in] w_current The GschemToplevel object. * \param [in] x The X coord of the new point. * \param [in] Y The X coord of the new point. */ void x_stroke_record (GschemToplevel *w_current, gint x, gint y) { cairo_matrix_t user_to_device_matrix; double x0, y0; GschemPageView *view = gschem_toplevel_get_current_page_view (w_current); g_return_if_fail (view != NULL); GschemPageGeometry *geometry = gschem_page_view_get_page_geometry (view); g_return_if_fail (geometry != NULL); g_assert (stroke_points != NULL); stroke_record (x, y); if (stroke_points->len < STROKE_MAX_POINTS) { StrokePoint point = { x, y }; g_array_append_val (stroke_points, point); cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(view))); GedaColor *color = x_color_lookup (w_current, STROKE_COLOR); cairo_set_source_rgba (cr, geda_color_get_red_double (color), geda_color_get_green_double (color), geda_color_get_blue_double (color), geda_color_get_alpha_double (color)); cairo_set_matrix (cr, gschem_page_geometry_get_world_to_screen_matrix (geometry)); x0 = x; y0 = y; cairo_device_to_user (cr, &x0, &y0); cairo_get_matrix (cr, &user_to_device_matrix); cairo_save (cr); cairo_identity_matrix (cr); cairo_matrix_transform_point (&user_to_device_matrix, &x0, &y0); cairo_rectangle (cr, x0, y0, 1, 1); cairo_fill (cr); cairo_restore (cr); cairo_destroy (cr); } }
static gboolean gul_gestures_motion_cb (GtkWidget *widget, GdkEventMotion *e, GulGestures *as) { GulGesturesPrivate *p = as->priv; if (p->autocancel_timeout) { if (gtk_drag_check_threshold (p->widget, p->start_x, p->start_y, e->x_root, e->y_root)) { g_source_remove (p->autocancel_timeout); p->autocancel_timeout = 0; } } stroke_record (e->x_root, e->y_root); return TRUE; }
/*! \brief Records a new point for the stroke. * \par Function Description * This function adds the point (<B>x</B>,<B>y</B>) as a new point in * the stroke. * * The footprint is updated and the new point is drawn on the drawing area. * * \param [in] w_current The GschemToplevel object. * \param [in] x The X coord of the new point. * \param [in] Y The X coord of the new point. */ void x_stroke_record (GschemToplevel *w_current, gint x, gint y) { GschemPageView *view = gschem_toplevel_get_current_page_view (w_current); g_return_if_fail (view != NULL); GdkGC *view_gc = gschem_page_view_get_gc (view); g_assert (stroke_points != NULL); stroke_record (x, y); if (stroke_points->len < STROKE_MAX_POINTS) { StrokePoint point = { x, y }; g_array_append_val (stroke_points, point); gdk_gc_set_foreground (view_gc, x_get_color (STROKE_COLOR)); gdk_draw_point (gtk_widget_get_window (GTK_WIDGET(view)), view_gc, x, y); } }