| 1 |
/* |
| 2 |
* Audacity: A Digital Audio Editor |
| 3 |
*/ |
| 4 |
import QtQuick |
| 5 |
import QtQuick.Controls |
| 6 |
import QtQuick.Layouts |
| 7 |
|
| 8 |
import Muse.Ui |
| 9 |
import Muse.UiComponents |
| 10 |
|
| 11 |
import Audacity.ProjectScene |
| 12 |
|
| 13 |
import "audio" |
| 14 |
|
| 15 |
ListItemBlank { |
| 16 |
id: root |
| 17 |
|
| 18 |
property var item: null |
| 19 |
|
| 20 |
signal interactionStarted() |
| 21 |
signal interactionEnded() |
| 22 |
|
| 23 |
property NavigationPanel navigationPanel: NavigationPanel { |
| 24 |
name: "Track" + root.item.title + "Panel" |
| 25 |
enabled: root.enabled && root.visible |
| 26 |
direction: NavigationPanel.Horizontal |
| 27 |
onActiveChanged: function(active) { |
| 28 |
if (active) { |
| 29 |
root.forceActiveFocus() |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
height: trackViewState.trackHeight |
| 35 |
clip: true |
| 36 |
|
| 37 |
signal duplicateRequested() |
| 38 |
signal deleteRequested() |
| 39 |
|
| 40 |
signal openEffectsRequested() |
| 41 |
|
| 42 |
TracksViewStateModel { |
| 43 |
id: trackViewState |
| 44 |
trackId: root.item ? root.item.trackId : -1 |
| 45 |
} |
| 46 |
|
| 47 |
Component.onCompleted: { |
| 48 |
trackViewState.init() |
| 49 |
} |
| 50 |
|
| 51 |
RowLayout { |
| 52 |
anchors.fill: parent |
| 53 |
|
| 54 |
spacing: 0 |
| 55 |
|
| 56 |
TrackSelectionBar { |
| 57 |
id: selectionBar |
| 58 |
isSelected: root.isSelected |
| 59 |
} |
| 60 |
|
| 61 |
ColumnLayout { |
| 62 |
Layout.topMargin: 7 |
| 63 |
Layout.margins: 12 |
| 64 |
Layout.alignment: Qt.AlignTop |
| 65 |
spacing: 2 |
| 66 |
|
| 67 |
RowLayout { |
| 68 |
Layout.fillWidth: true |
| 69 |
|
| 70 |
spacing: 8 |
| 71 |
|
| 72 |
StyledIconLabel { |
| 73 |
iconCode: IconCode.MICROPHONE |
| 74 |
} |
| 75 |
|
| 76 |
StyledTextLabel { |
| 77 |
Layout.fillWidth: true |
| 78 |
|
| 79 |
text: root.item.title |
| 80 |
font: ui.theme.bodyBoldFont |
| 81 |
horizontalAlignment: Text.AlignLeft |
| 82 |
} |
| 83 |
|
| 84 |
MenuButton { |
| 85 |
Component.onCompleted: { |
| 86 |
var operations = [ |
| 87 |
{ "id": "duplicate", "title": qsTrc("track", "Duplicate") }, |
| 88 |
{ "id": "delete", "title": qsTrc("track", "Delete") } |
| 89 |
] |
| 90 |
|
| 91 |
menuModel = operations |
| 92 |
} |
| 93 |
|
| 94 |
onHandleMenuItem: function(itemId) { |
| 95 |
switch(itemId) { |
| 96 |
case "duplicate": |
| 97 |
root.duplicateRequested() |
| 98 |
break |
| 99 |
case "delete": |
| 100 |
root.deleteRequested() |
| 101 |
break |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
RowLayout { |
| 108 |
Layout.fillWidth: true |
| 109 |
|
| 110 |
spacing: 16 |
| 111 |
|
| 112 |
BalanceKnob { |
| 113 |
value: root.item.balance |
| 114 |
|
| 115 |
onNewValueRequested: function(newValue) { |
| 116 |
root.item.balance = newValue |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
VolumeSlider { |
| 121 |
value: root.item.volumeLevel |
| 122 |
|
| 123 |
onValueChanged: { |
| 124 |
root.item.volumeLevel = value |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
RowLayout { |
| 129 |
Layout.fillWidth: true |
| 130 |
|
| 131 |
spacing: 4 |
| 132 |
|
| 133 |
FlatToggleButton { |
| 134 |
Layout.preferredWidth: 20 |
| 135 |
Layout.preferredHeight: Layout.preferredWidth |
| 136 |
|
| 137 |
icon: IconCode.MUTE |
| 138 |
checked: root.item.muted |
| 139 |
|
| 140 |
onToggled: { |
| 141 |
root.item.muted = !checked |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
FlatToggleButton { |
| 146 |
Layout.preferredWidth: 20 |
| 147 |
Layout.preferredHeight: Layout.preferredWidth |
| 148 |
|
| 149 |
icon: IconCode.SOLO |
| 150 |
checked: root.item.solo |
| 151 |
|
| 152 |
onToggled: { |
| 153 |
root.item.solo = !checked |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
FlatButton { |
| 160 |
Layout.fillWidth: true |
| 161 |
Layout.preferredHeight: 24 |
| 162 |
Layout.margins: 4 |
| 163 |
|
| 164 |
text: qsTrc("projectscene", "Effects") |
| 165 |
|
| 166 |
onClicked: { |
| 167 |
root.openEffectsRequested() |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
SeparatorLine {} |
| 173 |
|
| 174 |
Row { |
| 175 |
id: volumePressureContainer |
| 176 |
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter |
| 177 |
Layout.preferredWidth: 24 |
| 178 |
Layout.preferredHeight: root.height |
| 179 |
topPadding: 5 |
| 180 |
|
| 181 |
spacing: 2 |
| 182 |
Repeater { |
| 183 |
id: volumePressureMeters |
| 184 |
model: root.item.channelCount |
| 185 |
VolumePressureMeter { |
| 186 |
height: root.height |
| 187 |
currentVolumePressure: index === 0 ? root.item.leftChannelPressure : |
| 188 |
root.item.rightChannelPressure |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
states: [ |
| 193 |
State { |
| 194 |
when: root.item.channelCount === 1 |
| 195 |
name: "mono" |
| 196 |
PropertyChanges { |
| 197 |
target: volumePressureContainer |
| 198 |
leftPadding: 8 |
| 199 |
} |
| 200 |
PropertyChanges { |
| 201 |
target: volumePressureMeters.itemAt(0) |
| 202 |
indicatorWidth: 8 |
| 203 |
} |
| 204 |
}, |
| 205 |
State { |
| 206 |
when: root.item.channelCount === 2 |
| 207 |
name: "stereo" |
| 208 |
PropertyChanges { |
| 209 |
target: volumePressureContainer |
| 210 |
leftPadding: 4 |
| 211 |
} |
| 212 |
PropertyChanges { |
| 213 |
target: volumePressureMeters.itemAt(0) |
| 214 |
indicatorWidth: 7 |
| 215 |
} |
| 216 |
PropertyChanges { |
| 217 |
target: volumePressureMeters.itemAt(1) |
| 218 |
indicatorWidth: 7 |
| 219 |
} |
| 220 |
} |
| 221 |
] |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
MouseArea { |
| 226 |
id: dragArea |
| 227 |
|
| 228 |
anchors.left: parent.left |
| 229 |
anchors.right: parent.right |
| 230 |
anchors.bottom: parent.bottom |
| 231 |
height: 4 |
| 232 |
|
| 233 |
cursorShape: Qt.SizeVerCursor |
| 234 |
|
| 235 |
onPressed: { |
| 236 |
root.interactionStarted() |
| 237 |
} |
| 238 |
|
| 239 |
onPositionChanged: function(mouse) { |
| 240 |
mouse.accepted = true |
| 241 |
trackViewState.changeTrackHeight(mouse.y) |
| 242 |
} |
| 243 |
|
| 244 |
onReleased: { |
| 245 |
root.interactionEnded() |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
SeparatorLine { |
| 250 |
anchors.bottom: parent.bottom |
| 251 |
thickness: 2 |
| 252 |
} |
| 253 |
} |