Expand the hit area area around tab close icons

This commit is contained in:
Nathan Sobo 2021-09-18 10:37:32 -07:00
parent 928779154e
commit c7e2b6dacb
3 changed files with 14 additions and 1 deletions

View file

@ -348,6 +348,17 @@ enum Spacing {
},
}
impl Padding {
pub fn uniform(padding: f32) -> Self {
Self {
top: padding,
left: padding,
bottom: padding,
right: padding,
}
}
}
impl ToJson for Padding {
fn to_json(&self) -> serde_json::Value {
let mut value = json!({});

View file

@ -116,7 +116,8 @@ impl Element for MouseEventHandler {
let hit_bounds = RectF::from_points(
bounds.origin() - vec2f(self.padding.left, self.padding.top),
bounds.lower_right() + vec2f(self.padding.right, self.padding.bottom),
);
)
.round_out();
self.state.update(cx, |state, cx| match event {
Event::MouseMoved {

View file

@ -292,6 +292,7 @@ impl Pane {
}
},
)
.with_padding(Padding::uniform(4.))
.with_cursor_style(CursorStyle::PointingHand)
.on_click(move |cx| {
cx.dispatch_action(CloseItem(item_id))