Movimiento de objetos con cursores
authordanigm <danigm>
Fri, 26 Feb 2010 20:03:55 +0000 (20:03 +0000)
committerdanigm <danigm@aa302d1f-72b1-406a-902b-8593ca2b2744>
Fri, 26 Feb 2010 20:03:55 +0000 (20:03 +0000)
git-svn-id: https://forja.rediris.es/svn/cusl4-tbo@70 aa302d1f-72b1-406a-902b-8593ca2b2744

src/doodle-treeview.c
src/selector-tool.c
src/tbo-object.c
src/tbo-object.h

index c49a19d..68d80f6 100644 (file)
@@ -220,33 +220,3 @@ doodle_setup_tree (TboWindow *tbo)
 
     return vbox;
 }
-
-void
-tbo_object_order_down (tbo_object *self)
-{
-    Frame *frame = get_frame_view ();
-    GList *list = g_list_find (frame->objects, self);
-    GList *prev = g_list_previous (list);
-    tbo_object *tmp;
-    if (prev)
-    {
-        tmp = (tbo_object*)list->data;
-        list->data = prev->data;
-        prev->data = tmp;
-    }
-}
-
-void
-tbo_object_order_up (tbo_object *self)
-{
-    Frame *frame = get_frame_view ();
-    GList *list = g_list_find (frame->objects, self);
-    GList *next = g_list_next (list);
-    tbo_object *tmp;
-    if (next)
-    {
-        tmp = (tbo_object*)list->data;
-        list->data = next->data;
-        next->data = tmp;
-    }
-}
index 16080d3..c53912f 100644 (file)
@@ -433,16 +433,16 @@ frame_view_on_key (GtkWidget *widget, GdkEventKey *event, TboWindow *tbo)
                 tbo_object_order_down (OBJ);
                 break;
             case GDK_Up:
-                printf ("up\n");
+                tbo_object_move (OBJ, MOVE_UP);
                 break;
             case GDK_Down:
-                printf ("down\n");
+                tbo_object_move (OBJ, MOVE_DOWN);
                 break;
             case GDK_Left:
-                printf ("left\n");
+                tbo_object_move (OBJ, MOVE_LEFT);
                 break;
             case GDK_Right:
-                printf ("right\n");
+                tbo_object_move (OBJ, MOVE_RIGHT);
                 break;
             default:
                 break;
index 6a35a01..9c380b5 100644 (file)
@@ -1,5 +1,6 @@
 #include <gtk/gtk.h>
 #include <cairo.h>
+#include "ui-drawing.h"
 #include "tbo-types.h"
 #include "tbo-object.h"
 
@@ -40,3 +41,55 @@ tbo_object_get_flip_matrix (tbo_object *self, cairo_matrix_t *mx)
         mx->y0 = 0;
     }
 }
+
+void
+tbo_object_order_down (tbo_object *self)
+{
+    Frame *frame = get_frame_view ();
+    GList *list = g_list_find (frame->objects, self);
+    GList *prev = g_list_previous (list);
+    tbo_object *tmp;
+    if (prev)
+    {
+        tmp = (tbo_object*)list->data;
+        list->data = prev->data;
+        prev->data = tmp;
+    }
+}
+
+void
+tbo_object_order_up (tbo_object *self)
+{
+    Frame *frame = get_frame_view ();
+    GList *list = g_list_find (frame->objects, self);
+    GList *next = g_list_next (list);
+    tbo_object *tmp;
+    if (next)
+    {
+        tmp = (tbo_object*)list->data;
+        list->data = next->data;
+        next->data = tmp;
+    }
+}
+
+void
+tbo_object_move (tbo_object *self, enum MOVE_OPT type)
+{
+    switch (type)
+    {
+        case MOVE_UP:
+            self->y -= MOVING_OFFSET;
+            break;
+        case MOVE_DOWN:
+            self->y += MOVING_OFFSET;
+            break;
+        case MOVE_LEFT:
+            self->x -= MOVING_OFFSET;
+            break;
+        case MOVE_RIGHT:
+            self->x += MOVING_OFFSET;
+            break;
+        default:
+            break;
+    }
+}
index 4ea54c6..2fce8b9 100644 (file)
@@ -2,8 +2,19 @@
 #include <cairo.h>
 #include "tbo-types.h"
 
+enum MOVE_OPT
+{
+    MOVE_UP,
+    MOVE_DOWN,
+    MOVE_LEFT,
+    MOVE_RIGHT,
+};
+
+static int MOVING_OFFSET = 10;
+
 void tbo_object_flipv (tbo_object *self);
 void tbo_object_fliph (tbo_object *self);
 void tbo_object_get_flip_matrix (tbo_object *self, cairo_matrix_t *mx);
 void tbo_object_order_down (tbo_object *self);
 void tbo_object_order_up (tbo_object *self);
+void tbo_object_move (tbo_object *self, enum MOVE_OPT type);