Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Y Jeppu <adi.jeppu28@gmail.com>2021-09-13 15:57:05 +0300
committerAditya Y Jeppu <adi.jeppu28@gmail.com>2021-09-13 15:57:05 +0300
commit6f908dffe226f77e9dc5198a791b332ae0bd25d5 (patch)
treef4d028bf020fa2b74f232b3093941f180c0e78e6
parentf3d3e125b774774648f0c9ec84741d3e2c7ef578 (diff)
V2D navigating flag by Richard Antaliksoc-2021-vse-strip-thumbnails
-rw-r--r--source/blender/editors/interface/view2d_ops.c15
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c82
-rw-r--r--source/blender/makesdna/DNA_view2d_types.h2
3 files changed, 70 insertions, 29 deletions
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 1fd1b6c984d..3afbcf78851 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -147,6 +147,8 @@ static void view_pan_init(bContext *C, wmOperator *op)
const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
+
+ vpd->v2d->flag |= V2D_IS_NAVIGATING;
}
/* apply transform to view (i.e. adjust 'cur' rect) */
@@ -190,6 +192,8 @@ static void view_pan_apply(bContext *C, wmOperator *op)
/* Cleanup temp custom-data. */
static void view_pan_exit(wmOperator *op)
{
+ v2dViewPanData *vpd = op->customdata;
+ vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
}
@@ -305,7 +309,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
+static void view_pan_cancel(bContext *C, wmOperator *op)
{
view_pan_exit(op);
}
@@ -358,6 +362,7 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
View2DEdgePanData *vpd = op->customdata;
if (event->val == KM_RELEASE || event->type == EVT_ESCKEY) {
+ vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
@@ -371,6 +376,8 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
static void view_edge_pan_cancel(bContext *UNUSED(C), wmOperator *op)
{
+ v2dViewPanData *vpd = op->customdata;
+ vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
}
@@ -680,6 +687,8 @@ static void view_zoomdrag_init(bContext *C, wmOperator *op)
vzd->v2d = &vzd->region->v2d;
/* False by default. Interactive callbacks (ie invoke()) can set it to true. */
vzd->zoom_to_mouse_pos = false;
+
+ vzd->v2d->flag |= V2D_IS_NAVIGATING;
}
/* apply transform to view (i.e. adjust 'cur' rect) */
@@ -809,7 +818,8 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
static void view_zoomstep_exit(wmOperator *op)
{
UI_view2d_zoom_cache_reset();
-
+ v2dViewZoomData *vzd = op->customdata;
+ vzd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
}
@@ -1041,6 +1051,7 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
if (op->customdata) {
v2dViewZoomData *vzd = op->customdata;
+ vzd->v2d->flag &= ~V2D_IS_NAVIGATING;
if (vzd->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1ec6d9dc4a7..b4363db1e71 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1375,12 +1375,12 @@ static void seq_get_thumb_image_dimensions(Sequence *seq,
static float seq_thumbnail_get_start_frame(Sequence *seq, float frame_step, rctf *view_area)
{
- if (seq->start > view_area->xmin && seq->start < view_area->xmax) {
+ if (seq->start > view_area->xmin) {
return seq->start;
}
- /* Drawing and caching both check to see if strip is in view area or not before calling this
- * function so assuming strip/part of strip in view. */
+ /* Drawing and caching both check to see if stristart_framep is in view area or not before
+ * calling this function so assuming strip/part of strip in view. */
int no_invisible_thumbs = (view_area->xmin - seq->start) / frame_step;
return ((no_invisible_thumbs - 1) * frame_step) + seq->start;
@@ -1505,6 +1505,11 @@ static void sequencer_thumbnail_start_job_if_necessary(const bContext *C,
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
+ if ((v2d->flag & V2D_IS_NAVIGATING) != 0) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
+ return;
+ }
+
/* Leftover is set to true if missing image in strip. False when normal call to all strips done.
*/
if (v2d->cur.xmax != sseq->runtime.last_thumbnail_area.xmax ||
@@ -1521,6 +1526,24 @@ static void sequencer_thumbnail_start_job_if_necessary(const bContext *C,
}
}
+/* Don't display thumbnails only when zooming. Panning doesn't cause issues. */
+static bool sequencer_thumbnail_v2d_is_navigating(const bContext *C)
+{
+ ARegion *region = CTX_wm_region(C);
+ View2D *v2d = &region->v2d;
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+
+ if ((v2d->flag & V2D_IS_NAVIGATING) == 0) {
+ return false;
+ }
+
+ double x_diff = fabs(BLI_rctf_size_x(&sseq->runtime.last_thumbnail_area) -
+ BLI_rctf_size_x(&v2d->cur));
+ double y_diff = fabs(BLI_rctf_size_y(&sseq->runtime.last_thumbnail_area) -
+ BLI_rctf_size_y(&v2d->cur));
+ return x_diff > 0.01 || y_diff > 0.01;
+}
+
static void draw_seq_strip_thumbnail(View2D *v2d,
const bContext *C,
Scene *scene,
@@ -1538,6 +1561,11 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
if ((y2 - y1) / pixely <= 40 * U.dpi_fac)
return;
+ if (sequencer_thumbnail_v2d_is_navigating(C)) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
+ return;
+ }
+
SeqRenderData context = sequencer_thumbnail_context_init(C);
seq_get_thumb_image_dimensions(
seq, pixelx, pixely, &thumb_width, &thumb_height, &image_width, &image_height);
@@ -1603,32 +1631,32 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
/* Get the image. */
ImBuf *ibuf = SEQ_get_thumbnail(&context, seq, roundf(thumb_x_start), &crop, clipped);
- if (ibuf) {
- /* Transparency on overlap. */
- if (seq->flag & SEQ_OVERLAP) {
- GPU_blend(GPU_BLEND_ALPHA);
- unsigned char *buf = (unsigned char *)ibuf->rect;
- for (int pixel = ibuf->x * ibuf->y; pixel--; buf += 4) {
- buf[3] = OVERLAP_ALPHA;
- }
- }
-
- ED_draw_imbuf_ctx_clipping(C,
- ibuf,
- thumb_x_start + cut_off,
- y1,
- true,
- thumb_x_start + cut_off,
- y1,
- thumb_x_end,
- thumb_y_end,
- zoom_x,
- zoom_y);
- IMB_freeImBuf(ibuf);
- }
- else {
+ if (!ibuf) {
sequencer_thumbnail_start_job_if_necessary(C, scene->ed, v2d, true);
+ break;
}
+
+ /* Transparency on overlap. */
+ if (seq->flag & SEQ_OVERLAP) {
+ GPU_blend(GPU_BLEND_ALPHA);
+ unsigned char *buf = (unsigned char *)ibuf->rect;
+ for (int pixel = ibuf->x * ibuf->y; pixel--; buf += 4) {
+ buf[3] = OVERLAP_ALPHA;
+ }
+ }
+
+ ED_draw_imbuf_ctx_clipping(C,
+ ibuf,
+ thumb_x_start + cut_off,
+ y1,
+ true,
+ thumb_x_start + cut_off,
+ y1,
+ thumb_x_end,
+ thumb_y_end,
+ zoom_x,
+ zoom_y);
+ IMB_freeImBuf(ibuf);
GPU_blend(GPU_BLEND_NONE);
cut_off = 0;
thumb_x_start = thumb_x_end;
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index c385ac04bd3..f8166305fd9 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -132,6 +132,8 @@ enum {
V2D_PIXELOFS_X = (1 << 2),
/* apply pixel offsets on y-axis when setting view matrices */
V2D_PIXELOFS_Y = (1 << 3),
+ /* zoom, pan or similar action is in progress */
+ V2D_IS_NAVIGATING = (1 << 9),
/* view settings need to be set still... */
V2D_IS_INIT = (1 << 10),
};