UI: Select Operator Name Improvements
Different object selection modes show custom names like "Select (Extend)", but this does not happen for "Enumerate" modes. This PR shows these modes (on the status bar) with specific names and alters the title of the resulting menu from "Select Menu" to "Select Object", "Deselect Object", etc. Pull Request: https://projects.blender.org/blender/blender/pulls/134371
This commit is contained in:
committed by
Harley Acheson
parent
00b37d662f
commit
6035447ce5
@@ -36,6 +36,8 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# include "BLI_endian_switch.h"
|
||||
#endif
|
||||
@@ -1643,6 +1645,17 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static std::string object_select_menu_get_name(wmOperatorType * /*ot*/, PointerRNA *ptr)
|
||||
{
|
||||
if (RNA_boolean_get(ptr, "deselect")) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Deselect Object");
|
||||
}
|
||||
if (RNA_boolean_get(ptr, "toggle")) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Toggle Object Selection");
|
||||
}
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select Object");
|
||||
}
|
||||
|
||||
void VIEW3D_OT_select_menu(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
@@ -1655,6 +1668,7 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot)
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
ot->exec = object_select_menu_exec;
|
||||
ot->get_name = object_select_menu_get_name;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
@@ -161,21 +161,38 @@ void ED_select_pick_params_from_operator(PointerRNA *ptr, SelectPick_Params *par
|
||||
|
||||
std::string ED_select_pick_get_name(wmOperatorType * /*ot*/, PointerRNA *ptr)
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(ptr, "enumerate");
|
||||
const bool enumerate = (prop && RNA_property_boolean_get(ptr, prop));
|
||||
|
||||
SelectPick_Params params = {eSelectOp(0)};
|
||||
ED_select_pick_params_from_operator(ptr, ¶ms);
|
||||
switch (params.sel_op) {
|
||||
case SEL_OP_ADD:
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Extend)");
|
||||
if (enumerate) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select Extend (List)");
|
||||
}
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select Extend");
|
||||
case SEL_OP_SUB:
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Deselect)");
|
||||
if (enumerate) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Deselect (List)");
|
||||
}
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Deselect");
|
||||
case SEL_OP_XOR:
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (Toggle)");
|
||||
if (enumerate) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select Toggle (List)");
|
||||
}
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select Toggle");
|
||||
case SEL_OP_AND:
|
||||
BLI_assert_unreachable();
|
||||
ATTR_FALLTHROUGH;
|
||||
case SEL_OP_SET:
|
||||
break;
|
||||
}
|
||||
|
||||
if (enumerate) {
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select (List)");
|
||||
}
|
||||
|
||||
return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Select");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user