Exemple #1
0
void 
gv_rotate_tool_terminate( GvRotateTool *tool )
{
    if( tool->rrmode == RRMODE_DISPLAY )
        return;

    if( tool->original != NULL 
        && gv_shapes_get_shape( tool->layer->data, tool->shape_id) != NULL )
    {
        gv_shapes_replace_shapes( tool->layer->data, 1, &(tool->shape_id), 
                                  &(tool->original), FALSE );
        tool->original = NULL;
        gv_undo_enable();
        gv_undo_open();
    }
    else if( tool->original != NULL )
    {
        gv_shape_delete( tool->original );
        tool->original = NULL;
        gv_undo_enable();
        gv_undo_open();
    }

    tool->shape_id = -1;
    tool->rrmode = RRMODE_DISPLAY;
    gv_view_area_queue_draw(GV_TOOL(tool)->view);
}
Exemple #2
0
static void
gv_rotate_tool_button_release(GvTool *r_tool, GdkEventButton *event)
{
    GvRotateTool *tool = GV_ROTATE_TOOL(r_tool);

    if( tool->rrmode == RRMODE_DISPLAY )
        return;

    /* Put back original shape. */
    gv_shapes_replace_shapes( tool->layer->data, 1, &(tool->shape_id), 
                              &(tool->original), TRUE );
    
    /* re-enable undo */
    gv_undo_enable();
    gv_undo_open();

    /* Apply rotation or scaling to working shape. */
    if( tool->rrmode == RRMODE_SCALE 
        || tool->rrmode == RRMODE_ROTATESCALE )
        gv_shape_scale( tool->original, tool->scaling );

    if( tool->rrmode == RRMODE_ROTATE 
        || tool->rrmode == RRMODE_ROTATESCALE )
        gv_shape_rotate( tool->original, tool->rotation );

    /* Apply to the shapes object ... this will be undoable */
    gv_shapes_replace_shapes( tool->layer->data, 1, &(tool->shape_id), 
                              &(tool->original), TRUE );
    tool->original = NULL;
        
    tool->rrmode = RRMODE_DISPLAY;
}
Exemple #3
0
static void
gv_rect_tool_key_press(GvTool *rtool, GdkEventKey *event)
{
    GvRectTool *tool = GV_RECT_TOOL(rtool);

    if (!gv_rect_tool_configure(tool)) return;

    switch (event->keyval)
    {
        case GDK_Delete:
        case GDK_BackSpace:
        case GDK_Escape:
          if( tool->drawing )
          {
              tool->drawing = FALSE;
              gv_view_area_queue_draw(GV_TOOL(tool)->view);
          }
          if( tool->reshaping )
          {
              /* Reopen undo.  Push a memento describing the ring addition */
              gv_undo_enable();
              gv_undo_open();

              tool->reshaping = FALSE;
              gv_view_area_queue_draw(GV_TOOL(tool)->view);
          }
          break;
    }
}
Exemple #4
0
static gboolean
gv_rect_tool_button_release(GvTool *r_tool, GdkEventButton *event)
{
    GvRectTool *tool = GV_RECT_TOOL(r_tool);

    if (event->button == 1 && tool->drawing )
    {
        GvShape *shape;

        if (!gv_rect_tool_configure(tool)) return FALSE;

        /* Map pointer position to tail vertex */
        gv_view_area_map_pointer(GV_TOOL(tool)->view, event->x, event->y,
                                 &tool->v_tail.x, &tool->v_tail.y);

        gv_tool_clamp_to_bounds( GV_TOOL(tool),
                                 &tool->v_tail.x, &tool->v_tail.y );

        if( tool->v_tail.x != tool->v_head.x 
            && tool->v_tail.y != tool->v_head.y )
        {
            /* create the new rectangle */
            shape = gv_shape_new( GVSHAPE_AREA );

            gv_shape_add_node( shape, 0, tool->v_tail.x, tool->v_tail.y, 0 );
            gv_shape_add_node( shape, 0, tool->v_tail.x, tool->v_head.y, 0 );
            gv_shape_add_node( shape, 0, tool->v_head.x, tool->v_head.y, 0 );
            gv_shape_add_node( shape, 0, tool->v_head.x, tool->v_tail.y, 0 );
            gv_shape_add_node( shape, 0, tool->v_tail.x, tool->v_tail.y, 0 ); 

            gv_shapes_layer_select_new_shape( GV_SHAPES_LAYER(tool->layer), 
                                              shape );
        }

        tool->drawing = FALSE;
        return FALSE;
    }

    if (event->button == 1 && tool->reshaping )
    {
        if (!gv_rect_tool_configure(tool)) return FALSE;

        /* Reopen undo.  Push a memento describing the ring addition */
        gv_undo_enable();
        gv_undo_open();

        /* Map pointer position to tail vertex */
        gv_view_area_map_pointer(GV_TOOL(tool)->view, event->x, event->y,
                                 &tool->v_tail.x, &tool->v_tail.y);
        gv_rect_tool_reshape( tool, tool->v_tail.x, tool->v_tail.y );

        tool->reshaping = FALSE;
    }
    return FALSE;
}