From 03b34931383e701c39c653a7662a616fe21a0947 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:07:22 +0700 Subject: Remove trait-specific draw logic in `iced_native` --- native/src/renderer/null.rs | 191 +------------------------------------------- 1 file changed, 2 insertions(+), 189 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index b5921582..1ffca5c9 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,20 +1,15 @@ -use crate::alignment; use crate::button; use crate::checkbox; -use crate::column; use crate::container; use crate::pane_grid; use crate::progress_bar; use crate::radio; -use crate::row; use crate::scrollable; use crate::slider; use crate::text; use crate::text_input; use crate::toggler; -use crate::{ - Color, Element, Font, Layout, Padding, Point, Rectangle, Renderer, Size, -}; +use crate::{Font, Padding, Point, Rectangle, Renderer, Size}; /// A renderer that does nothing. /// @@ -30,35 +25,9 @@ impl Null { } impl Renderer for Null { - type Output = (); type Defaults = (); - fn overlay(&mut self, _base: (), _overlay: (), _overlay_bounds: Rectangle) { - } -} - -impl column::Renderer for Null { - fn draw( - &mut self, - _defaults: &Self::Defaults, - _content: &[Element<'_, Message, Self>], - _layout: Layout<'_>, - _cursor_position: Point, - _viewport: &Rectangle, - ) { - } -} - -impl row::Renderer for Null { - fn draw( - &mut self, - _defaults: &Self::Defaults, - _content: &[Element<'_, Message, Self>], - _layout: Layout<'_>, - _cursor_position: Point, - _viewport: &Rectangle, - ) { - } + fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {} } impl text::Renderer for Null { @@ -89,19 +58,6 @@ impl text::Renderer for Null { ) -> Option { None } - - fn draw( - &mut self, - _defaults: &Self::Defaults, - _bounds: Rectangle, - _content: &str, - _size: u16, - _font: Font, - _color: Option, - _horizontal_alignment: alignment::Horizontal, - _vertical_alignment: alignment::Vertical, - ) { - } } impl scrollable::Renderer for Null { @@ -118,20 +74,6 @@ impl scrollable::Renderer for Null { ) -> Option { None } - - fn draw( - &mut self, - _scrollable: &scrollable::State, - _bounds: Rectangle, - _content_bounds: Rectangle, - _is_mouse_over: bool, - _is_mouse_over_scrollbar: bool, - _scrollbar: Option, - _offset: u32, - _style: &Self::Style, - _content: Self::Output, - ) { - } } impl text_input::Renderer for Null { @@ -151,39 +93,12 @@ impl text_input::Renderer for Null { ) -> f32 { 0.0 } - - fn draw( - &mut self, - _bounds: Rectangle, - _text_bounds: Rectangle, - _cursor_position: Point, - _font: Font, - _size: u16, - _placeholder: &str, - _value: &text_input::Value, - _state: &text_input::State, - _style: &Self::Style, - ) -> Self::Output { - } } impl button::Renderer for Null { const DEFAULT_PADDING: Padding = Padding::ZERO; type Style = (); - - fn draw( - &mut self, - _defaults: &Self::Defaults, - _bounds: Rectangle, - _cursor_position: Point, - _is_disabled: bool, - _is_pressed: bool, - _style: &Self::Style, - _content: &Element<'_, Message, Self>, - _content_layout: Layout<'_>, - ) -> Self::Output { - } } impl radio::Renderer for Null { @@ -191,16 +106,6 @@ impl radio::Renderer for Null { const DEFAULT_SIZE: u16 = 20; const DEFAULT_SPACING: u16 = 15; - - fn draw( - &mut self, - _bounds: Rectangle, - _is_selected: bool, - _is_mouse_over: bool, - _label: Self::Output, - _style: &Self::Style, - ) { - } } impl checkbox::Renderer for Null { @@ -208,122 +113,30 @@ impl checkbox::Renderer for Null { const DEFAULT_SIZE: u16 = 20; const DEFAULT_SPACING: u16 = 15; - - fn draw( - &mut self, - _bounds: Rectangle, - _is_checked: bool, - _is_mouse_over: bool, - _label: Self::Output, - _style: &Self::Style, - ) { - } } impl slider::Renderer for Null { type Style = (); const DEFAULT_HEIGHT: u16 = 30; - - fn draw( - &mut self, - _bounds: Rectangle, - _cursor_position: Point, - _range: std::ops::RangeInclusive, - _value: f32, - _is_dragging: bool, - _style_sheet: &Self::Style, - ) { - } } impl progress_bar::Renderer for Null { type Style = (); const DEFAULT_HEIGHT: u16 = 30; - - fn draw( - &self, - _bounds: Rectangle, - _range: std::ops::RangeInclusive, - _value: f32, - _style: &Self::Style, - ) { - } } impl container::Renderer for Null { type Style = (); - - fn draw( - &mut self, - _defaults: &Self::Defaults, - _bounds: Rectangle, - _cursor_position: Point, - _viewport: &Rectangle, - _style: &Self::Style, - _content: &Element<'_, Message, Self>, - _content_layout: Layout<'_>, - ) { - } } impl pane_grid::Renderer for Null { type Style = (); - - fn draw( - &mut self, - _defaults: &Self::Defaults, - _content: &[(pane_grid::Pane, pane_grid::Content<'_, Message, Self>)], - _dragging: Option<(pane_grid::Pane, Point)>, - _resizing: Option<(pane_grid::Axis, Rectangle, bool)>, - _layout: Layout<'_>, - _style: &::Style, - _cursor_position: Point, - _viewport: &Rectangle, - ) { - } - - fn draw_pane( - &mut self, - _defaults: &Self::Defaults, - _bounds: Rectangle, - _style: &::Style, - _title_bar: Option<( - &pane_grid::TitleBar<'_, Message, Self>, - Layout<'_>, - )>, - _body: (&Element<'_, Message, Self>, Layout<'_>), - _cursor_position: Point, - _viewport: &Rectangle, - ) { - } - - fn draw_title_bar( - &mut self, - _defaults: &Self::Defaults, - _bounds: Rectangle, - _style: &::Style, - _content: (&Element<'_, Message, Self>, Layout<'_>), - _controls: Option<(&Element<'_, Message, Self>, Layout<'_>)>, - _cursor_position: Point, - _viewport: &Rectangle, - ) { - } } impl toggler::Renderer for Null { type Style = (); const DEFAULT_SIZE: u16 = 20; - - fn draw( - &mut self, - _bounds: Rectangle, - _is_checked: bool, - _is_mouse_over: bool, - _label: Option, - _style: &Self::Style, - ) { - } } -- cgit From 3a0c503db99eb3d45ac971132904df419ee566b6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:59:19 +0700 Subject: Implement `Widget::draw` for `Text` --- native/src/renderer/null.rs | 11 +++++++++-- native/src/renderer/text.rs | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 native/src/renderer/text.rs (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 1ffca5c9..da758ebb 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -4,12 +4,13 @@ use crate::container; use crate::pane_grid; use crate::progress_bar; use crate::radio; +use crate::renderer::{self, Renderer}; use crate::scrollable; use crate::slider; use crate::text; use crate::text_input; use crate::toggler; -use crate::{Font, Padding, Point, Rectangle, Renderer, Size}; +use crate::{Font, Padding, Point, Rectangle, Size}; /// A renderer that does nothing. /// @@ -28,11 +29,17 @@ impl Renderer for Null { type Defaults = (); fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {} + + fn clear(&mut self) {} } -impl text::Renderer for Null { +impl renderer::Text for Null { type Font = Font; + fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} +} + +impl text::Renderer for Null { fn default_size(&self) -> u16 { 20 } diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs new file mode 100644 index 00000000..5c189d89 --- /dev/null +++ b/native/src/renderer/text.rs @@ -0,0 +1,20 @@ +use crate::alignment; +use crate::{Color, Rectangle, Renderer}; + +pub trait Text: Renderer { + /// The font type used. + type Font: Default + Copy; + + fn fill_text(&mut self, section: Section<'_, Self::Font>); +} + +#[derive(Debug, Clone, Copy)] +pub struct Section<'a, Font> { + pub content: &'a str, + pub bounds: Rectangle, + pub size: Option, + pub color: Option, + pub font: Font, + pub horizontal_alignment: alignment::Horizontal, + pub vertical_alignment: alignment::Vertical, +} -- cgit From dfceee99aad9462f09ca61081e68e1decb2fed92 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 17:15:29 +0700 Subject: Implement `Widget::draw` for `Scrollable` Rendering the scroller is still WIP --- native/src/renderer/null.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index da758ebb..b8e01b80 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -10,7 +10,7 @@ use crate::slider; use crate::text; use crate::text_input; use crate::toggler; -use crate::{Font, Padding, Point, Rectangle, Size}; +use crate::{Font, Padding, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. /// @@ -28,7 +28,13 @@ impl Null { impl Renderer for Null { type Defaults = (); - fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {} + fn with_layer( + &mut self, + _bounds: Rectangle, + _offset: Vector, + _f: impl FnOnce(&mut Self), + ) { + } fn clear(&mut self) {} } -- cgit From a4f4d831615899046d36c96e6a580d5386aa25bf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 14:47:49 +0700 Subject: Introduce `fill_rectangle` to `Renderer` trait --- native/src/renderer/null.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index b8e01b80..1c026fde 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -37,6 +37,8 @@ impl Renderer for Null { } fn clear(&mut self) {} + + fn fill_rectangle(&mut self, _quad: renderer::Quad) {} } impl renderer::Text for Null { -- cgit From 54a9a232f8110364972a8eef966b7b7477573f4f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 14:48:33 +0700 Subject: Draw scrollbar in `Widget::draw` for `Scrollable` --- native/src/renderer/null.rs | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 1c026fde..960a5727 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -75,22 +75,6 @@ impl text::Renderer for Null { } } -impl scrollable::Renderer for Null { - type Style = (); - - fn scrollbar( - &self, - _bounds: Rectangle, - _content_bounds: Rectangle, - _offset: u32, - _scrollbar_width: u16, - _scrollbar_margin: u16, - _scroller_width: u16, - ) -> Option { - None - } -} - impl text_input::Renderer for Null { type Style = (); -- cgit From edea093350e1b576e2b7db50c525e7fa5c3bea9f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 15:19:04 +0700 Subject: Move `Defaults` from `iced_graphics` to `iced_native` --- native/src/renderer/null.rs | 3 --- native/src/renderer/text.rs | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 960a5727..268248fd 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -5,7 +5,6 @@ use crate::pane_grid; use crate::progress_bar; use crate::radio; use crate::renderer::{self, Renderer}; -use crate::scrollable; use crate::slider; use crate::text; use crate::text_input; @@ -26,8 +25,6 @@ impl Null { } impl Renderer for Null { - type Defaults = (); - fn with_layer( &mut self, _bounds: Rectangle, diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs index 5c189d89..9234c587 100644 --- a/native/src/renderer/text.rs +++ b/native/src/renderer/text.rs @@ -12,8 +12,8 @@ pub trait Text: Renderer { pub struct Section<'a, Font> { pub content: &'a str, pub bounds: Rectangle, - pub size: Option, - pub color: Option, + pub size: f32, + pub color: Color, pub font: Font, pub horizontal_alignment: alignment::Horizontal, pub vertical_alignment: alignment::Vertical, -- cgit From d61cb58d92b6fcd520f665deb093f3747ffd5e5c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 15:36:32 +0700 Subject: Wire up `container` styling to `iced_native` --- native/src/renderer/null.rs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 268248fd..fdb6ea92 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,6 +1,5 @@ use crate::button; use crate::checkbox; -use crate::container; use crate::pane_grid; use crate::progress_bar; use crate::radio; @@ -123,10 +122,6 @@ impl progress_bar::Renderer for Null { const DEFAULT_HEIGHT: u16 = 30; } -impl container::Renderer for Null { - type Style = (); -} - impl pane_grid::Renderer for Null { type Style = (); } -- cgit From 3140cdc4babcefc444f1c1d30eb0f5f4ed1df054 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 16:02:30 +0700 Subject: Wire up styling to `Button` in `iced_native` --- native/src/renderer/null.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index fdb6ea92..07023a67 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -90,12 +90,6 @@ impl text_input::Renderer for Null { } } -impl button::Renderer for Null { - const DEFAULT_PADDING: Padding = Padding::ZERO; - - type Style = (); -} - impl radio::Renderer for Null { type Style = (); -- cgit From 11bcb1342796a6fabc7c5b89a15c22c754b014ce Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 15:50:42 +0700 Subject: Wire up styling to `Slider` in `iced_native` --- native/src/renderer/null.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 07023a67..2d6979e3 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,14 +1,12 @@ -use crate::button; use crate::checkbox; use crate::pane_grid; use crate::progress_bar; use crate::radio; use crate::renderer::{self, Renderer}; -use crate::slider; use crate::text; use crate::text_input; use crate::toggler; -use crate::{Font, Padding, Point, Rectangle, Size, Vector}; +use crate::{Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. /// @@ -104,12 +102,6 @@ impl checkbox::Renderer for Null { const DEFAULT_SPACING: u16 = 15; } -impl slider::Renderer for Null { - type Style = (); - - const DEFAULT_HEIGHT: u16 = 30; -} - impl progress_bar::Renderer for Null { type Style = (); -- cgit From e914888f57394e4b67b40e42f1ad9df4ae8147e6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 18:40:39 +0700 Subject: Implement `Widget::draw` for `TextInput` --- native/src/renderer/null.rs | 24 +----------------------- native/src/renderer/text.rs | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 24 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 2d6979e3..084b8d6f 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -4,7 +4,6 @@ use crate::progress_bar; use crate::radio; use crate::renderer::{self, Renderer}; use crate::text; -use crate::text_input; use crate::toggler; use crate::{Font, Point, Rectangle, Size, Vector}; @@ -38,10 +37,6 @@ impl Renderer for Null { impl renderer::Text for Null { type Font = Font; - fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} -} - -impl text::Renderer for Null { fn default_size(&self) -> u16 { 20 } @@ -67,25 +62,8 @@ impl text::Renderer for Null { ) -> Option { None } -} -impl text_input::Renderer for Null { - type Style = (); - - fn measure_value(&self, _value: &str, _size: u16, _font: Font) -> f32 { - 0.0 - } - - fn offset( - &self, - _text_bounds: Rectangle, - _font: Font, - _size: u16, - _value: &text_input::Value, - _state: &text_input::State, - ) -> f32 { - 0.0 - } + fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} } impl radio::Renderer for Null { diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs index 9234c587..80769b62 100644 --- a/native/src/renderer/text.rs +++ b/native/src/renderer/text.rs @@ -1,10 +1,48 @@ use crate::alignment; -use crate::{Color, Rectangle, Renderer}; +use crate::{Color, Point, Rectangle, Renderer, Size}; + +pub use crate::text::Hit; pub trait Text: Renderer { /// The font type used. type Font: Default + Copy; + /// Returns the default size of [`Text`]. + fn default_size(&self) -> u16; + + /// Measures the text in the given bounds and returns the minimum boundaries + /// that can fit the contents. + fn measure( + &self, + content: &str, + size: u16, + font: Self::Font, + bounds: Size, + ) -> (f32, f32); + + fn measure_width(&self, content: &str, size: u16, font: Self::Font) -> f32 { + let (width, _) = self.measure(content, size, font, Size::INFINITY); + + width + } + + /// Tests whether the provided point is within the boundaries of [`Text`] + /// laid out with the given parameters, returning information about + /// the nearest character. + /// + /// If `nearest_only` is true, the hit test does not consider whether the + /// the point is interior to any glyph bounds, returning only the character + /// with the nearest centeroid. + fn hit_test( + &self, + contents: &str, + size: f32, + font: Self::Font, + bounds: Size, + point: Point, + nearest_only: bool, + ) -> Option; + fn fill_text(&mut self, section: Section<'_, Self::Font>); } -- cgit From d39ad717ed0ab85acbe935d7ab883166b36e7bc7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 19:06:53 +0700 Subject: Wire up styling to `Radio` in `iced_native` --- native/src/renderer/null.rs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 084b8d6f..40fd5995 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -66,13 +66,6 @@ impl renderer::Text for Null { fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} } -impl radio::Renderer for Null { - type Style = (); - - const DEFAULT_SIZE: u16 = 20; - const DEFAULT_SPACING: u16 = 15; -} - impl checkbox::Renderer for Null { type Style = (); -- cgit From 7c08c6bd138207b862933ee479752a4f1d18c4f2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 Oct 2021 18:50:27 +0700 Subject: Remove `Renderer` trait for `Checkbox` --- native/src/renderer/null.rs | 9 --------- 1 file changed, 9 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 40fd5995..010305a2 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,7 +1,5 @@ -use crate::checkbox; use crate::pane_grid; use crate::progress_bar; -use crate::radio; use crate::renderer::{self, Renderer}; use crate::text; use crate::toggler; @@ -66,13 +64,6 @@ impl renderer::Text for Null { fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} } -impl checkbox::Renderer for Null { - type Style = (); - - const DEFAULT_SIZE: u16 = 20; - const DEFAULT_SPACING: u16 = 15; -} - impl progress_bar::Renderer for Null { type Style = (); -- cgit From 1397be38ca2caaf5c49ca51e164a28b63f9e461b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 Oct 2021 19:06:22 +0700 Subject: Implement `Widget::draw` for `Checkbox` --- native/src/renderer/null.rs | 4 ++++ native/src/renderer/text.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 010305a2..351f6233 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -35,6 +35,10 @@ impl Renderer for Null { impl renderer::Text for Null { type Font = Font; + const ICON_FONT: Font = Font::Default; + const CHECKMARK_ICON: char = '0'; + const ARROW_DOWN_ICON: char = '0'; + fn default_size(&self) -> u16 { 20 } diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs index 80769b62..fbf116a1 100644 --- a/native/src/renderer/text.rs +++ b/native/src/renderer/text.rs @@ -7,6 +7,19 @@ pub trait Text: Renderer { /// The font type used. type Font: Default + Copy; + /// The icon font of the backend. + const ICON_FONT: Self::Font; + + /// The `char` representing a ✔ icon in the [`ICON_FONT`]. + /// + /// [`ICON_FONT`]: Self::ICON_FONT + const CHECKMARK_ICON: char; + + /// The `char` representing a ▼ icon in the built-in [`ICON_FONT`]. + /// + /// [`ICON_FONT`]: Self::ICON_FONT + const ARROW_DOWN_ICON: char; + /// Returns the default size of [`Text`]. fn default_size(&self) -> u16; -- cgit From 41394b4e90a81a43c796c070e706e6aa4d8652bc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 25 Oct 2021 15:37:28 +0700 Subject: Implement `Widget::draw` for `PaneGrid` --- native/src/renderer/null.rs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 351f6233..485c5b2c 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -74,10 +74,6 @@ impl progress_bar::Renderer for Null { const DEFAULT_HEIGHT: u16 = 30; } -impl pane_grid::Renderer for Null { - type Style = (); -} - impl toggler::Renderer for Null { type Style = (); -- cgit From 4a11cbd99445338619dfaf1f327dbc25b2983cb7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 25 Oct 2021 16:16:35 +0700 Subject: Implement `Widget::mouse_interaction` for `PaneGrid` ... and fix rendering of drag interaction in `PaneGrid` by introducing an explicit `with_translation` method to `Renderer` and simplifying the `with_layer` and `Clip` primitive. --- native/src/renderer/null.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 485c5b2c..cc1d41ba 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,4 +1,3 @@ -use crate::pane_grid; use crate::progress_bar; use crate::renderer::{self, Renderer}; use crate::text; @@ -19,10 +18,11 @@ impl Null { } impl Renderer for Null { - fn with_layer( + fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {} + + fn with_translation( &mut self, - _bounds: Rectangle, - _offset: Vector, + _translation: Vector, _f: impl FnOnce(&mut Self), ) { } -- cgit From e42e1e2f57ddb455ceff0017e215ddacca978d37 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 17:36:36 +0700 Subject: Implement `Widget::draw` for `ProgressBar` --- native/src/renderer/null.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index cc1d41ba..92e64cf4 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -68,12 +68,6 @@ impl renderer::Text for Null { fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} } -impl progress_bar::Renderer for Null { - type Style = (); - - const DEFAULT_HEIGHT: u16 = 30; -} - impl toggler::Renderer for Null { type Style = (); -- cgit From f6257973926233e7bb18ae3b4dee4385bfc6ab61 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 18:03:24 +0700 Subject: Implement `Widget::draw` for `Rule` --- native/src/renderer/null.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 92e64cf4..e91c4a80 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,4 +1,3 @@ -use crate::progress_bar; use crate::renderer::{self, Renderer}; use crate::text; use crate::toggler; -- cgit From 1c2792c0a0dc565f9dd9183ca8948331ec467590 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 18:17:47 +0700 Subject: Implement `Widget::draw` for `Toggler` --- native/src/renderer/null.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index e91c4a80..1f555065 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -66,9 +66,3 @@ impl renderer::Text for Null { fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} } - -impl toggler::Renderer for Null { - type Style = (); - - const DEFAULT_SIZE: u16 = 20; -} -- cgit From 55b31e6dcf3b8ef083e84372ba02f5a1018470db Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 20:41:07 +0700 Subject: Remove unused import for `toggler` in `iced_graphics` --- native/src/renderer/null.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 1f555065..dbd3a820 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,6 +1,5 @@ use crate::renderer::{self, Renderer}; use crate::text; -use crate::toggler; use crate::{Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. -- cgit From 0aafcde0ef1533c9eeba0379de8c0082e30c7504 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 15:35:12 +0700 Subject: Remove `widget` module re-exports in `iced_native` --- native/src/renderer/null.rs | 2 +- native/src/renderer/text.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index dbd3a820..e57841f4 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,5 +1,5 @@ use crate::renderer::{self, Renderer}; -use crate::text; +use crate::widget::text; use crate::{Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs index fbf116a1..fc1a2c66 100644 --- a/native/src/renderer/text.rs +++ b/native/src/renderer/text.rs @@ -1,7 +1,7 @@ use crate::alignment; use crate::{Color, Point, Rectangle, Renderer, Size}; -pub use crate::text::Hit; +pub use crate::widget::text::Hit; pub trait Text: Renderer { /// The font type used. -- cgit From b3a01973c6c726e6539be959659f4306ef3234c6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 16:13:03 +0700 Subject: Introduce first-class `text` module in `iced_native` --- native/src/renderer/null.rs | 6 ++-- native/src/renderer/text.rs | 71 --------------------------------------------- 2 files changed, 3 insertions(+), 74 deletions(-) delete mode 100644 native/src/renderer/text.rs (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index e57841f4..263b38a9 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,5 +1,5 @@ use crate::renderer::{self, Renderer}; -use crate::widget::text; +use crate::text::{self, Text}; use crate::{Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. @@ -30,7 +30,7 @@ impl Renderer for Null { fn fill_rectangle(&mut self, _quad: renderer::Quad) {} } -impl renderer::Text for Null { +impl text::Renderer for Null { type Font = Font; const ICON_FONT: Font = Font::Default; @@ -63,5 +63,5 @@ impl renderer::Text for Null { None } - fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} + fn fill_text(&mut self, _text: Text<'_, Self::Font>) {} } diff --git a/native/src/renderer/text.rs b/native/src/renderer/text.rs deleted file mode 100644 index fc1a2c66..00000000 --- a/native/src/renderer/text.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::alignment; -use crate::{Color, Point, Rectangle, Renderer, Size}; - -pub use crate::widget::text::Hit; - -pub trait Text: Renderer { - /// The font type used. - type Font: Default + Copy; - - /// The icon font of the backend. - const ICON_FONT: Self::Font; - - /// The `char` representing a ✔ icon in the [`ICON_FONT`]. - /// - /// [`ICON_FONT`]: Self::ICON_FONT - const CHECKMARK_ICON: char; - - /// The `char` representing a ▼ icon in the built-in [`ICON_FONT`]. - /// - /// [`ICON_FONT`]: Self::ICON_FONT - const ARROW_DOWN_ICON: char; - - /// Returns the default size of [`Text`]. - fn default_size(&self) -> u16; - - /// Measures the text in the given bounds and returns the minimum boundaries - /// that can fit the contents. - fn measure( - &self, - content: &str, - size: u16, - font: Self::Font, - bounds: Size, - ) -> (f32, f32); - - fn measure_width(&self, content: &str, size: u16, font: Self::Font) -> f32 { - let (width, _) = self.measure(content, size, font, Size::INFINITY); - - width - } - - /// Tests whether the provided point is within the boundaries of [`Text`] - /// laid out with the given parameters, returning information about - /// the nearest character. - /// - /// If `nearest_only` is true, the hit test does not consider whether the - /// the point is interior to any glyph bounds, returning only the character - /// with the nearest centeroid. - fn hit_test( - &self, - contents: &str, - size: f32, - font: Self::Font, - bounds: Size, - point: Point, - nearest_only: bool, - ) -> Option; - - fn fill_text(&mut self, section: Section<'_, Self::Font>); -} - -#[derive(Debug, Clone, Copy)] -pub struct Section<'a, Font> { - pub content: &'a str, - pub bounds: Rectangle, - pub size: f32, - pub color: Color, - pub font: Font, - pub horizontal_alignment: alignment::Horizontal, - pub vertical_alignment: alignment::Vertical, -} -- cgit From 023aded2772f0cd6abd716fe5c8624d5d22e21fa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 4 Nov 2021 19:22:29 +0700 Subject: Rename `fill_rectangle` to `fill_quad` in `Renderer` --- native/src/renderer/null.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'native/src/renderer') diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index 263b38a9..a5b2f277 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,6 +1,6 @@ use crate::renderer::{self, Renderer}; use crate::text::{self, Text}; -use crate::{Font, Point, Rectangle, Size, Vector}; +use crate::{Background, Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. /// @@ -27,7 +27,12 @@ impl Renderer for Null { fn clear(&mut self) {} - fn fill_rectangle(&mut self, _quad: renderer::Quad) {} + fn fill_quad( + &mut self, + _quad: renderer::Quad, + _background: impl Into, + ) { + } } impl text::Renderer for Null { -- cgit