diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 14:53:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 14:58:13 +0300 |
commit | 486e2547eea3f12bfde70f2526dde08f39a8722b (patch) | |
tree | c65c06162d46436c45c1972877d0b4163980411d /source | |
parent | a3409d3f53f1decb3cbe5c04fd804062dcf2cf49 (diff) |
DNA: move eObjectMode into own header
Add a enum headers to DNA, to be included in other headers
so function signatures can use enums for better type safety.
Add DNA_*_enums.h matching DNA_*.types.h as needed.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/include/ED_object.h | 6 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_enums.h | 49 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 23 |
5 files changed, 60 insertions, 27 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 818d4cd3d89..905abba5a7e 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -65,6 +65,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_node_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_fluidsim.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_force.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_enums.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_outliner_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_packedFile_types.h diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index cdca848f213..d74fb22faf8 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -54,6 +54,8 @@ struct PointerRNA; struct PropertyRNA; struct EnumPropertyItem; +#include "DNA_object_enums.h" + /* object_edit.c */ struct Object *ED_object_context(struct bContext *C); /* context.object */ struct Object *ED_object_active_context(struct bContext *C); /* context.object or context.active_object */ @@ -109,8 +111,8 @@ struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, st void ED_object_parent(struct Object *ob, struct Object *parent, const int type, const char *substr); -bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, int mode, struct ReportList *reports); -void ED_object_toggle_modes(struct bContext *C, int mode); +bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports); +void ED_object_toggle_modes(struct bContext *C, eObjectMode mode); /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index f8210f8a595..43a5307de1c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1622,7 +1622,7 @@ static const EnumPropertyItem *object_mode_set_itemsf( return item; } -static const char *object_mode_op_string(int mode) +static const char *object_mode_op_string(eObjectMode mode) { if (mode & OB_MODE_EDIT) return "OBJECT_OT_editmode_toggle"; @@ -1688,7 +1688,7 @@ static bool object_mode_compat_test(Object *ob, eObjectMode mode) * * This is so each mode's exec function can call */ -bool ED_object_mode_compat_set(bContext *C, Object *ob, int mode, ReportList *reports) +bool ED_object_mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports) { bool ok; if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) { @@ -1802,9 +1802,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } - - -void ED_object_toggle_modes(bContext *C, int mode) +void ED_object_toggle_modes(bContext *C, eObjectMode mode) { if (mode != OB_MODE_OBJECT) { const char *opstring = object_mode_op_string(mode); diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h new file mode 100644 index 00000000000..58f9e29297f --- /dev/null +++ b/source/blender/makesdna/DNA_object_enums.h @@ -0,0 +1,49 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file DNA_object_enums.h + * \ingroup DNA + * + * Enums typedef's for use in public headers. + */ + +#ifndef __DNA_OBJECT_ENUMS_H__ +#define __DNA_OBJECT_ENUMS_H__ + +/* Object.mode */ +typedef enum eObjectMode { + OB_MODE_OBJECT = 0, + OB_MODE_EDIT = 1 << 0, + OB_MODE_SCULPT = 1 << 1, + OB_MODE_VERTEX_PAINT = 1 << 2, + OB_MODE_WEIGHT_PAINT = 1 << 3, + OB_MODE_TEXTURE_PAINT = 1 << 4, + OB_MODE_PARTICLE_EDIT = 1 << 5, + OB_MODE_POSE = 1 << 6, + OB_MODE_GPENCIL = 1 << 7, /* NOTE: Just a dummy to make the UI nicer */ +} eObjectMode; + +/* Any mode where the brush system is used. */ +#define OB_MODE_ALL_PAINT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT) + +/* Any mode that uses Object.sculpt. */ +#define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) + +#endif /* __DNA_OBJECT_ENUMS_H__ */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index a9c36007d9c..e0b4d117bd1 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -33,6 +33,8 @@ #ifndef __DNA_OBJECT_TYPES_H__ #define __DNA_OBJECT_TYPES_H__ +#include "DNA_object_enums.h" + #include "DNA_defs.h" #include "DNA_listBase.h" #include "DNA_ID.h" @@ -671,26 +673,7 @@ enum { OB_LOCK_ROTW = 1 << 9, OB_LOCK_ROT4D = 1 << 10, }; - -/* ob->mode */ -typedef enum eObjectMode { - OB_MODE_OBJECT = 0, - OB_MODE_EDIT = 1 << 0, - OB_MODE_SCULPT = 1 << 1, - OB_MODE_VERTEX_PAINT = 1 << 2, - OB_MODE_WEIGHT_PAINT = 1 << 3, - OB_MODE_TEXTURE_PAINT = 1 << 4, - OB_MODE_PARTICLE_EDIT = 1 << 5, - OB_MODE_POSE = 1 << 6, - OB_MODE_GPENCIL = 1 << 7, /* NOTE: Just a dummy to make the UI nicer */ -} eObjectMode; - -/* any mode where the brush system is used */ -#define OB_MODE_ALL_PAINT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT) - -/* any mode that uses ob->sculpt */ -#define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) - + #define MAX_DUPLI_RECUR 8 #ifdef __cplusplus |