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:
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_view.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c106
1 files changed, 69 insertions, 37 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 4d245b9ddaa..c407dad623d 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -22,9 +22,11 @@
#include "RNA_define.h"
+#include "SEQ_iterator.h"
#include "SEQ_select.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
+#include "SEQ_transform.h"
/* For menu, popup, icons, etc. */
#include "ED_anim_api.h"
@@ -260,14 +262,30 @@ void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
/** \name Frame Selected Operator
* \{ */
-static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
+static void seq_view_collection_rect_preview(Scene *scene, SeqCollection *strips, rctf *rect)
+{
+ float min[2], max[2];
+ SEQ_image_transform_bounding_box_from_collection(scene, strips, true, min, max);
+
+ rect->xmin = min[0];
+ rect->xmax = max[0];
+ rect->ymin = min[1];
+ rect->ymax = max[1];
+
+ float minsize = min_ff(BLI_rctf_size_x(rect), BLI_rctf_size_y(rect));
+
+ /* If the size of the strip is smaller than a pixel, add padding to prevent division by zero. */
+ if (minsize < 1.0f) {
+ BLI_rctf_pad(rect, 20.0f, 20.0f);
+ }
+
+ /* Add padding. */
+ BLI_rctf_scale(rect, 1.1f);
+}
+
+static void seq_view_collection_rect_timeline(Scene *scene, SeqCollection *strips, rctf *rect)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
- ARegion *region = CTX_wm_region(C);
- Editing *ed = SEQ_editing_get(scene);
Sequence *seq;
- rctf cur_new = v2d->cur;
int xmin = MAXFRAME * 2;
int xmax = -MAXFRAME * 2;
@@ -278,49 +296,63 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
int ymargin = 1;
int xmargin = FPS;
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- xmin = min_ii(xmin, seq->startdisp);
- xmax = max_ii(xmax, seq->enddisp);
+ SEQ_ITERATOR_FOREACH (seq, strips) {
+ xmin = min_ii(xmin, seq->startdisp);
+ xmax = max_ii(xmax, seq->enddisp);
- ymin = min_ii(ymin, seq->machine);
- ymax = max_ii(ymax, seq->machine);
- }
+ ymin = min_ii(ymin, seq->machine);
+ ymax = max_ii(ymax, seq->machine);
}
- if (ymax != 0) {
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ xmax += xmargin;
+ xmin -= xmargin;
+ ymax += ymargin;
+ ymin -= ymargin;
- xmax += xmargin;
- xmin -= xmargin;
- ymax += ymargin;
- ymin -= ymargin;
+ orig_height = BLI_rctf_size_y(rect);
- orig_height = BLI_rctf_size_y(&cur_new);
+ rect->xmin = xmin;
+ rect->xmax = xmax;
- cur_new.xmin = xmin;
- cur_new.xmax = xmax;
+ rect->ymin = ymin;
+ rect->ymax = ymax;
- cur_new.ymin = ymin;
- cur_new.ymax = ymax;
+ /* Only zoom out vertically. */
+ if (orig_height > BLI_rctf_size_y(rect)) {
+ ymid = BLI_rctf_cent_y(rect);
- /* Only zoom out vertically. */
- if (orig_height > BLI_rctf_size_y(&cur_new)) {
- ymid = BLI_rctf_cent_y(&cur_new);
+ rect->ymin = ymid - (orig_height / 2);
+ rect->ymax = ymid + (orig_height / 2);
+ }
+}
- cur_new.ymin = ymid - (orig_height / 2);
- cur_new.ymax = ymid + (orig_height / 2);
- }
+static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ ARegion *region = CTX_wm_region(C);
+ SeqCollection *strips = selected_strips_from_context(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
+ rctf cur_new = v2d->cur;
- UI_view2d_smooth_view(C, region, &cur_new, smooth_viewtx);
+ if (SEQ_collection_len(strips) == 0) {
+ return OPERATOR_CANCELLED;
+ }
- return OPERATOR_FINISHED;
+ if (sequencer_view_has_preview_poll(C) && !sequencer_view_preview_only_poll(C)) {
+ return OPERATOR_CANCELLED;
}
- return OPERATOR_CANCELLED;
+
+ if (region && region->regiontype == RGN_TYPE_PREVIEW) {
+ seq_view_collection_rect_preview(scene, strips, &cur_new);
+ }
+ else {
+ seq_view_collection_rect_timeline(scene, strips, &cur_new);
+ }
+
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ UI_view2d_smooth_view(C, region, &cur_new, smooth_viewtx);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_selected(wmOperatorType *ot)