use crate::core::{Color, Rect};
use crate::render::RenderContext;
pub mod bottom_sheet;
pub mod color_dialog;
pub mod dialog_widget;
pub mod file_dialog;
pub mod find_replace_dialog;
pub mod font_dialog;
pub mod input_dialog;
pub mod message_box;
pub mod modal_bottom_sheet;
pub mod popover;
pub mod popup_window;
pub mod progress_dialog;
pub mod tooltip;
pub mod wizard;
pub use bottom_sheet::BottomSheet;
pub use color_dialog::ColorDialog;
pub use dialog_widget::Dialog;
pub use file_dialog::FileDialog;
pub use find_replace_dialog::FindReplaceDialog;
pub use font_dialog::FontDialog;
pub use input_dialog::InputDialog;
pub use message_box::MessageBox;
pub use modal_bottom_sheet::ModalBottomSheet;
pub use popover::Popover;
pub use popup_window::PopupWindow;
pub use progress_dialog::ProgressDialog;
pub use tooltip::Tooltip;
pub use wizard::{WizardDialog, WizardStep};
pub(crate) fn draw_modal_scrim(context: &mut RenderContext, page: Rect) {
draw_modal_scrim_scaled(context, page, 1.0);
}
pub(crate) fn draw_modal_scrim_scaled(context: &mut RenderContext, page: Rect, strength: f32) {
let strength = strength.clamp(0.0, 1.0);
if strength <= 0.0 {
return;
}
let scrim = crate::style::layer_color(crate::style::LayerColor::Scrim)
.unwrap_or_else(|| Color::BLACK.with_alpha(82));
let scrim = scrim.with_alpha((scrim.a as f32 * strength) as u8);
context.fill_rect(page, scrim);
}
pub(crate) const REVEAL_MIN_SCALE: f32 = 0.92;
pub(crate) fn scale_about_centre(rect: Rect, scale: f32) -> Rect {
let scale = scale.clamp(0.0, 1.0);
let width = ((rect.width as f32 * scale) + 0.5) as u32;
let height = ((rect.height as f32 * scale) + 0.5) as u32;
let dx = (rect.width.saturating_sub(width) / 2) as i32;
let dy = (rect.height.saturating_sub(height) / 2) as i32;
Rect::new(rect.x + dx, rect.y + dy, width, height)
}