From 346af3f8b0baa418fd37b878bc2930ff0bd57cc0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 11 Sep 2023 02:47:24 +0200 Subject: Make `FontSystem` global and simplify `Paragraph` API --- graphics/src/renderer.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index d4df29a5..c5033d36 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -158,41 +158,6 @@ where self.backend.load_font(bytes); } - fn create_paragraph(&self, text: Text<'_, Self::Font>) -> text::Paragraph { - text::Paragraph::with_text(text, self.backend.font_system()) - } - - fn update_paragraph( - &self, - paragraph: &mut Self::Paragraph, - text: Text<'_, Self::Font>, - ) { - let font_system = self.backend.font_system(); - - if paragraph.version() != font_system.version() { - // The font system has changed, paragraph fonts may be outdated - *paragraph = self.create_paragraph(text); - } else { - match core::text::compare(paragraph, text) { - core::text::Difference::None => {} - core::text::Difference::Bounds => { - self.resize_paragraph(paragraph, text.bounds); - } - core::text::Difference::Shape => { - *paragraph = self.create_paragraph(text); - } - } - } - } - - fn resize_paragraph( - &self, - paragraph: &mut Self::Paragraph, - new_bounds: Size, - ) { - paragraph.resize(new_bounds, self.backend.font_system()); - } - fn fill_paragraph( &mut self, paragraph: &Self::Paragraph, -- cgit From 6448429103c9c82b90040ac5a5a097bdded23f82 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Sep 2023 14:51:00 +0200 Subject: Draft `Editor` API and `TextEditor` widget --- graphics/src/renderer.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index c5033d36..9b699183 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -141,6 +141,7 @@ where { type Font = Font; type Paragraph = text::Paragraph; + type Editor = text::Editor; const ICON_FONT: Font = Font::with_name("Iced-Icons"); const CHECKMARK_ICON: char = '\u{f00c}'; @@ -171,6 +172,19 @@ where }); } + fn fill_editor( + &mut self, + editor: &Self::Editor, + position: Point, + color: Color, + ) { + self.primitives.push(Primitive::Editor { + editor: editor.downgrade(), + position, + color, + }); + } + fn fill_text( &mut self, text: Text<'_, Self::Font>, -- cgit From a5125d6fea824df1191777fe3eb53a2f748208b9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 11 Nov 2023 07:02:01 +0100 Subject: Refactor texture image filtering - Support only `Linear` or `Nearest` - Simplify `Layer` groups - Move `FilterMethod` to `Image` and `image::Viewer` --- graphics/src/renderer.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 93fff3b7..d7613e36 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -215,8 +215,17 @@ where self.backend().dimensions(handle) } - fn draw(&mut self, handle: image::Handle, bounds: Rectangle) { - self.primitives.push(Primitive::Image { handle, bounds }); + fn draw( + &mut self, + handle: image::Handle, + filter_method: image::FilterMethod, + bounds: Rectangle, + ) { + self.primitives.push(Primitive::Image { + handle, + filter_method, + bounds, + }); } } -- cgit From 936d480267578d7e80675e78ec1880aaaaab72d6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 1 Dec 2023 16:04:27 +0100 Subject: Clip text to `viewport` bounds instead of layout bounds --- graphics/src/renderer.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index d7613e36..0d3b11a7 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -164,11 +164,13 @@ where paragraph: &Self::Paragraph, position: Point, color: Color, + viewport: Rectangle, ) { self.primitives.push(Primitive::Paragraph { paragraph: paragraph.downgrade(), position, color, + viewport, }); } @@ -177,11 +179,13 @@ where editor: &Self::Editor, position: Point, color: Color, + viewport: Rectangle, ) { self.primitives.push(Primitive::Editor { editor: editor.downgrade(), position, color, + viewport, }); } @@ -190,6 +194,7 @@ where text: Text<'_, Self::Font>, position: Point, color: Color, + viewport: Rectangle, ) { self.primitives.push(Primitive::Text { content: text.content.to_string(), @@ -201,6 +206,7 @@ where horizontal_alignment: text.horizontal_alignment, vertical_alignment: text.vertical_alignment, shaping: text.shaping, + viewport, }); } } -- cgit From b526ce4958b28208395276dd4078ffe0d780e1d7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 2 Dec 2023 15:53:02 +0100 Subject: Rename `viewport` to `clip_bounds` --- graphics/src/renderer.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 0d3b11a7..1b0f5c5b 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -164,13 +164,13 @@ where paragraph: &Self::Paragraph, position: Point, color: Color, - viewport: Rectangle, + clip_bounds: Rectangle, ) { self.primitives.push(Primitive::Paragraph { paragraph: paragraph.downgrade(), position, color, - viewport, + clip_bounds, }); } @@ -179,13 +179,13 @@ where editor: &Self::Editor, position: Point, color: Color, - viewport: Rectangle, + clip_bounds: Rectangle, ) { self.primitives.push(Primitive::Editor { editor: editor.downgrade(), position, color, - viewport, + clip_bounds, }); } @@ -194,7 +194,7 @@ where text: Text<'_, Self::Font>, position: Point, color: Color, - viewport: Rectangle, + clip_bounds: Rectangle, ) { self.primitives.push(Primitive::Text { content: text.content.to_string(), @@ -206,7 +206,7 @@ where horizontal_alignment: text.horizontal_alignment, vertical_alignment: text.vertical_alignment, shaping: text.shaping, - viewport, + clip_bounds, }); } } -- cgit