mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 21:24:17 +00:00
live-preview: Remove setters that are not too helpful
We are getting too many setters for properties in our Api IMHO, so remove two that are easy enough to replicate with `set_code_property`.
This commit is contained in:
parent
64e8330d04
commit
c92960b9d3
4 changed files with 8 additions and 38 deletions
|
|
@ -425,16 +425,6 @@ fn set_code_binding(
|
|||
)
|
||||
}
|
||||
|
||||
fn set_bool_binding(
|
||||
element_url: slint::SharedString,
|
||||
element_version: i32,
|
||||
element_offset: i32,
|
||||
property_name: slint::SharedString,
|
||||
value: bool,
|
||||
) {
|
||||
set_binding(element_url, element_version, element_offset, property_name, value.to_string())
|
||||
}
|
||||
|
||||
fn set_color_binding(
|
||||
element_url: slint::SharedString,
|
||||
element_version: i32,
|
||||
|
|
@ -458,23 +448,6 @@ fn set_color_binding(
|
|||
)
|
||||
}
|
||||
|
||||
fn set_enum_binding(
|
||||
element_url: slint::SharedString,
|
||||
element_version: i32,
|
||||
element_offset: i32,
|
||||
property_name: slint::SharedString,
|
||||
enum_type: slint::SharedString,
|
||||
enum_value: slint::SharedString,
|
||||
) {
|
||||
set_binding(
|
||||
element_url,
|
||||
element_version,
|
||||
element_offset,
|
||||
property_name,
|
||||
format!("{}.{}", enum_type, enum_value),
|
||||
)
|
||||
}
|
||||
|
||||
fn set_string_binding(
|
||||
element_url: slint::SharedString,
|
||||
element_version: i32,
|
||||
|
|
|
|||
|
|
@ -75,8 +75,6 @@ pub fn create_ui(style: String, experimental: bool) -> Result<PreviewUi, Platfor
|
|||
api.on_test_string_binding(super::test_string_binding);
|
||||
api.on_set_code_binding(super::set_code_binding);
|
||||
api.on_set_color_binding(super::set_color_binding);
|
||||
api.on_set_bool_binding(super::set_bool_binding);
|
||||
api.on_set_enum_binding(super::set_enum_binding);
|
||||
api.on_set_string_binding(super::set_string_binding);
|
||||
|
||||
Ok(ui)
|
||||
|
|
|
|||
|
|
@ -227,7 +227,5 @@ export global Api {
|
|||
pure callback test-string-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* value: */ string) -> bool;
|
||||
callback set-code-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* property-value: */ string);
|
||||
callback set-color-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* property-value: */ color);
|
||||
callback set-bool-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* value: */ bool);
|
||||
callback set-enum-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* enum_type: */ string, /* enum_value: */ string);
|
||||
callback set-string-binding(/* element-url: */ string, /* element-version: */ int, /* element-offset: */ int, /* property-name: */ string, /* value: */ string);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,18 +112,19 @@ export component PropertyView {
|
|||
checked: property-row.property-value.value_bool;
|
||||
|
||||
toggled() => {
|
||||
Api.set-bool-binding(
|
||||
Api.set-code-binding(
|
||||
root.current-element.source-uri,
|
||||
root.current-element.source-version,
|
||||
root.current-element.range.start,
|
||||
property.name,
|
||||
self.checked,
|
||||
self.checked ? "true" : "false",
|
||||
);
|
||||
}
|
||||
}
|
||||
if property-row.property-value.kind == PropertyValueKind.string: LineEdit {
|
||||
width: 100%;
|
||||
height: 100%; // otherwise this gets too high and covers several rows.
|
||||
// otherwise this gets too high and covers several rows.
|
||||
height: 100%;
|
||||
text: property-row.property-value.value-string;
|
||||
|
||||
edited(text) => {
|
||||
|
|
@ -148,20 +149,20 @@ export component PropertyView {
|
|||
}
|
||||
if property-row.property-value.kind == PropertyValueKind.enum: ComboBox {
|
||||
width: 100%;
|
||||
height: 100%; // otherwise this gets too high and covers several rows.
|
||||
// otherwise this gets too high and covers several rows.
|
||||
height: 100%;
|
||||
|
||||
current-index: property-row.property-value.value-int;
|
||||
|
||||
model: property-row.property-value.visual-items;
|
||||
|
||||
selected(value) => {
|
||||
Api.set-enum-binding(
|
||||
Api.set-code-binding(
|
||||
root.current-element.source-uri,
|
||||
root.current-element.source-version,
|
||||
root.current-element.range.start,
|
||||
property.name,
|
||||
property-value.value_string,
|
||||
value,
|
||||
property-value.value_string + "." + value,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue