aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cursor-help.pd113
-rw-r--r--cursor.c38
2 files changed, 94 insertions, 57 deletions
diff --git a/cursor-help.pd b/cursor-help.pd
index 469280c..b5ecd81 100644
--- a/cursor-help.pd
+++ b/cursor-help.pd
@@ -1,45 +1,72 @@
-#N canvas 284 234 514 531 10;
-#X obj 151 126 symbol;
-#X msg 149 61 boat;
-#X msg 109 61 clock;
-#X msg 245 61 dot;
-#X msg 275 61 dotbox;
-#X msg 322 61 gumby;
-#X msg 365 61 gobbler;
-#X msg 366 130 pirate;
-#X msg 366 87 mouse;
-#X msg 366 109 target;
-#X msg 366 151 pencil;
-#X msg 184 61 coffee_mug;
-#X msg 151 151 cursor \$1;
-#X obj 51 334 pddp/print;
-#X obj 188 309 pddp/print;
-#X obj 147 250 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
+#N canvas 309 199 638 505 10;
+#X obj 136 401 pddp/print;
+#X obj 95 342 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
1;
-#X obj 126 278 cursor;
-#X msg 45 218 bang;
-#X obj 46 160 key;
-#X obj 45 185 select 32;
-#X text 163 247 poll the mouse pointer position;
-#X text 80 219 get the current mouse position;
-#X obj 111 367 print CURSOR;
-#X connect 0 0 12 0;
-#X connect 1 0 0 0;
-#X connect 2 0 0 0;
-#X connect 3 0 0 0;
-#X connect 4 0 0 0;
-#X connect 5 0 0 0;
-#X connect 6 0 0 0;
-#X connect 7 0 0 0;
-#X connect 8 0 0 0;
-#X connect 9 0 0 0;
-#X connect 10 0 0 0;
-#X connect 11 0 0 0;
-#X connect 12 0 16 0;
-#X connect 15 0 16 0;
-#X connect 16 0 13 0;
-#X connect 16 0 22 0;
-#X connect 16 1 14 0;
-#X connect 17 0 16 0;
-#X connect 18 0 19 0;
+#X obj 74 370 cursor;
+#X msg 70 318 bang;
+#X text 111 339 poll the mouse pointer position;
+#X text 101 318 get the current mouse position;
+#X obj 163 26 pddp/pddplink http://tcl.tk/man/tcl8.4/TkCmd/cursors.htm
+;
+#X text 48 9 Here's a complete list of the available cursors:;
+#X msg 169 229 runmode_clickme dot;
+#X msg 322 151 boat;
+#X msg 282 151 clock;
+#X msg 428 151 dot;
+#X msg 505 151 gumby;
+#X msg 548 151 gobbler;
+#X msg 357 151 coffee_mug;
+#X msg 458 151 pirate;
+#X msg 42 44 runmode_nothing;
+#N canvas 0 22 454 304 make 0;
+#X obj 95 9 inlet;
+#X obj 114 258 outlet;
+#X obj 116 168 pack symbol symbol;
+#X obj 221 147 symbol;
+#X obj 94 51 symbol;
+#X obj 329 19 inlet;
+#X obj 126 111 trigger bang anything;
+#X msg 116 192 set \$1 \$2;
+#X obj 115 220 trigger bang anything;
+#X connect 0 0 4 0;
+#X connect 2 0 7 0;
+#X connect 3 0 2 1;
+#X connect 4 0 2 0;
+#X connect 5 0 6 0;
+#X connect 6 0 2 0;
+#X connect 6 1 3 0;
+#X connect 7 0 8 0;
+#X connect 8 0 1 0;
+#X connect 8 1 1 0;
+#X restore 169 205 pd make message;
+#X msg 59 63 runmode_clickme;
+#X msg 75 82 runmode_thicken;
+#X msg 92 101 runmode_addpoint;
+#X obj 67 440 pddp/print;
+#X msg 110 120 editmode_nothing;
+#X msg 126 139 runmode_connect;
+#X msg 143 158 runmode_disconnect;
+#X text 201 81 <-- choose your cursor mode;
+#X text 312 128 now pick a cursor:;
+#X obj 169 266 cursor;
+#X text 295 229 <-- this is the actual message to send;
+#X connect 1 0 2 0;
+#X connect 2 0 21 0;
+#X connect 2 1 0 0;
+#X connect 3 0 2 0;
+#X connect 8 0 27 0;
+#X connect 9 0 17 1;
+#X connect 10 0 17 1;
+#X connect 11 0 17 1;
+#X connect 12 0 17 1;
+#X connect 13 0 17 1;
+#X connect 14 0 17 1;
+#X connect 15 0 17 1;
+#X connect 16 0 17 0;
+#X connect 17 0 8 0;
+#X connect 18 0 17 0;
#X connect 19 0 17 0;
+#X connect 20 0 17 0;
+#X connect 22 0 17 0;
+#X connect 23 0 17 0;
+#X connect 24 0 17 0;
diff --git a/cursor.c b/cursor.c
index cd323d6..3198fcd 100644
--- a/cursor.c
+++ b/cursor.c
@@ -14,7 +14,6 @@ typedef struct _cursor
{
t_object x_obj;
t_symbol *receive_symbol;
- t_symbol *current_cursor;
t_canvas *parent_canvas;
t_outlet *data_outlet;
t_outlet *status_outlet;
@@ -23,6 +22,12 @@ typedef struct _cursor
} t_cursor;
+static void cursor_setmethod(t_cursor *x, t_symbol *s, int argc, t_atom *argv)
+{
+ sys_vgui("set cursor_%s \"%s\"\n", s->s_name, atom_getsymbol(argv)->s_name);
+ canvas_setcursor(x->parent_canvas, 0); /* hack to refresh the cursor */
+}
+
static void cursor_bang(t_cursor *x)
{
sys_vgui("pd [concat %s motion [winfo pointerx .] [winfo pointery .] \\;]\n",
@@ -42,16 +47,6 @@ static void cursor_float(t_cursor *x, t_float f)
}
}
-static void cursor_cursor(t_cursor *x, t_symbol *s)
-{
- post("setting cursor: %s", s->s_name);
- x->current_cursor = s;
- post("set parent%lx [winfo parent .x%lx.c]; $parent%lx configure -cursor %s \n",
- x, x->parent_canvas, x, s->s_name);
- sys_vgui("set parent%lx [winfo parent .x%lx.c]; $parent%lx configure -cursor %s \n",
- x, x->parent_canvas, x, s->s_name);
-}
-
static void cursor_button_callback(t_cursor *x, t_float button, t_float state)
{
t_atom output_atoms[2];
@@ -81,9 +76,10 @@ static void cursor_wheel_callback(t_cursor *x, t_float f)
static void cursor_free(t_cursor *x)
{
pd_unbind(&x->x_obj.ob_pd, x->receive_symbol);
+ //TODO free the "bind all"
}
-static void *cursor_new(t_symbol *s, int argc, t_atom *argv)
+static void *cursor_new(t_symbol *s)
{
char buf[MAXPDSTRING];
t_cursor *x = (t_cursor *)pd_new(cursor_class);
@@ -119,12 +115,26 @@ void cursor_setup(void)
motion_symbol = gensym("motion");
wheel_symbol = gensym("wheel");
- class_addmethod(cursor_class, (t_method)cursor_cursor,
- gensym("cursor"), A_DEFSYMBOL, 0);
class_addmethod(cursor_class, (t_method)cursor_button_callback,
button_symbol, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(cursor_class, (t_method)cursor_motion_callback,
motion_symbol, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(cursor_class, (t_method)cursor_wheel_callback,
wheel_symbol, A_DEFFLOAT, 0);
+
+ /* methods for setting the cursor icon */
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("runmode_nothing"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("runmode_clickme"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("runmode_thicken"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("runmode_addpoint"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("editmode_nothing"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("editmode_connect"), A_GIMME, 0);
+ class_addmethod(cursor_class, (t_method)cursor_setmethod,
+ gensym("editmode_disconnect"), A_GIMME, 0);
}