diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-18 22:13:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-19 07:53:38 +0300 |
commit | 9573bf432c4b06d940b4b38cc455826f47518884 (patch) | |
tree | 6e8d4136abfbbd953423b1b6948ab64f11187eee /source/blender/editors/screen | |
parent | 638938e5a8c30c405c3b4e96ab4f78095003958b (diff) |
UI: move top-bar into the spaces header
Currently this is only in the 3D viewport however all spaces
that use the tool-system will have this region added.
D4680 by @brecht with own updates.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 68 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 22 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 29 |
3 files changed, 90 insertions, 29 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 1aa54bcd8b5..250a4171e8a 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -421,17 +421,18 @@ static void region_draw_status_text(ScrArea *sa, ARegion *ar) 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) +void ED_region_do_msg_notify_tag_redraw( + /* Follow wmMsgNotifyFn spec */ + bContext *UNUSED(C), + wmMsgSubscribeKey *UNUSED(msg_key), + wmMsgSubscribeValue *msg_val) { ARegion *ar = msg_val->owner; ED_region_tag_redraw(ar); /* This avoids _many_ situations where header/properties control display settings. * the common case is space properties in the header */ - if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_UI)) { + if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_UI)) { while (ar && ar->prev) { ar = ar->prev; } @@ -442,15 +443,48 @@ void ED_region_do_msg_notify_tag_redraw(bContext *UNUSED(C), } } } -/* Follow wmMsgNotifyFn spec */ -void ED_area_do_msg_notify_tag_refresh(bContext *UNUSED(C), - wmMsgSubscribeKey *UNUSED(msg_key), - wmMsgSubscribeValue *msg_val) +/** + * Use #ED_region_do_msg_notify_tag_redraw where possible, this draws too much typically. + */ +void ED_area_do_msg_notify_tag_redraw( + /* Follow wmMsgNotifyFn spec */ + bContext *UNUSED(C), + wmMsgSubscribeKey *UNUSED(msg_key), + wmMsgSubscribeValue *msg_val) +{ + ScrArea *sa = msg_val->owner; + ED_area_tag_redraw(sa); +} +void ED_area_do_msg_notify_tag_refresh( + /* Follow wmMsgNotifyFn spec */ + bContext *UNUSED(C), + wmMsgSubscribeKey *UNUSED(msg_key), + wmMsgSubscribeValue *msg_val) { ScrArea *sa = msg_val->user_data; ED_area_tag_refresh(sa); } +void ED_area_do_mgs_subscribe_for_tool_header( + /* Follow ARegionType.message_subscribe */ + const struct bContext *UNUSED(C), + struct WorkSpace *workspace, + struct Scene *UNUSED(scene), + struct bScreen *UNUSED(screen), + struct ScrArea *sa, + struct ARegion *UNUSED(ar), + struct wmMsgBus *mbus) +{ + /* TODO(campbell): investigate why ED_region_do_msg_notify_tag_redraw doesn't work here. */ + wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { + .owner = sa, + .user_data = sa, + .notify = ED_area_do_msg_notify_tag_redraw, + }; + WM_msg_subscribe_rna_prop( + mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw); +} + /** * Although there's no general support for minimizing areas, the status-bar can * be snapped to be only a few pixels high. A few pixels rather than 0 so it @@ -931,7 +965,7 @@ static bool region_azone_edge_poll(const ARegion *ar, const bool is_fullscreen) if (is_hidden && is_fullscreen) { return false; } - if (!is_hidden && ar->regiontype == RGN_TYPE_HEADER) { + if (!is_hidden && ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { return false; } @@ -1011,6 +1045,12 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, c { const bool is_fullscreen = screen->state == SCREENFULL; + /* Only display tab or icons when the header region is hidden + * (not the tool header - they overlap). */ + if (ar->regiontype == RGN_TYPE_TOOL_HEADER) { + return; + } + /* edge code (t b l r) is along which area edge azone will be drawn */ if (alignment == RGN_ALIGN_TOP) region_azone_edge_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); @@ -1183,6 +1223,9 @@ static void region_rect_recursive( else if (ar->regiontype == RGN_TYPE_HEADER) { prefsizey = ED_area_headersize(); } + else if (ar->regiontype == RGN_TYPE_TOOL_HEADER) { + prefsizey = ED_area_headersize(); + } else if (ar->regiontype == RGN_TYPE_FOOTER) { prefsizey = ED_area_footersize(); } @@ -1937,7 +1980,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi /* Spaces with footer. */ if (st->spaceid == SPACE_TEXT) { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_HEADER) { + if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { ar->alignment = header_alignment; } if (ar->regiontype == RGN_TYPE_FOOTER) { @@ -1950,7 +1993,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi } else { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_HEADER) { + if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { ar->alignment = header_alignment; break; } @@ -2035,6 +2078,7 @@ static ThemeColorID region_background_color_id(const bContext *C, const ARegion switch (region->regiontype) { case RGN_TYPE_HEADER: + case RGN_TYPE_TOOL_HEADER: if (ED_screen_area_active(C) || ED_area_is_global(area)) { return TH_HEADER; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 8caa960bb9a..259076f194f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -428,6 +428,10 @@ static void screen_refresh_headersizes(void) if (art) art->prefsizey = ED_area_headersize(); + art = BKE_regiontype_from_id(st, RGN_TYPE_TOOL_HEADER); + if (art) + art->prefsizey = ED_area_headersize(); + art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER); if (art) art->prefsizey = ED_area_headersize(); @@ -679,7 +683,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) if (do_draw) { for (ar = area_iter->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_HEADER) { + if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { ED_region_tag_redraw_no_rebuild(ar); } } @@ -813,16 +817,14 @@ static int screen_global_header_size(void) static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen) { - const short size_min = screen_global_header_size(); - const short size_max = 2.25 * screen_global_header_size(); - const short size = (screen->flag & SCREEN_COLLAPSE_TOPBAR) ? size_min : size_max; + const short size = screen_global_header_size(); rcti rect; BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1); - rect.ymin = rect.ymax - size_max; + rect.ymin = rect.ymax - size; screen_global_area_refresh( - win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size_min, size_max); + win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size, size); } static void screen_global_statusbar_area_refresh(wmWindow *win, bScreen *screen) @@ -845,14 +847,11 @@ void ED_screen_global_areas_sync(wmWindow *win) * global areas should just become part of the screen instead. */ bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - screen->flag &= ~(SCREEN_COLLAPSE_STATUSBAR | SCREEN_COLLAPSE_TOPBAR); + screen->flag &= ~SCREEN_COLLAPSE_STATUSBAR; for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { if (area->global->cur_fixed_height == area->global->size_min) { - if (area->spacetype == SPACE_TOPBAR) { - screen->flag |= SCREEN_COLLAPSE_TOPBAR; - } - else if (area->spacetype == SPACE_STATUSBAR) { + if (area->spacetype == SPACE_STATUSBAR) { screen->flag |= SCREEN_COLLAPSE_STATUSBAR; } } @@ -1278,6 +1277,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, + RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER, RGN_TYPE_TOOLS, RGN_TYPE_NAV_BAR, diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 07f60552ce4..4e39f56ddee 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1324,7 +1324,7 @@ static void area_move_set_limits( int size_max = ED_area_global_max_size_y(area) - 1; size_min = max_ii(size_min, 0); - BLI_assert(size_min < size_max); + BLI_assert(size_min <= size_max); /* logic here is only tested for lower edge :) */ /* left edge */ @@ -2338,12 +2338,12 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) } else if (scalear->alignment == RGN_ALIGN_TOP && (ar->alignment == RGN_ALIGN_BOTTOM || - ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER))) { + ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) { dist -= ar->winy; } else if (scalear->alignment == RGN_ALIGN_BOTTOM && (ar->alignment == RGN_ALIGN_TOP || - ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER))) { + ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) { dist -= ar->winy; } } @@ -2430,6 +2430,18 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) region_toggle_hidden(C, rmd->ar, 0); region_scale_validate_size(rmd); + + if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) { + if (rmd->ar->regiontype == RGN_TYPE_HEADER) { + ARegion *ar_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER); + if (ar_tool_header != NULL) { + if ((ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 && + (ar_tool_header->flag & RGN_FLAG_HIDDEN) != 0) { + region_toggle_hidden(C, ar_tool_header, 0); + } + } + } + } } static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -3794,11 +3806,16 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN ARegion *ar = CTX_wm_region(C); const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top"); - - if (!ELEM(sa->spacetype, SPACE_TOPBAR)) { + { PointerRNA ptr; RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr); uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE); + if (BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER)) { + ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + uiLayoutSetActive(layout, (ar_header->flag & RGN_FLAG_HIDDEN) == 0); + uiItemR(layout, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE); + uiLayoutSetActive(layout, true); + } } /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ @@ -4058,7 +4075,7 @@ static int match_region_with_redraws(int spacetype, if (redraws & TIME_ALL_BUTS_WIN) return 1; } - else if (regiontype == RGN_TYPE_HEADER) { + else if (ELEM(regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { if (spacetype == SPACE_ACTION) return 1; } |