static gboolean gimp_ruler_expose (GtkWidget *widget, GdkEventExpose *event) { if (gtk_widget_is_drawable (widget)) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkAllocation allocation; cairo_t *cr; gimp_ruler_draw_ticks (ruler); cr = gdk_cairo_create (gtk_widget_get_window (widget)); gdk_cairo_region (cr, event->region); cairo_clip (cr); gtk_widget_get_allocation (widget, &allocation); cairo_translate (cr, allocation.x, allocation.y); cairo_set_source_surface (cr, priv->backing_store, 0, 0); cairo_paint (cr); gimp_ruler_draw_pos (ruler); cairo_destroy (cr); } return FALSE; }
/** * gimp_ruler_set_position: * @ruler: a #GimpRuler * @position: the position to set the ruler to * * This sets the position of the ruler. * * Since: GIMP 2.8 */ void gimp_ruler_set_position (GimpRuler *ruler, gdouble position) { GimpRulerPrivate *priv; g_return_if_fail (GIMP_IS_RULER (ruler)); priv = GIMP_RULER_GET_PRIVATE (ruler); if (priv->position != position) { priv->position = position; g_object_notify (G_OBJECT (ruler), "position"); gimp_ruler_draw_pos (ruler); } }
static gboolean gimp_ruler_draw (GtkWidget *widget, cairo_t *cr) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height); gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height); if (! priv->backing_store_valid) gimp_ruler_draw_ticks (ruler); cairo_set_source_surface (cr, priv->backing_store, 0, 0); cairo_paint (cr); gimp_ruler_draw_pos (ruler, cr); return FALSE; }