summaryrefslogtreecommitdiffstats
path: root/native/src/widget/pane_grid
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-08 19:31:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-08 19:31:45 +0200
commitfa55dff61db47197a961152285c6a6abfab0b217 (patch)
tree44904afb16a0cab9e22fce0d73a5616676cd426b /native/src/widget/pane_grid
parent1dd1a2f97fc747e15e12b5188dad6c41b0d052ea (diff)
parent66eb6263003c1bbedd1fd14d6b12f172d20a6211 (diff)
downloadiced-fa55dff61db47197a961152285c6a6abfab0b217.tar.gz
iced-fa55dff61db47197a961152285c6a6abfab0b217.tar.bz2
iced-fa55dff61db47197a961152285c6a6abfab0b217.zip
Merge branch 'master' into theming
Diffstat (limited to 'native/src/widget/pane_grid')
-rw-r--r--native/src/widget/pane_grid/title_bar.rs73
1 files changed, 48 insertions, 25 deletions
diff --git a/native/src/widget/pane_grid/title_bar.rs b/native/src/widget/pane_grid/title_bar.rs
index 2a028dd5..14c3ab4e 100644
--- a/native/src/widget/pane_grid/title_bar.rs
+++ b/native/src/widget/pane_grid/title_bar.rs
@@ -114,20 +114,17 @@ where
let mut children = padded.children();
let title_layout = children.next().unwrap();
-
- self.content.draw(
- renderer,
- theme,
- &inherited_style,
- title_layout,
- cursor_position,
- viewport,
- );
+ let mut show_title = true;
if let Some(controls) = &self.controls {
let controls_layout = children.next().unwrap();
if show_controls || self.always_show_controls {
+ if title_layout.bounds().width + controls_layout.bounds().width
+ > padded.bounds().width
+ {
+ show_title = false;
+ }
controls.draw(
renderer,
theme,
@@ -138,6 +135,17 @@ where
);
}
}
+
+ if show_title {
+ self.content.draw(
+ renderer,
+ theme,
+ &inherited_style,
+ title_layout,
+ cursor_position,
+ viewport,
+ );
+ }
}
/// Returns whether the mouse cursor is over the pick area of the
@@ -225,9 +233,15 @@ where
let mut children = padded.children();
let title_layout = children.next().unwrap();
+ let mut show_title = true;
let control_status = if let Some(controls) = &mut self.controls {
let controls_layout = children.next().unwrap();
+ if title_layout.bounds().width + controls_layout.bounds().width
+ > padded.bounds().width
+ {
+ show_title = false;
+ }
controls.on_event(
event.clone(),
@@ -241,14 +255,18 @@ where
event::Status::Ignored
};
- let title_status = self.content.on_event(
- event,
- title_layout,
- cursor_position,
- renderer,
- clipboard,
- shell,
- );
+ let title_status = if show_title {
+ self.content.on_event(
+ event,
+ title_layout,
+ cursor_position,
+ renderer,
+ clipboard,
+ shell,
+ )
+ } else {
+ event::Status::Ignored
+ };
control_status.merge(title_status)
}
@@ -275,15 +293,20 @@ where
if let Some(controls) = &self.controls {
let controls_layout = children.next().unwrap();
+ let controls_interaction = controls.mouse_interaction(
+ controls_layout,
+ cursor_position,
+ viewport,
+ renderer,
+ );
- controls
- .mouse_interaction(
- controls_layout,
- cursor_position,
- viewport,
- renderer,
- )
- .max(title_interaction)
+ if title_layout.bounds().width + controls_layout.bounds().width
+ > padded.bounds().width
+ {
+ controls_interaction
+ } else {
+ controls_interaction.max(title_interaction)
+ }
} else {
title_interaction
}