mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Do the apply_default_properties_from_style before the lower_states pass
because we don't want the lowered state property to look like we set a property on it. Also do the ensure_window before because it need to be done before to be assigned the default color
This commit is contained in:
parent
90a97cd737
commit
f316c38d54
3 changed files with 25 additions and 17 deletions
|
@ -85,6 +85,19 @@ pub async fn run_passes(
|
||||||
focus_item::resolve_element_reference_in_set_focus_calls(component, diag);
|
focus_item::resolve_element_reference_in_set_focus_calls(component, diag);
|
||||||
focus_item::determine_initial_focus_item(component, diag);
|
focus_item::determine_initial_focus_item(component, diag);
|
||||||
focus_item::erase_forward_focus_properties(component);
|
focus_item::erase_forward_focus_properties(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_window::ensure_window(root_component, &doc.local_registry);
|
||||||
|
|
||||||
|
for component in (root_component.used_types.borrow().sub_components.iter())
|
||||||
|
.chain(std::iter::once(root_component))
|
||||||
|
{
|
||||||
|
apply_default_properties_from_style::apply_default_properties_from_style(
|
||||||
|
component,
|
||||||
|
&mut type_loader,
|
||||||
|
diag,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
flickable::handle_flickable(component, &global_type_registry.borrow());
|
flickable::handle_flickable(component, &global_type_registry.borrow());
|
||||||
lower_states::lower_states(component, &doc.local_registry, diag);
|
lower_states::lower_states(component, &doc.local_registry, diag);
|
||||||
repeater_component::process_repeater_components(component);
|
repeater_component::process_repeater_components(component);
|
||||||
|
@ -102,18 +115,6 @@ pub async fn run_passes(
|
||||||
visible::handle_visible(component, &global_type_registry.borrow());
|
visible::handle_visible(component, &global_type_registry.borrow());
|
||||||
materialize_fake_properties::materialize_fake_properties(component);
|
materialize_fake_properties::materialize_fake_properties(component);
|
||||||
}
|
}
|
||||||
ensure_window::ensure_window(root_component, &doc.local_registry);
|
|
||||||
|
|
||||||
for component in (root_component.used_types.borrow().sub_components.iter())
|
|
||||||
.chain(std::iter::once(root_component))
|
|
||||||
{
|
|
||||||
apply_default_properties_from_style::apply_default_properties_from_style(
|
|
||||||
component,
|
|
||||||
&mut type_loader,
|
|
||||||
diag,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
collect_globals::collect_globals(&doc, diag);
|
collect_globals::collect_globals(&doc, diag);
|
||||||
|
|
||||||
let disable_inlining = match std::env::var("SIXTYFPS_DISABLE_INLINING") {
|
let disable_inlining = match std::env::var("SIXTYFPS_DISABLE_INLINING") {
|
||||||
|
@ -137,9 +138,7 @@ pub async fn run_passes(
|
||||||
optimize_useless_rectangles::optimize_useless_rectangles(component);
|
optimize_useless_rectangles::optimize_useless_rectangles(component);
|
||||||
move_declarations::move_declarations(component, diag);
|
move_declarations::move_declarations(component, diag);
|
||||||
remove_aliases::remove_aliases(component, diag);
|
remove_aliases::remove_aliases(component, diag);
|
||||||
|
|
||||||
resolve_native_classes::resolve_native_classes(component);
|
resolve_native_classes::resolve_native_classes(component);
|
||||||
|
|
||||||
remove_unused_properties::remove_unused_properties(component);
|
remove_unused_properties::remove_unused_properties(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +155,6 @@ pub async fn run_passes(
|
||||||
std::iter::once(&*doc).chain(type_loader.all_documents()),
|
std::iter::once(&*doc).chain(type_loader.all_documents()),
|
||||||
compiler_config.embed_resources,
|
compiler_config.embed_resources,
|
||||||
);
|
);
|
||||||
|
|
||||||
root_component.is_root_component.set(true);
|
root_component.is_root_component.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,11 @@ use std::collections::HashSet;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub fn ensure_window(component: &Rc<Component>, type_register: &TypeRegister) {
|
pub fn ensure_window(component: &Rc<Component>, type_register: &TypeRegister) {
|
||||||
if matches!(component.root_element.borrow().base_type.to_string().as_str(), "Window" | "Dialog")
|
if component
|
||||||
|
.root_element
|
||||||
|
.borrow()
|
||||||
|
.builtin_type()
|
||||||
|
.map_or(true, |b| matches!(b.name.as_str(), "Window" | "Dialog"))
|
||||||
{
|
{
|
||||||
return; // already a window, nothing to do
|
return; // already a window, nothing to do
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,16 @@ TestCase := Rectangle {
|
||||||
color: #ffff00ff;
|
color: #ffff00ff;
|
||||||
}
|
}
|
||||||
text_in_sub_element := SubElement { sub_color: #ff0000; }
|
text_in_sub_element := SubElement { sub_color: #ff0000; }
|
||||||
|
text_in_state := Text { }
|
||||||
|
states [ xx when false: { text_in_state.color: #abc; } ]
|
||||||
|
|
||||||
property <color> default_text_color: default_text.color;
|
property <color> default_text_color: default_text.color;
|
||||||
property <color> color_of_initialized_text: text_with_color.color;
|
property <color> color_of_initialized_text: text_with_color.color;
|
||||||
property <color> color_of_sub_element_text: text_in_sub_element.sub_color;
|
property <color> color_of_sub_element_text: text_in_sub_element.sub_color;
|
||||||
|
property <color> color_in_state: text-in-state.color;
|
||||||
|
|
||||||
property <bool> test: default_text_color == StyleMetrics.default-text-color && color-of-initialized-text == #ffff00ff
|
property <bool> test: default_text_color == StyleMetrics.default-text-color && color-of-initialized-text == #ffff00ff
|
||||||
&& color_of_sub_element_text == #ff0000;
|
&& color_of_sub_element_text == #ff0000 && color-in-state == StyleMetrics.default-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +47,8 @@ instance.set_binding_to_default_text_color(sixtyfps::Color::from_rgb_uint8(0, 0,
|
||||||
assert_eq(instance.get_default_text_color(), sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
assert_eq(instance.get_default_text_color(), sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
||||||
assert_eq(instance.get_color_of_initialized_text(), sixtyfps::Color::from_rgb_uint8(255, 255, 0));
|
assert_eq(instance.get_color_of_initialized_text(), sixtyfps::Color::from_rgb_uint8(255, 255, 0));
|
||||||
assert_eq(instance.get_color_of_sub_element_text(), sixtyfps::Color::from_rgb_uint8(255, 0, 0));
|
assert_eq(instance.get_color_of_sub_element_text(), sixtyfps::Color::from_rgb_uint8(255, 0, 0));
|
||||||
|
assert_eq(instance.get_color_in_state(), sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
@ -52,6 +57,7 @@ instance.set_binding_to_default_text_color(sixtyfps::Color::from_rgb_u8(0, 0, 13
|
||||||
assert_eq!(instance.get_default_text_color(), sixtyfps::Color::from_rgb_u8(0, 0, 133));
|
assert_eq!(instance.get_default_text_color(), sixtyfps::Color::from_rgb_u8(0, 0, 133));
|
||||||
assert_eq!(instance.get_color_of_initialized_text(), sixtyfps::Color::from_rgb_u8(255, 255, 0));
|
assert_eq!(instance.get_color_of_initialized_text(), sixtyfps::Color::from_rgb_u8(255, 255, 0));
|
||||||
assert_eq!(instance.get_color_of_sub_element_text(), sixtyfps::Color::from_rgb_u8(255, 0, 0));
|
assert_eq!(instance.get_color_of_sub_element_text(), sixtyfps::Color::from_rgb_u8(255, 0, 0));
|
||||||
|
assert_eq!(instance.get_color_in_state(), sixtyfps::Color::from_rgb_u8(0, 0, 133));
|
||||||
```
|
```
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue