Skip to content

Adjust pose decimals based on element width #1089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/gui/plugins/component_inspector/Pose3d.qml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ Rectangle {
);
}

// Get decimals based on a width
function getDecimals(width) {
if (width<= 80)
return 2;
else if (width <= 100)
return 4;
return 6;
}

FontMetrics {
id: fontMetrics
font.family: "Roboto"
Expand All @@ -90,7 +99,7 @@ Rectangle {
value: writableSpin.activeFocus ? writableSpin.value : numberValue
minimumValue: -spinMax
maximumValue: spinMax
decimals: 6
decimals: getDecimals(writableSpin.width)
onEditingFinished: {
sendPose()
}
Expand All @@ -108,7 +117,7 @@ Rectangle {
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: {
var decimals = numberText.width < 100 ? 2 : 6
var decimals = getDecimals(numberText.width)
return numberValue.toFixed(decimals)
}
}
Expand Down