Fix T89909: Circle Select tool status bar doesn't match the operations
Assign get_name functions for select picking and circle select so modifier keys show the result of holding the modifiers.
This commit is contained in:
parent
470cbad51a
commit
113b8030ce
|
@ -2681,6 +2681,7 @@ void GPENCIL_OT_select(wmOperatorType *ot)
|
|||
ot->invoke = gpencil_select_invoke;
|
||||
ot->exec = gpencil_select_exec;
|
||||
ot->poll = gpencil_select_poll;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flag */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -14,6 +14,7 @@ extern "C" {
|
|||
|
||||
struct KDTree_1d;
|
||||
struct wmOperator;
|
||||
struct wmOperatorType;
|
||||
|
||||
enum {
|
||||
SEL_TOGGLE = 0,
|
||||
|
@ -96,16 +97,23 @@ struct SelectPick_Params {
|
|||
/**
|
||||
* Utility to get #eSelectPickMode from booleans for convenience.
|
||||
*/
|
||||
eSelectOp ED_select_op_from_operator(struct wmOperator *op)
|
||||
eSelectOp ED_select_op_from_operator(struct PointerRNA *ptr)
|
||||
ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Initialize `params` from `op`,
|
||||
* these properties are defined by #WM_operator_properties_mouse_select.
|
||||
*/
|
||||
void ED_select_pick_params_from_operator(struct wmOperator *op, struct SelectPick_Params *params)
|
||||
void ED_select_pick_params_from_operator(struct PointerRNA *ptr, struct SelectPick_Params *params)
|
||||
ATTR_NONNULL(1, 2);
|
||||
|
||||
/**
|
||||
* Get-name callback for #wmOperatorType.get_name, this is mainly useful so the selection
|
||||
* action is shown in the status-bar.
|
||||
*/
|
||||
const char *ED_select_pick_get_name(struct wmOperatorType *ot, PointerRNA *ptr);
|
||||
const char *ED_select_circle_get_name(struct wmOperatorType *ot, PointerRNA *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -402,6 +402,7 @@ void MASK_OT_select(wmOperatorType *ot)
|
|||
ot->exec = select_exec;
|
||||
ot->invoke = select_invoke;
|
||||
ot->poll = ED_maskedit_mask_poll;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
@ -748,6 +749,7 @@ void MASK_OT_select_circle(wmOperatorType *ot)
|
|||
ot->modal = WM_gesture_circle_modal;
|
||||
ot->exec = circle_select_exec;
|
||||
ot->poll = ED_maskedit_mask_poll;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
|
@ -887,6 +887,7 @@ void ACTION_OT_select_circle(wmOperatorType *ot)
|
|||
ot->exec = action_circle_select_exec;
|
||||
ot->poll = ED_operator_action_active;
|
||||
ot->cancel = WM_gesture_circle_cancel;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -835,6 +835,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
|
|||
ot->modal = WM_gesture_circle_modal;
|
||||
ot->exec = circle_select_exec;
|
||||
ot->poll = ED_space_clip_tracking_poll;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
|
@ -1080,6 +1080,7 @@ void GRAPH_OT_select_circle(wmOperatorType *ot)
|
|||
ot->exec = graph_circle_select_exec;
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
ot->cancel = WM_gesture_circle_cancel;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -664,7 +664,7 @@ static int node_select_exec(bContext *C, wmOperator *op)
|
|||
RNA_int_get_array(op->ptr, "location", mval);
|
||||
|
||||
struct SelectPick_Params params = {};
|
||||
ED_select_pick_params_from_operator(op, ¶ms);
|
||||
ED_select_pick_params_from_operator(op->ptr, ¶ms);
|
||||
|
||||
/* perform the select */
|
||||
const bool changed = node_mouse_select(C, op, mval, ¶ms);
|
||||
|
@ -698,6 +698,7 @@ void NODE_OT_select(wmOperatorType *ot)
|
|||
ot->exec = node_select_exec;
|
||||
ot->invoke = node_select_invoke;
|
||||
ot->poll = ED_operator_node_active;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
@ -887,8 +888,8 @@ void NODE_OT_select_circle(wmOperatorType *ot)
|
|||
ot->invoke = WM_gesture_circle_invoke;
|
||||
ot->exec = node_circleselect_exec;
|
||||
ot->modal = WM_gesture_circle_modal;
|
||||
|
||||
ot->poll = ED_operator_node_active;
|
||||
ot->get_name = ED_select_circle_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
|
@ -996,6 +996,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
|
|||
ot->invoke = sequencer_select_invoke;
|
||||
ot->modal = WM_generic_select_modal;
|
||||
ot->poll = ED_operator_sequencer_active;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* Flags. */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -1646,7 +1646,7 @@ static int bone_select_menu_exec(bContext *C, wmOperator *op)
|
|||
const int name_index = RNA_enum_get(op->ptr, "name");
|
||||
|
||||
const struct SelectPick_Params params = {
|
||||
.sel_op = ED_select_op_from_operator(op),
|
||||
.sel_op = ED_select_op_from_operator(op->ptr),
|
||||
};
|
||||
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
@ -2875,7 +2875,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
|
|||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
struct SelectPick_Params params = {0};
|
||||
ED_select_pick_params_from_operator(op, ¶ms);
|
||||
ED_select_pick_params_from_operator(op->ptr, ¶ms);
|
||||
|
||||
bool center = RNA_boolean_get(op->ptr, "center");
|
||||
bool enumerate = RNA_boolean_get(op->ptr, "enumerate");
|
||||
|
@ -2987,6 +2987,7 @@ void VIEW3D_OT_select(wmOperatorType *ot)
|
|||
ot->invoke = view3d_select_invoke;
|
||||
ot->exec = view3d_select_exec;
|
||||
ot->poll = ED_operator_view3d_active;
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
@ -4739,6 +4740,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
|
|||
ot->exec = view3d_circle_select_exec;
|
||||
ot->poll = view3d_selectable_data;
|
||||
ot->cancel = view3d_circle_select_cancel;
|
||||
ot->get_name = ED_select_circle_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -119,11 +119,11 @@ bool ED_select_similar_compare_float_tree(const KDTree_1d *tree,
|
|||
return false;
|
||||
}
|
||||
|
||||
eSelectOp ED_select_op_from_operator(wmOperator *op)
|
||||
eSelectOp ED_select_op_from_operator(PointerRNA *ptr)
|
||||
{
|
||||
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
||||
const bool deselect = RNA_boolean_get(op->ptr, "deselect");
|
||||
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
const bool extend = RNA_boolean_get(ptr, "extend");
|
||||
const bool deselect = RNA_boolean_get(ptr, "deselect");
|
||||
const bool toggle = RNA_boolean_get(ptr, "toggle");
|
||||
|
||||
if (extend) {
|
||||
return SEL_OP_ADD;
|
||||
|
@ -137,10 +137,56 @@ eSelectOp ED_select_op_from_operator(wmOperator *op)
|
|||
return SEL_OP_SET;
|
||||
}
|
||||
|
||||
void ED_select_pick_params_from_operator(wmOperator *op, struct SelectPick_Params *params)
|
||||
void ED_select_pick_params_from_operator(PointerRNA *ptr, struct SelectPick_Params *params)
|
||||
{
|
||||
memset(params, 0x0, sizeof(*params));
|
||||
params->sel_op = ED_select_op_from_operator(op);
|
||||
params->deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
|
||||
params->select_passthrough = RNA_boolean_get(op->ptr, "select_passthrough");
|
||||
params->sel_op = ED_select_op_from_operator(ptr);
|
||||
params->deselect_all = RNA_boolean_get(ptr, "deselect_all");
|
||||
params->select_passthrough = RNA_boolean_get(ptr, "select_passthrough");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Operator Naming Callbacks
|
||||
* \{ */
|
||||
|
||||
const char *ED_select_pick_get_name(wmOperatorType *UNUSED(ot), PointerRNA *ptr)
|
||||
{
|
||||
struct SelectPick_Params params = {0};
|
||||
ED_select_pick_params_from_operator(ptr, ¶ms);
|
||||
switch (params.sel_op) {
|
||||
case SEL_OP_ADD:
|
||||
return "Select (Extend)";
|
||||
case SEL_OP_SUB:
|
||||
return "Select (Deselect)";
|
||||
case SEL_OP_XOR:
|
||||
return "Select (Toggle)";
|
||||
case SEL_OP_AND:
|
||||
BLI_assert_unreachable();
|
||||
ATTR_FALLTHROUGH;
|
||||
case SEL_OP_SET:
|
||||
break;
|
||||
}
|
||||
return "Select";
|
||||
}
|
||||
|
||||
const char *ED_select_circle_get_name(wmOperatorType *UNUSED(ot), PointerRNA *ptr)
|
||||
{
|
||||
/* Matches options in #WM_operator_properties_select_operation_simple */
|
||||
const eSelectOp sel_op = RNA_enum_get(ptr, "mode");
|
||||
switch (sel_op) {
|
||||
case SEL_OP_ADD:
|
||||
return "Circle Select (Extend)";
|
||||
case SEL_OP_SUB:
|
||||
return "Circle Select (Deselect)";
|
||||
case SEL_OP_XOR:
|
||||
ATTR_FALLTHROUGH;
|
||||
case SEL_OP_AND:
|
||||
BLI_assert_unreachable();
|
||||
ATTR_FALLTHROUGH;
|
||||
case SEL_OP_SET:
|
||||
break;
|
||||
}
|
||||
return "Circle Select";
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -2624,7 +2624,7 @@ static int uv_select_exec(bContext *C, wmOperator *op)
|
|||
RNA_float_get_array(op->ptr, "location", co);
|
||||
|
||||
struct SelectPick_Params params = {0};
|
||||
ED_select_pick_params_from_operator(op, ¶ms);
|
||||
ED_select_pick_params_from_operator(op->ptr, ¶ms);
|
||||
|
||||
const bool changed = uv_mouse_select(C, co, ¶ms);
|
||||
|
||||
|
@ -2659,6 +2659,7 @@ void UV_OT_select(wmOperatorType *ot)
|
|||
ot->exec = uv_select_exec;
|
||||
ot->invoke = uv_select_invoke;
|
||||
ot->poll = ED_operator_uvedit; /* requires space image */
|
||||
ot->get_name = ED_select_pick_get_name;
|
||||
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
|
@ -3828,6 +3829,7 @@ void UV_OT_select_circle(wmOperatorType *ot)
|
|||
ot->exec = uv_circle_select_exec;
|
||||
ot->poll = ED_operator_uvedit_space_image; /* requires space image */
|
||||
ot->cancel = WM_gesture_circle_cancel;
|
||||
ot->get_name = ED_select_circle_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
Loading…
Reference in New Issue