Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modes.c
| Show All 21 Lines | |||||
| /** \file blender/editors/object/object_modes.c | /** \file blender/editors/object/object_modes.c | ||||
| * \ingroup edobj | * \ingroup edobj | ||||
| * | * | ||||
| * General utils to handle mode switching, | * General utils to handle mode switching, | ||||
| * actual mode switching logic is per-object type. | * actual mode switching logic is per-object type. | ||||
| */ | */ | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| Show All 28 Lines | static const char *object_mode_op_string(eObjectMode mode) | ||||
| if (mode == OB_MODE_WEIGHT_PAINT) | if (mode == OB_MODE_WEIGHT_PAINT) | ||||
| return "PAINT_OT_weight_paint_toggle"; | return "PAINT_OT_weight_paint_toggle"; | ||||
| if (mode == OB_MODE_TEXTURE_PAINT) | if (mode == OB_MODE_TEXTURE_PAINT) | ||||
| return "PAINT_OT_texture_paint_toggle"; | return "PAINT_OT_texture_paint_toggle"; | ||||
| if (mode == OB_MODE_PARTICLE_EDIT) | if (mode == OB_MODE_PARTICLE_EDIT) | ||||
| return "PARTICLE_OT_particle_edit_toggle"; | return "PARTICLE_OT_particle_edit_toggle"; | ||||
| if (mode == OB_MODE_POSE) | if (mode == OB_MODE_POSE) | ||||
| return "OBJECT_OT_posemode_toggle"; | return "OBJECT_OT_posemode_toggle"; | ||||
| if (mode == OB_MODE_GPENCIL) | if (mode == OB_MODE_GPENCIL_EDIT) | ||||
| return "GPENCIL_OT_editmode_toggle"; | return "GPENCIL_OT_editmode_toggle"; | ||||
| if (mode == OB_MODE_GPENCIL_PAINT) | |||||
| return "GPENCIL_OT_paintmode_toggle"; | |||||
| if (mode == OB_MODE_GPENCIL_SCULPT) | |||||
| return "GPENCIL_OT_sculptmode_toggle"; | |||||
| if (mode == OB_MODE_GPENCIL_WEIGHT) | |||||
| return "GPENCIL_OT_weightmode_toggle"; | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /** | /** | ||||
| * Checks the mode to be set is compatible with the object | * Checks the mode to be set is compatible with the object | ||||
| * should be made into a generic function | * should be made into a generic function | ||||
| */ | */ | ||||
| bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) | bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) | ||||
| { | { | ||||
| if (ob) { | if (ob) { | ||||
| if (mode == OB_MODE_OBJECT) | if (mode == OB_MODE_OBJECT) | ||||
| return true; | return true; | ||||
| else if (mode == OB_MODE_GPENCIL) | |||||
| return true; /* XXX: assume this is the case for now... */ | |||||
| switch (ob->type) { | switch (ob->type) { | ||||
| case OB_MESH: | case OB_MESH: | ||||
| if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | | if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | | ||||
| OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT)) | OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT)) | ||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_CURVE: | case OB_CURVE: | ||||
| case OB_SURF: | case OB_SURF: | ||||
| case OB_FONT: | case OB_FONT: | ||||
| case OB_MBALL: | case OB_MBALL: | ||||
| if (mode & (OB_MODE_EDIT)) | if (mode & (OB_MODE_EDIT)) | ||||
| return true; | return true; | ||||
| break; | break; | ||||
| case OB_LATTICE: | case OB_LATTICE: | ||||
| if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) | if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) | ||||
| return true; | return true; | ||||
| break; | break; | ||||
| case OB_ARMATURE: | case OB_ARMATURE: | ||||
| if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) | if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) | ||||
| return true; | return true; | ||||
| break; | break; | ||||
| case OB_GPENCIL: | |||||
| if (mode & (OB_MODE_EDIT | OB_MODE_GPENCIL_EDIT | OB_MODE_GPENCIL_PAINT | | |||||
| OB_MODE_GPENCIL_SCULPT | OB_MODE_GPENCIL_WEIGHT)) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the mode to a compatible state (use before entering the mode). | * Sets the mode to a compatible state (use before entering the mode). | ||||
| ▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines | |||||