[Bf-blender-cvs] [abe95fbdff2] master: Cleanup: refactor sequencer_edit.c file

Richard Antalik noreply at git.blender.org
Thu Nov 19 13:04:36 CET 2020


Commit: abe95fbdff2eed89ccd70173ee817f1834faf54a
Author: Richard Antalik
Date:   Thu Nov 19 12:59:29 2020 +0100
Branches: master
https://developer.blender.org/rBabe95fbdff2eed89ccd70173ee817f1834faf54a

Cleanup: refactor sequencer_edit.c file

Move RNA enums and utility functions closer to operator definition.

No functional changes.

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

M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/sequencer/SEQ_sequencer.h

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

diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 972b0b1cdfa..93b17830c0f 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -72,46 +72,6 @@
 /** \name Structs & Enums
  * \{ */
 
-/* RNA Enums, used in multiple files. */
-EnumPropertyItem sequencer_prop_effect_types[] = {
-    {SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
-    {SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
-    {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
-    {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
-    {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
-    {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
-    {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
-    {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
-    {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
-    {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
-    {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
-    {SEQ_TYPE_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
-    {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
-    {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
-    {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
-    {SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
-    {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
-    {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
-    {0, NULL, 0, NULL, NULL},
-};
-
-#define SEQ_SIDE_MOUSE -1
-
-EnumPropertyItem prop_side_types[] = {
-    {SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse Position", ""},
-    {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
-    {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
-    {SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
-    {SEQ_SIDE_NO_CHANGE, "NO_CHANGE", 0, "No Change", ""},
-    {0, NULL, 0, NULL, NULL},
-};
-
-static const EnumPropertyItem prop_side_lr_types[] = {
-    {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
-    {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
-    {0, NULL, 0, NULL, NULL},
-};
-
 typedef struct TransSeq {
   int start, machine;
   int startstill, endstill;
@@ -124,263 +84,6 @@ typedef struct TransSeq {
 
 /** \} */
 
-/* -------------------------------------------------------------------- */
-/** \name Sequence Query Utilities
- * \{ */
-
-void seq_rectf(Sequence *seq, rctf *rect)
-{
-  rect->xmin = seq->startdisp;
-  rect->xmax = seq->enddisp;
-  rect->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM;
-  rect->ymax = seq->machine + SEQ_STRIP_OFSTOP;
-}
-
-void boundbox_seq(Scene *scene, rctf *rect)
-{
-  Sequence *seq;
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-  float min[2], max[2];
-
-  if (ed == NULL) {
-    return;
-  }
-
-  min[0] = SFRA;
-  max[0] = EFRA + 1;
-  min[1] = 0.0;
-  max[1] = 8.0;
-
-  seq = ed->seqbasep->first;
-  while (seq) {
-
-    if (min[0] > seq->startdisp - 1) {
-      min[0] = seq->startdisp - 1;
-    }
-    if (max[0] < seq->enddisp + 1) {
-      max[0] = seq->enddisp + 1;
-    }
-    if (max[1] < seq->machine + 2) {
-      max[1] = seq->machine + 2;
-    }
-
-    seq = seq->next;
-  }
-
-  rect->xmin = min[0];
-  rect->xmax = max[0];
-  rect->ymin = min[1];
-  rect->ymax = max[1];
-}
-
-static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
-{
-  int mval[2];
-  float mouseloc[2];
-
-  mval[0] = mouse_x;
-  mval[1] = 0;
-
-  /* Choose the side based on which side of the current frame the mouse is on. */
-  UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
-
-  return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
-}
-
-Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
-{
-  /* sel: 0==unselected, 1==selected, -1==don't care. */
-  Sequence *seq;
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-
-  if (ed == NULL) {
-    return NULL;
-  }
-
-  if (sel > 0) {
-    sel = SELECT;
-  }
-
-  for (seq = ed->seqbasep->first; seq; seq = seq->next) {
-    if ((seq != test) && (test->machine == seq->machine) &&
-        ((sel == -1) || (sel && (seq->flag & SELECT)) ||
-         (sel == 0 && (seq->flag & SELECT) == 0))) {
-      switch (lr) {
-        case SEQ_SIDE_LEFT:
-          if (test->startdisp == (seq->enddisp)) {
-            return seq;
-          }
-          break;
-        case SEQ_SIDE_RIGHT:
-          if (test->enddisp == (seq->startdisp)) {
-            return seq;
-          }
-          break;
-      }
-    }
-  }
-  return NULL;
-}
-
-static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
-{
-  /* sel: 0==unselected, 1==selected, -1==don't care. */
-  Sequence *seq, *best_seq = NULL;
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-
-  int dist, best_dist;
-  best_dist = MAXFRAME * 2;
-
-  if (ed == NULL) {
-    return NULL;
-  }
-
-  seq = ed->seqbasep->first;
-  while (seq) {
-    if ((seq != test) && (test->machine == seq->machine) && (test->depth == seq->depth) &&
-        ((sel == -1) || (sel == (seq->flag & SELECT)))) {
-      dist = MAXFRAME * 2;
-
-      switch (lr) {
-        case SEQ_SIDE_LEFT:
-          if (seq->enddisp <= test->startdisp) {
-            dist = test->enddisp - seq->startdisp;
-          }
-          break;
-        case SEQ_SIDE_RIGHT:
-          if (seq->startdisp >= test->enddisp) {
-            dist = seq->startdisp - test->enddisp;
-          }
-          break;
-      }
-
-      if (dist == 0) {
-        best_seq = seq;
-        break;
-      }
-      if (dist < best_dist) {
-        best_dist = dist;
-        best_seq = seq;
-      }
-    }
-    seq = seq->next;
-  }
-  return best_seq; /* Can be null. */
-}
-
-Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2])
-{
-  Sequence *seq;
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-  float x, y;
-  float pixelx;
-  float handsize;
-  float displen;
-  *hand = SEQ_SIDE_NONE;
-
-  if (ed == NULL) {
-    return NULL;
-  }
-
-  pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
-
-  UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-
-  seq = ed->seqbasep->first;
-
-  while (seq) {
-    if (seq->machine == (int)y) {
-      /* Check for both normal strips, and strips that have been flipped horizontally. */
-      if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
-          ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x))) {
-        if (BKE_sequence_tx_test(seq)) {
-
-          /* Clamp handles to defined size in pixel space. */
-          handsize = 2.0f * sequence_handle_size_get_clamped(seq, pixelx);
-          displen = (float)abs(seq->startdisp - seq->enddisp);
-
-          /* Don't even try to grab the handles of small strips. */
-          if (displen / pixelx > 16) {
-
-            /* Set the max value to handle to 1/3 of the total len when its
-             * less than 28. This is important because otherwise selecting
-             * handles happens even when you click in the middle. */
-            if ((displen / 3) < 30 * pixelx) {
-              handsize = displen / 3;
-            }
-            else {
-              CLAMP(handsize, 7 * pixelx, 30 * pixelx);
-            }
-
-            if (handsize + seq->startdisp >= x) {
-              *hand = SEQ_SIDE_LEFT;
-            }
-            else if (-handsize + seq->enddisp <= x) {
-              *hand = SEQ_SIDE_RIGHT;
-            }
-          }
-        }
-        return seq;
-      }
-    }
-    seq = seq->next;
-  }
-  return NULL;
-}
-
-static bool seq_is_parent(Sequence *par, Sequence *seq)
-{
-  return ((par->seq1 == seq) || (par->seq2 == seq) || (par->seq3 == seq));
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Selection Utilities
- * \{ */
-
-void ED_sequencer_deselect_all(Scene *scene)
-{
-  Sequence *seq;
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-
-  if (ed == NULL) {
-    return;
-  }
-
-  SEQ_CURRENT_BEGIN (ed, seq) {
-    seq->flag &= ~SEQ_ALLSEL;
-  }
-  SEQ_CURRENT_END;
-}
-
-void recurs_sel_seq(Sequence *seqm)
-{
-  Sequence *seq;
-
-  seq = seqm->seqbase.first;
-  while (seq) {
-
-    if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
-      seq->flag &= ~SEQ_ALLSEL;
-    }
-    else if (seqm->flag & SELECT) {
-      seq->flag |= SELECT;
-    }
-    else {
-      seq->flag &= ~SEQ_ALLSEL;
-    }
-
-    if (seq->seqbase.first) {
-      recurs_sel_seq(seq);
-    }
-
-    seq = seq->next;
-  }
-}
-
-/** \} */
-
 /* -------------------------------------------------------------------- */
 /** \name Public Context Checks
  * \{ */
@@ -388,174 +91,98 @@ void recurs_sel_seq(Sequence *seqm)
 bool ED_space_sequencer_maskedit_mask_poll(bContext *C)
 {
   return ED_space_sequencer_maskedit_poll(C);
-}
-
-bool ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene)
-{
-  if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
-    return (BKE_sequencer_mask_get(scene) != NULL);
-  }
-
-  return false;
-}
-
-bool ED_space_sequencer_maskedit_poll(bContext *C)
-{
-  SpaceSeq *sseq = CTX_wm_space_seq(C);
-
-  if (sseq) {
-    Scene *scene = CTX_data_scene(C);
-    return ED_space_sequencer_check_show_maskedit(sseq, scene);
-  }
-
-  return false;
-}
-
-/* Are we displaying the seq output (not channels or histogram). */
-bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
-{
-  return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
-          ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
-}
-
-bool ED_space_sequencer_check_show_strip(SpaceSeq *sseq)
-{
-  return (ELEM(sseq->view, SEQ_VIEW_SEQUENCE, SEQ_VIEW_SEQUENCE_PREVIEW) &&
-          ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Find Selected Strips as Inputs to 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list