From 89e0d9848a0660c81e57f1e5e9778a2b920bd54a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 28 Jun 2018 12:06:00 +0200 Subject: UI: keep some operator text in headers. Key shortcuts and explanation about how to use the tool should go to the status bar, but other info can in the header so it's near where the user is working. This distinction has not been made yet for all operators. --- source/blender/editors/screen/area.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (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 9bf15a292ea..a9b163ab58a 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -462,7 +462,15 @@ void ED_region_do_draw(bContext *C, ARegion *ar) UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); - if (at->draw) { + /* optional header info instead? */ + 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); + } + else if (at->draw) { at->draw(C, ar); } @@ -633,6 +641,30 @@ void ED_area_tag_refresh(ScrArea *sa) /* *************************************************************** */ /* use NULL to disable it */ +void ED_area_status_text(ScrArea *sa, const char *str) +{ + ARegion *ar; + + /* happens when running transform operators in backround mode */ + if (sa == NULL) + return; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_HEADER) { + if (str) { + if (ar->headerstr == NULL) + ar->headerstr = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint"); + BLI_strncpy(ar->headerstr, str, UI_MAX_DRAW_STR); + } + else if (ar->headerstr) { + MEM_freeN(ar->headerstr); + ar->headerstr = NULL; + } + ED_region_tag_redraw(ar); + } + } +} + void ED_workspace_status_text(bContext *C, const char *str) { wmWindow *win = CTX_wm_window(C); -- cgit v1.2.3