Skip to content

Commit

Permalink
fix required changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-shinde-442 committed Dec 5, 2024
1 parent 9cd1188 commit b519dfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ Item {
TreeView {
id: instrumentsTreeView

readonly property real delegateHeight: 38

anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
Expand Down Expand Up @@ -184,11 +186,11 @@ Item {
}

function scrollToFocusedItem(focusedIndex) {
let targetScrollPosition = focusedIndex * 38
let targetScrollPosition = focusedIndex * instrumentsTreeView.delegateHeight
let visibleAreaEnd = flickable.contentY + flickable.height

if (targetScrollPosition + 38 > visibleAreaEnd) {
flickable.contentY = Math.min(targetScrollPosition + 38 - flickable.height, flickable.contentHeight - flickable.height)
if (targetScrollPosition + instrumentsTreeView.delegateHeight > visibleAreaEnd) {
flickable.contentY = Math.min(targetScrollPosition + instrumentsTreeView.delegateHeight - flickable.height, flickable.contentHeight - flickable.height)
} else if (targetScrollPosition < flickable.contentY) {
flickable.contentY = Math.max(targetScrollPosition, 0)
}
Expand Down Expand Up @@ -230,7 +232,7 @@ Item {
backgroundColor: "transparent"

rowDelegate: Item {
height: 38
height: instrumentsTreeView.delegateHeight
width: parent.width
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/playback/qml/MuseScore/Playback/MixerPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ ColumnLayout {
}

function scrollToFocusedItem(focusedIndex) {
let targetScrollPosition = (focusedIndex) * (prv.channelItemWidth + 2)
let targetScrollPosition = (focusedIndex) * (prv.channelItemWidth + 1) // + 1 for separators
let maxContentX = flickable.contentWidth - flickable.width

if (targetScrollPosition + prv.channelItemWidth > flickable.contentX + flickable.width) {
flickable.contentX = Math.min(targetScrollPosition + prv.channelItemWidth - flickable.width, maxContentX)
} else if (targetScrollPosition < flickable.contentX) {
flickable.contentX = Math.max(targetScrollPosition - 90, 0)
flickable.contentX = Math.max(targetScrollPosition - prv.channelItemWidth, 0)
}
}

Expand Down

0 comments on commit b519dfb

Please sign in to comment.