Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
maccallum committed Aug 14, 2014
2 parents ebad735 + 7e60f17 commit dc60afa
Show file tree
Hide file tree
Showing 4 changed files with 1,086 additions and 366 deletions.
96 changes: 41 additions & 55 deletions src/o.compose/o.compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ enum {
#ifdef OMAX_PD_VERSION
typedef struct _ocompose {
t_object ob;
t_glist *glist; //the canvas heirarchy

t_opd_textbox *textbox;

long textlen;
Expand Down Expand Up @@ -185,7 +183,7 @@ void ocompose_int(t_ocompose *x, long n);
void ocompose_float(t_ocompose *x, double xx);
void ocompose_list(t_ocompose *x, t_symbol *msg, short argc, t_atom *argv);
void ocompose_anything(t_ocompose *x, t_symbol *msg, short argc, t_atom *argv);
void omax_util_outletOSC(void *outlet, long len, char *ptr);
//void omax_util_outletOSC(void *outlet, long len, char *ptr);
void ocompose_free(t_ocompose *x);
void ocompose_inletinfo(t_ocompose *x, void *b, long index, char *t);
void *ocompose_new(t_symbol *msg, short argc, t_atom *argv);
Expand Down Expand Up @@ -766,6 +764,7 @@ static void ocompose_getrect(t_gobj *z, t_glist *glist,int *xp1, int *yp1, int *
*xp2 = x2;
*yp2 = y2;
//post("%s %d %d %d %d", __func__, x1, y1, x2, y2);
opd_textbox_motion(x->textbox);

}

Expand Down Expand Up @@ -793,10 +792,8 @@ void ocompose_drawElements(t_object *ob, int firsttime)

int x1, y1, x2, y2;
ocompose_getrect((t_gobj *)x, t->glist, &x1, &y1, &x2, &y2);
int cx1 = x1;// - 2;
int cy1 = y1;// - 2;
int cx2 = x2;// + 2;
int cy2 = y2;// + 2;
int cx2 = x2 - t->margin_r;
int cy2 = y2 - 10; //<< folds into right margin

t_glist *glist = t->glist;
t_canvas *canvas = glist_getcanvas(glist);
Expand All @@ -810,30 +807,28 @@ void ocompose_drawElements(t_object *ob, int firsttime)

if (firsttime)
{
//post("%x %s FIRST VIS height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2);
// post("%x %s FIRST VIS height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2);

//border
sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline \"\" -fill \"\" -tags [list %s msg]\n",canvas, x1, y1, x2, y2, x->border_tag);

sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d %d %d -outline #0066CC -fill \"\" -tags %sBorder -width 2 \n",canvas, cx1, cy1, cx2, cy1, cx2, cy2-10, cx2-10, cy2-10, cx2-10, cy2, cx1, cy2, x->border_tag);
sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d %d %d -outline #0066CC -fill \"white\" -tags %s -width 2 \n",canvas, x1, y1, x2, y1, x2, cy2, cx2, cy2, cx2, cy2, x1, cy2, x->border_tag);

sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d -outline #0066CC -fill \"white\" -tags %s \n",canvas, cx2-10, cy2-10, cx2-10, cy2, cx2, cy2-10, x->corner_tag);
sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d -outline #0066CC -fill \"white\" -tags %s \n",canvas, cx2, cy2, cx2, y2, x2, cy2, x->corner_tag);

}
else
{
post("%x %s REDRAW height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2);
// post("%x %s REDRAW height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2);

sys_vgui(".x%lx.c coords %s %d %d %d %d\n", canvas, x->border_tag, x1, y1, x2, y2);
sys_vgui(".x%lx.c coords %sBorder %d %d %d %d %d %d %d %d %d %d %d %d \n",canvas, x->border_tag, cx1, cy1, cx2, cy1, cx2, cy2-10, cx2-10, cy2-10, cx2-10, cy2, cx1, cy2);
sys_vgui(".x%lx.c coords %s %d %d %d %d %d %d \n",canvas, x->corner_tag, cx2-10, cy2-10, cx2-10, cy2, cx2, cy2-10);
sys_vgui(".x%lx.c coords %s %d %d %d %d %d %d %d %d %d %d %d %d \n",canvas, x->border_tag, x1, y1, x2, y1, x2, cy2, cx2, cy2, cx2, y2, x1, y2);
sys_vgui(".x%lx.c coords %s %d %d %d %d %d %d \n",canvas, x->corner_tag, cx2, cy2, cx2, y2, x2, cy2);


}

opd_textbox_drawElements(x->textbox, x1, y1, x2, y2, firsttime);

//sys_vgui(".x%lx.c itemconfigure %sBorder -outline %s\n", canvas, x->border_tag, (x->parse_error? "red" : "#0066CC" ));
//sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->border_tag, (x->parse_error? "red" : "#0066CC" ));
//sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->corner_tag, (x->parse_error? "red" : "blue" ));

sys_vgui(".x%lx.c itemconfigure %s -fill %s \n", canvas, x->corner_tag, (x->draw_new_data_indicator? "#0066CC" : "white"));
Expand Down Expand Up @@ -866,31 +861,32 @@ static void ocompose_displace(t_gobj *z, t_glist *glist,int dx, int dy)
{

t_ocompose *x = (t_ocompose *)z;
x->ob.te_xpix += dx;
x->ob.te_ypix += dy;

t_canvas *canvas = glist_getcanvas(glist);

sys_vgui(".x%lx.c move %s %d %d\n", canvas, x->border_tag, dx, dy);
sys_vgui(".x%lx.c move %sBorder %d %d\n", canvas, x->border_tag, dx, dy);
sys_vgui(".x%lx.c move %s %d %d\n", canvas, x->corner_tag, dx, dy);
sys_vgui(".x%lx.c move text%lx %d %d\n", canvas, (long)x, dx, dy);

opd_textbox_displace(x->textbox, glist, dx, dy);

if(!x->textbox->mouseDown)
{
x->ob.te_xpix += dx;
x->ob.te_ypix += dy;

t_canvas *canvas = glist_getcanvas(glist);

sys_vgui(".x%lx.c move %s %d %d\n", canvas, x->border_tag, dx, dy);
sys_vgui(".x%lx.c move %s %d %d\n", canvas, x->corner_tag, dx, dy);

opd_textbox_displace(x->textbox, glist, dx, dy);
}
}

static void ocompose_select(t_gobj *z, t_glist *glist, int state)
{
post("%s %d", __func__, state);
//post("%s %d", __func__, state);
t_ocompose *x = (t_ocompose *)z;
t_canvas *canvas = glist_getcanvas(glist);

opd_textbox_select(x->textbox, glist, state);

if (glist_isvisible(glist) && gobj_shouldvis(&x->ob.te_g, glist)){

sys_vgui(".x%lx.c itemconfigure %sBorder -outline %s\n", canvas, x->border_tag, (state? "#006699" : "#0066CC"));
sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->border_tag, (state? "#006699" : "#0066CC"));
sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->corner_tag, (state? "#006699" : "#0066CC"));

sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, x->corner_tag, (x->draw_new_data_indicator? (state? "#006699" : "#0066CC") : "white"));
Expand All @@ -899,7 +895,7 @@ static void ocompose_select(t_gobj *z, t_glist *glist, int state)

static void ocompose_activate(t_gobj *z, t_glist *glist, int state)
{
post("%s %d", __func__, state);
//post("%s %d", __func__, state);

t_ocompose *x = (t_ocompose *)z;
t_canvas *canvas = glist_getcanvas(glist);
Expand All @@ -909,8 +905,7 @@ static void ocompose_activate(t_gobj *z, t_glist *glist, int state)

opd_textbox_activate(x->textbox, glist, state);

// sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", glist, x->border_tag, (state? "$select_color" : "$msg_box_fill"));//was "$box_outline"
sys_vgui(".x%lx.c itemconfigure %sBorder -outline %s\n", canvas, x->border_tag, (state? "#006699" : "#0066CC"));
sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->border_tag, (state? "#006699" : "#0066CC"));
sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->corner_tag, (state? "#006699" : "#0066CC"));

sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, x->corner_tag, (x->draw_new_data_indicator? (state? "#006699" : "#0066CC") : "white"));
Expand All @@ -919,7 +914,7 @@ static void ocompose_activate(t_gobj *z, t_glist *glist, int state)

static void ocompose_delete(t_gobj *z, t_glist *glist)
{
post("%s", __func__);
//post("%s", __func__);
t_ocompose *x = (t_ocompose *)z;
t_opd_textbox *t = x->textbox;
t_canvas *canvas = glist_getcanvas(glist);
Expand All @@ -931,7 +926,6 @@ static void ocompose_delete(t_gobj *z, t_glist *glist)
// opd_textbox_nofocus_callback(t);

sys_vgui(".x%lx.c delete %s\n", canvas, x->border_tag);
sys_vgui(".x%lx.c delete %sBorder\n", canvas, x->border_tag);
sys_vgui(".x%lx.c delete %s\n", canvas, x->corner_tag);

opd_textbox_delete(t, glist);
Expand Down Expand Up @@ -987,7 +981,7 @@ static void ocompose_save(t_gobj *z, t_binbuf *b)
{
t_ocompose *x = (t_ocompose *)z;
t_opd_textbox *t = x->textbox;
post("%x %s", x, __func__);
//post("%x %s", x, __func__);

opd_textbox_setHexFromText(t, t->text);

Expand Down Expand Up @@ -1024,7 +1018,7 @@ static void ocompose_save(t_gobj *z, t_binbuf *b)

void ocompose_free(t_ocompose *x)
{
post("%x %s", x, __func__);
//post("%x %s", x, __func__);
free(x->border_tag);
free(x->corner_tag);

Expand Down Expand Up @@ -1067,6 +1061,16 @@ void *ocompose_new(t_symbol *msg, short argc, t_atom *argv)
t->editmode = glist_getcanvas(t->glist)->gl_edit;
t->textediting = 0;

t->margin_t = 1;
t->margin_l = 1;
t->margin_b = 1;
t->margin_r = 10;

t->resizebox_x_offset = 2;
t->resizebox_y_offset = 2;
t->resizebox_height = 10;
t->resizebox_width = 10;

x->textbox = t;

// post("%s %p glist %x canvas %x\n", __func__, x, t->glist, glist_getcanvas(t->glist));
Expand All @@ -1090,10 +1094,8 @@ void *ocompose_new(t_symbol *msg, short argc, t_atom *argv)
x->have_new_data = 1;
x->draw_new_data_indicator = 0;


x->border_tag = NULL;
x->corner_tag = NULL;


//object name heirarchy:
char buf[MAXPDSTRING];
Expand All @@ -1116,24 +1118,8 @@ void *ocompose_new(t_symbol *msg, short argc, t_atom *argv)
}
strcpy(x->corner_tag, buf);

opd_textbox_atoms(t, argc, argv);

if(argc > 3)
{
t->width = atom_getfloat(argv);
t->height = atom_getfloat(argv+1);
if(((argv+2)->a_type == A_SYMBOL ) && (atom_getsymbol(argv+2) == gensym("binhex")))
{

opd_textbox_textbuf(t, NULL, argc-2, (argv+2));
t_atom done[2];
atom_setsym(done, gensym("binhex"));
atom_setsym(done+1, gensym(t->receive_name));
opd_textbox_textbuf(t, NULL, 2, done);

}
}

// post("%x %s height %d", x, __func__, x->height);
t->in_new_flag = 0;
t->softlock = 0;

Expand Down
Loading

0 comments on commit dc60afa

Please sign in to comment.