diff options
author | 2025-02-03 03:22:10 +0100 | |
---|---|---|
committer | 2025-02-04 01:26:59 +0100 | |
commit | afef368d8a920c7702048d3b1604b2046fe46ff8 (patch) | |
tree | 956ce409f5969cfd6b163796f141213c6235b805 /widget | |
parent | 1b01d6718bf0c6b652a3256df51727c3e72fdd9e (diff) | |
download | iced-afef368d8a920c7702048d3b1604b2046fe46ff8.tar.gz iced-afef368d8a920c7702048d3b1604b2046fe46ff8.tar.bz2 iced-afef368d8a920c7702048d3b1604b2046fe46ff8.zip |
Take `Event` by reference in `Widget::update`
Diffstat (limited to 'widget')
35 files changed, 86 insertions, 122 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs index 11839d5e..0e24328f 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -275,7 +275,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -285,7 +285,7 @@ where ) { self.content.as_widget_mut().update( &mut tree.children[0], - event.clone(), + event, layout.children().next().unwrap(), cursor, renderer, diff --git a/widget/src/canvas.rs b/widget/src/canvas.rs index d10771f0..046abddf 100644 --- a/widget/src/canvas.rs +++ b/widget/src/canvas.rs @@ -218,7 +218,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/canvas/program.rs b/widget/src/canvas/program.rs index c68b2830..43446b64 100644 --- a/widget/src/canvas/program.rs +++ b/widget/src/canvas/program.rs @@ -32,7 +32,7 @@ where fn update( &self, _state: &mut Self::State, - _event: Event, + _event: &Event, _bounds: Rectangle, _cursor: mouse::Cursor, ) -> Option<Action<Message>> { @@ -82,7 +82,7 @@ where fn update( &self, state: &mut Self::State, - event: Event, + event: &Event, bounds: Rectangle, cursor: mouse::Cursor, ) -> Option<Action<Message>> { diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 663bfad1..6ed3e080 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -305,7 +305,7 @@ where fn update( &mut self, _tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, diff --git a/widget/src/column.rs b/widget/src/column.rs index c729cbdb..7200690b 100644 --- a/widget/src/column.rs +++ b/widget/src/column.rs @@ -260,7 +260,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -275,13 +275,7 @@ where .zip(layout.children()) { child.as_widget_mut().update( - state, - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, + state, event, layout, cursor, renderer, clipboard, shell, viewport, ); } diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index 05793155..f71e4a6e 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -512,7 +512,7 @@ where fn update( &mut self, tree: &mut widget::Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -540,7 +540,7 @@ where // Provide it to the widget self.text_input.update( &mut tree.children[0], - event.clone(), + event, layout, cursor, renderer, @@ -737,7 +737,7 @@ where let mut local_shell = Shell::new(&mut local_messages); self.text_input.update( &mut tree.children[0], - Event::Mouse(mouse::Event::ButtonPressed( + &Event::Mouse(mouse::Event::ButtonPressed( mouse::Button::Left, )), layout, diff --git a/widget/src/container.rs b/widget/src/container.rs index 852481f1..82dc3141 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -300,7 +300,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 199b8fc0..4cba197d 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -633,7 +633,7 @@ where fn update( &mut self, state: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -836,7 +836,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -885,14 +885,8 @@ where let redraw_request = shell.redraw_request(); self.top.as_widget_mut().update( - top_tree, - event.clone(), - top_layout, - cursor, - renderer, - clipboard, - shell, - viewport, + top_tree, event, top_layout, cursor, renderer, clipboard, + shell, viewport, ); // Ignore redraw requests of invisible content @@ -907,7 +901,7 @@ where self.base.as_widget_mut().update( base_tree, - event.clone(), + event, base_layout, cursor, renderer, diff --git a/widget/src/image/viewer.rs b/widget/src/image/viewer.rs index 20a7955f..06652ff7 100644 --- a/widget/src/image/viewer.rs +++ b/widget/src/image/viewer.rs @@ -151,7 +151,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -167,7 +167,7 @@ where return; }; - match delta { + match *delta { mouse::ScrollDelta::Lines { y, .. } | mouse::ScrollDelta::Pixels { y, .. } => { let state = tree.state.downcast_mut::<State>(); @@ -256,7 +256,7 @@ where .max(0.0) .round(); - let delta = position - origin; + let delta = *position - origin; let x = if bounds.width < scaled_size.width { (state.starting_offset.x - delta.x) diff --git a/widget/src/keyed/column.rs b/widget/src/keyed/column.rs index ab0b0bde..313b728a 100644 --- a/widget/src/keyed/column.rs +++ b/widget/src/keyed/column.rs @@ -300,7 +300,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -315,13 +315,7 @@ where .zip(layout.children()) { child.as_widget_mut().update( - state, - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, + state, event, layout, cursor, renderer, clipboard, shell, viewport, ); } diff --git a/widget/src/lazy.rs b/widget/src/lazy.rs index c6710e30..6df026de 100644 --- a/widget/src/lazy.rs +++ b/widget/src/lazy.rs @@ -198,7 +198,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -386,7 +386,7 @@ where fn update( &mut self, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/lazy/component.rs b/widget/src/lazy/component.rs index c93b7c42..30822b7d 100644 --- a/widget/src/lazy/component.rs +++ b/widget/src/lazy/component.rs @@ -313,7 +313,7 @@ where fn update( &mut self, tree: &mut Tree, - event: core::Event, + event: &core::Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -593,7 +593,7 @@ where fn update( &mut self, - event: core::Event, + event: &core::Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/lazy/responsive.rs b/widget/src/lazy/responsive.rs index 8129336e..e7c937af 100644 --- a/widget/src/lazy/responsive.rs +++ b/widget/src/lazy/responsive.rs @@ -188,7 +188,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -416,7 +416,7 @@ where fn update( &mut self, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/mouse_area.rs b/widget/src/mouse_area.rs index 9ba3cff5..c1c3ba0f 100644 --- a/widget/src/mouse_area.rs +++ b/widget/src/mouse_area.rs @@ -218,7 +218,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -228,7 +228,7 @@ where ) { self.content.as_widget_mut().update( &mut tree.children[0], - event.clone(), + event, layout, cursor, renderer, @@ -326,7 +326,7 @@ where fn update<Message: Clone, Theme, Renderer>( widget: &mut MouseArea<'_, Message, Theme, Renderer>, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, shell: &mut Shell<'_, Message>, @@ -425,7 +425,7 @@ fn update<Message: Clone, Theme, Renderer>( } Event::Mouse(mouse::Event::WheelScrolled { delta }) => { if let Some(on_scroll) = widget.on_scroll.as_ref() { - shell.publish(on_scroll(delta)); + shell.publish(on_scroll(*delta)); shell.capture_event(); } } diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs index 611476ce..9d0539ff 100644 --- a/widget/src/overlay/menu.rs +++ b/widget/src/overlay/menu.rs @@ -263,7 +263,7 @@ where fn update( &mut self, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -388,7 +388,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs index e972b983..3ae1dfc7 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -474,7 +474,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -509,15 +509,8 @@ where let is_picked = picked_pane == Some(pane); content.update( - tree, - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, - viewport, - is_picked, + tree, event, layout, cursor, renderer, clipboard, shell, + viewport, is_picked, ); } diff --git a/widget/src/pane_grid/content.rs b/widget/src/pane_grid/content.rs index be5e5066..4d63dd18 100644 --- a/widget/src/pane_grid/content.rs +++ b/widget/src/pane_grid/content.rs @@ -242,7 +242,7 @@ where pub(crate) fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -256,7 +256,7 @@ where title_bar.update( &mut tree.children[1], - event.clone(), + event, children.next().unwrap(), cursor, renderer, diff --git a/widget/src/pane_grid/title_bar.rs b/widget/src/pane_grid/title_bar.rs index 4bd2c2f6..611c3d67 100644 --- a/widget/src/pane_grid/title_bar.rs +++ b/widget/src/pane_grid/title_bar.rs @@ -430,7 +430,7 @@ where pub(crate) fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -456,7 +456,7 @@ where compact.as_widget_mut().update( &mut tree.children[2], - event.clone(), + event, compact_layout, cursor, renderer, @@ -469,7 +469,7 @@ where controls.full.as_widget_mut().update( &mut tree.children[1], - event.clone(), + event, controls_layout, cursor, renderer, @@ -481,7 +481,7 @@ where } else { controls.full.as_widget_mut().update( &mut tree.children[1], - event.clone(), + event, controls_layout, cursor, renderer, diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index 6708e7cd..b751fcc3 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -430,7 +430,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, @@ -489,13 +489,13 @@ where let options = self.options.borrow(); let selected = self.selected.as_ref().map(Borrow::borrow); - let next_option = if y < 0.0 { + let next_option = if *y < 0.0 { if let Some(selected) = selected { find_next(selected, options.iter()) } else { options.first() } - } else if y > 0.0 { + } else if *y > 0.0 { if let Some(selected) = selected { find_next(selected, options.iter().rev()) } else { @@ -513,7 +513,7 @@ where } } Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { - state.keyboard_modifiers = modifiers; + state.keyboard_modifiers = *modifiers; } _ => {} }; diff --git a/widget/src/pin.rs b/widget/src/pin.rs index 7c1aca61..afa29398 100644 --- a/widget/src/pin.rs +++ b/widget/src/pin.rs @@ -177,7 +177,7 @@ where fn update( &mut self, tree: &mut widget::Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/pop.rs b/widget/src/pop.rs index 146cfb2b..6e9df4be 100644 --- a/widget/src/pop.rs +++ b/widget/src/pop.rs @@ -108,7 +108,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/radio.rs b/widget/src/radio.rs index 15c983df..0df4d715 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -326,7 +326,7 @@ where fn update( &mut self, _state: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, diff --git a/widget/src/row.rs b/widget/src/row.rs index 3b605f07..5ffeab49 100644 --- a/widget/src/row.rs +++ b/widget/src/row.rs @@ -256,7 +256,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -271,13 +271,7 @@ where .zip(layout.children()) { child.as_widget_mut().update( - state, - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, + state, event, layout, cursor, renderer, clipboard, shell, viewport, ); } @@ -495,7 +489,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index a51a8625..8adf5136 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -517,7 +517,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -736,7 +736,7 @@ where self.content.as_widget_mut().update( &mut tree.children[0], - event.clone(), + event, content, cursor, renderer, @@ -781,7 +781,7 @@ where modifiers, )) = event { - state.keyboard_modifiers = modifiers; + state.keyboard_modifiers = *modifiers; return; } @@ -792,7 +792,7 @@ where return; } - let delta = match delta { + let delta = match *delta { mouse::ScrollDelta::Lines { x, y } => { let is_shift_pressed = state.keyboard_modifiers.shift(); diff --git a/widget/src/shader.rs b/widget/src/shader.rs index 48c96321..06254a1c 100644 --- a/widget/src/shader.rs +++ b/widget/src/shader.rs @@ -88,7 +88,7 @@ where fn update( &mut self, tree: &mut Tree, - event: crate::core::Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, @@ -174,7 +174,7 @@ where fn update( &self, state: &mut Self::State, - event: Event, + event: &Event, bounds: Rectangle, cursor: mouse::Cursor, ) -> Option<Action<Message>> { diff --git a/widget/src/shader/program.rs b/widget/src/shader/program.rs index 0fc110af..81ecc9b1 100644 --- a/widget/src/shader/program.rs +++ b/widget/src/shader/program.rs @@ -26,7 +26,7 @@ pub trait Program<Message> { fn update( &self, _state: &mut Self::State, - _event: shader::Event, + _event: &shader::Event, _bounds: Rectangle, _cursor: mouse::Cursor, ) -> Option<Action<Message>> { diff --git a/widget/src/slider.rs b/widget/src/slider.rs index 52500854..1908abc9 100644 --- a/widget/src/slider.rs +++ b/widget/src/slider.rs @@ -245,7 +245,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, diff --git a/widget/src/stack.rs b/widget/src/stack.rs index d5cf1ecf..df9f6162 100644 --- a/widget/src/stack.rs +++ b/widget/src/stack.rs @@ -207,7 +207,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, mut cursor: mouse::Cursor, renderer: &Renderer, @@ -227,13 +227,7 @@ where .enumerate() { child.as_widget_mut().update( - state, - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, + state, event, layout, cursor, renderer, clipboard, shell, viewport, ); diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index 0b499ec6..a9e544d1 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -358,7 +358,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index cfdf6b5d..e685256b 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -651,7 +651,7 @@ where fn update( &mut self, tree: &mut widget::Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -686,17 +686,18 @@ where Event::Window(window::Event::RedrawRequested(now)) => { if let Some(focus) = &mut state.focus { if focus.is_window_focused { - focus.now = now; + focus.now = *now; let millis_until_redraw = Focus::CURSOR_BLINK_INTERVAL_MILLIS - - (now - focus.updated_at).as_millis() + - (focus.now - focus.updated_at).as_millis() % Focus::CURSOR_BLINK_INTERVAL_MILLIS; shell.request_redraw_at( - now + Duration::from_millis( - millis_until_redraw as u64, - ), + focus.now + + Duration::from_millis( + millis_until_redraw as u64, + ), ); } } @@ -1216,7 +1217,7 @@ enum Ime { impl<Message> Update<Message> { fn from_event<H: Highlighter>( - event: Event, + event: &Event, state: &State<H>, bounds: Rectangle, padding: Padding, @@ -1284,14 +1285,14 @@ impl<Message> Update<Message> { if state.focus.is_some() => { Some(Update::InputMethod(Ime::Preedit { - content, - selection, + content: content.clone(), + selection: selection.clone(), })) } input_method::Event::Commit(content) if state.focus.is_some() => { - Some(Update::InputMethod(Ime::Commit(content))) + Some(Update::InputMethod(Ime::Commit(content.clone()))) } _ => None, }, @@ -1310,9 +1311,9 @@ impl<Message> Update<Message> { }; let key_press = KeyPress { - key, - modifiers, - text, + key: key.clone(), + modifiers: *modifiers, + text: text.clone(), status, }; diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index b22ee1ca..215ecbd6 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -692,7 +692,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/themer.rs b/widget/src/themer.rs index 769cc4ca..4e583882 100644 --- a/widget/src/themer.rs +++ b/widget/src/themer.rs @@ -113,7 +113,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -220,7 +220,7 @@ where fn update( &mut self, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index 56c2be1f..b711432e 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -309,7 +309,7 @@ where fn update( &mut self, _state: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs index a0ffe392..5bebeeac 100644 --- a/widget/src/tooltip.rs +++ b/widget/src/tooltip.rs @@ -192,7 +192,7 @@ where fn update( &mut self, tree: &mut widget::Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs index 2ed9419a..6f878fde 100644 --- a/widget/src/vertical_slider.rs +++ b/widget/src/vertical_slider.rs @@ -249,7 +249,7 @@ where fn update( &mut self, tree: &mut Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, _renderer: &Renderer, @@ -379,7 +379,7 @@ where if state.keyboard_modifiers.control() => { if cursor.is_over(layout.bounds()) { - let delta = match delta { + let delta = match *delta { mouse::ScrollDelta::Lines { x: _, y } => y, mouse::ScrollDelta::Pixels { x: _, y } => y, }; @@ -411,7 +411,7 @@ where } } Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { - state.keyboard_modifiers = modifiers; + state.keyboard_modifiers = *modifiers; } _ => {} } |