diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 55 | ||||
-rw-r--r-- | src/presentation.h | 13 | ||||
-rw-r--r-- | src/tool_select.c | 24 | ||||
-rw-r--r-- | src/tool_text.c | 65 |
4 files changed, 64 insertions, 93 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 2ab4175..6dc82a4 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -609,6 +609,34 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, } +static void start_drag_create(struct presentation *p, double x, double y) +{ + p->start_corner_x = x; + p->start_corner_y = y; + p->create_dragging = 1; +} + + +static void drag_create(struct presentation *p, double x, double y) +{ + p->drag_corner_x = x; + p->drag_corner_y = y; + redraw_overlay(p); +} + + +static void finish_drag_create(struct presentation *p, double x, double y) +{ + p->drag_corner_x = x; + p->drag_corner_y = y; + p->create_dragging = 0; + redraw_overlay(p); + p->cur_tool->create_region(p->cur_tool, p, + p->start_corner_x, p->start_corner_y, + p->drag_corner_x, p->drag_corner_y); +} + + static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, struct presentation *p) { @@ -619,12 +647,10 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, p->drag_reason = DRAG_REASON_CREATE; /* Start the drag, and send the first drag event */ - p->cur_tool->start_drag_create(p->cur_tool, p, - p->start_create_drag_x, - p->start_create_drag_y); - p->cur_tool->drag_create(p->cur_tool, p, - event->x - p->border_offs_x, - event->y - p->border_offs_y); + start_drag_create(p, p->start_create_drag_x, + p->start_create_drag_y); + drag_create(p, event->x - p->border_offs_x, + event->y - p->border_offs_y); break; case DRAG_REASON_MOVE : @@ -634,9 +660,8 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, break; case DRAG_REASON_CREATE : - p->cur_tool->drag_create(p->cur_tool, p, - event->x - p->border_offs_x, - event->y - p->border_offs_y); + drag_create(p, event->x - p->border_offs_x, + event->y - p->border_offs_y); break; @@ -700,7 +725,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event, break; case DRAG_REASON_CREATE : - p->cur_tool->finish_drag_create(p->cur_tool, p, x, y); + finish_drag_create(p, x, y); break; case DRAG_REASON_MOVE : @@ -745,6 +770,16 @@ static void draw_overlay(cairo_t *cr, struct presentation *p) cairo_set_line_width(cr, 1.0); cairo_stroke(cr); } + + if ( p->create_dragging ) { + cairo_new_path(cr); + cairo_rectangle(cr, p->start_corner_x, p->start_corner_y, + p->drag_corner_x - p->start_corner_x, + p->drag_corner_y - p->start_corner_y); + cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); + cairo_set_line_width(cr, 0.5); + cairo_stroke(cr); + } } diff --git a/src/presentation.h b/src/presentation.h index 2b6f67c..a06fbc9 100644 --- a/src/presentation.h +++ b/src/presentation.h @@ -67,12 +67,8 @@ struct toolinfo void (*drag_object)(struct toolinfo *tip, struct presentation *p, struct object *o, double x, double y); - void (*start_drag_create)(struct toolinfo *tip, struct presentation *p, - double x, double y); - void (*drag_create)(struct toolinfo *tip, struct presentation *p, - double x, double y); - void (*finish_drag_create)(struct toolinfo *tip, struct presentation *p, - double x, double y); + void (*create_region)(struct toolinfo *tip, struct presentation *p, + double x1, double y1, double x2, double y2); void (*draw_editing_overlay)(struct toolinfo *tip, cairo_t *cr, struct object *o); @@ -136,6 +132,11 @@ struct presentation double drag_offs_y; double start_create_drag_x; double start_create_drag_y; + int create_dragging; + double start_corner_x; + double start_corner_y; + double drag_corner_x; + double drag_corner_y; enum drag_reason drag_reason; unsigned int num_slides; diff --git a/src/tool_select.c b/src/tool_select.c index 39f4525..c03ebd1 100644 --- a/src/tool_select.c +++ b/src/tool_select.c @@ -85,24 +85,10 @@ static void drag_object(struct toolinfo *tip, struct presentation *p, } -static void start_drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) +static void create_region(struct toolinfo *tip, struct presentation *p, + double x1, double y1, double x2, double y2) { - /* Do nothing */ -} - - -static void drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) -{ - /* Do nothing */ -} - - -static void finish_drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) -{ - /* Do nothing */ + printf("Create %5.2f %5.2f %5.2f %5.2f\n", x1, y1, x2, y2); } @@ -151,9 +137,7 @@ struct toolinfo *initialise_select_tool() ti->base.select = select_object; ti->base.deselect = deselect_object; ti->base.drag_object = drag_object; - ti->base.start_drag_create = start_drag_create; - ti->base.drag_create = drag_create; - ti->base.finish_drag_create = finish_drag_create; + ti->base.create_region = create_region; ti->base.draw_editing_overlay = draw_overlay; ti->base.key_pressed = key_pressed; ti->base.im_commit = im_commit; diff --git a/src/tool_text.c b/src/tool_text.c index 038b375..ff290d1 100644 --- a/src/tool_text.c +++ b/src/tool_text.c @@ -40,12 +40,6 @@ struct text_toolinfo { struct toolinfo base; PangoContext *pc; - - int create_dragging; - double start_corner_x; - double start_corner_y; - double drag_corner_x; - double drag_corner_y; }; @@ -461,42 +455,6 @@ static void drag_object(struct toolinfo *tip, struct presentation *p, } -static void start_drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) -{ - struct text_toolinfo *ti = (struct text_toolinfo *)tip; - - ti->start_corner_x = x; - ti->start_corner_y = y; - ti->create_dragging = 1; -} - - -static void drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) -{ - struct text_toolinfo *ti = (struct text_toolinfo *)tip; - - ti->drag_corner_x = x; - ti->drag_corner_y = y; - - redraw_overlay(p); -} - - -static void finish_drag_create(struct toolinfo *tip, struct presentation *p, - double x, double y) -{ - struct text_toolinfo *ti = (struct text_toolinfo *)tip; - - ti->drag_corner_x = x; - ti->drag_corner_y = y; - ti->create_dragging = 0; - - redraw_overlay(p); -} - - static void create_default(struct presentation *p, struct style *sty, struct toolinfo *tip) { @@ -509,6 +467,13 @@ static void create_default(struct presentation *p, struct style *sty, } +static void create_region(struct toolinfo *tip, struct presentation *p, + double x1, double y1, double x2, double y2) +{ + printf("Create %5.2f %5.2f %5.2f %5.2f\n", x1, y1, x2, y2); +} + + static void select_object(struct object *o, struct toolinfo *tip) { /* Do nothing */ @@ -528,22 +493,10 @@ static int deselect_object(struct object *o, struct toolinfo *tip) static void draw_overlay(struct toolinfo *tip, cairo_t *cr, struct object *o) { - struct text_toolinfo *ti = (struct text_toolinfo *)tip; - if ( o != NULL ) { draw_editing_box(cr, o->x, o->y, o->bb_width, o->bb_height); draw_caret(cr, o); } - - if ( ti->create_dragging ) { - cairo_new_path(cr); - cairo_rectangle(cr, ti->start_corner_x, ti->start_corner_y, - ti->drag_corner_x - ti->start_corner_x, - ti->drag_corner_y - ti->start_corner_y); - cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); - cairo_set_line_width(cr, 0.5); - cairo_stroke(cr); - } } @@ -589,9 +542,7 @@ struct toolinfo *initialise_text_tool(GtkWidget *w) ti->base.select = select_object; ti->base.deselect = deselect_object; ti->base.drag_object = drag_object; - ti->base.start_drag_create = start_drag_create; - ti->base.drag_create = drag_create; - ti->base.finish_drag_create = finish_drag_create; + ti->base.create_region = create_region; ti->base.draw_editing_overlay = draw_overlay; ti->base.key_pressed = key_pressed; ti->base.im_commit = im_commit; |