[Bf-blender-cvs] [aac6a723fe8] temp-vse-grid-lines: VSE: Don't draw time grid lines

Richard Antalik noreply at git.blender.org
Wed Jul 14 20:29:36 CEST 2021


Commit: aac6a723fe8d612a57396d4852f555bf7d4d5411
Author: Richard Antalik
Date:   Wed Jul 14 15:11:38 2021 +0200
Branches: temp-vse-grid-lines
https://developer.blender.org/rBaac6a723fe8d612a57396d4852f555bf7d4d5411

VSE: Don't draw time grid lines

Add overlay option to disable grid drawing.
Reuse drawing code from other editors (timeline editor )

{F10215219,size=full}

Differential Revision: https://developer.blender.org/D11790

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 55714e0b0a5..1354cac1d60 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -263,6 +263,7 @@ class SEQUENCER_PT_sequencer_overlay(Panel):
 
         layout.prop(st, "show_strip_offset", text="Offsets")
         layout.prop(st, "show_fcurves", text="F-Curves")
+        layout.prop(st, "show_grid", text="Grid")
 
         layout.separator()
 
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 3c58c29c162..7e54644af13 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -540,5 +540,16 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
+
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+          if (sl->spacetype == SPACE_SEQ) {
+            SpaceSeq *sseq = (SpaceSeq *)sl;
+            sseq->flag |= SEQ_SHOW_GRID;
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 10b24532014..6b54600f915 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -183,7 +183,7 @@ static void blo_update_defaults_screen(bScreen *screen,
     else if (area->spacetype == SPACE_SEQ) {
       SpaceSeq *seq = area->spacedata.first;
       seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | SEQ_ZOOM_TO_FIT | SEQ_SHOW_STRIP_OVERLAY |
-                   SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_NAME | SEQ_SHOW_STRIP_DURATION;
+                   SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_NAME | SEQ_SHOW_STRIP_DURATION | SEQ_SHOW_GRID;
 
       seq->render_size = SEQ_RENDER_SIZE_PROXY_100;
       seq->flag |= SEQ_USE_PROXIES;
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 8191a9a9062..7726fc4eca8 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -143,7 +143,6 @@ void UI_view2d_view_orthoSpecial(struct ARegion *region, struct View2D *v2d, con
 void UI_view2d_view_restore(const struct bContext *C);
 
 /* grid drawing */
-void UI_view2d_constant_grid_draw(const struct View2D *v2d, float step);
 void UI_view2d_multi_grid_draw(
     const struct View2D *v2d, int colorid, float step, int level_size, int totlevels);
 
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index e9804840801..c68b09ab941 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1194,78 +1194,6 @@ void UI_view2d_view_restore(const bContext *C)
 /** \name Grid-Line Drawing
  * \{ */
 
-/* Draw a constant grid in given 2d-region */
-void UI_view2d_constant_grid_draw(const View2D *v2d, float step)
-{
-  float start_x, start_y;
-  int count_x, count_y;
-
-  start_x = v2d->cur.xmin;
-  if (start_x < 0.0) {
-    start_x += -(float)fmod(v2d->cur.xmin, step);
-  }
-  else {
-    start_x += (step - (float)fmod(v2d->cur.xmin, step));
-  }
-
-  if (start_x > v2d->cur.xmax) {
-    count_x = 0;
-  }
-  else {
-    count_x = (v2d->cur.xmax - start_x) / step + 1;
-  }
-
-  start_y = v2d->cur.ymin;
-  if (start_y < 0.0) {
-    start_y += -(float)fmod(v2d->cur.ymin, step);
-  }
-  else {
-    start_y += (step - (float)fabs(fmod(v2d->cur.ymin, step)));
-  }
-
-  if (start_y > v2d->cur.ymax) {
-    count_y = 0;
-  }
-  else {
-    count_y = (v2d->cur.ymax - start_y) / step + 1;
-  }
-
-  if (count_x > 0 || count_y > 0) {
-    GPUVertFormat *format = immVertexFormat();
-    const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-    const uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
-    float theme_color[3];
-
-    UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color);
-
-    immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-    immBegin(GPU_PRIM_LINES, count_x * 2 + count_y * 2 + 4);
-
-    immAttr3fv(color, theme_color);
-    for (int i = 0; i < count_x; start_x += step, i++) {
-      immVertex2f(pos, start_x, v2d->cur.ymin);
-      immVertex2f(pos, start_x, v2d->cur.ymax);
-    }
-
-    for (int i = 0; i < count_y; start_y += step, i++) {
-      immVertex2f(pos, v2d->cur.xmin, start_y);
-      immVertex2f(pos, v2d->cur.xmax, start_y);
-    }
-
-    /* X and Y axis */
-    UI_GetThemeColorShade3fv(TH_BACK, -18, theme_color);
-
-    immAttr3fv(color, theme_color);
-    immVertex2f(pos, 0.0f, v2d->cur.ymin);
-    immVertex2f(pos, 0.0f, v2d->cur.ymax);
-    immVertex2f(pos, v2d->cur.xmin, 0.0f);
-    immVertex2f(pos, v2d->cur.xmax, 0.0f);
-
-    immEnd();
-    immUnbindProgram();
-  }
-}
-
 /* Draw a multi-level grid in given 2d-region */
 void UI_view2d_multi_grid_draw(
     const View2D *v2d, int colorid, float step, int level_size, int totlevels)
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 8371a634a78..6a4b115a9bc 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -2416,7 +2416,10 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
   /* Get timeline bound-box, needed for the scroll-bars. */
   SEQ_timeline_boundbox(scene, SEQ_active_seqbase_get(ed), &v2d->tot);
   draw_seq_backdrop(v2d);
-  UI_view2d_constant_grid_draw(v2d, FPS);
+  if ((sseq->flag & SEQ_SHOW_STRIP_OVERLAY) && (sseq->flag & SEQ_SHOW_GRID)) {
+    UI_view2d_draw_lines_x__discrete_frames_or_seconds(
+        v2d, scene, (sseq->flag & SEQ_DRAWFRAMES) == 0);
+  }
 
   /* Only draw backdrop in timeline view. */
   if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) {
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index cf26d1e3243..6de95f0995a 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -100,7 +100,7 @@ static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *sce
   sseq->mainb = SEQ_DRAW_IMG_IMBUF;
   sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES |
                SEQ_ZOOM_TO_FIT | SEQ_SHOW_STRIP_OVERLAY | SEQ_SHOW_STRIP_NAME |
-               SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_DURATION;
+               SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_DURATION | SEQ_SHOW_GRID;
 
   /* Tool header. */
   region = MEM_callocN(sizeof(ARegion), "tool header for sequencer");
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 73a44ec16bb..f611bd036d0 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -653,6 +653,7 @@ typedef enum eSpaceSeq_Flag {
   SEQ_SHOW_STRIP_SOURCE = (1 << 15),
   SEQ_SHOW_STRIP_DURATION = (1 << 16),
   SEQ_USE_PROXIES = (1 << 17),
+  SEQ_SHOW_GRID = (1 << 18),
 } eSpaceSeq_Flag;
 
 /* SpaceSeq.view */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 11110dd154a..595225a96d0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -5549,6 +5549,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_TRANSFORM_PREVIEW);
   RNA_def_property_ui_text(prop, "Transform Preview", "Show preview of the transformed frames");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
+  prop = RNA_def_property(srna, "show_grid", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_GRID);
+  RNA_def_property_ui_text(prop, "Show Grid", "");
+  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
 }
 
 static void rna_def_space_text(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list