From cb712f3b84590a3d2541744e3518e1532667c510 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 31 May 2022 05:40:39 +0200 Subject: Bump versions :tada: --- pure/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pure') diff --git a/pure/Cargo.toml b/pure/Cargo.toml index 2301031d..b57e4c5a 100644 --- a/pure/Cargo.toml +++ b/pure/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_pure" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "Pure widgets for Iced" license = "MIT" -- cgit From 20780f36d1c00666140b31e8192e74e1cf36570c Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Tue, 7 Jun 2022 07:30:44 +0800 Subject: Prevent pane grid title bar content and controls from overlapping --- pure/src/widget/pane_grid/title_bar.rs | 78 ++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 28 deletions(-) (limited to 'pure') diff --git a/pure/src/widget/pane_grid/title_bar.rs b/pure/src/widget/pane_grid/title_bar.rs index 4a7c8c17..af71dc43 100644 --- a/pure/src/widget/pane_grid/title_bar.rs +++ b/pure/src/widget/pane_grid/title_bar.rs @@ -132,18 +132,15 @@ where let mut children = padded.children(); let title_layout = children.next().unwrap(); - - self.content.as_widget().draw( - &tree.children[0], - renderer, - &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 title_layout.bounds().width + controls_layout.bounds().width + > padded.bounds().width + { + show_title = false; + } if show_controls || self.always_show_controls { 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 @@ -247,9 +255,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.as_widget_mut().on_event( &mut tree.children[1], @@ -264,15 +278,19 @@ where event::Status::Ignored }; - let title_status = self.content.as_widget_mut().on_event( - &mut tree.children[0], - event, - title_layout, - cursor_position, - renderer, - clipboard, - shell, - ); + let title_status = if show_title { + self.content.as_widget_mut().on_event( + &mut tree.children[0], + event, + title_layout, + cursor_position, + renderer, + clipboard, + shell, + ) + } else { + event::Status::Ignored + }; control_status.merge(title_status) } @@ -301,17 +319,21 @@ where if let Some(controls) = &self.controls { let controls_layout = children.next().unwrap(); + let controls_interaction = controls.as_widget().mouse_interaction( + &tree.children[1], + controls_layout, + cursor_position, + viewport, + renderer, + ); - controls - .as_widget() - .mouse_interaction( - &tree.children[1], - 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 } -- cgit From 05e025b49f7f840241e3e2dcceb05b1e5fb7ad9a Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 23 Jun 2022 15:20:31 -0700 Subject: Allow overriding pure text_input value during draw --- pure/src/widget/text_input.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'pure') diff --git a/pure/src/widget/text_input.rs b/pure/src/widget/text_input.rs index 57ad26d9..ee790359 100644 --- a/pure/src/widget/text_input.rs +++ b/pure/src/widget/text_input.rs @@ -121,6 +121,32 @@ where self.style_sheet = style_sheet.into(); self } + + /// Draws the [`TextInput`] with the given [`Renderer`], overriding its + /// [`text_input::Value`] if provided. + /// + /// [`Renderer`]: text::Renderer + pub fn draw( + &self, + tree: &Tree, + renderer: &mut Renderer, + layout: Layout<'_>, + cursor_position: Point, + value: Option<&text_input::Value>, + ) { + text_input::draw( + renderer, + layout, + cursor_position, + tree.state.downcast_ref::(), + value.unwrap_or(&self.value), + &self.placeholder, + self.size, + &self.font, + self.is_secure, + self.style_sheet.as_ref(), + ) + } } impl<'a, Message, Renderer> Widget -- cgit