use egui::{Id, Ui, WidgetText};
use crate::{NodePath, TabStyle};
pub trait TabViewer {
type Tab;
fn title(&mut self, tab: &mut Self::Tab) -> WidgetText;
fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab);
fn context_menu(&mut self, _ui: &mut Ui, _tab: &mut Self::Tab, _path: NodePath) {}
fn id(&mut self, tab: &mut Self::Tab) -> Id {
Id::new(self.title(tab).text())
}
fn on_tab_button(&mut self, _tab: &mut Self::Tab, _response: &egui::Response) {}
fn on_close(&mut self, _tab: &mut Self::Tab) -> OnCloseResponse {
OnCloseResponse::Close
}
fn is_closeable(&self, _tab: &Self::Tab) -> bool {
true
}
#[deprecated = "Use the `TabViewer::is_closeable` function instead."]
fn closeable(&mut self, _tab: &mut Self::Tab) -> bool {
true
}
fn force_close(&mut self, _tab: &mut Self::Tab) -> bool {
false
}
fn on_add(&mut self, _path: NodePath) {}
fn on_rect_changed(&mut self, _tab: &mut Self::Tab) {}
fn add_popup(&mut self, _ui: &mut Ui, _path: NodePath) {}
fn tab_style_override(&self, _tab: &Self::Tab, _global_style: &TabStyle) -> Option<TabStyle> {
None
}
fn allowed_in_windows(&self, _tab: &mut Self::Tab) -> bool {
true
}
fn clear_background(&self, _tab: &Self::Tab) -> bool {
true
}
fn scroll_bars(&self, _tab: &Self::Tab) -> [bool; 2] {
[true, true]
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum OnCloseResponse {
Close,
Focus,
Ignore,
}