diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-10-18 20:15:06 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-10-18 20:31:00 +0300 |
commit | 69b4c9f6e5ea3ececde73ba8d6199e6ce797d956 (patch) | |
tree | 08c11598948db7289d02b666e22a9ba8391784fa /source/blender/editors | |
parent | c470620c169953e5c45ce3221d7f3dc3638814b9 (diff) | |
parent | 32145c4a88f9b4947e22e51b9f17459fe6eacd79 (diff) |
Merge branch 'blender2.8' into topbar
Diffstat (limited to 'source/blender/editors')
163 files changed, 1000 insertions, 881 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 01575bff3c2..26ba61f0f20 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -682,7 +682,7 @@ typedef enum eRearrangeAnimChan_Mode { } eRearrangeAnimChan_Mode; /* defines for rearranging channels */ -static EnumPropertyItem prop_animchannel_rearrange_types[] = { +static const EnumPropertyItem prop_animchannel_rearrange_types[] = { {REARRANGE_ANIMCHAN_TOP, "TOP", 0, "To Top", ""}, {REARRANGE_ANIMCHAN_UP, "UP", 0, "Up", ""}, {REARRANGE_ANIMCHAN_DOWN, "DOWN", 0, "Down", ""}, @@ -1745,7 +1745,7 @@ static void ANIM_OT_channels_delete(wmOperatorType *ot) /* ********************** Set Flags Operator *********************** */ /* defines for setting animation-channel flags */ -static EnumPropertyItem prop_animchannel_setflag_types[] = { +static const EnumPropertyItem prop_animchannel_setflag_types[] = { {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""}, {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, {ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""}, @@ -1755,7 +1755,7 @@ static EnumPropertyItem prop_animchannel_setflag_types[] = { /* defines for set animation-channel settings */ // TODO: could add some more types, but those are really quite dependent on the mode... -static EnumPropertyItem prop_animchannel_settings_types[] = { +static const EnumPropertyItem prop_animchannel_settings_types[] = { {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, {0, NULL, 0, NULL, NULL} @@ -2457,8 +2457,8 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) bAnimContext ac; rcti rect; short selectmode = 0; - int gesture_mode; - bool extend; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -2466,17 +2466,17 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); - - gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - extend = RNA_boolean_get(op->ptr, "extend"); - if (!extend) + if (!extend) { ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_CLEAR); + } - if (gesture_mode == GESTURE_MODAL_SELECT) + if (select) { selectmode = ACHANNEL_SETFLAG_ADD; - else + } + else { selectmode = ACHANNEL_SETFLAG_CLEAR; + } /* apply borderselect animation channels */ borderselect_anim_channels(&ac, &rect, selectmode); @@ -2495,10 +2495,10 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->description = "Select all animation channels within the specified region"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = animchannels_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = animedit_poll_channels_nla_tweakmode_off; @@ -2506,7 +2506,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /* ******************* Rename Operator ***************************** */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 8cf0e203a41..b24f48a10f9 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1249,7 +1249,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) View2D *v2d = UI_view2d_fromcontext(C); ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; - int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + bool select = !RNA_boolean_get(op->ptr, "deselect"); bool extend = RNA_boolean_get(op->ptr, "extend"); rctf rect; @@ -1262,13 +1262,11 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) /* XXX marker context */ for (marker = markers->first; marker; marker = marker->next) { if (BLI_rctf_isect_x(&rect, marker->frame)) { - switch (gesture_mode) { - case GESTURE_MODAL_SELECT: - marker->flag |= SELECT; - break; - case GESTURE_MODAL_DESELECT: - marker->flag &= ~SELECT; - break; + if (select) { + marker->flag |= SELECT; + } + else { + marker->flag &= ~SELECT; } } else if (!extend) { @@ -1284,7 +1282,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) static int ed_marker_select_border_invoke_wrapper(bContext *C, wmOperator *op, const wmEvent *event) { - return ed_markers_opwrap_invoke_custom(C, op, event, WM_border_select_invoke); + return ed_markers_opwrap_invoke_custom(C, op, event, WM_gesture_border_invoke); } static void MARKER_OT_select_border(wmOperatorType *ot) @@ -1297,8 +1295,8 @@ static void MARKER_OT_select_border(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_marker_border_select_exec; ot->invoke = ed_marker_select_border_invoke_wrapper; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ed_markers_poll_markers_exist; @@ -1306,7 +1304,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /* *********************** (de)select all ***************** */ diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index fcdd45d4ac3..f22c8c5b403 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -318,10 +318,10 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) ot->description = "Interactively define frame range used for playback"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = previewrange_define_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_animview_active; diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 1a3d82e5002..dde531a6193 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -125,7 +125,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde * Create FModifier so that old scripts won't break * for now before 2.7 series -- (September 4, 2013) */ - add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); } else { /* add 2 keyframes so that user has something to work with @@ -767,7 +767,7 @@ EnumPropertyItem prop_driver_create_mapping_types[] = { }; /* Filtering callback for driver mapping types enum */ -static EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRNA *UNUSED(owner_ptr), PropertyRNA *UNUSED(owner_prop), bool *r_free) +static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRNA *UNUSED(owner_ptr), PropertyRNA *UNUSED(owner_prop), bool *r_free) { EnumPropertyItem *input = prop_driver_create_mapping_types; EnumPropertyItem *item = NULL; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 6bb73416fec..8d77460e197 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -736,7 +736,7 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active) /* 'Paste' the F-Modifier(s) from the buffer to the specified list * - replace: free all the existing modifiers to leave only the pasted ones */ -bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace) +bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *curve) { FModifier *fcm; bool ok = false; @@ -745,6 +745,8 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace) if (modifiers == NULL) return 0; + bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve); + /* if replacing the list, free the existing modifiers */ if (replace) free_fmodifiers(modifiers); @@ -753,6 +755,8 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace) for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) { /* make a copy of it */ FModifier *fcmN = copy_fmodifier(fcm); + + fcmN->curve = curve; /* make sure the new one isn't active, otherwise the list may get several actives */ fcmN->flag &= ~FMODIFIER_FLAG_ACTIVE; @@ -762,6 +766,10 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace) ok = 1; } + /* adding or removing the Cycles modifier requires an update to handles */ + if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) + calchandles_fcurve(curve); + /* did we succeed? */ return ok; } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 071c5fab9d7..97f53561bfe 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -885,14 +885,14 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float /* ------------------- */ -EnumPropertyItem rna_enum_keyframe_paste_offset_items[] = { +const EnumPropertyItem rna_enum_keyframe_paste_offset_items[] = { {KEYFRAME_PASTE_OFFSET_CFRA_START, "START", 0, "Frame Start", "Paste keys starting at current frame"}, {KEYFRAME_PASTE_OFFSET_CFRA_END, "END", 0, "Frame End", "Paste keys ending at current frame"}, {KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE, "RELATIVE", 0, "Frame Relative", "Paste keys relative to the current frame when copying"}, {KEYFRAME_PASTE_OFFSET_NONE, "NONE", 0, "No Offset", "Paste keys from original time"}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem rna_enum_keyframe_paste_merge_items[] = { +const EnumPropertyItem rna_enum_keyframe_paste_merge_items[] = { {KEYFRAME_PASTE_MERGE_MIX, "MIX", 0, "Mix", "Overlay existing with new keys"}, {KEYFRAME_PASTE_MERGE_OVER, "OVER_ALL", 0, "Overwrite All", "Replace all keys"}, {KEYFRAME_PASTE_MERGE_OVER_RANGE, "OVER_RANGE", 0, "Overwrite Range", "Overwrite keys in pasted range"}, diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ce1379f760d..da206ac9a64 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -727,7 +727,7 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ /* Dynamically populate an enum of Keying Sets */ -EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index bbc81f522fa..cff161d9d93 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -778,7 +778,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) void ARMATURE_OT_symmetrize(wmOperatorType *ot) { /* subset of 'rna_enum_symmetrize_direction_items' */ - static EnumPropertyItem arm_symmetrize_direction_items[] = { + static const EnumPropertyItem arm_symmetrize_direction_items[] = { {-1, "NEGATIVE_X", 0, "-X to +X", ""}, {+1, "POSITIVE_X", 0, "+X to -X", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 51b76563c72..ab9a3e068d0 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -265,7 +265,7 @@ typedef enum eCalcRollTypes { CALC_ROLL_CURSOR, } eCalcRollTypes; -static EnumPropertyItem prop_calc_roll_types[] = { +static const EnumPropertyItem prop_calc_roll_types[] = { {0, "", 0, N_("Positive"), ""}, {CALC_ROLL_TAN_POS_X, "POS_X", 0, "Local +X Tangent", ""}, {CALC_ROLL_TAN_POS_Z, "POS_Z", 0, "Local +Z Tangent", ""}, @@ -967,7 +967,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) void ARMATURE_OT_merge(wmOperatorType *ot) { - static EnumPropertyItem merge_types[] = { + static const EnumPropertyItem merge_types[] = { {1, "WITHIN_CHAIN", 0, "Within Chains", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 712689396ae..0d114206c6b 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -436,7 +436,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) void ARMATURE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[] = { + static const EnumPropertyItem axis_items[] = { {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 99907e9e6ae..51c9836c741 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -743,7 +743,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo } -static EnumPropertyItem prop_editarm_make_parent_types[] = { +static const EnumPropertyItem prop_editarm_make_parent_types[] = { {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""}, {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""}, {0, NULL, 0, NULL, NULL} @@ -864,7 +864,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) -static EnumPropertyItem prop_editarm_clear_parent_types[] = { +static const EnumPropertyItem prop_editarm_clear_parent_types[] = { {1, "CLEAR", 0, "Clear Parent", ""}, {2, "DISCONNECT", 0, "Disconnect Bone", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index cbf16d38f6b..49619e13065 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -809,7 +809,7 @@ enum { SIMEDBONE_LAYER, }; -static EnumPropertyItem prop_similar_types[] = { +static const EnumPropertyItem prop_similar_types[] = { {SIMEDBONE_CHILDREN, "CHILDREN", 0, "Children", ""}, {SIMEDBONE_CHILDREN_IMMEDIATE, "CHILDREN_IMMEDIATE", 0, "Immediate children", ""}, {SIMEDBONE_SIBLINGS, "SIBLINGS", 0, "Siblings", ""}, @@ -1122,7 +1122,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 41c1c73e49c..1de7b99c6d2 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -998,7 +998,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S * the ideal would be to call this function only at the beginning of the snap operation, * or at the beginning of the operator itself */ struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0, + CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0, CTX_wm_region(C), CTX_wm_view3d(C)); float mvalf[2] = {UNPACK2(dd->mval)}; diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 7a8b89899a7..db8db2a2ded 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -675,7 +675,7 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op) void POSE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[] = { + static const EnumPropertyItem axis_items[] = { {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index c492772b282..c9b1d8613a9 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -328,7 +328,7 @@ static int group_move_exec(bContext *C, wmOperator *op) void POSE_OT_group_move(wmOperatorType *ot) { - static EnumPropertyItem group_slot_move[] = { + static const EnumPropertyItem group_slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index f11168525c0..7261ed0a11c 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -530,7 +530,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) /* ----- */ /* can be called with C == NULL */ -static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; @@ -786,7 +786,7 @@ static int poselib_move_exec(bContext *C, wmOperator *op) void POSELIB_OT_pose_move(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem pose_lib_pose_move[] = { + static const EnumPropertyItem pose_lib_pose_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index e43212c7bde..77b19130189 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -592,7 +592,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) void POSE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} @@ -841,7 +841,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) void POSE_OT_select_grouped(wmOperatorType *ot) { - static EnumPropertyItem prop_select_grouped_types[] = { + static const EnumPropertyItem prop_select_grouped_types[] = { {POSE_SEL_SAME_LAYER, "LAYER", 0, "Layer", "Shared layers"}, {POSE_SEL_SAME_GROUP, "GROUP", 0, "Group", "Shared group"}, {POSE_SEL_SAME_KEYINGSET, "KEYINGSET", 0, "Keying Set", "All bones affected by active Keying Set"}, diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index f62073d56ef..e5331aff12b 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -136,7 +136,7 @@ typedef enum ePoseSlide_Channels { } ePoseSlide_Channels; /* Property enum for ePoseSlide_Channels */ -static EnumPropertyItem prop_channels_types[] = { +static const EnumPropertyItem prop_channels_types[] = { {PS_TFM_ALL, "ALL", 0, "All Properties", "All properties, including transforms, bendy bone shape, and custom properties"}, {PS_TFM_LOC, "LOC", 0, "Location", "Location only"}, @@ -155,7 +155,7 @@ typedef enum ePoseSlide_AxisLock { } ePoseSlide_AxisLock; /* Property enum for ePoseSlide_AxisLock */ -static EnumPropertyItem prop_axis_lock_types[] = { +static const EnumPropertyItem prop_axis_lock_types[] = { {0, "FREE", 0, "Free", "All axes are affected"}, {PS_LOCK_X, "X", 0, "X", "Only X-axis transforms are affected"}, {PS_LOCK_Y, "Y", 0, "Y", "Only Y-axis transforms are affected"}, @@ -1575,7 +1575,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) void POSE_OT_propagate(wmOperatorType *ot) { - static EnumPropertyItem terminate_items[] = { + static const EnumPropertyItem terminate_items[] = { {POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held", "Propagate pose to all keyframes after current frame that don't change (Default behavior)"}, {POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe", diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 6327dbb8fae..4757c896650 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3596,7 +3596,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) void CURVE_OT_spline_type_set(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {CU_POLY, "POLY", 0, "Poly", ""}, {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, // {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, @@ -3641,7 +3641,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) void CURVE_OT_handle_type_set(wmOperatorType *ot) { /* keep in sync with graphkeys_handle_type_items */ - static EnumPropertyItem editcurve_handle_type_items[] = { + static const EnumPropertyItem editcurve_handle_type_items[] = { {HD_AUTO, "AUTOMATIC", 0, "Automatic", ""}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {5, "ALIGNED", 0, "Aligned", ""}, @@ -4795,13 +4795,13 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat { Nurb *nu; - float minmax[2][3]; + float center[3]; float temp[3]; - bool nu_has_select = false; - + uint verts_len; bool changed = false; - INIT_MINMAX(minmax[0], minmax[1]); + zero_v3(center); + verts_len = 0; for (nu = editnurb->nurbs.first; nu; nu = nu->next) { int i; @@ -4810,8 +4810,8 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat for (i = 0, bezt = nu->bezt; i < nu->pntsu; i++, bezt++) { if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) { - minmax_v3v3_v3(UNPACK2(minmax), bezt->vec[1]); - nu_has_select = true; + add_v3_v3(center, bezt->vec[1]); + verts_len += 1; } } } @@ -4820,18 +4820,18 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat for (i = 0, bp = nu->bp; i < nu->pntsu; i++, bp++) { if (bp->f1 & SELECT) { - minmax_v3v3_v3(UNPACK2(minmax), bp->vec); - nu_has_select = true; + add_v3_v3(center, bp->vec); + verts_len += 1; } } } } - if (nu_has_select && ed_editcurve_extrude(cu, editnurb)) { - float ofs[3], center[3]; + if (verts_len && ed_editcurve_extrude(cu, editnurb)) { + float ofs[3]; int i; - mid_v3_v3v3(center, minmax[0], minmax[1]); + mul_v3_fl(center, 1.0f / (float)verts_len); sub_v3_v3v3(ofs, location_init, center); if ((cu->flag & CU_3D) == 0) { @@ -5017,7 +5017,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) const float mval[2] = {UNPACK2(event->mval)}; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), vc.scene, vc.scene_layer, 0, + CTX_data_main(C), vc.scene, vc.scene_layer, vc.engine, 0, vc.ar, vc.v3d); ED_transform_snap_object_project_view3d_mixed( @@ -5258,7 +5258,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS void CURVE_OT_cyclic_toggle(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {0, "CYCLIC_U", 0, "Cyclic U", ""}, {1, "CYCLIC_V", 0, "Cyclic V", ""}, {0, NULL, 0, NULL, NULL} @@ -5752,13 +5752,13 @@ static int curve_delete_exec(bContext *C, wmOperator *op) return retval; } -static EnumPropertyItem curve_delete_type_items[] = { +static const EnumPropertyItem curve_delete_type_items[] = { {CURVE_VERTEX, "VERT", 0, "Vertices", ""}, {CURVE_SEGMENT, "SEGMENT", 0, "Segments", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem *rna_curve_delete_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), +static const EnumPropertyItem *rna_curve_delete_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL; diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index f6bbff2f5d4..a1b73a54e3d 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -805,7 +805,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) const float radius_range = cps->radius_max - cps->radius_min; Nurb *nu = MEM_callocN(sizeof(Nurb), __func__); - nu->pntsv = 1; + nu->pntsv = 0; nu->resolu = cu->resolu; nu->resolv = cu->resolv; nu->flag |= CU_SMOOTH; diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index cad70443657..02b8970731c 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1192,7 +1192,7 @@ enum { SIM_CMP_LT, }; -static EnumPropertyItem curve_prop_similar_compare_types[] = { +static const EnumPropertyItem curve_prop_similar_compare_types[] = { {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""}, {SIM_CMP_GT, "GREATER", 0, "Greater", ""}, {SIM_CMP_LT, "LESS", 0, "Less", ""}, @@ -1207,7 +1207,7 @@ enum { SIMCURHAND_DIRECTION, }; -static EnumPropertyItem curve_prop_similar_types[] = { +static const EnumPropertyItem curve_prop_similar_types[] = { {SIMCURHAND_TYPE, "TYPE", 0, "Type", ""}, {SIMCURHAND_RADIUS, "RADIUS", 0, "Radius", ""}, {SIMCURHAND_WEIGHT, "WEIGHT", 0, "Weight", ""}, diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index e6447bf100c..f5a0b225974 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -564,7 +564,7 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ /******************* set style operator ********************/ -static EnumPropertyItem style_items[] = { +static const EnumPropertyItem style_items[] = { {CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""}, {CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""}, {CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, @@ -884,7 +884,7 @@ void FONT_OT_text_paste(wmOperatorType *ot) /************************ move operator ************************/ -static EnumPropertyItem move_type_items[] = { +static const EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -1176,7 +1176,7 @@ void FONT_OT_line_break(wmOperatorType *ot) /******************* delete operator **********************/ -static EnumPropertyItem delete_type_items[] = { +static const EnumPropertyItem delete_type_items[] = { {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, @@ -1597,7 +1597,7 @@ void ED_curve_editfont_free(Object *obedit) /********************** set case operator *********************/ -static EnumPropertyItem case_items[] = { +static const EnumPropertyItem case_items[] = { {CASE_LOWER, "LOWER", 0, "Lower", ""}, {CASE_UPPER, "UPPER", 0, "Upper", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 1cee8db792a..38927cf91e1 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1851,8 +1851,6 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even void GPENCIL_OT_brush_paint(wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Stroke Sculpt"; ot->idname = "GPENCIL_OT_brush_paint"; @@ -1869,7 +1867,9 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* properties */ - RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke"); diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index a85a3cdf6dd..7da472c6573 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -109,20 +109,20 @@ enum { }; /* RNA enum define */ -static EnumPropertyItem prop_gpencil_convertmodes[] = { +static const EnumPropertyItem prop_gpencil_convertmodes[] = { {GP_STROKECONVERT_PATH, "PATH", ICON_CURVE_PATH, "Path", "Animation path"}, {GP_STROKECONVERT_CURVE, "CURVE", ICON_CURVE_BEZCURVE, "Bezier Curve", "Smooth Bezier curve"}, {GP_STROKECONVERT_POLY, "POLY", ICON_MESH_DATA, "Polygon Curve", "Bezier curve with straight-line segments (vector handles)"}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem prop_gpencil_convert_timingmodes_restricted[] = { +static const EnumPropertyItem prop_gpencil_convert_timingmodes_restricted[] = { {GP_STROKECONVERT_TIMING_NONE, "NONE", 0, "No Timing", "Ignore timing"}, {GP_STROKECONVERT_TIMING_LINEAR, "LINEAR", 0, "Linear", "Simple linear timing"}, {0, NULL, 0, NULL, NULL}, }; -static EnumPropertyItem prop_gpencil_convert_timingmodes[] = { +static const EnumPropertyItem prop_gpencil_convert_timingmodes[] = { {GP_STROKECONVERT_TIMING_NONE, "NONE", 0, "No Timing", "Ignore timing"}, {GP_STROKECONVERT_TIMING_LINEAR, "LINEAR", 0, "Linear", "Simple linear timing"}, {GP_STROKECONVERT_TIMING_FULL, "FULL", 0, "Original", "Use the original timing, gaps included"}, @@ -131,7 +131,7 @@ static EnumPropertyItem prop_gpencil_convert_timingmodes[] = { {0, NULL, 0, NULL, NULL}, }; -static EnumPropertyItem *rna_GPConvert_mode_items(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), +static const EnumPropertyItem *rna_GPConvert_mode_items(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { if (RNA_boolean_get(ptr, "use_timing_data")) { diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 6980ad46241..93c9d21e717 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -302,7 +302,7 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_layer_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_LAYER_MOVE_UP, "UP", 0, "Up", ""}, {GP_LAYER_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -831,7 +831,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op) void GPENCIL_OT_stroke_arrange(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_STROKE_MOVE_UP, "UP", 0, "Bring Forward", ""}, {GP_STROKE_MOVE_DOWN, "DOWN", 0, "Send Backward", ""}, {GP_STROKE_MOVE_TOP, "TOP", 0, "Bring to Front", ""}, @@ -1165,7 +1165,7 @@ static int gp_brush_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_brush_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_BRUSH_MOVE_UP, "UP", 0, "Up", ""}, {GP_BRUSH_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL } @@ -1922,7 +1922,7 @@ static int gp_palettecolor_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_palettecolor_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_COLOR_MOVE_UP, "UP", 0, "Up", ""}, {GP_COLOR_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 4cd628b7fd3..a82148788c8 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -653,7 +653,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) void GPENCIL_OT_paste(wmOperatorType *ot) { - static EnumPropertyItem copy_type[] = { + static const EnumPropertyItem copy_type[] = { {GP_COPY_ONLY, "COPY", 0, "Copy", ""}, {GP_COPY_MERGE, "MERGE", 0, "Merge", ""}, {0, NULL, 0, NULL, NULL} @@ -1318,7 +1318,7 @@ static int gp_delete_exec(bContext *C, wmOperator *op) void GPENCIL_OT_delete(wmOperatorType *ot) { - static EnumPropertyItem prop_gpencil_delete_types[] = { + static const EnumPropertyItem prop_gpencil_delete_types[] = { {GP_DELETEOP_POINTS, "POINTS", 0, "Points", "Delete selected points and split strokes into segments"}, {GP_DELETEOP_STROKES, "STROKES", 0, "Strokes", "Delete selected strokes"}, {GP_DELETEOP_FRAME, "FRAME", 0, "Frame", "Delete active frame"}, @@ -1738,7 +1738,7 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op) */ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot) { - static EnumPropertyItem cyclic_type[] = { + static const EnumPropertyItem cyclic_type[] = { {GP_STROKE_CYCLIC_CLOSE, "CLOSE", 0, "Close all", ""}, {GP_STROKE_CYCLIC_OPEN, "OPEN", 0, "Open all", ""}, {GP_STROKE_CYCLIC_TOGGLE, "TOGGLE", 0, "Toggle", ""}, @@ -2000,7 +2000,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) void GPENCIL_OT_stroke_join(wmOperatorType *ot) { - static EnumPropertyItem join_type[] = { + static const EnumPropertyItem join_type[] = { {GP_STROKE_JOIN, "JOIN", 0, "Join", ""}, {GP_STROKE_JOINCOPY, "JOINCOPY", 0, "Join and Copy", ""}, {0, NULL, 0, NULL, NULL} @@ -2190,7 +2190,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) void GPENCIL_OT_reproject(wmOperatorType *ot) { - static EnumPropertyItem reproject_type[] = { + static const EnumPropertyItem reproject_type[] = { {GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar", "Reproject the strokes to end up on the same plane, as if drawn from the current viewpoint " "using 'Cursor' Stroke Placement"}, diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index a3734c56c59..04bcea02c9b 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -121,16 +121,22 @@ void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush); /* Layers Enums -------------------------------------- */ -struct EnumPropertyItem *ED_gpencil_layers_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); -struct EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); +const struct EnumPropertyItem *ED_gpencil_layers_enum_itemf( + struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, + bool *r_free); +const struct EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf( + struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, + bool *r_free); /* Enums of GP Brushes */ -EnumPropertyItem *ED_gpencil_brushes_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), - bool *r_free); +const EnumPropertyItem *ED_gpencil_brushes_enum_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), + bool *r_free); /* Enums of GP palettes */ -EnumPropertyItem *ED_gpencil_palettes_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), - bool *r_free); +const EnumPropertyItem *ED_gpencil_palettes_enum_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), + bool *r_free); /* ***************************************************** */ /* Operator Defines */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index e0751985bcd..0b4bdb9914d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2758,7 +2758,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* ------------------------------- */ -static EnumPropertyItem prop_gpencil_drawmodes[] = { +static const EnumPropertyItem prop_gpencil_drawmodes[] = { {GP_PAINTMODE_DRAW, "DRAW", 0, "Draw Freehand", "Draw freehand stroke(s)"}, {GP_PAINTMODE_DRAW_STRAIGHT, "DRAW_STRAIGHT", 0, "Draw Straight Lines", "Draw straight line segment(s)"}, {GP_PAINTMODE_DRAW_POLY, "DRAW_POLY", 0, "Draw Poly Line", "Click to place endpoints of straight line segments (connected)"}, @@ -2784,8 +2784,10 @@ void GPENCIL_OT_draw(wmOperatorType *ot) ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; /* settings for drawing */ + PropertyRNA *prop; ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements"); - RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); /* NOTE: wait for input is enabled by default, so that all UI code can work properly without needing users to know about this */ RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Wait for first click instead of painting immediately"); diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 2912a1ac4eb..07abab8af2e 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -371,7 +371,7 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op) void GPENCIL_OT_select_grouped(wmOperatorType *ot) { - static EnumPropertyItem prop_select_grouped_types[] = { + static const EnumPropertyItem prop_select_grouped_types[] = { {GP_SEL_SAME_LAYER, "LAYER", 0, "Layer", "Shared layers"}, {GP_SEL_SAME_COLOR, "COLOR", 0, "Color", "Shared colors"}, {0, NULL, 0, NULL, NULL} @@ -769,8 +769,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) const int my = RNA_int_get(op->ptr, "y"); const int radius = RNA_int_get(op->ptr, "radius"); - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const bool select = (gesture_mode == GESTURE_MODAL_SELECT); + bool select = !RNA_boolean_get(op->ptr, "deselect"); GP_SpaceConversion gsc = {NULL}; rcti rect = {0}; /* for bounding rect around circle (for quicky intersection testing) */ @@ -830,10 +829,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); + WM_operator_properties_gesture_circle_select(ot); } /* ********************************************** */ @@ -843,8 +839,7 @@ static int gpencil_border_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const bool select = (gesture_mode == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); GP_SpaceConversion gsc = {NULL}; @@ -936,10 +931,10 @@ void GPENCIL_OT_select_border(wmOperatorType *ot) ot->idname = "GPENCIL_OT_select_border"; /* callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = gpencil_border_select_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = gpencil_select_poll; @@ -947,7 +942,7 @@ void GPENCIL_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /* ********************************************** */ @@ -1056,9 +1051,8 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + /* properties */ + WM_operator_properties_gesture_lasso_select(ot); } /* ********************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index fae08bd771e..4023a343b22 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -309,7 +309,8 @@ int gp_active_palettecolor_poll(bContext *C) /* NOTE: These include an option to create a new layer and use that... */ /* Just existing layers */ -EnumPropertyItem *ED_gpencil_layers_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +const EnumPropertyItem *ED_gpencil_layers_enum_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *gpl; @@ -342,7 +343,8 @@ EnumPropertyItem *ED_gpencil_layers_enum_itemf(bContext *C, PointerRNA *UNUSED(p } /* Existing + Option to add/use new layer */ -EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *gpl; @@ -1104,7 +1106,7 @@ bool ED_gpencil_stroke_minmax( } /* Dynamic Enums of GP Brushes */ -EnumPropertyItem *ED_gpencil_brushes_enum_itemf( +const EnumPropertyItem *ED_gpencil_brushes_enum_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { @@ -1139,7 +1141,7 @@ EnumPropertyItem *ED_gpencil_brushes_enum_itemf( } /* Dynamic Enums of GP Palettes */ -EnumPropertyItem *ED_gpencil_palettes_enum_itemf( +const EnumPropertyItem *ED_gpencil_palettes_enum_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 797262c685b..77b2ce435c2 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -573,7 +573,7 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active); /* 'Paste' the F-Modifier(s) from the buffer to the specified list * - replace: free all the existing modifiers to leave only the pasted ones */ -bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace); +bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, struct FCurve *curve); /* ************************************************* */ /* ASSORTED TOOLS */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 07cdff687a3..4279e3d202c 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -222,7 +222,7 @@ int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks); struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName); /* Dynamically populate an enum of Keying Sets */ -struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); +const struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); /* Check if KeyingSet can be used in the current context */ bool ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 56a91d9846c..5e3c91e15ab 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -213,7 +213,7 @@ bool ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v) /* object_select.c */ void ED_object_select_linked_by_id(struct bContext *C, struct ID *id); -struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( +const struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 1e984c15b22..55a5869c331 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -35,6 +35,7 @@ #include "DNA_space_types.h" #include "DNA_view2d_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "BLI_compiler_attrs.h" @@ -93,7 +94,8 @@ void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, str void ED_area_exit(struct bContext *C, struct ScrArea *sa); int ED_screen_area_active(const struct bContext *C); void ED_screen_global_areas_create(const struct bContext *C, struct wmWindow *win); -void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, const Scene *scene); +void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene, + struct WorkSpace *workspace); void ED_area_tag_redraw(ScrArea *sa); void ED_area_tag_redraw_regiontype(ScrArea *sa, int type); void ED_area_tag_refresh(ScrArea *sa); @@ -122,7 +124,7 @@ void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *wi void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note); bool ED_screen_change(struct bContext *C, struct bScreen *sc); void ED_screen_update_after_scene_change(const struct bScreen *screen, struct Scene *scene_new); -void ED_screen_set_subwinactive(struct bContext *C, struct wmEvent *event); +void ED_screen_set_subwinactive(struct bContext *C, const struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable); void ED_screen_animation_timer_update(struct bScreen *screen, int redraws, int refresh); @@ -140,7 +142,8 @@ void ED_screen_preview_render(const struct bScreen *screen, int size_x, int s struct WorkSpace *ED_workspace_add( struct Main *bmain, const char *name, - SceneLayer *act_render_layer) ATTR_NONNULL(); + SceneLayer *act_render_layer, + struct ViewRender *view_render) ATTR_NONNULL(); bool ED_workspace_change( struct WorkSpace *workspace_new, struct bContext *C, diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h index b802694444b..2639130acc0 100644 --- a/source/blender/editors/include/ED_transform_snap_object_context.h +++ b/source/blender/editors/include/ED_transform_snap_object_context.h @@ -30,6 +30,7 @@ struct BMEdge; struct BMFace; struct ListBase; +struct RenderEngineType; struct Scene; struct SceneLayer; struct Main; @@ -42,11 +43,11 @@ struct bContext; /* ED_transform_snap_object_*** API */ -typedef enum SnapSelect { +typedef enum eSnapSelect { SNAP_ALL = 0, SNAP_NOT_SELECTED = 1, SNAP_NOT_ACTIVE = 2, -} SnapSelect; +} eSnapSelect; /** used for storing multiple hits */ struct SnapObjectHitDepth { @@ -75,9 +76,9 @@ struct SnapObjectParams { typedef struct SnapObjectContext SnapObjectContext; SnapObjectContext *ED_transform_snap_object_context_create( - struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, int flag); + struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, struct RenderEngineType *engine, int flag); SnapObjectContext *ED_transform_snap_object_context_create_view3d( - struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, int flag, + struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, struct RenderEngineType *engine, int flag, /* extra args for view3d */ const struct ARegion *ar, const struct View3D *v3d); void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 0dcfd68c0f1..b55703bff0e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -51,6 +51,7 @@ struct Nurb; struct Object; struct RV3DMatrixStore; struct RegionView3D; +struct RenderEngineType; struct Scene; struct SceneLayer; struct ScrArea; @@ -68,6 +69,7 @@ struct wmWindowManager; struct GPUFX; struct GPUOffScreen; struct GPUFXSettings; +struct WorkSpace; enum eGPUFXFlags; /* for derivedmesh drawing callbacks, for view3d_select, .... */ @@ -75,6 +77,7 @@ typedef struct ViewContext { struct Depsgraph *depsgraph; struct Scene *scene; struct SceneLayer *scene_layer; + struct RenderEngineType *engine; struct Object *obact; struct Object *obedit; struct ARegion *ar; @@ -369,9 +372,11 @@ void ED_draw_object_facemap(const struct EvaluationContext *eval_ctx, struct Sc bool ED_view3d_context_activate(struct bContext *C); void ED_view3d_draw_offscreen_init( - const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d); + const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct SceneLayer *sl, struct View3D *v3d); void ED_view3d_draw_offscreen( - const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4], + const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct SceneLayer *scene_layer, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname, struct GPUFX *fx, struct GPUFXSettings *fx_settings, struct GPUOffScreen *ofs); @@ -380,12 +385,14 @@ void ED_view3d_draw_setup_view( float viewmat[4][4], float winmat[4][4], const struct rcti *rect); struct ImBuf *ED_view3d_draw_offscreen_imbuf( - const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar, + const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct SceneLayer *scene_layer, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, bool draw_background, int alpha_mode, int samples, bool full_samples, const char *viewname, struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]); struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple( - const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct Object *camera, int width, int height, + const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct SceneLayer *scene_layer, struct Object *camera, int width, int height, unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, int samples, bool full_samples, const char *viewname, struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c7d9cb27149..a3471e5c599 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3346,7 +3346,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu uiBut *but = (uiBut *)but_p; /* see comment in ui_item_enum_expand, re: uiname */ - EnumPropertyItem *item, *item_array; + const EnumPropertyItem *item, *item_array; bool free; uiLayout *split, *column = NULL; @@ -3456,9 +3456,8 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu UI_block_layout_set_current(block, layout); if (free) { - MEM_freeN(item_array); + MEM_freeN((void *)item_array); } - BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); block->flag |= UI_BLOCK_IS_FLIP; } @@ -3489,7 +3488,7 @@ static uiBut *ui_def_but_rna( /* use rna values if parameters are not specified */ if ((proptype == PROP_ENUM) && ELEM(type, UI_BTYPE_MENU, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) { /* UI_BTYPE_MENU is handled a little differently here */ - EnumPropertyItem *item; + const EnumPropertyItem *item; int value; bool free; int i; @@ -3531,7 +3530,7 @@ static uiBut *ui_def_but_rna( } if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } } else { @@ -4493,7 +4492,7 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c } else { PointerRNA *ptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */ - EnumPropertyItem *item, *item_array; + const EnumPropertyItem *item, *item_array; bool do_free; RNA_property_enum_items_gettexted((bContext *)C, ptr, prop, &item_array, NULL, &do_free); @@ -4506,8 +4505,9 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c } } - if (do_free) - MEM_freeN(item_array); + if (do_free) { + MEM_freeN((void *)item_array); + } } } @@ -4581,7 +4581,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) va_list args; uiStringInfo *si; - EnumPropertyItem *items = NULL, *item = NULL; + const EnumPropertyItem *items = NULL, *item = NULL; int totitems; bool free_items = false; @@ -4760,8 +4760,9 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } va_end(args); - if (free_items && items) - MEM_freeN(items); + if (free_items && items) { + MEM_freeN((void *)items); + } } /* Program Init/Exit */ diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 2695d4c9dd9..5f690794028 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -92,7 +92,7 @@ enum { wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {EYE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {EYE_MODAL_SAMPLE_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""}, {EYE_MODAL_SAMPLE_BEGIN, "SAMPLE_BEGIN", 0, "Start Sampling", ""}, diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ce1aad370d5..e70350e54e3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2826,8 +2826,8 @@ static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char } static void ui_textedit_move( - uiBut *but, uiHandleButtonData *data, strCursorJumpDirection direction, - const bool select, strCursorJumpType jump) + uiBut *but, uiHandleButtonData *data, eStrCursorJumpDirection direction, + const bool select, eStrCursorJumpType jump) { const char *str = data->str; const int len = strlen(str); @@ -2903,7 +2903,7 @@ static void ui_textedit_move( } } -static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int direction, strCursorJumpType jump) +static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int direction, eStrCursorJumpType jump) { char *str = data->str; const int len = strlen(str); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index ac07756b372..d048324d35e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1195,7 +1195,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) else { Object *ob = CTX_data_active_object(C); SpaceImage *sima; - EnumPropertyItem *items = NULL; + const EnumPropertyItem *items = NULL; int tool = PAINT_TOOL_DRAW, mode = 0; /* XXX: this is not nice, should probably make brushes diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 8f69df9404d..485d0ed879e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -604,7 +604,7 @@ static void ui_item_enum_expand( uiBut *but; uiLayout *layout_radial = NULL; - EnumPropertyItem *item, *item_array; + const EnumPropertyItem *item, *item_array; const char *name; int itemw, icon, value; bool free; @@ -665,7 +665,7 @@ static void ui_item_enum_expand( UI_block_layout_set_current(block, layout); if (free) { - MEM_freeN(item_array); + MEM_freeN((void *)item_array); } } @@ -880,7 +880,7 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval) { - EnumPropertyItem *item; + const EnumPropertyItem *item; bool free; const char *name; @@ -893,7 +893,7 @@ static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, Prope } if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } return name; @@ -1079,7 +1079,7 @@ void uiItemsFullEnumO( BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM)); if (prop && RNA_property_type(prop) == PROP_ENUM) { - EnumPropertyItem *item_array = NULL; + const EnumPropertyItem *item_array = NULL; int totitem; bool free; @@ -1096,7 +1096,7 @@ void uiItemsFullEnumO( item_array, totitem); if (free) { - MEM_freeN(item_array); + MEM_freeN((void *)item_array); } /* intentionally don't touch UI_BLOCK_IS_FLIP here, @@ -1152,7 +1152,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char PointerRNA ptr; PropertyRNA *prop; - EnumPropertyItem *item; + const EnumPropertyItem *item; int value; bool free; @@ -1166,14 +1166,14 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) { if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str); return; } if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } } else { @@ -1273,7 +1273,7 @@ static void ui_item_rna_size( } else if (type == PROP_ENUM) { /* Find the longest enum item name, instead of using a dummy text! */ - EnumPropertyItem *item, *item_array; + const EnumPropertyItem *item, *item_array; bool free; RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free); @@ -1283,7 +1283,7 @@ static void ui_item_rna_size( } } if (free) { - MEM_freeN(item_array); + MEM_freeN((void *)item_array); } } } @@ -1502,7 +1502,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - EnumPropertyItem *item; + const EnumPropertyItem *item; int ivalue, a; bool free; @@ -1516,7 +1516,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr if (!RNA_enum_value_from_id(item, value, &ivalue)) { if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } ui_item_disabled(layout, propname); RNA_warning("enum property value not found: %s", value); @@ -1534,7 +1534,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr } if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } } @@ -1557,7 +1557,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname return; } else { - EnumPropertyItem *item; + const EnumPropertyItem *item; int totitem, i; bool free; uiLayout *split = uiLayoutSplit(layout, 0.0f, false); @@ -1590,7 +1590,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname } if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 7770e45e2ba..c3759e232b0 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1321,7 +1321,7 @@ static int ui_panel_drag_collapse_handler(bContext *C, const wmEvent *event, voi static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was_open) { wmWindow *win = CTX_wm_window(C); - wmEvent *event = win->eventstate; + const wmEvent *event = win->eventstate; uiPanelDragCollapseHandle *dragcol_data = MEM_mallocN(sizeof(*dragcol_data), __func__); dragcol_data->was_first_open = was_open; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 0a32b1febf4..5ef5b677f51 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1291,7 +1291,7 @@ static uiLayout *draw_modifier( /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ if (modifier_can_delete(md) && (!modifier_is_simulation(md) || - STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME))) + STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME))) { uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); } @@ -2019,7 +2019,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) uiBlock *block; uiBut *but; int icon, value; - EnumPropertyItem *item; + const EnumPropertyItem *item; int a; bool free; int w, h; @@ -2059,7 +2059,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) UI_block_direction_set(block, UI_DIR_DOWN); if (free) { - MEM_freeN(item); + MEM_freeN((void *)item); } return block; @@ -2072,7 +2072,7 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); IconViewMenuArgs *cb_args; - EnumPropertyItem *items; + const EnumPropertyItem *items; uiBlock *block; uiBut *but; int value, icon = ICON_NONE, tot_items; @@ -2100,7 +2100,7 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); if (free_items) { - MEM_freeN(items); + MEM_freeN((void *)items); } } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index fa2c1f25cfc..b271b0b5bc6 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1223,7 +1223,6 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) View2D *v2d = &ar->v2d; rctf rect; rctf cur_new = v2d->cur; - int gesture_mode; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* convert coordinates of rect to 'tot' rect coordinates */ @@ -1231,9 +1230,9 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view_rctf(v2d, &rect, &rect); /* check if zooming in/out view */ - gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); - if (gesture_mode == GESTURE_MODAL_IN) { + if (zoom_in) { /* zoom in: * - 'cur' rect will be defined by the coordinates of the border region * - just set the 'cur' rect to have the same coordinates as the border region @@ -1248,8 +1247,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) cur_new.ymax = rect.ymax; } } - else { /* if (gesture_mode == GESTURE_MODAL_OUT) */ - + else { /* zoom out: * - the current 'cur' rect coordinates are going to end up where the 'rect' ones are, * but the 'cur' rect coordinates will need to be adjusted to take in more of the view @@ -1289,15 +1287,15 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot) ot->idname = "VIEW2D_OT_zoom_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = view_borderzoom_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = view_zoom_poll; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border_zoom(ot); } #ifdef WITH_INPUT_NDOF @@ -1545,7 +1543,7 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot) ot->flag = OPTYPE_INTERNAL; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border(ot); } /* ********************************************************* */ diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index f9297c58cbb..9e79ca5b0e3 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -315,13 +315,13 @@ void WM_OT_collada_export(wmOperatorType *ot) { struct StructRNA *func = ot->srna; - static EnumPropertyItem prop_bc_export_mesh_type[] = { + static const EnumPropertyItem prop_bc_export_mesh_type[] = { {BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"}, {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem prop_bc_export_transformation_type[] = { + static const EnumPropertyItem prop_bc_export_transformation_type[] = { {BC_TRANSFORMATION_TYPE_MATRIX, "matrix", 0, "Matrix", "Use <matrix> to specify transformations"}, {BC_TRANSFORMATION_TYPE_TRANSROTLOC, "transrotloc", 0, "TransRotLoc", "Use <translate>, <rotate>, <scale> to specify transformations"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index d299bba93c3..c170fbde7dc 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1910,7 +1910,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) void MASK_OT_handle_type_set(wmOperatorType *ot) { - static EnumPropertyItem editcurve_handle_type_items[] = { + static const EnumPropertyItem editcurve_handle_type_items[] = { {HD_AUTO, "AUTO", 0, "Auto", ""}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {HD_ALIGN, "ALIGNED", 0, "Aligned Single", ""}, @@ -2152,7 +2152,7 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op) void MASK_OT_layer_move(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index a4268bddaf5..9f2f6de8a09 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -408,8 +408,9 @@ static int border_select_exec(bContext *C, wmOperator *op) rcti rect; rctf rectf; - int mode; - bool changed = false, extend; + bool changed = false; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* get rectangle from operator */ WM_operator_properties_border_to_rcti(op, &rect); @@ -417,9 +418,6 @@ static int border_select_exec(bContext *C, wmOperator *op) ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - mode = RNA_int_get(op->ptr, "gesture_mode"); - extend = RNA_boolean_get(op->ptr, "extend"); - /* do actual selection */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { MaskSpline *spline; @@ -439,8 +437,8 @@ static int border_select_exec(bContext *C, wmOperator *op) /* TODO: uw? */ if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) { - BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); - BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, mode == GESTURE_MODAL_SELECT); + BKE_mask_point_select_set(point, select); + BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select); } else if (!extend) { BKE_mask_point_select_set(point, false); @@ -471,16 +469,16 @@ void MASK_OT_select_border(wmOperatorType *ot) ot->idname = "MASK_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = border_select_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_UNDO; /* properties */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, short select) @@ -580,9 +578,7 @@ void MASK_OT_select_lasso(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + WM_operator_properties_gesture_lasso_select(ot); } /********************** circle select operator *********************/ @@ -608,15 +604,15 @@ static int circle_select_exec(bContext *C, wmOperator *op) int i; float zoomx, zoomy, offset[2], ellipse[2]; - int x, y, radius, width, height, mode; + int width, height; bool changed = false; /* get operator properties */ - x = RNA_int_get(op->ptr, "x"); - y = RNA_int_get(op->ptr, "y"); - radius = RNA_int_get(op->ptr, "radius"); + const int x = RNA_int_get(op->ptr, "x"); + const int y = RNA_int_get(op->ptr, "y"); + const int radius = RNA_int_get(op->ptr, "radius"); - mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); /* compute ellipse and position in unified coordinates */ ED_mask_get_size(sa, &width, &height); @@ -644,8 +640,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) MaskSplinePoint *point_deform = &points_array[i]; if (mask_spline_point_inside_ellipse(&point_deform->bezt, offset, ellipse)) { - BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); - BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, mode == GESTURE_MODAL_SELECT); + BKE_mask_point_select_set(point, select); + BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select); changed = true; } @@ -681,10 +677,7 @@ void MASK_OT_select_circle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); + WM_operator_properties_gesture_circle_select(ot); } static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 6b4f3516338..2af05a9ad8d 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -596,7 +596,7 @@ void MESH_OT_bevel(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem offset_type_items[] = { + static const EnumPropertyItem offset_type_items[] = { {BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"}, {BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"}, {BEVEL_AMT_DEPTH, "DEPTH", 0, "Depth", "Amount is perpendicular distance from original edge to bevel face"}, diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 9bc01687122..9b6c7c08b13 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -518,40 +518,46 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w ViewContext vc; BMVert *v1; BMIter iter; - float min[3], max[3]; - bool done = false; + float center[3]; + uint verts_len; bool use_proj; em_setup_viewcontext(C, &vc); + invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) && (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE)); - INIT_MINMAX(min, max); + zero_v3(center); + verts_len = 0; BM_ITER_MESH (v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) { - minmax_v3v3_v3(min, max, v1->co); - done = true; + add_v3_v3(center, v1->co); + verts_len += 1; } } /* call extrude? */ - if (done) { + if (verts_len != 0) { const char extrude_htype = edbm_extrude_htype_from_em_select(vc.em); const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source"); BMEdge *eed; - float vec[3], cent[3], mat[3][3]; + float mat[3][3]; + float vec[3], ofs[3]; float nor[3] = {0.0, 0.0, 0.0}; /* 2D normal calc */ const float mval_f[2] = {(float)event->mval[0], (float)event->mval[1]}; + mul_v3_fl(center, 1.0f / (float)verts_len); + /* check for edges that are half selected, use for rotation */ - done = false; + bool done = false; BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { float co1[2], co2[2]; @@ -592,21 +598,20 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w } /* center */ - mid_v3_v3v3(cent, min, max); - copy_v3_v3(min, cent); + copy_v3_v3(ofs, center); - mul_m4_v3(vc.obedit->obmat, min); /* view space */ - ED_view3d_win_to_3d_int(vc.v3d, vc.ar, min, event->mval, min); - mul_m4_v3(vc.obedit->imat, min); // back in object space + mul_m4_v3(vc.obedit->obmat, ofs); /* view space */ + ED_view3d_win_to_3d_int(vc.v3d, vc.ar, ofs, event->mval, ofs); + mul_m4_v3(vc.obedit->imat, ofs); // back in object space - sub_v3_v3(min, cent); + sub_v3_v3(ofs, center); /* calculate rotation */ unit_m3(mat); if (done) { float angle; - normalize_v3_v3(vec, min); + normalize_v3_v3(vec, ofs); angle = angle_normalized_v3v3(vec, nor); @@ -626,7 +631,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w if (rot_src) { EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3", - BM_ELEM_SELECT, cent, mat); + BM_ELEM_SELECT, center, mat); /* also project the source, for retopo workflow */ if (use_proj) @@ -635,22 +640,21 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w edbm_extrude_ex(vc.obedit, vc.em, extrude_htype, BM_ELEM_SELECT, true, true); EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3", - BM_ELEM_SELECT, cent, mat); + BM_ELEM_SELECT, center, mat); EDBM_op_callf(vc.em, op, "translate verts=%hv vec=%v", - BM_ELEM_SELECT, min); + BM_ELEM_SELECT, ofs); } else { - const float *curs = ED_view3d_cursor3d_get(vc.scene, vc.v3d); + const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d); BMOperator bmop; BMOIter oiter; - - copy_v3_v3(min, curs); - ED_view3d_win_to_3d_int(vc.v3d, vc.ar, min, event->mval, min); - invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); - mul_m4_v3(vc.obedit->imat, min); // back in object space + copy_v3_v3(center, cursor); + ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center); + + mul_m4_v3(vc.obedit->imat, center); // back in object space - EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min); + EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", center); BMO_op_exec(vc.em->bm, &bmop); BMO_ITER (v1, &oiter, bmop.slots_out, "vert.out", BM_VERT) { diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 49bfde77032..3498c6246d7 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -214,7 +214,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) void MESH_OT_intersect(struct wmOperatorType *ot) { - static EnumPropertyItem isect_mode_items[] = { + static const EnumPropertyItem isect_mode_items[] = { {ISECT_SEL, "SELECT", 0, "Self Intersect", "Self intersect selected faces"}, {ISECT_SEL_UNSEL, "SELECT_UNSELECT", 0, "Selected/Unselected", @@ -222,7 +222,7 @@ void MESH_OT_intersect(struct wmOperatorType *ot) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem isect_separate_items[] = { + static const EnumPropertyItem isect_separate_items[] = { {ISECT_SEPARATE_ALL, "ALL", 0, "All", "Separate all geometry from intersections"}, {ISECT_SEPARATE_CUT, "CUT", 0, "Cut", @@ -298,7 +298,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) void MESH_OT_intersect_boolean(struct wmOperatorType *ot) { - static EnumPropertyItem isect_boolean_operation_items[] = { + static const EnumPropertyItem isect_boolean_operation_items[] = { {BMESH_ISECT_BOOLEAN_ISECT, "INTERSECT", 0, "Intersect", ""}, {BMESH_ISECT_BOOLEAN_UNION, "UNION", 0, "Union", ""}, {BMESH_ISECT_BOOLEAN_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 433163b2fab..c0501078424 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -274,6 +274,8 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f); static void knifetool_free_bmbvh(KnifeTool_OpData *kcd); +static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event); + static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *kcd) { char header[UI_MAX_DRAW_STR]; @@ -2679,6 +2681,7 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) { const bool only_select = RNA_boolean_get(op->ptr, "only_selected"); const bool cut_through = !RNA_boolean_get(op->ptr, "use_occlude_geometry"); + const bool wait_for_input = RNA_boolean_get(op->ptr, "wait_for_input"); KnifeTool_OpData *kcd; @@ -2706,6 +2709,18 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) knifetool_update_mval_i(kcd, event->mval); + if (wait_for_input == false) { + /* Avoid copy-paste logic. */ + wmEvent event_modal = { + .prevval = KM_NOTHING, + .type = EVT_MODAL_MAP, + .val = KNF_MODAL_ADD_CUT, + }; + int ret = knifetool_modal(C, op, &event_modal); + BLI_assert(ret == OPERATOR_RUNNING_MODAL); + UNUSED_VARS_NDEBUG(ret); + } + knife_update_header(C, op, kcd); return OPERATOR_RUNNING_MODAL; @@ -2713,7 +2728,7 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {KNF_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {KNF_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {KNF_MODAL_MIDPOINT_ON, "SNAP_MIDPOINTS_ON", 0, "Snap To Midpoints On", ""}, @@ -2973,8 +2988,13 @@ void MESH_OT_knife_tool(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + /* properties */ + PropertyRNA *prop; RNA_def_boolean(ot->srna, "use_occlude_geometry", true, "Occlude Geometry", "Only cut the front most geometry"); RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only cut selected geometry"); + + prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7fe4e58d2e0..4e0be704298 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -970,7 +970,7 @@ static int unified_findnearest( /* **************** SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */ -static EnumPropertyItem prop_similar_compare_types[] = { +static const EnumPropertyItem prop_similar_compare_types[] = { {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""}, {SIM_CMP_GT, "GREATER", 0, "Greater", ""}, {SIM_CMP_LT, "LESS", 0, "Less", ""}, @@ -978,7 +978,7 @@ static EnumPropertyItem prop_similar_compare_types[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem prop_similar_types[] = { +static const EnumPropertyItem prop_similar_types[] = { {SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""}, {SIMVERT_FACE, "FACE", 0, "Amount of Adjacent Faces", ""}, {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, @@ -1152,7 +1152,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) else return similar_face_select_exec(C, op); } -static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), +static const EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *obedit; @@ -1347,14 +1347,14 @@ void MESH_OT_select_mode(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem elem_items[] = { + static const EnumPropertyItem elem_items[] = { {SCE_SELECT_VERTEX, "VERT", ICON_VERTEXSEL, "Vertices", ""}, {SCE_SELECT_EDGE, "EDGE", ICON_EDGESEL, "Edges", ""}, {SCE_SELECT_FACE, "FACE", ICON_FACESEL, "Faces", ""}, {0, NULL, 0, NULL, NULL}, }; - static EnumPropertyItem actions_items[] = { + static const EnumPropertyItem actions_items[] = { {0, "DISABLE", 0, "Disable", "Disable selected markers"}, {1, "ENABLE", 0, "Enable", "Enable selected markers"}, {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"}, @@ -3820,14 +3820,14 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) void MESH_OT_select_axis(wmOperatorType *ot) { - static EnumPropertyItem axis_mode_items[] = { + static const EnumPropertyItem axis_mode_items[] = { {0, "POSITIVE", 0, "Positive Axis", ""}, {1, "NEGATIVE", 0, "Negative Axis", ""}, {-1, "ALIGNED", 0, "Aligned Axis", ""}, {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem axis_items_xyz[] = { + static const EnumPropertyItem axis_items_xyz[] = { {0, "X_AXIS", 0, "X Axis", ""}, {1, "Y_AXIS", 0, "Y Axis", ""}, {2, "Z_AXIS", 0, "Z Axis", ""}, diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b6434e58b1e..d80cca1071f 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -116,7 +116,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) } /* Note, these values must match delete_mesh() event values */ -static EnumPropertyItem prop_mesh_cornervert_types[] = { +static const EnumPropertyItem prop_mesh_cornervert_types[] = { {SUBD_CORNER_INNERVERT, "INNERVERT", 0, "Inner Vert", ""}, {SUBD_CORNER_PATH, "PATH", 0, "Path", ""}, {SUBD_CORNER_STRAIGHT_CUT, "STRAIGHT_CUT", 0, "Straight Cut", ""}, @@ -175,7 +175,7 @@ struct EdgeRingOpSubdProps { static void mesh_operator_edgering_props(wmOperatorType *ot, const int cuts_min, const int cuts_default) { /* Note, these values must match delete_mesh() event values */ - static EnumPropertyItem prop_subd_edgering_types[] = { + static const EnumPropertyItem prop_subd_edgering_types[] = { {SUBD_RING_INTERP_LINEAR, "LINEAR", 0, "Linear", ""}, {SUBD_RING_INTERP_PATH, "PATH", 0, "Blend Path", ""}, {SUBD_RING_INTERP_SURF, "SURFACE", 0, "Blend Surface", ""}, @@ -309,7 +309,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) ED_view3d_init_mats_rv3d(obedit, ar->regiondata); struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0, + CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0, ar, CTX_wm_view3d(C)); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -395,7 +395,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) void MESH_OT_delete(wmOperatorType *ot) { - static EnumPropertyItem prop_mesh_delete_types[] = { + static const EnumPropertyItem prop_mesh_delete_types[] = { {MESH_DELETE_VERT, "VERT", 0, "Vertices", ""}, {MESH_DELETE_EDGE, "EDGE", 0, "Edges", ""}, {MESH_DELETE_FACE, "FACE", 0, "Faces", ""}, @@ -2271,7 +2271,7 @@ static int edbm_merge_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem merge_type_items[] = { +static const EnumPropertyItem merge_type_items[] = { {MESH_MERGE_FIRST, "FIRST", 0, "At First", ""}, {MESH_MERGE_LAST, "LAST", 0, "At Last", ""}, {MESH_MERGE_CENTER, "CENTER", 0, "At Center", ""}, @@ -2280,7 +2280,7 @@ static EnumPropertyItem merge_type_items[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *obedit; EnumPropertyItem *item = NULL; @@ -2543,7 +2543,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em; @@ -2695,7 +2695,7 @@ void MESH_OT_solidify(wmOperatorType *ot) #define KNIFE_MIDPOINT 2 #define KNIFE_MULTICUT 3 -static EnumPropertyItem knife_items[] = { +static const EnumPropertyItem knife_items[] = { {KNIFE_EXACT, "EXACT", 0, "Exact", ""}, {KNIFE_MIDPOINT, "MIDPOINTS", 0, "Midpoints", ""}, {KNIFE_MULTICUT, "MULTICUT", 0, "Multicut", ""}, @@ -2981,8 +2981,6 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) void MESH_OT_knife_cut(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name = "Knife Cut"; ot->description = "Cut selected edges and faces into parts"; ot->idname = "MESH_OT_knife_cut"; @@ -2995,10 +2993,13 @@ void MESH_OT_knife_cut(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + + /* properties */ + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", ""); - prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, BC_NUMCURSORS, "Cursor", "", 0, BC_NUMCURSORS); @@ -3383,7 +3384,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) void MESH_OT_separate(wmOperatorType *ot) { - static EnumPropertyItem prop_separate_types[] = { + static const EnumPropertyItem prop_separate_types[] = { {MESH_SEPARATE_SELECTED, "SELECTED", 0, "Selection", ""}, {MESH_SEPARATE_MATERIAL, "MATERIAL", 0, "By Material", ""}, {MESH_SEPARATE_LOOSE, "LOOSE", 0, "By loose parts", ""}, @@ -3849,7 +3850,7 @@ static int edbm_poke_face_exec(bContext *C, wmOperator *op) void MESH_OT_poke(wmOperatorType *ot) { - static EnumPropertyItem poke_center_modes[] = { + static const EnumPropertyItem poke_center_modes[] = { {BMOP_POKE_MEAN_WEIGHTED, "MEAN_WEIGHTED", 0, "Weighted Mean", "Weighted Mean Face Center"}, {BMOP_POKE_MEAN, "MEAN", 0, "Mean", "Mean Face Center"}, {BMOP_POKE_BOUNDS, "BOUNDS", 0, "Bounds", "Face Bounds Center"}, @@ -5151,7 +5152,7 @@ static void edbm_sort_elements_ui(bContext *C, wmOperator *op) void MESH_OT_sort_elements(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", "Sort selected elements from farthest to nearest one in current view"}, {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", @@ -5168,7 +5169,7 @@ void MESH_OT_sort_elements(wmOperatorType *ot) {0, NULL, 0, NULL, NULL}, }; - static EnumPropertyItem elem_items[] = { + static const EnumPropertyItem elem_items[] = { {BM_VERT, "VERT", 0, "Vertices", ""}, {BM_EDGE, "EDGE", 0, "Edges", ""}, {BM_FACE, "FACE", 0, "Faces", ""}, @@ -5425,7 +5426,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) void MESH_OT_bridge_edge_loops(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {MESH_BRIDGELOOP_SINGLE, "SINGLE", 0, "Open Loop", ""}, {MESH_BRIDGELOOP_CLOSED, "CLOSED", 0, "Closed Loop", ""}, {MESH_BRIDGELOOP_PAIRS, "PAIRS", 0, "Loop Pairs", ""}, diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 47d354ac72a..175b40d72ff 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -188,7 +188,7 @@ enum { SIMMBALL_ROTATION }; -static EnumPropertyItem prop_similar_types[] = { +static const EnumPropertyItem prop_similar_types[] = { {SIMMBALL_TYPE, "TYPE", 0, "Type", ""}, {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""}, {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""}, diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 7451268eac9..936f9b346b4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -125,7 +125,7 @@ /* this is an exact copy of the define in rna_lamp.c * kept here because of linking order. * Icons are only defined here */ -EnumPropertyItem rna_enum_lamp_type_items[] = { +const EnumPropertyItem rna_enum_lamp_type_items[] = { {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"}, {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"}, {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"}, @@ -135,7 +135,7 @@ EnumPropertyItem rna_enum_lamp_type_items[] = { }; /* copy from rna_object_force.c */ -static EnumPropertyItem field_type_items[] = { +static const EnumPropertyItem field_type_items[] = { {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""}, {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""}, {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""}, @@ -1073,7 +1073,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) group = (Group *)BKE_libblock_find_name(ID_GR, name); if (0 == RNA_struct_property_is_set(op->ptr, "location")) { - wmEvent *event = CTX_wm_window(C)->eventstate; + const wmEvent *event = CTX_wm_window(C)->eventstate; ARegion *ar = CTX_wm_region(C); const int mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; @@ -1459,8 +1459,9 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob_dst->totcol = 0; } - BKE_collection_object_add_from(scene, ob_src, ob_dst); + BKE_collection_object_add_from(scene, base->object, ob_dst); base_dst = BKE_scene_layer_base_find(sl, ob_dst); + BLI_assert(base_dst != NULL); BKE_scene_object_base_flag_sync_from_base(base_dst); @@ -1627,7 +1628,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) /**************************** Convert **************************/ -static EnumPropertyItem convert_target_items[] = { +static const EnumPropertyItem convert_target_items[] = { {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""}, {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Text", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 1a4abec4d20..0174a307c16 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -89,7 +89,7 @@ typedef struct BakeAPIRender { ReportList *reports; ListBase selected_objects; - ScenePassType pass_type; + eScenePassType pass_type; int pass_filter; int margin; @@ -103,7 +103,7 @@ typedef struct BakeAPIRender { float cage_extrusion; int normal_space; - BakeNormalSwizzle normal_swizzle[3]; + eBakeNormalSwizzle normal_swizzle[3]; char uv_layer[MAX_CUSTOMDATA_LAYER_NAME]; char custom_cage[MAX_NAME]; @@ -342,7 +342,7 @@ static bool write_external_bake_pixels( return ok; } -static bool is_noncolor_pass(ScenePassType pass_type) +static bool is_noncolor_pass(eScenePassType pass_type) { return ELEM(pass_type, SCE_PASS_Z, @@ -433,7 +433,7 @@ static bool bake_object_check(Scene *scene, Object *ob, ReportList *reports) return true; } -static bool bake_pass_filter_check(ScenePassType pass_type, const int pass_filter, ReportList *reports) +static bool bake_pass_filter_check(eScenePassType pass_type, const int pass_filter, ReportList *reports) { switch (pass_type) { case SCE_PASS_COMBINED: @@ -636,10 +636,10 @@ static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, static int bake( Render *re, Main *bmain, Depsgraph *graph, Scene *scene, Object *ob_low, ListBase *selected_objects, ReportList *reports, - const ScenePassType pass_type, const int pass_filter, const int margin, - const BakeSaveMode save_mode, const bool is_clear, const bool is_split_materials, + const eScenePassType pass_type, const int pass_filter, const int margin, + const eBakeSaveMode save_mode, const bool is_clear, const bool is_split_materials, const bool is_automatic_name, const bool is_selected_to_active, const bool is_cage, - const float cage_extrusion, const int normal_space, const BakeNormalSwizzle normal_swizzle[], + const float cage_extrusion, const int normal_space, const eBakeNormalSwizzle normal_swizzle[], const char *custom_cage, const char *filepath, const int width, const int height, const char *identifier, ScrArea *sa, const char *uv_layer) { diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 4e578906e07..5392b5c3dd0 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -572,7 +572,7 @@ static void object_test_constraint(Object *owner, bConstraint *con) #define EDIT_CONSTRAINT_OWNER_OBJECT 0 #define EDIT_CONSTRAINT_OWNER_BONE 1 -static EnumPropertyItem constraint_owner_items[] = { +static const EnumPropertyItem constraint_owner_items[] = { {EDIT_CONSTRAINT_OWNER_OBJECT, "OBJECT", 0, "Object", "Edit a constraint on the active object"}, {EDIT_CONSTRAINT_OWNER_BONE, "BONE", 0, "Bone", "Edit a constraint on the active bone"}, {0, NULL, 0, NULL, NULL}}; @@ -1031,7 +1031,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) * and define basic slope of this curve based on the properties */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { - FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); + FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); FMod_Generator *gen = fcm->data; /* Assume that we have the following equation: diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index b96f4fa9f31..bc8002010ef 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -64,7 +64,7 @@ /* All possible data to transfer. * Note some are 'fake' ones, i.e. they are not hold by real CDLayers. */ /* Not shared with modifier, since we use a usual enum here, not a multi-choice one. */ -static EnumPropertyItem DT_layer_items[] = { +static const EnumPropertyItem DT_layer_items[] = { {0, "", 0, "Vertex Data", ""}, {DT_TYPE_MDEFORMVERT, "VGROUP_WEIGHTS", 0, "Vertex Group(s)", "Transfer active or all vertex groups"}, #if 0 /* XXX For now, would like to finish/merge work from 2014 gsoc first. */ @@ -91,21 +91,20 @@ static EnumPropertyItem DT_layer_items[] = { }; /* Note: rna_enum_dt_layers_select_src_items enum is from rna_modifier.c */ -static EnumPropertyItem *dt_layers_select_src_itemf( +static const EnumPropertyItem *dt_layers_select_src_itemf( bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { EvaluationContext eval_ctx; EnumPropertyItem *item = NULL, tmp_item = {0}; int totitem = 0; - - CTX_data_eval_ctx(C, &eval_ctx); - const int data_type = RNA_enum_get(ptr, "data_type"); if (!C) { /* needed for docs and i18n tools */ return rna_enum_dt_layers_select_src_items; } + CTX_data_eval_ctx(C, &eval_ctx); + RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC); RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC); @@ -187,7 +186,7 @@ static EnumPropertyItem *dt_layers_select_src_itemf( } /* Note: rna_enum_dt_layers_select_dst_items enum is from rna_modifier.c */ -static EnumPropertyItem *dt_layers_select_dst_itemf( +static const EnumPropertyItem *dt_layers_select_dst_itemf( bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL; @@ -213,7 +212,7 @@ static EnumPropertyItem *dt_layers_select_dst_itemf( return item; } -static EnumPropertyItem *dt_layers_select_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) +static const EnumPropertyItem *dt_layers_select_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) { const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer"); @@ -234,7 +233,7 @@ static EnumPropertyItem *dt_layers_select_itemf(bContext *C, PointerRNA *ptr, Pr } /* Note: rna_enum_dt_mix_mode_items enum is from rna_modifier.c */ -static EnumPropertyItem *dt_mix_mode_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *dt_mix_mode_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL; int totitem = 0; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 289d0bb586b..771915a06dc 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1393,9 +1393,10 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, SceneLayer *sl) } -static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *object_mode_set_itemsf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { - EnumPropertyItem *input = rna_enum_object_mode_items; + const EnumPropertyItem *input = rna_enum_object_mode_items; EnumPropertyItem *item = NULL; Object *ob; bGPdata *gpd; @@ -1466,7 +1467,7 @@ static const char *object_mode_op_string(int mode) /* checks the mode to be set is compatible with the object * should be made into a generic function */ -static bool object_mode_compat_test(Object *ob, ObjectMode mode) +static bool object_mode_compat_test(Object *ob, eObjectMode mode) { if (ob) { if (mode == OB_MODE_OBJECT) @@ -1551,8 +1552,8 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); bGPdata *gpd = CTX_data_gpencil_data(C); - ObjectMode mode = RNA_enum_get(op->ptr, "mode"); - ObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; + eObjectMode mode = RNA_enum_get(op->ptr, "mode"); + eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); if (gpd) { @@ -1775,7 +1776,7 @@ static int game_property_move(bContext *C, wmOperator *op) void OBJECT_OT_game_property_move(wmOperatorType *ot) { - static EnumPropertyItem direction_property_move[] = { + static const EnumPropertyItem direction_property_move[] = { {GAME_PROPERTY_MOVE_UP, "UP", 0, "Up", ""}, {GAME_PROPERTY_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -1808,14 +1809,14 @@ void OBJECT_OT_game_property_move(wmOperatorType *ot) #define COPY_PROPERTIES_MERGE 2 #define COPY_PROPERTIES_COPY 3 -static EnumPropertyItem game_properties_copy_operations[] = { +static const EnumPropertyItem game_properties_copy_operations[] = { {COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""}, {COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""}, {COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob = ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index b32fb975ea8..ef7e48f2d1a 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -64,7 +64,7 @@ /********************* 3d view operators ***********************/ /* can be called with C == NULL */ -static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob; EnumPropertyItem *item = NULL, item_tmp = {0}; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 314019b4f76..3f6651299be 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -669,7 +669,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 4eafe715a6f..557e0a0eccf 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -820,7 +820,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op) void LATTICE_OT_flip(wmOperatorType *ot) { - static EnumPropertyItem flip_items[] = { + static const EnumPropertyItem flip_items[] = { {LATTICE_FLIP_U, "U", 0, "U (X) Axis", ""}, {LATTICE_FLIP_V, "V", 0, "V (Y) Axis", ""}, {LATTICE_FLIP_W, "W", 0, "W (Z) Axis", ""}, diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6e70734db19..b7ac6c5de32 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -752,10 +752,12 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *modifier_add_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob = ED_object_active_context(C); - EnumPropertyItem *item = NULL, *md_item, *group_item = NULL; + EnumPropertyItem *item = NULL; + const EnumPropertyItem *md_item, *group_item = NULL; const ModifierTypeInfo *mti; int totitem = 0, a; @@ -1027,7 +1029,7 @@ static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNU return OPERATOR_CANCELLED; } -static EnumPropertyItem modifier_apply_as_items[] = { +static const EnumPropertyItem modifier_apply_as_items[] = { {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, {0, NULL, 0, NULL, NULL} @@ -1585,7 +1587,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op) void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot) { - static EnumPropertyItem action_items[] = { + static const EnumPropertyItem action_items[] = { {SKIN_LOOSE_MARK, "MARK", 0, "Mark", "Mark selected vertices as loose"}, {SKIN_LOOSE_CLEAR, "CLEAR", 0, "Clear", "Set selected vertices as not loose"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f92d67deaff..896c90507c1 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -389,7 +389,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op) } /* Generic itemf's for operators that take library args */ -static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), +static const EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem item_tmp = {0}, *item = NULL; @@ -650,7 +650,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) - add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); } /* fall back on regular parenting now (for follow only) */ @@ -1142,7 +1142,7 @@ enum { CLEAR_TRACK_KEEP_TRANSFORM = 2, }; -static EnumPropertyItem prop_clear_track_types[] = { +static const EnumPropertyItem prop_clear_track_types[] = { {CLEAR_TRACK, "CLEAR", 0, "Clear Track", ""}, {CLEAR_TRACK_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, {0, NULL, 0, NULL, NULL} @@ -1211,7 +1211,7 @@ enum { CREATE_TRACK_LOCKTRACK = 3, }; -static EnumPropertyItem prop_make_track_types[] = { +static const EnumPropertyItem prop_make_track_types[] = { {CREATE_TRACK_DAMPTRACK, "DAMPTRACK", 0, "Damped Track Constraint", ""}, {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track To Constraint", ""}, {CREATE_TRACK_LOCKTRACK, "LOCKTRACK", 0, "Lock Track Constraint", ""}, @@ -1596,7 +1596,7 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot) void OBJECT_OT_make_links_data(wmOperatorType *ot) { - static EnumPropertyItem make_links_items[] = { + static const EnumPropertyItem make_links_items[] = { {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""}, {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""}, {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""}, @@ -2299,7 +2299,7 @@ static int make_local_exec(bContext *C, wmOperator *op) void OBJECT_OT_make_local(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {MAKE_LOCAL_SELECT_OB, "SELECT_OBJECT", 0, "Selected Objects", ""}, {MAKE_LOCAL_SELECT_OBDATA, "SELECT_OBDATA", 0, "Selected Objects and Data", ""}, {MAKE_LOCAL_SELECT_OBDATA_MATERIAL, "SELECT_OBDATA_MATERIAL", 0, "Selected Objects, Data and Materials", ""}, @@ -2381,7 +2381,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) void OBJECT_OT_make_single_user(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {MAKE_SINGLE_USER_SELECTED, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, {MAKE_SINGLE_USER_ALL, "ALL", 0, "All", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 280294e714d..d0c37fc108a 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -233,7 +233,7 @@ enum { OBJECT_SELECT_LINKED_LIBRARY_OBDATA }; -static EnumPropertyItem prop_select_linked_types[] = { +static const EnumPropertyItem prop_select_linked_types[] = { //{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX deprecated animation system stuff... {OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""}, {OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""}, @@ -530,7 +530,7 @@ enum { OBJECT_GRPSEL_LAMP_TYPE = 12, }; -static EnumPropertyItem prop_select_grouped_types[] = { +static const EnumPropertyItem prop_select_grouped_types[] = { {OBJECT_GRPSEL_CHILDREN_RECURSIVE, "CHILDREN_RECURSIVE", 0, "Children", ""}, {OBJECT_GRPSEL_CHILDREN, "CHILDREN", 0, "Immediate Children", ""}, {OBJECT_GRPSEL_PARENT, "PARENT", 0, "Parent", ""}, diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index b7c0a2679bc..4fefe03c6ab 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -479,7 +479,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) void OBJECT_OT_shape_key_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {KB_MOVE_TOP, "TOP", 0, "Top", "Top of the list"}, {KB_MOVE_UP, "UP", 0, "Up", ""}, {KB_MOVE_DOWN, "DOWN", 0, "Down", ""}, diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 944fbb0bbe1..b9c8edf8614 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1114,7 +1114,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) void OBJECT_OT_origin_set(wmOperatorType *ot) { - static EnumPropertyItem prop_set_center_types[] = { + static const EnumPropertyItem prop_set_center_types[] = { {GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"}, {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Calculate the center of geometry based on the current pivot point (median, otherwise bounding-box)"}, @@ -1128,7 +1128,7 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem prop_set_bounds_types[] = { + static const EnumPropertyItem prop_set_bounds_types[] = { {V3D_AROUND_CENTER_MEAN, "MEDIAN", 0, "Median Center", ""}, {V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 386c63d4095..9d01ad6886c 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -668,7 +668,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type) /***********************Start weight transfer (WT)*********************************/ -static EnumPropertyItem WT_vertex_group_select_item[] = { +static const EnumPropertyItem WT_vertex_group_select_item[] = { {WT_VGROUP_ACTIVE, "ACTIVE", 0, "Active Group", "The active Vertex Group"}, {WT_VGROUP_BONE_SELECT, @@ -680,7 +680,7 @@ static EnumPropertyItem WT_vertex_group_select_item[] = { {0, NULL, 0, NULL, NULL} }; -EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( +const EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( const bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free, const unsigned int selection_mask) { @@ -688,9 +688,10 @@ EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( EnumPropertyItem *item = NULL; int totitem = 0; - - if (!C) /* needed for docs and i18n tools */ + if (C == NULL) { + /* needed for docs and i18n tools */ return WT_vertex_group_select_item; + } ob = CTX_data_active_object(C); if (selection_mask & (1 << WT_VGROUP_ACTIVE)) @@ -712,13 +713,13 @@ EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( return item; } -static EnumPropertyItem *rna_vertex_group_with_single_itemf(bContext *C, PointerRNA *ptr, +static const EnumPropertyItem *rna_vertex_group_with_single_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) { return ED_object_vgroup_selection_itemf_helper(C, ptr, prop, r_free, WT_VGROUP_MASK_ALL); } -static EnumPropertyItem *rna_vertex_group_select_itemf(bContext *C, PointerRNA *ptr, +static const EnumPropertyItem *rna_vertex_group_select_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) { return ED_object_vgroup_selection_itemf_helper(C, ptr, prop, r_free, WT_VGROUP_MASK_ALL & ~(1 << WT_VGROUP_ACTIVE)); @@ -1628,7 +1629,7 @@ enum { VGROUP_INVERT }; -static EnumPropertyItem vgroup_lock_actions[] = { +static const EnumPropertyItem vgroup_lock_actions[] = { {VGROUP_TOGGLE, "TOGGLE", 0, "Toggle", "Unlock all vertex groups if there is at least one locked group, lock all in other case"}, {VGROUP_LOCK, "LOCK", 0, "Lock", "Lock all vertex groups"}, {VGROUP_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock all vertex groups"}, @@ -3421,7 +3422,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { Object *ob = ED_object_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -3640,7 +3641,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) void OBJECT_OT_vertex_group_sort(wmOperatorType *ot) { - static EnumPropertyItem vgroup_sort_type[] = { + static const EnumPropertyItem vgroup_sort_type[] = { {SORT_TYPE_NAME, "NAME", 0, "Name", ""}, {SORT_TYPE_BONEHIERARCHY, "BONE_HIERARCHY", 0, "Bone Hierarchy", ""}, {0, NULL, 0, NULL, NULL} @@ -3691,7 +3692,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op) void OBJECT_OT_vertex_group_move(wmOperatorType *ot) { - static EnumPropertyItem vgroup_slot_move[] = { + static const EnumPropertyItem vgroup_slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 1f0ee6862d2..93f010778f1 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -255,7 +255,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op) void DPAINT_OT_output_toggle(wmOperatorType *ot) { - static EnumPropertyItem prop_output_toggle_types[] = { + static const EnumPropertyItem prop_output_toggle_types[] = { {0, "A", 0, "Output A", ""}, {1, "B", 0, "Output B", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 6a5a3c73f81..67ba1a1312a 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1630,7 +1630,7 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) enum { RAN_HAIR, RAN_POINTS }; -static EnumPropertyItem select_random_type_items[] = { +static const EnumPropertyItem select_random_type_items[] = { {RAN_HAIR, "HAIR", 0, "Hair", ""}, {RAN_POINTS, "POINTS", 0, "Points", ""}, {0, NULL, 0, NULL, NULL} @@ -2771,7 +2771,7 @@ static void toggle_particle_cursor(bContext *C, int enable) enum { DEL_PARTICLE, DEL_KEY }; -static EnumPropertyItem delete_type_items[] = { +static const EnumPropertyItem delete_type_items[] = { {DEL_PARTICLE, "PARTICLE", 0, "Particle", ""}, {DEL_KEY, "KEY", 0, "Key", ""}, {0, NULL, 0, NULL, NULL}}; @@ -4127,7 +4127,9 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; /* properties */ - RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } /*********************** cut shape ***************************/ diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 571a8ab18f0..1e643ea7277 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -1211,7 +1211,7 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot) { - static EnumPropertyItem space_items[] = { + static const EnumPropertyItem space_items[] = { {PAR_COPY_SPACE_OBJECT, "OBJECT", 0, "Object", "Copy inside each object's local space"}, {PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index d4f949880ee..74946e3f44d 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -166,6 +166,7 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) baker->main = CTX_data_main(C); baker->scene = CTX_data_scene(C); + baker->scene_layer = CTX_data_scene_layer(C); baker->bake = RNA_boolean_get(op->ptr, "bake"); baker->render = 0; baker->anim_init = 0; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index cf9dc8ff2a3..3b667520550 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -457,7 +457,7 @@ static const int NUM_RB_MATERIAL_PRESETS = sizeof(RB_MATERIAL_DENSITY_TABLE) / s * - Although there is a runtime cost, this has a lower maintenance cost * in the long run than other two-list solutions... */ -static EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem item_tmp = {0}; EnumPropertyItem *item = NULL; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index ababd637e00..037e8adff9a 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -56,6 +56,7 @@ #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" @@ -64,6 +65,7 @@ #include "BKE_sequencer.h" #include "BKE_screen.h" #include "BKE_scene.h" +#include "BKE_workspace.h" #include "DEG_depsgraph.h" @@ -787,33 +789,46 @@ static void screen_render_cancel(bContext *C, wmOperator *op) WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER); } +static void clean_viewport_memory_base(Base *base) +{ + if ((base->flag & BASE_VISIBLED) == 0) { + return; + } + + Object *object = base->object; + + if (object->id.tag & LIB_TAG_DOIT) { + return; + } + + object->id.tag &= ~LIB_TAG_DOIT; + if (RE_allow_render_generic_object(object)) { + BKE_object_free_derived_caches(object); + } +} + static void clean_viewport_memory(Main *bmain, Scene *scene) { - Object *object; Scene *sce_iter; Base *base; - for (object = bmain->object.first; object; object = object->id.next) { - object->id.tag |= LIB_TAG_DOIT; - } + /* Tag all the available objects. */ + BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - for (SETLOOPER(scene, sce_iter, base)) { - if ((base->flag & BASE_VISIBLED) == 0) { - continue; - } - if (RE_allow_render_generic_object(base->object)) { - base->object->id.tag &= ~LIB_TAG_DOIT; - } - } + /* Go over all the visible objects. */ + for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { + for (wmWindow *win = wm->windows.first; win; win = win->next) { + WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); + SceneLayer *scene_layer = BKE_scene_layer_from_workspace_get(scene, workspace); - for (SETLOOPER(scene, sce_iter, base)) { - object = base->object; - if ((object->id.tag & LIB_TAG_DOIT) == 0) { - continue; + for (base = scene_layer->object_bases.first; base; base = base->next) { + clean_viewport_memory_base(base); + } } - object->id.tag &= ~LIB_TAG_DOIT; + } - BKE_object_free_derived_caches(object); + for (SETLOOPER_SET_ONLY(scene, sce_iter, base)) { + clean_viewport_memory_base(base); } } @@ -1256,10 +1271,10 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda /* initalize always */ if (use_border) { rdata.mode |= R_BORDER; - RE_InitState(re, NULL, &rdata, NULL, rp->ar->winx, rp->ar->winy, &cliprct); + RE_InitState(re, NULL, &rdata, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, &cliprct); } else - RE_InitState(re, NULL, &rdata, NULL, rp->ar->winx, rp->ar->winy, NULL); + RE_InitState(re, NULL, &rdata, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, NULL); } if (orth) @@ -1679,7 +1694,7 @@ static int render_shutter_curve_preset_exec(bContext *C, wmOperator *op) void RENDER_OT_shutter_curve_preset(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem prop_shape_items[] = { + static const EnumPropertyItem prop_shape_items[] = { {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, {CURVE_PRESET_MAX, "MAX", 0, "Max", ""}, diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index af932c27c5e..c17beded91e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -94,6 +94,7 @@ typedef struct OGLRender { Main *bmain; Render *re; Scene *scene; + WorkSpace *workspace; SceneLayer *scene_layer; View3D *v3d; @@ -267,7 +268,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr) { Scene *scene = oglrender->scene; - SceneLayer *sl = oglrender->scene_layer; + SceneLayer *scene_layer = oglrender->scene_layer; ARegion *ar = oglrender->ar; View3D *v3d = oglrender->v3d; RegionView3D *rv3d = oglrender->rv3d; @@ -352,7 +353,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R if (view_context) { ibuf_view = ED_view3d_draw_offscreen_imbuf( - &eval_ctx, scene, sl, v3d, ar, sizex, sizey, + &eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, IB_rect, draw_bgpic, alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname, oglrender->fx, oglrender->ofs, err_out); @@ -364,7 +365,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R } else { ibuf_view = ED_view3d_draw_offscreen_imbuf_simple( - &eval_ctx, scene, sl, scene->camera, oglrender->sizex, oglrender->sizey, + &eval_ctx, scene, scene_layer, scene->camera, oglrender->sizex, oglrender->sizey, IB_rect, OB_SOLID, false, true, true, alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname, oglrender->fx, oglrender->ofs, err_out); @@ -591,6 +592,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) /* new render clears all callbacks */ wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); + WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); ScrArea *prevsa = CTX_wm_area(C); @@ -662,6 +664,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->sizey = sizey; oglrender->bmain = CTX_data_main(C); oglrender->scene = scene; + oglrender->workspace = workspace; oglrender->scene_layer = CTX_data_scene_layer(C); oglrender->cfrao = scene->r.cfra; @@ -698,6 +701,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) /* create render */ oglrender->re = RE_NewSceneRender(scene); + ViewRender *view_render = BKE_viewrender_get(scene, workspace); + RE_SetEngineByID(oglrender->re, view_render->engine_id); /* create image and image user */ oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); @@ -708,7 +713,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->iuser.ok = 1; /* create render result */ - RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL); + RE_InitState(oglrender->re, NULL, &scene->r, view_render, NULL, sizex, sizey, NULL); /* create render views */ screen_opengl_views_setup(oglrender); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 3f817672c00..958f1585e84 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -173,6 +173,7 @@ typedef struct ShaderPreview { Main *bmain; Main *pr_main; + ViewRender *view_render; } ShaderPreview; typedef struct IconPreviewSize { @@ -187,6 +188,7 @@ typedef struct IconPreview { void *owner; ID *id; ListBase sizes; + ViewRender *view_render; } IconPreview; /* *************************** Preview for buttons *********************** */ @@ -229,7 +231,7 @@ void ED_preview_ensure_dbase(void) static bool check_engine_supports_textures(Scene *scene) { - RenderEngineType *type = RE_engines_find(scene->r.engine); + RenderEngineType *type = RE_engines_find(scene->view_render.engine_id); return type->flag & RE_USE_TEXTURE_PREVIEW; } @@ -383,10 +385,10 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty * seems commonly used render engines does not support * such kind of rendering. */ - BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine)); + BLI_strncpy(sce->view_render.engine_id, RE_engine_id_BLENDER_RENDER, sizeof(sce->view_render.engine_id)); } else { - BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); + BLI_strncpy(sce->view_render.engine_id, scene->view_render.engine_id, sizeof(sce->view_render.engine_id)); } if (id_type == ID_MA) { @@ -857,7 +859,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs ((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex; /* entire cycle for render engine */ - RE_PreviewRender(re, pr_main, sce); + RE_PreviewRender(re, pr_main, sce, sp->view_render); ((Camera *)sce->camera->data)->lens = oldlens; @@ -1184,6 +1186,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short /* construct shader preview from image size and previewcustomdata */ sp->scene = ip->scene; + sp->view_render = ip->view_render; sp->owner = ip->owner; sp->sizex = cur_size->sizex; sp->sizey = cur_size->sizey; @@ -1268,6 +1271,7 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec ip.bmain = bmain; ip.scene = scene; + ip.view_render = &scene->view_render; ip.owner = BKE_previewimg_id_ensure(id); ip.id = id; @@ -1301,6 +1305,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r /* customdata for preview thread */ ip->bmain = CTX_data_main(C); ip->scene = CTX_data_scene(C); + ip->view_render = &ip->scene->view_render; ip->owner = owner; ip->id = id; @@ -1328,8 +1333,12 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M wmJob *wm_job; ShaderPreview *sp; Scene *scene = CTX_data_scene(C); + WorkSpace *workspace = CTX_wm_workspace(C); short id_type = GS(id->name); - bool use_new_shading = BKE_scene_use_new_shading_nodes(scene); + + /* Use workspace render only for buttons Window, since the other previews are related to the datablock. */ + ViewRender *view_render = (method == PR_BUTS_RENDER) ? BKE_viewrender_get(scene, workspace) : &scene->view_render; + bool use_new_shading = BKE_viewrender_use_new_shading_nodes(view_render); /* Only texture node preview is supported with Cycles. */ if (use_new_shading && method == PR_NODE_RENDER && id_type != ID_TE) { @@ -1352,6 +1361,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->parent = parent; sp->slot = slot; sp->bmain = CTX_data_main(C); + sp->view_render = view_render; /* hardcoded preview .blend for cycles/internal, this should be solved * once with custom preview .blend path for external engines */ diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 58dd67f4923..ef436c44b74 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -434,7 +434,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op) void OBJECT_OT_material_slot_move(wmOperatorType *ot) { - static EnumPropertyItem material_slot_move[] = { + static const EnumPropertyItem material_slot_move[] = { {1, "UP", 0, "Up", ""}, {-1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -843,7 +843,7 @@ static int freestyle_module_move_exec(bContext *C, wmOperator *op) void SCENE_OT_freestyle_module_move(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -1003,7 +1003,7 @@ static int freestyle_lineset_move_exec(bContext *C, wmOperator *op) void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -1380,7 +1380,7 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -1501,7 +1501,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op) void TEXTURE_OT_slot_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index ccea1e5930c..f38b190b92c 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -38,6 +38,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "DNA_world_types.h" #include "DNA_windowmanager_types.h" @@ -56,6 +57,7 @@ #include "BKE_node.h" #include "BKE_paint.h" #include "BKE_scene.h" +#include "BKE_workspace.h" #include "GPU_lamp.h" #include "GPU_material.h" @@ -113,7 +115,9 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) ARegion *ar; CTX_wm_window_set(C, win); - + WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); + ViewRender *view_render = BKE_viewrender_get(win->scene, workspace); + for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->spacetype != SPACE_VIEW3D) continue; @@ -141,7 +145,7 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) engine->type->view_update(engine, C); } - else if ((RE_engines_find(scene->r.engine)->flag & RE_USE_LEGACY_PIPELINE) == 0) { + else if ((RE_engines_find(view_render->engine_id)->flag & RE_USE_LEGACY_PIPELINE) == 0) { if (updated) { CTX_wm_screen_set(C, sc); CTX_wm_area_set(C, sa); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 08be062aaf6..20af9ee215e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -145,11 +145,11 @@ void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note } /* only exported for WM */ -void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, const Scene *scene) +void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, Scene *scene, WorkSpace *workspace) { /* no generic notes? */ if (sa->type && sa->type->listener) { - sa->type->listener(sc, sa, note, scene); + sa->type->listener(sc, sa, note, scene, workspace); } } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 5813f317295..b8575b2da2a 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -89,7 +89,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult ScrArea *sa = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - SceneLayer *sl = BKE_scene_layer_from_workspace_get(workspace); + SceneLayer *sl = BKE_scene_layer_from_workspace_get(scene, workspace); Object *obedit = scene->obedit; Object *obact = sl->basact ? sl->basact->object : NULL; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index df2619c9ea3..6544d42f6a8 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -957,7 +957,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) /* *********************************** */ /* case when on area-edge or in azones, or outside window */ -static void screen_cursor_set(wmWindow *win, wmEvent *event) +static void screen_cursor_set(wmWindow *win, const wmEvent *event) { const bScreen *screen = WM_window_get_active_screen(win); const int screen_size_x = WM_window_screen_pixels_x(win); @@ -997,7 +997,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) /* called in wm_event_system.c. sets state vars in screen, cursors */ /* event type is mouse move */ -void ED_screen_set_subwinactive(bContext *C, wmEvent *event) +void ED_screen_set_subwinactive(bContext *C, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); bScreen *scr = WM_window_get_active_screen(win); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index dd609d8e2ac..9a3d1da2375 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1788,7 +1788,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static EnumPropertyItem prop_direction_items[] = { +static const EnumPropertyItem prop_direction_items[] = { {'h', "HORIZONTAL", 0, "Horizontal", ""}, {'v', "VERTICAL", 0, "Vertical", ""}, {0, NULL, 0, NULL, NULL} @@ -3806,9 +3806,9 @@ static void SCREEN_OT_border_select(wmOperatorType *ot) /* api callbacks */ ot->exec = border_select_exec; - ot->invoke = WM_border_select_invoke; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->invoke = WM_gesture_border_invoke; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_areaactive; @@ -4083,7 +4083,7 @@ enum { SPACE_CONTEXT_CYCLE_NEXT, }; -static EnumPropertyItem space_context_cycle_direction[] = { +static const EnumPropertyItem space_context_cycle_direction[] = { {SPACE_CONTEXT_CYCLE_PREV, "PREV", 0, "Previous", ""}, {SPACE_CONTEXT_CYCLE_NEXT, "NEXT", 0, "Next", ""}, {0, NULL, 0, NULL, NULL} @@ -4222,7 +4222,7 @@ void ED_operatortypes_screen(void) static void keymap_modal_set(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {KM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {KM_MODAL_APPLY, "APPLY", 0, "Apply", ""}, {KM_MODAL_STEP10, "STEP10", 0, "Steps on", ""}, diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 312117f2bbe..2229ecce408 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -38,6 +38,7 @@ #include "BKE_main.h" #include "BKE_library.h" #include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_workspace.h" @@ -51,6 +52,8 @@ #include "ED_object.h" #include "ED_screen.h" +#include "MEM_guardedalloc.h" + #include "RNA_access.h" #include "UI_interface.h" @@ -68,7 +71,7 @@ * \{ */ WorkSpace *ED_workspace_add( - Main *bmain, const char *name, SceneLayer *act_render_layer) + Main *bmain, const char *name, SceneLayer *act_render_layer, ViewRender *view_render) { WorkSpace *workspace = BKE_workspace_add(bmain, name); @@ -77,6 +80,7 @@ WorkSpace *ED_workspace_add( #endif BKE_workspace_render_layer_set(workspace, act_render_layer); + BKE_viewrender_copy(&workspace->view_render, view_render); return workspace; } @@ -90,8 +94,8 @@ static void workspace_change_update_mode( const WorkSpace *workspace_old, const WorkSpace *workspace_new, bContext *C, Object *ob_act, ReportList *reports) { - ObjectMode mode_old = BKE_workspace_object_mode_get(workspace_old); - ObjectMode mode_new = BKE_workspace_object_mode_get(workspace_new); + eObjectMode mode_old = BKE_workspace_object_mode_get(workspace_old); + eObjectMode mode_new = BKE_workspace_object_mode_get(workspace_new); if (mode_old != mode_new) { ED_object_mode_compat_set(C, ob_act, mode_new, reports); @@ -215,7 +219,8 @@ WorkSpace *ED_workspace_duplicate( ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); WorkSpace *workspace_new = ED_workspace_add( bmain, workspace_old->id.name + 2, - BKE_workspace_render_layer_get(workspace_old)); + BKE_workspace_render_layer_get(workspace_old), + &workspace_old->view_render); ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old); ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new); @@ -231,7 +236,6 @@ WorkSpace *ED_workspace_duplicate( win->workspace_hook->temp_layout_store = layout_new; } } - return workspace_new; } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 2d2d5fa33c9..e1e90506299 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -249,12 +249,12 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima TexSnapshot *target; MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex; - OverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); + eOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); GLubyte *buffer = NULL; int size; bool refresh; - OverlayControlFlags invalid = (primary) ? (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) : + eOverlayControlFlags invalid = (primary) ? (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) : (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY); target = (primary) ? &primary_snap : &secondary_snap; @@ -397,7 +397,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) { bool init; - OverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); + eOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); GLubyte *buffer = NULL; int size; @@ -778,11 +778,11 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush, } static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush, - ViewContext *vc, int x, int y, float zoom, PaintMode mode) + ViewContext *vc, int x, int y, float zoom, ePaintMode mode) { /* color means that primary brush texture is colured and secondary is used for alpha/mask control */ bool col = ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex) ? true : false; - OverlayControlFlags flags = BKE_paint_get_overlay_flags(); + eOverlayControlFlags flags = BKE_paint_get_overlay_flags(); gpuPushAttrib(GPU_DEPTH_BUFFER_BIT | GPU_BLEND_BIT); /* coloured overlay should be drawn separately */ @@ -997,7 +997,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon } } -static bool ommit_cursor_drawing(Paint *paint, PaintMode mode, Brush *brush) +static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush) { if (paint->flags & PAINT_SHOW_BRUSH) { if (ELEM(mode, ePaintTexture2D, ePaintTextureProjective) && brush->imagepaint_tool == PAINT_TOOL_FILL) { @@ -1014,7 +1014,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); /* check that brush drawing is enabled */ if (ommit_cursor_drawing(paint, mode, brush)) diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 9704db9d035..0ee78d61fb8 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -128,7 +128,7 @@ static void paintcurve_undo_delete(ListBase *lb) static void paintcurve_undo_begin(bContext *C, wmOperator *op, PaintCurve *pc) { - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); ListBase *lb = NULL; int undo_stack_id; UndoCurve *uc; @@ -733,7 +733,7 @@ void PAINTCURVE_OT_slide(wmOperatorType *ot) static int paintcurve_draw_exec(bContext *C, wmOperator *UNUSED(op)) { - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); const char *name; switch (mode) { @@ -774,7 +774,7 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot) static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); switch (mode) { case ePaintTexture2D: diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index d2e2df01238..8377b22756e 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -436,20 +436,20 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event) PartialVisArea area = RNA_enum_get(op->ptr, "area"); if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) - return WM_border_select_invoke(C, op, event); + return WM_gesture_border_invoke(C, op, event); else return op->type->exec(C, op); } void PAINT_OT_hide_show(struct wmOperatorType *ot) { - static EnumPropertyItem action_items[] = { + static const EnumPropertyItem action_items[] = { {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem area_items[] = { + static const EnumPropertyItem area_items[] = { {PARTIALVIS_OUTSIDE, "OUTSIDE", 0, "Outside", "Hide or show vertices outside the selection"}, {PARTIALVIS_INSIDE, "INSIDE", 0, "Inside", "Hide or show vertices inside the selection"}, {PARTIALVIS_ALL, "ALL", 0, "All", "Hide or show all vertices"}, @@ -464,7 +464,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) /* api callbacks */ ot->invoke = hide_show_invoke; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->exec = hide_show_exec; /* sculpt-only for now */ ot->poll = sculpt_mode_poll_view3d; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index e324f2b89f0..580e42e5974 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -511,7 +511,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj) BlurKernel *kernel = MEM_mallocN(sizeof(BlurKernel), "blur kernel"); float radius; int side; - BlurKernelType type = br->blur_mode; + eBlurKernelType type = br->blur_mode; if (proj) { radius = 0.5f; @@ -625,13 +625,13 @@ static int image_paint_2d_clone_poll(bContext *C) } /************************ paint operator ************************/ -typedef enum TexPaintMode { +typedef enum eTexPaintMode { PAINT_MODE_2D, PAINT_MODE_3D_PROJECT -} TexPaintMode; +} eTexPaintMode; typedef struct PaintOperation { - TexPaintMode mode; + eTexPaintMode mode; void *custom_paint; @@ -1208,7 +1208,7 @@ static int sample_color_exec(bContext *C, wmOperator *op) { Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); ARegion *ar = CTX_wm_region(C); wmWindow *win = CTX_wm_window(C); const bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); @@ -1260,7 +1260,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event RNA_int_set_array(op->ptr, "location", event->mval); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); const bool use_sample_texture = (mode == ePaintTextureProjective) && !RNA_boolean_get(op->ptr, "merged"); paint_sample_color(C, ar, event->mval[0], event->mval[1], use_sample_texture, false); @@ -1296,7 +1296,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); const bool use_sample_texture = (mode == ePaintTextureProjective) && !RNA_boolean_get(op->ptr, "merged"); switch (event->type) { diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 2ffd9757f92..da2fcd6459d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5455,7 +5455,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) char filename[FILE_MAX]; Scene *scene = CTX_data_scene(C); - SceneLayer *sl = CTX_data_scene_layer(C); + SceneLayer *scene_layer = CTX_data_scene_layer(C); EvaluationContext eval_ctx; ToolSettings *settings = scene->toolsettings; int w = settings->imapaint.screen_grab_size[0]; @@ -5473,7 +5473,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if (h > maxsize) h = maxsize; ibuf = ED_view3d_draw_offscreen_imbuf( - &eval_ctx, scene, sl, CTX_wm_view3d(C), CTX_wm_region(C), + &eval_ctx, scene, scene_layer, CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL, NULL, NULL, err_out); if (!ibuf) { @@ -5645,7 +5645,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m /* Add layer operator */ -static EnumPropertyItem layer_type_items[] = { +static const EnumPropertyItem layer_type_items[] = { {MAP_COL, "DIFFUSE_COLOR", 0, "Diffuse Color", ""}, {MAP_REF, "DIFFUSE_INTENSITY", 0, "Diffuse Intensity", ""}, {MAP_ALPHA, "ALPHA", 0, "Alpha", ""}, diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b3b7d40391a..28d9dfe13b0 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -54,7 +54,7 @@ struct wmOperator; struct wmOperatorType; struct wmWindowManager; struct DMCoNo; -enum PaintMode; +enum ePaintMode; /* paint_stroke.c */ typedef bool (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]); @@ -69,12 +69,12 @@ struct PaintStroke *paint_stroke_new(struct bContext *C, struct wmOperator *op, StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); -bool paint_space_stroke_enabled(struct Brush *br, enum PaintMode mode); -bool paint_supports_dynamic_size(struct Brush *br, enum PaintMode mode); -bool paint_supports_dynamic_tex_coords(struct Brush *br, enum PaintMode mode); -bool paint_supports_smooth_stroke(struct Brush *br, enum PaintMode mode); -bool paint_supports_texture(enum PaintMode mode); -bool paint_supports_jitter(enum PaintMode mode); +bool paint_space_stroke_enabled(struct Brush *br, enum ePaintMode mode); +bool paint_supports_dynamic_size(struct Brush *br, enum ePaintMode mode); +bool paint_supports_dynamic_tex_coords(struct Brush *br, enum ePaintMode mode); +bool paint_supports_smooth_stroke(struct Brush *br, enum ePaintMode mode); +bool paint_supports_texture(enum ePaintMode mode); +bool paint_supports_jitter(enum ePaintMode mode); struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf); int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); @@ -335,7 +335,7 @@ typedef struct { int pixel_len; /* pixels around center that kernel is wide */ } BlurKernel; -enum BlurKernelType; +enum eBlurKernelType; /* can be extended to other blur kernels later */ BlurKernel *paint_new_blur_kernel(struct Brush *br, bool proj); void paint_delete_blur_kernel(BlurKernel *); diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index b7159c375cd..0fec4c4fc80 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -69,7 +69,7 @@ #include <stdlib.h> -static EnumPropertyItem mode_items[] = { +static const EnumPropertyItem mode_items[] = { {PAINT_MASK_FLOOD_VALUE, "VALUE", 0, "Value", "Set mask to the level specified by the 'value' property"}, {PAINT_MASK_FLOOD_VALUE_INVERSE, "VALUE_INVERSE", 0, "Value Inverted", "Set mask to the level specified by the inverted 'value' property"}, {PAINT_MASK_INVERT, "INVERT", 0, "Invert", "Invert the mask"}, @@ -511,8 +511,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name = "Mask Lasso Gesture"; ot->idname = "PAINT_OT_mask_lasso_gesture"; ot->description = "Add mask within the lasso as you move the brush"; @@ -525,8 +523,8 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); + /* properties */ + WM_operator_properties_gesture_lasso(ot); RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL); RNA_def_float(ot->srna, "value", 1.0, 0, 1.0, "Value", diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 2899cfeedcf..40210d63566 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -66,7 +66,7 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) Paint *paint = BKE_paint_get_active_from_context(C); Brush *br = BKE_paint_brush(paint); Main *bmain = CTX_data_main(C); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); if (br) br = BKE_brush_copy(bmain, br); @@ -195,7 +195,7 @@ static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = paint->brush; - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); Palette *palette = paint->palette; PaletteColor *color; @@ -455,7 +455,7 @@ static int brush_select_exec(bContext *C, wmOperator *op) static void PAINT_OT_brush_select(wmOperatorType *ot) { - static EnumPropertyItem paint_mode_items[] = { + static const EnumPropertyItem paint_mode_items[] = { {OB_MODE_ACTIVE, "ACTIVE", 0, "Current", "Set brush for active paint mode"}, {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, @@ -776,7 +776,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve static int stencil_control_poll(bContext *C) { - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); Paint *paint; Brush *br; @@ -793,14 +793,14 @@ static int stencil_control_poll(bContext *C) static void BRUSH_OT_stencil_control(wmOperatorType *ot) { - static EnumPropertyItem stencil_control_items[] = { + static const EnumPropertyItem stencil_control_items[] = { {STENCIL_TRANSLATE, "TRANSLATION", 0, "Translation", ""}, {STENCIL_SCALE, "SCALE", 0, "Scale", ""}, {STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""}, {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem stencil_texture_items[] = { + static const EnumPropertyItem stencil_texture_items[] = { {STENCIL_PRIMARY, "PRIMARY", 0, "Primary", ""}, {STENCIL_SECONDARY, "SECONDARY", 0, "Secondary", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d92afd414f8..dacaea6a96e 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -201,7 +201,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) glDisable(GL_LINE_SMOOTH); } -static bool paint_tool_require_location(Brush *brush, PaintMode mode) +static bool paint_tool_require_location(Brush *brush, ePaintMode mode) { switch (mode) { case ePaintSculpt: @@ -223,7 +223,7 @@ static bool paint_tool_require_location(Brush *brush, PaintMode mode) /* Initialize the stroke cache variants from operator properties */ static bool paint_brush_update(bContext *C, Brush *brush, - PaintMode mode, + ePaintMode mode, struct PaintStroke *stroke, const float mouse_init[2], float mouse[2], float pressure, @@ -405,7 +405,7 @@ static bool paint_brush_update(bContext *C, return location_success; } -static bool paint_stroke_use_jitter(PaintMode mode, Brush *brush, bool invert) +static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert) { bool use_jitter = (brush->flag & BRUSH_ABSOLUTE_JITTER) ? (brush->jitter_absolute != 0) : (brush->jitter != 0); @@ -425,7 +425,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float { Scene *scene = CTX_data_scene(C); Paint *paint = BKE_paint_get_active_from_context(C); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); PaintStroke *stroke = op->customdata; UnifiedPaintSettings *ups = stroke->ups; @@ -500,7 +500,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float /* Returns zero if no sculpt changes should be made, non-zero otherwise */ static bool paint_smooth_stroke( - PaintStroke *stroke, const PaintSample *sample, PaintMode mode, + PaintStroke *stroke, const PaintSample *sample, ePaintMode mode, float r_mouse[2], float *r_pressure) { if (paint_supports_smooth_stroke(stroke->brush, mode)) { @@ -766,7 +766,7 @@ static void stroke_done(struct bContext *C, struct wmOperator *op) } /* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ -bool paint_space_stroke_enabled(Brush *br, PaintMode mode) +bool paint_space_stroke_enabled(Brush *br, ePaintMode mode) { return (br->flag & BRUSH_SPACE) && paint_supports_dynamic_size(br, mode); } @@ -781,7 +781,7 @@ static bool sculpt_is_grab_tool(Brush *br) } /* return true if the brush size can change during paint (normally used for pressure) */ -bool paint_supports_dynamic_size(Brush *br, PaintMode mode) +bool paint_supports_dynamic_size(Brush *br, ePaintMode mode) { if (br->flag & BRUSH_ANCHORED) return false; @@ -807,7 +807,7 @@ bool paint_supports_dynamic_size(Brush *br, PaintMode mode) return true; } -bool paint_supports_smooth_stroke(Brush *br, PaintMode mode) +bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode) { if (!(br->flag & BRUSH_SMOOTH_STROKE) || (br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE))) @@ -826,14 +826,14 @@ bool paint_supports_smooth_stroke(Brush *br, PaintMode mode) return true; } -bool paint_supports_texture(PaintMode mode) +bool paint_supports_texture(ePaintMode mode) { /* omit: PAINT_WEIGHT, PAINT_SCULPT_UV, PAINT_INVALID */ return ELEM(mode, ePaintSculpt, ePaintVertex, ePaintTextureProjective, ePaintTexture2D); } /* return true if the brush size can change during paint (normally used for pressure) */ -bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode) +bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode) { if (br->flag & BRUSH_ANCHORED) return false; @@ -1095,7 +1095,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2]) int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) { Paint *p = BKE_paint_get_active_from_context(C); - PaintMode mode = BKE_paintmode_get_active_from_context(C); + ePaintMode mode = BKE_paintmode_get_active_from_context(C); PaintStroke *stroke = op->customdata; Brush *br = stroke->brush; PaintSample sample_average; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index bb69a5d3db9..bf00ce865e9 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -207,14 +207,17 @@ void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], void paint_stroke_operator_properties(wmOperatorType *ot) { - static EnumPropertyItem stroke_mode_items[] = { + static const EnumPropertyItem stroke_mode_items[] = { {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"}, {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"}, {BRUSH_STROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke"}, {0} }; - RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + PropertyRNA *prop; + + prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Stroke Mode", @@ -279,7 +282,7 @@ static void imapaint_pick_uv(EvaluationContext *eval_ctx, Scene *scene, Object * float p[2], w[3], absw, minabsw; float matrix[4][4], proj[4][4]; GLint view[4]; - const ImagePaintMode mode = scene->toolsettings->imapaint.mode; + const eImageePaintMode mode = scene->toolsettings->imapaint.mode; const MLoopTri *lt = dm->getLoopTriArray(dm); const MPoly *mpoly = dm->getPolyArray(dm); const MLoop *mloop = dm->getLoopArray(dm); @@ -582,7 +585,7 @@ static int brush_curve_preset_poll(bContext *C) void BRUSH_OT_curve_preset(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem prop_shape_items[] = { + static const EnumPropertyItem prop_shape_items[] = { {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, {CURVE_PRESET_MAX, "MAX", 0, "Max", ""}, diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index ef86f3c773d..1348847167c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -145,7 +145,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) void PAINT_OT_weight_from_bones(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights from bones"}, {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius"}, {0, NULL, 0, NULL, NULL}}; @@ -288,7 +288,7 @@ static bool weight_paint_sample_enum_itemf__helper(const MDeformVert *dvert, con } return found; } -static EnumPropertyItem *weight_paint_sample_enum_itemf( +static const EnumPropertyItem *weight_paint_sample_enum_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { if (C) { @@ -827,7 +827,7 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEve /* TODO, hardcoded, extend WM_gesture_straightline_ */ if (event->type == LEFTMOUSE && event->val == KM_PRESS) { wmGesture *gesture = op->customdata; - gesture->mode = 1; + gesture->is_active = true; } } } @@ -837,7 +837,7 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEve void PAINT_OT_weight_gradient(wmOperatorType *ot) { /* defined in DNA_space_types.h */ - static EnumPropertyItem gradient_types[] = { + static const EnumPropertyItem gradient_types[] = { {WPAINT_GRADIENT_TYPE_LINEAR, "LINEAR", 0, "Linear", ""}, {WPAINT_GRADIENT_TYPE_RADIAL, "RADIAL", 0, "Radial", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index dff536f91f2..ca5d0f53ea4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3920,7 +3920,7 @@ static const char *sculpt_tool_name(Sculpt *sd) { Brush *brush = BKE_paint_brush(&sd->paint); - switch ((BrushSculptTool)brush->sculpt_tool) { + switch ((eBrushSculptTool)brush->sculpt_tool) { case SCULPT_TOOL_DRAW: return "Draw Brush"; case SCULPT_TOOL_SMOOTH: diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 14e82e94d30..c9453f94e61 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -905,7 +905,7 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *ev void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) { - static EnumPropertyItem stroke_mode_items[] = { + static const EnumPropertyItem stroke_mode_items[] = { {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"}, {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"}, {BRUSH_STROKE_SMOOTH, "RELAX", 0, "Relax", "Switch brush to relax mode for duration of stroke"}, diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 4d67247e985..e82542cbcb2 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -397,7 +397,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) } #ifdef WITH_AUDASPACE -static EnumPropertyItem container_items[] = { +static const EnumPropertyItem container_items[] = { #ifdef WITH_FFMPEG {AUD_CONTAINER_AC3, "AC3", 0, "ac3", "Dolby Digital ATRAC 3"}, #endif @@ -429,7 +429,7 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op) const char *extension = NULL; - EnumPropertyItem *item = container_items; + const EnumPropertyItem *item = container_items; while (item->identifier != NULL) { if (item->value == container) { const char **ext = snd_ext_sound; @@ -491,7 +491,7 @@ static bool sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA * static void sound_mixdown_draw(bContext *C, wmOperator *op) { - static EnumPropertyItem pcm_format_items[] = { + static const EnumPropertyItem pcm_format_items[] = { {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, #ifdef WITH_SNDFILE @@ -503,21 +503,21 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem mp3_format_items[] = { + static const EnumPropertyItem mp3_format_items[] = { {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"}, {0, NULL, 0, NULL, NULL} }; #ifdef WITH_SNDFILE - static EnumPropertyItem flac_format_items[] = { + static const EnumPropertyItem flac_format_items[] = { {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, {0, NULL, 0, NULL, NULL} }; #endif - static EnumPropertyItem all_codec_items[] = { + static const EnumPropertyItem all_codec_items[] = { {AUD_CODEC_AAC, "AAC", 0, "AAC", "Advanced Audio Coding"}, {AUD_CODEC_AC3, "AC3", 0, "AC3", "Dolby Digital ATRAC 3"}, {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, @@ -528,7 +528,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem ogg_codec_items[] = { + static const EnumPropertyItem ogg_codec_items[] = { {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, {0, NULL, 0, NULL, NULL} @@ -641,7 +641,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op) static void SOUND_OT_mixdown(wmOperatorType *ot) { #ifdef WITH_AUDASPACE - static EnumPropertyItem format_items[] = { + static const EnumPropertyItem format_items[] = { {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, @@ -651,7 +651,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem codec_items[] = { + static const EnumPropertyItem codec_items[] = { #ifdef WITH_FFMPEG {AUD_CODEC_AAC, "AAC", 0, "AAC", "Advanced Audio Coding"}, {AUD_CODEC_AC3, "AC3", 0, "AC3", "Dolby Digital ATRAC 3"}, diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a9920389980..72b1245ca8a 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -660,7 +660,7 @@ void ACTION_OT_paste(wmOperatorType *ot) /* ******************** Insert Keyframes Operator ************************* */ /* defines for insert keyframes tool */ -static EnumPropertyItem prop_actkeys_insertkey_types[] = { +static const EnumPropertyItem prop_actkeys_insertkey_types[] = { {1, "ALL", 0, "All Channels", ""}, {2, "SEL", 0, "Only Selected Channels", ""}, {3, "GROUP", 0, "In Active Group", ""}, /* XXX not in all cases */ @@ -1110,7 +1110,7 @@ void ACTION_OT_sample(wmOperatorType *ot) #define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ -static EnumPropertyItem prop_actkeys_expo_types[] = { +static const EnumPropertyItem prop_actkeys_expo_types[] = { {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"}, {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"}, @@ -1146,7 +1146,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) /* only add if one doesn't exist */ if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) { /* TODO: add some more preset versions which set different extrapolation options? */ - add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, fcu); } } else if (mode == CLEAR_CYCLIC_EXPO) { @@ -1550,7 +1550,7 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) /* ******************** Snap Keyframes Operator *********************** */ /* defines for snap keyframes tool */ -static EnumPropertyItem prop_actkeys_snap_types[] = { +static const EnumPropertyItem prop_actkeys_snap_types[] = { {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", "Snap selected keyframes to the current frame"}, {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", @@ -1659,7 +1659,7 @@ void ACTION_OT_snap(wmOperatorType *ot) /* ******************** Mirror Keyframes Operator *********************** */ /* defines for mirror keyframes tool */ -static EnumPropertyItem prop_actkeys_mirror_types[] = { +static const EnumPropertyItem prop_actkeys_mirror_types[] = { {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", "Flip times of selected keyframes using the current frame as the mirror line"}, {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 17edbc6cc1d..1c55a0d76cf 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -309,26 +309,27 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) bAnimContext ac; rcti rect; short mode = 0, selectmode = 0; - int gesture_mode; - bool extend; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend = RNA_boolean_get(op->ptr, "extend"); - if (!extend) + if (!extend) { deselect_action_keys(&ac, 1, SELECT_SUBTRACT); + } /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); - - gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - if (gesture_mode == GESTURE_MODAL_SELECT) + + if (select) { selectmode = SELECT_ADD; - else + } + else { selectmode = SELECT_SUBTRACT; + } /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { @@ -362,10 +363,10 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->description = "Select all keyframes within the specified region"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = actkeys_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_action_active; @@ -373,7 +374,7 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } @@ -572,9 +573,7 @@ void ACTION_OT_select_lasso(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first"); + WM_operator_properties_gesture_lasso_select(ot); } /* ------------------- */ @@ -582,8 +581,8 @@ void ACTION_OT_select_lasso(wmOperatorType *ot) static int action_circle_select_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const short selectmode = (gesture_mode == GESTURE_MODAL_SELECT) ? SELECT_ADD : SELECT_SUBTRACT; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT; KeyframeEdit_CircleData data = {0}; rctf rect_fl; @@ -629,11 +628,9 @@ void ACTION_OT_select_circle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); + + /* properties */ + WM_operator_properties_gesture_circle_select(ot); } /* ******************** Column Select Operator **************************** */ @@ -645,7 +642,7 @@ void ACTION_OT_select_circle(wmOperatorType *ot) */ /* defines for column-select mode */ -static EnumPropertyItem prop_column_select_types[] = { +static const EnumPropertyItem prop_column_select_types[] = { {ACTKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""}, {ACTKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""}, {ACTKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""}, @@ -1013,7 +1010,7 @@ void ACTION_OT_select_less(wmOperatorType *ot) /* Select keyframes left/right of the current frame indicator */ /* defines for left-right select tool */ -static EnumPropertyItem prop_actkeys_leftright_select_types[] = { +static const EnumPropertyItem prop_actkeys_leftright_select_types[] = { {ACTKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""}, {ACTKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""}, {ACTKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""}, diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index f4affb90cc3..50882571dad 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -409,7 +409,8 @@ static void action_main_region_listener( /* editor level listener */ static void action_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) + bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f6c15f4d030..8aa4e674d11 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -57,6 +57,7 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_linestyle.h" +#include "BKE_workspace.h" #include "RNA_access.h" @@ -168,29 +169,53 @@ static int buttons_context_path_linestyle(ButsContextPath *path) return 0; } +static int buttons_context_path_workspace(ButsContextPath *path) +{ + PointerRNA *ptr = &path->ptr[path->len - 1]; + + /* This one just verifies. */ + return RNA_struct_is_a(ptr->type, &RNA_WorkSpace); +} + +static int buttons_context_path_collection(ButsContextPath *path) +{ + PointerRNA *ptr = &path->ptr[path->len - 1]; + + /* if we already have a (pinned) Collection, we're done */ + if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { + return 1; + } + + SceneLayer *sl = ptr->data; + LayerCollection *sc = BKE_layer_collection_get_active(sl); + + if (sc) { + RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); + path->len++; + return 1; + } + + /* no path to a collection possible */ + return 0; +} + static int buttons_context_path_object(ButsContextPath *path) { - Scene *scene; - Object *ob; PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) object, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Object)) { return 1; } - /* if we have a scene, use the scene's active object */ - else if (buttons_context_path_scene(path)) { - scene = path->ptr[path->len - 1].data; - SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); - ob = (sl->basact) ? sl->basact->object : NULL; + SceneLayer *sl = ptr->data; + Object *ob = (sl->basact) ? sl->basact->object : NULL; - if (ob) { - RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); - path->len++; + if (ob) { + RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); + path->len++; - return 1; - } + return 1; } /* no path to a object possible */ @@ -559,39 +584,11 @@ static bool buttons_context_linestyle_pinnable(const bContext *C) } #endif -static int buttons_context_path_collection(const bContext *C, ButsContextPath *path) -{ - PointerRNA *ptr = &path->ptr[path->len - 1]; - - /* if we already have a (pinned) Collection, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { - return 1; - } - - SceneLayer *sl = CTX_data_scene_layer(C); - LayerCollection *sc = BKE_layer_collection_get_active(sl); - - if (sc) { - RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); - path->len++; - - /* temporary object in context path to get edit mode */ - Object *ob = CTX_data_active_object(C); - if (ob) { - RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); - path->len++; - } - - return 1; - } - - /* no path to a collection possible */ - return 0; -} - static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { SpaceButs *sbuts = CTX_wm_space_buts(C); + Scene *scene = CTX_data_scene(C); + WorkSpace *workspace = CTX_wm_workspace(C); ID *id; int found; @@ -599,18 +596,32 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma path->flag = flag; path->tex_ctx = sbuts->texture_context; - /* if some ID datablock is pinned, set the root pointer */ + const bool use_scene_settings = BKE_workspace_use_scene_settings_get(workspace); + + /* If some ID datablock is pinned, set the root pointer. */ if (sbuts->pinid) { id = sbuts->pinid; RNA_id_pointer_create(id, &path->ptr[0]); path->len++; } + /* No pinned root, use scene or workspace as initial root. */ + else { + if ((mainb != BCONTEXT_WORKSPACE) && (use_scene_settings || + ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD))) + { + RNA_id_pointer_create(&scene->id, &path->ptr[0]); + path->len++; + } + else { + RNA_id_pointer_create(&workspace->id, &path->ptr[0]); + path->len++; + } + } - /* no pinned root, use scene as root */ - if (path->len == 0) { - id = (ID *)CTX_data_scene(C); - RNA_id_pointer_create(id, &path->ptr[0]); + if (!ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD)) { + SceneLayer *scene_layer = BKE_scene_layer_from_workspace_get(scene, workspace); + RNA_pointer_create(NULL, &RNA_SceneLayer, scene_layer, &path->ptr[path->len]); path->len++; } @@ -635,6 +646,12 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma case BCONTEXT_WORLD: found = buttons_context_path_world(path); break; + case BCONTEXT_WORKSPACE: + found = buttons_context_path_workspace(path); + break; + case BCONTEXT_COLLECTION: + found = buttons_context_path_collection(path); + break; case BCONTEXT_OBJECT: case BCONTEXT_PHYSICS: case BCONTEXT_CONSTRAINT: @@ -663,9 +680,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma case BCONTEXT_BONE_CONSTRAINT: found = buttons_context_path_pose_bone(path); break; - case BCONTEXT_COLLECTION: - found = buttons_context_path_collection(C, path); - break; default: found = 0; break; @@ -783,7 +797,7 @@ const char *buttons_context_dir[] = { "texture", "texture_user", "texture_user_property", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", "particle_settings", "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", - "line_style", "collection", NULL + "line_style", "collection", "workspace", NULL }; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) @@ -812,6 +826,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_World); return 1; } + else if (CTX_data_equals(member, "workspace")) { + /* Do not return one here if scene not found in path, in this case we want to get default context scene! */ + return set_pointer_type(path, result, &RNA_WorkSpace); + } else if (CTX_data_equals(member, "object")) { set_pointer_type(path, result, &RNA_Object); return 1; @@ -1168,10 +1186,14 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if (name) { - if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene) + if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene) || + (!ELEM(sbuts->mainb, BCONTEXT_WORKSPACE) && ptr->type == &RNA_WorkSpace)) + { uiItemLDrag(row, ptr, "", icon); /* save some space */ - else + } + else { uiItemLDrag(row, ptr, name, icon); + } if (name != namebuf) MEM_freeN(name); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 299ab7171d6..3607f817721 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -151,6 +151,10 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar) ED_region_panels(C, ar, "render_layer", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_WORLD) ED_region_panels(C, ar, "world", sbuts->mainb, vertical); + else if (sbuts->mainb == BCONTEXT_WORKSPACE) + ED_region_panels(C, ar, "workspace", sbuts->mainb, vertical); + else if (sbuts->mainb == BCONTEXT_COLLECTION) + ED_region_panels(C, ar, "collection", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_OBJECT) ED_region_panels(C, ar, "object", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_DATA) @@ -171,8 +175,6 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar) ED_region_panels(C, ar, "constraint", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) ED_region_panels(C, ar, "bone_constraint", sbuts->mainb, vertical); - else if (sbuts->mainb == BCONTEXT_COLLECTION) - ED_region_panels(C, ar, "collection", sbuts->mainb, vertical); sbuts->re_align = 0; sbuts->mainbo = sbuts->mainb; @@ -235,7 +237,8 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) /* reused! */ static void buttons_area_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) + bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { SpaceButs *sbuts = sa->spacedata.first; diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index edac128d18b..e5a3cb6b57b 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -332,8 +332,7 @@ void CLIP_OT_graph_select(wmOperatorType *ot) typedef struct BorderSelectuserData { rctf rect; - int mode; - bool changed, extend; + bool select, extend, changed; } BorderSelectuserData; static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), @@ -349,11 +348,12 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), else flag = MARKER_GRAPH_SEL_Y; - if (data->mode == GESTURE_MODAL_SELECT) + if (data->select) { marker->flag |= flag; - else + } + else { marker->flag &= ~flag; - + } data->changed = true; } else if (!data->extend) { @@ -381,7 +381,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view_rctf(&ar->v2d, &rect, &userdata.rect); userdata.changed = false; - userdata.mode = RNA_int_get(op->ptr, "gesture_mode"); + userdata.select = !RNA_boolean_get(op->ptr, "deselect"); userdata.extend = RNA_boolean_get(op->ptr, "extend"); clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, border_select_cb, NULL, NULL); @@ -403,16 +403,16 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot) ot->idname = "CLIP_OT_graph_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = border_select_graph_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = clip_graph_knots_poll; /* flags */ ot->flag = OPTYPE_UNDO; /* properties */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /********************** select all operator *********************/ @@ -701,7 +701,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) void CLIP_OT_graph_disable_markers(wmOperatorType *ot) { - static EnumPropertyItem actions_items[] = { + static const EnumPropertyItem actions_items[] = { {0, "DISABLE", 0, "Disable", "Disable selected markers"}, {1, "ENABLE", 0, "Enable", "Enable selected markers"}, {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"}, diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index f185eea6d32..478254fb165 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -330,7 +330,8 @@ static SpaceLink *clip_duplicate(SpaceLink *sl) return (SpaceLink *)scn; } -static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index ea7ede46887..2439ac06d9c 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1138,7 +1138,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) void CLIP_OT_clear_track_path(wmOperatorType *ot) { - static EnumPropertyItem clear_path_actions[] = { + static const EnumPropertyItem clear_path_actions[] = { {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear up-to", "Clear path up to current frame"}, {TRACK_CLEAR_REMAINED, "REMAINED", 0, "Clear remained", "Clear path at remaining frames (after current)"}, {TRACK_CLEAR_ALL, "ALL", 0, "Clear all", "Clear the whole path"}, @@ -1210,7 +1210,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) void CLIP_OT_disable_markers(wmOperatorType *ot) { - static EnumPropertyItem actions_items[] = { + static const EnumPropertyItem actions_items[] = { {MARKER_OP_DISABLE, "DISABLE", 0, "Disable", "Disable selected markers"}, {MARKER_OP_ENABLE, "ENABLE", 0, "Enable", @@ -1477,7 +1477,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) void CLIP_OT_frame_jump(wmOperatorType *ot) { - static EnumPropertyItem position_items[] = { + static const EnumPropertyItem position_items[] = { {0, "PATHSTART", 0, "Path Start", "Jump to start of current path"}, {1, "PATHEND", 0, "Path End", "Jump to end of current path"}, {2, "FAILEDPREV", 0, "Previous Failed", "Jump to previous failed frame"}, @@ -1645,7 +1645,7 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) void CLIP_OT_lock_tracks(wmOperatorType *ot) { - static EnumPropertyItem actions_items[] = { + static const EnumPropertyItem actions_items[] = { {TRACK_ACTION_LOCK, "LOCK", 0, "Lock", "Lock selected tracks"}, {TRACK_ACTION_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock selected tracks"}, {TRACK_ACTION_TOGGLE, "TOGGLE", 0, "Toggle", @@ -1701,7 +1701,7 @@ static int set_solver_keyframe_exec(bContext *C, wmOperator *op) void CLIP_OT_set_solver_keyframe(wmOperatorType *ot) { - static EnumPropertyItem keyframe_items[] = { + static const EnumPropertyItem keyframe_items[] = { {SOLVER_KEYFRAME_A, "KEYFRAME_A", 0, "Keyframe A", ""}, {SOLVER_KEYFRAME_B, "KEYFRAME_B", 0, "Keyframe B", ""}, {0, NULL, 0, NULL, NULL} @@ -1972,7 +1972,7 @@ static int clean_tracks_invoke(bContext *C, void CLIP_OT_clean_tracks(wmOperatorType *ot) { - static EnumPropertyItem actions_items[] = { + static const EnumPropertyItem actions_items[] = { {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"}, {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", diff --git a/source/blender/editors/space_clip/tracking_ops_detect.c b/source/blender/editors/space_clip/tracking_ops_detect.c index 992c347a630..0ee06b305da 100644 --- a/source/blender/editors/space_clip/tracking_ops_detect.c +++ b/source/blender/editors/space_clip/tracking_ops_detect.c @@ -128,7 +128,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) void CLIP_OT_detect_features(wmOperatorType *ot) { - static EnumPropertyItem placement_items[] = { + static const EnumPropertyItem placement_items[] = { {0, "FRAME", 0, "Whole Frame", "Place markers across the whole frame"}, {1, "INSIDE_GPENCIL", 0, "Inside grease pencil", diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c index c411f64a88b..1abfa0ae2a4 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.c +++ b/source/blender/editors/space_clip/tracking_ops_orient.c @@ -509,7 +509,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) void CLIP_OT_set_plane(wmOperatorType *ot) { - static EnumPropertyItem plane_items[] = { + static const EnumPropertyItem plane_items[] = { {0, "FLOOR", 0, "Floor", "Set floor plane"}, {1, "WALL", 0, "Wall", "Set wall plane"}, {0, NULL, 0, NULL, NULL} @@ -583,7 +583,7 @@ static int set_axis_exec(bContext *C, wmOperator *op) void CLIP_OT_set_axis(wmOperatorType *ot) { - static EnumPropertyItem axis_actions[] = { + static const EnumPropertyItem axis_actions[] = { {0, "X", 0, "X", "Align bundle align X axis"}, {1, "Y", 0, "Y", "Align bundle align Y axis"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index e970b1b9743..eddd65475a2 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -438,7 +438,6 @@ static int border_select_exec(bContext *C, wmOperator *op) rcti rect; rctf rectf; bool changed = false; - int mode, extend; int framenr = ED_space_clip_get_clip_frame_number(sc); /* get rectangle from operator */ @@ -447,8 +446,8 @@ static int border_select_exec(bContext *C, wmOperator *op) ED_clip_point_stable_pos(sc, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); ED_clip_point_stable_pos(sc, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - mode = RNA_int_get(op->ptr, "gesture_mode"); - extend = RNA_boolean_get(op->ptr, "extend"); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* do actual selection */ track = tracksbase->first; @@ -458,10 +457,12 @@ static int border_select_exec(bContext *C, wmOperator *op) if (MARKER_VISIBLE(sc, track, marker)) { if (BLI_rctf_isect_pt_v(&rectf, marker->pos)) { - if (mode == GESTURE_MODAL_SELECT) + if (select) { BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); - else + } + else { BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT); + } } else if (!extend) { BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT); @@ -485,7 +486,7 @@ static int border_select_exec(bContext *C, wmOperator *op) for (i = 0; i < 4; i++) { if (BLI_rctf_isect_pt_v(&rectf, plane_marker->corners[i])) { - if (mode == GESTURE_MODAL_SELECT) { + if (select) { plane_track->flag |= SELECT; } else { @@ -520,16 +521,16 @@ void CLIP_OT_select_border(wmOperatorType *ot) ot->idname = "CLIP_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = border_select_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_UNDO; /* properties */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /********************** lasso select operator *********************/ @@ -656,9 +657,7 @@ void CLIP_OT_select_lasso(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + WM_operator_properties_gesture_lasso_select(ot); } /********************** circle select operator *********************/ @@ -690,17 +689,17 @@ static int circle_select_exec(bContext *C, wmOperator *op) MovieTrackingPlaneTrack *plane_track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking); - int x, y, radius, width, height, mode; + int width, height; bool changed = false; float zoomx, zoomy, offset[2], ellipse[2]; int framenr = ED_space_clip_get_clip_frame_number(sc); /* get operator properties */ - x = RNA_int_get(op->ptr, "x"); - y = RNA_int_get(op->ptr, "y"); - radius = RNA_int_get(op->ptr, "radius"); + const int x = RNA_int_get(op->ptr, "x"); + const int y = RNA_int_get(op->ptr, "y"); + const int radius = RNA_int_get(op->ptr, "radius"); - mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); /* compute ellipse and position in unified coordinates */ ED_space_clip_get_size(sc, &width, &height); @@ -718,11 +717,12 @@ static int circle_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) { - if (mode == GESTURE_MODAL_SELECT) + if (select) { BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); - else + } + else { BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT); - + } changed = true; } } @@ -741,7 +741,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) for (i = 0; i < 4; i++) { if (point_inside_ellipse(plane_marker->corners[i], offset, ellipse)) { - if (mode == GESTURE_MODAL_SELECT) { + if (select) { plane_track->flag |= SELECT; } else { @@ -782,10 +782,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); + WM_operator_properties_gesture_circle_select(ot); } /********************** select all operator *********************/ @@ -975,7 +972,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) void CLIP_OT_select_grouped(wmOperatorType *ot) { - static EnumPropertyItem select_group_items[] = { + static const EnumPropertyItem select_group_items[] = { {0, "KEYFRAMED", 0, "Keyframed tracks", "Select all keyframed tracks"}, {1, "ESTIMATED", 0, "Estimated tracks", "Select all estimated tracks"}, {2, "TRACKED", 0, "Tracked tracks", "Select all tracked tracks"}, diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 2b99c4dfa3d..b740ff4b397 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -299,7 +299,7 @@ static bool console_line_column_from_index( /* static funcs for text editing */ /* similar to the text editor, with some not used. keep compatible */ -static EnumPropertyItem console_move_type_items[] = { +static const EnumPropertyItem console_move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -570,7 +570,7 @@ void CONSOLE_OT_unindent(wmOperatorType *ot) ot->poll = ED_operator_console_active; } -static EnumPropertyItem console_delete_type_items[] = { +static const EnumPropertyItem console_delete_type_items[] = { {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, @@ -895,7 +895,7 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op) void CONSOLE_OT_scrollback_append(wmOperatorType *ot) { /* defined in DNA_space_types.h */ - static EnumPropertyItem console_line_type_items[] = { + static const EnumPropertyItem console_line_type_items[] = { {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""}, {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""}, {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""}, diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 22c1214d928..cca33cdd1a7 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -105,7 +105,7 @@ static void file_deselect_all(SpaceFile *sfile, unsigned int flag) filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } -typedef enum FileSelect { +typedef enum FileSelect { FILE_SELECT_NOTHING = 0, FILE_SELECT_DIR = 1, FILE_SELECT_FILE = 2 @@ -370,7 +370,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent * int result; - result = WM_border_select_modal(C, op, event); + result = WM_gesture_border_modal(C, op, event); if (result == OPERATOR_RUNNING_MODAL) { WM_operator_properties_border_to_rcti(op, &rect); @@ -419,7 +419,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) SpaceFile *sfile = CTX_wm_space_file(C); rcti rect; FileSelect ret; - const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); WM_operator_properties_border_to_rcti(op, &rect); @@ -452,14 +452,14 @@ void FILE_OT_select_border(wmOperatorType *ot) ot->idname = "FILE_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = file_border_select_exec; ot->modal = file_border_select_modal; ot->poll = ED_operator_file_active; - ot->cancel = WM_border_select_cancel; + ot->cancel = WM_gesture_border_cancel; /* properties */ - WM_operator_properties_gesture_border(ot, 1); + WM_operator_properties_gesture_border_select(ot); } static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -730,7 +730,7 @@ static int file_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *U void FILE_OT_select_walk(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {FILE_SELECT_WALK_UP, "UP", 0, "Prev", ""}, {FILE_SELECT_WALK_DOWN, "DOWN", 0, "Next", ""}, {FILE_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""}, @@ -1041,7 +1041,7 @@ static int bookmark_move_exec(bContext *C, wmOperator *op) void FILE_OT_bookmark_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {FILE_BOOKMARK_MOVE_TOP, "TOP", 0, "Top", "Top of the list"}, {FILE_BOOKMARK_MOVE_UP, "UP", 0, "Up", ""}, {FILE_BOOKMARK_MOVE_DOWN, "DOWN", 0, "Down", ""}, diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 6e4815af032..780c2ec5a47 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -292,7 +292,8 @@ static void file_refresh(const bContext *C, ScrArea *sa) } } -static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 12d872a3c8a..2876fccaa51 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -503,7 +503,7 @@ typedef enum eGraphKeys_InsertKey_Types { } eGraphKeys_InsertKey_Types; /* RNA mode types for insert keyframes tool */ -static EnumPropertyItem prop_graphkeys_insertkey_types[] = { +static const EnumPropertyItem prop_graphkeys_insertkey_types[] = { {GRAPHKEYS_INSERTKEY_ALL, "ALL", 0, "All Channels", "Insert a keyframe on all visible and editable F-Curves using each curve's current value"}, {GRAPHKEYS_INSERTKEY_SEL, "SEL", 0, "Only Selected Channels", @@ -1467,7 +1467,7 @@ void GRAPH_OT_sample(wmOperatorType *ot) #define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ -static EnumPropertyItem prop_graphkeys_expo_types[] = { +static const EnumPropertyItem prop_graphkeys_expo_types[] = { {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"}, {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"}, @@ -1505,7 +1505,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) /* only add if one doesn't exist */ if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) { // TODO: add some more preset versions which set different extrapolation options? - add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, fcu); } } else if (mode == CLEAR_CYCLIC_EXPO) { @@ -2067,7 +2067,7 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) /* ******************** Snap Keyframes Operator *********************** */ /* defines for snap keyframes tool */ -static EnumPropertyItem prop_graphkeys_snap_types[] = { +static const EnumPropertyItem prop_graphkeys_snap_types[] = { {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", "Snap selected keyframes to the current frame"}, {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", @@ -2196,7 +2196,7 @@ void GRAPH_OT_snap(wmOperatorType *ot) /* ******************** Mirror Keyframes Operator *********************** */ /* defines for mirror keyframes tool */ -static EnumPropertyItem prop_graphkeys_mirror_types[] = { +static const EnumPropertyItem prop_graphkeys_mirror_types[] = { {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", "Flip times of selected keyframes using the current frame as the mirror line"}, {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", @@ -2387,7 +2387,7 @@ void GRAPH_OT_smooth(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ -static EnumPropertyItem *graph_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL; int totitem = 0; @@ -2447,7 +2447,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) FModifier *fcm; /* add F-Modifier of specified type to active F-Curve, and make it the active one */ - fcm = add_fmodifier(&fcu->modifiers, type); + fcm = add_fmodifier(&fcu->modifiers, type, fcu); if (fcm) { set_active_fmodifier(&fcu->modifiers, fcm); } @@ -2583,7 +2583,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) FCurve *fcu = (FCurve *)ale->data; int tot; - tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace); + tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace, fcu); if (tot) { ale->update |= ANIM_UPDATE_DEPS; diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 67b960bfa53..68982275c79 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -332,25 +332,27 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) rctf rect_fl; short mode = 0, selectmode = 0; bool incl_handles; - bool extend; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend = RNA_boolean_get(op->ptr, "extend"); + if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true); /* get select mode - * - 'gesture_mode' from the operator specifies how to select * - 'include_handles' from the operator specifies whether to include handles in the selection */ - if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT) + if (select) { selectmode = SELECT_ADD; - else + } + else { selectmode = SELECT_SUBTRACT; + } incl_handles = RNA_boolean_get(op->ptr, "include_handles"); @@ -391,10 +393,10 @@ void GRAPH_OT_select_border(wmOperatorType *ot) ot->description = "Select all keyframes within the specified region"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = graphkeys_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = graphop_visible_keyframes_poll; @@ -402,7 +404,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria"); @@ -486,9 +488,7 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first"); + WM_operator_properties_gesture_lasso_select(ot); } /* ------------------- */ @@ -496,8 +496,8 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot) static int graph_circle_select_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const short selectmode = (gesture_mode == GESTURE_MODAL_SELECT) ? SELECT_ADD : SELECT_SUBTRACT; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT; bool incl_handles = false; KeyframeEdit_CircleData data = {0}; @@ -555,11 +555,9 @@ void GRAPH_OT_select_circle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); + + /* properties */ + WM_operator_properties_gesture_circle_select(ot); } /* ******************** Column Select Operator **************************** */ @@ -571,7 +569,7 @@ void GRAPH_OT_select_circle(wmOperatorType *ot) */ /* defines for column-select mode */ -static EnumPropertyItem prop_column_select_types[] = { +static const EnumPropertyItem prop_column_select_types[] = { {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""}, {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""}, {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""}, @@ -916,7 +914,7 @@ void GRAPH_OT_select_less(wmOperatorType *ot) /* Select keyframes left/right of the current frame indicator */ /* defines for left-right select tool */ -static EnumPropertyItem prop_graphkeys_leftright_select_types[] = { +static const EnumPropertyItem prop_graphkeys_leftright_select_types[] = { {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""}, {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""}, {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""}, diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index d2358a494d5..4b89c8db9e6 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -475,7 +475,8 @@ static void graph_region_listener( } /* editor level listener */ -static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 806ddaa8a43..88613682b8b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1003,7 +1003,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); rctf bounds; - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); WM_operator_properties_border_to_rctf(op, &bounds); @@ -1022,7 +1022,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op) sima_zoom_set_from_bounds(sima, ar, &bounds); /* zoom out */ - if (gesture_mode == GESTURE_MODAL_OUT) { + if (!zoom_in) { sima->xof = sima_view_prev.xof + (sima->xof - sima_view_prev.xof); sima->yof = sima_view_prev.yof + (sima->yof - sima_view_prev.yof); sima->zoom = sima_view_prev.zoom * (sima_view_prev.zoom / sima->zoom); @@ -1041,15 +1041,15 @@ void IMAGE_OT_view_zoom_border(wmOperatorType *ot) ot->idname = "IMAGE_OT_view_zoom_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = image_view_zoom_border_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = space_image_main_region_poll; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border_zoom(ot); } /**************** load/replace/save callbacks ******************/ @@ -2556,7 +2556,7 @@ void IMAGE_OT_new(wmOperatorType *ot) PropertyRNA *prop; static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - static EnumPropertyItem gen_context_items[] = { + static const EnumPropertyItem gen_context_items[] = { {GEN_CONTEXT_NONE, "NONE", 0, "None", ""}, {GEN_CONTEXT_PAINT_CANVAS, "PAINT_CANVAS", 0, "Paint Canvas", ""}, {GEN_CONTEXT_PAINT_STENCIL, "PAINT_STENCIL", 0, "Paint Stencil", ""}, @@ -3263,7 +3263,7 @@ void IMAGE_OT_sample_line(wmOperatorType *ot) void IMAGE_OT_curves_point_set(wmOperatorType *ot) { - static EnumPropertyItem point_items[] = { + static const EnumPropertyItem point_items[] = { {0, "BLACK_POINT", 0, "Black Point", ""}, {1, "WHITE_POINT", 0, "White Point", ""}, {0, NULL, 0, NULL, NULL} @@ -3691,10 +3691,10 @@ void IMAGE_OT_render_border(wmOperatorType *ot) ot->idname = "IMAGE_OT_render_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = render_border_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = image_cycle_render_slot_poll; /* flags */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 514cb1ab97e..cd4bfb918b3 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -442,7 +442,8 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } -static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *scene) +static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene, + WorkSpace *workspace) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; @@ -536,7 +537,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, co case ND_TRANSFORM: case ND_MODIFIER: { - SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); + SceneLayer *sl = BKE_scene_layer_from_workspace_get(scene, workspace); Object *ob = OBACT_NEW(sl); if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) { if (sima->lock && (sima->flag & SI_DRAWSHADOW)) { diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 0cc01646e82..31df9b199ea 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -230,7 +230,7 @@ static int borderselect_exec(bContext *C, wmOperator *op) rcti rect; //rctf rectf, rq; - const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); //int mval[2]; WM_operator_properties_border_to_rcti(op, &rect); @@ -298,10 +298,10 @@ void INFO_OT_select_border(wmOperatorType *ot) ot->idname = "INFO_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_info_active; @@ -309,7 +309,7 @@ void INFO_OT_select_border(wmOperatorType *ot) /* ot->flag = OPTYPE_REGISTER; */ /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index bd1bdb952d6..463195f74f7 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -301,7 +301,7 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) } } - stats_object(ob, base->flag_legacy & SELECT, 1, stats); + stats_object(ob, base->flag & BASE_SELECTED, 1, stats); stats->totobj++; } else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS | OB_DUPLIFACES))) { @@ -317,23 +317,23 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) } stats->totobj += tot; - stats_object(ob, base->flag_legacy & SELECT, tot, stats); + stats_object(ob, base->flag & BASE_SELECTED, tot, stats); } else if (ob->transflag & OB_DUPLIFRAMES) { /* Dupli Frames */ int tot = count_duplilist(ob); stats->totobj += tot; - stats_object(ob, base->flag_legacy & SELECT, tot, stats); + stats_object(ob, base->flag & BASE_SELECTED, tot, stats); } else if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { /* Dupli Group */ int tot = count_duplilist(ob); stats->totobj += tot; - stats_object(ob, base->flag_legacy & SELECT, tot, stats); + stats_object(ob, base->flag & BASE_SELECTED, tot, stats); } else { /* No Dupli */ - stats_object(ob, base->flag_legacy & SELECT, 1, stats); + stats_object(ob, base->flag & BASE_SELECTED, 1, stats); stats->totobj++; } } diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index e5eee21ed08..54e6e217b77 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -142,8 +142,6 @@ static int cut_links_exec(bContext *C, wmOperator *op) void LOGIC_OT_links_cut(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name = "Cut Links"; ot->idname = "LOGIC_OT_links_cut"; ot->description = "Remove logic brick connections"; @@ -158,8 +156,10 @@ void LOGIC_OT_links_cut(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); + /* properties */ + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); } diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 1559515221e..35a29f4bad8 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -562,7 +562,7 @@ static void LOGIC_OT_actuator_add(wmOperatorType *ot) } /* ************* Move Logic Bricks Operator ************* */ -static EnumPropertyItem logicbricks_move_direction[] = { +static const EnumPropertyItem logicbricks_move_direction[] = { {1, "UP", 0, "Move Up", ""}, {2, "DOWN", 0, "Move Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index f7f7c82171d..31524f8450a 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -2089,7 +2089,7 @@ void NLA_OT_clear_scale(wmOperatorType *ot) /* Moves the start-point of the selected strips to the specified places */ /* defines for snap keyframes tool */ -static EnumPropertyItem prop_nlaedit_snap_types[] = { +static const EnumPropertyItem prop_nlaedit_snap_types[] = { {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current Frame", ""}, {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? @@ -2239,7 +2239,7 @@ void NLA_OT_snap(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ -static EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL; int totitem = 0; @@ -2316,7 +2316,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) continue; /* add F-Modifier of specified type to selected, and make it the active one */ - fcm = add_fmodifier(&strip->modifiers, type); + fcm = add_fmodifier(&strip->modifiers, type, NULL); if (fcm) { set_active_fmodifier(&strip->modifiers, fcm); @@ -2470,7 +2470,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) } /* paste FModifiers from buffer */ - ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace); + ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, NULL); ale->update |= ANIM_UPDATE_DEPS; } } diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 8261397c940..1179401f346 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -278,25 +278,28 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) bAnimContext ac; rcti rect; short mode = 0, selectmode = 0; - int extend; + const bool select = !RNA_boolean_get(op->ptr, "deselect"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend = RNA_boolean_get(op->ptr, "extend"); - if (!extend) + if (!extend) { deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_SUBTRACT); + } /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); - - if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT) + + if (select) { selectmode = SELECT_ADD; - else + } + else { selectmode = SELECT_SUBTRACT; - + } + /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { /* mode depends on which axis of the range is larger to determine which axis to use @@ -329,10 +332,10 @@ void NLA_OT_select_border(wmOperatorType *ot) ot->description = "Use box selection to grab NLA-Strips"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = nlaedit_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = nlaop_poll_tweakmode_off; @@ -340,7 +343,7 @@ void NLA_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, 1); + WM_operator_properties_gesture_border_select(ot); RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } @@ -349,7 +352,7 @@ void NLA_OT_select_border(wmOperatorType *ot) /* Select keyframes left/right of the current frame indicator */ /* defines for left-right select tool */ -static EnumPropertyItem prop_nlaedit_leftright_select_types[] = { +static const EnumPropertyItem prop_nlaedit_leftright_select_types[] = { {NLAEDIT_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""}, {NLAEDIT_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""}, {NLAEDIT_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""}, diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index ab7a913ce62..f6068087f02 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -477,7 +477,8 @@ static void nla_channel_region_listener( } /* editor level listener */ -static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index dc6b06790e0..ec35727d176 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -277,8 +277,6 @@ static int add_reroute_exec(bContext *C, wmOperator *op) void NODE_OT_add_reroute(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name = "Add Reroute"; ot->idname = "NODE_OT_add_reroute"; ot->description = "Add a reroute node"; @@ -293,8 +291,10 @@ void NODE_OT_add_reroute(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); + /* properties */ + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); /* internal */ RNA_def_int(ot->srna, "cursor", BC_CROSSCURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); } @@ -517,7 +517,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { return rna_node_tree_type_itemf(NULL, NULL, r_free); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index a8bf68d92e2..a9bc58661a0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -383,7 +383,7 @@ bool ED_node_is_texture(struct SpaceNode *snode) /* called from shading buttons or header */ void ED_node_shader_default(const bContext *C, ID *id) { - Scene *scene = CTX_data_scene(C); + ViewRender *view_render = CTX_data_view_render(C); bNode *in, *out; bNodeSocket *fromsock, *tosock, *sock; bNodeTree *ntree; @@ -398,11 +398,11 @@ void ED_node_shader_default(const bContext *C, ID *id) Material *ma = (Material *)id; ma->nodetree = ntree; - if (BKE_scene_uses_blender_eevee(scene)) { + if (BKE_viewrender_uses_blender_eevee(view_render)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_PRINCIPLED; } - else if (BKE_scene_use_new_shading_nodes(scene)) { + else if (BKE_viewrender_use_new_shading_nodes(view_render)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_DIFFUSE; } @@ -460,7 +460,7 @@ void ED_node_shader_default(const bContext *C, ID *id) nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ - if (BKE_scene_use_new_shading_nodes(scene)) { + if (BKE_viewrender_use_new_shading_nodes(view_render)) { PointerRNA sockptr; sock = in->inputs.first; RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr); @@ -1910,7 +1910,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, { 0, NULL, 0, NULL, NULL } @@ -2278,7 +2278,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot) /********************** Move interface socket operator *********************/ -static EnumPropertyItem move_direction_items[] = { +static const EnumPropertyItem move_direction_items[] = { { 1, "UP", 0, "Up", "" }, { 2, "DOWN", 0, "Down", "" }, { 0, NULL, 0, NULL, NULL }, @@ -2353,7 +2353,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot) static int node_shader_script_update_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - RenderEngineType *type = RE_engines_find(scene->r.engine); + RenderEngineType *type = RE_engines_find(scene->view_render.engine_id); SpaceNode *snode = CTX_wm_space_node(C); bNode *node; Text *text; @@ -2423,7 +2423,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) bool found = false; /* setup render engine */ - type = RE_engines_find(scene->r.engine); + type = RE_engines_find(scene->view_render.engine_id); engine = RE_engine_create(type); engine->reports = op->reports; @@ -2568,17 +2568,17 @@ void NODE_OT_viewer_border(wmOperatorType *ot) ot->idname = "NODE_OT_viewer_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = viewer_border_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = composite_node_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 9d750bfe348..7eaf35c6c4f 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -515,7 +515,7 @@ typedef enum eNodeGroupSeparateType { } eNodeGroupSeparateType; /* Operator Property */ -static EnumPropertyItem node_group_separate_types[] = { +static const EnumPropertyItem node_group_separate_types[] = { {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 3b03399a5e7..64c019d12a3 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1007,8 +1007,6 @@ static int cut_links_exec(bContext *C, wmOperator *op) void NODE_OT_links_cut(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name = "Cut Links"; ot->idname = "NODE_OT_links_cut"; ot->description = "Use the mouse to cut (remove) some links"; @@ -1023,8 +1021,11 @@ void NODE_OT_links_cut(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); + /* properties */ + PropertyRNA *prop; + prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); } diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 7195d2a9838..dc7863bb354 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -333,7 +333,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op) void NODE_OT_select_grouped(wmOperatorType *ot) { - static EnumPropertyItem prop_select_grouped_types[] = { + static const EnumPropertyItem prop_select_grouped_types[] = { {NODE_SELECT_GROUPED_TYPE, "TYPE", 0, "Type", ""}, {NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""}, {NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""}, @@ -524,23 +524,23 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); bNode *node; rctf rectf; - int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); for (node = snode->edittree->nodes.first; node; node = node->next) { - bool select; + bool is_inside; if (node->type == NODE_FRAME) { - select = BLI_rctf_inside_rctf(&rectf, &node->totr); + is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr); } else { - select = BLI_rctf_isect(&rectf, &node->totr, NULL); + is_inside = BLI_rctf_isect(&rectf, &node->totr, NULL); } - if (select) { - nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT)); + if (is_inside) { + nodeSetSelected(node, select); } else if (!extend) { nodeSetSelected(node, false); @@ -571,7 +571,7 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } - return WM_border_select_invoke(C, op, event); + return WM_gesture_border_invoke(C, op, event); } void NODE_OT_select_border(wmOperatorType *ot) @@ -584,8 +584,8 @@ void NODE_OT_select_border(wmOperatorType *ot) /* api callbacks */ ot->invoke = node_border_select_invoke; ot->exec = node_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_node_active; @@ -593,7 +593,7 @@ void NODE_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); } @@ -605,12 +605,12 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); bNode *node; - int x, y, radius, gesture_mode; + int x, y, radius; float offset[2]; float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur)); - gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); /* get operator properties */ x = RNA_int_get(op->ptr, "x"); @@ -621,7 +621,7 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) for (node = snode->edittree->nodes.first; node; node = node->next) { if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { - nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT)); + nodeSetSelected(node, select); } } @@ -647,11 +647,8 @@ void NODE_OT_select_circle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* rna */ - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); + /* properties */ + WM_operator_properties_gesture_circle_select(ot); } /* ****** Lasso Select ****** */ @@ -728,9 +725,7 @@ void NODE_OT_select_lasso(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + WM_operator_properties_gesture_lasso_select(ot); } /* ****** Select/Deselect All ****** */ diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 5d0877a1eff..c791b9f6eae 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -559,6 +559,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); + ViewRender *view_render = CTX_data_view_render(C); uiBlock *block = uiLayoutGetBlock(layout); uiBut *but = (uiBut *)but_p; uiLayout *split, *column; @@ -575,7 +576,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ arg->layout = split; if (ntreetype && ntreetype->foreach_nodeclass) - ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); + ntreetype->foreach_nodeclass(view_render, arg, node_menu_column_foreach_cb); column = uiLayoutColumn(split, false); UI_block_layout_set_current(block, column); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 7cb22dcc570..e1765e39f7a 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -382,12 +382,14 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) } -static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *scene) +static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene, + WorkSpace *workspace) { /* note, ED_area_tag_refresh will re-execute compositor */ SpaceNode *snode = sa->spacedata.first; + ViewRender *view_render = BKE_viewrender_get(scene, workspace); /* shaderfrom is only used for new shading nodes, otherwise all shaders are from objects */ - short shader_type = BKE_scene_use_new_shading_nodes(scene) ? snode->shaderfrom : SNODE_SHADER_OBJECT; + short shader_type = BKE_viewrender_use_new_shading_nodes(view_render) ? snode->shaderfrom : SNODE_SHADER_OBJECT; /* preview renders */ switch (wmn->category) { diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 092909cbcba..45d632dc293 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -160,7 +160,8 @@ static void collection_scene_collection_itemf_recursive( } } -static EnumPropertyItem *collection_scene_collection_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *collection_scene_collection_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 98388ecb3ec..24f147a68bf 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -542,7 +542,7 @@ static int outliner_id_remap_invoke(bContext *C, wmOperator *op, const wmEvent * return WM_operator_props_dialog_popup(C, op, 200, 100); } -static EnumPropertyItem *outliner_id_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *outliner_id_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem item_tmp = {0}, *item = NULL; int totitem = 0; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index a470711d9df..0ef39fc4c92 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1059,12 +1059,12 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) /* ****************************************************** */ /* **************** Border Select Tool ****************** */ -static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement *te, int gesture_mode) +static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement *te, bool select) { TreeStoreElem *tselem = TREESTORE(te); if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) { - if (gesture_mode == GESTURE_MODAL_SELECT) { + if (select) { tselem->flag |= TSE_SELECTED; } else { @@ -1075,7 +1075,7 @@ static void outliner_item_border_select(Scene *scene, rctf *rectf, TreeElement * /* Look at its children. */ if ((tselem->flag & TSE_CLOSED) == 0) { for (te = te->subtree.first; te; te = te->next) { - outliner_item_border_select(scene, rectf, te, gesture_mode); + outliner_item_border_select(scene, rectf, te, select); } } } @@ -1087,13 +1087,13 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); TreeElement *te; rctf rectf; - int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + bool select = !RNA_boolean_get(op->ptr, "deselect"); WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); for (te = soops->tree.first; te; te = te->next) { - outliner_item_border_select(scene, &rectf, te, gesture_mode); + outliner_item_border_select(scene, &rectf, te, select); } WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -1110,10 +1110,10 @@ void OUTLINER_OT_select_border(wmOperatorType *ot) ot->description = "Use box selection to select tree elements"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = outliner_border_select_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_outliner_active; @@ -1121,7 +1121,7 @@ void OUTLINER_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border_ex(ot, true, false); } /* ****************************************************** */ diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index f2d73f40039..edd897fbbab 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -282,7 +282,7 @@ typedef enum eOutliner_PropSceneOps { OL_SCENE_OP_DELETE = 1 } eOutliner_PropSceneOps; -static EnumPropertyItem prop_scene_op_types[] = { +static const EnumPropertyItem prop_scene_op_types[] = { {OL_SCENE_OP_DELETE, "DELETE", ICON_X, "Delete", ""}, {0, NULL, 0, NULL, NULL} }; @@ -977,7 +977,7 @@ enum { OL_OP_RENAME, }; -static EnumPropertyItem prop_object_op_types[] = { +static const EnumPropertyItem prop_object_op_types[] = { {OL_OP_SELECT, "SELECT", 0, "Select", ""}, {OL_OP_DESELECT, "DESELECT", 0, "Deselect", ""}, {OL_OP_SELECT_HIERARCHY, "SELECT_HIERARCHY", 0, "Select Hierarchy", ""}, @@ -1110,7 +1110,7 @@ typedef enum eOutliner_PropGroupOps { OL_GROUPOP_RENAME, } eOutliner_PropGroupOps; -static EnumPropertyItem prop_group_op_types[] = { +static const EnumPropertyItem prop_group_op_types[] = { {OL_GROUPOP_UNLINK, "UNLINK", 0, "Unlink Group", ""}, {OL_GROUPOP_LOCAL, "LOCAL", 0, "Make Local Group", ""}, {OL_GROUPOP_LINK, "LINK", 0, "Link Group Objects to Scene", ""}, @@ -1208,7 +1208,7 @@ typedef enum eOutlinerIdOpTypes { } eOutlinerIdOpTypes; // TODO: implement support for changing the ID-block used -static EnumPropertyItem prop_id_op_types[] = { +static const EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""}, {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""}, {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, @@ -1395,7 +1395,7 @@ typedef enum eOutlinerLibOpTypes { OL_LIB_RELOAD, } eOutlinerLibOpTypes; -static EnumPropertyItem outliner_lib_op_type_items[] = { +static const EnumPropertyItem outliner_lib_op_type_items[] = { {OL_LIB_RENAME, "RENAME", 0, "Rename", ""}, {OL_LIB_DELETE, "DELETE", 0, "Delete", "Delete this library and all its item from Blender - WARNING: no undo"}, {OL_LIB_RELOCATE, "RELOCATE", 0, "Relocate", "Select a new path for this library, and reload all its data"}, @@ -1605,7 +1605,7 @@ typedef enum eOutliner_AnimDataOps { //OUTLINER_ANIMOP_PASTE_DRIVERS } eOutliner_AnimDataOps; -static EnumPropertyItem prop_animdata_op_types[] = { +static const EnumPropertyItem prop_animdata_op_types[] = { {OUTLINER_ANIMOP_CLEAR_ADT, "CLEAR_ANIMDATA", 0, "Clear Animation Data", "Remove this animation data container"}, {OUTLINER_ANIMOP_SET_ACT, "SET_ACT", 0, "Set Action", ""}, {OUTLINER_ANIMOP_CLEAR_ACT, "CLEAR_ACT", 0, "Unlink Action", ""}, @@ -1705,7 +1705,7 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot) /* **************************************** */ -static EnumPropertyItem prop_constraint_op_types[] = { +static const EnumPropertyItem prop_constraint_op_types[] = { {OL_CONSTRAINTOP_ENABLE, "ENABLE", ICON_RESTRICT_VIEW_OFF, "Enable", ""}, {OL_CONSTRAINTOP_DISABLE, "DISABLE", ICON_RESTRICT_VIEW_ON, "Disable", ""}, {OL_CONSTRAINTOP_DELETE, "DELETE", ICON_X, "Delete", ""}, @@ -1751,7 +1751,7 @@ void OUTLINER_OT_constraint_operation(wmOperatorType *ot) /* ******************** */ -static EnumPropertyItem prop_modifier_op_types[] = { +static const EnumPropertyItem prop_modifier_op_types[] = { {OL_MODIFIER_OP_TOGVIS, "TOGVIS", ICON_RESTRICT_VIEW_OFF, "Toggle viewport use", ""}, {OL_MODIFIER_OP_TOGREN, "TOGREN", ICON_RESTRICT_RENDER_OFF, "Toggle render use", ""}, {OL_MODIFIER_OP_DELETE, "DELETE", ICON_X, "Delete", ""}, @@ -1844,7 +1844,7 @@ void OUTLINER_OT_collection_operation(wmOperatorType *ot) /* ******************** */ // XXX: select linked is for RNA structs only -static EnumPropertyItem prop_data_op_types[] = { +static const EnumPropertyItem prop_data_op_types[] = { {OL_DOP_SELECT, "SELECT", 0, "Select", ""}, {OL_DOP_DESELECT, "DESELECT", 0, "Deselect", ""}, {OL_DOP_HIDE, "HIDE", 0, "Hide", ""}, diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index f3a5af4b164..5331c76a0dc 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -386,7 +386,7 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s outliner_add_element(soops, lb, sce->world, te, 0, 0); #ifdef WITH_FREESTYLE - if (STREQ(sce->r.engine, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS)) + if (STREQ(sce->view_render->engine_id, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS)) outliner_add_line_styles(soops, lb, sce, te); #endif } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index a1549f39b7c..a8a5bc6e96b 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -107,7 +107,7 @@ EnumPropertyItem prop_side_types[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem prop_side_lr_types[] = { +static const EnumPropertyItem prop_side_lr_types[] = { {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""}, {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""}, {0, NULL, 0, NULL, NULL} @@ -2010,7 +2010,7 @@ void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot) /* cut operator */ -static EnumPropertyItem prop_cut_types[] = { +static const EnumPropertyItem prop_cut_types[] = { {SEQ_CUT_SOFT, "SOFT", 0, "Soft", ""}, {SEQ_CUT_HARD, "HARD", 0, "Hard", ""}, {0, NULL, 0, NULL, NULL} @@ -2800,7 +2800,7 @@ void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot) #if 0 -static EnumPropertyItem view_type_items[] = { +static const EnumPropertyItem view_type_items[] = { {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""}, {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""}, {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SEQUENCER, "Sequencer and Image Preview", ""}, @@ -3398,17 +3398,17 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) ot->description = "Set the boundaries of the border used for offset-view"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = view_ghost_border_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = sequencer_view_preview_poll; - ot->cancel = WM_border_select_cancel; + ot->cancel = WM_gesture_border_cancel; /* flags */ ot->flag = 0; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border(ot); } /* rebuild_proxy operator */ @@ -3562,7 +3562,7 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) /* change ops */ -static EnumPropertyItem prop_change_effect_input_types[] = { +static const EnumPropertyItem prop_change_effect_input_types[] = { {0, "A_B", 0, "A -> B", ""}, {1, "B_C", 0, "B -> C", ""}, {2, "A_C", 0, "A -> C", ""}, diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index 1b3d458bb69..7ab9308f9a6 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -185,7 +185,7 @@ static int strip_modifier_move_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"}, {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"}, {0, NULL, 0, NULL, NULL} @@ -258,7 +258,7 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot) { - static EnumPropertyItem type_items[] = { + static const EnumPropertyItem type_items[] = { {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"}, {SEQ_MODIFIER_COPY_APPEND, "APPEND", 0, "Append", diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index d88ed36e392..90a369760ac 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -548,7 +548,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e void SEQUENCER_OT_select(wmOperatorType *ot) { - static EnumPropertyItem sequencer_select_left_right_types[] = { + static const EnumPropertyItem sequencer_select_left_right_types[] = { {SEQ_SELECT_LR_NONE, "NONE", 0, "None", "Don't do left-right selection"}, {SEQ_SELECT_LR_MOUSE, "MOUSE", 0, "Mouse", "Use mouse position for selection"}, {SEQ_SELECT_LR_LEFT, "LEFT", 0, "Left", "Select left"}, @@ -889,7 +889,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) Sequence *seq; rctf rectf, rq; - const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); if (ed == NULL) @@ -927,10 +927,10 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot) ot->description = "Select strips using border selection"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = sequencer_borderselect_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_sequencer_active; @@ -938,7 +938,7 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /* ****** Selected Grouped ****** */ @@ -953,7 +953,7 @@ enum { SEQ_SELECT_GROUP_OVERLAP, }; -static EnumPropertyItem sequencer_prop_select_grouped_types[] = { +static const EnumPropertyItem sequencer_prop_select_grouped_types[] = { {SEQ_SELECT_GROUP_TYPE, "TYPE", 0, "Type", "Shared strip type"}, {SEQ_SELECT_GROUP_TYPE_BASIC, "TYPE_BASIC", 0, "Global Type", "All strips of same basic type (Graphical or Sound)"}, {SEQ_SELECT_GROUP_TYPE_EFFECT, "TYPE_EFFECT", 0, "Effect Type", diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 3b04e6c80cd..da16ac5acaa 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -338,7 +338,8 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) } static void sequencer_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) + bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index ed1ef080e0c..539fe1c53bd 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -125,7 +125,8 @@ static SpaceLink *text_duplicate(SpaceLink *sl) return (SpaceLink *)stextn; } -static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { SpaceText *st = sa->spacedata.first; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 548cf157c0f..2a0c350ba54 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1046,7 +1046,7 @@ void TEXT_OT_uncomment(wmOperatorType *ot) /******************* convert whitespace operator *********************/ enum { TO_SPACES, TO_TABS }; -static EnumPropertyItem whitespace_type_items[] = { +static const EnumPropertyItem whitespace_type_items[] = { {TO_SPACES, "SPACES", 0, "To Spaces", NULL}, {TO_TABS, "TABS", 0, "To Tabs", NULL}, {0, NULL, 0, NULL, NULL}}; @@ -1280,7 +1280,7 @@ static int move_lines_exec(bContext *C, wmOperator *op) void TEXT_OT_move_lines(wmOperatorType *ot) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {TXT_MOVE_LINE_UP, "UP", 0, "Up", ""}, {TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -1301,7 +1301,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot) /************************ move operator ************************/ -static EnumPropertyItem move_type_items[] = { +static const EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {FILE_TOP, "FILE_TOP", 0, "File Top", ""}, @@ -1923,7 +1923,7 @@ void TEXT_OT_jump(wmOperatorType *ot) /******************* delete operator **********************/ -static EnumPropertyItem delete_type_items[] = { +static const EnumPropertyItem delete_type_items[] = { {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, @@ -3086,7 +3086,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) /****************** resolve conflict operator ******************/ enum { RESOLVE_IGNORE, RESOLVE_RELOAD, RESOLVE_SAVE, RESOLVE_MAKE_INTERNAL }; -static EnumPropertyItem resolution_items[] = { +static const EnumPropertyItem resolution_items[] = { {RESOLVE_IGNORE, "IGNORE", 0, "Ignore", ""}, {RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""}, {RESOLVE_SAVE, "SAVE", 0, "Save", ""}, diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 7ecb5cb072d..b9a35de6779 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -468,7 +468,8 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar) /* ---------------- */ /* editor level listener */ -static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { /* mainly for updating cache display */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 07d072f0156..b49594d7a0d 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -650,7 +650,7 @@ void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const /* Function to draw an Image on an empty Object */ -static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4], StereoViews sview) +static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4], eStereoViews sview) { Image *ima = ob->data; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 0a4f400a721..9b5c5e6cd30 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1262,7 +1262,8 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar) /* area (not region) level listener */ static void space_view3d_listener( - bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, const Scene *UNUSED(scene)) + bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene), + WorkSpace *UNUSED(workspace)) { View3D *v3d = sa->spacedata.first; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ed4d7861d6d..ec2dcc75bc0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1880,10 +1880,11 @@ static void view3d_draw_view(const bContext *C, ARegion *ar) void view3d_main_region_draw(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); + WorkSpace *workspace = CTX_wm_workspace(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ar->regiondata; - /* XXX: In the future we should get RE from Layers/Depsgraph */ - RenderEngineType *type = RE_engines_find(scene->r.engine); + ViewRender *view_render = BKE_viewrender_get(scene, workspace); + RenderEngineType *type = RE_engines_find(view_render->engine_id); /* Provisory Blender Internal drawing */ if (type->flag & RE_USE_LEGACY_PIPELINE) { @@ -1931,7 +1932,7 @@ static void view3d_stereo3d_setup_offscreen( void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d) { - RenderEngineType *type = RE_engines_find(scene->r.engine); + RenderEngineType *type = eval_ctx->engine; if (type->flag & RE_USE_LEGACY_PIPELINE) { /* shadow buffers, before we setup matrices */ if (draw_glsl_material(scene, sl, NULL, v3d, v3d->drawtype)) { @@ -1959,7 +1960,8 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar) * stuff like shadow buffers */ void ED_view3d_draw_offscreen( - const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int winx, int winy, + const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer, + View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[4][4], float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname, GPUFX *fx, GPUFXSettings *fx_settings, @@ -2013,7 +2015,7 @@ void ED_view3d_draw_offscreen( view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL); /* main drawing call */ - RenderEngineType *type = RE_engines_find(scene->r.engine); + RenderEngineType *type = eval_ctx->engine; if (type->flag & RE_USE_LEGACY_PIPELINE) { /* framebuffer fx needed, we need to draw offscreen first */ @@ -2055,8 +2057,8 @@ void ED_view3d_draw_offscreen( } else { /* XXX, should take depsgraph as arg */ - Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl); - DRW_draw_render_loop_offscreen(depsgraph, ar, v3d, ofs); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer); + DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine, ar, v3d, ofs); } /* restore size */ @@ -2079,7 +2081,8 @@ void ED_view3d_draw_offscreen( * (avoids re-creating when doing multiple GL renders). */ ImBuf *ED_view3d_draw_offscreen_imbuf( - const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int sizex, int sizey, + const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer, + View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, bool draw_background, int alpha_mode, int samples, bool full_samples, const char *viewname, /* output vars */ @@ -2108,7 +2111,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( } } - ED_view3d_draw_offscreen_init(eval_ctx, scene, sl, v3d); + ED_view3d_draw_offscreen_init(eval_ctx, scene, scene_layer, v3d); GPU_offscreen_bind(ofs, true); @@ -2150,7 +2153,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( if ((samples && full_samples) == 0) { /* Single-pass render, common case */ ED_view3d_draw_offscreen( - eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat, + eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat, draw_background, draw_sky, !is_ortho, viewname, fx, &fx_settings, ofs); @@ -2174,7 +2177,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( /* first sample buffer, also initializes 'rv3d->persmat' */ ED_view3d_draw_offscreen( - eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat, + eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat, draw_background, draw_sky, !is_ortho, viewname, fx, &fx_settings, ofs); GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp); @@ -2193,7 +2196,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( (jit_ofs[j][1] * 2.0f) / sizey); ED_view3d_draw_offscreen( - eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat_jitter, + eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat_jitter, draw_background, draw_sky, !is_ortho, viewname, fx, &fx_settings, ofs); GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp); @@ -2244,7 +2247,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( * \note used by the sequencer */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( - const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *camera, int width, int height, + const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer, + Object *camera, int width, int height, unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, int samples, bool full_samples, const char *viewname, GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) @@ -2298,7 +2302,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( invert_m4_m4(rv3d.persinv, rv3d.viewinv); return ED_view3d_draw_offscreen_imbuf( - eval_ctx, scene, sl, &v3d, &ar, width, height, flag, + eval_ctx, scene, scene_layer, &v3d, &ar, width, height, flag, draw_background, alpha_mode, samples, full_samples, viewname, fx, ofs, err_out); } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index d24c8241855..3680470c734 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -1786,8 +1786,7 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect) static bool view3d_main_region_do_render_draw(const Scene *scene) { - RenderEngineType *type = RE_engines_find(scene->r.engine); - + RenderEngineType *type = RE_engines_find(scene->view_render.engine_id); return (type && type->view_update && type->render_to_view); } @@ -1849,8 +1848,7 @@ static bool view3d_main_region_draw_engine( /* create render engine */ if (!rv3d->render_engine) { RenderEngine *engine; - - type = RE_engines_find(scene->r.engine); + type = RE_engines_find(scene->view_render.engine_id); if (!(type->view_update && type->render_to_view)) return false; @@ -1979,7 +1977,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Sce rv3d->rflag &= ~RV3D_IS_GAME_ENGINE; #ifdef WITH_GAMEENGINE - if (STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)) { + if (STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME)) { rv3d->rflag |= RV3D_IS_GAME_ENGINE; /* Make sure LoDs are up to date */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b54d1254293..84f31020c32 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -916,7 +916,7 @@ enum { /* called in transform_ops.c, on each regeneration of keymaps */ void viewrotate_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""}, @@ -1940,7 +1940,7 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) /* called in transform_ops.c, on each regeneration of keymaps */ void viewmove_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, @@ -2119,7 +2119,7 @@ void VIEW3D_OT_move(wmOperatorType *ot) /* called in transform_ops.c, on each regeneration of keymaps */ void viewzoom_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, @@ -2511,7 +2511,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) /* called in transform_ops.c, on each regeneration of keymaps */ void viewdolly_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"}, @@ -3524,10 +3524,10 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) ot->idname = "VIEW3D_OT_render_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = render_border_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_view3d_active; @@ -3597,7 +3597,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); - int gesture_mode; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* Zooms in on a border drawn by the user */ @@ -3622,7 +3621,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) WM_operator_properties_border_to_rcti(op, &rect); /* check if zooming in/out view */ - gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); ED_view3d_dist_range_get(v3d, dist_range); @@ -3705,7 +3704,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_dist *= max_ff(xscale, yscale); } - if (gesture_mode == GESTURE_MODAL_OUT) { + if (!zoom_in) { sub_v3_v3v3(dvec, new_ofs, rv3d->ofs); new_dist = rv3d->dist * (rv3d->dist / new_dist); add_v3_v3v3(new_ofs, rv3d->ofs, dvec); @@ -3731,7 +3730,7 @@ static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, const wmEvent /* if in camera view do not exec the operator so we do not conflict with set render border*/ if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) - return WM_border_select_invoke(C, op, event); + return WM_gesture_border_invoke(C, op, event); else return OPERATOR_PASS_THROUGH; } @@ -3746,8 +3745,8 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) /* api callbacks */ ot->invoke = view3d_zoom_border_invoke; ot->exec = view3d_zoom_border_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_region_view3d_active; @@ -3755,7 +3754,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) ot->flag = 0; /* rna */ - WM_operator_properties_gesture_border(ot, false); + WM_operator_properties_gesture_border_zoom(ot); } /* sets the view to 1:1 camera/render-pixel */ @@ -3805,7 +3804,7 @@ void VIEW3D_OT_zoom_camera_1_to_1(wmOperatorType *ot) /* ********************* Changing view operator ****************** */ -static EnumPropertyItem prop_view_items[] = { +static const EnumPropertyItem prop_view_items[] = { {RV3D_VIEW_LEFT, "LEFT", ICON_TRIA_LEFT, "Left", "View From the Left"}, {RV3D_VIEW_RIGHT, "RIGHT", ICON_TRIA_RIGHT, "Right", "View From the Right"}, {RV3D_VIEW_BOTTOM, "BOTTOM", ICON_TRIA_DOWN, "Bottom", "View From the Bottom"}, @@ -4042,7 +4041,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -static EnumPropertyItem prop_view_orbit_items[] = { +static const EnumPropertyItem prop_view_orbit_items[] = { {V3D_VIEW_STEPLEFT, "ORBITLEFT", 0, "Orbit Left", "Orbit the view around to the Left"}, {V3D_VIEW_STEPRIGHT, "ORBITRIGHT", 0, "Orbit Right", "Orbit the view around to the Right"}, {V3D_VIEW_STEPUP, "ORBITUP", 0, "Orbit Up", "Orbit the view Up"}, @@ -4265,7 +4264,7 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event) return ret; } -static EnumPropertyItem prop_view_roll_items[] = { +static const EnumPropertyItem prop_view_roll_items[] = { {0, "ANGLE", 0, "Roll Angle", "Roll the view using an angle value"}, {V3D_VIEW_STEPLEFT, "LEFT", 0, "Roll Left", "Roll the view around to the Left"}, {V3D_VIEW_STEPRIGHT, "RIGHT", 0, "Roll Right", "Roll the view around to the Right"}, @@ -4400,7 +4399,7 @@ void VIEW3D_OT_view_roll(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -static EnumPropertyItem prop_view_pan_items[] = { +static const EnumPropertyItem prop_view_pan_items[] = { {V3D_VIEW_PANLEFT, "PANLEFT", 0, "Pan Left", "Pan the view to the Left"}, {V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the Right"}, {V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view Up"}, @@ -4671,7 +4670,7 @@ static int view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *ev return OPERATOR_FINISHED; } else { - return WM_border_select_invoke(C, op, event); + return WM_gesture_border_invoke(C, op, event); } } @@ -4687,8 +4686,8 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot) /* api callbacks */ ot->invoke = view3d_clipping_invoke; ot->exec = view3d_clipping_exec; - ot->modal = WM_border_select_modal; - ot->cancel = WM_border_select_cancel; + ot->modal = WM_gesture_border_modal; + ot->cancel = WM_gesture_border_cancel; ot->poll = ED_operator_region_view3d_active; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index bce27fc5c92..b3ed8e34755 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -99,7 +99,7 @@ typedef enum eFlyPanState { /* called in transform_ops.c, on each regeneration of keymaps */ void fly_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {FLY_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""}, diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 60e90121ad1..03f4f506c13 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) } else if (state == RULER_STATE_DRAG) { ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0, + CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0, ruler_info->ar, CTX_wm_view3d(C)); } else { diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 5ac3aa15d4c..5408269ce13 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -114,6 +114,7 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->depsgraph = CTX_data_depsgraph(C); vc->scene = CTX_data_scene(C); vc->scene_layer = CTX_data_scene_layer(C); + vc->engine = CTX_data_engine(C); vc->v3d = CTX_wm_view3d(C); vc->win = CTX_wm_window(C); vc->rv3d = CTX_wm_region_view3d(C); @@ -896,9 +897,8 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + /* properties */ + WM_operator_properties_gesture_lasso_select(ot); } @@ -966,7 +966,7 @@ typedef struct SelMenuItemF { static SelMenuItemF object_mouse_select_menu_data[SEL_MENU_SIZE]; /* special (crappy) operator only for menu select */ -static EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem *item = NULL, item_tmp = {0}; int totitem = 0; @@ -2161,9 +2161,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) CTX_data_eval_ctx(C, &eval_ctx); view3d_set_viewcontext(C, &vc); - select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); - WM_operator_properties_border_to_rcti(op, &rect); + select = !RNA_boolean_get(op->ptr, "deselect"); extend = RNA_boolean_get(op->ptr, "extend"); + WM_operator_properties_border_to_rcti(op, &rect); if (vc.obedit) { switch (vc.obedit->type) { @@ -2238,17 +2238,17 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) ot->idname = "VIEW3D_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = view3d_borderselect_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = view3d_selectable_data; - ot->cancel = WM_border_select_cancel; + ot->cancel = WM_gesture_border_cancel; /* flags */ ot->flag = OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } @@ -2860,8 +2860,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); const int radius = RNA_int_get(op->ptr, "radius"); - const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const bool select = (gesture_mode == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; @@ -2922,9 +2921,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); + + /* properties */ + WM_operator_properties_gesture_circle_select(ot); } diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 44b7fadd29f..ce089aa29fa 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -58,6 +58,8 @@ #include "GPU_immediate.h" +#include "RE_engine.h" + #include "view3d_intern.h" /* own include */ #ifdef WITH_INPUT_NDOF @@ -130,7 +132,7 @@ typedef enum eWalkGravityState { /* called in transform_ops.c, on each regeneration of keymaps */ void walk_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {WALK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {WALK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, @@ -249,6 +251,7 @@ typedef struct WalkInfo { ARegion *ar; Scene *scene; SceneLayer *scene_layer; + RenderEngineType *engine; wmTimer *timer; /* needed for redraws */ @@ -512,6 +515,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->ar = CTX_wm_region(C); walk->scene = CTX_data_scene(C); walk->scene_layer = CTX_data_scene_layer(C); + walk->engine = CTX_data_engine(C); #ifdef NDOF_WALK_DEBUG puts("\n-- walk begin --"); @@ -600,7 +604,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->rflag |= RV3D_NAVIGATING; walk->snap_context = ED_transform_snap_object_context_create_view3d( - CTX_data_main(C), walk->scene, walk->scene_layer, 0, + CTX_data_main(C), walk->scene, walk->scene_layer, walk->engine, 0, walk->ar, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index fda15545ead..f38f6c064b8 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -29,6 +29,7 @@ set(INC ../../ikplugin ../../makesdna ../../makesrna + ../../render/extern/include ../../windowmanager ../../depsgraph ../../../../intern/guardedalloc diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4745631e85c..40309b701a4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -808,7 +808,7 @@ enum { /* called in transform_ops.c, on each regeneration of keymaps */ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) { - static EnumPropertyItem modal_items[] = { + static const EnumPropertyItem modal_items[] = { {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 92eb31aabe6..60ad61e3475 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -37,6 +37,8 @@ #include "ED_numinput.h" #include "ED_view3d.h" +#include "RE_engine.h" + #include "DNA_listBase.h" /* ************************** Types ***************************** */ @@ -60,6 +62,7 @@ struct wmTimer; struct ARegion; struct ReportList; struct EditBone; +struct RenderEngineType; struct SnapObjectContext; /* transinfo->redraw */ @@ -467,6 +470,7 @@ typedef struct TransInfo { struct ARegion *ar; struct Scene *scene; struct SceneLayer *scene_layer; + struct RenderEngineType *engine; struct ToolSettings *settings; struct wmTimer *animtimer; struct wmKeyMap *keymap; /* so we can do lookups for header text */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 166a5805fa1..b04767724ea 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2485,7 +2485,7 @@ static void createTransEditVerts(TransInfo *t) int *island_vert_map = NULL; DEG_evaluation_context_init_from_scene(&eval_ctx, - t->scene, t->scene_layer, + t->scene, t->scene_layer, t->engine, DAG_EVAL_VIEWPORT); /* Even for translation this is needed because of island-orientation, see: T51651. */ @@ -5557,7 +5557,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* handle pending update events, otherwise they got copied below */ EvaluationContext eval_ctx; DEG_evaluation_context_init_from_scene(&eval_ctx, - t->scene, t->scene_layer, + t->scene, t->scene_layer, t->engine, DAG_EVAL_VIEWPORT); for (base = sl->object_bases.first; base; base = base->next) { if (base->object->recalc & OB_RECALC_ALL) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 2bed1dd28f2..5081b65c215 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -105,6 +105,8 @@ #include "WM_types.h" #include "WM_api.h" +#include "RE_engine.h" + #include "UI_resources.h" #include "UI_view2d.h" @@ -1122,10 +1124,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve Object *obedit = CTX_data_edit_object(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = CTX_data_gpencil_data(C); + RenderEngineType *engine = CTX_data_engine(C); PropertyRNA *prop; t->scene = sce; t->scene_layer = sl; + t->engine = engine; t->sa = sa; t->ar = ar; t->obedit = obedit; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index d7ed80841da..ad855427ff1 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -122,7 +122,7 @@ static TransformModeItem transform_modes[] = {NULL, 0} }; -EnumPropertyItem rna_enum_transform_mode_types[] = +const EnumPropertyItem rna_enum_transform_mode_types[] = { {TFM_INIT, "INIT", 0, "Init", ""}, {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, @@ -568,9 +568,8 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } if ((flags & P_NO_DEFAULTS) == 0) { - // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit - /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button"); - //RNA_def_property_flag(prop, PROP_HIDDEN); + prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button"); + RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_boolean(ot->srna, "use_accurate", 0, "Accurate", "Use accurate transformation"); RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index e3ea8a51c6d..3aedb53cfce 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -105,7 +105,7 @@ static float ResizeBetween(TransInfo *t, const float p1[3], const float p2[3]); /****************** IMPLEMENTATIONS *********************/ -static bool snapNodeTest(View2D *v2d, bNode *node, SnapSelect snap_select); +static bool snapNodeTest(View2D *v2d, bNode *node, eSnapSelect snap_select); static NodeBorder snapNodeBorder(int snap_node_mode); #if 0 @@ -585,7 +585,7 @@ static void initSnappingMode(TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { if (t->tsnap.object_context == NULL) { t->tsnap.object_context = ED_transform_snap_object_context_create_view3d( - G.main, t->scene, t->scene_layer, 0, + G.main, t->scene, t->scene_layer, t->engine, 0, t->ar, t->view); ED_transform_snap_object_context_set_editmesh_callbacks( @@ -1299,7 +1299,7 @@ bool peelObjectsTransform( /******************** NODES ***********************************/ -static bool snapNodeTest(View2D *v2d, bNode *node, SnapSelect snap_select) +static bool snapNodeTest(View2D *v2d, bNode *node, eSnapSelect snap_select) { /* node is use for snapping only if a) snap mode matches and b) node is inside the view */ return ((snap_select == SNAP_NOT_SELECTED && !(node->flag & NODE_SELECT)) || @@ -1378,7 +1378,7 @@ static bool snapNode( static bool snapNodes( ToolSettings *ts, SpaceNode *snode, ARegion *ar, - const int mval[2], SnapSelect snap_select, + const int mval[2], eSnapSelect snap_select, float r_loc[2], float *r_dist_px, char *r_node_border) { bNodeTree *ntree = snode->edittree; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index e72bfa40480..af3c78f5d89 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -150,12 +150,12 @@ typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Obj * Walks through all objects in the scene to create the list of objets to snap. * * \param sctx: Snap context to store data. - * \param snap_select : from enum SnapSelect. + * \param snap_select : from enum eSnapSelect. * \param obedit : Object Edited to use its coordinates of BMesh(if any) to do the snapping. */ static void iter_snap_objects( SnapObjectContext *sctx, - const SnapSelect snap_select, + const eSnapSelect snap_select, Object *obedit, IterSnapObjsCallback sob_callback, void *data) @@ -799,7 +799,7 @@ static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, * * \param sctx: Snap context to store data. * \param snapdata: struct generated in `set_snapdata`. - * \param snap_select : from enum SnapSelect. + * \param snap_select : from enum eSnapSelect. * \param use_object_edit_cage : Uses the coordinates of BMesh(if any) to do the snapping. * \param obj_list: List with objects to snap (created in `create_object_list`). * @@ -823,7 +823,7 @@ static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, static bool raycastObjects( SnapObjectContext *sctx, const float ray_start[3], const float ray_dir[3], - const SnapSelect snap_select, const bool use_object_edit_cage, + const eSnapSelect snap_select, const bool use_object_edit_cage, /* read/write args */ float *ray_depth, /* return args */ @@ -2040,7 +2040,7 @@ static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, flo * * \param sctx: Snap context to store data. * \param snapdata: struct generated in `get_snapdata`. - * \param snap_select : from enum SnapSelect. + * \param snap_select : from enum eSnapSelect. * \param use_object_edit_cage : Uses the coordinates of BMesh(if any) to do the snapping. * * Read/Write Args @@ -2062,7 +2062,7 @@ static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, flo */ static bool snapObjectsRay( SnapObjectContext *sctx, SnapData *snapdata, - const SnapSelect snap_select, const bool use_object_edit_cage, + const eSnapSelect snap_select, const bool use_object_edit_cage, /* read/write args */ float *ray_depth, float *dist_px, /* return args */ @@ -2096,7 +2096,7 @@ static bool snapObjectsRay( * \{ */ SnapObjectContext *ED_transform_snap_object_context_create( - Main *bmain, Scene *scene, SceneLayer *sl, int flag) + Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag) { SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__); @@ -2105,7 +2105,7 @@ SnapObjectContext *ED_transform_snap_object_context_create( sctx->bmain = bmain; sctx->scene = scene; - DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, DAG_EVAL_VIEWPORT); + DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, engine, DAG_EVAL_VIEWPORT); sctx->cache.object_map = BLI_ghash_ptr_new(__func__); sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); @@ -2114,11 +2114,11 @@ SnapObjectContext *ED_transform_snap_object_context_create( } SnapObjectContext *ED_transform_snap_object_context_create_view3d( - Main *bmain, Scene *scene, SceneLayer *sl, int flag, + Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag, /* extra args for view3d */ const ARegion *ar, const View3D *v3d) { - SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, flag); + SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, engine, flag); sctx->use_v3d = true; sctx->v3d_data.ar = ar; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index ff328a28ee9..5b91ee4fc29 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -533,7 +533,7 @@ static int get_undo_system(bContext *C) } /* create enum based on undo items */ -static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) +static const EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) { EnumPropertyItem item_tmp = {0}, *item = NULL; int i = 0; @@ -586,7 +586,7 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE undosys = get_undo_system(C); if (undosys) { - EnumPropertyItem *item = rna_undo_itemf(C, undosys, &totitem); + const EnumPropertyItem *item = rna_undo_itemf(C, undosys, &totitem); if (totitem > 0) { uiPopupMenu *pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); @@ -609,7 +609,7 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE } } - MEM_freeN(item); + MEM_freeN((void *)item); UI_popup_menu_end(C, pup); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 2a0eed6f438..12ff1ebe566 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1622,7 +1622,7 @@ static int uv_align_exec(bContext *C, wmOperator *op) static void UV_OT_align(wmOperatorType *ot) { - static EnumPropertyItem axis_items[] = { + static const EnumPropertyItem axis_items[] = { {'s', "ALIGN_S", 0, "Straighten", "Align UVs along the line defined by the endpoints"}, {'t', "ALIGN_T", 0, "Straighten X", "Align UVs along the line defined by the endpoints along the X axis"}, {'u', "ALIGN_U", 0, "Straighten Y", "Align UVs along the line defined by the endpoints along the Y axis"}, @@ -2760,9 +2760,9 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); /* figure out what to select/deselect */ - select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); - pinned = RNA_boolean_get(op->ptr, "pinned"); + select = !RNA_boolean_get(op->ptr, "deselect"); extend = RNA_boolean_get(op->ptr, "extend"); + pinned = RNA_boolean_get(op->ptr, "pinned"); if (!extend) uv_select_all_perform(scene, ima, em, SEL_DESELECT); @@ -2839,11 +2839,11 @@ static void UV_OT_select_border(wmOperatorType *ot) ot->idname = "UV_OT_select_border"; /* api callbacks */ - ot->invoke = WM_border_select_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = uv_border_select_exec; - ot->modal = WM_border_select_modal; + ot->modal = WM_gesture_border_modal; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; - ot->cancel = WM_border_select_cancel; + ot->cancel = WM_gesture_border_cancel; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2851,7 +2851,7 @@ static void UV_OT_select_border(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only"); - WM_operator_properties_gesture_border(ot, true); + WM_operator_properties_gesture_border_select(ot); } /* ******************** circle select operator **************** */ @@ -2892,8 +2892,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) MLoopUV *luv; int x, y, radius, width, height; float zoomx, zoomy, offset[2], ellipse[2]; - int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - const bool select = (gesture_mode == GESTURE_MODAL_SELECT); + const bool select = !RNA_boolean_get(op->ptr, "deselect"); bool changed = false; const bool use_face_center = (ts->uv_flag & UV_SYNC_SELECTION) ? (ts->selectmode == SCE_SELECT_FACE) : @@ -2971,12 +2970,9 @@ static void UV_OT_circle_select(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "radius", 1, 1, INT_MAX, "Radius", "", 1, INT_MAX); - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); + WM_operator_properties_gesture_circle_select(ot); } @@ -3104,9 +3100,8 @@ static void UV_OT_select_lasso(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + /* properties */ + WM_operator_properties_gesture_lasso_select(ot); } @@ -3160,7 +3155,7 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op) static void UV_OT_snap_cursor(wmOperatorType *ot) { - static EnumPropertyItem target_items[] = { + static const EnumPropertyItem target_items[] = { {0, "PIXELS", 0, "Pixels", ""}, {1, "SELECTED", 0, "Selected", ""}, {0, NULL, 0, NULL, NULL}}; @@ -3367,7 +3362,7 @@ static int uv_snap_selection_exec(bContext *C, wmOperator *op) static void UV_OT_snap_selected(wmOperatorType *ot) { - static EnumPropertyItem target_items[] = { + static const EnumPropertyItem target_items[] = { {0, "PIXELS", 0, "Pixels", ""}, {1, "CURSOR", 0, "Cursor", ""}, {2, "CURSOR_OFFSET", 0, "Cursor (Offset)", ""}, diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 4ff4c3223f0..fa936e998fa 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -2320,7 +2320,7 @@ void UV_OT_stitch(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem stitch_modes[] = { + static const EnumPropertyItem stitch_modes[] = { {STITCH_VERT, "VERTEX", 0, "Vertex", ""}, {STITCH_EDGE, "EDGE", 0, "Edge", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index b700c992a01..8a742735a06 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -995,13 +995,13 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float static void uv_transform_properties(wmOperatorType *ot, int radius) { - static EnumPropertyItem direction_items[] = { + static const EnumPropertyItem direction_items[] = { {VIEW_ON_EQUATOR, "VIEW_ON_EQUATOR", 0, "View on Equator", "3D view is on the equator"}, {VIEW_ON_POLES, "VIEW_ON_POLES", 0, "View on Poles", "3D view is on the poles"}, {ALIGN_TO_OBJECT, "ALIGN_TO_OBJECT", 0, "Align to Object", "Align according to object transform"}, {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem align_items[] = { + static const EnumPropertyItem align_items[] = { {POLAR_ZX, "POLAR_ZX", 0, "Polar ZX", "Polar 0 is X"}, {POLAR_ZY, "POLAR_ZY", 0, "Polar ZY", "Polar 0 is Y"}, {0, NULL, 0, NULL, NULL} @@ -1236,7 +1236,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) void UV_OT_unwrap(wmOperatorType *ot) { - static EnumPropertyItem method_items[] = { + static const EnumPropertyItem method_items[] = { {0, "ANGLE_BASED", 0, "Angle Based", ""}, {1, "CONFORMAL", 0, "Conformal", ""}, {0, NULL, 0, NULL, NULL} |