[Bf-blender-cvs] [194eb45c43d] temp-vse-channels-edge-panning: Merge remaining changes from D14263

Richard Antalik noreply at git.blender.org
Wed Mar 9 18:10:51 CET 2022


Commit: 194eb45c43d02b5c966f5d42c02a3afc828f6414
Author: Richard Antalik
Date:   Tue Mar 8 19:45:31 2022 +0100
Branches: temp-vse-channels-edge-panning
https://developer.blender.org/rB194eb45c43d02b5c966f5d42c02a3afc828f6414

Merge remaining changes from D14263

===================================================================

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/animation/time_scrub_ui.c
M	source/blender/editors/include/ED_time_scrub_ui.h
M	source/blender/editors/space_sequencer/sequencer_view.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/transform/transform_convert_sequencer.c
M	source/blender/sequencer/intern/strip_time.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index a8a851bb228..1639a564508 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 5
+#define BLENDER_FILE_SUBVERSION 6
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 5269f58fb94..b3c088e1378 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -52,6 +52,7 @@
 #include "BKE_main.h"
 #include "BKE_modifier.h"
 #include "BKE_node.h"
+#include "BKE_screen.h"
 
 #include "RNA_access.h"
 #include "RNA_enum_types.h"
@@ -2567,7 +2568,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
-  if (!MAIN_VERSION_ATLEAST(bmain, 302, 5)) {
+  if (!MAIN_VERSION_ATLEAST(bmain, 302, 6)) {
     /* Sequencer channels region. */
     for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
       LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 3a780b32398..5e6950acf21 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -31,7 +31,7 @@
 
 #include "RNA_access.h"
 
-static void get_time_scrub_region_rect(const ARegion *region, rcti *rect)
+void ED_time_scrub_region_rect_get(const ARegion *region, rcti *rect)
 {
   rect->xmin = 0;
   rect->xmax = region->winx;
@@ -153,7 +153,7 @@ void ED_time_scrub_draw_current_frame(const ARegion *region,
   wmOrtho2_region_pixelspace(region);
 
   rcti scrub_region_rect;
-  get_time_scrub_region_rect(region, &scrub_region_rect);
+  ED_time_scrub_region_rect_get(region, &scrub_region_rect);
 
   draw_current_frame(scene, display_seconds, v2d, &scrub_region_rect, scene->r.cfra);
   GPU_matrix_pop_projection();
@@ -170,7 +170,7 @@ void ED_time_scrub_draw(const ARegion *region,
   wmOrtho2_region_pixelspace(region);
 
   rcti scrub_region_rect;
-  get_time_scrub_region_rect(region, &scrub_region_rect);
+  ED_time_scrub_region_rect_get(region, &scrub_region_rect);
 
   draw_background(&scrub_region_rect);
 
diff --git a/source/blender/editors/include/ED_time_scrub_ui.h b/source/blender/editors/include/ED_time_scrub_ui.h
index 596fdd87afc..efc972ef69d 100644
--- a/source/blender/editors/include/ED_time_scrub_ui.h
+++ b/source/blender/editors/include/ED_time_scrub_ui.h
@@ -14,6 +14,7 @@ extern "C" {
 struct bContext;
 struct bDopeSheet;
 struct wmEvent;
+struct rcti;
 
 void ED_time_scrub_draw_current_frame(const struct ARegion *region,
                                       const struct Scene *scene,
@@ -29,6 +30,7 @@ bool ED_time_scrub_event_in_region(const struct ARegion *region, const struct wm
 void ED_time_scrub_channel_search_draw(const struct bContext *C,
                                        struct ARegion *region,
                                        struct bDopeSheet *dopesheet);
+void ED_time_scrub_region_rect_get(const struct ARegion *region, struct rcti *rect);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 4d245b9ddaa..0cfbb30b648 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -30,6 +30,7 @@
 #include "ED_anim_api.h"
 #include "ED_screen.h"
 #include "ED_util_imbuf.h"
+#include "ED_time_scrub_ui.h"
 
 /* Own include. */
 #include "sequencer_intern.h"
@@ -84,6 +85,16 @@ static int sequencer_view_all_exec(bContext *C, wmOperator *op)
     box.xmax = ms->disp_range[1] + 1;
   }
   SEQ_timeline_expand_boundbox(SEQ_active_seqbase_get(ed), &box);
+
+  View2D *v2d = &region->v2d;
+  rcti scrub_rect;
+  ED_time_scrub_region_rect_get(region, &scrub_rect);
+  const float pixel_view_size_y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+  const float scrub_bar_height = BLI_rcti_size_y(&scrub_rect) * pixel_view_size_y;
+
+  /* Channel n has range of <n, n+1>. */
+  box.ymax += 1.0f + scrub_bar_height;    //xxx this is not exact fixme
+
   UI_view2d_smooth_view(C, region, &box, smooth_viewtx);
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index d1b25af52f1..0e928fa75a9 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -18,6 +18,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
+#include "BLI_math_base.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
@@ -29,8 +30,10 @@
 
 #include "GPU_state.h"
 
+#include "ED_markers.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
+#include "ED_time_scrub_ui.h"
 #include "ED_transform.h"
 #include "ED_view3d.h"
 #include "ED_view3d_offscreen.h" /* Only for sequencer view3d drawing callback. */
@@ -41,6 +44,8 @@
 
 #include "RNA_access.h"
 
+#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
 #include "SEQ_transform.h"
 #include "SEQ_utils.h"
 
@@ -165,7 +170,7 @@ static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *sce
   region->v2d.tot.xmin = 0.0f;
   region->v2d.tot.ymin = 0.0f;
   region->v2d.tot.xmax = scene->r.efra;
-  region->v2d.tot.ymax = 8.0f;
+  region->v2d.tot.ymax = 8.5f;
 
   region->v2d.cur = region->v2d.tot;
 
@@ -631,6 +636,68 @@ static void sequencer_main_region_draw_overlay(const bContext *C, ARegion *regio
   draw_timeline_seq_display(C, region);
 }
 
+struct View2DScrollers {
+  int vert_min, vert_max; /* vertical scrollbar */
+  int hor_min, hor_max;   /* horizontal scrollbar */
+
+  /* These values are written into, even if we don't use them. */
+  rcti _hor, _vert;
+};
+
+static void sequencer_main_clamp_view(const bContext *C, ARegion *region)
+{
+  View2D *v2d = &region->v2d;
+  Editing *ed = SEQ_editing_get(CTX_data_scene(C));
+
+  /* Initialize default view with 7 channels, that are visible even if empty. */
+  rctf strip_boundbox;
+  BLI_rctf_init(&strip_boundbox, 0.0f, 0.0f, 1.0f, 7.0f);
+  SEQ_timeline_expand_boundbox(ed->seqbasep, &strip_boundbox);
+
+  /* Clamp Y max. Scrubbing area height must be added, so strips aren't occluded. */
+  rcti scrub_rect;
+  ED_time_scrub_region_rect_get(region, &scrub_rect);
+  const float pixel_view_size_y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+  const float scrub_bar_height = BLI_rcti_size_y(&scrub_rect) * pixel_view_size_y;
+
+  /* Channel n has range of <n, n+1>. */
+  strip_boundbox.ymax += 1.0f + scrub_bar_height;
+
+  /* Clamp Y min. Scroller and marker area height must be added, so strips aren't occluded. */
+  struct View2DScrollers scrollers;
+  UI_view2d_scrollers_calc(v2d, NULL, &scrollers);
+  float scroll_bar_height = scrollers._hor.ymax * pixel_view_size_y;
+
+  ListBase *markers = ED_context_get_markers(C);
+  if (markers != NULL && !BLI_listbase_is_empty(markers)) {
+    float markers_size = UI_MARKER_MARGIN_Y * pixel_view_size_y;
+    strip_boundbox.ymin -= markers_size;
+  }
+  else {
+    strip_boundbox.ymin -= scroll_bar_height;
+  }
+
+  const float range_y = BLI_rctf_size_y(&v2d->cur);
+  if (v2d->cur.ymax > strip_boundbox.ymax) {
+    v2d->cur.ymax = strip_boundbox.ymax;
+    v2d->cur.ymin = max_ff(strip_boundbox.ymin, strip_boundbox.ymax - range_y);
+  }
+  if (v2d->cur.ymin < strip_boundbox.ymin) {
+    v2d->cur.ymin = strip_boundbox.ymin;
+    v2d->cur.ymax = min_ff(strip_boundbox.ymax, strip_boundbox.ymin + range_y);
+  }
+}
+
+static void sequencer_main_region_layout(const bContext *C, ARegion *region)
+{
+  sequencer_main_clamp_view(C, region);
+}
+
+static void sequencer_main_region_view2d_changed(const bContext *C, ARegion *region)
+{
+  sequencer_main_clamp_view(C, region);
+}
+
 static void sequencer_main_region_listener(const wmRegionListenerParams *params)
 {
   ARegion *region = params->region;
@@ -1011,6 +1078,8 @@ void ED_spacetype_sequencer(void)
   art->init = sequencer_main_region_init;
   art->draw = sequencer_main_region_draw;
   art->draw_overlay = sequencer_main_region_draw_overlay;
+  art->layout = sequencer_main_region_layout;
+  art->on_view2d_changed = sequencer_main_region_view2d_changed;
   art->listener = sequencer_main_region_listener;
   art->message_subscribe = sequencer_main_region_message_subscribe;
   /* NOTE: inclusion of #ED_KEYMAP_GIZMO is currently for scripts and isn't used by default. */
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index 91ff696b31b..4badbf109c8 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -17,6 +17,7 @@
 #include "BKE_report.h"
 
 #include "ED_markers.h"
+#include "ED_time_scrub_ui.h"
 
 #include "SEQ_animation.h"
 #include "SEQ_edit.h"
@@ -824,6 +825,7 @@ static void flushTransSeq(TransInfo *t)
       seq->flag |= SEQ_OVERLAP;
     }
   }
+
   SEQ_collection_free(transformed_strips);
 }
 
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
index ec908dcdc93..635f03add0b 100644
--- a/source/blender/sequencer/intern/strip_time.c
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -443,7 +443,7 @@ void SEQ_timeline_expand_boundbox(const ListBase *seqbase, rctf *rect)
       rect->xmax = seq->enddisp + 1;
     }
     if (rect->ymax < seq->machine + 2) {
-      rect->ymax = seq->machine + 2;
+      rect->ymax = seq->machine;
     }
   }
 }



More information about the Bf-blender-cvs mailing list