X-Git-Url: https://git.blender.org/gitweb/gitweb.cgi/blender.git/blobdiff_plain/623421d580277f6e1f5404c019d4f807cf1645e9..43b26b72ab0df5ff8bbdb7e30c761099b95385a6:/source/blender/editors/space_outliner/space_outliner.c diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 008cf9bc044..8903f26cf3e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -107,17 +107,19 @@ void UI_table_free(uiTable *table) void UI_table_draw(wmWindow *window, ARegion *region, uiTable *table) { uiBlock *block; + View2D *v2d; rcti *rct, cellrct; int y, row, col; - + + v2d= ®ion->v2d; rct= &table->rct; - + block= uiBeginBlock(window, region, "table outliner", UI_EMBOSST, UI_HELV); - + for(y=rct->ymax, row=0; y>rct->ymin; y-=ROW_HEIGHT, row++) { if(row%2 == 0) { UI_ThemeColorShade(TH_BACK, 6); - glRecti(rct->xmin, y-ROW_HEIGHT, rct->xmax, y); + glRecti(v2d->cur.xmin, y-ROW_HEIGHT, v2d->cur.xmax, y); } if(row >= table->rows) @@ -153,7 +155,6 @@ typedef struct CellRNA { int lastrow, index; CollectionPropertyIterator iter; - PropertyRNA *iterprop; } CellRNA; static void rna_back_cb(void *arg_buts, void *arg_unused) @@ -186,20 +187,23 @@ static void rna_label(CellRNA *cell, rcti *rct, uiBlock *block) PropertyType type; PropertyRNA *prop; char *vectoritem[4]= {"x", "y", "z", "w"}; + char *quatitem[4]= {"w", "x", "y", "z"}; char *coloritem[4]= {"r", "g", "b", "a"}; char item[32]; int arraylength; prop= cell->prop; - type= RNA_property_type(prop, &cell->ptr); - subtype= RNA_property_subtype(prop, &cell->ptr); - arraylength= RNA_property_array_length(prop, &cell->ptr); + type= RNA_property_type(&cell->ptr, prop); + subtype= RNA_property_subtype(&cell->ptr, prop); + arraylength= RNA_property_array_length(&cell->ptr, prop); if(cell->index == -1) { - uiDefBut(block, LABEL, 0, (char*)RNA_property_ui_name(prop, &cell->ptr), rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin, 0, 0, 0, 0, 0, (char*)RNA_property_ui_description(prop, &cell->ptr)); + uiDefBut(block, LABEL, 0, (char*)RNA_property_ui_name(&cell->ptr, prop), rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin, 0, 0, 0, 0, 0, (char*)RNA_property_ui_description(&cell->ptr, prop)); } else if (type != PROP_COLLECTION) { - if(arraylength <= 4 && (subtype == PROP_VECTOR || subtype == PROP_ROTATION)) + if(arraylength == 4 && subtype == PROP_ROTATION) + sprintf(item, " %s", quatitem[cell->index]); + else if(arraylength <= 4 && (subtype == PROP_VECTOR || subtype == PROP_ROTATION)) sprintf(item, " %s", vectoritem[cell->index]); else if(arraylength <= 4 && subtype == PROP_COLOR) sprintf(item, " %s", coloritem[cell->index]); @@ -217,13 +221,13 @@ static void rna_collection_but(CellRNA *cell, rcti *rct, uiBlock *block) PropertyRNA *nameprop; char name[256]= "", *nameptr= name; - RNA_property_collection_lookup_int(cell->prop, &cell->ptr, cell->index, &lookup); + RNA_property_collection_lookup_int(&cell->ptr, cell->prop, cell->index, &lookup); if(lookup.data) { nameprop= RNA_struct_name_property(&lookup); if(nameprop) - nameptr= RNA_property_string_get_alloc(nameprop, &lookup, name, sizeof(name)); + nameptr= RNA_property_string_get_alloc(&lookup, nameprop, name, sizeof(name)); else sprintf(nameptr, "%d", cell->index+1); } @@ -245,8 +249,8 @@ static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block) int arraylength, index; prop= cell->prop; - type= RNA_property_type(prop, &cell->ptr); - arraylength= RNA_property_array_length(prop, &cell->ptr); + type= RNA_property_type(&cell->ptr, prop); + arraylength= RNA_property_array_length(&cell->ptr, prop); if(type == PROP_COLLECTION) { /* item in a collection */ @@ -294,17 +298,17 @@ static void rna_table_cell_func(void *userdata, int row, int col, rcti *rct, uiB if(cell->prop) { cell->index++; - type= RNA_property_type(cell->prop, &cell->ptr); + type= RNA_property_type(&cell->ptr, cell->prop); if(type == PROP_COLLECTION) - length= RNA_property_collection_length(cell->prop, &cell->ptr); + length= RNA_property_collection_length(&cell->ptr, cell->prop); else - length= RNA_property_array_length(cell->prop, &cell->ptr); + length= RNA_property_array_length(&cell->ptr, cell->prop); /* verify if we need to go to the next property */ if(type == PROP_COLLECTION && cell->index < length); else if(length && cell->index < length); else { - RNA_property_collection_next(cell->iterprop, &cell->iter); + RNA_property_collection_next(&cell->iter); cell->prop= cell->iter.ptr.data; cell->index= -1; } @@ -330,29 +334,26 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) uiTable *table; rcti rct; CellRNA cell; - PropertyRNA *prop; + PropertyRNA *prop, *iterprop; PointerRNA newptr; float col[3]; - int rows, cols, width, height; + int rows, cols, awidth, aheight, width, height; SpaceOops *soutliner= C->area->spacedata.first; + View2D *v2d= &ar->v2d; /* clear */ UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - width= ar->winrct.xmax - ar->winrct.xmin; - height= ar->winrct.ymax - ar->winrct.ymin; + // XXX width should be depend on max length of items (like height)... + awidth= width= ar->winrct.xmax - ar->winrct.xmin; + aheight= height= ar->winrct.ymax - ar->winrct.ymin; /* create table */ - rct.xmin= 0; - rct.ymin= 0; - rct.xmax= width; - rct.ymax= height; - cell.space= soutliner; cell.lastrow= -1; - RNA_pointer_main_get(G.main, &cell.ptr); + RNA_main_pointer_create(G.main, &cell.ptr); cell.prop= NULL; /* solve RNA path or reset if fails */ @@ -375,25 +376,43 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) rows= 1; cols= 2; - cell.iterprop= RNA_struct_iterator_property(&cell.ptr); - RNA_property_collection_begin(cell.iterprop, &cell.iter, &cell.ptr); + iterprop= RNA_struct_iterator_property(&cell.ptr); + RNA_property_collection_begin(&cell.ptr, iterprop, &cell.iter); - for(; cell.iter.valid; RNA_property_collection_next(cell.iterprop, &cell.iter)) { + for(; cell.iter.valid; RNA_property_collection_next(&cell.iter)) { prop= cell.iter.ptr.data; - rows += 1 + RNA_property_array_length(prop, &cell.ptr); - if(RNA_property_type(prop, &cell.ptr) == PROP_COLLECTION) - rows += RNA_property_collection_length(prop, &cell.ptr); + rows += 1 + RNA_property_array_length(&cell.ptr, prop); + if(RNA_property_type(&cell.ptr, prop) == PROP_COLLECTION) + rows += RNA_property_collection_length(&cell.ptr, prop); } - RNA_property_collection_end(cell.iterprop, &cell.iter); + RNA_property_collection_end(&cell.iter); + if ((rows*ROW_HEIGHT) > height) + height= rows * ROW_HEIGHT; + + /* need to validate view2d after updating size of tot */ + v2d->tot.xmin= 0; + v2d->tot.xmax= width; + v2d->tot.ymax= 0; + v2d->tot.ymin= -height; + UI_view2d_enforce_status(v2d, awidth, aheight); + + rct.xmin= 0; + rct.ymin= -height; + rct.xmax= width; + rct.ymax= 0; + + /* set matrix for 2d-view controls */ + UI_view2d_ortho(C, v2d); + /* create and draw table */ table= UI_table_create(rows, 2, &rct, rna_table_cell_func, &cell); - RNA_property_collection_begin(cell.iterprop, &cell.iter, &cell.ptr); + RNA_property_collection_begin(&cell.ptr, iterprop, &cell.iter); UI_table_draw(C->window, ar, table); - RNA_property_collection_end(cell.iterprop, &cell.iter); + RNA_property_collection_end(&cell.iter); UI_table_free(table); } @@ -480,6 +499,7 @@ static void outliner_init(wmWindowManager *wm, ScrArea *sa) ar->type= &mainart; WM_event_add_keymap_handler(&ar->handlers, &wm->uikeymap); + WM_event_add_keymap_handler(&ar->handlers, &wm->view2dkeymap); } else if(ar->regiontype == RGN_TYPE_HEADER) { static ARegionType headerart={NULL, NULL, NULL, NULL, NULL}; @@ -490,6 +510,7 @@ static void outliner_init(wmWindowManager *wm, ScrArea *sa) ar->type= &headerart; WM_event_add_keymap_handler(&ar->handlers, &wm->uikeymap); + WM_event_add_keymap_handler(&ar->handlers, &wm->view2dkeymap); } else { static ARegionType headerart={NULL, NULL, NULL, NULL, NULL}; @@ -508,6 +529,9 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) { SpaceOops *soutliner= (SpaceOops *)sl; SpaceOops *soutlinern= MEM_dupallocN(soutliner); + + if(soutlinern->rnapath) + soutlinern->rnapath= MEM_dupallocN(soutlinern->rnapath); return (SpaceLink *)soutlinern; }