[dia] Bug 434388 - mouse cursor differentiation between create and modify



commit 24feeaac0d9cb7e906f734bea1b7593acca8e8c9
Author: Hans Breuer <hans breuer org>
Date:   Fri Jul 8 19:18:20 2011 +0200

    Bug 434388 - mouse cursor differentiation between create and modify
    
    The create cursor is rather simple, i.e. not object specific.
    Additionally there are hovering resize cursors, but only if the
    handle is properly advertizing it's direction.

 app/Makefile.am                    |    2 ++
 app/create_object.c                |    2 ++
 app/cursor.c                       |   32 ++++++++++++++++++++++++--------
 app/cursor.h                       |    3 +++
 app/modify_tool.c                  |   19 +++++++++++++++----
 app/pixmaps/cursor-create-data.xbm |    8 ++++++++
 app/pixmaps/cursor-create-mask.xbm |    8 ++++++++
 app/pixmaps/cursor-create.png      |  Bin 0 -> 463 bytes
 8 files changed, 62 insertions(+), 12 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index bbd07cd..3e71260 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -232,6 +232,8 @@ EXTRA_DIST = \
 	pixmaps/portrait.xpm \
 	pixmaps/landscape.xpm \
 	\
+	pixmaps/cursor-create-data.xbm \
+	pixmaps/cursor-create-mask.xbm \
 	pixmaps/hand-open-data.xbm \
 	pixmaps/hand-open-mask.xbm \
 	pixmaps/hand-closed-data.xbm \
diff --git a/app/create_object.c b/app/create_object.c
index 7cb1654..6ae66d7 100644
--- a/app/create_object.c
+++ b/app/create_object.c
@@ -293,6 +293,8 @@ create_create_object_tool(DiaObjectType *objtype, void *user_data,
   tool->user_data = user_data;
   tool->moving = FALSE;
   tool->invert_persistence = invert_persistence;
+
+  ddisplay_set_all_cursor(get_cursor(CURSOR_CREATE));
   
   return (Tool *) tool;
 }
diff --git a/app/cursor.c b/app/cursor.c
index 89dbc19..90fb174 100644
--- a/app/cursor.c
+++ b/app/cursor.c
@@ -33,6 +33,8 @@
 #include "pixmaps/magnify-plus-mask.xbm"
 #include "pixmaps/magnify-minus-data.xbm"
 #include "pixmaps/magnify-minus-mask.xbm"
+#include "pixmaps/cursor-create-data.xbm"
+#include "pixmaps/cursor-create-mask.xbm"
 
 static struct {
   /* Can't use a union because it can't be statically initialized
@@ -46,30 +48,44 @@ static struct {
   int hot_y;
   GdkCursor *cursor;
 } cursors[MAX_CURSORS] = {
-  { GDK_LEFT_PTR },
-  { GDK_FLEUR },
-  { DIA_CURSOR,
+  { GDK_LEFT_PTR }, /* CURSOR_POINT */
+  { DIA_CURSOR, /* CURSOR_CREATE */
+    cursor_create_data_bits,
+    cursor_create_data_width, cursor_create_data_height,
+    cursor_create_mask_bits,
+    0, 0},  
+  { GDK_FLEUR }, /* CURSOR_SCROLL */
+  { DIA_CURSOR, /* CURSOR_GRAB */
     hand_open_data_bits,
     hand_open_data_width, hand_open_data_height,
     hand_open_mask_bits,
     hand_open_data_width/2, hand_open_data_height/2},
-  { DIA_CURSOR, 
+  { DIA_CURSOR, /* CURSOR_GRABBING */
     hand_closed_data_bits,
     hand_closed_data_width, hand_closed_data_height,
     hand_closed_mask_bits,
     hand_closed_data_width/2, hand_closed_data_height/2},
-  { DIA_CURSOR,
+  { DIA_CURSOR, /* CURSOR_ZOOM_OUT */
     magnify_minus_data_bits,
     magnify_minus_data_width, magnify_minus_data_height,
     magnify_minus_mask_bits,
     magnify_minus_data_x_hot, magnify_minus_data_y_hot},
-  { DIA_CURSOR,
+  { DIA_CURSOR, /* CURSOR_ZOOM_IN */
     magnify_plus_data_bits,
     magnify_plus_data_width, magnify_plus_data_height,
     magnify_plus_mask_bits,
     magnify_plus_data_x_hot, magnify_plus_data_y_hot},
-  { GDK_CROSS_REVERSE },
-  { GDK_XTERM },
+  { GDK_CROSS_REVERSE }, /* CURSOR_CONNECT */
+  { GDK_XTERM }, /* CURSOR_XTERM */
+  /* for safety reasons these should be last and must be in the same order HANDLE_RESIZE_* */
+  { GDK_TOP_LEFT_CORNER },/* CURSOR_DIRECTION_0 + NW */
+  { GDK_TOP_SIDE },/* N */
+  { GDK_TOP_RIGHT_CORNER },/* NE */
+  { GDK_LEFT_SIDE },/* W */
+  { GDK_RIGHT_SIDE },/* E */
+  { GDK_BOTTOM_LEFT_CORNER },/* SE */
+  { GDK_BOTTOM_SIDE },/* S */
+  { GDK_BOTTOM_RIGHT_CORNER }, /* SW */
 };
 
 GdkCursor *
diff --git a/app/cursor.h b/app/cursor.h
index c18c567..0cf4e0d 100644
--- a/app/cursor.h
+++ b/app/cursor.h
@@ -22,6 +22,7 @@
 
 typedef enum {
   CURSOR_POINT,
+  CURSOR_CREATE,
   CURSOR_SCROLL,
   CURSOR_GRAB,
   CURSOR_GRABBING,
@@ -29,6 +30,8 @@ typedef enum {
   CURSOR_ZOOM_IN,
   CURSOR_CONNECT,
   CURSOR_XTERM,
+  CURSOR_DIRECTION_0, /* there are eight of them */
+  CURSOR_DIRECTION_7 = CURSOR_DIRECTION_0 + 7,
   MAX_CURSORS
 } DiaCursorType;
 
diff --git a/app/modify_tool.c b/app/modify_tool.c
index 8ffd0c0..ad14736 100644
--- a/app/modify_tool.c
+++ b/app/modify_tool.c
@@ -398,13 +398,24 @@ modify_motion(ModifyTool *tool, GdkEventMotion *event,
   ConnectionPoint *connectionpoint = NULL;
   ObjectChange *objchange = NULL;
 
-  if (tool->state==STATE_NONE)
-    return; /* Fast path... */
+  ddisplay_untransform_coords(ddisp, event->x, event->y, &to.x, &to.y);
 
+  if (tool->state==STATE_NONE) {
+    DiaObject *obj = NULL;
+    Handle *handle = NULL;
+    real dist;
+    dist = diagram_find_closest_handle (ddisp->diagram, &handle, &obj, &to);
+    if  (handle && handle->type != HANDLE_NON_MOVABLE
+      && handle->id >= HANDLE_RESIZE_NW && handle->id <= HANDLE_RESIZE_SE
+      && handle_is_clicked(ddisp, handle, &to)
+      && g_list_length (ddisp->diagram->data->selected) == 1)
+      ddisplay_set_all_cursor(get_cursor(CURSOR_DIRECTION_0 + handle->id));
+    else
+      ddisplay_set_all_cursor(get_cursor(CURSOR_POINT));
+    return; /* Fast path... */
+  }
   auto_scroll = ddisplay_autoscroll(ddisp, event->x, event->y);
   
-  ddisplay_untransform_coords(ddisp, event->x, event->y, &to.x, &to.y);
-
   if (!modify_move_already(tool, ddisp, &to)) return;
 
   switch (tool->state) {
diff --git a/app/pixmaps/cursor-create-data.xbm b/app/pixmaps/cursor-create-data.xbm
new file mode 100644
index 0000000..e79d33b
--- /dev/null
+++ b/app/pixmaps/cursor-create-data.xbm
@@ -0,0 +1,8 @@
+#define cursor_create_data_width 20
+#define cursor_create_data_height 20
+static unsigned char cursor_create_data_bits[] = {
+   0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x09, 0x00, 0x00,
+   0x11, 0x00, 0x00, 0x21, 0x00, 0x00, 0x41, 0x00, 0x00, 0x81, 0x00, 0x00,
+   0x01, 0x01, 0x00, 0x01, 0x02, 0x00, 0xc1, 0x07, 0x00, 0x49, 0x00, 0x00,
+   0x95, 0xf0, 0x07, 0x93, 0x10, 0x04, 0x21, 0x91, 0x04, 0x20, 0xd1, 0x05,
+   0x40, 0x92, 0x04, 0x40, 0x12, 0x04, 0x80, 0xf1, 0x07, 0x00, 0x00, 0x00 };
diff --git a/app/pixmaps/cursor-create-mask.xbm b/app/pixmaps/cursor-create-mask.xbm
new file mode 100644
index 0000000..a1b99df
--- /dev/null
+++ b/app/pixmaps/cursor-create-mask.xbm
@@ -0,0 +1,8 @@
+#define cursor_create_mask_width 20
+#define cursor_create_mask_height 20
+static unsigned char cursor_create_mask_bits[] = {
+   0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x0f, 0x00, 0x00,
+   0x1f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00,
+   0xff, 0x01, 0x00, 0xff, 0x03, 0x00, 0xff, 0x07, 0x00, 0x7f, 0x00, 0x00,
+   0xf7, 0xf0, 0x07, 0xf3, 0xf0, 0x07, 0xe1, 0xf1, 0x07, 0xe0, 0xf1, 0x07,
+   0xc0, 0xf3, 0x07, 0xc0, 0xf3, 0x07, 0x80, 0xf1, 0x07, 0x00, 0x00, 0x00 };
diff --git a/app/pixmaps/cursor-create.png b/app/pixmaps/cursor-create.png
new file mode 100644
index 0000000..b9738c3
Binary files /dev/null and b/app/pixmaps/cursor-create.png differ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]