diff options
Diffstat (limited to 'examples/ggez/renderer')
-rw-r--r-- | examples/ggez/renderer/button.rs | 2 | ||||
-rw-r--r-- | examples/ggez/renderer/checkbox.rs | 4 | ||||
-rw-r--r-- | examples/ggez/renderer/radio.rs | 4 | ||||
-rw-r--r-- | examples/ggez/renderer/slider.rs | 2 | ||||
-rw-r--r-- | examples/ggez/renderer/text.rs | 22 |
5 files changed, 17 insertions, 17 deletions
diff --git a/examples/ggez/renderer/button.rs b/examples/ggez/renderer/button.rs index 2423efe1..fc3ea7ca 100644 --- a/examples/ggez/renderer/button.rs +++ b/examples/ggez/renderer/button.rs @@ -29,7 +29,7 @@ impl button::Renderer for Renderer<'_> { fn draw( &mut self, cursor_position: iced::Point, - mut bounds: iced::Rectangle<f32>, + mut bounds: iced::Rectangle, state: &button::State, label: &str, class: button::Class, diff --git a/examples/ggez/renderer/checkbox.rs b/examples/ggez/renderer/checkbox.rs index 1930631d..20a91be5 100644 --- a/examples/ggez/renderer/checkbox.rs +++ b/examples/ggez/renderer/checkbox.rs @@ -14,8 +14,8 @@ impl checkbox::Renderer for Renderer<'_> { fn draw( &mut self, cursor_position: iced::Point, - bounds: iced::Rectangle<f32>, - text_bounds: iced::Rectangle<f32>, + bounds: iced::Rectangle, + text_bounds: iced::Rectangle, is_checked: bool, ) -> MouseCursor { let mouse_over = bounds.contains(cursor_position) diff --git a/examples/ggez/renderer/radio.rs b/examples/ggez/renderer/radio.rs index 64310f9b..0f7815d6 100644 --- a/examples/ggez/renderer/radio.rs +++ b/examples/ggez/renderer/radio.rs @@ -14,8 +14,8 @@ impl radio::Renderer for Renderer<'_> { fn draw( &mut self, cursor_position: Point, - bounds: Rectangle<f32>, - bounds_with_label: Rectangle<f32>, + bounds: Rectangle, + bounds_with_label: Rectangle, is_selected: bool, ) -> MouseCursor { let mouse_over = bounds_with_label.contains(cursor_position); diff --git a/examples/ggez/renderer/slider.rs b/examples/ggez/renderer/slider.rs index 86757127..146cee18 100644 --- a/examples/ggez/renderer/slider.rs +++ b/examples/ggez/renderer/slider.rs @@ -22,7 +22,7 @@ impl slider::Renderer for Renderer<'_> { fn draw( &mut self, cursor_position: Point, - bounds: Rectangle<f32>, + bounds: Rectangle, state: &slider::State, range: RangeInclusive<f32>, value: f32, diff --git a/examples/ggez/renderer/text.rs b/examples/ggez/renderer/text.rs index bfdedf74..a6f782fc 100644 --- a/examples/ggez/renderer/text.rs +++ b/examples/ggez/renderer/text.rs @@ -9,16 +9,16 @@ impl text::Renderer<Color> for Renderer<'_> { fn node(&self, style: iced::Style, content: &str, size: f32) -> iced::Node { let font_cache = graphics::font_cache(self.context); let content = String::from(content); + + // TODO: Investigate why stretch tries to measure this MANY times + // with every ancestor's bounds. + // Bug? Using the library wrong? I should probably open an issue on + // the stretch repository. + // I noticed that the first measure is the one that matters in + // practice. Here, we use a RefCell to store the cached measurement. let measure = RefCell::new(None); iced::Node::with_measure(style, move |bounds| { - // TODO: Investigate why stretch tries to measure this MANY times - // with every ancestor's bounds. - // Bug? Using the library wrong? I should probably open an issue on - // the stretch repository. - // I noticed that the first measure is the one that matters in - // practice. Here, we use a RefCell to store the cached - // measurement. let mut measure = measure.borrow_mut(); if measure.is_none() { @@ -47,7 +47,7 @@ impl text::Renderer<Color> for Renderer<'_> { Align::Left, ); - let (width, height) = text.dimensions(&font_cache); + let (width, height) = font_cache.dimensions(&text); let size = iced::Size { width: width as f32, @@ -69,10 +69,10 @@ impl text::Renderer<Color> for Renderer<'_> { fn draw( &mut self, - bounds: iced::Rectangle<f32>, + bounds: iced::Rectangle, content: &str, size: f32, - color: Color, + color: Option<Color>, horizontal_alignment: text::HorizontalAlignment, _vertical_alignment: text::VerticalAlignment, ) { @@ -101,7 +101,7 @@ impl text::Renderer<Color> for Renderer<'_> { x: bounds.x, y: bounds.y, }, - Some(color), + color, ); } } |