From f40cd831fd3581e98e2f9481cf64a8a7ff6d53ef Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 27 Aug 2024 21:18:10 +0200 Subject: [PATCH] UI: Hide Timeline Scrollbars When Very Short If the Timeline is sized too short to show any of the scrubbing area, then the scrollbars obscure the time line and current frame marker. This PR hides the scrollbars in this case. Also for similar cases with Dope Sheet, Graph Editor, and the embedded Graph Editor/DopeSheet in Movie Clip Editor. Pull Request: https://projects.blender.org/blender/blender/pulls/126806 --- .../editors/space_action/space_action.cc | 4 +++- .../blender/editors/space_clip/space_clip.cc | 10 ++++++--- .../editors/space_graph/space_graph.cc | 22 ++++++++++--------- .../sequencer_timeline_draw.cc | 10 +++++---- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index 3a3888a5da6..dadaa4a2508 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -248,7 +248,9 @@ static void action_main_region_draw_overlay(const bContext *C, ARegion *region) ED_time_scrub_draw_current_frame(region, scene, saction->flag & SACTION_DRAWTIME); /* scrollers */ - UI_view2d_scrollers_draw(v2d, nullptr); + if (region->winy > HEADERY * UI_SCALE_FAC) { + UI_view2d_scrollers_draw(v2d, nullptr); + } } /* add handlers, stuff you only do once or on area/region changes */ diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index a7f8a9bf0e5..350850ead4f 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -873,8 +873,10 @@ static void graph_region_draw(const bContext *C, ARegion *region) ED_time_scrub_draw_current_frame(region, scene, sc->flag & SC_SHOW_SECONDS); /* scrollers */ - const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); - UI_view2d_scrollers_draw(v2d, &scroller_mask); + if (region->winy > HEADERY * UI_SCALE_FAC) { + const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); + UI_view2d_scrollers_draw(v2d, &scroller_mask); + } /* scale indicators */ { @@ -924,7 +926,9 @@ static void dopesheet_region_draw(const bContext *C, ARegion *region) ED_time_scrub_draw_current_frame(region, scene, sc->flag & SC_SHOW_SECONDS); /* scrollers */ - UI_view2d_scrollers_draw(v2d, nullptr); + if (region->winy > HEADERY * UI_SCALE_FAC) { + UI_view2d_scrollers_draw(v2d, nullptr); + } } static void clip_preview_region_draw(const bContext *C, ARegion *region) diff --git a/source/blender/editors/space_graph/space_graph.cc b/source/blender/editors/space_graph/space_graph.cc index 0b3369f484c..c4b2362f07e 100644 --- a/source/blender/editors/space_graph/space_graph.cc +++ b/source/blender/editors/space_graph/space_graph.cc @@ -333,17 +333,19 @@ static void graph_main_region_draw_overlay(const bContext *C, ARegion *region) ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME); } - /* scrollers */ - const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); - /* FIXME: args for scrollers depend on the type of data being shown. */ - UI_view2d_scrollers_draw(v2d, &scroller_mask); + if (region->winy > HEADERY * UI_SCALE_FAC) { + /* scrollers */ + const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); + /* FIXME: args for scrollers depend on the type of data being shown. */ + UI_view2d_scrollers_draw(v2d, &scroller_mask); - /* scale numbers */ - { - rcti rect; - BLI_rcti_init( - &rect, 0, 15 * UI_SCALE_FAC, 15 * UI_SCALE_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); - UI_view2d_draw_scale_y__values(region, v2d, &rect, TH_SCROLL_TEXT); + /* scale numbers */ + { + rcti rect; + BLI_rcti_init( + &rect, 0, 15 * UI_SCALE_FAC, 15 * UI_SCALE_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y); + UI_view2d_draw_scale_y__values(region, v2d, &rect, TH_SCROLL_TEXT); + } } } diff --git a/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc b/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc index 1eb9afebb97..1bc28bc1b2b 100644 --- a/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc @@ -1964,8 +1964,10 @@ void draw_timeline_seq_display(const bContext *C, ARegion *region) ED_time_scrub_draw_current_frame(region, scene, !(sseq->flag & SEQ_DRAWFRAMES)); - const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); - SEQ_timeline_boundbox(scene, seqbase, &v2d->tot); - const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); - UI_view2d_scrollers_draw(v2d, &scroller_mask); + if (region->winy > HEADERY * UI_SCALE_FAC) { + const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); + SEQ_timeline_boundbox(scene, seqbase, &v2d->tot); + const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask); + UI_view2d_scrollers_draw(v2d, &scroller_mask); + } }