diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 27 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 66 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh.c | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 27 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 47 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 21 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 18 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 38 |
15 files changed, 188 insertions, 120 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index adcf2cfc024..fde270040a9 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -38,6 +38,7 @@ struct wmEvent; struct bContext; struct Object; struct uiLayout; +struct EnumPropertyItem; void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid); void transform_operatortypes(void); @@ -114,7 +115,7 @@ int BIF_menuselectTransformOrientation(void); void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts); void BIF_selectTransformOrientationValue(struct bContext *C, int orientation); -void BIF_menuTransformOrientation(struct bContext *C, struct uiLayout *layout, void *arg); +struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C); char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */ int BIF_countTransformOrientation(const struct bContext *C); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4fe28c2e457..391be4ba591 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1615,6 +1615,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block= MEM_callocN(sizeof(uiBlock), "uiBlock"); block->active= 1; block->dt= dt; + block->evil_C= C; // XXX BLI_strncpy(block->name, name, sizeof(block->name)); if(region) @@ -2113,11 +2114,11 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, /* use rna values if parameters are not specified */ if(!str) { if(type == MENU && proptype == PROP_ENUM) { - const EnumPropertyItem *item; + EnumPropertyItem *item; DynStr *dynstr; - int i, totitem, value; + int i, totitem, value, free; - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); value= RNA_property_enum_get(ptr, prop); dynstr= BLI_dynstr_new(); @@ -2136,13 +2137,16 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, str= BLI_dynstr_get_cstring(dynstr); BLI_dynstr_free(dynstr); + if(free) + MEM_freeN(item); + freestr= 1; } else if(type == ROW && proptype == PROP_ENUM) { - const EnumPropertyItem *item; - int i, totitem; + EnumPropertyItem *item; + int i, totitem, free; - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); for(i=0; i<totitem; i++) { if(item[i].identifier[0] && item[i].value == (int)max) { str= (char*)item[i].name; @@ -2152,6 +2156,8 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(!str) str= (char*)RNA_property_ui_name(prop); + if(free) + MEM_freeN(item); } else { str= (char*)RNA_property_ui_name(prop); @@ -2161,10 +2167,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(!tip) { if(type == ROW && proptype == PROP_ENUM) { - const EnumPropertyItem *item; - int i, totitem; + EnumPropertyItem *item; + int i, totitem, free; - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); for(i=0; i<totitem; i++) { if(item[i].identifier[0] && item[i].value == (int)max) { @@ -2173,6 +2179,9 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, break; } } + + if(free) + MEM_freeN(item); } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 1b16155c7e6..8c254419ec3 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -290,6 +290,8 @@ struct uiBlock { int tooltipdisabled; // to avoid tooltip after click int active; // to keep blocks while drawing and free them afterwards + + void *evil_C; // XXX hack for dynamic operator enums }; typedef struct uiSafetyRct { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 8e880b10185..77af58bacc1 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -429,13 +429,13 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h) { - const EnumPropertyItem *item; + EnumPropertyItem *item; const char *identifier; char *name; - int a, totitem, itemw, icon, value; + int a, totitem, itemw, icon, value, free; identifier= RNA_property_identifier(prop); - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); for(a=0; a<totitem; a++) { @@ -455,6 +455,9 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); } uiBlockSetCurLayout(block, layout); + + if(free) + MEM_freeN(item); } /* create label + button for RNA property */ @@ -545,7 +548,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert } } -static char *ui_menu_enumpropname(char *opname, char *propname, int retval) +static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval) { wmOperatorType *ot= WM_operatortype_find(opname); PointerRNA ptr; @@ -558,13 +561,18 @@ static char *ui_menu_enumpropname(char *opname, char *propname, int retval) prop= RNA_struct_find_property(&ptr, propname); if(prop) { - const EnumPropertyItem *item; - int totitem; + EnumPropertyItem *item; + int totitem, free; const char *name; - RNA_property_enum_items(&ptr, prop, &item, &totitem); - if(RNA_enum_name(item, retval, &name)) + RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); + if(RNA_enum_name(item, retval, &name)) { + if(free) MEM_freeN(item); return (char*)name; + } + + if(free) + MEM_freeN(item); } return ""; @@ -578,7 +586,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro RNA_enum_set(&ptr, propname, value); if(!name) - name= ui_menu_enumpropname(opname, propname, value); + name= ui_menu_enumpropname(layout, opname, propname, value); uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); } @@ -598,16 +606,19 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) prop= RNA_struct_find_property(&ptr, propname); if(prop && RNA_property_type(prop) == PROP_ENUM) { - const EnumPropertyItem *item; - int totitem, i; + EnumPropertyItem *item; + int totitem, i, free; - RNA_property_enum_items(&ptr, prop, &item, &totitem); + RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); for(i=0; i<totitem; i++) if(item[i].identifier[0]) uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value); else uiItemS(layout); + + if(free) + MEM_freeN(item); } } @@ -618,18 +629,22 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch /* for getting the enum */ PropertyRNA *prop; - const EnumPropertyItem *item; - int value; + EnumPropertyItem *item; + int value, free; WM_operator_properties_create(&ptr, opname); /* enum lookup */ if((prop= RNA_struct_find_property(&ptr, propname))) { - RNA_property_enum_items(&ptr, prop, &item, NULL); + RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); if(RNA_enum_value_from_id(item, value_str, &value)==0) { + if(free) MEM_freeN(item); printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str); return; } + + if(free) + MEM_freeN(item); } else { printf("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); @@ -640,7 +655,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch /* same as uiItemEnumO */ if(!name) - name= ui_menu_enumpropname(opname, propname, value); + name= ui_menu_enumpropname(layout, opname, propname, value); uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext); } @@ -845,8 +860,8 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value) { PropertyRNA *prop; - const EnumPropertyItem *item; - int ivalue, a; + EnumPropertyItem *item; + int ivalue, a, free; if(!ptr->data || !propname) return; @@ -859,9 +874,10 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN return; } - RNA_property_enum_items(ptr, prop, &item, NULL); + RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free); if(!RNA_enum_value_from_id(item, value, &ivalue)) { + if(free) MEM_freeN(item); ui_item_disabled(layout, propname); printf("uiItemEnumR: enum property value not found: %s\n", value); return; @@ -873,6 +889,9 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN break; } } + + if(free) + MEM_freeN(item); } void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) @@ -887,16 +906,19 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) } if(RNA_property_type(prop) == PROP_ENUM) { - const EnumPropertyItem *item; - int totitem, i; + EnumPropertyItem *item; + int totitem, i, free; - RNA_property_enum_items(ptr, prop, &item, &totitem); + RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free); for(i=0; i<totitem; i++) if(item[i].identifier[0]) uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value); else uiItemS(layout); + + if(free) + MEM_freeN(item); } } diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index a680fb5d07a..cdd51a72f4f 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1606,13 +1606,13 @@ static int mesh_separate_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Base *base= CTX_data_active_base(C); - int retval= 0; + int retval= 0, type= RNA_enum_get(op->ptr, "type"); - if(RNA_enum_is_equal(op->ptr, "type", "SELECTED")) + if(type == 0) retval= mesh_separate_selected(scene, base); - else if(RNA_enum_is_equal(op->ptr, "type", "MATERIAL")) + else if(type == 1) retval= mesh_separate_material (scene, base); - else if(RNA_enum_is_equal(op->ptr, "type", "LOOSE")) + else if(type == 2) retval= mesh_separate_loose(scene, base); if(retval) { diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index ca0f73ece68..2995e2d895b 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -1227,12 +1227,29 @@ static int select_similar_exec(bContext *C, wmOperator *op) return similar_face_select_exec(C, op); } -static EnumPropertyItem *select_similar_type_itemf(PointerRNA *ptr) +static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *ptr, int *free) { - /* XXX need context! */ - return prop_simface_types; - return prop_simvertex_types; - return prop_simedge_types; + Object *obedit= CTX_data_edit_object(C); + + if(obedit && obedit->type == OB_MESH) { + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + EnumPropertyItem *item= NULL; + int totitem= 0; + + if(em->selectmode & SCE_SELECT_VERTEX) + RNA_enum_items_add(&item, &totitem, prop_simvertex_types); + else if(em->selectmode & SCE_SELECT_EDGE) + RNA_enum_items_add(&item, &totitem, prop_simedge_types); + else if(em->selectmode & SCE_SELECT_FACE) + RNA_enum_items_add(&item, &totitem, prop_simface_types); + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; + } + + return NULL; } void MESH_OT_select_similar(wmOperatorType *ot) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4377f459081..682b1ee4a64 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -5799,29 +5799,38 @@ static EnumPropertyItem merge_type_items[]= { {5, "COLLAPSE", 0, "Collapse", ""}, {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *merge_type_itemf(PointerRNA *ptr) +static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *free) { - /* XXX need context here */ -#if 0 - Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); - EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - if(em->selectmode & SCE_SELECT_VERTEX) - if(em->selected.first && em->selected.last && - ((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) - event = pupmenu("Merge %t|At First %x6|At Last%x1|At Center%x3|At Cursor%x4|Collapse%x2"); - else if (em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT) - event = pupmenu("Merge %t|At First %x6|At Center%x3|At Cursor%x4|Collapse%x2"); - else if (em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT) - event = pupmenu("Merge %t|At Last %x1|At Center%x3|At Cursor%x4|Collapse%x2"); - else event = pupmenu("Merge %t|At Center%x3|At Cursor%x4|Collapse%x2"); - else event = pupmenu("Merge %t|At Center%x3|At Cursor%x4|Collapse%x2"); + if(obedit && obedit->type == OB_MESH) { + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); + EnumPropertyItem *item= NULL; + int totitem= 0; - BKE_mesh_end_editmesh(obedit->data, em); -#endif + if(em->selectmode & SCE_SELECT_VERTEX) { + if(em->selected.first && em->selected.last && + ((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) { + RNA_enum_item_add(&item, &totitem, &merge_type_items[0]); + RNA_enum_item_add(&item, &totitem, &merge_type_items[1]); + } + else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT) + RNA_enum_item_add(&item, &totitem, &merge_type_items[1]); + else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT) + RNA_enum_item_add(&item, &totitem, &merge_type_items[0]); + } + + RNA_enum_item_add(&item, &totitem, &merge_type_items[2]); + RNA_enum_item_add(&item, &totitem, &merge_type_items[3]); + RNA_enum_item_add(&item, &totitem, &merge_type_items[4]); + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; + } - return merge_type_items; + return NULL; } void MESH_OT_merge(wmOperatorType *ot) @@ -5841,7 +5850,7 @@ void MESH_OT_merge(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", merge_type_items, 6, "Type", "Merge method to use."); + prop= RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use."); RNA_def_enum_funcs(prop, merge_type_itemf); RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge."); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 6bc2f240859..cfe8dd4352d 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -75,7 +75,7 @@ static int vertex_specials_invoke(bContext *C, wmOperator *op, wmEvent *event) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); uiItemO(layout, "Remove Doubles", 0, "MESH_OT_remove_doubles"); - uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); // mergmenu(em) + uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth"); uiItemO(layout, "Select Vertex Path", 0, "MESH_OT_select_vertex_path"); //uiItemO(layout, "Blend From Shape", 0, "MESH_OT_blend_from_shape"); @@ -387,6 +387,7 @@ void ED_keymap_mesh(wmWindowManager *wm) WM_keymap_add_item(keymap, "MESH_OT_colors_mirror",EIGHTKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_rip",VKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); /* add/remove */ WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0a9ed945c1d..9ea8907e172 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1379,20 +1379,21 @@ static EnumPropertyItem prop_clear_parent_types[] = { /* note, poll should check for editable scene */ static int parent_clear_exec(bContext *C, wmOperator *op) { + int type= RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(RNA_enum_is_equal(op->ptr, "type", "CLEAR")) { + if(type == 0) { ob->parent= NULL; } - if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_KEEP_TRANSFORM")) { + else if(type == 1) { ob->parent= NULL; ob->track= NULL; ED_object_apply_obmat(ob); } - if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_INVERSE")) { + else if(type == 2) Mat4One(ob->parentinv); - } + ob->recalc |= OB_RECALC; } CTX_DATA_END; @@ -1435,6 +1436,8 @@ static EnumPropertyItem prop_clear_track_types[] = { /* note, poll should check for editable scene */ static int object_track_clear_exec(bContext *C, wmOperator *op) { + int type= RNA_enum_get(op->ptr, "type"); + if(CTX_data_edit_object(C)) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); return OPERATOR_CANCELLED; @@ -1443,9 +1446,8 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) ob->track= NULL; ob->recalc |= OB_RECALC; - if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_KEEP_TRANSFORM")) { + if(type == 1) ED_object_apply_obmat(ob); - } } CTX_DATA_END; @@ -2663,8 +2665,9 @@ static EnumPropertyItem prop_make_track_types[] = { static int track_set_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); + int type= RNA_enum_get(op->ptr, "type"); - if(RNA_enum_is_equal(op->ptr, "type", "TRACKTO")){ + if(type == 1) { bConstraint *con; bTrackToConstraint *data; @@ -2688,7 +2691,7 @@ static int track_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - else if(RNA_enum_is_equal(op->ptr, "type", "LOCKTRACK")){ + else if(type == 2) { bConstraint *con; bLockTrackConstraint *data; @@ -2712,7 +2715,7 @@ static int track_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - else if(RNA_enum_is_equal(op->ptr, "type", "OLDTRACK")){ + else { CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if(base!=BASACT) { base->object->track= BASACT->object; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index a030603996c..868897b76ac 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -122,11 +122,6 @@ EnumPropertyItem sequencer_prop_effect_types[] = { }; /* mute operator */ -EnumPropertyItem sequencer_prop_operate_types[] = { /* better name? */ - {SEQ_SELECTED, "SELECTED", 0, "Selected", ""}, - {SEQ_UNSELECTED, "UNSELECTED", 0, "Unselected ", ""}, - {0, NULL, 0, NULL, NULL} -}; EnumPropertyItem prop_side_types[] = { {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""}, @@ -1491,8 +1486,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) if(ed==NULL) return OPERATOR_CANCELLED; - selected= RNA_enum_is_equal(op->ptr, "type", "SELECTED"); - + selected= !RNA_boolean_get(op->ptr, "unselected"); for(seq= ed->seqbasep->first; seq; seq= seq->next) { if ((seq->flag & SEQ_LOCK)==0) { @@ -1528,7 +1522,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", sequencer_prop_operate_types, SEQ_SELECTED, "Type", ""); + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips."); } @@ -1543,8 +1537,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) if(ed==NULL) return OPERATOR_CANCELLED; - selected= RNA_enum_is_equal(op->ptr, "type", "SELECTED"); - + selected= !RNA_boolean_get(op->ptr, "unselected"); for(seq= ed->seqbasep->first; seq; seq= seq->next) { if ((seq->flag & SEQ_LOCK)==0) { @@ -1580,7 +1573,7 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", sequencer_prop_operate_types, SEQ_SELECTED, "Type", ""); + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "UnMute unselected rather than selected strips."); } diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 82047272049..f561fb2ac43 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -116,11 +116,11 @@ void sequencer_keymap(wmWindowManager *wm) RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD); - RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_SELECTED); - RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED); + WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); - RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", SEQ_SELECTED); - RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED); + WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1); WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", HKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 70dde481018..112847272e5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -203,10 +203,10 @@ void view3d_keymap(wmWindowManager *wm) /* selection*/ WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1); WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "type", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "deselect", 1); WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index fedf3a30181..2537982210a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -715,12 +715,6 @@ void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short } -static EnumPropertyItem lasso_select_types[] = { - {0, "SELECT", 0, "Select", ""}, - {1, "DESELECT", 0, "Deselect", ""}, - {0, NULL, 0, NULL, NULL} -}; - /* lasso operator gives properties, but since old code works with short array we convert */ @@ -747,7 +741,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) /* setup view context for argument to callbacks */ view3d_set_viewcontext(C, &vc); - select= RNA_enum_is_equal(op->ptr, "type", "SELECT"); + select= !RNA_boolean_get(op->ptr, "deselect"); view3d_lasso_select(C, &vc, mcords, i, select); return OPERATOR_FINISHED; @@ -769,7 +763,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_enum(ot->srna, "type", lasso_select_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items."); } @@ -1528,11 +1522,6 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) /* *****************Selection Operators******************* */ -static EnumPropertyItem prop_select_types[] = { - {0, "EXCLUSIVE", 0, "Exclusive", ""}, - {1, "EXTEND", 0, "Extend", ""}, - {0, NULL, 0, NULL, NULL} -}; /* ****** Border Select ****** */ void VIEW3D_OT_select_border(wmOperatorType *ot) @@ -1558,7 +1547,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); - RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everyting first."); } /* ****** Mouse Select ****** */ @@ -1567,7 +1556,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit= CTX_data_edit_object(C); - short extend= RNA_enum_is_equal(op->ptr, "type", "EXTEND"); + short extend= RNA_boolean_get(op->ptr, "extend"); view3d_operator_needs_opengl(C); @@ -1605,7 +1594,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everyting first."); } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 97fb3531718..dcd34011eef 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -109,10 +109,6 @@ TransformModeItem transform_modes[] = static int select_orientation_exec(bContext *C, wmOperator *op) { int orientation = RNA_enum_get(op->ptr, "orientation"); - int custom_index= RNA_int_get(op->ptr, "custom_index");; - - if(orientation == V3D_MANIP_CUSTOM) - orientation += custom_index; BIF_selectTransformOrientationValue(C, orientation); @@ -126,20 +122,26 @@ static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event pup= uiPupMenuBegin(C, "Orientation", 0); layout= uiPupMenuLayout(pup); - BIF_menuTransformOrientation(C, layout, NULL); + uiItemsEnumO(layout, "TFM_OT_select_orientation", "orientation"); uiPupMenuEnd(C, pup); return OPERATOR_CANCELLED; } +static EnumPropertyItem *select_orientation_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + *free= 1; + return BIF_enumTransformOrientation(C); +} + void TFM_OT_select_orientation(struct wmOperatorType *ot) { + PropertyRNA *prop; static EnumPropertyItem orientation_items[]= { {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""}, {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""}, {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""}, {V3D_MANIP_VIEW, "VIEW", 0, "View", ""}, - {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", ""}, {0, NULL, 0, NULL, NULL}}; /* identifiers */ @@ -151,8 +153,8 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot) ot->exec = select_orientation_exec; ot->poll = ED_operator_areaactive; - RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_CUSTOM, "Orientation", "DOC_BROKEN"); - RNA_def_int(ot->srna, "custom_index", 0, 0, INT_MAX, "Custom Index", "", 0, INT_MAX); + prop= RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_GLOBAL, "Orientation", "DOC_BROKEN"); + RNA_def_enum_funcs(prop, select_orientation_itemf); } static void transformops_exit(bContext *C, wmOperator *op) diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 1e065de94e1..f3b373f0e48 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -59,6 +59,8 @@ #include "UI_interface.h" +#include "RNA_define.h" + #include "transform.h" /* *********************** TransSpace ************************** */ @@ -354,19 +356,37 @@ void BIF_selectTransformOrientationValue(bContext *C, int orientation) { v3d->twmode = orientation; } -void BIF_menuTransformOrientation(bContext *C, uiLayout *layout, void *arg) +EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) { ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; - TransformOrientation *ts; - int i= V3D_MANIP_CUSTOM; + TransformOrientation *ts = transform_spaces->first; + EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""}; + EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""}; + EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""}; + EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""}; + EnumPropertyItem sepr = {0, "", 0, NULL, NULL}; + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item= NULL; + int i = V3D_MANIP_CUSTOM, totitem= 0; + + RNA_enum_item_add(&item, &totitem, &global); + RNA_enum_item_add(&item, &totitem, &normal); + RNA_enum_item_add(&item, &totitem, &local); + RNA_enum_item_add(&item, &totitem, &view); + + if(ts) + RNA_enum_item_add(&item, &totitem, &sepr); + + for(; ts; ts = ts->next) { + tmp.identifier = "CUSTOM"; + tmp.name= ts->name; + tmp.value = i++; + RNA_enum_item_add(&item, &totitem, &tmp); + } - uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL); - uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL); - uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL); - uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW); + RNA_enum_item_end(&item, &totitem); - for(ts = transform_spaces->first; ts; ts = ts->next) - uiItemIntO(layout, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++); + return item; } char * BIF_menustringTransformOrientation(const bContext *C, char *title) { |