int has_subtree(struct node *n1,struct node *n2){ if(n2==NULL||n1==NULL) return 0; if(n1->value==n2->value){ return same(n1,n2); }else{ struct node *n1l=n1->left; struct node *n1r=n1->right; int lr=has_subtree(n1l,n2); int rr=has_subtree(n1r,n2); return lr||rr; } }
bool has_player (path ip) { path p= reverse (ip); if (!has_subtree (the_et, p)) return false; tree t= subtree (the_et, p); blackbox bb; return t->obs->get_contents (ADDENDUM_PLAYER, bb); }
player get_player (path ip) { path p= reverse (ip); if (has_subtree (the_et, p)) { tree t= subtree (the_et, p); blackbox bb; bool ok= t->obs->get_contents (ADDENDUM_PLAYER, bb); if (ok) return open_box<player> (bb); } return player (); }
path search_animation_ip (path ip) { if (is_nil (ip)) return ip; path p= reverse (ip); if (has_subtree (the_et, p)) { tree t= subtree (the_et, p); blackbox bb; bool ok= t->obs->get_contents (ADDENDUM_PLAYER, bb); if (ok) return ip; } return search_animation_ip (ip->next); }
bool admissible_selection (gr_selection sel) { if (sel->type != "box" || N(sel->cp) != 1) return true; if (last_item (sel->cp[0]) < 0 || N(sel->cp[0]) <= 2) return true; path p= path_up (sel->cp[0]); if (!has_subtree (the_et, p)) return true; tree st= subtree (the_et, p); if (is_compound (st, "anim-edit")) return false; tree pt= subtree (the_et, path_up (p)); if (is_func (st, WITH) && is_compound (pt, "anim-edit")) return false; return true; }
void concater_rep::typeset_anim_accelerate (tree t, path ip) { if (N(t) != 2) { typeset_error (t, ip); return; } path uip= undecorate (ip); while (!has_subtree (the_et, reverse (uip))) uip= uip->next; player apl= get_player (uip); if (!is_nil (uip) && !has_player (uip)) { path aip= search_animation_ip (uip); player pl = is_nil (aip)? player (): get_player (aip); apl= accelerate (pl, t[1]); tree st= subtree (the_et, reverse (uip)); blackbox bb= close_box<player> (apl); (void) tree_addendum_new (st, ADDENDUM_PLAYER, bb, false); } box b= typeset_as_concat (env, t[0], descend (ip, 0)); apl->set_duration (b->anim_duration ()); array<box> bs; bs << b; print (composite_box (ip, bs)); }
path search_longest_ip (path ip) { path p= reverse (ip); if (has_subtree (the_et, p)) return ip; return search_longest_ip (ip->next); }