diff options
author | 2023-12-02 16:10:42 +0100 | |
---|---|---|
committer | 2023-12-02 16:10:42 +0100 | |
commit | 8727b3fc50ec251d9c117c51ca1289be5ba9b117 (patch) | |
tree | 802fef9f0b54b6f9cbbeedff14d7f57169db7d6b /core | |
parent | 7f8b17604a31e00becc43130ec516c1a53552c88 (diff) | |
parent | b526ce4958b28208395276dd4078ffe0d780e1d7 (diff) | |
download | iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.gz iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.bz2 iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.zip |
Merge pull request #2154 from iced-rs/fix/text-clipping
Fix text clipping
Diffstat (limited to 'core')
-rw-r--r-- | core/src/renderer/null.rs | 3 | ||||
-rw-r--r-- | core/src/text.rs | 5 | ||||
-rw-r--r-- | core/src/widget/text.rs | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index da0f32de..7accd34e 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -64,6 +64,7 @@ impl text::Renderer for Null { _paragraph: &Self::Paragraph, _position: Point, _color: Color, + _clip_bounds: Rectangle, ) { } @@ -72,6 +73,7 @@ impl text::Renderer for Null { _editor: &Self::Editor, _position: Point, _color: Color, + _clip_bounds: Rectangle, ) { } @@ -80,6 +82,7 @@ impl text::Renderer for Null { _paragraph: Text<'_, Self::Font>, _position: Point, _color: Color, + _clip_bounds: Rectangle, ) { } } diff --git a/core/src/text.rs b/core/src/text.rs index 546d0b5c..edef79c2 100644 --- a/core/src/text.rs +++ b/core/src/text.rs @@ -9,7 +9,7 @@ pub use highlighter::Highlighter; pub use paragraph::Paragraph; use crate::alignment; -use crate::{Color, Pixels, Point, Size}; +use crate::{Color, Pixels, Point, Rectangle, Size}; use std::borrow::Cow; use std::hash::{Hash, Hasher}; @@ -202,6 +202,7 @@ pub trait Renderer: crate::Renderer { text: &Self::Paragraph, position: Point, color: Color, + clip_bounds: Rectangle, ); /// Draws the given [`Editor`] at the given position and with the given @@ -211,6 +212,7 @@ pub trait Renderer: crate::Renderer { editor: &Self::Editor, position: Point, color: Color, + clip_bounds: Rectangle, ); /// Draws the given [`Text`] at the given position and with the given @@ -220,5 +222,6 @@ pub trait Renderer: crate::Renderer { text: Text<'_, Self::Font>, position: Point, color: Color, + clip_bounds: Rectangle, ); } diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 97e0acac..e020b030 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -172,7 +172,7 @@ where style: &renderer::Style, layout: Layout<'_>, _cursor_position: mouse::Cursor, - _viewport: &Rectangle, + viewport: &Rectangle, ) { let state = tree.state.downcast_ref::<State<Renderer::Paragraph>>(); @@ -182,6 +182,7 @@ where layout, state, theme.appearance(self.style.clone()), + viewport, ); } } @@ -244,6 +245,7 @@ pub fn draw<Renderer>( layout: Layout<'_>, state: &State<Renderer::Paragraph>, appearance: Appearance, + viewport: &Rectangle, ) where Renderer: text::Renderer, { @@ -266,6 +268,7 @@ pub fn draw<Renderer>( paragraph, Point::new(x, y), appearance.color.unwrap_or(style.text_color), + *viewport, ); } |