Commit 2e4940ea authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Fixed regression in toggling subpatch gop redrect

* It is supposed to toggle on and off depending on whether the subpatch has scalars only in it. It does this by also intelligently accounting for temporary text objects that are created and need to be filled by the scalar name before they are converted into a scalar class.

* There is one condition the original implementation failed to account for: creating a new text_object in an empty canvas which erroneously still resulted in the assumption that the subpatch consisted of only scalars.

* This patch fixes this special case.

* To test: create an empty subpatch and enable GOP, inside the subpatch create an empty object which will erase GOP until you make that object something concrete (e.g. print). With the patch, the GOP redrect will never dissappear (and it shouldn't).
parent 4d38f271
Pipeline #2984 failed with stage
in 232 minutes and 22 seconds
......@@ -64,17 +64,18 @@ extern t_canvas *canvas_templatecanvas_forgroup(t_canvas *c);
/* ico@vt.edu 2020-08-24:
check if canvas consists of only scalars and returns 2. if the canvas only
has the last object as a non-scalar (e.g. a new object has just been created,
then we return 1, otherwise return 0. this is used to prevent creation of new
objects in an GOP window that only has scalars inside it or scalars with one
newly created object that is yet to be typed into and therefore properly
instantiated */
then we return 1, otherwise return 0. this is used to determine whether the
GOP redrect should be drawn inside the GOP-enabled toplevel window, depending
whether it only has scalars inside it or scalars with one newly created object
that is yet to be typed into and therefore properly instantiated */
int canvas_has_scalars_only(t_canvas *x)
{
t_gobj *g = x->gl_list;
int hasonlyscalars = 2;
int hasonlyscalars = 0;
while (g)
{
//post("g...");
hasonlyscalars = 2;
if (pd_class(&g->g_pd) != scalar_class)
{
/*
......@@ -85,17 +86,20 @@ int canvas_has_scalars_only(t_canvas *x)
/* ico@vt.edu 2020-08-24:
if we have one more object or the last object is not newly
instantiated text object
to distinguish between a comment and a text object that is
yet to be instantiated we use:
instantiated text object to distinguish between a comment and
a text object that is yet to be instantiated we use:
1) comment is text_class and its te_type is T_TEXT
2) blank object one is typing into is text_class but is NOT T_TEXT
3) instantiated object is something other than text_class (unless)
it is a comment
3) instantiated object is something other than text_class (unless
it is a comment)
4) object that has failed to create is same as blank object
*/
if (g->g_next || (pd_class(&g->g_pd) != text_class || ((t_text *)g)->te_type == T_TEXT))
hasonlyscalars = 0;
// check if we are not the only object on the canvas, in which case we should still
// return 0 since we have no scalars inside the canvas
else if (g == x->gl_list && !g->g_next)
hasonlyscalars = 0;
else
hasonlyscalars = 1;
break;
......@@ -103,7 +107,6 @@ int canvas_has_scalars_only(t_canvas *x)
//post("...scalar, comment, or uninitialized object=yes");
g = g->g_next;
}
//post("has scalars only=%d", hasonlyscalars);
return(hasonlyscalars);
}
......@@ -128,7 +131,7 @@ void glist_update_redrect(t_glist *x)
}
else if (canvas_has_scalars_only(x) && x->gl_goprect)
{
x->gl_goprect = 0;
x->gl_goprect = 0;
canvas_drawredrect(x, 0);
}
}
......
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