Skip to content

Commit

Permalink
Merge pull request #1480 from tarkah/more-pane-grid-fixes
Browse files Browse the repository at this point in the history
More pane grid fixes
  • Loading branch information
hecrj authored Oct 19, 2022
2 parents 69e288c + 069371c commit 8221794
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
46 changes: 27 additions & 19 deletions native/src/widget/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ where
cursor_position,
viewport,
renderer,
self.on_drag.is_some(),
)
})
.max()
Expand Down Expand Up @@ -648,7 +649,7 @@ pub fn mouse_interaction(
resize_leeway: Option<u16>,
) -> Option<mouse::Interaction> {
if action.picked_pane().is_some() {
return Some(mouse::Interaction::Grab);
return Some(mouse::Interaction::Grabbing);
}

let resize_axis =
Expand Down Expand Up @@ -756,27 +757,12 @@ pub fn draw<Renderer, T>(
cursor_position
};

let mut render_picked_pane = None;

for ((id, pane), layout) in elements.zip(layout.children()) {
match picked_pane {
Some((dragging, origin)) if id == dragging => {
let bounds = layout.bounds();

renderer.with_translation(
cursor_position
- Point::new(bounds.x + origin.x, bounds.y + origin.y),
|renderer| {
renderer.with_layer(bounds, |renderer| {
draw_pane(
pane,
renderer,
default_style,
layout,
pane_cursor_position,
viewport,
);
});
},
);
render_picked_pane = Some((pane, origin, layout));
}
_ => {
draw_pane(
Expand All @@ -791,6 +777,28 @@ pub fn draw<Renderer, T>(
}
}

// Render picked pane last
if let Some((pane, origin, layout)) = render_picked_pane {
let bounds = layout.bounds();

renderer.with_translation(
cursor_position
- Point::new(bounds.x + origin.x, bounds.y + origin.y),
|renderer| {
renderer.with_layer(bounds, |renderer| {
draw_pane(
pane,
renderer,
default_style,
layout,
pane_cursor_position,
viewport,
);
});
},
);
};

if let Some((axis, split_region, is_picked)) = picked_split {
let highlight = if is_picked {
theme.picked_split(style)
Expand Down
3 changes: 2 additions & 1 deletion native/src/widget/pane_grid/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ where
cursor_position: Point,
viewport: &Rectangle,
renderer: &Renderer,
drag_enabled: bool,
) -> mouse::Interaction {
let (body_layout, title_bar_interaction) =
if let Some(title_bar) = &self.title_bar {
Expand All @@ -247,7 +248,7 @@ where
let is_over_pick_area = title_bar
.is_over_pick_area(title_bar_layout, cursor_position);

if is_over_pick_area {
if is_over_pick_area && drag_enabled {
return mouse::Interaction::Grab;
}

Expand Down

0 comments on commit 8221794

Please sign in to comment.