Skip to content

Commit

Permalink
Merge pull request #971 from tarkah/fix/pane-dragging-overlay
Browse files Browse the repository at this point in the history
fix: allow titlebar overlays to close when dragging pane
  • Loading branch information
hecrj authored Jul 28, 2021
2 parents 2586210 + 6618c6b commit a08e4eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
37 changes: 19 additions & 18 deletions native/src/widget/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,25 @@ where
_ => {}
}

if self.state.picked_pane().is_none() {
self.elements
.iter_mut()
.zip(layout.children())
.map(|((_, pane), layout)| {
pane.on_event(
event.clone(),
layout,
cursor_position,
renderer,
clipboard,
messages,
)
})
.fold(event_status, event::Status::merge)
} else {
event::Status::Captured
}
let picked_pane = self.state.picked_pane().map(|(pane, _)| pane);

self.elements
.iter_mut()
.zip(layout.children())
.map(|((pane, content), layout)| {
let is_picked = picked_pane == Some(*pane);

content.on_event(
event.clone(),
layout,
cursor_position,
renderer,
clipboard,
messages,
is_picked,
)
})
.fold(event_status, event::Status::merge)
}

fn draw(
Expand Down
21 changes: 13 additions & 8 deletions native/src/widget/pane_grid/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
messages: &mut Vec<Message>,
is_picked: bool,
) -> event::Status {
let mut event_status = event::Status::Ignored;

Expand All @@ -169,14 +170,18 @@ where
layout
};

let body_status = self.body.on_event(
event,
body_layout,
cursor_position,
renderer,
clipboard,
messages,
);
let body_status = if is_picked {
event::Status::Ignored
} else {
self.body.on_event(
event,
body_layout,
cursor_position,
renderer,
clipboard,
messages,
)
};

event_status.merge(body_status)
}
Expand Down

0 comments on commit a08e4eb

Please sign in to comment.