aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-07-29 22:57:29 +0200
committerThomas White <taw@bitwiz.org.uk>2013-07-29 22:57:29 +0200
commit43ffbe1e916aac750c0a112de013cf709ce6723d (patch)
tree721ae18d81c329cfcfe0b1bd62f933405d0f06a2
parent2dc8e58f3109e119f6e2afe1285eb3288925de23 (diff)
Fix selection logic
-rw-r--r--src/mainwindow.c117
-rw-r--r--src/presentation.h1
2 files changed, 73 insertions, 45 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 42a8ce5..beea913 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1134,65 +1134,84 @@ static void calculate_box_size(struct frame *fr, struct presentation *p,
static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
struct presentation *p)
{
- struct frame *clicked;
+ enum corner c;
gdouble x, y;
x = event->x - p->border_offs_x;
y = event->y - p->border_offs_y;
- clicked = find_frame_at_position(p->cur_edit_slide->top, x, y);
-
- if ( clicked == NULL ) {
-
- /* Clicked no object. Deselect old object and set up for
- * (maybe) creating a new one. */
-
- set_selection(p, NULL);
- p->start_corner_x = event->x - p->border_offs_x;
- p->start_corner_y = event->y - p->border_offs_y;
- p->drag_status = DRAG_STATUS_COULD_DRAG;
- p->drag_reason = DRAG_REASON_CREATE;
-
- } else {
-
- /* If the clicked object is not the same as the previously
- * selected one, deselect the old one. */
- if ( p->selection[0] != clicked ) {
+ if ( p->n_selection == 0 ) {
+
+ struct frame *clicked;
+
+ clicked = find_frame_at_position(p->cur_edit_slide->top, x, y);
+
+ if ( clicked == NULL ) {
+
+ /* Clicked no object. Deselect old object and set up for
+ * (maybe) creating a new one. */
+
set_selection(p, NULL);
+ p->start_corner_x = event->x - p->border_offs_x;
+ p->start_corner_y = event->y - p->border_offs_y;
+ p->drag_status = DRAG_STATUS_COULD_DRAG;
+ p->drag_reason = DRAG_REASON_CREATE;
+
+ } else {
+
+ /* Select new frame */
p->drag_status = DRAG_STATUS_NONE;
p->drag_reason = DRAG_REASON_NONE;
set_selection(p, clicked);
+
+ }
+
+ } else {
+
+ struct frame *fr;
+
+ fr = p->selection[0];
+
+ /* Within the resizing region? */
+ c = which_corner(x, y, fr);
+ if ( c != CORNER_NONE ) {
+
+ p->drag_reason = DRAG_REASON_RESIZE;
+ p->drag_corner = c;
+
+ p->start_corner_x = x;
+ p->start_corner_y = y;
+ p->diagonal_length = pow(fr->w, 2.0);
+ p->diagonal_length += pow(fr->h, 2.0);
+ p->diagonal_length = sqrt(p->diagonal_length);
+
+ calculate_box_size(fr, p, x, y);
+
+ p->drag_status = DRAG_STATUS_COULD_DRAG;
+ p->drag_reason = DRAG_REASON_RESIZE;
+ printf("could drag resize\n");
+
+
} else {
-
- enum corner c;
- struct frame *fr;
-
- fr = p->selection[0];
-
- /* Within the resizing region? */
- c = which_corner(x, y, fr);
- if ( c != CORNER_NONE ) {
-
- p->drag_reason = DRAG_REASON_RESIZE;
- p->drag_corner = c;
-
- p->start_corner_x = x;
- p->start_corner_y = y;
- p->diagonal_length = pow(fr->w, 2.0);
- p->diagonal_length += pow(fr->h, 2.0);
- p->diagonal_length = sqrt(p->diagonal_length);
-
- calculate_box_size(fr, p, x, y);
-
+
+ struct frame *clicked;
+
+ clicked = find_frame_at_position(p->cur_edit_slide->top,
+ x, y);
+
+ if ( clicked == fr ) {
p->drag_status = DRAG_STATUS_COULD_DRAG;
- p->drag_reason = DRAG_REASON_RESIZE;
- printf("could drag resize\n");
+ p->drag_reason = DRAG_REASON_MOVE;
+ } else {
+ /* Select new frame */
+ p->drag_status = DRAG_STATUS_NONE;
+ p->drag_reason = DRAG_REASON_NONE;
+ set_selection(p, clicked);
}
-
}
-
+
}
-
+
gtk_widget_grab_focus(GTK_WIDGET(da));
redraw_editor(p);
return FALSE;
@@ -1232,6 +1251,10 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
event->y - p->border_offs_y);
redraw_editor(p);
break;
+
+ case DRAG_REASON_MOVE :
+
+ break;
}
@@ -1323,6 +1346,10 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
case DRAG_REASON_RESIZE :
do_resize(p, p->box_x, p->box_y, p->box_width, p->box_height);
break;
+
+ case DRAG_REASON_MOVE :
+ /* FIXME */
+ break;
}
diff --git a/src/presentation.h b/src/presentation.h
index f0e3071..208ed66 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -57,6 +57,7 @@ enum drag_reason
DRAG_REASON_CREATE,
DRAG_REASON_IMPORT,
DRAG_REASON_RESIZE,
+ DRAG_REASON_MOVE
};