Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/space_sequencer.c
| Show All 22 Lines | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_sound_types.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| ▲ Show 20 Lines • Show All 356 Lines • ▼ Show 20 Lines | static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| if (drag->type == WM_DRAG_PATH) { | if (drag->type == WM_DRAG_PATH) { | ||||
| if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* Rule might not work? */ | if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* Rule might not work? */ | ||||
| if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return WM_drag_is_ID_type(drag, ID_IM); | ||||
| } | } | ||||
| static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| int hand; | int hand; | ||||
| if (drag->type == WM_DRAG_PATH) { | if (drag->type == WM_DRAG_PATH) { | ||||
| if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */ | if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */ | ||||
| if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return 0; | |||||
| return WM_drag_is_ID_type(drag, ID_MC); | |||||
| } | } | ||||
| static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| int hand; | int hand; | ||||
| if (drag->type == WM_DRAG_PATH) { | if (drag->type == WM_DRAG_PATH) { | ||||
| if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might not work? */ | if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might not work? */ | ||||
| if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return 0; | |||||
| return WM_drag_is_ID_type(drag, ID_SO); | |||||
| } | } | ||||
| static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) | static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| /* Copy drag path to properties. */ | ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); | ||||
| /* ID dropped. */ | |||||
| if (id != NULL) { | |||||
| const ID_Type id_type = GS(id->name); | |||||
| if (id_type == ID_IM) { | |||||
| Image *ima = (Image *)id; | |||||
| PointerRNA itemptr; | |||||
| char dir[FILE_MAX], file[FILE_MAX]; | |||||
| BLI_split_dirfile(ima->filepath, dir, file, sizeof(dir), sizeof(file)); | |||||
| RNA_string_set(drop->ptr, "directory", dir); | |||||
| RNA_collection_clear(drop->ptr, "files"); | |||||
| RNA_collection_add(drop->ptr, "files", &itemptr); | |||||
sergey: `sequencer_id_path_drop_copy` -> `sequencer_id_or_path_drop_copy`
ID path is something else. | |||||
| RNA_string_set(&itemptr, "name", file); | |||||
| } | |||||
| else if (id_type == ID_MC) { | |||||
| MovieClip *clip = (MovieClip *)id; | |||||
| RNA_string_set(drop->ptr, "filepath", clip->filepath); | |||||
| RNA_struct_property_unset(drop->ptr, "name"); | |||||
| } | |||||
| else if (id_type == ID_SO) { | |||||
| bSound *sound = (bSound *)id; | |||||
| RNA_string_set(drop->ptr, "filepath", sound->filepath); | |||||
| RNA_struct_property_unset(drop->ptr, "name"); | |||||
| } | |||||
| } | |||||
| /* Path dropped. */ | |||||
| else if (drag->path[0]) { | |||||
| if (RNA_struct_find_property(drop->ptr, "filepath")) { | if (RNA_struct_find_property(drop->ptr, "filepath")) { | ||||
| RNA_string_set(drop->ptr, "filepath", drag->path); | RNA_string_set(drop->ptr, "filepath", drag->path); | ||||
| } | } | ||||
| if (RNA_struct_find_property(drop->ptr, "directory")) { | if (RNA_struct_find_property(drop->ptr, "directory")) { | ||||
| PointerRNA itemptr; | PointerRNA itemptr; | ||||
| char dir[FILE_MAX], file[FILE_MAX]; | char dir[FILE_MAX], file[FILE_MAX]; | ||||
| BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file)); | BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file)); | ||||
| RNA_string_set(drop->ptr, "directory", dir); | RNA_string_set(drop->ptr, "directory", dir); | ||||
| RNA_collection_clear(drop->ptr, "files"); | RNA_collection_clear(drop->ptr, "files"); | ||||
| RNA_collection_add(drop->ptr, "files", &itemptr); | RNA_collection_add(drop->ptr, "files", &itemptr); | ||||
| RNA_string_set(&itemptr, "name", file); | RNA_string_set(&itemptr, "name", file); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /* This region dropbox definition. */ | /* This region dropbox definition. */ | ||||
| static void sequencer_dropboxes(void) | static void sequencer_dropboxes(void) | ||||
| { | { | ||||
| ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); | ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); | ||||
| WM_dropbox_add( | WM_dropbox_add( | ||||
| lb, "SEQUENCER_OT_image_strip_add", image_drop_poll, sequencer_drop_copy, NULL, NULL); | lb, "SEQUENCER_OT_image_strip_add", image_drop_poll, sequencer_drop_copy, NULL, NULL); | ||||
| ▲ Show 20 Lines • Show All 608 Lines • Show Last 20 Lines | |||||
sequencer_id_path_drop_copy -> sequencer_id_or_path_drop_copy
ID path is something else.