pub mod button;
pub mod chips;
pub mod dropdown;
pub mod gallery;
pub mod icon_button;
pub mod input;
pub mod paint;
pub mod preview;
pub mod surface;
pub mod tabs;
pub mod toggle;
pub use button::{Button, Size, Variant};
pub use chips::{reference_field, Chip, ReferenceField, ReferenceOutput};
pub use dropdown::{dropdown, Dropdown};
pub use icon_button::{BarSide, IconButton};
pub use input::{number_input, search_input, text_input, NumberInput, TextInput};
pub use tabs::{document_tabs, tab_bar, DocumentTab, DocumentTabsOutput};
pub use toggle::{checkbox, slider, switch, Check};
use eframe::egui;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Show {
#[default]
Live,
Hover,
Pressed,
Focus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub(crate) struct Interact {
pub hovered: bool,
pub pressed: bool,
pub focused: bool,
}
impl Interact {
pub fn of(response: &egui::Response, show: Show, enabled: bool) -> Self {
if !enabled {
return Interact::default();
}
Interact {
hovered: response.hovered() || matches!(show, Show::Hover | Show::Pressed),
pressed: response.is_pointer_button_down_on() || show == Show::Pressed,
focused: response.has_focus() || show == Show::Focus,
}
}
}
pub fn themed<R>(ui: &mut egui::Ui, theme: std::sync::Arc<crate::theme::Theme>, contents: impl FnOnce(&mut egui::Ui) -> R) -> R {
let before = crate::theme::stored(ui.ctx());
crate::theme::set(ui.ctx(), theme.clone());
let out = ui
.scope(|ui| {
let style = theme.style(ui.style());
ui.set_style(style);
contents(ui)
})
.inner;
match before {
Some(theme) => crate::theme::set(ui.ctx(), theme),
None => crate::theme::clear(ui.ctx()),
}
out
}