diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_dragdrop.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index e5bba9285b4..cdc3c9eaaff 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -45,10 +45,8 @@ #include "BIF_glutil.h" #include "BKE_context.h" -#include "BKE_screen.h" #include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -58,8 +56,6 @@ #include "WM_api.h" #include "WM_types.h" #include "wm_event_system.h" -#include "wm.h" - /* ****************************************************** */ @@ -85,7 +81,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) for (dm = dropboxes.first; dm; dm = dm->next) if (dm->spaceid == spaceid && dm->regionid == regionid) - if (0 == strncmp(idname, dm->idname, KMAP_MAX_NAME)) + if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME)) return &dm->dropboxes; dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); @@ -271,16 +267,11 @@ void wm_drags_check_ops(bContext *C, wmEvent *event) static void wm_drop_operator_draw(const char *name, int x, int y) { - int width = UI_GetStringWidth(name); - int padding = 4 * UI_DPI_FAC; - - glColor4ub(0, 0, 0, 50); - - uiSetRoundBox(UI_CNR_ALL | UI_RB_ALPHA); - uiRoundBox(x, y, x + width + 2 * padding, y + 4 * padding, padding); - - glColor4ub(255, 255, 255, 255); - UI_DrawString(x + padding, y + padding, name); + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + const unsigned char fg[4] = {255, 255, 255, 255}; + const unsigned char bg[4] = {0, 0, 0, 50}; + + UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, fg, bg); } static const char *wm_drag_name(wmDrag *drag) @@ -288,13 +279,12 @@ static const char *wm_drag_name(wmDrag *drag) switch (drag->type) { case WM_DRAG_ID: { - ID *id = (ID *)drag->poin; + ID *id = drag->poin; return id->name + 2; } case WM_DRAG_PATH: - return drag->path; case WM_DRAG_NAME: - return (char *)drag->path; + return drag->path; } return ""; } @@ -315,6 +305,7 @@ static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2) /* if rect set, do not draw */ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) { + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; wmWindowManager *wm = CTX_wm_manager(C); wmDrag *drag; const int winsize_y = WM_window_pixels_y(win); @@ -330,7 +321,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ glEnable(GL_BLEND); for (drag = wm->drags.first; drag; drag = drag->next) { - int iconsize = 16 * UI_DPI_FAC; /* assumed to be 16 pixels */ + int iconsize = UI_DPI_ICON_SIZE; int padding = 4 * UI_DPI_FAC; /* image or icon */ @@ -366,12 +357,12 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) } if (rect) { - int w = UI_GetStringWidth(wm_drag_name(drag)); + int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x + w, y + iconsize); } else { glColor4ub(255, 255, 255, 255); - UI_DrawString(x, y, wm_drag_name(drag)); + UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag)); } /* operator name with roundbox */ @@ -387,14 +378,16 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) else { x = cursorx - 2 * padding; - if (cursory + iconsize + iconsize < winsize_y) - y = cursory + iconsize; - else - y = cursory - iconsize - 2 * UI_DPI_FAC; + if (cursory + iconsize + iconsize < winsize_y) { + y = (cursory + iconsize) + padding; + } + else { + y = (cursory - iconsize) - padding; + } } if (rect) { - int w = UI_GetStringWidth(wm_drag_name(drag)); + int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x + w, y + iconsize); } else |