Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 13 additions & 0 deletions components/controls/StrokeControls.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ ColumnLayout {
property string strokeCap: "butt" // "butt", "square", "round"
property string strokeAlign: "center" // "center", "inner", "outer"
property string strokeOrder: "top" // "top" or "bottom"
property bool strokeScaleWithObject: false

signal widthEdited(real newWidth)
signal widthCommitted(real newWidth)
signal styleChanged(string newStyle)
signal capChanged(string newCap)
signal alignChanged(string newAlign)
signal orderChanged(string newOrder)
signal scaleWithObjectChanged(bool newValue)

readonly property SystemPalette themePalette: Lucent.Themed.palette

Expand Down Expand Up @@ -279,5 +281,16 @@ ColumnLayout {
}
}
}

Item {
Layout.fillWidth: true
}

CheckBox {
text: qsTr("Scale with object")
font.pixelSize: 12
checked: root.strokeScaleWithObject
onToggled: root.scaleWithObjectChanged(checked)
}
}
}
4 changes: 4 additions & 0 deletions components/controls/StrokeEditorButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ Item {
property string strokeCap: "butt" // "butt", "square", "round"
property string strokeAlign: "center" // "center", "inner", "outer"
property string strokeOrder: "top" // "top" or "bottom"
property bool strokeScaleWithObject: false

signal widthEdited(real newWidth)
signal widthCommitted(real newWidth)
signal styleChanged(string newStyle)
signal capChanged(string newCap)
signal alignChanged(string newAlign)
signal orderChanged(string newOrder)
signal scaleWithObjectChanged(bool newValue)
signal panelOpened
signal panelClosed

Expand Down Expand Up @@ -102,12 +104,14 @@ Item {
strokeCap: root.strokeCap
strokeAlign: root.strokeAlign
strokeOrder: root.strokeOrder
strokeScaleWithObject: root.strokeScaleWithObject
onWidthEdited: newWidth => root.widthEdited(newWidth)
onWidthCommitted: newWidth => root.widthCommitted(newWidth)
onStyleChanged: newStyle => root.styleChanged(newStyle)
onCapChanged: newCap => root.capChanged(newCap)
onAlignChanged: newAlign => root.alignChanged(newAlign)
onOrderChanged: newOrder => root.orderChanged(newOrder)
onScaleWithObjectChanged: newValue => root.scaleWithObjectChanged(newValue)
}
}
}
6 changes: 4 additions & 2 deletions components/tools/EllipseTool.qml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Item {
visible: style.strokeVisible,
cap: style.strokeCap,
align: style.strokeAlign,
order: style.strokeOrder
order: style.strokeOrder,
scaleWithObject: style.strokeScaleWithObject
}
]
});
Expand Down Expand Up @@ -141,7 +142,8 @@ Item {
visible: style.strokeVisible,
cap: style.strokeCap,
align: style.strokeAlign,
order: style.strokeOrder
order: style.strokeOrder,
scaleWithObject: style.strokeScaleWithObject
}
]
});
Expand Down
14 changes: 14 additions & 0 deletions components/tools/EllipseToolSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RowLayout {
property string _defaultStrokeCap: "butt"
property string _defaultStrokeAlign: "center"
property string _defaultStrokeOrder: "top"
property bool _defaultStrokeScaleWithObject: false
property color _defaultFillColor: Lucent.Themed.defaultFill
property real _defaultFillOpacity: 1.0

Expand Down Expand Up @@ -97,6 +98,13 @@ RowLayout {
}
return _defaultStrokeOrder;
}
readonly property bool strokeScaleWithObject: {
if (editMode) {
var stroke = _getStroke();
return stroke ? (stroke.scaleWithObject === true) : _defaultStrokeScaleWithObject;
}
return _defaultStrokeScaleWithObject;
}

readonly property color fillColor: {
if (editMode) {
Expand Down Expand Up @@ -130,6 +138,8 @@ RowLayout {
_defaultStrokeAlign = value;
else if (propName === "strokeOrder")
_defaultStrokeOrder = value;
else if (propName === "strokeScaleWithObject")
_defaultStrokeScaleWithObject = value;
else if (propName === "fillColor")
_defaultFillColor = value;
else if (propName === "fillOpacity")
Expand Down Expand Up @@ -166,6 +176,8 @@ RowLayout {
updated.align = value;
else if (propName === "strokeOrder")
updated.order = value;
else if (propName === "strokeScaleWithObject")
updated.scaleWithObject = value;
}
newAppearances.push(updated);
}
Expand Down Expand Up @@ -219,12 +231,14 @@ RowLayout {
strokeCap: root.strokeCap
strokeAlign: root.strokeAlign
strokeOrder: root.strokeOrder
strokeScaleWithObject: root.strokeScaleWithObject
onWidthEdited: newWidth => root.updateProperty("strokeWidth", newWidth)
onWidthCommitted: newWidth => root.updateProperty("strokeWidth", newWidth)
onStyleChanged: newStyle => root.updateProperty("strokeVisible", newStyle === "solid")
onCapChanged: newCap => root.updateProperty("strokeCap", newCap)
onAlignChanged: newAlign => root.updateProperty("strokeAlign", newAlign)
onOrderChanged: newOrder => root.updateProperty("strokeOrder", newOrder)
onScaleWithObjectChanged: newValue => root.updateProperty("strokeScaleWithObject", newValue)
onPanelOpened: canvasModel.beginTransaction()
onPanelClosed: canvasModel.endTransaction()
}
Expand Down
8 changes: 6 additions & 2 deletions components/tools/PenTool.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Item {
var strokeCap = s.strokeCap !== undefined ? s.strokeCap : "butt";
var strokeAlign = s.strokeAlign !== undefined ? s.strokeAlign : "center";
var strokeOrder = s.strokeOrder !== undefined ? s.strokeOrder : "top";
var strokeScaleWithObject = s.strokeScaleWithObject === true;
var fillColor = _colorString(s.fillColor);
var fillOpacity = s.fillOpacity !== undefined ? s.fillOpacity : 1.0;

Expand All @@ -113,7 +114,8 @@ Item {
visible: strokeVisible,
cap: strokeCap,
align: strokeAlign,
order: strokeOrder
order: strokeOrder,
scaleWithObject: strokeScaleWithObject
}
]
});
Expand Down Expand Up @@ -369,6 +371,7 @@ Item {
var strokeCap = s.strokeCap !== undefined ? s.strokeCap : "butt";
var strokeAlign = s.strokeAlign !== undefined ? s.strokeAlign : "center";
var strokeOrder = s.strokeOrder !== undefined ? s.strokeOrder : "top";
var strokeScaleWithObject = s.strokeScaleWithObject === true;
var fillColor = tool._colorString(s.fillColor);
var fillOpacity = s.fillOpacity !== undefined ? s.fillOpacity : 1.0;

Expand All @@ -395,7 +398,8 @@ Item {
visible: strokeVisible,
cap: strokeCap,
align: strokeAlign,
order: strokeOrder
order: strokeOrder,
scaleWithObject: strokeScaleWithObject
}
]
});
Expand Down
14 changes: 14 additions & 0 deletions components/tools/PenToolSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RowLayout {
property string _defaultStrokeCap: "butt"
property string _defaultStrokeAlign: "center"
property string _defaultStrokeOrder: "top"
property bool _defaultStrokeScaleWithObject: false
property color _defaultFillColor: Lucent.Themed.defaultFill
property real _defaultFillOpacity: 0.0

Expand Down Expand Up @@ -97,6 +98,13 @@ RowLayout {
}
return _defaultStrokeOrder;
}
readonly property bool strokeScaleWithObject: {
if (editMode) {
var stroke = _getStroke();
return stroke ? (stroke.scaleWithObject === true) : _defaultStrokeScaleWithObject;
}
return _defaultStrokeScaleWithObject;
}

readonly property color fillColor: {
if (editMode) {
Expand Down Expand Up @@ -130,6 +138,8 @@ RowLayout {
_defaultStrokeAlign = value;
else if (propName === "strokeOrder")
_defaultStrokeOrder = value;
else if (propName === "strokeScaleWithObject")
_defaultStrokeScaleWithObject = value;
else if (propName === "fillColor")
_defaultFillColor = value;
else if (propName === "fillOpacity")
Expand Down Expand Up @@ -166,6 +176,8 @@ RowLayout {
updated.align = value;
else if (propName === "strokeOrder")
updated.order = value;
else if (propName === "strokeScaleWithObject")
updated.scaleWithObject = value;
}
newAppearances.push(updated);
}
Expand Down Expand Up @@ -219,12 +231,14 @@ RowLayout {
strokeCap: root.strokeCap
strokeAlign: root.strokeAlign
strokeOrder: root.strokeOrder
strokeScaleWithObject: root.strokeScaleWithObject
onWidthEdited: newWidth => root.updateProperty("strokeWidth", newWidth)
onWidthCommitted: newWidth => root.updateProperty("strokeWidth", newWidth)
onStyleChanged: newStyle => root.updateProperty("strokeVisible", newStyle === "solid")
onCapChanged: newCap => root.updateProperty("strokeCap", newCap)
onAlignChanged: newAlign => root.updateProperty("strokeAlign", newAlign)
onOrderChanged: newOrder => root.updateProperty("strokeOrder", newOrder)
onScaleWithObjectChanged: newValue => root.updateProperty("strokeScaleWithObject", newValue)
onPanelOpened: canvasModel.beginTransaction()
onPanelClosed: canvasModel.endTransaction()
}
Expand Down
6 changes: 4 additions & 2 deletions components/tools/RectangleTool.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Item {
visible: style.strokeVisible,
cap: style.strokeCap,
align: style.strokeAlign,
order: style.strokeOrder
order: style.strokeOrder,
scaleWithObject: style.strokeScaleWithObject
}
]
});
Expand Down Expand Up @@ -161,7 +162,8 @@ Item {
visible: style.strokeVisible,
cap: style.strokeCap,
align: style.strokeAlign,
order: style.strokeOrder
order: style.strokeOrder,
scaleWithObject: style.strokeScaleWithObject
}
]
});
Expand Down
16 changes: 15 additions & 1 deletion components/tools/RectangleToolSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RowLayout {
property string _defaultStrokeCap: "butt"
property string _defaultStrokeAlign: "center"
property string _defaultStrokeOrder: "top"
property bool _defaultStrokeScaleWithObject: false
property color _defaultFillColor: Lucent.Themed.defaultFill
property real _defaultFillOpacity: 1.0
property real _defaultCornerRadius: 0
Expand Down Expand Up @@ -103,6 +104,13 @@ RowLayout {
}
return _defaultStrokeOrder;
}
readonly property bool strokeScaleWithObject: {
if (editMode) {
var stroke = _getStroke();
return stroke ? (stroke.scaleWithObject === true) : _defaultStrokeScaleWithObject;
}
return _defaultStrokeScaleWithObject;
}

readonly property color fillColor: {
if (editMode) {
Expand Down Expand Up @@ -179,6 +187,8 @@ RowLayout {
_defaultStrokeAlign = value;
else if (propName === "strokeOrder")
_defaultStrokeOrder = value;
else if (propName === "strokeScaleWithObject")
_defaultStrokeScaleWithObject = value;
else if (propName === "fillColor")
_defaultFillColor = value;
else if (propName === "fillOpacity")
Expand All @@ -201,7 +211,7 @@ RowLayout {
if (!currentItem)
return;

var updatesAppearance = propName === "fillColor" || propName === "fillOpacity" || propName === "strokeWidth" || propName === "strokeColor" || propName === "strokeOpacity" || propName === "strokeVisible" || propName === "strokeCap" || propName === "strokeAlign" || propName === "strokeOrder";
var updatesAppearance = propName === "fillColor" || propName === "fillOpacity" || propName === "strokeWidth" || propName === "strokeColor" || propName === "strokeOpacity" || propName === "strokeVisible" || propName === "strokeCap" || propName === "strokeAlign" || propName === "strokeOrder" || propName === "strokeScaleWithObject";
var updatesGeometry = propName === "cornerRadius" || propName === "cornerRadiusTL" || propName === "cornerRadiusTR" || propName === "cornerRadiusBR" || propName === "cornerRadiusBL";

var newAppearances = currentItem.appearances;
Expand Down Expand Up @@ -230,6 +240,8 @@ RowLayout {
updated.align = value;
else if (propName === "strokeOrder")
updated.order = value;
else if (propName === "strokeScaleWithObject")
updated.scaleWithObject = value;
}
newAppearances.push(updated);
}
Expand Down Expand Up @@ -299,12 +311,14 @@ RowLayout {
strokeCap: root.strokeCap
strokeAlign: root.strokeAlign
strokeOrder: root.strokeOrder
strokeScaleWithObject: root.strokeScaleWithObject
onWidthEdited: newWidth => root.updateProperty("strokeWidth", newWidth)
onWidthCommitted: newWidth => root.updateProperty("strokeWidth", newWidth)
onStyleChanged: newStyle => root.updateProperty("strokeVisible", newStyle === "solid")
onCapChanged: newCap => root.updateProperty("strokeCap", newCap)
onAlignChanged: newAlign => root.updateProperty("strokeAlign", newAlign)
onOrderChanged: newOrder => root.updateProperty("strokeOrder", newOrder)
onScaleWithObjectChanged: newValue => root.updateProperty("strokeScaleWithObject", newValue)
onPanelOpened: canvasModel.beginTransaction()
onPanelClosed: canvasModel.endTransaction()
}
Expand Down
1 change: 1 addition & 0 deletions components/tools/TwoPointToolHelper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ QtObject {
strokeCap: settings ? (settings.strokeCap !== undefined ? settings.strokeCap : "butt") : "butt",
strokeAlign: settings ? (settings.strokeAlign !== undefined ? settings.strokeAlign : "center") : "center",
strokeOrder: settings ? (settings.strokeOrder !== undefined ? settings.strokeOrder : "top") : "top",
strokeScaleWithObject: settings ? (settings.strokeScaleWithObject === true) : false,
fillColor: settings ? settings.fillColor.toString() : "",
fillOpacity: settings ? settings.fillOpacity : 1.0
};
Expand Down
4 changes: 4 additions & 0 deletions src/lucent/appearances.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def __init__(
cap: str = "butt",
align: str = "center",
order: str = "top",
scale_with_object: bool = False,
) -> None:
super().__init__(visible)
self.color = color
Expand All @@ -170,6 +171,7 @@ def __init__(
self.cap = cap if cap in self.VALID_CAPS else "butt"
self.align = align if align in self.VALID_ALIGNS else "center"
self.order = order if order in self.VALID_ORDERS else "top"
self.scale_with_object = bool(scale_with_object)

def render(
self,
Expand Down Expand Up @@ -237,6 +239,7 @@ def to_dict(self) -> Dict[str, Any]:
"cap": self.cap,
"align": self.align,
"order": self.order,
"scaleWithObject": self.scale_with_object,
}

@staticmethod
Expand All @@ -250,6 +253,7 @@ def from_dict(data: Dict[str, Any]) -> "Stroke":
cap=data.get("cap", "butt"),
align=data.get("align", "center"),
order=data.get("order", "top"),
scale_with_object=bool(data.get("scaleWithObject", False)),
)

def get_sg_color(self) -> Optional[QColor]:
Expand Down
2 changes: 2 additions & 0 deletions src/lucent/item_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _parse_appearances(data: Dict[str, Any]) -> List[Dict[str, Any]]:
"cap": "butt",
"align": "center",
"order": "top",
"scaleWithObject": False,
},
]

Expand Down Expand Up @@ -121,6 +122,7 @@ def _parse_appearances(data: Dict[str, Any]) -> List[Dict[str, Any]]:
"cap": cap,
"align": align,
"order": order,
"scaleWithObject": bool(a.get("scaleWithObject", False)),
}
)
return result
Expand Down
Loading