aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Gruendl <[email protected]>2025-04-28 22:59:27 +0200
committerHenning Gruendl <[email protected]>2025-04-30 08:51:43 +0200
commit8c9e0faa0dd8b8adf019e357212e59898a7bebfb (patch)
treef4495b631d6a7aaea2acb7786c940783d26df569
parent94c5aa7f4c5b65c3d76ad50ab2440a7e2f81c61f (diff)
Components: Fix mixed radii calculationsHEADdev
Fix mixed radii calculations for RectangleItem and BorderItem. Each corner radii calculation now takes into account both of its neighboring corner radii. Change-Id: I489543846b000ddcfd5f65086db636774b39feb6 Reviewed-by: Thomas Hartmann <[email protected]>
-rw-r--r--src/imports/components/BorderItem.qml55
-rw-r--r--src/imports/components/RectangleItem.qml55
2 files changed, 16 insertions, 94 deletions
diff --git a/src/imports/components/BorderItem.qml b/src/imports/components/BorderItem.qml
index c25ea99..6aca3fd 100644
--- a/src/imports/components/BorderItem.qml
+++ b/src/imports/components/BorderItem.qml
@@ -344,59 +344,20 @@ Shape {
}
// Mixed radii
- let topLeftRadiusMin = Math.min(minDimension, root.topLeftRadius)
- let topRightRadiusMin = Math.min(minDimension, root.topRightRadius)
- let bottomLeftRadiusMin = Math.min(minDimension, root.bottomLeftRadius)
- let bottomRightRadiusMin = Math.min(minDimension, root.bottomRightRadius)
-
- // Top radii
let topRadii = root.topLeftRadius + root.topRightRadius
-
- if (topRadii > root.width) {
- let topLeftRadiusFactor = root.topLeftRadius / topRadii
- let tlr = Math.round(root.width * topLeftRadiusFactor)
-
- topLeftRadiusMin = Math.min(topLeftRadiusMin, tlr)
- topRightRadiusMin = Math.min(topRightRadiusMin, root.width - tlr)
- }
-
- // Right radii
let rightRadii = root.topRightRadius + root.bottomRightRadius
-
- if (rightRadii > root.height) {
- let topRightRadiusFactor = root.topRightRadius / rightRadii
- let trr = Math.round(root.height * topRightRadiusFactor)
-
- topRightRadiusMin = Math.min(topRightRadiusMin, trr)
- bottomRightRadiusMin = Math.min(bottomRightRadiusMin, root.height - trr)
- }
-
- // Bottom radii
let bottomRadii = root.bottomRightRadius + root.bottomLeftRadius
-
- if (bottomRadii > root.width) {
- let bottomRightRadiusFactor = root.bottomRightRadius / bottomRadii
- let brr = Math.round(root.width * bottomRightRadiusFactor)
-
- bottomRightRadiusMin = Math.min(bottomRightRadiusMin, brr)
- bottomLeftRadiusMin = Math.min(bottomLeftRadiusMin, root.width - brr)
- }
-
- // Left radii
let leftRadii = root.bottomLeftRadius + root.topLeftRadius
- if (leftRadii > root.height) {
- let bottomLeftRadiusFactor = root.bottomLeftRadius / leftRadii
- let blr = Math.round(root.height * bottomLeftRadiusFactor)
-
- bottomLeftRadiusMin = Math.min(bottomLeftRadiusMin, blr)
- topLeftRadiusMin = Math.min(topLeftRadiusMin, root.height - blr)
- }
+ let tlr = Math.min(root.width / topRadii, root.height / leftRadii) * root.topLeftRadius
+ let trr = Math.min(root.width / topRadii, root.height / rightRadii) * root.topRightRadius
+ let brr = Math.min(root.width / bottomRadii, root.height / rightRadii) * root.bottomRightRadius
+ let blr = Math.min(root.width / bottomRadii, root.height / leftRadii) * root.bottomLeftRadius
- path.__topLeftRadius = topLeftRadiusMin
- path.__topRightRadius = topRightRadiusMin
- path.__bottomLeftRadius = bottomLeftRadiusMin
- path.__bottomRightRadius = bottomRightRadiusMin
+ path.__topLeftRadius = Math.round(Math.min(root.topLeftRadius, tlr))
+ path.__topRightRadius = Math.round(Math.min(root.topRightRadius, trr))
+ path.__bottomRightRadius = Math.round(Math.min(root.bottomRightRadius, brr))
+ path.__bottomLeftRadius = Math.round(Math.min(root.bottomLeftRadius, blr))
}
ShapePath {
diff --git a/src/imports/components/RectangleItem.qml b/src/imports/components/RectangleItem.qml
index 7982fb1..918fc3d 100644
--- a/src/imports/components/RectangleItem.qml
+++ b/src/imports/components/RectangleItem.qml
@@ -344,59 +344,20 @@ Shape {
}
// Mixed radii
- let topLeftRadiusMin = Math.min(minDimension, root.topLeftRadius)
- let topRightRadiusMin = Math.min(minDimension, root.topRightRadius)
- let bottomLeftRadiusMin = Math.min(minDimension, root.bottomLeftRadius)
- let bottomRightRadiusMin = Math.min(minDimension, root.bottomRightRadius)
-
- // Top radii
let topRadii = root.topLeftRadius + root.topRightRadius
-
- if (topRadii > root.width) {
- let topLeftRadiusFactor = root.topLeftRadius / topRadii
- let tlr = Math.round(root.width * topLeftRadiusFactor)
-
- topLeftRadiusMin = Math.min(topLeftRadiusMin, tlr)
- topRightRadiusMin = Math.min(topRightRadiusMin, root.width - tlr)
- }
-
- // Right radii
let rightRadii = root.topRightRadius + root.bottomRightRadius
-
- if (rightRadii > root.height) {
- let topRightRadiusFactor = root.topRightRadius / rightRadii
- let trr = Math.round(root.height * topRightRadiusFactor)
-
- topRightRadiusMin = Math.min(topRightRadiusMin, trr)
- bottomRightRadiusMin = Math.min(bottomRightRadiusMin, root.height - trr)
- }
-
- // Bottom radii
let bottomRadii = root.bottomRightRadius + root.bottomLeftRadius
-
- if (bottomRadii > root.width) {
- let bottomRightRadiusFactor = root.bottomRightRadius / bottomRadii
- let brr = Math.round(root.width * bottomRightRadiusFactor)
-
- bottomRightRadiusMin = Math.min(bottomRightRadiusMin, brr)
- bottomLeftRadiusMin = Math.min(bottomLeftRadiusMin, root.width - brr)
- }
-
- // Left radii
let leftRadii = root.bottomLeftRadius + root.topLeftRadius
- if (leftRadii > root.height) {
- let bottomLeftRadiusFactor = root.bottomLeftRadius / leftRadii
- let blr = Math.round(root.height * bottomLeftRadiusFactor)
-
- bottomLeftRadiusMin = Math.min(bottomLeftRadiusMin, blr)
- topLeftRadiusMin = Math.min(topLeftRadiusMin, root.height - blr)
- }
+ let tlr = Math.min(root.width / topRadii, root.height / leftRadii) * root.topLeftRadius
+ let trr = Math.min(root.width / topRadii, root.height / rightRadii) * root.topRightRadius
+ let brr = Math.min(root.width / bottomRadii, root.height / rightRadii) * root.bottomRightRadius
+ let blr = Math.min(root.width / bottomRadii, root.height / leftRadii) * root.bottomLeftRadius
- path.__topLeftRadius = topLeftRadiusMin
- path.__topRightRadius = topRightRadiusMin
- path.__bottomLeftRadius = bottomLeftRadiusMin
- path.__bottomRightRadius = bottomRightRadiusMin
+ path.__topLeftRadius = Math.round(Math.min(root.topLeftRadius, tlr))
+ path.__topRightRadius = Math.round(Math.min(root.topRightRadius, trr))
+ path.__bottomRightRadius = Math.round(Math.min(root.bottomRightRadius, brr))
+ path.__bottomLeftRadius = Math.round(Math.min(root.bottomLeftRadius, blr))
}
ShapePath {