Skip to content

Commit

Permalink
[GraphEditor] Iterations of for loop visible in NodeEditor (only UI b…
Browse files Browse the repository at this point in the history
…y now)
  • Loading branch information
Just-Kiel committed Aug 30, 2024
1 parent 314eedd commit 97b6bc1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 27 deletions.
36 changes: 31 additions & 5 deletions meshroom/ui/qml/GraphEditor/NodeEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,37 @@ Panel {
Controls1.SplitView {
anchors.fill: parent

// The list of iterations
NodeEditorElementsListView {
id: iterationsLV
visible: root.node.countForLoop > 0
elements: {
if (root.node.countForLoop == 0)
return []
var elements = []
for (let i = 0; i < node.attributes.count; ++i) {
if (node.attributes.at(i).isLink) {
var srcAttr = node.attributes.at(i).linkParam
for (let j = 0; j < srcAttr.root.value.count; ++j) {
elements.push(j)
}
return elements
}
}
}

// TODO to remove when the elements would be correct
currentElement: elements[0]

isChunk: false
title: "Iterations"
}

// The list of chunks
ChunksListView {
NodeEditorElementsListView {
id: chunksLV
visible: (tabBar.currentIndex >= 1 && tabBar.currentIndex <= 3)
chunks: root.node.chunks
elements: root.node.chunks
}

StackLayout {
Expand Down Expand Up @@ -295,7 +321,7 @@ Panel {
id: nodeLog
node: root.node
currentChunkIndex: chunksLV.currentIndex
currentChunk: chunksLV.currentChunk
currentChunk: chunksLV.currentElement
}
}

Expand All @@ -310,7 +336,7 @@ Panel {
Layout.fillWidth: true
node: root.node
currentChunkIndex: chunksLV.currentIndex
currentChunk: chunksLV.currentChunk
currentChunk: chunksLV.currentElement
}
}

Expand All @@ -325,7 +351,7 @@ Panel {
Layout.fillWidth: true
node: root.node
currentChunkIndex: chunksLV.currentIndex
currentChunk: chunksLV.currentChunk
currentChunk: chunksLV.currentElement
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,56 @@ import Controls 1.0
import "common.js" as Common

/**
* ChunkListView
* NodeEditorElementsListView
*/
ColumnLayout {
id: root
property variant chunks
property variant elements
property int currentIndex: 0
property variant currentChunk: (chunks && currentIndex >= 0) ? chunks.at(currentIndex) : undefined
property bool isChunk: true
property string title: "Chunks"

onChunksChanged: {
// TODO : change to currentElement
property variant currentElement: (elements && currentIndex >= 0) ? elements.at(currentIndex) : undefined

onElementsChanged: {
// When the list changes, ensure the current index is in the new range
if (currentIndex >= chunks.count)
currentIndex = chunks.count-1
if (currentIndex >= elements.count)
currentIndex = elements.count-1
}

// chunksSummary is in sync with allChunks button (but not directly accessible as it is in a Component)
property bool chunksSummary: (currentIndex === -1)
// elementsSummary is in sync with allElements button (but not directly accessible as it is in a Component)
property bool elementsSummary: (currentIndex === -1)

width: 60
width: 75

ListView {
id: chunksLV
id: elementsLV
Layout.fillWidth: true
Layout.fillHeight: true

model: root.chunks
model: root.elements

highlightFollowsCurrentItem: (root.chunksSummary === false)
highlightFollowsCurrentItem: (root.elementsSummary === false)
keyNavigationEnabled: true
focus: true
currentIndex: root.currentIndex
onCurrentIndexChanged: {
if (chunksLV.currentIndex !== root.currentIndex) {
if (elementsLV.currentIndex !== root.currentIndex) {
// When the list is resized, the currentIndex is reset to 0.
// So here we force it to keep the binding.
chunksLV.currentIndex = Qt.binding(function() { return root.currentIndex })
elementsLV.currentIndex = Qt.binding(function() { return root.currentIndex })
}
}

header: Component {
Button {
id: allChunks
text: "Chunks"
id: allElements
text: title
width: parent.width
flat: true
checkable: true
property bool summaryEnabled: root.chunksSummary
property bool summaryEnabled: root.elementsSummary
checked: summaryEnabled
onSummaryEnabledChanged: {
checked = summaryEnabled
Expand All @@ -66,7 +70,7 @@ ColumnLayout {
}
highlight: Component {
Rectangle {
visible: true // !root.chunksSummary
visible: true // !root.elementsSummary
color: activePalette.highlight
opacity: 0.3
z: 2
Expand All @@ -76,19 +80,19 @@ ColumnLayout {
highlightResizeDuration: 0

delegate: ItemDelegate {
id: chunkDelegate
property var chunk: object
id: elementDelegate
property var element: object
text: index
width: parent ? parent.width : 0
leftPadding: 8
onClicked: {
chunksLV.forceActiveFocus()
elementsLV.forceActiveFocus()
root.currentIndex = index
}
Rectangle {
width: 4
height: parent.height
color: Common.getChunkColor(parent.chunk)
color: isChunk ? Common.getChunkColor(parent.element) : palette.mid
}
}
}
Expand Down

0 comments on commit 97b6bc1

Please sign in to comment.