Page MenuHome
Paste P1121

Sequencer: Drag-all-selected experiment
ActivePublic

Authored by Julian Eisel (Severin) on Sep 30 2019, 11:36 PM.
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 1839dd5f322..2a8231ed1d2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2394,7 +2394,10 @@ def km_sequencer(params):
),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS'},
{"properties": [("extend", False), ("deselect_all", True),
- ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
+ ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False), ("exit_if_selected", True)]}),
+ ("sequencer.select", {"type": params.select_mouse, "value": 'RELEASE'},
+ {"properties": [("extend", False), ("deselect_all", True),
+ ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False), ("exit_if_selected", False)]}),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "alt": True},
@@ -2429,7 +2432,8 @@ def km_sequencer(params):
("wm.context_set_int", {"type": 'O', "value": 'PRESS'},
{"properties": [("data_path", 'scene.sequence_editor.overlay_frame'), ("value", 0)]}),
("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None),
- ("transform.seq_slide", {"type": params.select_tweak, "value": 'ANY'}, None),
+ ("transform.seq_slide", {"type": params.select_mouse, "value": 'PRESS'},
+ {"properties": [("wait_for_tweak", True)]}),
("transform.transform", {"type": 'E', "value": 'PRESS'},
{"properties": [("mode", 'TIME_EXTEND')]}),
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index affb6d3fd88..80ac84f03e4 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -328,6 +328,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
+ const bool exit_if_selected = RNA_boolean_get(op->ptr, "exit_if_selected");
int left_right = RNA_enum_get(op->ptr, "left_right");
Sequence *seq, *neighbor, *act_orig;
@@ -342,6 +343,11 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
+ if (exit_if_selected && seq && (seq->flag & SELECT)) {
+ /* Allow tweaks. */
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
+
// XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
left_right = SEQ_SELECT_LR_NONE;
@@ -598,6 +604,12 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
"Select based on the current frame side the cursor is on");
RNA_def_boolean(
ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time");
+ RNA_def_boolean(
+ ot->srna,
+ "exit_if_selected",
+ false,
+ "Exit if selected",
+ "Do not perform any selection change if the strip to be selected already is selected");
}
/* run recursively to select linked */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 67ea0f255fc..cef41e7ac6a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -54,6 +54,7 @@
#include "BKE_editmesh_bvh.h"
#include "BKE_context.h"
#include "BKE_constraint.h"
+#include "BKE_global.h"
#include "BKE_particle.h"
#include "BKE_unit.h"
#include "BKE_scene.h"
@@ -1051,11 +1052,29 @@ int transformEvent(TransInfo *t, const wmEvent *event)
const int modifiers_prev = t->modifiers;
const int mode_prev = t->mode;
+ if (t->state == TRANS_WAITING) {
+ if ((event->type == t->launch_event) && (event->val == KM_RELEASE)) {
+ t->state = TRANS_CANCEL;
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
+ else if (ISTWEAK(event->type)) {
+ t->state = TRANS_STARTING;
+ G.moving = special_transform_moving(t);
+ }
+ else {
+ t->state = TRANS_WAITING;
+ return OPERATOR_PASS_THROUGH;
+ }
+ }
+
t->redraw |= handleMouseInput(t, &t->mouse, event);
+ if (handled) {
+ /* Pass */
+ }
/* Handle modal numinput events first, if already activated. */
- if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) &&
- handleNumInput(t->context, &(t->num), event)) {
+ else if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) &&
+ handleNumInput(t->context, &(t->num), event)) {
t->redraw |= TREDRAW_HARD;
handled = true;
}
@@ -1625,7 +1644,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
WM_window_status_area_tag_redraw(CTX_wm_window(t->context));
}
- if (handled || t->redraw) {
+ if (handled || t->redraw || ELEM(t->state, TRANS_CONFIRM, TRANS_CANCEL)) {
return 0;
}
else {
@@ -2325,6 +2344,13 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->state = TRANS_STARTING;
+ if (op && ((prop = RNA_struct_find_property(op->ptr, "wait_for_tweak")) &&
+ RNA_property_is_set(op->ptr, prop))) {
+ if (RNA_property_boolean_get(op->ptr, prop)) {
+ t->state = TRANS_WAITING;
+ }
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) &&
RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
@@ -2785,7 +2811,10 @@ int transformEnd(bContext *C, TransInfo *t)
t->context = C;
- if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) {
+ if (t->state == TRANS_WAITING) {
+ exit_code = 0;
+ }
+ else if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) {
/* handle restoring objects */
if (t->state == TRANS_CANCEL) {
/* exception, edge slide transformed UVs too */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index ff2afbc0cd7..7fdaf7d5e5d 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -714,6 +714,7 @@ typedef struct TransInfo {
/* transinfo->state */
enum {
+ TRANS_WAITING = -1,
TRANS_STARTING = 0,
TRANS_RUNNING = 1,
TRANS_CONFIRM = 2,
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 5862faaf667..2e3af5d9418 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -2332,7 +2332,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
int special_transform_moving(TransInfo *t)
{
- if (t->spacetype == SPACE_SEQ) {
+ if (t->state == TRANS_WAITING) {
+ /* Pass. */
+ }
+ else if (t->spacetype == SPACE_SEQ) {
return G_TRANSFORM_SEQ;
}
else if (t->spacetype == SPACE_GRAPH) {
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index b2d8671fbce..1a26838ee43 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -414,6 +414,7 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* XXX insert keys are called here, and require context */
t->context = C;
exit_code = transformEvent(t, event);
+ BLI_assert((t->state != TRANS_WAITING) || (exit_code & OPERATOR_PASS_THROUGH));
t->context = NULL;
/* XXX, workaround: active needs to be calculated before transforming,
@@ -430,9 +431,12 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
exit_code |= transformEnd(C, t);
- if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
+ if (t->state == TRANS_WAITING) {
+ /* pass */
+ }
+ else if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
transformops_exit(C, op);
- exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
+ // exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
}
else {
if (mode_prev != t->mode) {
@@ -1159,6 +1163,16 @@ static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
WM_operatortype_props_advanced_begin(ot);
+ /* Might want to support this in Transform_Properties(). */
+ prop = RNA_def_boolean(
+ ot->srna,
+ "wait_for_tweak",
+ 0,
+ "Wait for Tweak Event",
+ "Let events pass to other operators and only start applying transformations when a tweak "
+ "event from the initial event source is recognized");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
Transform_Properties(ot, P_SNAP);
}