Debian Codegraph @

au4/src/projectscene/qml/Audacity/ProjectScene/toolbars/PlaybackToolBar.qml

raw
1 /*
2 * Audacity: A Digital Audio Editor
3 */
4 import QtQuick 2.15
5
6 import Muse.Ui 1.0
7 import Muse.UiComponents 1.0
8
9 import Audacity.Playback 1.0
10 import Audacity.Record 1.0
11 import Audacity.ProjectScene 1.0
12
13 import "internal"
14
15 Item {
16 id: root
17
18 property bool floating: false
19
20 property int maximumWidth: 0
21 property int maximumHeight: 0
22
23 property alias navigationPanel: view.navigationPanel
24
25 width: view.width + /*spacing*/ 4 + customizeButton.width
26 height: 48 // todo
27
28 StyledToolBarView {
29 id: view
30
31 anchors.verticalCenter: parent.verticalCenter
32
33 rowHeight: root.height - view.spacing - 1
34
35 model: PlaybackToolBarModel {}
36
37 sourceComponentCallback: function(type) {
38 switch(type) {
39 case PlaybackToolBarModel.PLAYBACK_CONTROL: return controlComp
40 case PlaybackToolBarModel.PLAYBACK_LEVEL: return playbackLevelComp
41 case PlaybackToolBarModel.PLAYBACK_TIME: return playbackTimeComp
42 case PlaybackToolBarModel.PLAYBACK_BPM: return playbackBPMComp
43 case PlaybackToolBarModel.PLAYBACK_TIME_SIGNATURE: return playbackTimeSignatureComp
44 case PlaybackToolBarModel.RECORD_LEVEL: return recordLevelComp
45 case PlaybackToolBarModel.PROJECT_CONTROL: return projectControlComp
46 case PlaybackToolBarModel.SNAP: return snapComp
47 }
48
49 return null
50 }
51
52 Component {
53 id: controlComp
54
55 StyledToolBarItem {
56 width: 32
57 height: width
58
59 iconColor: Boolean(itemData) ? itemData.iconColor : ui.theme.fontPrimaryColor
60 accentColor: Boolean(itemData) ? itemData.backgroundColor : ui.theme.buttonColor
61 accentButton: Boolean(itemData) ? itemData.selected : false
62 }
63 }
64
65 Component {
66 id: projectControlComp
67
68 StyledToolBarItem {
69 width: 28
70 height: width
71 }
72 }
73
74 Component {
75 id: playbackLevelComp
76
77 PlaybackLevel {
78 property var itemData: null
79
80 width: 240
81 height: 28
82
83 volumeLevel: Boolean(itemData) ? itemData.level : 0
84 leftCurrentVolumePressure: Boolean(itemData) ? itemData.leftChannelPressure : 0
85 rightCurrentVolumePressure: Boolean(itemData) ? itemData.rightChannelPressure : 0
86
87 enabled: Boolean(itemData) ? itemData.enabled : false
88
89 onVolumeLevelChangeRequested: function(level) {
90 itemData.level = level
91 }
92 }
93 }
94
95 Component {
96 id: playbackTimeComp
97
98 Timecode {
99 property var itemData: null
100
101 value: Boolean(itemData) ? itemData.currentValue : 0
102
103 sampleRate: Boolean(itemData) ? itemData.sampleRate : 0
104 tempo: Boolean(itemData) ? itemData.tempo : 0
105 upperTimeSignature: Boolean(itemData) ? itemData.upperTimeSignature : 0
106 lowerTimeSignature: Boolean(itemData) ? itemData.lowerTimeSignature : 0
107
108 currentFormat: Boolean(itemData) ? itemData.currentFormat : 0
109
110 enabled: Boolean(itemData) ? itemData.enabled : false
111
112 onValueChangeRequested: function(newValue) {
113 if (!Boolean(itemData)) {
114 return
115 }
116
117 itemData.currentValue = newValue
118 }
119
120 onCurrentFormatChanged: {
121 if (!Boolean(itemData)) {
122 return
123 }
124
125 itemData.currentFormat = currentFormat
126 }
127 }
128 }
129
130 Component {
131 id: playbackBPMComp
132
133 BPM {
134 property var itemData: null
135
136 value: Boolean(itemData) ? itemData.currentValue : 0
137
138 enabled: Boolean(itemData) ? itemData.enabled : false
139
140 onValueChangeRequested: function(newValue) {
141 if (!Boolean(itemData)) {
142 return
143 }
144
145 itemData.currentValue = newValue
146 }
147 }
148 }
149
150 Component {
151 id: playbackTimeSignatureComp
152
153 TimeSignature {
154 property var itemData: null
155
156 upper: Boolean(itemData) ? itemData.upper : 0
157 lower: Boolean(itemData) ? itemData.lower : 0
158
159 enabled: Boolean(itemData) ? itemData.enabled : false
160
161 onUpperChangeRequested: function(newValue) {
162 if (!Boolean(itemData)) {
163 return
164 }
165
166 itemData.upper = newValue
167 }
168
169 onLowerChangeRequested: function(newValue) {
170 if (!Boolean(itemData)) {
171 return
172 }
173
174 itemData.lower = newValue
175 }
176 }
177 }
178
179 Component {
180 id: recordLevelComp
181
182 RecordLevel {
183 property var itemData: null
184
185 width: 28
186 height: width
187
188 icon: Boolean(itemData) ? itemData.icon : IconCode.NONE
189
190 toolTipTitle: Boolean(itemData) ? itemData.title : ""
191 toolTipDescription: Boolean(itemData) ? itemData.description : ""
192
193 volumeLevel: Boolean(itemData) ? itemData.level : 0
194 leftCurrentVolumePressure: Boolean(itemData) ? itemData.leftChannelPressure : 0
195 rightCurrentVolumePressure: Boolean(itemData) ? itemData.rightChannelPressure : 0
196
197 enabled: Boolean(itemData) ? itemData.enabled : false
198
199 onVolumeLevelChangeRequested: function(level) {
200 itemData.level = level
201 }
202 }
203 }
204
205 Component {
206 id: snapComp
207
208 Snap {
209 property var itemData: null
210
211 width: 143
212 height: 28
213
214 isSnapEnabled: Boolean(itemData) ? itemData.isSnapEnabled : false
215 currentSnapMode: Boolean(itemData) ? itemData.currentValue : ""
216 contextMenuModel: Boolean(itemData) ? itemData.availableSnapTypes : null
217
218 enabled: Boolean(itemData) ? itemData.enabled : false
219
220 onSnapEnableChangeRequested: function(enabled) {
221 itemData.isSnapEnabled = enabled
222 }
223
224 onHandleMenuItem: function(itemId) {
225 itemData.handleMenuItem(itemId)
226 }
227 }
228 }
229 }
230
231 FlatButton {
232 id: customizeButton
233
234 anchors.margins: 4
235 anchors.left: view.right
236 anchors.verticalCenter: root.verticalCenter
237
238 width: 28
239 height: width
240
241 icon: IconCode.SETTINGS_COG
242 iconFont: ui.theme.toolbarIconsFont
243 toolTipTitle: qsTrc("projectscene", "Customize toolbar")
244 toolTipDescription: qsTrc("projectscene", "Show/hide toolbar buttons")
245
246 enabled: view.model.isEnabled
247
248 navigation.panel: root.navigationPanel
249 navigation.order: 100
250 navigation.accessible.name: qsTrc("projectscene", "Customize toolbar")
251
252 onClicked: {
253 customizePopup.toggleOpened()
254 }
255
256 PlaybackToolBarCustomisePopup {
257 id: customizePopup
258
259 anchorItem: !root.floating ? ui.rootItem : null
260 }
261 }
262 }