Exemplo n.º 1
0
static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceOops *so= CTX_wm_space_outliner(C);
	Scene *scene= CTX_data_scene(C);
	ARegion *ar= CTX_wm_region(C);
	View2D *v2d= &ar->v2d;
	
	TreeElement *te;
	int xdelta, ytop;
	
	// TODO: make this get this info from context instead...
	if (OBACT == NULL) 
		return OPERATOR_CANCELLED;
	
	te= outliner_find_id(so, &so->tree, (ID *)OBACT);
	if (te) {
		/* make te->ys center of view */
		ytop= (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin)/2);
		if (ytop>0) ytop= 0;
		
		v2d->cur.ymax= (float)ytop;
		v2d->cur.ymin= (float)(ytop-(v2d->mask.ymax - v2d->mask.ymin));
		
		/* make te->xs ==> te->xend center of view */
		xdelta = (int)(te->xs - v2d->cur.xmin);
		v2d->cur.xmin += xdelta;
		v2d->cur.xmax += xdelta;
		
		so->storeflag |= SO_TREESTORE_REDRAW;
	}
	
	ED_region_tag_redraw(ar);
	
	return OPERATOR_FINISHED;
}
Exemplo n.º 2
0
/* Find treestore that refers to given ID */
TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
{
	TreeElement *te, *tes;
	TreeStoreElem *tselem;
	
	for (te = lb->first; te; te = te->next) {
		tselem = TREESTORE(te);
		if (tselem->type == 0) {
			if (tselem->id == id) return te;
			/* only deeper on scene or object */
			if (te->idcode == ID_OB || te->idcode == ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode == ID_GR)) {
				tes = outliner_find_id(soops, &te->subtree, id);
				if (tes) return tes;
			}
		}
	}
	return NULL;
}