[Bf-blender-cvs] [517b06c] asset-experiments: Reorganization: move ID filters to DNA_ID.h, and add helpers in bke's idcode.c to convert between idcode and idfilter.
Bastien Montagne
noreply at git.blender.org
Mon Jan 12 17:47:01 CET 2015
Commit: 517b06c29696195fc808d99cdb45c72b3e94a86e
Author: Bastien Montagne
Date: Mon Jan 12 17:44:44 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB517b06c29696195fc808d99cdb45c72b3e94a86e
Reorganization: move ID filters to DNA_ID.h, and add helpers in bke's idcode.c to convert between idcode and idfilter.
===================================================================
M source/blender/blenkernel/BKE_idcode.h
M source/blender/blenkernel/intern/idcode.c
M source/blender/editors/space_file/filelist.c
M source/blender/makesdna/DNA_ID.h
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h
index 10a3483..2a57ae5 100644
--- a/source/blender/blenkernel/BKE_idcode.h
+++ b/source/blender/blenkernel/BKE_idcode.h
@@ -38,6 +38,9 @@ int BKE_idcode_from_name(const char *name);
bool BKE_idcode_is_linkable(int code);
bool BKE_idcode_is_valid(int code);
+int BKE_idcode_to_idfilter(const int idcode);
+int BKE_idcode_from_idfilter(const int idfilter);
+
/**
* Return an ID code and steps the index forward 1.
*
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 1b7a03e..92fe12c 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -176,6 +176,136 @@ const char *BKE_idcode_to_name_plural(int code)
}
/**
+ * Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB).
+ */
+int BKE_idcode_to_idfilter(const int idcode)
+{
+ switch (idcode) {
+ case ID_AC:
+ return FILTER_ID_AC;
+ case ID_AR:
+ return FILTER_ID_AR;
+ case ID_BR:
+ return FILTER_ID_BR;
+ case ID_CA:
+ return FILTER_ID_CA;
+ case ID_CU:
+ return FILTER_ID_CU;
+ case ID_GD:
+ return FILTER_ID_GD;
+ case ID_GR:
+ return FILTER_ID_GR;
+ case ID_IM:
+ return FILTER_ID_IM;
+ case ID_LA:
+ return FILTER_ID_LA;
+ case ID_LS:
+ return FILTER_ID_LS;
+ case ID_LT:
+ return FILTER_ID_LT;
+ case ID_MA:
+ return FILTER_ID_MA;
+ case ID_MB:
+ return FILTER_ID_MB;
+ case ID_MC:
+ return FILTER_ID_MC;
+ case ID_ME:
+ return FILTER_ID_ME;
+ case ID_MSK:
+ return FILTER_ID_MSK;
+ case ID_NT:
+ return FILTER_ID_NT;
+ case ID_OB:
+ return FILTER_ID_OB;
+ case ID_PAL:
+ return FILTER_ID_PAL;
+ case ID_PC:
+ return FILTER_ID_PC;
+ case ID_SCE:
+ return FILTER_ID_SCE;
+ case ID_SPK:
+ return FILTER_ID_SPK;
+ case ID_SO:
+ return FILTER_ID_SO;
+ case ID_TE:
+ return FILTER_ID_TE;
+ case ID_TXT:
+ return FILTER_ID_TXT;
+ case ID_VF:
+ return FILTER_ID_VF;
+ case ID_WO:
+ return FILTER_ID_WO;
+ default:
+ return 0;
+ }
+}
+
+/**
+ * Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).
+ */
+int BKE_idcode_from_idfilter(const int idfilter)
+{
+ switch (idfilter) {
+ case FILTER_ID_AC:
+ return ID_AC;
+ case FILTER_ID_AR:
+ return ID_AR;
+ case FILTER_ID_BR:
+ return ID_BR;
+ case FILTER_ID_CA:
+ return ID_CA;
+ case FILTER_ID_CU:
+ return ID_CU;
+ case FILTER_ID_GD:
+ return ID_GD;
+ case FILTER_ID_GR:
+ return ID_GR;
+ case FILTER_ID_IM:
+ return ID_IM;
+ case FILTER_ID_LA:
+ return ID_LA;
+ case FILTER_ID_LS:
+ return ID_LS;
+ case FILTER_ID_LT:
+ return ID_LT;
+ case FILTER_ID_MA:
+ return ID_MA;
+ case FILTER_ID_MB:
+ return ID_MB;
+ case FILTER_ID_MC:
+ return ID_MC;
+ case FILTER_ID_ME:
+ return ID_ME;
+ case FILTER_ID_MSK:
+ return ID_MSK;
+ case FILTER_ID_NT:
+ return ID_NT;
+ case FILTER_ID_OB:
+ return ID_OB;
+ case FILTER_ID_PAL:
+ return ID_PAL;
+ case FILTER_ID_PC:
+ return ID_PC;
+ case FILTER_ID_SCE:
+ return ID_SCE;
+ case FILTER_ID_SPK:
+ return ID_SPK;
+ case FILTER_ID_SO:
+ return ID_SO;
+ case FILTER_ID_TE:
+ return ID_TE;
+ case FILTER_ID_TXT:
+ return ID_TXT;
+ case FILTER_ID_VF:
+ return ID_VF;
+ case FILTER_ID_WO:
+ return ID_WO;
+ default:
+ return 0;
+ }
+}
+
+/**
* Return an ID code and steps the index forward 1.
*
* \param index start as 0.
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 4cf13ed..011a536 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -61,10 +61,10 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_icons.h"
+#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BLO_readfile.h"
-#include "BKE_idcode.h"
#include "DNA_space_types.h"
@@ -1324,64 +1324,7 @@ static unsigned int groupname_to_filter_id(const char *group)
{
int id_code = groupname_to_code(group);
- switch (id_code) {
- case ID_AC:
- return FILTER_ID_AC;
- case ID_AR:
- return FILTER_ID_AR;
- case ID_BR:
- return FILTER_ID_BR;
- case ID_CA:
- return FILTER_ID_CA;
- case ID_CU:
- return FILTER_ID_CU;
- case ID_GD:
- return FILTER_ID_GD;
- case ID_GR:
- return FILTER_ID_GR;
- case ID_IM:
- return FILTER_ID_IM;
- case ID_LA:
- return FILTER_ID_LA;
- case ID_LS:
- return FILTER_ID_LS;
- case ID_LT:
- return FILTER_ID_LT;
- case ID_MA:
- return FILTER_ID_MA;
- case ID_MB:
- return FILTER_ID_MB;
- case ID_MC:
- return FILTER_ID_MC;
- case ID_ME:
- return FILTER_ID_ME;
- case ID_MSK:
- return FILTER_ID_MSK;
- case ID_NT:
- return FILTER_ID_NT;
- case ID_OB:
- return FILTER_ID_OB;
- case ID_PAL:
- return FILTER_ID_PAL;
- case ID_PC:
- return FILTER_ID_PC;
- case ID_SCE:
- return FILTER_ID_SCE;
- case ID_SPK:
- return FILTER_ID_SPK;
- case ID_SO:
- return FILTER_ID_SO;
- case ID_TE:
- return FILTER_ID_TE;
- case ID_TXT:
- return FILTER_ID_TXT;
- case ID_VF:
- return FILTER_ID_VF;
- case ID_WO:
- return FILTER_ID_WO;
- default:
- return 0;
- }
+ return BKE_idcode_to_idfilter(id_code);
}
/*
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 2456b10..e1a42a5 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -275,6 +275,41 @@ enum {
LIB_ANIM_NO_RECALC = 1 << 14,
};
+/* To filter ID types (filter_id) */
+/* XXX We cannot put all needed IDs inside an enum...
+ * We'll have to see whether we can fit all needed ones inside 32 values,
+ * or if we need to fallback to longlong defines :/
+ */
+enum {
+ FILTER_ID_AC = (1 << 0),
+ FILTER_ID_AR = (1 << 1),
+ FILTER_ID_BR = (1 << 2),
+ FILTER_ID_CA = (1 << 3),
+ FILTER_ID_CU = (1 << 4),
+ FILTER_ID_GD = (1 << 5),
+ FILTER_ID_GR = (1 << 6),
+ FILTER_ID_IM = (1 << 7),
+ FILTER_ID_LA = (1 << 8),
+ FILTER_ID_LS = (1 << 9),
+ FILTER_ID_LT = (1 << 10),
+ FILTER_ID_MA = (1 << 11),
+ FILTER_ID_MB = (1 << 12),
+ FILTER_ID_MC = (1 << 13),
+ FILTER_ID_ME = (1 << 14),
+ FILTER_ID_MSK = (1 << 15),
+ FILTER_ID_NT = (1 << 16),
+ FILTER_ID_OB = (1 << 17),
+ FILTER_ID_PAL = (1 << 18),
+ FILTER_ID_PC = (1 << 19),
+ FILTER_ID_SCE = (1 << 20),
+ FILTER_ID_SPK = (1 << 21),
+ FILTER_ID_SO = (1 << 22),
+ FILTER_ID_TE = (1 << 23),
+ FILTER_ID_TXT = (1 << 24),
+ FILTER_ID_VF = (1 << 25),
+ FILTER_ID_WO = (1 << 26),
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index ecaefb3..67056e5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -724,37 +724,6 @@ typedef enum eFileSel_File_Types {
FILE_TYPE_BLENDERLIB = (1 << 31),
} eFileSel_File_Types;
-/* To filter ID types (filter_id) */
-typedef enum eFileSel_LibID_Types {
- FILTER_ID_AC = (1 << 0),
- FILTER_ID_AR = (1 << 1),
- FILTER_ID_BR = (1 << 2),
- FILTER_ID_CA = (1 << 3),
- FILTER_ID_CU = (1 << 4),
- FILTER_ID_GD = (1 << 5),
- FILTER_ID_GR = (1 << 6),
- FILTER_ID_IM = (1 << 7),
- FILTER_ID_LA = (1 << 8),
- FILTER_ID_LS = (1 << 9),
- FILTER_ID_LT = (1 << 10),
- FILTER_ID_MA = (1 << 11),
- FILTER_ID_MB = (1 << 12),
- FILTER_ID_MC = (1 << 13),
- FILTER_ID_ME = (1 << 14),
- FILTER_ID_MSK = (1 << 15),
- FILTER_ID_NT = (1 << 16),
- FILTER_ID_OB = (1 << 17),
- FILTER_ID_PAL = (1 << 18),
- FILTER_ID_PC = (1 << 19),
- FILTER_ID_SCE = (1 << 20),
- FILTER_ID_SPK = (1 << 21),
- FILTER_ID_SO = (1 << 22),
- FILTER_ID_TE = (1 << 23),
- FILTER_ID_TXT = (1 << 24),
- FILTER_ID_VF = (1 << 25),
- FILTER_ID_WO = (1 << 26),
-} eFileSel_LibID_Types;
-
/* Selection Flags in filesel: struct direntry, unsigned char selflag */
typedef enum eDirEntry_SelectFlag {
/* FILE_SEL_ACTIVE = (1 << 1), */ /* UNUSED */
More information about the Bf-blender-cvs
mailing list