From 1d067868c05cc3b8b8b76f6d21ef4a3eebdc885c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 15 Aug 2018 14:47:48 +0200 Subject: UI: tweak drawing of header status text for transparent headers. --- source/blender/editors/screen/area.c | 50 ++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/screen/area.c') diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 18bacee98b9..034e75a1b87 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -393,6 +393,49 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) GPU_blend(false); } +static void region_draw_status_text(ScrArea *sa, ARegion *ar) +{ + bool overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype); + + if (overlap) { + GPU_clear_color(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + } + else { + UI_ThemeClearColor(TH_HEADER); + glClear(GL_COLOR_BUFFER_BIT); + } + + int fontid = BLF_set_default(); + + const float width = BLF_width(fontid, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); + const float x = UI_UNIT_X; + const float y = 0.4f * UI_UNIT_Y; + + if (overlap) { + const float pad = 2.0f * UI_DPI_FAC; + const float x1 = x - (UI_UNIT_X - pad); + const float x2 = x + width + (UI_UNIT_X - pad); + const float y1 = pad; + const float y2 = ar->winy - pad; + + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + + float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; + UI_GetThemeColor3fv(TH_BACK, color); + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa(true, x1, y1, x2, y2, 4.0f, color); + + UI_FontThemeColor(fontid, TH_TEXT); + } + else { + UI_FontThemeColor(fontid, TH_TEXT); + } + + BLF_position(fontid, x, y, 0.0f); + BLF_draw(fontid, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); +} + /* Follow wmMsgNotifyFn spec */ void ED_region_do_msg_notify_tag_redraw( bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) @@ -480,11 +523,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) } /* optional header info instead? */ else if (ar->headerstr) { - UI_ThemeClearColor(TH_HEADER); - glClear(GL_COLOR_BUFFER_BIT); - - UI_FontThemeColor(BLF_default(), TH_TEXT); - BLF_draw_default(UI_UNIT_X, 0.4f * UI_UNIT_Y, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); + region_draw_status_text(sa, ar); } else if (at->draw) { at->draw(C, ar); @@ -671,6 +710,7 @@ void ED_area_status_text(ScrArea *sa, const char *str) if (ar->headerstr == NULL) ar->headerstr = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint"); BLI_strncpy(ar->headerstr, str, UI_MAX_DRAW_STR); + BLI_str_rstrip(ar->headerstr); } else if (ar->headerstr) { MEM_freeN(ar->headerstr); -- cgit v1.2.3