ailloli_ui_widgets/chrome/window_drag_region.rs
1//! Geometry-only hit testing for client-side title-bar drag regions.
2
3use ailloli_ui_core::{Point, Rect};
4
5/// Window drag region: no `DrawCmd` (hit-test only).
6///
7/// Returns `true` when enabled and `p` is inside the inclusive rectangle.
8/// The rectangle is not normalized.
9///
10/// # Examples
11///
12/// ```
13/// use ailloli_ui_core::{Point, Rect};
14/// use ailloli_ui_widgets::chrome::hit_window_drag_region;
15/// let bounds = Rect::new(0.0, 0.0, 100.0, 30.0);
16/// assert!(hit_window_drag_region(bounds, Point::new(50.0, 10.0), true));
17/// assert!(!hit_window_drag_region(bounds, Point::new(50.0, 10.0), false));
18/// ```
19pub fn hit_window_drag_region(bounds: Rect, p: Point, enabled: bool) -> bool {
20 enabled && bounds.contains(p.x, p.y)
21}