Example #1
0
static gboolean
drawable_motion_cb (GtkWidget *widget, GdkEventMotion *event, VnrCrop *crop)
{
    if(!crop->drawing_rectangle)
        return FALSE;

    gdouble x, y;
    x = event->x;
    y = event->y;

    x = CLAMP(x, 0, crop->width);
    y = CLAMP(y, 0, crop->height);

    vnr_crop_clear_rectangle (crop);

    if(x > crop->start_x)
    {
        crop->sub_x = crop->start_x;
        crop->sub_width = x - crop->start_x;
    }
    else if(x == crop->start_x)
    {
        crop->sub_x = x;
        crop->sub_width = 1;
    }
    else
    {
        crop->sub_x = x;
        crop->sub_width = crop->start_x - x;
    }

    if(y > crop->start_y)
    {
        crop->sub_y = crop->start_y;
        crop->sub_height = y - crop->start_y;
    }
    else if(y == crop->start_y)
    {
        crop->sub_y = y;
        crop->sub_height = 1;
    }
    else
    {
        crop->sub_y = y;
        crop->sub_height = crop->start_y - y;
    }

    crop->drawing_rectangle = FALSE;
    crop->do_redraw= FALSE;

    vnr_crop_update_spin_button_values (crop);

    crop->drawing_rectangle = TRUE;
    crop->do_redraw= TRUE;

    vnr_crop_draw_rectangle (crop);

    return FALSE;
}
Example #2
0
static void
spin_height_cb (GtkSpinButton *spinbutton, VnrCrop *crop)
{
    if(crop->drawing_rectangle)
        return;

    vnr_crop_clear_rectangle (crop);

    crop->sub_height = gtk_spin_button_get_value(spinbutton) * crop->zoom;

    if(crop->sub_height <1)
        crop->sub_height = 1;

    vnr_crop_draw_rectangle (crop);
}
Example #3
0
static void
spin_y_cb (GtkSpinButton *spinbutton, VnrCrop *crop)
{
    if(crop->drawing_rectangle)
        return;

    vnr_crop_clear_rectangle (crop);

    gboolean old_do_redraw = crop->do_redraw;
    crop->do_redraw = FALSE;
    gtk_spin_button_set_range (crop->spin_height, 1,
                               crop->vnr_win->current_image_height
                                - gtk_spin_button_get_value(spinbutton));
    crop->do_redraw = old_do_redraw;

    crop->sub_y = gtk_spin_button_get_value(spinbutton) * crop->zoom;

    vnr_crop_check_sub_y(crop);

    vnr_crop_draw_rectangle (crop);
}
Example #4
0
static gboolean
drawable_expose_cb (GtkWidget *widget, GdkEventExpose *event, VnrCrop *crop)
{
    gdk_draw_pixbuf (GDK_DRAWABLE(widget->window), NULL, crop->preview_pixbuf,
                     0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);

    crop->gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
    gdk_gc_set_function (crop->gc, GDK_INVERT);
    gdk_gc_set_line_attributes (crop->gc,
                                2,
                                GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);

    if(crop->sub_width == -1)
    {
        crop->sub_x = 0;
        crop->sub_y = 0;
        crop->sub_width = crop->width;
        crop->sub_height = crop->height;
    }
    vnr_crop_clear_rectangle (crop);

    return FALSE;
}