This commit is contained in:
sxyazi 2023-11-16 11:46:29 +08:00
parent 944fa6767c
commit 420a6ddf18
No known key found for this signature in database
2 changed files with 11 additions and 6 deletions

View file

@ -1,6 +1,6 @@
use serde::Deserialize;
#[derive(Clone, Copy, Default, Deserialize)]
#[derive(Clone, Copy, Default, Deserialize, PartialEq, Eq)]
pub enum Origin {
#[default]
#[serde(rename = "top-left")]

View file

@ -26,13 +26,18 @@ impl Ctx {
}
}
pub fn area(&self, pos: &Position) -> Rect {
// TODO: hovered
if let Origin::Hovered = pos.origin {
return Rect::default();
pub fn area(&self, position: &Position) -> Rect {
if position.origin != Origin::Hovered {
return position.rect();
}
pos.rect()
if let Some(r) =
self.manager.hovered().and_then(|h| self.manager.current().rect_current(&h.url))
{
Position::sticky(r, position.offset)
} else {
Position::new(Origin::TopCenter, position.offset).rect()
}
}
#[inline]