[graph-gtk] Visual feedback when connecting pads
- From: Isaac Wagner <isaacbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [graph-gtk] Visual feedback when connecting pads
- Date: Fri, 27 Jul 2012 13:37:00 +0000 (UTC)
commit 3795d0f22400c36cb414c6c3847275ccc55872f9
Author: Isaac Wagner <isaacbw src gnome org>
Date: Fri Jul 27 09:36:54 2012 -0400
Visual feedback when connecting pads
graph-gtk/graph-gtk-view.c | 23 +++++++++++++++++++++++
graph-gtk/graph-gtk-view.h | 2 ++
2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/graph-gtk/graph-gtk-view.c b/graph-gtk/graph-gtk-view.c
index 6911500..945ea82 100644
--- a/graph-gtk/graph-gtk-view.c
+++ b/graph-gtk/graph-gtk-view.c
@@ -183,6 +183,19 @@ graph_gtk_view_draw(GtkWidget *widget, cairo_t* cr)
}
}
+ if(view->is_mouse_connecting)
+ {
+ int x, y;
+ graph_gtk_pad_get_position(view->pad_connecting_from, &x, &y);
+
+ cairo_move_to(cr, x, y);
+ cairo_line_to(cr, view->mouse_x, view->mouse_y);
+
+ cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+ }
+
GSList* list;
for(list = view->nodes; list != NULL; list = list->next)
{
@@ -271,6 +284,8 @@ graph_gtk_view_button_released(GtkWidget* widget, GdkEventButton* event)
}
else if(self->is_mouse_connecting)
{
+ self->is_mouse_connecting = FALSE;
+
GSList *nodes;
for(nodes = self->nodes; nodes != NULL; nodes = nodes->next)
{
@@ -307,6 +322,14 @@ static gboolean
graph_gtk_view_mouse_moved(GtkWidget* widget, GdkEventMotion* event)
{
GraphGtkView *self = GRAPH_GTK_VIEW(widget);
+
+ self->mouse_x = event->x;
+ self->mouse_y = event->y;
+
+ if(self->is_mouse_connecting)
+ {
+ REDRAW();
+ }
if(self->is_mouse_dragging)
{
diff --git a/graph-gtk/graph-gtk-view.h b/graph-gtk/graph-gtk-view.h
index dfd5893..6cf6b07 100644
--- a/graph-gtk/graph-gtk-view.h
+++ b/graph-gtk/graph-gtk-view.h
@@ -61,6 +61,8 @@ struct _GraphGtkView
gboolean is_mouse_connecting;
GraphGtkPad* pad_connecting_from;
+ gdouble mouse_x, mouse_y;
+
gboolean is_mouse_dragging; //mouse was pressed on a node and has not yet been released
gint drag_begin_x, drag_begin_y; //mouse coordinates in screen space when dragging began
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]