diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d174a78ee23..824920bce73 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1201,7 +1201,7 @@ void ED_operatortypes_ui(void); void ED_keymap_ui(struct wmKeyConfig *keyconf); void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop); -bool UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event); +bool UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event, const char **tooltip); bool UI_context_copy_to_selected_list( struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index ec10fc9d494..ae0fe912f95 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1243,7 +1243,7 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) ot->exec = reloadtranslation_exec; } -bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { /* should only return true for regions that include buttons, for now * return true always */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 50ac5dfd224..c8ad2b954a5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4826,7 +4826,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf) } -static bool open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) { if (drag->icon == ICON_FILE_BLEND) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 725c2b7fa6d..4f9fd9c65d7 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -847,7 +847,7 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul } /* dropboxes */ -static bool clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) if (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 3a48d5ad7dd..ce87ad3b177 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -170,7 +170,7 @@ static void console_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* ************* dropboxes ************* */ -static bool id_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool id_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_ID) @@ -189,7 +189,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) MEM_freeN(text); } -static bool path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_PATH) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 116cd700cc0..cb21659dbb8 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -720,7 +720,7 @@ static void file_ui_region_listener( } } -static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) { SpaceFile *sfile = CTX_wm_space_file(C); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index d87bfbe00ce..69bedf7c442 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -387,7 +387,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) } /* dropboxes */ -static bool image_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool image_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) if (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 10f337440d4..74c036883e6 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -675,7 +675,7 @@ static void node_main_region_draw(const bContext *C, ARegion *ar) /* ************* dropboxes ************* */ -static bool node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -689,7 +689,7 @@ static bool node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 0; } -static bool node_mask_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool node_mask_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index f37cd7fa5e4..c53a431a017 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -107,7 +107,7 @@ static TreeElement *outliner_dropzone_find(const SpaceOops *soops, const float f /* ******************** Parent Drop Operator *********************** */ -static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -367,7 +367,7 @@ static bool parenting_poll(bContext *C) /* ******************** Parent Clear Operator *********************** */ -static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -456,7 +456,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) /* ******************** Scene Drop Operator *********************** */ -static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -563,7 +563,7 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot) /* ******************** Material Drop Operator *********************** */ -static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -648,7 +648,7 @@ void OUTLINER_OT_material_drop(wmOperatorType *ot) /* ******************** Collection Drop Operator *********************** */ -static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 8fb526bf502..11517d64d7a 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -366,7 +366,7 @@ static void sequencer_listener( /* ************* dropboxes ************* */ -static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -380,7 +380,7 @@ static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) return 0; } -static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -393,7 +393,7 @@ static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) return 0; } -static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip)) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index ac43d7de408..53272ee9ed9 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -474,7 +474,7 @@ static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* ************* dropboxes ************* */ -static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) { /* rule might not work? */ @@ -491,7 +491,7 @@ static void text_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "filepath", drag->path); } -static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) return true; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index eaa6f03c533..62adca6af6b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -554,7 +554,7 @@ static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) } } -static bool view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -564,7 +564,7 @@ static bool view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 0; } -static bool view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -574,7 +574,7 @@ static bool view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const return 0; } -static bool view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -584,7 +584,7 @@ static bool view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEven return 0; } -static bool view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -610,19 +610,19 @@ static bool view3d_ima_bg_is_camera_view(bContext *C) return false; } -static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **tooltip) { if (view3d_ima_bg_is_camera_view(C)) { return true; } if (!ED_view3d_give_base_under_cursor(C, event->mval)) { - return view3d_ima_drop_poll(C, drag, event); + return view3d_ima_drop_poll(C, drag, event, tooltip); } return 0; } -static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **tooltip) { if (!view3d_ima_bg_is_camera_view(C)) { return true; @@ -634,18 +634,18 @@ static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent if ((base == NULL) || ((base != NULL) && base->object->type == OB_EMPTY)) { - return view3d_ima_drop_poll(C, drag, event); + return view3d_ima_drop_poll(C, drag, event, tooltip); } return 0; } -static bool view3d_ima_mesh_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_mesh_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **tooltip) { Base *base = ED_view3d_give_base_under_cursor(C, event->mval); if (base && base->object->type == OB_MESH) - return view3d_ima_drop_poll(C, drag, event); + return view3d_ima_drop_poll(C, drag, event, tooltip); return 0; } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 67ca5f8a08a..3521c4d1bd5 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -485,7 +485,8 @@ void WM_drag_free(struct wmDrag *drag); void WM_drag_free_list(struct ListBase *lb); struct wmDropBox *WM_dropbox_add( - ListBase *lb, const char *idname, bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event), + ListBase *lb, const char *idname, + bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event, const char **), void (*copy)(struct wmDrag *, struct wmDropBox *)); ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 6b1bb8f4806..809588b1a36 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -682,7 +682,7 @@ typedef struct wmDropBox { struct wmDropBox *next, *prev; /* test if the dropbox is active, then can print optype name */ - bool (*poll)(struct bContext *, struct wmDrag *, const wmEvent *); + bool (*poll)(struct bContext *, struct wmDrag *, const wmEvent *, const char **); /* before exec, this copies drag info to wmDrop properties */ void (*copy)(struct wmDrag *, struct wmDropBox *); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index eca3a838c0f..0ae51cc922b 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -98,7 +98,8 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) wmDropBox *WM_dropbox_add( - ListBase *lb, const char *idname, bool (*poll)(bContext *, wmDrag *, const wmEvent *), + ListBase *lb, const char *idname, + bool (*poll)(bContext *, wmDrag *, const wmEvent *, const char **), void (*copy)(wmDrag *, wmDropBox *)) { wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox"); @@ -195,10 +196,12 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, if (handler->dropboxes) { wmDropBox *drop = handler->dropboxes->first; for (; drop; drop = drop->next) { - if (drop->poll(C, drag, event)) + const char *tooltip = NULL; + if (drop->poll(C, drag, event, &tooltip)) { /* XXX Doing translation here might not be ideal, but later we have no more * access to ot (and hence op context)... */ - return RNA_struct_ui_name(drop->ot->srna); + return (tooltip) ? tooltip : RNA_struct_ui_name(drop->ot->srna); + } } } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8b1cce27502..5d343c5e0fe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2368,7 +2368,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers wmDrag *drag; for (drag = lb->first; drag; drag = drag->next) { - if (drop->poll(C, drag, event)) { + const char *tooltip = NULL; + if (drop->poll(C, drag, event, &tooltip)) { drop->copy(drag, drop); /* free the drags before calling operator */