mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-30 03:27:22 +00:00
live-preview: Do not pass on signals from "invisible" widgets
This stops e.g. the color widget filling in default values for empty strings.
This commit is contained in:
parent
daba39e34b
commit
14b55e54b4
1 changed files with 70 additions and 20 deletions
|
|
@ -52,10 +52,12 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
property-value <=> root.property-value;
|
property-value <=> root.property-value;
|
||||||
|
|
||||||
set-bool-binding(value) => {
|
set-bool-binding(value) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.boolean {
|
||||||
root.set-bool-binding(value);
|
root.set-bool-binding(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: (root.property-value.kind == PropertyValueKind.color) ? self.preferred-height : 0px;
|
height: (root.property-value.kind == PropertyValueKind.color) ? self.preferred-height : 0px;
|
||||||
|
|
@ -69,20 +71,30 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
has-reset-action: root.has-reset-action;
|
has-reset-action: root.has-reset-action;
|
||||||
|
|
||||||
test-color-binding(text) => {
|
test-color-binding(text) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.color {
|
||||||
return (root.test-color-binding(text));
|
return (root.test-color-binding(text));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set-color-binding(text) => {
|
set-color-binding(text) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.color {
|
||||||
root.set-color-binding(text);
|
root.set-color-binding(text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reset-action() => {
|
reset-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.color {
|
||||||
root.reset-action();
|
root.reset-action();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
code-action() => {
|
code-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.color {
|
||||||
root.code-action();
|
root.code-action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: (root.property-value.kind == PropertyValueKind.brush) ? self.preferred-height : 0px;
|
height: (root.property-value.kind == PropertyValueKind.brush) ? self.preferred-height : 0px;
|
||||||
|
|
@ -96,20 +108,30 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
has-reset-action: root.has-reset-action;
|
has-reset-action: root.has-reset-action;
|
||||||
|
|
||||||
test-brush-binding(kind, angle, color, stops) => {
|
test-brush-binding(kind, angle, color, stops) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.brush {
|
||||||
return root.test-brush-binding(kind, angle, color, stops);
|
return root.test-brush-binding(kind, angle, color, stops);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set-brush-binding(kind, angle, color, stops) => {
|
set-brush-binding(kind, angle, color, stops) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.brush {
|
||||||
root.set-brush-binding(kind, angle, color, stops);
|
root.set-brush-binding(kind, angle, color, stops);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reset-action() => {
|
reset-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.brush {
|
||||||
root.reset-action();
|
root.reset-action();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
code-action() => {
|
code-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.brush {
|
||||||
root.code-action();
|
root.code-action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: root.property-value.kind == PropertyValueKind.code ? self.preferred-height : 0px;
|
height: root.property-value.kind == PropertyValueKind.code ? self.preferred-height : 0px;
|
||||||
|
|
@ -120,13 +142,17 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
property-value <=> root.property-value;
|
property-value <=> root.property-value;
|
||||||
|
|
||||||
reset-action() => {
|
reset-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.code {
|
||||||
root.reset-action();
|
root.reset-action();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
code-action() => {
|
code-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.code {
|
||||||
root.code-action();
|
root.code-action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: root.property-value.kind == PropertyValueKind.enum ? self.preferred-height : 0px;
|
height: root.property-value.kind == PropertyValueKind.enum ? self.preferred-height : 0px;
|
||||||
|
|
@ -137,10 +163,12 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
property-value <=> root.property-value;
|
property-value <=> root.property-value;
|
||||||
|
|
||||||
set-enum-binding(text) => {
|
set-enum-binding(text) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.enum {
|
||||||
root.set-enum-binding(text);
|
root.set-enum-binding(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: root.property-value.kind == PropertyValueKind.float ? self.preferred-height : 0px;
|
height: root.property-value.kind == PropertyValueKind.float ? self.preferred-height : 0px;
|
||||||
|
|
@ -151,13 +179,19 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
property-value <=> root.property-value;
|
property-value <=> root.property-value;
|
||||||
|
|
||||||
test-float-binding(text, unit) => {
|
test-float-binding(text, unit) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.float {
|
||||||
return (root.test-float-binding(text, unit));
|
return (root.test-float-binding(text, unit));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set-float-binding(text, unit) => {
|
set-float-binding(text, unit) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.float {
|
||||||
root.set-float-binding(text, unit);
|
root.set-float-binding(text, unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: root.property-value.kind == PropertyValueKind.integer ? self.preferred-height : 0px;
|
height: root.property-value.kind == PropertyValueKind.integer ? self.preferred-height : 0px;
|
||||||
|
|
@ -168,13 +202,19 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
property-value <=> root.property-value;
|
property-value <=> root.property-value;
|
||||||
|
|
||||||
test-integer-binding(text) => {
|
test-integer-binding(text) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.integer {
|
||||||
return (root.test-code-binding(text));
|
return (root.test-code-binding(text));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set-integer-binding(text) => {
|
set-integer-binding(text) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.integer {
|
||||||
root.set-code-binding(text);
|
root.set-code-binding(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
clip: true;
|
clip: true;
|
||||||
height: root.property-value.kind == PropertyValueKind.string ? self.preferred-height : 0px;
|
height: root.property-value.kind == PropertyValueKind.string ? self.preferred-height : 0px;
|
||||||
|
|
@ -189,20 +229,30 @@ export component PropertyValueWidget inherits VerticalLayout {
|
||||||
is-translatable <=> root.strings-are-translatable;
|
is-translatable <=> root.strings-are-translatable;
|
||||||
|
|
||||||
reset-action() => {
|
reset-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.string {
|
||||||
root.reset-action();
|
root.reset-action();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
code-action() => {
|
code-action() => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.string {
|
||||||
root.code-action();
|
root.code-action();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
test-string-binding(text, is_translated) => {
|
test-string-binding(text, is_translated) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.string {
|
||||||
return root.test-string-binding(text, is_translated);
|
return root.test-string-binding(text, is_translated);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set-string-binding(text, is_translated) => {
|
set-string-binding(text, is_translated) => {
|
||||||
|
if root.property-value.kind == PropertyValueKind.string {
|
||||||
root.set-string-binding(text, is_translated);
|
root.set-string-binding(text, is_translated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export component PropertyInformationWidget inherits VerticalLayout {
|
export component PropertyInformationWidget inherits VerticalLayout {
|
||||||
in property <PropertyInformation> property-information;
|
in property <PropertyInformation> property-information;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue