use uzor::app_context::StateRegistry;
use uzor::input::InputCoordinator;
use uzor::tokens::{TokenTheme, Tokens};
use uzor::LayerId;
use uzor::WidgetId;
use uzor::WidgetState;
use crate::handle::{VisualView, Widgets};
use crate::types::spec::Spec;
use super::host::ContentCx;
pub(crate) fn interaction_state<S: Spec>(
view: &VisualView<S>,
id: &WidgetId,
disabled: bool,
) -> WidgetState {
if disabled {
WidgetState::Disabled
} else if view.is_pressed(id) {
WidgetState::Pressed
} else if view.is_hovered(id) {
WidgetState::Hovered
} else {
WidgetState::Normal
}
}
pub(crate) fn token_theme(tokens: &Tokens) -> TokenTheme {
TokenTheme::from_tokens(tokens)
}
pub(crate) fn theme_of<'a, C: ContentCx<'a>>(cx: &mut C) -> TokenTheme {
cx.with_paint(|_, _, _, tokens| token_theme(tokens))
}
pub(crate) fn parts<'w, 'a>(
widgets: &'w mut Widgets<'a>,
) -> (&'w mut InputCoordinator, &'w mut StateRegistry, &'w LayerId) {
(&mut widgets.coord, &mut widgets.states, &widgets.layer)
}