Skip to content

Commit

Permalink
Add vertical offset parameter to the No Sync filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Jan 21, 2025
1 parent 3116a70 commit 753fa37
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/qml/filters/nosync/meta.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ Metadata {
keyframes {
allowAnimateIn: true
allowAnimateOut: true
simpleProperties: ['0']
simpleProperties: ['0', '1']
parameters: [
Parameter {
name: qsTr('Offset')
name: qsTr('H Offset')
property: '0'
isCurve: true
minimum: 0
maximum: 1
},
Parameter {
name: qsTr('V Offset')
property: '1'
isCurve: true
minimum: 0
maximum: 1
}
]
}
Expand Down
51 changes: 44 additions & 7 deletions src/qml/filters/nosync/ui.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 Meltytech, LLC
* Copyright (c) 2019-2024 Meltytech, LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,34 +22,41 @@ import Shotcut.Controls as Shotcut
Shotcut.KeyframableFilter {
property string horizontal: '0'
property double horizontalDefault: 0.2
property string vertical: '1'
property double verticalDefault: 0.0

function setControls() {
var position = getPosition();
blockUpdate = true;
horizontalSlider.value = filter.getDouble(horizontal, position) * horizontalSlider.maximumValue;
horizontalKeyframesButton.checked = filter.animateIn <= 0 && filter.animateOut <= 0 && filter.keyframeCount(horizontal) > 0;
verticalSlider.value = filter.getDouble(vertical, position) * verticalSlider.maximumValue;
verticalKeyframesButton.checked = filter.animateIn <= 0 && filter.animateOut <= 0 && filter.keyframeCount(vertical) > 0;
blockUpdate = false;
enableControls(isSimpleKeyframesActive());
}

function enableControls(enabled) {
horizontalSlider.enabled = enabled;
verticalSlider.enabled = enabled;
}

function updateSimpleKeyframes() {
setControls();
updateFilter(horizontal, horizontalSlider.value / horizontalSlider.maximumValue, horizontalKeyframesButton, null);
updateFilter(vertical, verticalSlider.value / verticalSlider.maximumValue, verticalKeyframesButton, null);
}

keyframableParameters: [horizontal]
startValues: [0]
middleValues: [horizontalDefault]
endValues: [0]
keyframableParameters: [horizontal, vertical]
startValues: [0, 0]
middleValues: [horizontalDefault, verticalDefault]
endValues: [0, 0]
width: 350
height: 100
Component.onCompleted: {
if (filter.isNew) {
filter.set(horizontal, horizontalDefault);
filter.set(vertical, verticalDefault);
filter.savePreset(preset.parameters);
}
setControls();
Expand All @@ -68,10 +75,11 @@ Shotcut.KeyframableFilter {
Shotcut.Preset {
id: preset

parameters: [horizontal]
parameters: [horizontal, vertical]
Layout.columnSpan: 3
onBeforePresetLoaded: {
filter.resetProperty(horizontal);
filter.resetProperty(vertical);
}
onPresetSelected: {
setControls();
Expand All @@ -80,7 +88,7 @@ Shotcut.KeyframableFilter {
}

Label {
text: qsTr('Offset')
text: qsTr('Horizontal Offset')
Layout.alignment: Qt.AlignRight
}

Expand Down Expand Up @@ -108,6 +116,35 @@ Shotcut.KeyframableFilter {
}
}

Label {
text: qsTr('Vertical Offset')
Layout.alignment: Qt.AlignRight
}

Shotcut.SliderSpinner {
id: verticalSlider

minimumValue: 0
maximumValue: 100
stepSize: 0.01
decimals: 2
suffix: ' %'
onValueChanged: updateFilter(vertical, verticalSlider.value / verticalSlider.maximumValue, verticalKeyframesButton, getPosition())
}

Shotcut.UndoButton {
onClicked: verticalSlider.value = verticalDefault * verticalSlider.maximumValue
}

Shotcut.KeyframesButton {
id: verticalKeyframesButton

onToggled: {
enableControls(true);
toggleKeyframes(checked, vertical, verticalSlider.value / verticalSlider.maximumValue);
}
}

Item {
Layout.fillHeight: true
}
Expand Down

0 comments on commit 753fa37

Please sign in to comment.