Blender  V2.93
Classes | Typedefs | Functions | Variables
wm_dragdrop.c File Reference
#include <string.h>
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
#include "BLT_translation.h"
#include "BLI_blenlib.h"
#include "BIF_glutil.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "GPU_shader.h"
#include "GPU_state.h"
#include "GPU_viewport.h"
#include "IMB_imbuf_types.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm_event_system.h"

Go to the source code of this file.

Classes

struct  wmDropBoxMap
 

Typedefs

typedef struct wmDropBoxMap wmDropBoxMap
 

Functions

ListBaseWM_dropboxmap_find (const char *idname, int spaceid, int regionid)
 
wmDropBoxWM_dropbox_add (ListBase *lb, const char *idname, bool(*poll)(bContext *, wmDrag *, const wmEvent *, const char **), void(*copy)(wmDrag *, wmDropBox *), void(*cancel)(struct Main *, wmDrag *, wmDropBox *))
 
void wm_dropbox_free (void)
 
wmDragWM_event_start_drag (struct bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
 
void WM_event_drag_image (wmDrag *drag, ImBuf *imb, float scale, int sx, int sy)
 
void WM_drag_data_free (int dragtype, void *poin)
 
void WM_drag_free (wmDrag *drag)
 
void WM_drag_free_list (struct ListBase *lb)
 
static const char * dropbox_active (bContext *C, ListBase *handlers, wmDrag *drag, const wmEvent *event)
 
static const char * wm_dropbox_active (bContext *C, wmDrag *drag, const wmEvent *event)
 
static void wm_drop_operator_options (bContext *C, wmDrag *drag, const wmEvent *event)
 
void wm_drags_check_ops (bContext *C, const wmEvent *event)
 
void WM_drag_add_local_ID (wmDrag *drag, ID *id, ID *from_parent)
 
IDWM_drag_get_local_ID (const wmDrag *drag, short idcode)
 
IDWM_drag_get_local_ID_from_event (const wmEvent *event, short idcode)
 
bool WM_drag_is_ID_type (const wmDrag *drag, int idcode)
 
wmDragAssetWM_drag_get_asset_data (const wmDrag *drag, int idcode)
 
static IDwm_drag_asset_id_import (wmDragAsset *asset_drag)
 
IDWM_drag_get_local_ID_or_import_from_asset (const wmDrag *drag, int idcode)
 
void WM_drag_free_imported_drag_ID (struct Main *bmain, wmDrag *drag, wmDropBox *drop)
 Free asset ID imported for cancelled drop. More...
 
static void wm_drop_operator_draw (const char *name, int x, int y)
 
static const char * wm_drag_name (wmDrag *drag)
 
static void drag_rect_minmax (rcti *rect, int x1, int y1, int x2, int y2)
 
void wm_drags_draw (bContext *C, wmWindow *win, rcti *rect)
 

Variables

static ListBase dropboxes = {NULL, NULL}
 

Detailed Description

Our own drag-and-drop, drag state and drop boxes.

Definition in file wm_dragdrop.c.

Typedef Documentation

◆ wmDropBoxMap

typedef struct wmDropBoxMap wmDropBoxMap

Function Documentation

◆ drag_rect_minmax()

static void drag_rect_minmax ( rcti rect,
int  x1,
int  y1,
int  x2,
int  y2 
)
static

Definition at line 481 of file wm_dragdrop.c.

References x2, rcti::xmax, rcti::xmin, y1, rcti::ymax, and rcti::ymin.

Referenced by wm_drags_draw().

◆ dropbox_active()

static const char* dropbox_active ( bContext C,
ListBase handlers,
wmDrag drag,
const wmEvent event 
)
static

◆ WM_drag_add_local_ID()

void WM_drag_add_local_ID ( wmDrag drag,
ID id,
ID from_parent 
)

◆ wm_drag_asset_id_import()

static ID* wm_drag_asset_id_import ( wmDragAsset asset_drag)
static

◆ WM_drag_data_free()

void WM_drag_data_free ( int  dragtype,
void *  poin 
)

◆ WM_drag_free()

void WM_drag_free ( wmDrag drag)

◆ WM_drag_free_imported_drag_ID()

void WM_drag_free_imported_drag_ID ( struct Main bmain,
wmDrag drag,
wmDropBox drop 
)

Free asset ID imported for cancelled drop.

If the asset was imported (linked/appended) using WM_drag_get_local_ID_or_import_from_asset()` (typically via a wmDropBox.copy() callback), we want the ID to be removed again if the drop operator cancels. This is for use as wmDropBox.cancel() callback.

Definition at line 419 of file wm_dragdrop.c.

References BKE_id_delete(), BKE_libblock_find_name(), wmDragAsset::id_type, MAX_ID_NAME, wmDropBox::ptr, RNA_string_get(), wmDrag::type, WM_DRAG_ASSET, and WM_drag_get_asset_data().

Referenced by node_dropboxes(), and view3d_dropboxes().

◆ WM_drag_free_list()

void WM_drag_free_list ( struct ListBase lb)

◆ WM_drag_get_asset_data()

wmDragAsset* WM_drag_get_asset_data ( const wmDrag drag,
int  idcode 
)

◆ WM_drag_get_local_ID()

ID* WM_drag_get_local_ID ( const wmDrag drag,
short  idcode 
)

◆ WM_drag_get_local_ID_from_event()

ID* WM_drag_get_local_ID_from_event ( const wmEvent event,
short  idcode 
)

◆ WM_drag_get_local_ID_or_import_from_asset()

ID* WM_drag_get_local_ID_or_import_from_asset ( const wmDrag drag,
int  idcode 
)

When dragging a local ID, return that. Otherwise, if dragging an asset-handle, link or append that depending on what was chosen by the drag-box (currently append only in fact).

Use WM_drag_free_imported_drag_ID() as cancel callback of the drop-box, so that the asset import is rolled back if the drop operator fails.

Definition at line 392 of file wm_dragdrop.c.

References ELEM, NULL, wmDrag::type, WM_DRAG_ASSET, wm_drag_asset_id_import(), WM_drag_get_asset_data(), WM_drag_get_local_ID(), and WM_DRAG_ID.

Referenced by node_group_drop_copy(), node_id_drop_copy(), node_id_path_drop_copy(), view3d_collection_drop_copy(), view3d_id_drop_copy(), view3d_id_drop_copy_with_type(), view3d_id_path_drop_copy(), and view3d_ob_drop_copy().

◆ WM_drag_is_ID_type()

bool WM_drag_is_ID_type ( const wmDrag drag,
int  idcode 
)

◆ wm_drag_name()

static const char* wm_drag_name ( wmDrag drag)
static

◆ wm_drags_check_ops()

void wm_drags_check_ops ( bContext C,
const wmEvent event 
)

◆ wm_drags_draw()

void wm_drags_draw ( bContext C,
wmWindow win,
rcti rect 
)

◆ wm_drop_operator_draw()

static void wm_drop_operator_draw ( const char *  name,
int  x,
int  y 
)
static

Definition at line 446 of file wm_dragdrop.c.

References UI_fontstyle_draw_simple_backdrop(), UI_FSTYLE_WIDGET, x, and y.

Referenced by wm_drags_draw().

◆ wm_drop_operator_options()

static void wm_drop_operator_options ( bContext C,
wmDrag drag,
const wmEvent event 
)
static

◆ wm_dropbox_active()

static const char* wm_dropbox_active ( bContext C,
wmDrag drag,
const wmEvent event 
)
static

◆ WM_dropbox_add()

wmDropBox* WM_dropbox_add ( ListBase lb,
const char *  idname,
bool(*)(bContext *, wmDrag *, const wmEvent *, const char **)  poll,
void(*)(wmDrag *, wmDropBox *)  copy,
void(*)(struct Main *, wmDrag *, wmDropBox *)  cancel 
)

◆ wm_dropbox_free()

void wm_dropbox_free ( void  )

Definition at line 121 of file wm_dragdrop.c.

References BLI_freelistN(), dropboxes, LISTBASE_FOREACH, MEM_freeN, and WM_operator_properties_free().

Referenced by WM_exit_ex().

◆ WM_dropboxmap_find()

ListBase* WM_dropboxmap_find ( const char *  idname,
int  spaceid,
int  regionid 
)

◆ WM_event_drag_image()

void WM_event_drag_image ( wmDrag drag,
ImBuf imb,
float  scale,
int  sx,
int  sy 
)

Definition at line 180 of file wm_dragdrop.c.

References wmDrag::imb, wmDrag::scale, wmDrag::sx, and wmDrag::sy.

Referenced by ui_but_drag_init().

◆ WM_event_start_drag()

wmDrag* WM_event_start_drag ( struct bContext C,
int  icon,
int  type,
void *  poin,
double  value,
unsigned int  flags 
)

Variable Documentation

◆ dropboxes

ListBase dropboxes = {NULL, NULL}
static

Definition at line 61 of file wm_dragdrop.c.

Referenced by wm_dropbox_free(), WM_dropboxmap_find(), and WM_event_add_dropbox_handler().