aboutsummaryrefslogtreecommitdiff
path: root/cursor.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-06 02:30:53 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-06 02:30:53 +0000
commit61e356e0b1d0935c5fbe042868bc82e5e33ad873 (patch)
tree365cca6a80e2447bae8383d91a6f04ed7f7fee84 /cursor.c
parent1506fc56c521e5e01c48bf6c76a76e813d5cc985 (diff)
- updated to work with set_cursors_in_tcl-0.41-test06.patch (patch #1826507),
now you can actually set the cursors and have them stick throughout Pd svn path=/trunk/externals/hcs/; revision=8942
Diffstat (limited to 'cursor.c')
-rw-r--r--cursor.c38
1 files changed, 24 insertions, 14 deletions
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);
}