[Bf-blender-cvs] [5cb88e6d3a8] temp-vse-channels-edge-panning: Use edge panning method implemented for nodes

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


Commit: 5cb88e6d3a82e8ed16db4671e9ce6c8414f0673c
Author: Richard Antalik
Date:   Wed Mar 9 12:17:17 2022 +0100
Branches: temp-vse-channels-edge-panning
https://developer.blender.org/rB5cb88e6d3a82e8ed16db4671e9ce6c8414f0673c

Use edge panning method implemented for nodes

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

M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/transform/transform_convert_sequencer.c
M	source/blender/makesdna/DNA_space_types.h

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

diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 0e928fa75a9..6bf91c21285 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -649,6 +649,12 @@ static void sequencer_main_clamp_view(const bContext *C, ARegion *region)
   View2D *v2d = &region->v2d;
   Editing *ed = SEQ_editing_get(CTX_data_scene(C));
 
+  /* Transformation uses edge panning to move view. Also if smooth view is running, don't apply
+   * clamping to prevent overriding this functionality. */
+  if (G.moving || v2d->smooth_timer != NULL) {
+    return;
+  }
+
   /* 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);
@@ -677,14 +683,30 @@ static void sequencer_main_clamp_view(const bContext *C, ARegion *region)
     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);
+  rctf view_clamped = v2d->cur;
+  bool do_clamp = false;
+
+  const float range_y = BLI_rctf_size_y(&view_clamped);
+  if (view_clamped.ymax > strip_boundbox.ymax) {
+    view_clamped.ymax = strip_boundbox.ymax;
+    view_clamped.ymin = max_ff(strip_boundbox.ymin, strip_boundbox.ymax - range_y);
+    do_clamp = true;
   }
-  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);
+  if (view_clamped.ymin < strip_boundbox.ymin) {
+    view_clamped.ymin = strip_boundbox.ymin;
+    view_clamped.ymax = min_ff(strip_boundbox.ymax, strip_boundbox.ymin + range_y);
+    do_clamp = true;
+  }
+
+  SpaceSeq *sseq = CTX_wm_space_seq(C);
+  if (do_clamp) {
+    if ((sseq->flag & SPACE_SEQ_CLAMP_SMOOTH) != 0) {
+      UI_view2d_smooth_view(C, region, &view_clamped, U.smooth_viewtx);
+      sseq->flag &= ~SPACE_SEQ_CLAMP_SMOOTH;
+    }
+    else {
+      v2d->cur = view_clamped;
+    }
   }
 }
 
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index 4badbf109c8..04ed1bb08d3 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -734,11 +734,14 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s
   }
 }
 
-static void flushTransSeq(TransInfo *t)
+static void view2d_edge_pan_loc_compensate(TransInfo *t, float loc_in[2], float r_loc[2])
 {
   TransSeq *ts = (TransSeq *)TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
 
   if (t->options & CTX_VIEW2D_EDGE_PAN) {
+    SpaceSeq *sseq = CTX_wm_space_seq(t->context);
+    sseq->flag |= SPACE_SEQ_CLAMP_SMOOTH;
+
     if (t->state == TRANS_CANCEL) {
       UI_view2d_edge_pan_cancel(t->context, &ts->edge_pan);
     }
@@ -756,6 +759,13 @@ static void flushTransSeq(TransInfo *t)
   const rctf *rect_src = &ts->initial_v2d_cur;
   const rctf *rect_dst = &t->region->v2d.cur;
 
+  copy_v2_v2(r_loc, loc_in);
+  /* Additional offset due to change in view2D rect. */
+  BLI_rctf_transform_pt_v(rect_dst, rect_src, r_loc, r_loc);
+}
+
+static void flushTransSeq(TransInfo *t)
+{
   /* Editing null check already done */
   ListBase *seqbasep = seqbase_active_get(t);
 
@@ -771,11 +781,8 @@ static void flushTransSeq(TransInfo *t)
   for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) {
     tdsq = (TransDataSeq *)td->extra;
     seq = tdsq->seq;
-
     float loc[2];
-    copy_v2_v2(loc, td2d->loc);
-    /* additional offset due to change in view2D rect */
-    BLI_rctf_transform_pt_v(rect_dst, rect_src, loc, loc);
+    view2d_edge_pan_loc_compensate(t, td->loc, loc);
 
     new_frame = round_fl_to_int(loc[0]);
 
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index e6c163d94ba..9f4f9fb6c11 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -678,7 +678,7 @@ typedef enum eSpaceSeq_Flag {
   SEQ_DRAWFRAMES = (1 << 0),
   SEQ_MARKER_TRANS = (1 << 1),
   SEQ_DRAW_COLOR_SEPARATED = (1 << 2),
-  SPACE_SEQ_FLAG_UNUSED_3 = (1 << 3),
+  SPACE_SEQ_CLAMP_SMOOTH = (1 << 3),
   SPACE_SEQ_FLAG_UNUSED_4 = (1 << 4),
   SPACE_SEQ_FLAG_UNUSED_5 = (1 << 5),
   SEQ_USE_ALPHA = (1 << 6), /* use RGBA display mode for preview */



More information about the Bf-blender-cvs mailing list