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:
authorBrecht Van Lommel <brecht>2020-03-03 19:21:22 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-03-03 19:22:30 +0300
commit19785b96c43f6dc19906f4b39a18a656684826b1 (patch)
tree72aac82ebd54ffda9cca137d87e3da6bd304d819 /source/blender/windowmanager
parent0c603cffd123689c3021862a9d76dad9fbe13f4d (diff)
IDs: modify wm.previews_clear operator to make space for new ID types
Use a regular enum, to avoid running out of bits. Differential Revision: https://developer.blender.org/D7003
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c79
1 files changed, 59 insertions, 20 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index bc519055af3..02ac94112ad 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3412,38 +3412,78 @@ static void WM_OT_previews_ensure(wmOperatorType *ot)
/** \name Data-Block Preview Clear Operator
* \{ */
+typedef enum PreviewFilterID {
+ PREVIEW_FILTER_ALL,
+ PREVIEW_FILTER_GEOMETRY,
+ PREVIEW_FILTER_SHADING,
+ PREVIEW_FILTER_SCENE,
+ PREVIEW_FILTER_COLLECTION,
+ PREVIEW_FILTER_OBJECT,
+ PREVIEW_FILTER_MATERIAL,
+ PREVIEW_FILTER_LIGHT,
+ PREVIEW_FILTER_WORLD,
+ PREVIEW_FILTER_TEXTURE,
+ PREVIEW_FILTER_IMAGE,
+} PreviewFilterID;
+
/* Only types supporting previews currently. */
static const EnumPropertyItem preview_id_type_items[] = {
- {FILTER_ID_SCE | FILTER_ID_GR | FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_LA | FILTER_ID_WO |
- FILTER_ID_TE | FILTER_ID_IM,
- "ALL",
- 0,
- "All Types",
- ""},
- {FILTER_ID_SCE | FILTER_ID_GR | FILTER_ID_OB,
+ {PREVIEW_FILTER_ALL, "ALL", 0, "All Types", ""},
+ {PREVIEW_FILTER_GEOMETRY,
"GEOMETRY",
0,
"All Geometry Types",
"Clear previews for scenes, collections and objects"},
- {FILTER_ID_MA | FILTER_ID_LA | FILTER_ID_WO | FILTER_ID_TE | FILTER_ID_IM,
+ {PREVIEW_FILTER_SHADING,
"SHADING",
0,
"All Shading Types",
"Clear previews for materials, lights, worlds, textures and images"},
- {FILTER_ID_SCE, "SCENE", 0, "Scenes", ""},
- {FILTER_ID_GR, "GROUP", 0, "Groups", ""},
- {FILTER_ID_OB, "OBJECT", 0, "Objects", ""},
- {FILTER_ID_MA, "MATERIAL", 0, "Materials", ""},
- {FILTER_ID_LA, "LIGHT", 0, "Lights", ""},
- {FILTER_ID_WO, "WORLD", 0, "Worlds", ""},
- {FILTER_ID_TE, "TEXTURE", 0, "Textures", ""},
- {FILTER_ID_IM, "IMAGE", 0, "Images", ""},
+ {PREVIEW_FILTER_SCENE, "SCENE", 0, "Scenes", ""},
+ {PREVIEW_FILTER_COLLECTION, "COLLECTION", 0, "Collections", ""},
+ {PREVIEW_FILTER_OBJECT, "OBJECT", 0, "Objects", ""},
+ {PREVIEW_FILTER_MATERIAL, "MATERIAL", 0, "Materials", ""},
+ {PREVIEW_FILTER_LIGHT, "LIGHT", 0, "Lights", ""},
+ {PREVIEW_FILTER_WORLD, "WORLD", 0, "Worlds", ""},
+ {PREVIEW_FILTER_TEXTURE, "TEXTURE", 0, "Textures", ""},
+ {PREVIEW_FILTER_IMAGE, "IMAGE", 0, "Images", ""},
#if 0 /* XXX TODO */
- {FILTER_ID_BR, "BRUSH", 0, "Brushes", ""},
+ {PREVIEW_FILTER_BRUSH, "BRUSH", 0, "Brushes", ""},
#endif
{0, NULL, 0, NULL, NULL},
};
+static uint preview_filter_to_idfilter(enum PreviewFilterID filter)
+{
+ switch (filter) {
+ case PREVIEW_FILTER_ALL:
+ return FILTER_ID_SCE | FILTER_ID_GR | FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_LA |
+ FILTER_ID_WO | FILTER_ID_TE | FILTER_ID_IM;
+ case PREVIEW_FILTER_GEOMETRY:
+ return FILTER_ID_SCE | FILTER_ID_GR | FILTER_ID_OB;
+ case PREVIEW_FILTER_SHADING:
+ return FILTER_ID_MA | FILTER_ID_LA | FILTER_ID_WO | FILTER_ID_TE | FILTER_ID_IM;
+ case PREVIEW_FILTER_SCENE:
+ return FILTER_ID_SCE;
+ case PREVIEW_FILTER_COLLECTION:
+ return FILTER_ID_GR;
+ case PREVIEW_FILTER_OBJECT:
+ return FILTER_ID_OB;
+ case PREVIEW_FILTER_MATERIAL:
+ return FILTER_ID_MA;
+ case PREVIEW_FILTER_LIGHT:
+ return FILTER_ID_LA;
+ case PREVIEW_FILTER_WORLD:
+ return FILTER_ID_WO;
+ case PREVIEW_FILTER_TEXTURE:
+ return FILTER_ID_TE;
+ case PREVIEW_FILTER_IMAGE:
+ return FILTER_ID_IM;
+ }
+
+ return 0;
+}
+
static int previews_clear_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -3459,7 +3499,7 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
};
int i;
- const int id_filters = RNA_enum_get(op->ptr, "id_type");
+ const int id_filters = preview_filter_to_idfilter(RNA_enum_get(op->ptr, "id_type"));
for (i = 0; lb[i]; i++) {
ID *id = lb[i]->first;
@@ -3503,8 +3543,7 @@ static void WM_OT_previews_clear(wmOperatorType *ot)
ot->prop = RNA_def_enum_flag(ot->srna,
"id_type",
preview_id_type_items,
- FILTER_ID_SCE | FILTER_ID_OB | FILTER_ID_GR | FILTER_ID_MA |
- FILTER_ID_LA | FILTER_ID_WO | FILTER_ID_TE | FILTER_ID_IM,
+ PREVIEW_FILTER_ALL,
"Data-Block Type",
"Which data-block previews to clear");
}