Handle different item_spacings when doing hover detection
This commit is contained in:
parent
6ff39d88bf
commit
bd192a0374
3 changed files with 12 additions and 3 deletions
|
@ -179,6 +179,7 @@ impl Prepared {
|
|||
let move_response = ctx.interact(
|
||||
layer_id,
|
||||
Rect::everything(),
|
||||
ctx.style().spacing.item_spacing,
|
||||
state.rect(),
|
||||
interact_id,
|
||||
Sense::click_and_drag(),
|
||||
|
|
|
@ -427,11 +427,12 @@ impl Context {
|
|||
self: &Arc<Self>,
|
||||
layer_id: LayerId,
|
||||
clip_rect: Rect,
|
||||
item_spacing: Vec2,
|
||||
rect: Rect,
|
||||
id: Option<Id>,
|
||||
sense: Sense,
|
||||
) -> Response {
|
||||
let interact_rect = rect.expand2(0.5 * self.style().spacing.item_spacing); // make it easier to click. TODO: nice way to do this
|
||||
let interact_rect = rect.expand2((0.5 * item_spacing).min(Vec2::splat(5.0))); // make it easier to click
|
||||
let hovered = self.contains_mouse(layer_id, clip_rect, interact_rect);
|
||||
let has_kb_focus = id.map(|id| self.memory().has_kb_focus(id)).unwrap_or(false);
|
||||
|
||||
|
|
|
@ -372,14 +372,21 @@ impl Ui {
|
|||
/// # Interaction
|
||||
impl Ui {
|
||||
pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response {
|
||||
self.ctx()
|
||||
.interact(self.layer_id(), self.clip_rect(), rect, Some(id), sense)
|
||||
self.ctx().interact(
|
||||
self.layer_id(),
|
||||
self.clip_rect(),
|
||||
self.style().spacing.item_spacing,
|
||||
rect,
|
||||
Some(id),
|
||||
sense,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn interact_hover(&self, rect: Rect) -> Response {
|
||||
self.ctx().interact(
|
||||
self.layer_id(),
|
||||
self.clip_rect(),
|
||||
self.style().spacing.item_spacing,
|
||||
rect,
|
||||
None,
|
||||
Sense::nothing(),
|
||||
|
|
Loading…
Reference in a new issue