use super::api::Carousel;
use crate::{
accessibility::Scope, AccessActionKind as Kind, AccessOrientation, AccessRole, Id, Ui,
};
impl Carousel {
pub fn accessible_label(mut self, label: impl Into<String>) -> Self {
self.label = label.into();
self
}
}
pub(super) struct Region<'a> {
pub(super) label: &'a str,
pub(super) page: usize,
pub(super) count: usize,
pub(super) axis: usize,
pub(super) enabled: bool,
}
pub(super) fn begin(ui: &mut Ui<'_>, id: Id, region: Region<'_>) -> Scope {
ui.a11y_begin(id, AccessRole::Region, |node| {
node.label(region.label)
.numeric(region.page as f64 + 1.0, 1.0, region.count as f64)
.step(1.0)
.orientation(if region.axis == 0 {
AccessOrientation::Horizontal
} else {
AccessOrientation::Vertical
})
.disabled(!region.enabled)
.action(Kind::Increment)
.action(Kind::Decrement)
.action(Kind::SetValue);
})
}
pub(super) fn page(ui: &mut Ui<'_>, id: Id, page: usize, count: usize, current: bool) -> Scope {
ui.a11y_begin(id, AccessRole::Group, |node| {
node.label(format!("Page {}", page + 1))
.position_in_set(page, count)
.hidden(!current);
})
}