use super::internal;
use crate::prelude::*;
pub trait AccessibilityModifiers: internal::Modifiable {
fn role(mut self, role: Role) -> Self {
let id = self.entity();
self.context().style.role.insert(id, role);
self.context().style.needs_access_update(id);
self
}
fn name<U: ToStringLocalized>(mut self, name: impl Res<U>) -> Self {
let entity = self.entity();
let current = self.current();
self.context().with_current(current, move |cx| {
name.set_or_bind(cx, entity, move |cx, name| {
cx.style.name.insert(entity, name.get(cx).to_string_local(cx));
cx.style.needs_access_update(entity);
});
});
self
}
fn default_action_verb(mut self, action_verb: DefaultActionVerb) -> Self {
let id = self.entity();
self.context().style.default_action_verb.insert(id, action_verb);
self.context().style.needs_access_update(id);
self
}
fn live(mut self, live: Live) -> Self {
let id = self.entity();
self.context().style.live.insert(id, live);
self.context().style.needs_access_update(id);
self
}
fn hidden<U: Into<bool>>(mut self, hidden: impl Res<U>) -> Self {
let entity = self.entity();
let current = self.current();
self.context().with_current(current, |cx| {
hidden.set_or_bind(cx, entity, |cx, hidden| {
cx.style.hidden.insert(cx.current, hidden.get(cx).into());
cx.style.needs_access_update(cx.current);
});
});
self
}
fn numeric_value<U: Into<f64>>(mut self, value: impl Res<U>) -> Self {
let entity = self.entity();
let current = self.current();
self.context().with_current(current, |cx| {
value.set_or_bind(cx, entity, |cx, val| {
let v = val.get(cx).into();
cx.style.numeric_value.insert(cx.current, v);
cx.style.needs_access_update(cx.current);
});
});
self
}
fn text_value<U: ToStringLocalized>(mut self, value: impl Res<U>) -> Self {
let entity = self.entity();
let current = self.current();
self.context().with_current(current, |cx| {
value.set_or_bind(cx, entity, |cx, val| {
cx.style.text_value.insert(cx.current, val.get(cx).to_string_local(cx));
cx.style.needs_access_update(cx.current);
});
});
self
}
}
impl<'a, V: View> AccessibilityModifiers for Handle<'a, V> {}