Commit 1c7e9976 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*fixed incorrect sizing of an object that used to be valid with a number of...

*fixed incorrect sizing of an object that used to be valid with a number of connections greater than the new, invalid object name (including empty object) that happens upon retexting the object, as well as during undo and redo.
parent e5207f8d
......@@ -6385,11 +6385,17 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
/* if object creation failed, make dummy inlets or outlets
as needed */
if (pd_class(&src->g_pd) == text_class && objsrc->te_type == T_OBJECT)
{
while (outno >= obj_noutlets(objsrc))
outlet_new(objsrc, 0);
//fprintf(stderr,"canvas_connect got fake outlets\n");
}
if (pd_class(&sink->g_pd) == text_class && objsink->te_type == T_OBJECT)
{
while (inno >= obj_ninlets(objsink))
inlet_new(objsink, &objsink->ob_pd, 0, 0);
//fprintf(stderr,"canvas_connect got fake inlets\n");
}
if (!canvas_isconnected(x, objsrc, outno, objsink, inno))
{
......
......@@ -181,8 +181,8 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix,
if (!x)
{
/* LATER make the color reflect this */
//fprintf(stderr,"creating blank object\n");
x = (t_text *)pd_new(text_class);
//fprintf(stderr,"creating blank object %lx\n", x);
}
/* special case: an object, like preset_hub, hides its arguments
beyond the first n, so we modify its binbuf here */
......@@ -1407,6 +1407,15 @@ static void text_getrect(t_gobj *z, t_glist *glist,
int no = obj_noutlets(ob);
int ni = obj_ninlets(ob);
/*
// debug chunk
char *bufdbg;
int bufsizedbg;
if (y) rtext_gettext(y, &bufdbg, &bufsizedbg);
if (!strncmp(bufdbg, "gate", 4) || strlen(bufdbg) == 0)
fprintf(stderr,"text_getrect nlets %d %d <%s>\n", ni, no, ( y ? bufdbg : "null" ));
*/
int m = ( ni > no ? ni : no);
//let's see if the object has more nlets than
//its text width and resize them accordingly
......@@ -1996,6 +2005,8 @@ void glist_drawiofor_withtag(t_glist *glist, t_object *ob, int firsttime,
void text_drawborder(t_text *x, t_glist *glist,
char *tag, int width2, int height2, int firsttime)
{
//fprintf(stderr,"text_drawborder\n");
t_object *ob;
int x1, y1, x2, y2;
......@@ -2205,7 +2216,7 @@ void text_drawborder_withtag(t_text *x, t_glist *glist,
x2, y2, x1, y2, x1, y1,
tag, tag);
}
/* for comments, just draw a bar on RHS if unlocked; when a visible
/* for comments, draw a dotted box; when a visible
canvas is unlocked we have to call this anew on all comments, and when
locked we erase them all via the annoying "commentbar" tag. */
else if (x->te_type == T_TEXT && glist->gl_edit)
......@@ -2277,6 +2288,23 @@ static int compare_subpatch_selectors(t_atom *a, t_atom *b)
return 0;
}
void text_checkvalidwidth(t_glist *glist)
{
// readjust border in case the new object is invalid and it has more connections
// than what the default width allows (this typically happens when there is a valid
// object that has been replaced by an invalid one and during recreation the new
// object has 0 inlets and outlets and is therefore unaware of its possibly greater
// width)
t_gobj *yg = glist->gl_list;
while (yg->g_next)
yg = yg->g_next;
t_text *newest_t = (t_text *)yg;
//fprintf(stderr, "newest object text class is %lx\n", newest_t);
t_rtext *yn = glist_findrtext(glist, newest_t);
if (yn && pd_class(&newest_t->te_pd) == text_class && newest_t->te_type != T_TEXT)
text_drawborder(newest_t, glist, rtext_gettag(yn), rtext_width(yn), rtext_height(yn), 0);
}
/* change text; if T_OBJECT, remake it. */
void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
......@@ -2354,6 +2382,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
canvas_restoreconnections(glist_getcanvas(glist));
//canvas_apply_restore_original_position(glist_getcanvas(glist),
// pos);
text_checkvalidwidth(glist);
}
else
{
......
......@@ -10,6 +10,8 @@ int we_are_undoing = 0;
extern const char *canvas_undo_name;
extern void glob_preset_node_list_seek_hub(void);
extern void glob_preset_node_list_check_loc_and_update(void);
extern void text_checkvalidwidth(t_glist *glist);
t_undo_action *canvas_undo_init(t_canvas *x)
{
......@@ -94,6 +96,7 @@ void canvas_undo_undo(t_canvas *x)
{
sys_vgui("pdtk_undomenu .x%lx %s %s\n",
x, undo_action, redo_action);
text_checkvalidwidth(x);
canvas_getscroll(x);
}
canvas_dirty(x, 1);
......@@ -139,6 +142,7 @@ void canvas_undo_redo(t_canvas *x)
{
sys_vgui("pdtk_undomenu .x%lx %s %s\n",
x, undo_action, redo_action);
text_checkvalidwidth(x);
canvas_getscroll(x);
}
canvas_dirty(x, 1);
......
Markdown is supported
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