diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-28 13:06:00 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-28 14:04:28 +0300 |
commit | 89e0d9848a0660c81e57f1e5e9778a2b920bd54a (patch) | |
tree | 9c72026a731d04c3663683e52f06f943e78a1a32 /source/blender/editors/screen | |
parent | af9fcb6a333b575e7f1c2ab1e3d8fbcf1a69b7e1 (diff) |
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.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 34 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 8 |
2 files changed, 40 insertions, 2 deletions
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); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index cdd0225e1b7..c067e5a452d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -876,6 +876,11 @@ void ED_region_exit(bContext *C, ARegion *ar) WM_event_modal_handler_region_replace(win, ar, NULL); WM_draw_region_free(ar); + if (ar->headerstr) { + MEM_freeN(ar->headerstr); + ar->headerstr = NULL; + } + if (ar->regiontimer) { WM_event_remove_timer(wm, win, ar->regiontimer); ar->regiontimer = NULL; @@ -1413,7 +1418,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s } } - /* prevent hanging header prints */ + /* prevent hanging status prints */ + ED_area_status_text(sa, NULL); ED_workspace_status_text(C, NULL); } |