Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c187
1 files changed, 109 insertions, 78 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 33c1a4da4c7..90ab4e05d44 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -76,12 +76,16 @@
#include "DNA_effect_types.h"
#include "DNA_brush_types.h"
#include "DNA_particle_types.h"
-#include "BKE_particle.h"
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
+#include "DNA_anim_types.h"
+#include "DNA_gpencil_types.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
-#include "BKE_bad_level_calls.h"
+#include "BKE_animsys.h"
+#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_global.h"
@@ -110,8 +114,8 @@
#include "BKE_effect.h"
#include "BKE_brush.h"
#include "BKE_idprop.h"
-
-#include "DNA_space_types.h"
+#include "BKE_particle.h"
+#include "BKE_gpencil.h"
#define MAX_IDPUP 60 /* was 24 */
@@ -138,6 +142,12 @@ void id_us_plus(ID *id)
}
}
+void id_us_min(ID *id)
+{
+ if(id)
+ id->us--;
+}
+
ListBase *wich_libbase(Main *mainlib, short type)
{
switch( type ) {
@@ -195,6 +205,10 @@ ListBase *wich_libbase(Main *mainlib, short type)
return &(mainlib->brush);
case ID_PA:
return &(mainlib->particle);
+ case ID_WM:
+ return &(mainlib->wm);
+ case ID_GD:
+ return &(mainlib->gpencil);
}
return 0;
}
@@ -229,6 +243,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
/* BACKWARDS! also watch order of free-ing! (mesh<->mat) */
lb[a++]= &(main->ipo);
+ lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
lb[a++]= &(main->key);
lb[a++]= &(main->nodetree);
lb[a++]= &(main->image);
@@ -241,7 +256,6 @@ int set_listbasepointers(Main *main, ListBase **lb)
*/
lb[a++]= &(main->armature);
- lb[a++]= &(main->action);
lb[a++]= &(main->mesh);
lb[a++]= &(main->curve);
@@ -264,6 +278,8 @@ int set_listbasepointers(Main *main, ListBase **lb)
lb[a++]= &(main->object);
lb[a++]= &(main->scene);
lb[a++]= &(main->library);
+ lb[a++]= &(main->wm);
+ lb[a++]= &(main->gpencil);
lb[a]= NULL;
@@ -343,7 +359,7 @@ static ID *alloc_libblock_notest(short type)
id= MEM_callocN(sizeof(Text), "text");
break;
case ID_SCRIPT:
- id= MEM_callocN(sizeof(Script), "script");
+ //XXX id= MEM_callocN(sizeof(Script), "script");
break;
case ID_SO:
id= MEM_callocN(sizeof(bSound), "sound");
@@ -366,6 +382,12 @@ static ID *alloc_libblock_notest(short type)
case ID_PA:
id = MEM_callocN(sizeof(ParticleSettings), "ParticleSettings");
break;
+ case ID_WM:
+ id = MEM_callocN(sizeof(wmWindowManager), "Window manager");
+ break;
+ case ID_GD:
+ id = MEM_callocN(sizeof(bGPdata), "Grease Pencil");
+ break;
}
return id;
}
@@ -394,6 +416,45 @@ void *alloc_libblock(ListBase *lb, short type, const char *name)
/* from blendef: */
#define GS(a) (*((short *)(a)))
+/* by spec, animdata is first item after ID */
+/* we still read ->adt itself, to ensure compiler warns when it doesnt exist */
+static void id_copy_animdata(ID *id)
+{
+ switch(GS(id->name)) {
+ case ID_OB:
+ ((Object *)id)->adt= BKE_copy_animdata(((Object *)id)->adt);
+ break;
+ case ID_CU:
+ ((Curve *)id)->adt= BKE_copy_animdata(((Curve *)id)->adt);
+ break;
+ case ID_CA:
+ ((Camera *)id)->adt= BKE_copy_animdata(((Camera *)id)->adt);
+ break;
+ case ID_KE:
+ ((Key *)id)->adt= BKE_copy_animdata(((Key *)id)->adt);
+ break;
+ case ID_LA:
+ ((Lamp *)id)->adt= BKE_copy_animdata(((Lamp *)id)->adt);
+ break;
+ case ID_MA:
+ ((Material *)id)->adt= BKE_copy_animdata(((Material *)id)->adt);
+ break;
+ case ID_NT:
+ ((bNodeTree *)id)->adt= BKE_copy_animdata(((bNodeTree *)id)->adt);
+ break;
+ case ID_SCE:
+ ((Scene *)id)->adt= BKE_copy_animdata(((Scene *)id)->adt);
+ break;
+ case ID_TE:
+ ((Tex *)id)->adt= BKE_copy_animdata(((Tex *)id)->adt);
+ break;
+ case ID_WO:
+ ((World *)id)->adt= BKE_copy_animdata(((World *)id)->adt);
+ break;
+ }
+
+}
+
/* used everywhere in blenkernel and text.c */
void *copy_libblock(void *rt)
{
@@ -422,6 +483,8 @@ void *copy_libblock(void *rt)
idn->flag |= LIB_NEW;
if (id->properties) idn->properties = IDP_CopyProperty(id->properties);
+ id_copy_animdata(id);
+
return idn;
}
@@ -430,6 +493,13 @@ static void free_library(Library *lib)
/* no freeing needed for libraries yet */
}
+static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL;
+
+void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) )
+{
+ free_windowmanager_cb= func;
+}
+
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
void free_libblock(ListBase *lb, void *idv)
{
@@ -494,7 +564,7 @@ void free_libblock(ListBase *lb, void *idv)
free_text((Text *)id);
break;
case ID_SCRIPT:
- free_script((Script *)id);
+ //XXX free_script((Script *)id);
break;
case ID_SO:
sound_free_sound((bSound *)id);
@@ -517,6 +587,13 @@ void free_libblock(ListBase *lb, void *idv)
case ID_PA:
psys_free_settings((ParticleSettings *)id);
break;
+ case ID_WM:
+ if(free_windowmanager_cb)
+ free_windowmanager_cb(NULL, (wmWindowManager *)id);
+ break;
+ case ID_GD:
+ free_gpencil_data((bGPdata *)id);
+ break;
}
if (id->properties) {
@@ -539,7 +616,7 @@ void free_libblock_us(ListBase *lb, void *idv) /* test users */
else printf("ERROR block %s users %d\n", id->name, id->us);
}
if(id->us==0) {
- if( GS(id->name)==ID_OB ) unlink_object((Object *)id);
+ if( GS(id->name)==ID_OB ) unlink_object(NULL, (Object *)id);
free_libblock(lb, id);
}
@@ -664,52 +741,6 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
}
}
- /* Silly routine, the only difference between the one
- * above is that it only adds items with a matching
- * blocktype... this should be unified somehow... - zr
- */
-static void IPOnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int blocktype)
-{
- ID *id;
- int i, nids;
-
- for (id= lb->first, nids= 0; id; id= id->next) {
- Ipo *ipo= (Ipo*) id;
-
- if (ipo->blocktype==blocktype)
- nids++;
- }
-
- if (nids>MAX_IDPUP) {
- BLI_dynstr_append(pupds, "DataBrowse %x-2");
- } else {
- for (i=0, id= lb->first; id; id= id->next) {
- Ipo *ipo= (Ipo*) id;
-
- if (ipo->blocktype==blocktype) {
- char buf[32];
-
- if (id==link)
- *nr= i+1;
-
- if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
- continue;
-
- get_flags_for_id(id, buf);
-
- BLI_dynstr_append(pupds, buf);
- BLI_dynstr_append(pupds, id->name+2);
- sprintf(buf, "%%x%d", i+1);
- BLI_dynstr_append(pupds, buf);
-
- if(id->next)
- BLI_dynstr_append(pupds, "|");
-
- i++;
- }
- }
- }
-}
/* used by headerbuttons.c buttons.c editobject.c editseq.c */
/* if nr==NULL no MAX_IDPUP, this for non-header browsing */
@@ -757,28 +788,6 @@ void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb
}
-/* only used by headerbuttons.c */
-void IPOnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb, ID *link, short *nr, int blocktype)
-{
- DynStr *pupds= BLI_dynstr_new();
-
- if (title) {
- BLI_dynstr_append(pupds, title);
- BLI_dynstr_append(pupds, "%t|");
- }
-
- if (extraops) {
- BLI_dynstr_append(pupds, extraops);
- if (BLI_dynstr_get_len(pupds))
- BLI_dynstr_append(pupds, "|");
- }
-
- IPOnames_to_dyn_pupstring(pupds, lb, link, nr, blocktype);
-
- *str= BLI_dynstr_get_cstring(pupds);
- BLI_dynstr_free(pupds);
-}
-
/* used by buttons.c library.c mball.c */
void splitIDname(char *name, char *left, int *nr)
{
@@ -994,14 +1003,15 @@ static void lib_indirect_test_id(ID *id)
if(id->lib)
return;
-
+
if(GS(id->name)==ID_OB) {
Object *ob= (Object *)id;
bActionStrip *strip;
Mesh *me;
int a;
-
+
+ // XXX old animation system!
for (strip=ob->nlastrips.first; strip; strip=strip->next){
LIBTAG(strip->object);
LIBTAG(strip->act);
@@ -1098,6 +1108,27 @@ void test_idbutton(char *name)
if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
}
+void text_idbutton(struct ID *id, char *text)
+{
+ if(id) {
+ if(GS(id->name)==ID_SCE)
+ strcpy(text, "SCE: ");
+ else if(GS(id->name)==ID_SCE)
+ strcpy(text, "SCR: ");
+ else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
+ strcpy(text, "NT: ");
+ else {
+ text[0]= id->name[0];
+ text[1]= id->name[1];
+ text[2]= ':';
+ text[3]= ' ';
+ text[4]= 0;
+ }
+ }
+ else
+ strcpy(text, "");
+}
+
void rename_id(ID *id, char *name)
{
ListBase *lb;