diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 19:11:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 19:11:11 +0300 |
commit | 22a892f4024db7da71ccdced00bf494c28443510 (patch) | |
tree | 591505ea18810778727110f1ef04b0b858e12c08 /source/blender/makesrna | |
parent | 68bc4d7355d8a13d6565d976180970af5c2d20e3 (diff) |
- make ToolSettings.mesh_selection_mode into an array of 3 bools rather then an enum since multiple can be set at once.
- ToolSettings had its id.data set to NULL when taken directly from the context (causing a crash in cases)
- menu for changing vert/edge/face selection now a python menu, removed operator.
- wm.context_set_value(), would really prefer not to have this since it evaluates the value as a python expression however there are no ways to define arrays in PyOperators
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_context.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 48 |
4 files changed, 54 insertions, 5 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index e771b495b96..90603f98c7a 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -164,7 +164,12 @@ typedef enum PropertyFlag { PROP_ID_SELF_CHECK = 1<<20, PROP_NEVER_NULL = 1<<18, - /* flag contains multiple enums */ + /* flag contains multiple enums. + * note: not to be confused with prop->enumbitflags + * this exposes the flag as multiple options in python and the UI. + * + * note: these can't be animated so use with care. + */ PROP_ENUM_FLAG = 1<<21, /* need context for update function */ diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 7239fc1ff3d..70d61b15d9f 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -100,6 +100,7 @@ static PointerRNA rna_Context_scene_get(PointerRNA *ptr) static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; + ptr->id.data= CTX_data_scene(C); return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C)); } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 1c14d0d4c06..5bb3c82395d 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -75,6 +75,9 @@ typedef struct PropertyDefRNA { int dnalengthfixed; int booleanbit, booleannegative; + + /* not to be confused with PROP_ENUM_FLAG + * this only allows one of the flags to be set at a time, clearing all others */ int enumbitflags; } PropertyDefRNA; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e4df352bcc8..ba389f66438 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -72,6 +72,7 @@ EnumPropertyItem proportional_editing_items[] = { {PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected", ""}, {0, NULL, 0, NULL, NULL}}; +/* keep for operators, not used here */ EnumPropertyItem mesh_select_mode_items[] = { {SCE_SELECT_VERTEX, "VERTEX", ICON_VERTEXSEL, "Vertex", "Vertex selection mode."}, {SCE_SELECT_EDGE, "EDGE", ICON_EDGESEL, "Edge", "Edge selection mode."}, @@ -91,6 +92,7 @@ EnumPropertyItem snap_element_items[] = { #include "DNA_anim_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_mesh_types.h" #include "BKE_context.h" #include "BKE_global.h" @@ -99,13 +101,18 @@ EnumPropertyItem snap_element_items[] = { #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_depsgraph.h" +#include "BKE_mesh.h" #include "BLI_threads.h" +#include "BLI_editVert.h" + +#include "WM_api.h" #include "ED_info.h" #include "ED_node.h" #include "ED_view3d.h" #include "ED_object.h" +#include "ED_mesh.h" #include "RE_pipeline.h" @@ -562,6 +569,38 @@ static void rna_Physics_update(Main *bmain, Scene *unused, PointerRNA *ptr) for(base = scene->base.first; base; base=base->next) BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH); } + +static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value) +{ + Scene *scene= (Scene*)ptr->id.data; + ToolSettings *ts = (ToolSettings*)ptr->data; + int flag = (value[0] ? SCE_SELECT_VERTEX:0) | (value[1] ? SCE_SELECT_EDGE:0) | (value[2] ? SCE_SELECT_FACE:0); + + ts->selectmode = flag; + + if(scene->basact) { + Mesh *me= get_mesh(scene->basact->object); + if(me && me->edit_mesh && me->edit_mesh->selectmode != flag) { + me->edit_mesh->selectmode= flag; + EM_selectmode_set(me->edit_mesh); + } + } +} + +static void rna_Scene_editmesh_select_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Mesh *me= NULL; + + if(scene->basact) { + me= get_mesh(scene->basact->object); + if(me && me->edit_mesh==NULL) + me= NULL; + } + + WM_main_add_notifier(NC_GEOM|ND_SELECT, me); + WM_main_add_notifier(NC_SCENE|ND_MODE, NULL); /* header redraw */ +} + #else static void rna_def_transform_orientation(BlenderRNA *brna) @@ -736,10 +775,11 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); /* Mesh */ - prop= RNA_def_property(srna, "mesh_selection_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "selectmode"); - RNA_def_property_enum_items(prop, mesh_select_mode_items); - RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Mesh selection and display mode."); + prop= RNA_def_property(srna, "mesh_selection_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selectmode", 1); + RNA_def_property_array(prop, 3); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_editmesh_select_mode_set"); + RNA_def_property_update(prop, 0, "rna_Scene_editmesh_select_mode_update"); prop= RNA_def_property(srna, "vertex_group_weight", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "vgroup_weight"); |