diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-05-26 19:35:43 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-05-26 19:35:43 +0200 |
commit | 96605c925f243e88eeeb346dde95fb5a3066434f (patch) | |
tree | e23edbd19f8bca2a4f34f6d3dfd9fe4943cbed13 /src/mainwindow.c | |
parent | bcbdceef6e1be59a6ca1d653b6a54bf9009b4143 (diff) |
More clicky logic
Diffstat (limited to 'src/mainwindow.c')
-rw-r--r-- | src/mainwindow.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 44fed9e..df5fd59 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -185,13 +185,29 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, struct presentation *p) { + struct object *clicked; + gdouble x, y; + + x = event->x - p->border_offs_x; + y = event->y - p->border_offs_y; + if ( p->editing_object && p->editing_object->empty ) { delete_object(p->editing_object); } + p->editing_object = NULL; + + if ( (x>0.0) && (x<p->view_slide->slide_width) + && (y>0.0) && (y<p->view_slide->slide_height) ) + { + clicked = find_object_at_position(p->view_slide, x, y); + if ( !clicked ) { + p->editing_object = add_text_object(p->view_slide, + x, y); + } else { + p->editing_object = clicked; + } - p->editing_object = add_text_object(p->view_slide, - event->x - p->border_offs_x, - event->y - p->border_offs_y); + } gtk_widget_grab_focus(GTK_WIDGET(da)); @@ -219,9 +235,7 @@ static void draw_editing_bits(cairo_t *cr, struct object *o) case TEXT : - draw_editing_box(cr, o->x - o->bb_width/2.0, - o->y - o->bb_height/2.0, - o->bb_width, o->bb_height); + draw_editing_box(cr, o->x, o->y, o->bb_width, o->bb_height); break; } |