Skip to content

Commit

Permalink
live-preview: Add a ResetButton for properties
Browse files Browse the repository at this point in the history
This button can be used to remove an existing property
assignment, thus resetting to the default value the
element inherited.
  • Loading branch information
hunger committed Sep 13, 2024
1 parent bb99267 commit 9d2a788
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tools/lsp/ui/views/property-view.slint
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ component CodeButton inherits Button {
}
}

component ResetButton inherits Button {
in property <ElementInformation> element-information;
in property <PropertyInformation> property-information;

text: @tr("Reset");
clicked => {
Api.set-code-binding(
element-information.source-uri,
element-information.source-version,
element-information.range.start,
property-information.name,
"",
);
}
}

component ExpandableGroup {
in property <ElementInformation> element-information;
in property <string> text;
Expand Down Expand Up @@ -114,9 +130,15 @@ component ExpandableGroup {
);
}
}
if property.value.kind == PropertyValueKind.code: CodeButton {
element-information <=> root.element-information;
property-information: property;
if property.value.kind == PropertyValueKind.code: HorizontalLayout {
ResetButton {
element-information <=> root.element-information;
property-information: property;
}
CodeButton {
element-information <=> root.element-information;
property-information: property;
}
}
}
}
Expand Down

0 comments on commit 9d2a788

Please sign in to comment.