diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 48b1d0be7e7..e96c3ed2793 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -2103,7 +2103,7 @@ class VIEW3D_MT_select_edit_curves(Menu): layout.separator() layout.operator("curves.select_random", text="Random") - layout.operator("curves.select_end", text="Endpoints") + layout.operator("curves.select_ends", text="Endpoints") layout.operator("curves.select_linked", text="Linked") layout.separator() @@ -2121,7 +2121,7 @@ class VIEW3D_MT_select_sculpt_curves(Menu): layout.operator("curves.select_all", text="None").action = 'DESELECT' layout.operator("curves.select_all", text="Invert").action = 'INVERT' layout.operator("sculpt_curves.select_random", text="Random") - layout.operator("curves.select_end", text="Endpoints") + layout.operator("curves.select_ends", text="Endpoints") layout.operator("sculpt_curves.select_grow", text="Grow") diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index f0edf8b8cae..401e85192b9 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -16,6 +16,8 @@ #include "BLI_utildefines.h" #include "BLI_vector_set.hh" +#include "BLT_translation.h" + #include "ED_curves.h" #include "ED_object.h" #include "ED_screen.h" @@ -938,15 +940,15 @@ static void CURVES_OT_select_random(wmOperatorType *ot) 1.0f); } -static int select_end_exec(bContext *C, wmOperator *op) +static int select_ends_exec(bContext *C, wmOperator *op) { VectorSet unique_curves = curves::get_unique_editable_curves(*C); - const bool end_points = RNA_boolean_get(op->ptr, "end_points"); - const int amount = RNA_int_get(op->ptr, "amount"); + const int amount_start = RNA_int_get(op->ptr, "amount_start"); + const int amount_end = RNA_int_get(op->ptr, "amount_end"); for (Curves *curves_id : unique_curves) { CurvesGeometry &curves = curves_id->geometry.wrap(); - select_ends(curves, amount, end_points); + select_ends(curves, amount_start, amount_end); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic * attribute for now. */ @@ -957,24 +959,48 @@ static int select_end_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void CURVES_OT_select_end(wmOperatorType *ot) +static void select_ends_ui(bContext * /*C*/, wmOperator *op) { - ot->name = "Select End"; + uiLayout *layout = op->layout; + + uiLayoutSetPropSep(layout, true); + + uiLayout *col = uiLayoutColumn(layout, true); + uiLayoutSetPropDecorate(col, false); + uiItemR(col, op->ptr, "amount_start", 0, IFACE_("Amount Start"), ICON_NONE); + uiItemR(col, op->ptr, "amount_end", 0, IFACE_("End"), ICON_NONE); +} + +static void CURVES_OT_select_ends(wmOperatorType *ot) +{ + ot->name = "Select Ends"; ot->idname = __func__; ot->description = "Select end points of curves"; - ot->exec = select_end_exec; + ot->exec = select_ends_exec; + ot->ui = select_ends_ui; ot->poll = editable_curves_point_domain_poll; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, - "end_points", - true, - "End Points", - "Select points at the end of the curve as opposed to the beginning"); - RNA_def_int( - ot->srna, "amount", 1, 0, INT32_MAX, "Amount", "Number of points to select", 0, INT32_MAX); + RNA_def_int(ot->srna, + "amount_start", + 0, + 0, + INT32_MAX, + "Amount Front", + "Number of points to select from the front", + 0, + INT32_MAX); + RNA_def_int(ot->srna, + "amount_end", + 1, + 0, + INT32_MAX, + "Amount Back", + "Number of points to select from the back", + 0, + INT32_MAX); } static int select_linked_exec(bContext *C, wmOperator * /*op*/) @@ -1181,7 +1207,7 @@ void ED_operatortypes_curves() WM_operatortype_append(CURVES_OT_set_selection_domain); WM_operatortype_append(CURVES_OT_select_all); WM_operatortype_append(CURVES_OT_select_random); - WM_operatortype_append(CURVES_OT_select_end); + WM_operatortype_append(CURVES_OT_select_ends); WM_operatortype_append(CURVES_OT_select_linked); WM_operatortype_append(CURVES_OT_select_more); WM_operatortype_append(CURVES_OT_select_less); diff --git a/source/blender/editors/curves/intern/curves_selection.cc b/source/blender/editors/curves/intern/curves_selection.cc index aebaf763e14..591ed935e6f 100644 --- a/source/blender/editors/curves/intern/curves_selection.cc +++ b/source/blender/editors/curves/intern/curves_selection.cc @@ -222,7 +222,7 @@ void select_all(bke::CurvesGeometry &curves, const eAttrDomain selection_domain, } } -void select_ends(bke::CurvesGeometry &curves, int amount, bool end_points) +void select_ends(bke::CurvesGeometry &curves, int amount_start, int amount_end) { const bool was_anything_selected = has_anything_selected(curves); const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -240,12 +240,9 @@ void select_ends(bke::CurvesGeometry &curves, int amount, bool end_points) MutableSpan selection_typed = selection.span.typed(); threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) { for (const int curve_i : range) { - if (end_points) { - selection_typed.slice(points_by_curve[curve_i].drop_back(amount)).fill(T(0)); - } - else { - selection_typed.slice(points_by_curve[curve_i].drop_front(amount)).fill(T(0)); - } + selection_typed + .slice(points_by_curve[curve_i].drop_front(amount_start).drop_back(amount_end)) + .fill(T(0)); } }); } diff --git a/source/blender/editors/include/ED_curves.h b/source/blender/editors/include/ED_curves.h index ddd60730dfc..e4404ab0971 100644 --- a/source/blender/editors/include/ED_curves.h +++ b/source/blender/editors/include/ED_curves.h @@ -150,10 +150,10 @@ void select_all(bke::CurvesGeometry &curves, eAttrDomain selection_domain, int a /** * Select the ends (front or back) of all the curves. * - * \param amount: The amount of points to select from the front or back. - * \param end_points: If true, select the last point(s), if false, select the first point(s). + * \param amount_start: The amount of points to select from the front. + * \param amount_end: The amount of points to select from the back. */ -void select_ends(bke::CurvesGeometry &curves, int amount, bool end_points); +void select_ends(bke::CurvesGeometry &curves, int amount_start, int amount_end); /** * Select the points of all curves that have at least one point selected.