Merge pull request #1361 from mtkennerly/feature/prevent-overlapping-title-bar
Prevent pane grid title bar content and controls from overlapping
This commit is contained in:
commit
092dfc34e8
2 changed files with 97 additions and 52 deletions
|
|
@ -105,19 +105,17 @@ where
|
||||||
|
|
||||||
let mut children = padded.children();
|
let mut children = padded.children();
|
||||||
let title_layout = children.next().unwrap();
|
let title_layout = children.next().unwrap();
|
||||||
|
let mut show_title = true;
|
||||||
self.content.draw(
|
|
||||||
renderer,
|
|
||||||
&inherited_style,
|
|
||||||
title_layout,
|
|
||||||
cursor_position,
|
|
||||||
viewport,
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(controls) = &self.controls {
|
if let Some(controls) = &self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
|
||||||
if show_controls || self.always_show_controls {
|
if show_controls || self.always_show_controls {
|
||||||
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
|
> padded.bounds().width
|
||||||
|
{
|
||||||
|
show_title = false;
|
||||||
|
}
|
||||||
controls.draw(
|
controls.draw(
|
||||||
renderer,
|
renderer,
|
||||||
&inherited_style,
|
&inherited_style,
|
||||||
|
|
@ -127,6 +125,16 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if show_title {
|
||||||
|
self.content.draw(
|
||||||
|
renderer,
|
||||||
|
&inherited_style,
|
||||||
|
title_layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the mouse cursor is over the pick area of the
|
/// Returns whether the mouse cursor is over the pick area of the
|
||||||
|
|
@ -214,9 +222,15 @@ where
|
||||||
|
|
||||||
let mut children = padded.children();
|
let mut children = padded.children();
|
||||||
let title_layout = children.next().unwrap();
|
let title_layout = children.next().unwrap();
|
||||||
|
let mut show_title = true;
|
||||||
|
|
||||||
let control_status = if let Some(controls) = &mut self.controls {
|
let control_status = if let Some(controls) = &mut self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
|
> padded.bounds().width
|
||||||
|
{
|
||||||
|
show_title = false;
|
||||||
|
}
|
||||||
|
|
||||||
controls.on_event(
|
controls.on_event(
|
||||||
event.clone(),
|
event.clone(),
|
||||||
|
|
@ -230,14 +244,18 @@ where
|
||||||
event::Status::Ignored
|
event::Status::Ignored
|
||||||
};
|
};
|
||||||
|
|
||||||
let title_status = self.content.on_event(
|
let title_status = if show_title {
|
||||||
event,
|
self.content.on_event(
|
||||||
title_layout,
|
event,
|
||||||
cursor_position,
|
title_layout,
|
||||||
renderer,
|
cursor_position,
|
||||||
clipboard,
|
renderer,
|
||||||
shell,
|
clipboard,
|
||||||
);
|
shell,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
event::Status::Ignored
|
||||||
|
};
|
||||||
|
|
||||||
control_status.merge(title_status)
|
control_status.merge(title_status)
|
||||||
}
|
}
|
||||||
|
|
@ -264,15 +282,20 @@ where
|
||||||
|
|
||||||
if let Some(controls) = &self.controls {
|
if let Some(controls) = &self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
let controls_interaction = controls.mouse_interaction(
|
||||||
|
controls_layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
renderer,
|
||||||
|
);
|
||||||
|
|
||||||
controls
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
.mouse_interaction(
|
> padded.bounds().width
|
||||||
controls_layout,
|
{
|
||||||
cursor_position,
|
controls_interaction
|
||||||
viewport,
|
} else {
|
||||||
renderer,
|
controls_interaction.max(title_interaction)
|
||||||
)
|
}
|
||||||
.max(title_interaction)
|
|
||||||
} else {
|
} else {
|
||||||
title_interaction
|
title_interaction
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,18 +132,15 @@ where
|
||||||
|
|
||||||
let mut children = padded.children();
|
let mut children = padded.children();
|
||||||
let title_layout = children.next().unwrap();
|
let title_layout = children.next().unwrap();
|
||||||
|
let mut show_title = true;
|
||||||
self.content.as_widget().draw(
|
|
||||||
&tree.children[0],
|
|
||||||
renderer,
|
|
||||||
&inherited_style,
|
|
||||||
title_layout,
|
|
||||||
cursor_position,
|
|
||||||
viewport,
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(controls) = &self.controls {
|
if let Some(controls) = &self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
|
> padded.bounds().width
|
||||||
|
{
|
||||||
|
show_title = false;
|
||||||
|
}
|
||||||
|
|
||||||
if show_controls || self.always_show_controls {
|
if show_controls || self.always_show_controls {
|
||||||
controls.as_widget().draw(
|
controls.as_widget().draw(
|
||||||
|
|
@ -156,6 +153,17 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if show_title {
|
||||||
|
self.content.as_widget().draw(
|
||||||
|
&tree.children[0],
|
||||||
|
renderer,
|
||||||
|
&inherited_style,
|
||||||
|
title_layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the mouse cursor is over the pick area of the
|
/// Returns whether the mouse cursor is over the pick area of the
|
||||||
|
|
@ -247,9 +255,15 @@ where
|
||||||
|
|
||||||
let mut children = padded.children();
|
let mut children = padded.children();
|
||||||
let title_layout = children.next().unwrap();
|
let title_layout = children.next().unwrap();
|
||||||
|
let mut show_title = true;
|
||||||
|
|
||||||
let control_status = if let Some(controls) = &mut self.controls {
|
let control_status = if let Some(controls) = &mut self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
|
> padded.bounds().width
|
||||||
|
{
|
||||||
|
show_title = false;
|
||||||
|
}
|
||||||
|
|
||||||
controls.as_widget_mut().on_event(
|
controls.as_widget_mut().on_event(
|
||||||
&mut tree.children[1],
|
&mut tree.children[1],
|
||||||
|
|
@ -264,15 +278,19 @@ where
|
||||||
event::Status::Ignored
|
event::Status::Ignored
|
||||||
};
|
};
|
||||||
|
|
||||||
let title_status = self.content.as_widget_mut().on_event(
|
let title_status = if show_title {
|
||||||
&mut tree.children[0],
|
self.content.as_widget_mut().on_event(
|
||||||
event,
|
&mut tree.children[0],
|
||||||
title_layout,
|
event,
|
||||||
cursor_position,
|
title_layout,
|
||||||
renderer,
|
cursor_position,
|
||||||
clipboard,
|
renderer,
|
||||||
shell,
|
clipboard,
|
||||||
);
|
shell,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
event::Status::Ignored
|
||||||
|
};
|
||||||
|
|
||||||
control_status.merge(title_status)
|
control_status.merge(title_status)
|
||||||
}
|
}
|
||||||
|
|
@ -301,17 +319,21 @@ where
|
||||||
|
|
||||||
if let Some(controls) = &self.controls {
|
if let Some(controls) = &self.controls {
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
|
let controls_interaction = controls.as_widget().mouse_interaction(
|
||||||
|
&tree.children[1],
|
||||||
|
controls_layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
renderer,
|
||||||
|
);
|
||||||
|
|
||||||
controls
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
.as_widget()
|
> padded.bounds().width
|
||||||
.mouse_interaction(
|
{
|
||||||
&tree.children[1],
|
controls_interaction
|
||||||
controls_layout,
|
} else {
|
||||||
cursor_position,
|
controls_interaction.max(title_interaction)
|
||||||
viewport,
|
}
|
||||||
renderer,
|
|
||||||
)
|
|
||||||
.max(title_interaction)
|
|
||||||
} else {
|
} else {
|
||||||
title_interaction
|
title_interaction
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue