use std::rc::Rc;
use std::sync::Arc;
use crate::callback::Callback;
use crate::core::element::Key;
use crate::core::node::WidgetNode;
use crate::style::{Rect, RichText, Style, StyleSlot};
use crate::widgets::internal::StackProps;
use crate::widgets::{TabVariant, TabsEvent};
#[derive(Clone, Debug)]
pub struct StackLayoutCache {
pub bounds: Rect,
pub layout_hash: u64,
pub child_rects: Rc<Vec<Rect>>,
}
#[derive(Clone)]
pub struct StackNode {
pub props: StackProps,
pub tab_titles: Vec<RichText>,
pub active_tab: usize,
pub on_tab_change: Option<Callback<TabsEvent>>,
pub active_tab_style: StyleSlot,
pub inactive_tab_style: Style,
pub tab_variant: TabVariant,
pub title_prefix: Option<Arc<str>>,
pub layout_cache: Option<StackLayoutCache>,
pub last_focused_key: Option<Key>,
}
impl WidgetNode for StackNode {
fn has_on_click(&self) -> bool {
self.on_tab_change.is_some()
}
fn hit_test_refinement(&self, _x: i16, y: i16, rect: Rect) -> Option<bool> {
if self.on_tab_change.is_some() {
if y != rect.y {
return Some(false);
}
}
None
}
}