1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-17 21:14:04 +02:00

When repeatedly clicking on a stack of items to cycle through the stack, a

click on an anchor point of the selected object would be treated as a drag, 
even if the click was very short. This created a very confusing user 
experience.

- gui_canvas.c (button_release_event): if we didn't "escape" the drag radius,
  don't treat the click as a drag but run the click-to-select process instead
  (note: the drag visualization still flickers briefly)
- gui_canvas.c (button_release_event): to find out if we've escaped the drag
  radius, just call drag_left instead of duplicating some of its code



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5772 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2010-01-02 22:04:25 +00:00
parent 522e8df574
commit f9eefa4e69

View File

@ -40,8 +40,11 @@ static struct coord curr_pos; /* canvas coordinates ! */
static struct coord user_origin = { 0, 0 }; static struct coord user_origin = { 0, 0 };
static int dragging = 0; static int dragging = 0;
static int drag_escaped = 0; /* 1 once we've made is out of the drag radius */ static int drag_escaped = 0; /* 1 once we've made it out of the drag radius */
static struct coord drag_start; static struct coord drag_start;
static struct inst *selected_before_drag;
/* instance selected before dragging. we use it to do the click-to-select
routine in case we later find out the drag was really just a click. */
/* ----- status display ---------------------------------------------------- */ /* ----- status display ---------------------------------------------------- */
@ -183,11 +186,22 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
/* ----- button press and release ------------------------------------------ */ /* ----- button press and release ------------------------------------------ */
static void click_to_select(struct coord pos)
{
const struct inst *prev;
tool_reset();
prev = selected_inst;
inst_select(pos);
if (prev != selected_inst)
redraw();
}
static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event, static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
gpointer data) gpointer data)
{ {
struct coord pos = canvas_to_coord(event->x, event->y); struct coord pos = canvas_to_coord(event->x, event->y);
const struct inst *prev;
int res; int res;
DPRINTF("--- button press ---"); DPRINTF("--- button press ---");
@ -207,6 +221,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
break; break;
} }
if (res) { if (res) {
selected_before_drag = selected_inst;
inst_deselect(); inst_deselect();
redraw(); redraw();
dragging = 1; dragging = 1;
@ -214,11 +229,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
drag_start = pos; drag_start = pos;
break; break;
} }
tool_reset(); click_to_select(pos);
prev = selected_inst;
inst_select(pos);
if (prev != selected_inst)
redraw();
break; break;
case 2: case 2:
tool_dehover(); tool_dehover();
@ -241,14 +252,16 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
case 1: case 1:
if (!dragging) if (!dragging)
break; break;
drag_left(pos);
dragging = 0; dragging = 0;
if (hypot(pos.x-drag_start.x, if (!drag_escaped) {
pos.y-drag_start.y)/draw_ctx.scale < DRAG_MIN_R)
tool_cancel_drag(); tool_cancel_drag();
else { selected_inst = selected_before_drag;
click_to_select(pos);
break;
}
if (tool_end_drag(pos)) if (tool_end_drag(pos))
change_world(); change_world();
}
break; break;
} }
return TRUE; return TRUE;