mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 21:38:58 +08:00
Merge pull request #4884 from Ultimaker/add_border_to_rounded_rectangle
Add border to rounded rectangle.
This commit is contained in:
commit
d1a5d548a9
10
resources/qml/BorderGroup.qml
Normal file
10
resources/qml/BorderGroup.qml
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
QtObject
|
||||
{
|
||||
property real width: 0
|
||||
property color color: "black"
|
||||
}
|
@ -5,6 +5,7 @@ import UM 1.2 as UM
|
||||
// The rounded rectangle works mostly like a regular rectangle, but provides the option to have rounded corners on only one side of the rectangle.
|
||||
Item
|
||||
{
|
||||
id: roundedRectangle
|
||||
// As per the regular rectangle
|
||||
property color color: "transparent"
|
||||
|
||||
@ -15,6 +16,9 @@ Item
|
||||
// 1 is down, 2 is left, 3 is up and 4 is right.
|
||||
property int cornerSide: RoundedRectangle.Direction.None
|
||||
|
||||
// Simple object to ensure that border.width and border.color work
|
||||
property BorderGroup border: BorderGroup {}
|
||||
|
||||
enum Direction
|
||||
{
|
||||
None = 0,
|
||||
@ -31,6 +35,8 @@ Item
|
||||
anchors.fill: parent
|
||||
radius: cornerSide != RoundedRectangle.Direction.None ? parent.radius : 0
|
||||
color: parent.color
|
||||
border.width: parent.border.width
|
||||
border.color: parent.border.color
|
||||
}
|
||||
|
||||
// The item that covers 2 of the corners to make them not rounded.
|
||||
@ -45,5 +51,22 @@ Item
|
||||
right: cornerSide == RoundedRectangle.Direction.Left ? parent.right: undefined
|
||||
bottom: cornerSide == RoundedRectangle.Direction.Up ? parent.bottom: undefined
|
||||
}
|
||||
|
||||
border.width: parent.border.width
|
||||
border.color: parent.border.color
|
||||
|
||||
Rectangle
|
||||
{
|
||||
color: roundedRectangle.color
|
||||
height: cornerSide % 2 ? roundedRectangle.border.width: roundedRectangle.height - 2 * roundedRectangle.border.width
|
||||
width: cornerSide % 2 ? roundedRectangle.width - 2 * roundedRectangle.border.width: roundedRectangle.border.width
|
||||
anchors
|
||||
{
|
||||
right: cornerSide == RoundedRectangle.Direction.Right ? parent.right : undefined
|
||||
bottom: cornerSide == RoundedRectangle.Direction.Down ? parent.bottom: undefined
|
||||
horizontalCenter: cornerSide % 2 ? parent.horizontalCenter: undefined
|
||||
verticalCenter: cornerSide % 2 ? undefined: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user