Skip to content

Commit 758f63b

Browse files
committed
Add select tool
1 parent 54226ef commit 758f63b

8 files changed

Lines changed: 108 additions & 3 deletions

File tree

src/plugins/coreplugin/res/icons/config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11228,6 +11228,18 @@
1122811228
{
1122911229
"id": "automation_3p",
1123011230
"icon": "automation_3p"
11231+
},
11232+
{
11233+
"id": "cursor_text",
11234+
"icon": "cursor_text"
11235+
},
11236+
{
11237+
"id": "rectangle_landscape_dash",
11238+
"icon": "rectangle_landscape_dash"
11239+
},
11240+
{
11241+
"id": "cursor_text_rectangle_landscape_dash",
11242+
"icon": "cursor_text_rectangle_landscape_dash"
1123111243
}
1123211244
]
1123311245
}

src/plugins/visualeditor/core/ArrangementPanelInterface.cpp

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,76 @@ namespace VisualEditor {
112112

113113
void ArrangementPanelInterfacePrivate::bindControllersInteraction() const {
114114
Q_Q(const ArrangementPanelInterface);
115-
// TODO select tool
116115
QObject::connect(q, &ArrangementPanelInterface::toolChanged, scrollBehaviorViewModel, [=, this] {
117116
switch (tool) {
118117
case ArrangementPanelInterface::PointerTool: {
118+
labelSequenceInteractionControllerOfLabel->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
119+
labelSequenceInteractionControllerOfLabel->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::CopyAndMove);
120+
labelSequenceInteractionControllerOfLabel->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
121+
labelSequenceInteractionControllerOfLabel->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
122+
123+
labelSequenceInteractionControllerOfTempo->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
124+
labelSequenceInteractionControllerOfTempo->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
125+
labelSequenceInteractionControllerOfTempo->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
126+
labelSequenceInteractionControllerOfTempo->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
127+
128+
trackListInteractionController->setPrimaryItemInteraction(sflow::TrackListInteractionController::DragMove);
129+
trackListInteractionController->setSecondaryItemInteraction(sflow::TrackListInteractionController::DragCopy);
130+
trackListInteractionController->setPrimarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
131+
trackListInteractionController->setSecondarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
132+
119133
clipPaneInteractionController->setPrimaryItemInteraction(sflow::ClipPaneInteractionController::Move);
120134
clipPaneInteractionController->setSecondaryItemInteraction(sflow::ClipPaneInteractionController::CopyAndMove);
121135
clipPaneInteractionController->setPrimarySceneInteraction(sflow::ClipPaneInteractionController::RubberBandSelect);
122136
clipPaneInteractionController->setSecondarySceneInteraction(sflow::ClipPaneInteractionController::TimeRangeSelect);
137+
break;
123138
}
124139
case ArrangementPanelInterface::PencilTool: {
140+
labelSequenceInteractionControllerOfLabel->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
141+
labelSequenceInteractionControllerOfLabel->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::CopyAndMove);
142+
labelSequenceInteractionControllerOfLabel->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
143+
labelSequenceInteractionControllerOfLabel->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
144+
145+
labelSequenceInteractionControllerOfTempo->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
146+
labelSequenceInteractionControllerOfTempo->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::Move);
147+
labelSequenceInteractionControllerOfTempo->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
148+
labelSequenceInteractionControllerOfTempo->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
149+
150+
trackListInteractionController->setPrimaryItemInteraction(sflow::TrackListInteractionController::DragMove);
151+
trackListInteractionController->setSecondaryItemInteraction(sflow::TrackListInteractionController::DragCopy);
152+
trackListInteractionController->setPrimarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
153+
trackListInteractionController->setSecondarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
154+
125155
clipPaneInteractionController->setPrimaryItemInteraction(sflow::ClipPaneInteractionController::Move);
126156
clipPaneInteractionController->setSecondaryItemInteraction(sflow::ClipPaneInteractionController::Draw);
127157
clipPaneInteractionController->setPrimarySceneInteraction(sflow::ClipPaneInteractionController::Draw);
128158
clipPaneInteractionController->setSecondarySceneInteraction(sflow::ClipPaneInteractionController::Draw);
159+
break;
160+
}
161+
case ArrangementPanelInterface::SelectTool: {
162+
labelSequenceInteractionControllerOfLabel->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
163+
labelSequenceInteractionControllerOfLabel->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
164+
labelSequenceInteractionControllerOfLabel->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
165+
labelSequenceInteractionControllerOfLabel->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
166+
167+
labelSequenceInteractionControllerOfTempo->setPrimaryItemInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
168+
labelSequenceInteractionControllerOfTempo->setSecondaryItemInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
169+
labelSequenceInteractionControllerOfTempo->setPrimarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
170+
labelSequenceInteractionControllerOfTempo->setSecondarySceneInteraction(sflow::LabelSequenceInteractionController::RubberBandSelect);
171+
172+
trackListInteractionController->setPrimaryItemInteraction(sflow::TrackListInteractionController::RubberBandSelect);
173+
trackListInteractionController->setSecondaryItemInteraction(sflow::TrackListInteractionController::RubberBandSelect);
174+
trackListInteractionController->setPrimarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
175+
trackListInteractionController->setSecondarySceneInteraction(sflow::TrackListInteractionController::RubberBandSelect);
176+
177+
clipPaneInteractionController->setPrimaryItemInteraction(sflow::ClipPaneInteractionController::RubberBandSelect);
178+
clipPaneInteractionController->setSecondaryItemInteraction(sflow::ClipPaneInteractionController::TimeRangeSelect);
179+
clipPaneInteractionController->setPrimarySceneInteraction(sflow::ClipPaneInteractionController::RubberBandSelect);
180+
clipPaneInteractionController->setSecondarySceneInteraction(sflow::ClipPaneInteractionController::TimeRangeSelect);
181+
break;
129182
}
130-
case ArrangementPanelInterface::HandTool: break;
183+
case ArrangementPanelInterface::HandTool:
184+
break;
131185
}
132186
});
133187
}

src/plugins/visualeditor/core/ArrangementPanelInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ namespace VisualEditor {
8181
enum Tool {
8282
PointerTool,
8383
PencilTool,
84+
SelectTool,
8485
HandTool,
8586
};
8687
Q_ENUM(Tool)

src/plugins/visualeditor/internal/addon/ArrangementAddOn.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ namespace VisualEditor::Internal {
6666
AdditionalTrackLoader *ArrangementAddOn::additionalTrackLoader() const {
6767
return m_additionalTrackLoader;
6868
}
69+
bool ArrangementAddOn::altPressed() const {
70+
return m_altPressed;
71+
}
6972
bool ArrangementAddOn::eventFilter(QObject *watched, QEvent *event) {
7073
if (watched == windowHandle()->window()) {
7174
switch (event->type()) {
@@ -75,13 +78,26 @@ namespace VisualEditor::Internal {
7578
break;
7679
}
7780
auto keyEvent = static_cast<QKeyEvent *>(event);
81+
if (keyEvent->isAutoRepeat()) {
82+
break;
83+
}
7884
if (keyEvent->key() == Qt::Key_Shift) {
7985
arrangementPanelInterface()->setSnapTemporarilyDisabled(keyEvent->type() == QEvent::KeyPress);
86+
} else if (keyEvent->key() == Qt::Key_Alt) {
87+
auto p = keyEvent->type() == QEvent::KeyPress;
88+
if (m_altPressed != p) {
89+
m_altPressed = p;
90+
Q_EMIT altPressedChanged();
91+
}
8092
}
8193
break;
8294
}
8395
case QEvent::FocusOut: {
8496
arrangementPanelInterface()->setSnapTemporarilyDisabled(false);
97+
if (m_altPressed) {
98+
m_altPressed = false;
99+
Q_EMIT altPressedChanged();
100+
}
85101
break;
86102
}
87103
default:

src/plugins/visualeditor/internal/addon/ArrangementAddOn.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace VisualEditor::Internal {
1515
Q_OBJECT
1616
Q_PROPERTY(VisualEditor::ArrangementPanelInterface *arrangementPanelInterface READ arrangementPanelInterface CONSTANT)
1717
Q_PROPERTY(AdditionalTrackLoader *additionalTrackLoader READ additionalTrackLoader CONSTANT)
18+
Q_PROPERTY(bool altPressed READ altPressed NOTIFY altPressedChanged)
1819
public:
1920
explicit ArrangementAddOn(QObject *parent = nullptr);
2021
~ArrangementAddOn() override;
@@ -29,8 +30,14 @@ namespace VisualEditor::Internal {
2930

3031
bool eventFilter(QObject *watched, QEvent *event) override;
3132

33+
bool altPressed() const;
34+
35+
Q_SIGNALS:
36+
void altPressedChanged();
37+
3238
private:
3339
AdditionalTrackLoader *m_additionalTrackLoader{};
40+
bool m_altPressed{};
3441

3542
};
3643

src/plugins/visualeditor/qml/actions/ArrangementAddOnActions.qml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ ActionCollection {
3939
}
4040
}
4141

42+
ActionItem {
43+
actionId: "org.diffscope.visualeditor.arrangementPanel.selectTool"
44+
Action {
45+
checkable: true
46+
checked: d.arrangementPanelInterface?.tool === ArrangementPanelInterface.SelectTool
47+
icon.source: d.addOn?.altPressed ? "image://fluent-system-icons/cursor_text_rectangle_landscape_dash" : "image://fluent-system-icons/rectangle_landscape_dash"
48+
onTriggered: () => {
49+
d.arrangementPanelInterface.tool = ArrangementPanelInterface.SelectTool
50+
Qt.callLater(() => GlobalHelper.setProperty(this, "checked", true))
51+
}
52+
}
53+
}
54+
4255
ActionItem {
4356
actionId: "org.diffscope.visualeditor.arrangementPanel.handTool"
4457
Action {

src/plugins/visualeditor/res/org.diffscope.visualeditor_actions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<items>
1818
<action id="org.diffscope.visualeditor.arrangementPanel.pointerTool" icon="cursor" />
1919
<action id="org.diffscope.visualeditor.arrangementPanel.pencilTool" icon="edit" />
20+
<action id="org.diffscope.visualeditor.arrangementPanel.selectTool" icon="rectangle_landscape_dash" />
2021
<action id="org.diffscope.visualeditor.arrangementPanel.handTool" icon="hand_left" />
2122
<action id="org.diffscope.visualeditor.mixerPanel.pointerTool" icon="cursor" />
2223
<action id="org.diffscope.visualeditor.mixerPanel.handTool" icon="hand_left" />
@@ -42,6 +43,7 @@
4243
<group id="org.diffscope.visualeditor.arrangementPanelToolBar.toolActions">
4344
<action id="org.diffscope.visualeditor.arrangementPanel.pointerTool" />
4445
<action id="org.diffscope.visualeditor.arrangementPanel.pencilTool" />
46+
<action id="org.diffscope.visualeditor.arrangementPanel.selectTool" />
4547
<action id="org.diffscope.visualeditor.arrangementPanel.handTool" />
4648
</group>
4749
<group id="org.diffscope.visualeditor.arrangementPanelToolBar.snapActions">

0 commit comments

Comments
 (0)