[ui] GraphEditor: improve alignments

Reduce usage of anchors (except centerIn/fill).
Display of Next/Previous for IntSelector.
This commit is contained in:
Fabien Castan 2024-08-20 23:44:34 +02:00 committed by Aurore LAFAURIE
parent ff86a5182e
commit 48d08b1f88
4 changed files with 81 additions and 93 deletions

View file

@ -7,41 +7,26 @@ import QtQuick.Layouts 1.11
* IntSelector with arrows and a text input to select a number * IntSelector with arrows and a text input to select a number
*/ */
Item { Row {
id: root id: root
property string tooltipText: ""
property int value: 0 property int value: 0
property var range: { "min" : 0, "max" : 0 } property var range: { "min" : 0, "max" : 0 }
Layout.preferredWidth: previousIntButton.width + intMetrics.width + nextIntButton.width Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: intInput.height
MouseArea { spacing: 0
id: mouseAreaIntLabel property bool displayButtons: previousIntButton.hovered || intInputMouseArea.containsMouse || nextIntButton.hovered
property real buttonsOpacity: displayButtons ? 1.0 : 0.0
anchors.fill: parent
hoverEnabled: true
onEntered: {
previousIntButton.opacity = 1
nextIntButton.opacity = 1
}
onExited: {
previousIntButton.opacity = 0
nextIntButton.opacity = 0
}
MaterialToolButton { MaterialToolButton {
id: previousIntButton id: previousIntButton
anchors.verticalCenter: mouseAreaIntLabel.verticalCenter opacity: buttonsOpacity
opacity: 0
width: 10 width: 10
text: MaterialIcons.navigate_before text: MaterialIcons.navigate_before
ToolTip.text: "Previous Integer" ToolTip.text: "Previous"
onClicked: { onClicked: {
if (value > range.min) { if (value > range.min) {
@ -53,12 +38,15 @@ Item {
TextInput { TextInput {
id: intInput id: intInput
anchors.horizontalCenter: mouseAreaIntLabel.horizontalCenter ToolTip.text: tooltipText
anchors.verticalCenter: mouseAreaIntLabel.verticalCenter ToolTip.visible: tooltipText && intInputMouseArea.containsMouse
Layout.preferredWidth: intMetrics.width
width: intMetrics.width
height: previousIntButton.height
color: palette.text color: palette.text
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
selectByMouse: true selectByMouse: true
text: value text: value
@ -69,18 +57,23 @@ Item {
value = Math.min(range.max, Math.max(range.min, parseInt(text))) value = Math.min(range.max, Math.max(range.min, parseInt(text)))
focus = false focus = false
} }
MouseArea {
id: intInputMouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
}
} }
MaterialToolButton { MaterialToolButton {
id: nextIntButton id: nextIntButton
anchors.right: mouseAreaIntLabel.right
anchors.verticalCenter: mouseAreaIntLabel.verticalCenter
width: 10 width: 10
opacity: 0 opacity: buttonsOpacity
text: MaterialIcons.navigate_next text: MaterialIcons.navigate_next
ToolTip.text: "Next Integer" ToolTip.text: "Next"
onClicked: { onClicked: {
if (value < range.max) { if (value < range.max) {
@ -95,7 +88,5 @@ Item {
font: intInput.font font: intInput.font
text: "10000" text: "10000"
} }
}
} }

View file

@ -78,21 +78,20 @@ Item {
visible: root.isForLoop visible: root.isForLoop
Rectangle { Rectangle {
anchors.centerIn: parent anchors.centerIn: parent
property int margin: 1 property int margin: 2
width: childrenRect.width + 2 * margin width: childrenRect.width + 2 * margin
height: childrenRect.height + 2 * margin height: childrenRect.height + 2 * margin
radius: width radius: width
color: path.strokeColor color: path.strokeColor
MaterialToolLabel { MaterialToolLabel {
id: icon id: icon
x: parent.margin anchors.centerIn: parent
y: parent.margin
iconText: MaterialIcons.loop iconText: MaterialIcons.loop
label: (root.iteration + 1) + "/" + root.loopSize label: (root.iteration + 1) + "/" + root.loopSize + " "
color: palette.base color: palette.base
ToolTip.text: "Foreach Loop"
ToolTip.text: "This is a for loop"
} }
} }
} }

View file

@ -388,10 +388,8 @@ Item {
expandButton.canExpand = uigraph.canExpandForLoop(edgeMenu.currentEdge) expandButton.canExpand = uigraph.canExpandForLoop(edgeMenu.currentEdge)
} }
contentItem: GridLayout { contentItem: Row {
layoutDirection: Qt.LeftToRight spacing: 20
columns: 2
columnSpacing: 20
Column { Column {
id: listAttrColumn id: listAttrColumn
@ -403,13 +401,11 @@ Item {
text: "<b>Iteration:</b>" text: "<b>Iteration:</b>"
color: activePalette.text color: activePalette.text
bottomPadding: 15
} }
IntSelector { IntSelector {
tooltipText: "Iterations"
width: listAttrColumn.width width: listAttrColumn.width
anchors.top: listAttrMenuText.bottom
anchors.horizontalCenter: listAttrColumn.horizontalCenter
visible: edgeMenu.currentEdge && edgeMenu.forLoop visible: edgeMenu.currentEdge && edgeMenu.forLoop
// We add 1 to the index because of human readable index (starting at 1) // We add 1 to the index because of human readable index (starting at 1)
@ -439,7 +435,7 @@ Item {
color: activePalette.text color: activePalette.text
} }
RowLayout { Row {
MaterialToolButton { MaterialToolButton {
font.pointSize: 13 font.pointSize: 13
ToolTip.text: "Remove edge" ToolTip.text: "Remove edge"

View file

@ -147,6 +147,8 @@ FloatingPane {
IntSelector { IntSelector {
id: frameInput id: frameInput
tooltipText: "Frame"
value: m.frame value: m.frame
range: frameRange range: frameRange