diff options
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper.c | 15 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 49 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 26 |
5 files changed, 73 insertions, 27 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index da857c27435..128febdc5f9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -981,8 +981,13 @@ void UI_fontstyle_draw_ex( void UI_fontstyle_draw(const struct uiFontStyle *fs, const struct rcti *rect, const char *str); void UI_fontstyle_draw_rotated(const struct uiFontStyle *fs, const struct rcti *rect, const char *str); void UI_fontstyle_draw_simple(const struct uiFontStyle *fs, float x, float y, const char *str); +void UI_fontstyle_draw_simple_backdrop( + const uiFontStyle *fs, float x, float y, const char *str, + const unsigned char fg[4], const unsigned char bg[4]); int UI_fontstyle_string_width(const struct uiFontStyle *fs, const char *str); +int UI_fontstyle_height_max(const struct uiFontStyle *fs); + void UI_draw_icon_tri(float x, float y, char dir); uiStyle *UI_style_get(void); /* use for fonts etc */ diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index dfcafd7e46e..ec1234a82be 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -77,7 +77,9 @@ static void eyedropper_draw_cursor_text(const struct bContext *C, ARegion *ar, c wmWindow *win = CTX_wm_window(C); int x = win->eventstate->x; int y = win->eventstate->y; - int width; + const unsigned char fg[4] = {255, 255, 255, 255}; + const unsigned char bg[4] = {0, 0, 0, 50}; + if ((name[0] == '\0') || (BLI_rcti_isect_pt(&ar->winrct, x, y) == false)) @@ -85,19 +87,12 @@ static void eyedropper_draw_cursor_text(const struct bContext *C, ARegion *ar, c return; } - width = UI_fontstyle_string_width(fstyle, name); x = x - ar->winrct.xmin; y = y - ar->winrct.ymin; - y += 20; - - glColor4ub(0, 0, 0, 50); - - UI_draw_roundbox_corner_set(UI_CNR_ALL | UI_RB_ALPHA); - UI_draw_roundbox(x, y, x + width + 8, y + 15, 4); + y += U.widget_unit; - glColor4ub(255, 255, 255, 255); - UI_fontstyle_draw_simple(fstyle, x + 4, y + 4, name); + UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, fg, bg); } /** \} */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 2fe44b2a9b6..c42c911cd5c 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -45,6 +45,7 @@ #include "BKE_global.h" +#include "BIF_gl.h" #include "BLF_api.h" #ifdef WITH_INTERNATIONAL @@ -277,6 +278,47 @@ void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const cha BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); } +/** + * Same as #UI_fontstyle_draw but draw a colored backdrop. + */ +void UI_fontstyle_draw_simple_backdrop( + const uiFontStyle *fs, float x, float y, const char *str, + const unsigned char fg[4], const unsigned char bg[4]) +{ + if (fs->kerning == 1) + BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); + + UI_fontstyle_set(fs); + + { + const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); + const float height = BLF_height_max(fs->uifont_id); + const float decent = BLF_descender(fs->uifont_id); + const float margin = height / 4.0f; + + /* backdrop */ + glColor4ubv(bg); + + UI_draw_roundbox_corner_set(UI_CNR_ALL | UI_RB_ALPHA); + UI_draw_roundbox( + x - margin, + (y + decent) - margin, + x + width + margin, + (y + decent) + height + margin, + margin); + + glColor4ubv(fg); + } + + + BLF_position(fs->uifont_id, x, y, 0.0f); + BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); + + if (fs->kerning == 1) + BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); +} + + /* ************** helpers ************************ */ /* XXX: read a style configure */ uiStyle *UI_style_get(void) @@ -329,6 +371,13 @@ int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str) return width; } +int UI_fontstyle_height_max(const uiFontStyle *fs) +{ + UI_fontstyle_set(fs); + return BLF_height_max(fs->uifont_id); +} + + /* ************** init exit ************************ */ /* called on each startup.blend read */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 24050697585..31d91f50789 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1281,8 +1281,9 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* camera name - draw in highlighted text color */ if (ca && (ca->flag & CAM_SHOWNAME)) { UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(x1i, y1i - 15, 0.0f, v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2); - UI_ThemeColor(TH_WIRE); + BLF_draw_default( + x1i, y1i - (0.7f * U.widget_unit), 0.0f, + v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2); } } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 0056474edf9..9859a7ded87 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -268,16 +268,10 @@ void wm_drags_check_ops(bContext *C, wmEvent *event) static void wm_drop_operator_draw(const char *name, int x, int y) { const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; - int width = UI_fontstyle_string_width(fstyle, name); - int padding = 4 * UI_DPI_FAC; - - glColor4ub(0, 0, 0, 50); - - UI_draw_roundbox_corner_set(UI_CNR_ALL | UI_RB_ALPHA); - UI_draw_roundbox(x, y, x + width + 2 * padding, y + 4 * padding, padding); - - glColor4ub(255, 255, 255, 255); - UI_fontstyle_draw_simple(fstyle, x + padding, y + padding, name); + 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) @@ -327,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 */ @@ -384,10 +378,12 @@ 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) { |