Anim: clarify the "Clear Motion Paths" operators

Make the "Clear Motion Paths" operators more intuitive. Previously, the
only way to clear the motion path of the selected object/bone would be
to shift-click the "Clear ALL Motion Paths" button. Now there are two
"X" buttons, one for "selected" and one for "all".

The "Clear Selected" and "Clear All" buttons align with the
corresponding "Update Selected" and "Update All" buttons.
This commit is contained in:
Sybren A. Stüvel 2022-12-22 12:46:19 +01:00
parent 4d22a517c9
commit dc30c9971d
3 changed files with 22 additions and 16 deletions

View File

@ -56,7 +56,9 @@ class MotionPathButtonsPanel:
# Update Selected.
col = layout.column(align=True)
col.operator(f"{op_category}.paths_update", text="Update Path", icon=icon)
row = col.row(align=True)
row.operator(f"{op_category}.paths_update", text="Update Path", icon=icon)
row.operator(f"{op_category}.paths_clear", text="", icon='X').only_selected = True
else:
# Calculate.
col = layout.column(align=True)
@ -67,7 +69,7 @@ class MotionPathButtonsPanel:
# Note that 'col' is from inside the preceeding `if` or `else` block.
row = col.row(align=True)
row.operator("object.paths_update_visible", text="Update All Paths", icon='WORLD')
row.operator(f"{op_category}.paths_clear", text="", icon='X')
row.operator(f"{op_category}.paths_clear", text="", icon='X').only_selected = False
class MotionPathButtonsPanel_display:

View File

@ -11,6 +11,8 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
@ -427,13 +429,15 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
static int pose_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static char *pose_clear_paths_description(struct bContext *UNUSED(C),
struct wmOperatorType *UNUSED(ot),
struct PointerRNA *ptr)
{
if ((event->modifier & KM_SHIFT) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
RNA_boolean_set(op->ptr, "only_selected", true);
const bool only_selected = RNA_boolean_get(ptr, "only_selected");
if (only_selected) {
return BLI_strdup(TIP_("Clear motion paths of selected bones"));
}
return pose_clear_paths_exec(C, op);
return BLI_strdup(TIP_("Clear motion paths of all bones"));
}
void POSE_OT_paths_clear(wmOperatorType *ot)
@ -441,12 +445,11 @@ void POSE_OT_paths_clear(wmOperatorType *ot)
/* identifiers */
ot->name = "Clear Bone Paths";
ot->idname = "POSE_OT_paths_clear";
ot->description = "Clear motion paths for all bones, hold Shift key for selected bones only";
/* api callbacks */
ot->invoke = pose_clear_paths_invoke;
ot->exec = pose_clear_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
ot->get_description = pose_clear_paths_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

View File

@ -1439,13 +1439,15 @@ static int object_clear_paths_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
static int object_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static char *object_clear_paths_description(struct bContext *UNUSED(C),
struct wmOperatorType *UNUSED(ot),
struct PointerRNA *ptr)
{
if ((event->modifier & KM_SHIFT) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
RNA_boolean_set(op->ptr, "only_selected", true);
const bool only_selected = RNA_boolean_get(ptr, "only_selected");
if (only_selected) {
return BLI_strdup(TIP_("Clear motion paths of selected objects"));
}
return object_clear_paths_exec(C, op);
return BLI_strdup(TIP_("Clear motion paths of all objects"));
}
void OBJECT_OT_paths_clear(wmOperatorType *ot)
@ -1453,12 +1455,11 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
/* identifiers */
ot->name = "Clear Object Paths";
ot->idname = "OBJECT_OT_paths_clear";
ot->description = "Clear motion paths for all objects, hold Shift key for selected objects only";
/* api callbacks */
ot->invoke = object_clear_paths_invoke;
ot->exec = object_clear_paths_exec;
ot->poll = ED_operator_object_active_editable;
ot->get_description = object_clear_paths_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;