[ui] Inspector3D: simplify handling of scene media items hovering

* add MouseArea at root of media
* use flow to display media info and avoid text clipping
This commit is contained in:
Yann Lanthony 2019-09-11 10:47:49 +02:00
parent 312b9f5e0b
commit 03e91bea49
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642

View file

@ -21,6 +21,7 @@ FloatingPane {
signal mediaFocusRequest(var index)
signal mediaRemoveRequest(var index)
signal nodeActivated(var node)
padding: 0
@ -194,25 +195,46 @@ FloatingPane {
}
}
delegate: RowLayout {
delegate: MouseArea {
id: mediaDelegate
// add mediaLibrary.count in the binding to ensure 'entity'
// is re-evaluated when mediaLibrary delegates are modified
property bool loading: model.status === SceneLoader.Loading
spacing: 2
width: parent.width - scrollBar.width / 2
property string src: model.source
onSrcChanged: focusAnim.restart()
property bool hovered: model.attribute ? uigraph.hoveredNode === model.attribute.node : mouseArea.containsMouse
property bool hovered: model.attribute ? uigraph.hoveredNode === model.attribute.node : containsMouse
property bool isSelectedNode: model.attribute ? uigraph.selectedNode === model.attribute.node : false
onIsSelectedNodeChanged: updateCurrentIndex()
function updateCurrentIndex() {
if(isSelectedNode) { mediaListView.currentIndex = index }
}
onIsSelectedNodeChanged: updateCurrentIndex()
height: childrenRect.height
width: parent.width - scrollBar.width
hoverEnabled: true
onEntered: { if(model.attribute) uigraph.hoveredNode = model.attribute.node }
onExited: { if(model.attribute) uigraph.hoveredNode = null }
onClicked: {
if(model.attribute)
uigraph.selectedNode = model.attribute.node;
else
uigraph.selectedNode = null;
if(mouse.button == Qt.RightButton)
contextMenu.popup();
mediaListView.currentIndex = index;
}
onDoubleClicked: {
model.visible = true;
camera.viewEntity(root.mediaLibrary.entityAt(index));
}
RowLayout {
width: parent.width
spacing: 2
property string src: model.source
onSrcChanged: focusAnim.restart()
Connections {
target: mediaListView
@ -235,6 +257,7 @@ FloatingPane {
// Media visibility/loading control
MaterialToolButton {
Layout.alignment: Qt.AlignTop
Layout.fillHeight: true
text: model.visible ? MaterialIcons.visibility : MaterialIcons.visibility_off
font.pointSize: 10
ToolTip.text: model.visible ? "Hide" : model.requested ? "Show" : model.valid ? "Load and Show" : "Load and Show when Available"
@ -299,39 +322,36 @@ FloatingPane {
visible: infoButton.checked
Layout.fillWidth: true
implicitHeight: childrenRect.height
RowLayout {
Flow {
width: parent.width
spacing: 4
visible: model.status === SceneLoader.Ready
MaterialLabel { visible: model.vertexCount; text: MaterialIcons.grain }
Label { visible: model.vertexCount; text: Format.intToString(model.vertexCount) }
MaterialLabel { visible: model.faceCount; text: MaterialIcons.details; rotation: -180 }
Label { visible: model.faceCount; text: Format.intToString(model.faceCount) }
MaterialLabel { visible: model.cameraCount; text: MaterialIcons.videocam }
Label { visible: model.cameraCount; text: model.cameraCount }
MaterialLabel { visible: model.textureCount; text: MaterialIcons.texture }
Label { visible: model.textureCount; text: model.textureCount }
RowLayout {
spacing: 1
visible: model.vertexCount
MaterialLabel { text: MaterialIcons.grain }
Label { text: Format.intToString(model.vertexCount) }
}
RowLayout {
spacing: 1
visible: model.faceCount
MaterialLabel { text: MaterialIcons.details; rotation: -180 }
Label { text: Format.intToString(model.faceCount) }
}
RowLayout {
spacing: 1
visible: model.cameraCount
MaterialLabel { text: MaterialIcons.videocam }
Label { text: model.cameraCount }
}
RowLayout {
spacing: 1
visible: model.textureCount
MaterialLabel { text: MaterialIcons.texture }
Label { text: model.textureCount }
}
}
}
MouseArea {
id: mouseArea
anchors.fill: centralLayout
hoverEnabled: true
acceptedButtons: Qt.AllButtons
onEntered: { if(model.attribute) uigraph.hoveredNode = model.attribute.node }
onExited: { if(model.attribute) uigraph.hoveredNode = null }
onClicked: {
if(model.attribute)
uigraph.selectedNode = model.attribute.node;
else
uigraph.selectedNode = null;
if(mouse.button == Qt.RightButton)
contextMenu.popup();
mediaListView.currentIndex = index;
}
onDoubleClicked: {
model.visible = true;
camera.viewEntity(mediaLibrary.entityAt(index));
}
}
Menu {
@ -360,10 +380,12 @@ FloatingPane {
Layout.alignment: Qt.AlignTop
Layout.fillHeight: true
visible: hovered || mouseArea.containsMouse && !loading
visible: !loading && mediaDelegate.containsMouse
text: MaterialIcons.clear
font.pointSize: 10
ToolTip.text: "Remove"
ToolTip.delay: 500
onClicked: mediaLibrary.remove(index)
}
@ -379,4 +401,5 @@ FloatingPane {
}
}
}
}
}