Fix SimulationSliderLabel width

This commit is contained in:
Nino van Hooff 2019-11-12 14:52:11 +01:00
parent ae245ed0e5
commit f4b9c0fdd4

View file

@ -1,7 +1,6 @@
// Copyright (c) 2017 Ultimaker B.V. // Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.5
import QtQuick 2.2
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
@ -40,6 +39,13 @@ UM.PointingRectangle {
anchors.fill: parent anchors.fill: parent
} }
TextMetrics {
id: maxValueMetrics
font: UM.Theme.getFont("default")
text: maximumValue + 1 // layers are 0 based, add 1 for display value
}
TextField { TextField {
id: valueLabel id: valueLabel
@ -49,7 +55,6 @@ UM.PointingRectangle {
alignWhenCentered: false alignWhenCentered: false
} }
width: ((maximumValue + 1).toString().length + 1) * UM.Theme.getFont("default").pixelSize
text: sliderLabelRoot.value + startFrom // the current handle value, add 1 because layers is an array text: sliderLabelRoot.value + startFrom // the current handle value, add 1 because layers is an array
horizontalAlignment: TextInput.AlignHCenter horizontalAlignment: TextInput.AlignHCenter
@ -61,7 +66,8 @@ UM.PointingRectangle {
textColor: UM.Theme.getColor("text") textColor: UM.Theme.getColor("text")
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
renderType: Text.NativeRendering renderType: Text.NativeRendering
background: Item { } // valueLabel width
background: Item { implicitWidth: maxValueMetrics.width + UM.Theme.getSize("default_margin").width }
} }
onEditingFinished: { onEditingFinished: {