Blender  V3.3
wm_dragdrop.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2010 Blender Foundation. All rights reserved. */
3 
10 #include <cstring>
11 
12 #include "DNA_screen_types.h"
13 #include "DNA_space_types.h"
15 
16 #include "MEM_guardedalloc.h"
17 
18 #include "BLT_translation.h"
19 
20 #include "BLI_bitmap.h"
21 #include "BLI_blenlib.h"
22 #include "BLI_math_color.h"
23 
24 #include "BIF_glutil.h"
25 
26 #include "BKE_context.h"
27 #include "BKE_global.h"
28 #include "BKE_idprop.h"
29 #include "BKE_idtype.h"
30 #include "BKE_lib_id.h"
31 #include "BKE_main.h"
32 #include "BKE_screen.h"
33 
34 #include "GHOST_C-api.h"
35 
36 #include "BLO_readfile.h"
37 
38 #include "ED_asset.h"
39 #include "ED_screen.h"
40 
41 #include "GPU_shader.h"
42 #include "GPU_state.h"
43 #include "GPU_viewport.h"
44 
45 #include "IMB_imbuf_types.h"
46 
47 #include "UI_interface.h"
48 #include "UI_interface_icons.h"
49 #include "UI_resources.h"
50 
51 #include "RNA_access.h"
52 
53 #include "WM_api.h"
54 #include "WM_types.h"
55 #include "wm_event_system.h"
56 #include "wm_window.h"
57 
58 /* ****************************************************** */
59 
60 static ListBase dropboxes = {nullptr, nullptr};
61 
62 static void wm_drag_free_asset_data(wmDragAsset **asset_data);
63 
64 /* drop box maps are stored global for now */
65 /* these are part of blender's UI/space specs, and not like keymaps */
66 /* when editors become configurable, they can add own dropbox definitions */
67 
68 struct wmDropBoxMap {
69  struct wmDropBoxMap *next, *prev;
70 
72  short spaceid, regionid;
74 };
75 
77 {
79  if (dm->spaceid == spaceid && dm->regionid == regionid) {
80  if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME)) {
81  return &dm->dropboxes;
82  }
83  }
84  }
85 
86  wmDropBoxMap *dm = MEM_cnew<wmDropBoxMap>(__func__);
88  dm->spaceid = spaceid;
89  dm->regionid = regionid;
90  BLI_addtail(&dropboxes, dm);
91 
92  return &dm->dropboxes;
93 }
94 
96  const char *idname,
97  bool (*poll)(bContext *, wmDrag *, const wmEvent *),
98  void (*copy)(bContext *, wmDrag *, wmDropBox *),
99  void (*cancel)(Main *, wmDrag *, wmDropBox *),
100  WMDropboxTooltipFunc tooltip)
101 {
102  wmDropBox *drop = MEM_cnew<wmDropBox>(__func__);
103  drop->poll = poll;
104  drop->copy = copy;
105  drop->cancel = cancel;
106  drop->tooltip = tooltip;
107  drop->ot = WM_operatortype_find(idname, false);
108 
109  if (drop->ot == nullptr) {
110  MEM_freeN(drop);
111  printf("Error: dropbox with unknown operator: %s\n", idname);
112  return nullptr;
113  }
114  WM_operator_properties_alloc(&(drop->ptr), &(drop->properties), idname);
115 
116  BLI_addtail(lb, drop);
117 
118  return drop;
119 }
120 
121 void wm_dropbox_free(void)
122 {
123 
125  LISTBASE_FOREACH (wmDropBox *, drop, &dm->dropboxes) {
126  if (drop->ptr) {
127  WM_operator_properties_free(drop->ptr);
128  MEM_freeN(drop->ptr);
129  }
130  }
131  BLI_freelistN(&dm->dropboxes);
132  }
133 
135 }
136 
137 /* *********************************** */
138 
139 static void wm_dropbox_invoke(bContext *C, wmDrag *drag)
140 {
142 
143  /* Create a bitmap flag matrix of all currently visible region and area types.
144  * Everything that isn't visible in the current window should not prefetch any data. */
145  bool area_region_tag[SPACE_TYPE_NUM][RGN_TYPE_NUM] = {{false}};
146 
147  LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
148  bScreen *screen = WM_window_get_active_screen(win);
149  ED_screen_areas_iter (win, screen, area) {
150  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
151  if (region->visible) {
152  BLI_assert(area->spacetype < SPACE_TYPE_NUM);
153  BLI_assert(region->regiontype < RGN_TYPE_NUM);
154  area_region_tag[area->spacetype][region->regiontype] = true;
155  }
156  }
157  }
158  }
159 
161  if (!area_region_tag[dm->spaceid][dm->regionid]) {
162  continue;
163  }
164  LISTBASE_FOREACH (wmDropBox *, drop, &dm->dropboxes) {
165  if (drag->drop_state.ui_context) {
167  }
168 
169  if (drop->on_drag_start) {
170  drop->on_drag_start(C, drag);
171  }
172  CTX_store_set(C, nullptr);
173  }
174  }
175 }
176 
178  bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
179 {
180  wmDrag *drag = MEM_cnew<wmDrag>(__func__);
181 
182  /* Keep track of future multi-touch drag too, add a mouse-pointer id or so. */
183  /* if multiple drags are added, they're drawn as list */
184 
185  drag->flags = static_cast<eWM_DragFlags>(flags);
186  drag->icon = icon;
187  drag->type = type;
188  switch (type) {
189  case WM_DRAG_PATH:
190  BLI_strncpy(drag->path, static_cast<const char *>(poin), FILE_MAX);
191  /* As the path is being copied, free it immediately as `drag` won't "own" the data. */
192  if (flags & WM_DRAG_FREE_DATA) {
193  MEM_freeN(poin);
194  }
195  break;
196  case WM_DRAG_ID:
197  if (poin) {
198  WM_drag_add_local_ID(drag, static_cast<ID *>(poin), nullptr);
199  }
200  break;
201  case WM_DRAG_ASSET:
203  /* Move ownership of poin to wmDrag. */
204  drag->poin = poin;
205  drag->flags |= WM_DRAG_FREE_DATA;
206  break;
207  /* The asset-list case is special: We get multiple assets from context and attach them to the
208  * drag item. */
209  case WM_DRAG_ASSET_LIST: {
210  const AssetLibraryReference *asset_library = CTX_wm_asset_library_ref(C);
211  ListBase asset_file_links = CTX_data_collection_get(C, "selected_asset_files");
212  LISTBASE_FOREACH (const CollectionPointerLink *, link, &asset_file_links) {
213  const FileDirEntry *asset_file = static_cast<const FileDirEntry *>(link->ptr.data);
214  const AssetHandle asset_handle = {asset_file};
215  WM_drag_add_asset_list_item(drag, C, asset_library, &asset_handle);
216  }
217  BLI_freelistN(&asset_file_links);
218  break;
219  }
220  default:
221  drag->poin = poin;
222  break;
223  }
224  drag->value = value;
225 
226  return drag;
227 }
228 
230 {
232 
233  BLI_addtail(&wm->drags, drag);
234  wm_dropbox_invoke(C, drag);
235 }
236 
238  bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
239 {
240  wmDrag *drag = WM_drag_data_create(C, icon, type, poin, value, flags);
242 }
243 
245 {
246  bool any_active = false;
247  LISTBASE_FOREACH (const wmDrag *, drag, &wm->drags) {
248  if (drag->drop_state.active_dropbox) {
249  any_active = true;
250  break;
251  }
252  }
253 
254  /* If there is no active drop-box #wm_drags_check_ops() set a stop-cursor, which needs to be
255  * restored. */
256  if (!any_active) {
258  /* Ensure the correct area cursor is restored. */
259  win->tag_cursor_refresh = true;
261  }
262 }
263 
265 {
267  if (!active_but) {
268  return nullptr;
269  }
270 
271  bContextStore *but_context = UI_but_context_get(active_but);
272  if (!but_context) {
273  return nullptr;
274  }
275 
276  return CTX_store_copy(but_context);
277 }
278 
279 static void wm_drop_ui_context_free(bContextStore **context_store)
280 {
281  if (!*context_store) {
282  return;
283  }
284  CTX_store_free(*context_store);
285  *context_store = nullptr;
286 }
287 
288 void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale)
289 {
290  drag->imb = imb;
291  drag->imbuf_scale = scale;
292 }
293 
294 void WM_drag_data_free(int dragtype, void *poin)
295 {
296  /* Don't require all the callers to have a nullptr-check, just allow passing nullptr. */
297  if (!poin) {
298  return;
299  }
300 
301  /* Not too nice, could become a callback. */
302  if (dragtype == WM_DRAG_ASSET) {
303  wmDragAsset *asset_data = static_cast<wmDragAsset *>(poin);
304  wm_drag_free_asset_data(&asset_data);
305  }
306  else {
307  MEM_freeN(poin);
308  }
309 }
310 
311 void WM_drag_free(wmDrag *drag)
312 {
315  }
316  if (drag->flags & WM_DRAG_FREE_DATA) {
317  WM_drag_data_free(drag->type, drag->poin);
318  }
320  if (drag->drop_state.free_disabled_info) {
322  }
323  BLI_freelistN(&drag->ids);
325  if (asset_item->is_external) {
326  wm_drag_free_asset_data(&asset_item->asset_data.external_info);
327  }
328  BLI_freelinkN(&drag->asset_items, asset_item);
329  }
330  MEM_freeN(drag);
331 }
332 
334 {
335  wmDrag *drag;
336  while ((drag = static_cast<wmDrag *>(BLI_pophead(lb)))) {
337  WM_drag_free(drag);
338  }
339 }
340 
341 static char *dropbox_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *drop)
342 {
343  char *tooltip = nullptr;
344  if (drop->tooltip) {
345  tooltip = drop->tooltip(C, drag, xy, drop);
346  }
347  if (!tooltip) {
348  tooltip = BLI_strdup(WM_operatortype_name(drop->ot, drop->ptr));
349  }
350  /* XXX Doing translation here might not be ideal, but later we have no more
351  * access to ot (and hence op context)... */
352  return tooltip;
353 }
354 
356  ListBase *handlers,
357  wmDrag *drag,
358  const wmEvent *event)
359 {
360  if (drag->drop_state.free_disabled_info) {
362  }
363  drag->drop_state.disabled_info = nullptr;
364 
365  LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
366  if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) {
367  wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base;
368  if (handler->dropboxes) {
369  LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) {
370  if (drag->drop_state.ui_context) {
372  }
373 
374  if (!drop->poll(C, drag, event)) {
375  /* If the drop's poll fails, don't set the disabled-info. This would be too aggressive.
376  * Instead show it only if the drop box could be used in principle, but the operator
377  * can't be executed. */
378  continue;
379  }
380 
381  const wmOperatorCallContext opcontext = wm_drop_operator_context_get(drop);
382  if (WM_operator_poll_context(C, drop->ot, opcontext)) {
383  CTX_store_set(C, nullptr);
384  return drop;
385  }
386 
387  /* Attempt to set the disabled hint when the poll fails. Will always be the last hint set
388  * when there are multiple failing polls (could allow multiple disabled-hints too). */
389  bool free_disabled_info = false;
390  const char *disabled_hint = CTX_wm_operator_poll_msg_get(C, &free_disabled_info);
391  if (disabled_hint) {
392  drag->drop_state.disabled_info = disabled_hint;
393  drag->drop_state.free_disabled_info = free_disabled_info;
394  }
395  }
396  }
397  }
398  }
399  CTX_store_set(C, nullptr);
400  return nullptr;
401 }
402 
403 /* return active operator tooltip/name when mouse is in box */
404 static wmDropBox *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *event)
405 {
406  wmWindow *win = CTX_wm_window(C);
407  wmDropBox *drop = dropbox_active(C, &win->handlers, drag, event);
408  if (!drop) {
410  drop = dropbox_active(C, &area->handlers, drag, event);
411  }
412  if (!drop) {
413  ARegion *region = CTX_wm_region(C);
414  drop = dropbox_active(C, &region->handlers, drag, event);
415  }
416  return drop;
417 }
418 
422 static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *event)
423 {
424  wmWindow *win = CTX_wm_window(C);
425  const int winsize_x = WM_window_pixels_x(win);
426  const int winsize_y = WM_window_pixels_y(win);
427 
428  /* for multiwin drags, we only do this if mouse inside */
429  if (event->xy[0] < 0 || event->xy[1] < 0 || event->xy[0] > winsize_x ||
430  event->xy[1] > winsize_y) {
431  return;
432  }
433 
434  /* Update UI context, before polling so polls can query this context. */
437 
438  wmDropBox *drop_prev = drag->drop_state.active_dropbox;
439  wmDropBox *drop = wm_dropbox_active(C, drag, event);
440  if (drop != drop_prev) {
441  if (drop_prev && drop_prev->draw_deactivate) {
442  drop_prev->draw_deactivate(drop_prev, drag);
443  BLI_assert(drop_prev->draw_data == nullptr);
444  }
445  if (drop && drop->draw_activate) {
446  drop->draw_activate(drop, drag);
447  }
448  drag->drop_state.active_dropbox = drop;
449  drag->drop_state.area_from = drop ? CTX_wm_area(C) : nullptr;
450  drag->drop_state.region_from = drop ? CTX_wm_region(C) : nullptr;
451  }
452 
453  if (!drag->drop_state.active_dropbox) {
455  }
456 }
457 
459 {
460  const wmOperatorCallContext opcontext = wm_drop_operator_context_get(drop);
461 
462  if (drag->drop_state.ui_context) {
464  }
465 
466  /* Optionally copy drag information to operator properties. Don't call it if the
467  * operator fails anyway, it might do more than just set properties (e.g.
468  * typically import an asset). */
469  if (drop->copy && WM_operator_poll_context(C, drop->ot, opcontext)) {
470  drop->copy(C, drag, drop);
471  }
472 
474 }
475 
477 {
478  CTX_store_set(C, nullptr);
479 }
480 
481 void wm_drags_check_ops(bContext *C, const wmEvent *event)
482 {
484 
485  bool any_active = false;
486  LISTBASE_FOREACH (wmDrag *, drag, &wm->drags) {
487  wm_drop_update_active(C, drag, event);
488 
489  if (drag->drop_state.active_dropbox) {
490  any_active = true;
491  }
492  }
493 
494  /* Change the cursor to display that dropping isn't possible here. But only if there is something
495  * being dragged actually. Cursor will be restored in #wm_drags_exit(). */
496  if (!BLI_listbase_is_empty(&wm->drags)) {
498  }
499 }
500 
502 {
503  return WM_OP_INVOKE_DEFAULT;
504 }
505 
506 /* ************** IDs ***************** */
507 
508 void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
509 {
510  /* Don't drag the same ID twice. */
511  LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
512  if (drag_id->id == id) {
513  if (drag_id->from_parent == nullptr) {
514  drag_id->from_parent = from_parent;
515  }
516  return;
517  }
518  if (GS(drag_id->id->name) != GS(id->name)) {
519  BLI_assert_msg(0, "All dragged IDs must have the same type");
520  return;
521  }
522  }
523 
524  /* Add to list. */
525  wmDragID *drag_id = MEM_cnew<wmDragID>(__func__);
526  drag_id->id = id;
527  drag_id->from_parent = from_parent;
528  BLI_addtail(&drag->ids, drag_id);
529 }
530 
531 ID *WM_drag_get_local_ID(const wmDrag *drag, short idcode)
532 {
533  if (drag->type != WM_DRAG_ID) {
534  return nullptr;
535  }
536 
537  wmDragID *drag_id = static_cast<wmDragID *>(drag->ids.first);
538  if (!drag_id) {
539  return nullptr;
540  }
541 
542  ID *id = drag_id->id;
543  return (idcode == 0 || GS(id->name) == idcode) ? id : nullptr;
544 }
545 
546 ID *WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
547 {
548  if (event->custom != EVT_DATA_DRAGDROP) {
549  return nullptr;
550  }
551 
552  ListBase *lb = static_cast<ListBase *>(event->customdata);
553  return WM_drag_get_local_ID(static_cast<const wmDrag *>(lb->first), idcode);
554 }
555 
556 bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
557 {
558  return WM_drag_get_local_ID(drag, idcode) || WM_drag_get_asset_data(drag, idcode);
559 }
560 
562  AssetMetaData *metadata,
563  const char *path,
564  int import_type)
565 {
566  wmDragAsset *asset_drag = MEM_new<wmDragAsset>(__func__);
567 
568  BLI_strncpy(asset_drag->name, ED_asset_handle_get_name(asset), sizeof(asset_drag->name));
569  asset_drag->metadata = metadata;
570  asset_drag->path = path;
571  asset_drag->id_type = ED_asset_handle_get_id_type(asset);
572  asset_drag->import_type = import_type;
573 
574  return asset_drag;
575 }
576 
577 static void wm_drag_free_asset_data(wmDragAsset **asset_data)
578 {
579  MEM_freeN((char *)(*asset_data)->path);
580  MEM_SAFE_FREE(*asset_data);
581 }
582 
583 wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode)
584 {
585  if (drag->type != WM_DRAG_ASSET) {
586  return nullptr;
587  }
588 
589  wmDragAsset *asset_drag = static_cast<wmDragAsset *>(drag->poin);
590  return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : nullptr;
591 }
592 
594 {
595  wmDragAsset *drag_asset = WM_drag_get_asset_data(drag, idcode);
596  if (drag_asset) {
597  return drag_asset->metadata;
598  }
599 
600  ID *local_id = WM_drag_get_local_ID(drag, idcode);
601  if (local_id) {
602  return local_id->asset_data;
603  }
604 
605  return nullptr;
606 }
607 
608 ID *WM_drag_asset_id_import(wmDragAsset *asset_drag, const int flag_extra)
609 {
610  /* Only support passing in limited flags. */
611  BLI_assert(flag_extra == (flag_extra & FILE_AUTOSELECT));
612  eFileSel_Params_Flag flag = static_cast<eFileSel_Params_Flag>(flag_extra) |
614 
615  const char *name = asset_drag->name;
616  ID_Type idtype = static_cast<ID_Type>(asset_drag->id_type);
617 
618  /* FIXME: Link/Append should happens in the operator called at the end of drop process, not from
619  * here. */
620 
621  Main *bmain = CTX_data_main(asset_drag->evil_C);
622  Scene *scene = CTX_data_scene(asset_drag->evil_C);
623  ViewLayer *view_layer = CTX_data_view_layer(asset_drag->evil_C);
624  View3D *view3d = CTX_wm_view3d(asset_drag->evil_C);
625 
626  switch ((eFileAssetImportType)asset_drag->import_type) {
628  return WM_file_link_datablock(
629  bmain, scene, view_layer, view3d, asset_drag->path, idtype, name, flag);
631  return WM_file_append_datablock(bmain,
632  scene,
633  view_layer,
634  view3d,
635  asset_drag->path,
636  idtype,
637  name,
642  scene,
643  view_layer,
644  view3d,
645  asset_drag->path,
646  idtype,
647  name,
651  }
652 
654  return nullptr;
655 }
656 
658 {
659  if (drag->type != WM_DRAG_ASSET) {
660  return false;
661  }
662 
663  const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
664  return asset_drag->import_type == FILE_ASSET_IMPORT_LINK;
665 }
666 
668 {
669  if (!ELEM(drag->type, WM_DRAG_ASSET, WM_DRAG_ID)) {
670  return nullptr;
671  }
672 
673  if (drag->type == WM_DRAG_ID) {
674  return WM_drag_get_local_ID(drag, idcode);
675  }
676 
677  wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, idcode);
678  if (!asset_drag) {
679  return nullptr;
680  }
681 
682  /* Link/append the asset. */
683  return WM_drag_asset_id_import(asset_drag, 0);
684 }
685 
687 {
688  if (drag->type != WM_DRAG_ASSET) {
689  return;
690  }
691 
692  wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
693  if (!asset_drag) {
694  return;
695  }
696 
697  /* Try to find the imported ID. For this to work either a "session_uuid" or "name" property must
698  * have been defined (see #WM_operator_properties_id_lookup()). */
700  bmain, drop->ptr, static_cast<ID_Type>(asset_drag->id_type));
701  if (id != nullptr) {
702  /* Do not delete the dragged ID if it has any user, otherwise if it is a 're-used' ID it will
703  * cause T95636. Note that we need first to add the user that we want to remove in
704  * #BKE_id_free_us. */
705  id_us_plus(id);
706  BKE_id_free_us(bmain, id);
707  }
708 }
709 
711 {
712  if (drag->type != WM_DRAG_ASSET_CATALOG) {
713  return nullptr;
714  }
715 
716  return static_cast<wmDragAssetCatalog *>(drag->poin);
717 }
718 
720  wmDrag *drag,
721  /* Context only needed for the hack in #ED_asset_handle_get_full_library_path(). */
722  const bContext *C,
723  const AssetLibraryReference *asset_library_ref,
724  const AssetHandle *asset)
725 {
727 
728  /* No guarantee that the same asset isn't added twice. */
729 
730  /* Add to list. */
731  wmDragAssetListItem *drag_asset = MEM_cnew<wmDragAssetListItem>(__func__);
732  ID *local_id = ED_asset_handle_get_local_id(asset);
733  if (local_id) {
734  drag_asset->is_external = false;
735  drag_asset->asset_data.local_id = local_id;
736  }
737  else {
738  AssetMetaData *metadata = ED_asset_handle_get_metadata(asset);
739  char asset_blend_path[FILE_MAX_LIBEXTRA];
740  ED_asset_handle_get_full_library_path(C, asset_library_ref, asset, asset_blend_path);
741  drag_asset->is_external = true;
743  asset, metadata, BLI_strdup(asset_blend_path), FILE_ASSET_IMPORT_APPEND);
744  }
745  BLI_addtail(&drag->asset_items, drag_asset);
746 }
747 
749 {
750  if (drag->type != WM_DRAG_ASSET_LIST) {
751  return nullptr;
752  }
753 
754  return &drag->asset_items;
755 }
756 
757 /* ************** draw ***************** */
758 
759 static void wm_drop_operator_draw(const char *name, int x, int y)
760 {
761  const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
762 
763  /* Use the theme settings from tooltips. */
764  const bTheme *btheme = UI_GetTheme();
765  const uiWidgetColors *wcol = &btheme->tui.wcol_tooltip;
766 
767  float col_fg[4], col_bg[4];
768  rgba_uchar_to_float(col_fg, wcol->text);
769  rgba_uchar_to_float(col_bg, wcol->inner);
770 
771  UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, col_fg, col_bg);
772 }
773 
774 static void wm_drop_redalert_draw(const char *redalert_str, int x, int y)
775 {
776  const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
777  const bTheme *btheme = UI_GetTheme();
778  const uiWidgetColors *wcol = &btheme->tui.wcol_tooltip;
779 
780  float col_fg[4], col_bg[4];
782  rgba_uchar_to_float(col_bg, wcol->inner);
783 
784  UI_fontstyle_draw_simple_backdrop(fstyle, x, y, redalert_str, col_fg, col_bg);
785 }
786 
787 const char *WM_drag_get_item_name(wmDrag *drag)
788 {
789  switch (drag->type) {
790  case WM_DRAG_ID: {
791  ID *id = WM_drag_get_local_ID(drag, 0);
792  bool single = (BLI_listbase_count_at_most(&drag->ids, 2) == 1);
793 
794  if (single) {
795  return id->name + 2;
796  }
797  if (id) {
799  }
800  break;
801  }
802  case WM_DRAG_ASSET: {
803  const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
804  return asset_drag->name;
805  }
806  case WM_DRAG_PATH:
807  case WM_DRAG_NAME:
808  return drag->path;
809  }
810  return "";
811 }
812 
813 static int wm_drag_imbuf_icon_width_get(const wmDrag *drag)
814 {
815  return round_fl_to_int(drag->imb->x * drag->imbuf_scale);
816 }
817 
818 static int wm_drag_imbuf_icon_height_get(const wmDrag *drag)
819 {
820  return round_fl_to_int(drag->imb->y * drag->imbuf_scale);
821 }
822 
824  wmWindow *UNUSED(win),
825  wmDrag *drag,
826  const int xy[2])
827 {
828  int x, y;
829 
830  /* This could also get the preview image of an ID when dragging one. But the big preview icon may
831  * actually not always be wanted, for example when dragging objects in the Outliner it gets in
832  * the way). So make the drag user set an image buffer explicitly (e.g. through
833  * #UI_but_drag_attach_image()). */
834 
835  if (drag->imb) {
836  x = xy[0] - (wm_drag_imbuf_icon_width_get(drag) / 2);
837  y = xy[1] - (wm_drag_imbuf_icon_height_get(drag) / 2);
838 
839  const float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
842  x,
843  y,
844  drag->imb->x,
845  drag->imb->y,
846  GPU_RGBA8,
847  false,
848  drag->imb->rect,
849  drag->imbuf_scale,
850  drag->imbuf_scale,
851  1.0f,
852  1.0f,
853  col);
854  }
855  else {
856  int padding = 4 * UI_DPI_FAC;
857  x = xy[0] - 2 * padding;
858  y = xy[1] - 2 * UI_DPI_FAC;
859 
860  const uchar text_col[] = {255, 255, 255, 255};
861  UI_icon_draw_ex(x, y, drag->icon, U.inv_dpi_fac, 0.8, 0.0f, text_col, false);
862  }
863 }
864 
865 static void wm_drag_draw_item_name(wmDrag *drag, const int x, const int y)
866 {
867  const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
868  const uchar text_col[] = {255, 255, 255, 255};
869  UI_fontstyle_draw_simple(fstyle, x, y, WM_drag_get_item_name(drag), text_col);
870 }
871 
873  wmWindow *UNUSED(win),
874  wmDrag *drag,
875  const int xy[2])
876 {
877  int x = xy[0] + 10 * UI_DPI_FAC;
878  int y = xy[1] + 1 * UI_DPI_FAC;
879 
880  wm_drag_draw_item_name(drag, x, y);
881 }
882 
883 static void wm_drag_draw_tooltip(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
884 {
885  if (!CTX_wm_region(C)) {
886  /* Some callbacks require the region. */
887  return;
888  }
889  int iconsize = UI_DPI_ICON_SIZE;
890  int padding = 4 * UI_DPI_FAC;
891 
892  char *tooltip = nullptr;
893  if (drag->drop_state.active_dropbox) {
894  tooltip = dropbox_tooltip(C, drag, xy, drag->drop_state.active_dropbox);
895  }
896 
897  const bool has_disabled_info = drag->drop_state.disabled_info &&
898  drag->drop_state.disabled_info[0];
899  if (!tooltip && !has_disabled_info) {
900  return;
901  }
902 
903  const int winsize_y = WM_window_pixels_y(win);
904  int x, y;
905  if (drag->imb) {
906  const int icon_width = wm_drag_imbuf_icon_width_get(drag);
907  const int icon_height = wm_drag_imbuf_icon_height_get(drag);
908 
909  x = xy[0] - (icon_width / 2);
910 
911  if (xy[1] + (icon_height / 2) + padding + iconsize < winsize_y) {
912  y = xy[1] + (icon_height / 2) + padding;
913  }
914  else {
915  y = xy[1] - (icon_height / 2) - padding - iconsize - padding - iconsize;
916  }
917  }
918  else {
919  x = xy[0] - 2 * padding;
920 
921  if (xy[1] + iconsize + iconsize < winsize_y) {
922  y = (xy[1] + iconsize) + padding;
923  }
924  else {
925  y = (xy[1] - iconsize) - padding;
926  }
927  }
928 
929  if (tooltip) {
930  wm_drop_operator_draw(tooltip, x, y);
931  MEM_freeN(tooltip);
932  }
933  else if (has_disabled_info) {
935  }
936 }
937 
938 static void wm_drag_draw_default(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
939 {
940  int xy_tmp[2] = {UNPACK2(xy)};
941 
942  /* Image or icon. */
943  wm_drag_draw_icon(C, win, drag, xy_tmp);
944 
945  /* Item name. */
946  if (drag->imb) {
947  int iconsize = UI_DPI_ICON_SIZE;
948  xy_tmp[0] = xy[0] - (wm_drag_imbuf_icon_width_get(drag) / 2);
949  xy_tmp[1] = xy[1] - (wm_drag_imbuf_icon_height_get(drag) / 2) - iconsize;
950  }
951  else {
952  xy_tmp[0] = xy[0] + 10 * UI_DPI_FAC;
953  xy_tmp[1] = xy[1] + 1 * UI_DPI_FAC;
954  }
955  wm_drag_draw_item_name(drag, UNPACK2(xy_tmp));
956 
957  /* Operator name with roundbox. */
958  wm_drag_draw_tooltip(C, win, drag, xy);
959 }
960 
961 void WM_drag_draw_default_fn(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
962 {
963  wm_drag_draw_default(C, win, drag, xy);
964 }
965 
967 {
968  int xy[2];
970  wm_cursor_position_get(win, &xy[0], &xy[1]);
971  }
972  else {
973  xy[0] = win->eventstate->xy[0];
974  xy[1] = win->eventstate->xy[1];
975  }
976 
977  bScreen *screen = CTX_wm_screen(C);
978  /* To start with, use the area and region under the mouse cursor, just like event handling. The
979  * operator context may still override it. */
982  /* Will be overridden and unset eventually. */
984 
986 
987  /* Should we support multi-line drag draws? Maybe not, more types mixed won't work well. */
989  LISTBASE_FOREACH (wmDrag *, drag, &wm->drags) {
990  if (drag->drop_state.active_dropbox) {
991  CTX_wm_area_set(C, drag->drop_state.area_from);
992  CTX_wm_region_set(C, drag->drop_state.region_from);
993  CTX_store_set(C, drag->drop_state.ui_context);
994 
995  if (region && drag->drop_state.active_dropbox->draw_in_view) {
996  wmViewport(&region->winrct);
997  drag->drop_state.active_dropbox->draw_in_view(C, win, drag, xy);
998  wmWindowViewport(win);
999  }
1000 
1001  /* Drawing should be allowed to assume the context from handling and polling (that's why we
1002  * restore it above). */
1003  if (drag->drop_state.active_dropbox->draw_droptip) {
1004  drag->drop_state.active_dropbox->draw_droptip(C, win, drag, xy);
1005  continue;
1006  }
1007  }
1008  else if (region) {
1010  CTX_wm_region_set(C, region);
1011  }
1012 
1013  wm_drag_draw_default(C, win, drag, xy);
1014  }
1016  CTX_wm_area_set(C, nullptr);
1017  CTX_wm_region_set(C, nullptr);
1018  CTX_store_set(C, nullptr);
1019 }
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition: glutil.c:44
void immDrawPixelsTexTiled_scaling(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, void *rect, float scaleX, float scaleY, float xzoom, float yzoom, const float color[4])
Definition: glutil.c:300
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
void CTX_store_set(bContext *C, bContextStore *store)
Definition: context.c:188
void CTX_wm_region_set(bContext *C, struct ARegion *region)
Definition: context.c:1009
const struct AssetLibraryReference * CTX_wm_asset_library_ref(const bContext *C)
Definition: context.c:1475
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
bContextStore * CTX_store_copy(bContextStore *store)
Definition: context.c:209
void CTX_store_free(bContextStore *store)
Definition: context.c:217
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
const char * CTX_wm_operator_poll_msg_get(struct bContext *C, bool *r_free)
Definition: context.c:1057
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
Definition: context.c:997
ListBase CTX_data_collection_get(const bContext *C, const char *member)
Definition: context.c:503
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
#define G_MAIN
Definition: BKE_global.h:267
const char * BKE_idtype_idcode_to_name_plural(short idcode)
Definition: idtype.c:149
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL()
struct ScrArea struct ScrArea * BKE_screen_find_area_xy(struct bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:221
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
int BLI_listbase_count_at_most(const struct ListBase *listbase, int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
MINLINE int round_fl_to_int(float a)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
Definition: math_color.c:383
#define FILE_MAX
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned char uchar
Definition: BLI_sys_types.h:70
#define UNPACK2(a)
#define STREQLEN(a, b, n)
#define UNUSED(x)
#define ELEM(...)
external readfile function prototypes.
@ BLO_LIBLINK_APPEND_RECURSIVE
Definition: BLO_readfile.h:339
@ BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR
Definition: BLO_readfile.h:343
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
Definition: BLO_readfile.h:341
ID_Type
Definition: DNA_ID_enums.h:44
#define RGN_TYPE_ANY
#define RGN_TYPE_NUM
eFileAssetImportType
@ FILE_ASSET_IMPORT_APPEND_REUSE
@ FILE_ASSET_IMPORT_APPEND
@ FILE_ASSET_IMPORT_LINK
#define SPACE_TYPE_NUM
eFileSel_Params_Flag
@ FILE_ACTIVE_COLLECTION
@ FILE_AUTOSELECT
#define SPACE_TYPE_ANY
#define FILE_MAX_LIBEXTRA
#define KMAP_MAX_NAME
struct ID * ED_asset_handle_get_local_id(const struct AssetHandle *asset)
ID_Type ED_asset_handle_get_id_type(const struct AssetHandle *asset)
const char * ED_asset_handle_get_name(const struct AssetHandle *asset)
struct AssetMetaData * ED_asset_handle_get_metadata(const struct AssetHandle *asset)
void ED_asset_handle_get_full_library_path(const struct bContext *C, const struct AssetLibraryReference *asset_library_ref, const struct AssetHandle *asset, char r_full_lib_path[])
ARegion * ED_area_find_region_xy_visual(const ScrArea *area, int regiontype, const int event_xy[2])
Definition: area_query.c:178
#define ED_screen_areas_iter(win, screen, area_name)
Definition: ED_screen.h:267
GHOST C-API function and type declarations.
@ GHOST_kGrabWrap
Definition: GHOST_Types.h:410
@ GHOST_kGrabHide
Definition: GHOST_Types.h:415
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
@ GPU_SHADER_2D_IMAGE_COLOR
Definition: GPU_shader.h:217
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
@ GPU_RGBA8
Definition: GPU_texture.h:87
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
#define C
Definition: RandGen.cpp:25
void UI_fontstyle_draw_simple(const struct uiFontStyle *fs, float x, float y, const char *str, const uchar col[4])
#define UI_DPI_ICON_SIZE
Definition: UI_interface.h:307
#define UI_DPI_FAC
Definition: UI_interface.h:305
uiBut * UI_region_active_but_get(const struct ARegion *region)
void UI_fontstyle_draw_simple_backdrop(const struct uiFontStyle *fs, float x, float y, const char *str, const float col_fg[4], const float col_bg[4])
#define UI_FSTYLE_WIDGET
struct bContextStore * UI_but_context_get(const uiBut *but)
Definition: interface.cc:5929
void UI_icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], bool mono_border)
@ TH_REDALERT
Definition: UI_resources.h:34
struct bTheme * UI_GetTheme(void)
Definition: resources.c:1067
void UI_GetThemeColor4fv(int colorid, float col[4])
Definition: resources.c:1173
#define WM_DRAG_PATH
Definition: WM_types.h:1050
eWM_DragFlags
Definition: WM_types.h:1057
@ WM_DRAG_FREE_DATA
Definition: WM_types.h:1059
char *(* WMDropboxTooltipFunc)(struct bContext *, struct wmDrag *, const int xy[2], struct wmDropBox *drop)
Definition: WM_types.h:1113
#define WM_DRAG_NAME
Definition: WM_types.h:1051
#define WM_DRAG_ASSET_LIST
Definition: WM_types.h:1048
#define WM_DRAG_ASSET_CATALOG
Definition: WM_types.h:1055
wmOperatorCallContext
Definition: WM_types.h:199
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
#define WM_DRAG_ASSET
Definition: WM_types.h:1044
#define WM_DRAG_ID
Definition: WM_types.h:1043
unsigned int U
Definition: btGjkEpa3.h:78
Scene scene
uint col
uint padding(uint offset, uint alignment)
#define GS(x)
Definition: iris.c:225
const int state
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
static void area(int d1, int d2, int e1, int e2, float weights[2])
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
ListBase handlers
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
Definition: DNA_ID.h:368
struct AssetMetaData * asset_data
Definition: DNA_ID.h:375
char name[66]
Definition: DNA_ID.h:378
unsigned int * rect
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
uiWidgetColors wcol_tooltip
ThemeUI tui
unsigned char inner[4]
unsigned char text[4]
struct bContextStore * ui_context
Definition: WM_types.h:1134
const char * disabled_info
Definition: WM_types.h:1139
struct ScrArea * area_from
Definition: WM_types.h:1127
struct wmDropBox * active_dropbox
Definition: WM_types.h:1123
struct ARegion * region_from
Definition: WM_types.h:1130
wmDragAsset * external_info
Definition: WM_types.h:1107
union wmDragAssetListItem::@1219 asset_data
struct ID * local_id
Definition: WM_types.h:1106
struct bContext * evil_C
Definition: WM_types.h:1087
const char * path
Definition: WM_types.h:1077
int import_type
Definition: WM_types.h:1080
struct AssetMetaData * metadata
Definition: WM_types.h:1079
char name[64]
Definition: WM_types.h:1075
struct ID * id
Definition: WM_types.h:1067
struct ID * from_parent
Definition: WM_types.h:1068
float imbuf_scale
Definition: WM_types.h:1155
char path[1024]
Definition: WM_types.h:1150
void * poin
Definition: WM_types.h:1149
int icon
Definition: WM_types.h:1146
double value
Definition: WM_types.h:1151
ListBase ids
Definition: WM_types.h:1162
struct ImBuf * imb
Definition: WM_types.h:1154
ListBase asset_items
Definition: WM_types.h:1164
wmDragActiveDropState drop_state
Definition: WM_types.h:1157
int type
Definition: WM_types.h:1148
eWM_DragFlags flags
Definition: WM_types.h:1159
short regionid
Definition: wm_dragdrop.cc:72
struct wmDropBoxMap * next
Definition: wm_dragdrop.cc:69
ListBase dropboxes
Definition: wm_dragdrop.cc:71
struct wmDropBoxMap * prev
Definition: wm_dragdrop.cc:69
char idname[KMAP_MAX_NAME]
Definition: wm_dragdrop.cc:73
WMDropboxTooltipFunc tooltip
Definition: WM_types.h:1226
void(* draw_deactivate)(struct wmDropBox *drop, struct wmDrag *drag)
Definition: WM_types.h:1220
void * draw_data
Definition: WM_types.h:1223
void(* copy)(struct bContext *C, struct wmDrag *drag, struct wmDropBox *drop)
Definition: WM_types.h:1187
wmOperatorType * ot
Definition: WM_types.h:1232
bool(* poll)(struct bContext *C, struct wmDrag *drag, const wmEvent *event)
Definition: WM_types.h:1179
void(* draw_activate)(struct wmDropBox *drop, struct wmDrag *drag)
Definition: WM_types.h:1217
struct IDProperty * properties
Definition: WM_types.h:1235
void(* cancel)(struct Main *bmain, struct wmDrag *drag, struct wmDropBox *drop)
Definition: WM_types.h:1193
struct PointerRNA * ptr
Definition: WM_types.h:1237
short custom
Definition: WM_types.h:712
int xy[2]
Definition: WM_types.h:682
struct wmEvent * eventstate
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:191
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:200
@ WM_CURSOR_DEFAULT
Definition: wm_cursors.h:18
@ WM_CURSOR_STOP
Definition: wm_cursors.h:21
static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *event)
Definition: wm_dragdrop.cc:422
void wm_drop_prepare(bContext *C, wmDrag *drag, wmDropBox *drop)
Definition: wm_dragdrop.cc:458
const ListBase * WM_drag_asset_list_get(const wmDrag *drag)
Definition: wm_dragdrop.cc:748
void wm_drop_end(bContext *C, wmDrag *UNUSED(drag), wmDropBox *UNUSED(drop))
Definition: wm_dragdrop.cc:476
static void wm_drag_free_asset_data(wmDragAsset **asset_data)
Definition: wm_dragdrop.cc:577
wmDragAssetCatalog * WM_drag_get_asset_catalog_data(const wmDrag *drag)
Definition: wm_dragdrop.cc:710
static void wm_drop_redalert_draw(const char *redalert_str, int x, int y)
Definition: wm_dragdrop.cc:774
void wm_dropbox_free(void)
Definition: wm_dragdrop.cc:121
ID * WM_drag_get_local_ID_or_import_from_asset(const wmDrag *drag, int idcode)
Definition: wm_dragdrop.cc:667
static wmDropBox * wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *event)
Definition: wm_dragdrop.cc:404
void WM_event_start_drag(bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
Definition: wm_dragdrop.cc:237
void WM_drag_free_imported_drag_ID(Main *bmain, wmDrag *drag, wmDropBox *drop)
Free asset ID imported for canceled drop.
Definition: wm_dragdrop.cc:686
static void wm_drop_operator_draw(const char *name, int x, int y)
Definition: wm_dragdrop.cc:759
bool WM_drag_asset_will_import_linked(const wmDrag *drag)
Definition: wm_dragdrop.cc:657
static void wm_drag_draw_tooltip(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
Definition: wm_dragdrop.cc:883
static void wm_drag_draw_default(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
Definition: wm_dragdrop.cc:938
AssetMetaData * WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode)
Definition: wm_dragdrop.cc:593
void wm_drags_draw(bContext *C, wmWindow *win)
Definition: wm_dragdrop.cc:966
static void wm_drop_ui_context_free(bContextStore **context_store)
Definition: wm_dragdrop.cc:279
void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale)
Definition: wm_dragdrop.cc:288
void WM_drag_free(wmDrag *drag)
Definition: wm_dragdrop.cc:311
void WM_event_start_prepared_drag(bContext *C, wmDrag *drag)
Definition: wm_dragdrop.cc:229
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
Definition: wm_dragdrop.cc:531
static bContextStore * wm_drop_ui_context_create(const bContext *C)
Definition: wm_dragdrop.cc:264
wmOperatorCallContext wm_drop_operator_context_get(const wmDropBox *UNUSED(drop))
Definition: wm_dragdrop.cc:501
void wm_drags_check_ops(bContext *C, const wmEvent *event)
Definition: wm_dragdrop.cc:481
void WM_drag_draw_default_fn(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
Definition: wm_dragdrop.cc:961
bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
Definition: wm_dragdrop.cc:556
void WM_drag_data_free(int dragtype, void *poin)
Definition: wm_dragdrop.cc:294
wmDrag * WM_drag_data_create(bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
Definition: wm_dragdrop.cc:177
static int wm_drag_imbuf_icon_height_get(const wmDrag *drag)
Definition: wm_dragdrop.cc:818
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
Definition: wm_dragdrop.cc:76
void WM_drag_add_asset_list_item(wmDrag *drag, const bContext *C, const AssetLibraryReference *asset_library_ref, const AssetHandle *asset)
Definition: wm_dragdrop.cc:719
wmDragAsset * WM_drag_create_asset_data(const AssetHandle *asset, AssetMetaData *metadata, const char *path, int import_type)
Definition: wm_dragdrop.cc:561
static void wm_drag_draw_icon(bContext *UNUSED(C), wmWindow *UNUSED(win), wmDrag *drag, const int xy[2])
Definition: wm_dragdrop.cc:823
void wm_drags_exit(wmWindowManager *wm, wmWindow *win)
Definition: wm_dragdrop.cc:244
wmDragAsset * WM_drag_get_asset_data(const wmDrag *drag, int idcode)
Definition: wm_dragdrop.cc:583
static void wm_dropbox_invoke(bContext *C, wmDrag *drag)
Definition: wm_dragdrop.cc:139
void WM_drag_free_list(ListBase *lb)
Definition: wm_dragdrop.cc:333
ID * WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
Definition: wm_dragdrop.cc:546
static wmDropBox * dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, const wmEvent *event)
Definition: wm_dragdrop.cc:355
ID * WM_drag_asset_id_import(wmDragAsset *asset_drag, const int flag_extra)
Definition: wm_dragdrop.cc:608
const char * WM_drag_get_item_name(wmDrag *drag)
Definition: wm_dragdrop.cc:787
static ListBase dropboxes
Definition: wm_dragdrop.cc:60
void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
Definition: wm_dragdrop.cc:508
wmDropBox * WM_dropbox_add(ListBase *lb, const char *idname, bool(*poll)(bContext *, wmDrag *, const wmEvent *), void(*copy)(bContext *, wmDrag *, wmDropBox *), void(*cancel)(Main *, wmDrag *, wmDropBox *), WMDropboxTooltipFunc tooltip)
Definition: wm_dragdrop.cc:95
static void wm_drag_draw_item_name(wmDrag *drag, const int x, const int y)
Definition: wm_dragdrop.cc:865
static int wm_drag_imbuf_icon_width_get(const wmDrag *drag)
Definition: wm_dragdrop.cc:813
static char * dropbox_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *drop)
Definition: wm_dragdrop.cc:341
void WM_drag_draw_item_name_fn(bContext *UNUSED(C), wmWindow *UNUSED(win), wmDrag *drag, const int xy[2])
Definition: wm_dragdrop.cc:872
int xy[2]
Definition: wm_draw.c:135
bool WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context)
void WM_event_add_mousemove(wmWindow *win)
@ WM_HANDLER_TYPE_DROPBOX
@ EVT_DATA_DRAGDROP
ID * WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, PointerRNA *ptr, const ID_Type type)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
const char * WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties)
void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring)
Definition: wm_operators.c:680
void WM_operator_properties_free(PointerRNA *ptr)
Definition: wm_operators.c:783
void wmViewport(const rcti *winrct)
Definition: wm_subwindow.c:21
void wmWindowViewport(wmWindow *win)
Definition: wm_subwindow.c:72
int WM_window_pixels_y(const wmWindow *win)
Definition: wm_window.c:2082
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2300
int WM_window_pixels_x(const wmWindow *win)
Definition: wm_window.c:2076
void wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
Definition: wm_window.c:960