Fix T41041: 'Delete keyframe' removes markers too

Operators that trigger UI events (but nothing else)
were using 'CANCELLED' making it impossible to tell if an invoke
function failed, or opened a menu.
This commit is contained in:
Campbell Barton 2014-10-28 17:51:06 +01:00
parent ba76f0c6a2
commit 2f0bdcb306
Notes: blender-bot 2023-02-14 11:18:07 +01:00
Referenced by commit 485293647f, Player: fix conflicting type introduced in 2f0bdcb306
Referenced by issue #41041, 'Delete keyframe' active in markers' area too
25 changed files with 72 additions and 58 deletions

View File

@ -503,8 +503,9 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm
/* return status modifications - for now, make this spacetype dependent as above */
if (sa->spacetype != SPACE_TIME) {
/* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */
if (retval != OPERATOR_FINISHED)
if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) {
retval |= OPERATOR_PASS_THROUGH;
}
}
return retval;

View File

@ -1407,7 +1407,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN
uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type");
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
else {
/* just call the exec() on the active keyingset */

View File

@ -477,7 +477,7 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve
uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static int keyingset_active_menu_exec(bContext *C, wmOperator *op)

View File

@ -693,7 +693,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void ARMATURE_OT_parent_set(wmOperatorType *ot)

View File

@ -162,7 +162,7 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
/* finish building the menu, and process it (should result in calling self again) */
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
else {
/* just use the active group index, and call the exec callback for the calling operator */

View File

@ -423,7 +423,7 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
uiPupMenuEnd(C, pup);
/* this operator is only for a menu, not used further */
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}

View File

@ -5386,7 +5386,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
layout = uiPupMenuLayout(pup);
uiItemsEnumO(layout, op->type->idname, "direction");
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
}
}

View File

@ -359,15 +359,15 @@ void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
void uiPupMenuReports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2);
int uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2);
/* Pie menus */
typedef struct uiPieMenu uiPieMenu;
void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event);
void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
int uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event);
int uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
const char *propname, const struct wmEvent *event);
void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event);
int uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event);
struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) ATTR_NONNULL();
void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie);

View File

@ -2794,7 +2794,7 @@ uiLayout *uiPieMenuLayout(uiPieMenu *pie)
return pie->layout;
}
void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event)
int uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event)
{
uiPieMenu *pie;
uiLayout *layout;
@ -2803,11 +2803,11 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even
if (mt == NULL) {
printf("%s: named menu \"%s\" not found\n", __func__, idname);
return;
return OPERATOR_CANCELLED;
}
if (mt->poll && mt->poll(C, mt) == 0)
return;
return OPERATOR_CANCELLED;
pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event);
layout = uiPieMenuLayout(pie);
@ -2822,10 +2822,12 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even
mt->draw(C, &menu);
uiPieMenuEnd(C, pie);
return OPERATOR_INTERFACE;
}
void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
const char *propname, const wmEvent *event)
int uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
const char *propname, const wmEvent *event)
{
uiPieMenu *pie;
uiLayout *layout;
@ -2837,10 +2839,12 @@ void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *
uiItemsEnumO(layout, opname, propname);
uiPieMenuEnd(C, pie);
return OPERATOR_INTERFACE;
}
void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path,
const wmEvent *event)
int uiPieEnumInvoke(struct bContext *C, const char *title, const char *path,
const wmEvent *event)
{
PointerRNA ctx_ptr;
PointerRNA r_ptr;
@ -2851,13 +2855,13 @@ void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path,
RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
if (!RNA_path_resolve(&ctx_ptr, path, &r_ptr, &r_prop)) {
return;
return OPERATOR_CANCELLED;
}
/* invalid property, only accept enums */
if (RNA_property_type(r_prop) != PROP_ENUM) {
BLI_assert(0);
return;
return OPERATOR_CANCELLED;
}
pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event);
@ -2868,6 +2872,8 @@ void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path,
uiItemFullR(layout, &r_ptr, r_prop, RNA_NO_INDEX, 0, UI_ITEM_R_EXPAND, NULL, 0);
uiPieMenuEnd(C, pie);
return OPERATOR_INTERFACE;
}
@ -2922,7 +2928,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
}
}
bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports)
int uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports)
{
uiPopupMenu *pup;
uiLayout *layout;
@ -2931,11 +2937,11 @@ bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports)
if (mt == NULL) {
BKE_reportf(reports, RPT_ERROR, "Menu \"%s\" not found", idname);
return false;
return OPERATOR_CANCELLED;
}
if (mt->poll && mt->poll(C, mt) == 0)
return false;
return OPERATOR_CANCELLED;
pup = uiPupMenuBegin(C, IFACE_(mt->label), ICON_NONE);
layout = uiPupMenuLayout(pup);
@ -2951,7 +2957,7 @@ bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports)
uiPupMenuEnd(C, pup);
return true;
return OPERATOR_INTERFACE;
}

View File

@ -1911,7 +1911,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* finish building the menu, and process it (should result in calling self again) */
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
/* call constraint_add_exec() to add the IK constraint */

View File

@ -309,14 +309,16 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* present the menu and be done... */
uiPupMenuEnd(C, pup);
/* this invoke just calls another instance of this operator... */
return OPERATOR_INTERFACE;
}
else {
/* error.. cannot continue */
BKE_report(op->reports, RPT_ERROR, "Can only make proxy for a referenced object or group");
return OPERATOR_CANCELLED;
}
/* this invoke just calls another instance of this operator... */
return OPERATOR_CANCELLED;
}
static int make_proxy_exec(bContext *C, wmOperator *op)
@ -923,7 +925,7 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static bool parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)

View File

@ -2759,7 +2759,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static void SCREEN_OT_area_options(wmOperatorType *ot)
@ -2866,7 +2866,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static int repeat_history_exec(bContext *C, wmOperator *op)
@ -3262,7 +3262,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static void SCREEN_OT_header_toolbox(wmOperatorType *ot)

View File

@ -4738,7 +4738,7 @@ static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, bool vdata, bo
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}

View File

@ -77,7 +77,7 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN
uiItemsEnumR(layout, &ptr, "align");
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void BUTTONS_OT_toolbox(wmOperatorType *ot)

View File

@ -2256,7 +2256,7 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
BKE_image_release_ibuf(ima, ibuf, NULL);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
BKE_image_release_ibuf(ima, ibuf, NULL);

View File

@ -261,7 +261,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void FILE_OT_unpack_all(wmOperatorType *ot)
@ -330,7 +330,7 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void FILE_OT_unpack_item(wmOperatorType *ot)

View File

@ -2194,7 +2194,7 @@ static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const w
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)

View File

@ -571,7 +571,7 @@ static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void NODE_OT_group_separate(wmOperatorType *ot)

View File

@ -1617,7 +1617,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
}
else {

View File

@ -3173,7 +3173,7 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEve
break;
}
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
void TEXT_OT_resolve_conflict(wmOperatorType *ot)

View File

@ -176,7 +176,7 @@ static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), const
uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)

View File

@ -352,13 +352,22 @@ enum {
OPERATOR_RUNNING_MODAL = (1 << 0),
OPERATOR_CANCELLED = (1 << 1),
OPERATOR_FINISHED = (1 << 2),
/* add this flag if the event should pass through */
/* add this flag if the event should pass through */
OPERATOR_PASS_THROUGH = (1 << 3),
/* in case operator got executed outside WM code... like via fileselect */
/* in case operator got executed outside WM code... like via fileselect */
OPERATOR_HANDLED = (1 << 4),
/* used for operators that act indirectly (eg. popup menu)
* note: this isn't great design (using operators to trigger UI) avoid where possible. */
OPERATOR_INTERFACE = (1 << 5),
};
#define OPERATOR_FLAGS_ALL (OPERATOR_RUNNING_MODAL | OPERATOR_CANCELLED | OPERATOR_FINISHED | \
OPERATOR_PASS_THROUGH | OPERATOR_HANDLED)
#define OPERATOR_FLAGS_ALL ( \
OPERATOR_RUNNING_MODAL | \
OPERATOR_CANCELLED | \
OPERATOR_FINISHED | \
OPERATOR_PASS_THROUGH | \
OPERATOR_HANDLED | \
OPERATOR_INTERFACE | \
0)
/* sanity checks for debug mode only */
#define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)

View File

@ -429,6 +429,7 @@ EnumPropertyItem operator_return_items[] = {
{OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"},
/* used as a flag */
{OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"},
{OPERATOR_INTERFACE, "INTERFACE", 0, "Interface", "Handled but not executed (popup menus)"},
{0, NULL, 0, NULL, NULL}
};

View File

@ -1079,6 +1079,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
return OPERATOR_INTERFACE;
}
return OPERATOR_CANCELLED;
@ -1123,7 +1124,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op)
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
uiPupBlock(C, wm_enum_search_menu, op);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
/* Can't be used as an invoke directly, needs message arg (can be NULL) */
@ -1145,7 +1146,7 @@ int WM_operator_confirm_message_ex(bContext *C, wmOperator *op,
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
@ -2018,7 +2019,7 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
{
uiPupBlock(C, wm_block_search_menu, op);
return OPERATOR_CANCELLED;
return OPERATOR_INTERFACE;
}
/* op->poll */
@ -2057,9 +2058,7 @@ static int wm_call_menu_exec(bContext *C, wmOperator *op)
char idname[BKE_ST_MAXNAME];
RNA_string_get(op->ptr, "name", idname);
uiPupMenuInvoke(C, idname, op->reports);
return OPERATOR_CANCELLED;
return uiPupMenuInvoke(C, idname, op->reports);
}
static void WM_OT_call_menu(wmOperatorType *ot)
@ -2081,9 +2080,7 @@ static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *e
char idname[BKE_ST_MAXNAME];
RNA_string_get(op->ptr, "name", idname);
uiPieMenuInvoke(C, idname, event);
return OPERATOR_CANCELLED;
return uiPieMenuInvoke(C, idname, event);
}
static int wm_call_pie_menu_exec(bContext *C, wmOperator *op)
@ -2091,9 +2088,7 @@ static int wm_call_pie_menu_exec(bContext *C, wmOperator *op)
char idname[BKE_ST_MAXNAME];
RNA_string_get(op->ptr, "name", idname);
uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate);
return OPERATOR_CANCELLED;
return uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate);
}
static void WM_OT_call_menu_pie(wmOperatorType *ot)

View File

@ -626,7 +626,7 @@ struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int ic
void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head) RET_NONE
struct uiLayout *uiPupMenuLayout(struct uiPopupMenu *head) RET_NULL
struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie) RET_NULL
void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_NONE
int uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_NONE
struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) RET_NULL
void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie) RET_NONE
struct uiLayout *uiLayoutRadial(struct uiLayout *layout) RET_NULL