pub use super::consume::{consume_event, drag_outcome_popup, ConsumeEventCtx};
pub use super::render::register_input_coordinator_popup;
use super::state::PopupState;
use crate::layout::{ClickDispatcher, EventBuilder, PopupHandle};
use crate::types::{Rect, WidgetId};
pub fn register_popup_dispatch(dispatcher: &mut ClickDispatcher, handle: &PopupHandle) {
use crate::layout::ChevronStepDirection;
let id: &WidgetId = &handle.id;
for (suffix, dir) in [
("chevron_up", ChevronStepDirection::Up),
("chevron_down", ChevronStepDirection::Down),
("chevron_left", ChevronStepDirection::Left),
("chevron_right", ChevronStepDirection::Right),
] {
let cid = WidgetId(format!("{}:{}", id.0, suffix));
dispatcher.on_exact(
format!("{}:{}", id.0, suffix),
EventBuilder::ChevronStep {
chevron_id: cid,
direction: dir,
},
);
}
}
pub fn handle_popup_dismiss(state: &PopupState, click_pos: (f64, f64), popup_rect: Rect) -> bool {
if state.is_dragging_any() {
return false;
}
!popup_rect.contains(click_pos.0, click_pos.1)
}
pub struct PopupGridCell<'a> {
pub id: &'a str,
pub color: &'a str,
}