Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow titlebar overlays to close when dragging pane #971

Merged
merged 3 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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