@@ -9,65 +9,65 @@ Rectangle {
99 RowLayout {
1010 anchors.fill: parent
1111 spacing: 2
12- ScrollView {
13- id: songScrollView
12+ ListView {
13+ id: songListView
1414 Layout.fillWidth: true
1515 Layout.fillHeight: true
16- ScrollBar.vertical.policy: ScrollBar.AlwaysOff
17- ScrollBar.horizontal.policy: ScrollBar.AsNeeded
18- Row {
19- id: patternRow
20- spacing: 2
21- property real patternSize: rootItem.height
22- property real contentWidth: patternSize * editorService.songLength + spacing * (editorService.songLength - 1)
23- width: contentWidth
24- height: rootItem.height
25- Repeater {
26- model: editorService.songLength
27- delegate: Rectangle {
28- id: patternRect
29- width: patternRow.patternSize
30- height: patternRow.patternSize
31- color: index % 4 < 2 ? "#4A4A4A" : "#5A5A5A"
32- border.color: "#888888"
33- border.width: 1
34- Text {
35- id: textField
36- anchors.centerIn: parent
37- text: editorService.patternAtSongPosition(index)
38- color: editorService.songPosition === index ? "orange" : "white"
39- font.pixelSize: 14
40- font.bold: true
41- }
42- MouseArea {
43- id: patternMouseArea
44- anchors.fill: parent
45- hoverEnabled: true
46- cursorShape: Qt.PointingHandCursor
47- onClicked: if (!UiService.isPlaying()) {
48- editorService.setSongPosition(index);
16+ orientation: ListView.Horizontal
17+ spacing: 2
18+ model: editorService.songLength
19+ clip: true
20+ currentIndex: editorService.songPosition
21+ onCurrentIndexChanged: {
22+ if (songListView.currentIndex >= 0) {
23+ songListView.positionViewAtIndex(songListView.currentIndex, ListView.Contain);
24+ }
25+ }
26+ delegate: Rectangle {
27+ id: patternRect
28+ width: songListView.height
29+ height: songListView.height
30+ color: index % 4 < 2 ? "#4A4A4A" : "#5A5A5A"
31+ border.color: "#888888"
32+ border.width: 1
33+ Text {
34+ id: textField
35+ anchors.centerIn: parent
36+ text: editorService.patternAtSongPosition(index)
37+ color: editorService.songPosition === index ? "orange" : "white"
38+ font.pixelSize: 14
39+ font.bold: true
40+ }
41+ MouseArea {
42+ id: patternMouseArea
43+ anchors.fill: parent
44+ hoverEnabled: true
45+ cursorShape: Qt.PointingHandCursor
46+ onClicked: if (!UiService.isPlaying()) {
47+ editorService.setSongPosition(index);
48+ }
49+ states: [
50+ State {
51+ when: patternMouseArea.containsMouse
52+ PropertyChanges {
53+ target: patternRect
54+ color: "#777777"
4955 }
50- states: [
51- State {
52- when: patternMouseArea.containsMouse
53- PropertyChanges {
54- target: patternRect
55- color: "#777777"
56- }
57- }
58- ]
5956 }
60- Connections {
61- target: editorService
62- function onPatternAtCurrentSongPositionChanged() {
63- if ( editorService.songPosition === index) {
64- textField.text = editorService.patternAtSongPosition(index);
65- }
66- }
57+ ]
58+ }
59+ Connections {
60+ target: editorService
61+ function onPatternAtCurrentSongPositionChanged() {
62+ if (editorService.songPosition === index) {
63+ textField.text = editorService.patternAtSongPosition(index);
6764 }
6865 }
6966 }
7067 }
68+ ScrollBar.horizontal: ScrollBar {
69+ policy: ScrollBar.AsNeeded
70+ }
7171 }
7272 Rectangle {
7373 Layout.preferredWidth: rootItem.height
@@ -93,4 +93,4 @@ Rectangle {
9393 ToolTip.timeout: Constants.toolTipTimeout
9494 }
9595 }
96- }
96+ }
0 commit comments