Ignore terminals when hovering above selection.

Also fix checking for the shift key and rename the "object"
variable to "object_at_cursor" in button handlers.
This commit is contained in:
Přemysl Eric Janouch 2011-06-08 07:51:01 +02:00
parent 8001619bf1
commit cd66c3d84a
2 changed files with 39 additions and 25 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
Version TBD
- Fixed checking for the shift key when selecting.
- Terminals are ignored when hovering the cursor above a selection.
Version 0.1.2 Version 0.1.2
- Updated symbol library. - Updated symbol library.
- Added Slovak, Polish and German translations. - Added Slovak, Polish and German translations.

View File

@ -1307,6 +1307,13 @@ check_terminals (LdDiagramView *self, const LdPoint *point)
{ {
GList *objects, *iter; GList *objects, *iter;
CheckTerminalsData data; CheckTerminalsData data;
LdDiagramObject *object_at_cursor;
hide_terminals (self);
object_at_cursor = get_object_at_point (self, point);
if (object_at_cursor && is_object_selected (self, object_at_cursor))
return;
data.found = FALSE; data.found = FALSE;
data.point = *point; data.point = *point;
@ -1321,8 +1328,6 @@ check_terminals (LdDiagramView *self, const LdPoint *point)
check_symbol_terminals (self, iter->data, &data); check_symbol_terminals (self, iter->data, &data);
} }
hide_terminals (self);
if (data.found) if (data.found)
{ {
self->priv->terminal_hovered = TRUE; self->priv->terminal_hovered = TRUE;
@ -2165,7 +2170,7 @@ on_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
LdPoint point; LdPoint point;
LdDiagramView *self; LdDiagramView *self;
AddObjectData *data; AddObjectData *data;
LdDiagramObject *object; LdDiagramObject *object_at_cursor;
point.x = event->x; point.x = event->x;
point.y = event->y; point.y = event->y;
@ -2183,9 +2188,9 @@ on_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
rotate_symbol (self, LD_DIAGRAM_SYMBOL (data->object)); rotate_symbol (self, LD_DIAGRAM_SYMBOL (data->object));
break; break;
case OPER_0: case OPER_0:
object = get_object_at_point (self, &point); object_at_cursor = get_object_at_point (self, &point);
if (object && LD_IS_DIAGRAM_SYMBOL (object)) if (object_at_cursor && LD_IS_DIAGRAM_SYMBOL (object_at_cursor))
rotate_symbol (self, LD_DIAGRAM_SYMBOL (object)); rotate_symbol (self, LD_DIAGRAM_SYMBOL (object_at_cursor));
return FALSE; return FALSE;
} }
} }
@ -2211,28 +2216,33 @@ on_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
break; break;
case OPER_0: case OPER_0:
self->priv->drag_start_pos = point; self->priv->drag_start_pos = point;
object_at_cursor = get_object_at_point (self, &point);
if (self->priv->terminal_hovered) if (self->priv->terminal_hovered
&& (!ld_diagram_get_selection (self->priv->diagram)
|| !object_at_cursor
|| !is_object_selected (self, object_at_cursor)))
{ {
self->priv->drag_operation = OPER_CONNECT; if (ld_diagram_get_selection (self->priv->diagram))
break; ld_diagram_unselect_all (self->priv->diagram);
}
object = get_object_at_point (self, &point); self->priv->drag_operation = OPER_CONNECT;
if (!object) }
else if (object_at_cursor)
{
if (!is_object_selected (self, object_at_cursor))
{
if (!(event->state & GDK_SHIFT_MASK))
ld_diagram_unselect_all (self->priv->diagram);
ld_diagram_select (self->priv->diagram, object_at_cursor);
}
self->priv->drag_operation = OPER_MOVE_SELECTION;
}
else
{ {
ld_diagram_unselect_all (self->priv->diagram); ld_diagram_unselect_all (self->priv->diagram);
self->priv->drag_operation = OPER_SELECT; self->priv->drag_operation = OPER_SELECT;
} }
else if (!is_object_selected (self, object))
{
if (event->state != GDK_SHIFT_MASK)
ld_diagram_unselect_all (self->priv->diagram);
ld_diagram_select (self->priv->diagram, object);
self->priv->drag_operation = OPER_MOVE_SELECTION;
}
else
self->priv->drag_operation = OPER_MOVE_SELECTION;
break; break;
} }
return FALSE; return FALSE;
@ -2243,7 +2253,7 @@ on_button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{ {
LdPoint point; LdPoint point;
LdDiagramView *self; LdDiagramView *self;
LdDiagramObject *object; LdDiagramObject *object_at_cursor;
if (event->button != 1) if (event->button != 1)
return FALSE; return FALSE;
@ -2264,12 +2274,12 @@ on_button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
LD_DIAGRAM_VIEW_GET_CLASS (self)->cancel_operation_signal, 0); LD_DIAGRAM_VIEW_GET_CLASS (self)->cancel_operation_signal, 0);
break; break;
case OPER_0: case OPER_0:
object = get_object_at_point (self, &point); object_at_cursor = get_object_at_point (self, &point);
if (object && is_object_selected (self, object)) if (object_at_cursor && is_object_selected (self, object_at_cursor))
{ {
if (!(event->state & GDK_SHIFT_MASK)) if (!(event->state & GDK_SHIFT_MASK))
ld_diagram_unselect_all (self->priv->diagram); ld_diagram_unselect_all (self->priv->diagram);
ld_diagram_select (self->priv->diagram, object); ld_diagram_select (self->priv->diagram, object_at_cursor);
} }
break; break;
} }