Skip to content

Commit 21bcfee

Browse files
committed
Update arrangement functionalities
1 parent f7d1739 commit 21bcfee

20 files changed

+467
-46
lines changed

src/plugins/coreplugin/internal/addon/WorkspaceAddOn.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,10 @@ namespace Core::Internal {
137137
if (i == spec.visibleIndex || opened) {
138138
visibleIndices.append(result.size());
139139
}
140-
if (data.isValid()) {
141-
object->setProperty("panelPersistentData", data);
142-
}
143140
result.append(QVariantMap{
144141
{"object", QVariant::fromValue(object)},
145142
{"geometry", geometry},
143+
{"state", data}
146144
});
147145
}
148146
}

src/plugins/coreplugin/qml/windows/WorkspaceAddOnHelper.qml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,16 @@ QtObject {
104104
}
105105
return v.object
106106
}
107+
const loadState = v => {
108+
try {
109+
v.object.loadState(v.state)
110+
console.debug(lcWorkspaceAddOnHelper, "State loaded:", v.object, v.object.ActionInstantiator.id)
111+
} catch (e) {
112+
}
113+
}
107114
const f = (dockingView, edge) => {
108115
let o = addOn.createDockingViewContents(edge)
116+
o.objects.forEach(loadState)
109117
dockingView.contentData = o.objects.map(conv)
110118
dockingView.preferredPanelSize = o.preferredPanelSize
111119
dockingView.splitterRatio = o.splitterRatio
@@ -118,8 +126,10 @@ QtObject {
118126

119127
let topData = addOn.createDockingViewContents(Qt.TopEdge)
120128
let bottomData = addOn.createDockingViewContents(Qt.BottomEdge)
129+
topData.objects.forEach(loadState)
121130
window.topDockingView.contentData = topData.objects.map(conv)
122131
window.topDockingView.splitterRatio = topData.splitterRatio
132+
bottomData.objects.forEach(loadState)
123133
window.bottomDockingView.contentData = bottomData.objects.map(conv)
124134
window.bottomDockingView.splitterRatio = bottomData.splitterRatio
125135
window.topDockingViewHeightRatio = topData.preferredPanelSize
@@ -140,6 +150,15 @@ QtObject {
140150
console.info(lcWorkspaceAddOnHelper, "Saving current layout")
141151
savingCurrentLayout = true
142152
let viewSpecMap = []
153+
const saveState = o => {
154+
try {
155+
let state = o.saveState()
156+
console.debug(lcWorkspaceAddOnHelper, "State saved:", o, o.ActionInstantiator.id)
157+
return state
158+
} catch (e) {
159+
return undefined
160+
}
161+
}
143162
const f = (dockingView, isLeftOrRight, firstKey, lastKey) => {
144163
console.debug(lcWorkspaceAddOnHelper, "Saving docking view", firstKey);
145164
viewSpecMap[firstKey] = {
@@ -150,7 +169,7 @@ QtObject {
150169
dock: o.dock,
151170
opened: o.Docking.window?.visible ?? false,
152171
geometry: Qt.rect(o.Docking.window?.x ?? 0, o.Docking.window?.y ?? 0, o.Docking.window?.width ?? 0, o.Docking.window?.height ?? 0),
153-
data: o.panelPersistentData
172+
data: saveState(o)
154173
}
155174
console.debug(lcWorkspaceAddOnHelper, "Handled panel spec",o , v.id, v.dock, v.opened, v.geometry, v.data)
156175
return v
@@ -169,7 +188,7 @@ QtObject {
169188
dock: o.dock,
170189
opened: o.Docking.window?.visible ?? false,
171190
geometry: Qt.rect(o.Docking.window?.x ?? 0, o.Docking.window?.y ?? 0, o.Docking.window?.width ?? 0, o.Docking.window?.height ?? 0),
172-
data: o.panelPersistentData
191+
data: saveState(o)
173192
}
174193
console.debug(lcWorkspaceAddOnHelper, "Handled panel spec",o , v.id, v.dock, v.opened, v.geometry, v.data)
175194
return v

src/plugins/visualeditor/core/ArrangementPanelInterface.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <coreplugin/ProjectWindowInterface.h>
1717
#include <coreplugin/ProjectTimeline.h>
1818

19+
#include <visualeditor/AutoPageScrollingManipulator.h>
1920
#include <visualeditor/PositionAlignmentManipulator.h>
2021
#include <visualeditor/ProjectViewModelContext.h>
2122
#include <visualeditor/internal/EditorPreference.h>
@@ -88,6 +89,22 @@ namespace VisualEditor {
8889
});
8990
}
9091

92+
void ArrangementPanelInterfacePrivate::bindPositionAlignmentManipulator() const {
93+
Q_Q(const ArrangementPanelInterface);
94+
positionAlignmentManipulator->setAutoDurationPositionAlignment(Internal::EditorPreference::autoDurationPositionAlignment());
95+
QObject::connect(Internal::EditorPreference::instance(), &Internal::EditorPreference::autoDurationPositionAlignmentChanged, positionAlignmentManipulator, [=, this] {
96+
positionAlignmentManipulator->setAutoDurationPositionAlignment(Internal::EditorPreference::autoDurationPositionAlignment());
97+
});
98+
QObject::connect(q, &ArrangementPanelInterface::snapTemporarilyDisabledChanged, positionAlignmentManipulator, [=, this] {
99+
if (isSnapTemporarilyDisabled) {
100+
previousDuration = positionAlignmentManipulator->duration();
101+
positionAlignmentManipulator->setDuration(PositionAlignmentManipulator::Unset);
102+
} else {
103+
positionAlignmentManipulator->setDuration(previousDuration);
104+
}
105+
});
106+
}
107+
91108
ArrangementPanelInterface::ArrangementPanelInterface(Core::ProjectWindowInterface *windowHandle) : QObject(windowHandle), d_ptr(new ArrangementPanelInterfacePrivate) {
92109
Q_D(ArrangementPanelInterface);
93110
Q_ASSERT(windowHandle->getObjects(staticMetaObject.className()).isEmpty());
@@ -102,6 +119,11 @@ namespace VisualEditor {
102119

103120
d->positionAlignmentManipulator = new PositionAlignmentManipulator(this);
104121
d->positionAlignmentManipulator->setTimeLayoutViewModel(d->timeLayoutViewModel);
122+
d->autoPageScrollingManipulator = new AutoPageScrollingManipulator(this);
123+
d->autoPageScrollingManipulator->setEnabled(true);
124+
d->autoPageScrollingManipulator->setTimeViewModel(d->timeViewModel);
125+
d->autoPageScrollingManipulator->setTimeLayoutViewModel(d->timeLayoutViewModel);
126+
d->autoPageScrollingManipulator->setPlaybackViewModel(ProjectViewModelContext::of(d->windowHandle)->playbackViewModel());
105127

106128
QQmlComponent component(Core::RuntimeInterface::qmlEngine(), "DiffScope.VisualEditor", "ArrangementView");
107129
if (component.isError()) {
@@ -118,10 +140,13 @@ namespace VisualEditor {
118140
d->arrangementView = qobject_cast<QQuickItem *>(o);
119141
Q_ASSERT(d->arrangementView);
120142

143+
d->autoPageScrollingManipulator->setTarget(d->arrangementView->property("timeline").value<QQuickItem *>());
144+
121145
d->bindTimeViewModel();
122146
d->bindTimeLayoutViewModel();
123147
d->bindTimelineInteractionController();
124148
d->bindScrollBehaviorViewModel();
149+
d->bindPositionAlignmentManipulator();
125150
}
126151

127152
ArrangementPanelInterface::~ArrangementPanelInterface() = default;
@@ -157,6 +182,11 @@ namespace VisualEditor {
157182
return d->positionAlignmentManipulator;
158183
}
159184

185+
AutoPageScrollingManipulator *ArrangementPanelInterface::autoPageScrollingManipulator() const {
186+
Q_D(const ArrangementPanelInterface);
187+
return d->autoPageScrollingManipulator;
188+
}
189+
160190
QQuickItem *ArrangementPanelInterface::arrangementView() const {
161191
Q_D(const ArrangementPanelInterface);
162192
return d->arrangementView;
@@ -175,6 +205,19 @@ namespace VisualEditor {
175205
}
176206
}
177207

208+
bool ArrangementPanelInterface::isSnapTemporarilyDisabled() const {
209+
Q_D(const ArrangementPanelInterface);
210+
return d->isSnapTemporarilyDisabled;
211+
}
212+
213+
void ArrangementPanelInterface::setSnapTemporarilyDisabled(bool disabled) {
214+
Q_D(ArrangementPanelInterface);
215+
if (d->isSnapTemporarilyDisabled != disabled) {
216+
d->isSnapTemporarilyDisabled = disabled;
217+
Q_EMIT snapTemporarilyDisabledChanged();
218+
}
219+
}
220+
178221
}
179222

180-
#include "moc_ArrangementPanelInterface.cpp"
223+
#include "moc_ArrangementPanelInterface.cpp"

src/plugins/visualeditor/core/ArrangementPanelInterface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace VisualEditor {
2626
}
2727

2828
class PositionAlignmentManipulator;
29+
class AutoPageScrollingManipulator;
2930

3031
class ArrangementPanelInterfacePrivate;
3132

@@ -40,8 +41,10 @@ namespace VisualEditor {
4041
Q_PROPERTY(sflow::ScrollBehaviorViewModel *scrollBehaviorViewModel READ scrollBehaviorViewModel CONSTANT)
4142
Q_PROPERTY(sflow::TimelineInteractionController *timelineInteractionController READ timelineInteractionController CONSTANT)
4243
Q_PROPERTY(PositionAlignmentManipulator *positionAlignmentManipulator READ positionAlignmentManipulator CONSTANT)
44+
Q_PROPERTY(AutoPageScrollingManipulator *autoPageScrollingManipulator READ autoPageScrollingManipulator CONSTANT)
4345
Q_PROPERTY(QQuickItem *arrangementView READ arrangementView CONSTANT)
4446
Q_PROPERTY(Tool tool READ tool WRITE setTool NOTIFY toolChanged)
47+
Q_PROPERTY(bool snapTemporarilyDisabled READ isSnapTemporarilyDisabled WRITE setSnapTemporarilyDisabled NOTIFY snapTemporarilyDisabledChanged)
4548

4649
public:
4750
~ArrangementPanelInterface() override;
@@ -56,6 +59,7 @@ namespace VisualEditor {
5659
sflow::TimelineInteractionController *timelineInteractionController() const;
5760

5861
PositionAlignmentManipulator *positionAlignmentManipulator() const;
62+
AutoPageScrollingManipulator *autoPageScrollingManipulator() const;
5963

6064
QQuickItem *arrangementView() const;
6165

@@ -68,8 +72,12 @@ namespace VisualEditor {
6872
Tool tool() const;
6973
void setTool(Tool tool);
7074

75+
bool isSnapTemporarilyDisabled() const;
76+
void setSnapTemporarilyDisabled(bool disabled);
77+
7178
Q_SIGNALS:
7279
void toolChanged();
80+
void snapTemporarilyDisabledChanged();
7381

7482
private:
7583
friend class Internal::ArrangementAddOn;

src/plugins/visualeditor/core/ArrangementPanelInterface_p.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define DIFFSCOPE_VISUALEDITOR_ARRANGEMENTPANELINTERFACE_P_H
33

44
#include <visualeditor/ArrangementPanelInterface.h>
5+
#include <visualeditor/PositionAlignmentManipulator.h>
56

67
namespace VisualEditor {
78

@@ -17,15 +18,20 @@ namespace VisualEditor {
1718
sflow::ScrollBehaviorViewModel *scrollBehaviorViewModel;
1819

1920
PositionAlignmentManipulator *positionAlignmentManipulator;
21+
AutoPageScrollingManipulator *autoPageScrollingManipulator;
2022

2123
QQuickItem *arrangementView;
2224

2325
ArrangementPanelInterface::Tool tool{ArrangementPanelInterface::PointerTool};
26+
bool isSnapTemporarilyDisabled{false};
27+
28+
mutable PositionAlignmentManipulator::Duration previousDuration{};
2429

2530
void bindTimeViewModel() const;
2631
void bindTimeLayoutViewModel() const;
2732
void bindTimelineInteractionController() const;
2833
void bindScrollBehaviorViewModel() const;
34+
void bindPositionAlignmentManipulator() const;
2935
};
3036

3137
}

0 commit comments

Comments
 (0)