Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/include/UI_interface.h5
-rw-r--r--source/blender/editors/interface/interface.c38
-rw-r--r--source/blender/editors/interface/interface_intern.h6
-rw-r--r--source/blender/editors/space_file/file_draw.c4
4 files changed, 47 insertions, 6 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 330484bf72b..027a8f4619a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -467,10 +467,11 @@ int UI_but_return_value_get(uiBut *but);
void UI_but_drag_set_id(uiBut *but, struct ID *id);
void UI_but_drag_set_rna(uiBut *but, struct PointerRNA *ptr);
-void UI_but_drag_set_path(uiBut *but, const char *path);
+void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free);
void UI_but_drag_set_name(uiBut *but, const char *name);
void UI_but_drag_set_value(uiBut *but);
-void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
+void UI_but_drag_set_image(
+ uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free);
bool UI_but_active_drop_name(struct bContext *C);
bool UI_but_active_drop_color(struct bContext *C);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index d11c1957d33..19b780322ac 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -753,6 +753,10 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu
BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata));
}
+ if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ SWAP(void *, but->dragpoin, oldbut->dragpoin);
+ }
+
BLI_remlink(&block->buttons, but);
ui_but_free(C, but);
@@ -2520,6 +2524,10 @@ static void ui_but_free(const bContext *C, uiBut *but)
IMB_freeImBuf((struct ImBuf *)but->poin);
}
+ if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_freeN(but->dragpoin);
+ }
+
BLI_assert(UI_butstore_is_registered(but->block, but) == false);
MEM_freeN(but);
@@ -4046,24 +4054,43 @@ int UI_but_return_value_get(uiBut *but)
void UI_but_drag_set_id(uiBut *but, ID *id)
{
but->dragtype = WM_DRAG_ID;
+ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_SAFE_FREE(but->dragpoin);
+ but->dragflag &= ~UI_BUT_DRAGPOIN_FREE;
+ }
but->dragpoin = (void *)id;
}
void UI_but_drag_set_rna(uiBut *but, PointerRNA *ptr)
{
but->dragtype = WM_DRAG_RNA;
+ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_SAFE_FREE(but->dragpoin);
+ but->dragflag &= ~UI_BUT_DRAGPOIN_FREE;
+ }
but->dragpoin = (void *)ptr;
}
-void UI_but_drag_set_path(uiBut *but, const char *path)
+void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free)
{
but->dragtype = WM_DRAG_PATH;
+ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_SAFE_FREE(but->dragpoin);
+ but->dragflag &= ~UI_BUT_DRAGPOIN_FREE;
+ }
but->dragpoin = (void *)path;
+ if (use_free) {
+ but->dragflag |= UI_BUT_DRAGPOIN_FREE;
+ }
}
void UI_but_drag_set_name(uiBut *but, const char *name)
{
but->dragtype = WM_DRAG_NAME;
+ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_SAFE_FREE(but->dragpoin);
+ but->dragflag &= ~UI_BUT_DRAGPOIN_FREE;
+ }
but->dragpoin = (void *)name;
}
@@ -4073,11 +4100,18 @@ void UI_but_drag_set_value(uiBut *but)
but->dragtype = WM_DRAG_VALUE;
}
-void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale)
+void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale, const bool use_free)
{
but->dragtype = WM_DRAG_PATH;
ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesnt draw in button */
+ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ MEM_SAFE_FREE(but->dragpoin);
+ but->dragflag &= ~UI_BUT_DRAGPOIN_FREE;
+ }
but->dragpoin = (void *)path;
+ if (use_free) {
+ but->dragflag |= UI_BUT_DRAGPOIN_FREE;
+ }
but->imb = imb;
but->imb_scale = scale;
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index fc477d89ff4..df554a2fdfd 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -129,6 +129,11 @@ typedef enum uiButExtraIconType {
UI_BUT_ICONEXTRA_EYEDROPPER,
} uiButExtraIconType;
+/* uiBut->dragflag */
+enum {
+ UI_BUT_DRAGPOIN_FREE = (1 << 0),
+};
+
/* but->pie_dir */
typedef enum RadialDirection {
UI_RADIAL_NONE = -1,
@@ -297,6 +302,7 @@ struct uiBut {
/* Draggable data, type is WM_DRAG_... */
char dragtype;
+ short dragflag;
void *dragpoin;
struct ImBuf *imb;
float imb_scale;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 78638334338..7f96321f542 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -296,7 +296,7 @@ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int
but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "");
if (drag) {
- UI_but_drag_set_path(but, path);
+ UI_but_drag_set_path(but, path, false);
}
}
@@ -411,7 +411,7 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int
/* dragregion */
if (drag) {
but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, "");
- UI_but_drag_set_image(but, file->path, get_file_icon(file), imb, scale);
+ UI_but_drag_set_image(but, file->path, get_file_icon(file), imb, scale, false);
}
glDisable(GL_BLEND);