diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-10-20 15:44:57 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-10-20 15:44:57 +0300 |
commit | e5916187e808c1c22229589d103f4de4d4411b5b (patch) | |
tree | d2424f858d51a976d21d2e9339f7d53aa9ddeee4 /source/blender/editors | |
parent | dcb56d79a87966d93fe0509e64ab51eb90c1d486 (diff) |
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index ac9e2e36ded..665ae88d833 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1318,7 +1318,16 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case ID_GR: tselem_draw_icon_uibut(&arg, ICON_GROUP); break; case ID_LI: - tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); break; + if (tselem->id->flag & LIB_MISSING) { + tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_BROKEN); + } + else if (((Library *)tselem->id)->parent) { + tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_INDIRECT); + } + else { + tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); + } + break; case ID_LS: tselem_draw_icon_uibut(&arg, ICON_LINE_DATA); break; case ID_GD: @@ -1553,10 +1562,15 @@ static void outliner_draw_tree_element( if (tselem->type == 0 && tselem->id->lib) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); - if (tselem->id->flag & LIB_INDIRECT) + if (tselem->id->flag & LIB_MISSING) { + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_BROKEN); + } + else if (tselem->id->flag & LIB_INDIRECT) { UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_INDIRECT); - else + } + else { UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT); + } glPixelTransferf(GL_ALPHA_SCALE, 1.0f); offsx += UI_UNIT_X; } |