Commit ebd8cf8a authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Cleaned-up gatom behavior

* gatom due to its reliance on the "click" legacy message lacks adequate information to allow for some of the advanced functionality of the iemgui numbox. This, coupled with other legacy behavior (e.g. having a min and max that does not apply to the values coming into its inlet) in my view make vanilla gatom a legacy object. This also makes a distinguishing factor between it and the iemgui numbox.

* Nonetheless, new features persist, such as drag and shift+drag that offers +-1 and +-0.01 increments respectively inside the number gatom, the ability to append to the symbol gatom text by shift+clicking onto it, and shift+delete deletes all the text at once inside the gatom symbol.
parent 3b43f5db
......@@ -877,7 +877,7 @@ typedef struct _gatom
t_symbol *a_symfrom; /* "receive" name -- bind ourselvs to this */
t_symbol *a_symto; /* "send" name -- send to this on output */
char a_buf[ATOMBUFSIZE]; /* string buffer for typing */
char a_shift; /* was shift key down when dragging started? */
int a_shift; /* was shift key down when dragging started? */
char a_wherelabel; /* 0-3 for left, right, above, below */
t_symbol *a_expanded_to; /* a_symto after $0, $1, ... expansion */
int a_shift_clicked; /* used to keep old text after \n. this is
......@@ -1112,7 +1112,8 @@ static void gatom_key(void *z, t_floatarg f)
t_gatom *x = (t_gatom *)z;
int c = f;
//post("gatom_key <%c> %d", c, x->a_shift);
//post("gatom_key %f shift=%d strlen=%d <%s>", \
f, x->a_shift, strlen(x->a_buf), x->a_buf);
int len = strlen(x->a_buf);
t_atom at;
char sbuf[ATOMBUFSIZE + 4];
......@@ -1120,7 +1121,7 @@ static void gatom_key(void *z, t_floatarg f)
// we're being notified that no more keys will come for this grab
//post("gatom_key end <%s> <%s>", x->a_buf, x->a_atom.a_w.w_symbol->s_name);
pd_unbind(&x->a_text.ob_pd, gensym("#keyname_a"));
//pd_unbind(&x->a_text.ob_pd, gensym("#keyname_a"));
//post("unbind <%s>", x->a_buf);
if (x->a_atom.a_type == A_FLOAT)
......@@ -1233,8 +1234,8 @@ static void gatom_click(t_gatom *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
t_floatarg alt)
//post("gatom_click %f %f", ctrl, alt);
pd_bind(&x->a_text.ob_pd, gensym("#keyname_a"));
//post("gatom_click shift=%f ctrl=%f alt=%f", shift, ctrl, alt);
//pd_bind(&x->a_text.ob_pd, gensym("#keyname_a"));
if (x->a_text.te_width == 1)
......@@ -1255,17 +1256,24 @@ static void gatom_click(t_gatom *x,
gatom_retext(x, 0, 1);
x->a_shift = shift;
// LATER: consider difference between exclusive (typed) grab
// and a simple click'n'drag grab
x->a_shift = (int)shift;
// unlike iemgui numbox, here we are unable to distinguish
// between the exclusive and non-exclusive focus because
// the old school "click" message passed to the object does
// not provide additional necessary info, such as doubleclick
// (which we use to differentiate between the genuine mouseup
// events and those generated by the mouse motion), and doit
// (which differentiates the button press or 1 from the aforesaid
// two events). Long story short, we do not seek exclusive focus
// with the vanilla gatom.
glist_grab(x->a_glist, &x->a_text.te_g, gatom_motion, gatom_key,
gatom_list, xpos, ypos, 1);
gatom_list, xpos, ypos, 0);
//post("a_shift_clicked=%d", x->a_shift_clicked);
x->a_shift_clicked = shift;
x->a_shift_clicked = x->a_shift;
// second click wipes prior text
if (!x->a_shift_clicked)
x->a_buf[0] = 0;
//post("a_shift_clicked=%d", x->a_shift_clicked);
//post("a_shift_clicked=%d <%s>", x->a_shift_clicked, x->a_buf);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment