mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
TextInput: use selection colors from palette
This commit is contained in:
parent
b2016239d1
commit
044518ee81
4 changed files with 38 additions and 8 deletions
|
@ -17,6 +17,7 @@ All notable changes to this project are documented in this file.
|
|||
### Widgets
|
||||
|
||||
- Checkbox: fix text color in fluent style (#6239)
|
||||
- TextInput: fix selection colors not used from style (#6326)
|
||||
|
||||
### LSP and tooling
|
||||
|
||||
|
|
|
@ -217,8 +217,8 @@ export component TextInput {
|
|||
in property <bool> font-italic;
|
||||
in property <int> font-weight;
|
||||
in property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
|
||||
in property <color> selection-foreground-color: #000;
|
||||
in property <color> selection-background-color: #808080;
|
||||
in property <color> selection-foreground-color; // Palette.selection-foreground set in apply_default_properties_from_style
|
||||
in property <color> selection-background-color; // Palette.selection-background set in apply_default_properties_from_style
|
||||
in property <TextHorizontalAlignment> horizontal-alignment;
|
||||
in property <TextVerticalAlignment> vertical-alignment;
|
||||
in property <TextWrap> wrap;
|
||||
|
|
|
@ -68,6 +68,14 @@ pub async fn run_passes(
|
|||
.await
|
||||
.unwrap_or_else(|| panic!("can't load style metrics"))
|
||||
};
|
||||
let palette = {
|
||||
// Ignore import errors
|
||||
let mut build_diags_to_ignore = crate::diagnostics::BuildDiagnostics::default();
|
||||
type_loader
|
||||
.import_component("std-widgets.slint", "Palette", &mut build_diags_to_ignore)
|
||||
.await
|
||||
.unwrap_or_else(|| panic!("can't load palette"))
|
||||
};
|
||||
|
||||
let global_type_registry = type_loader.global_type_registry.clone();
|
||||
run_import_passes(doc, type_loader, diag);
|
||||
|
@ -92,6 +100,7 @@ pub async fn run_passes(
|
|||
apply_default_properties_from_style::apply_default_properties_from_style(
|
||||
component,
|
||||
&style_metrics,
|
||||
&palette,
|
||||
diag,
|
||||
);
|
||||
lower_states::lower_states(component, &doc.local_registry, diag);
|
||||
|
|
|
@ -15,6 +15,7 @@ use std::rc::Rc;
|
|||
pub fn apply_default_properties_from_style(
|
||||
root_component: &Rc<Component>,
|
||||
style_metrics: &Rc<Component>,
|
||||
palette: &Rc<Component>,
|
||||
_diag: &mut BuildDiagnostics,
|
||||
) {
|
||||
crate::object_tree::recurse_elem_including_sub_components(
|
||||
|
@ -30,13 +31,32 @@ pub fn apply_default_properties_from_style(
|
|||
"text-cursor-width",
|
||||
))
|
||||
});
|
||||
elem.set_binding_if_not_set("color".into(), || Expression::Cast {
|
||||
from: Expression::PropertyReference(NamedReference::new(
|
||||
&style_metrics.root_element,
|
||||
"default-text-color",
|
||||
elem.set_binding_if_not_set("color".into(), || {
|
||||
Expression::PropertyReference(NamedReference::new(
|
||||
&palette.root_element,
|
||||
"foreground",
|
||||
))
|
||||
.into(),
|
||||
to: Type::Brush,
|
||||
.into()
|
||||
});
|
||||
elem.set_binding_if_not_set("selection-background-color".into(), || {
|
||||
Expression::Cast {
|
||||
from: Expression::PropertyReference(NamedReference::new(
|
||||
&palette.root_element,
|
||||
"selection-background",
|
||||
))
|
||||
.into(),
|
||||
to: Type::Color,
|
||||
}
|
||||
});
|
||||
elem.set_binding_if_not_set("selection-foreground-color".into(), || {
|
||||
Expression::Cast {
|
||||
from: Expression::PropertyReference(NamedReference::new(
|
||||
&palette.root_element,
|
||||
"selection-foreground",
|
||||
))
|
||||
.into(),
|
||||
to: Type::Color,
|
||||
}
|
||||
});
|
||||
}
|
||||
"Text" => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue