summaryrefslogtreecommitdiffstats
path: root/native/src/program
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-23 06:44:34 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-23 06:44:34 +0200
commitf30a666dc81fdc85d225dc83f1a33e32d5dccbd2 (patch)
tree579f3a0e8a050447c208282305c3de98f52f694e /native/src/program
parentbbdf558bd7eb3abbf69c922b34075360cd5f12c5 (diff)
downloadiced-f30a666dc81fdc85d225dc83f1a33e32d5dccbd2.tar.gz
iced-f30a666dc81fdc85d225dc83f1a33e32d5dccbd2.tar.bz2
iced-f30a666dc81fdc85d225dc83f1a33e32d5dccbd2.zip
Decouple `cursor_position` from `Cache`
Instead, we ask explicitly for it in the different `update` and `draw` methods. This way, the runtime can derive the logical position of the cursor from the source of truth.
Diffstat (limited to 'native/src/program')
-rw-r--r--native/src/program/state.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/native/src/program/state.rs b/native/src/program/state.rs
index bb428198..fdc42e8b 100644
--- a/native/src/program/state.rs
+++ b/native/src/program/state.rs
@@ -1,5 +1,5 @@
use crate::{
- Cache, Clipboard, Command, Debug, Event, Program, Renderer, Size,
+ Cache, Clipboard, Command, Debug, Event, Point, Program, Renderer, Size,
UserInterface,
};
@@ -31,6 +31,7 @@ where
pub fn new(
mut program: P,
bounds: Size,
+ cursor_position: Point,
renderer: &mut P::Renderer,
debug: &mut Debug,
) -> Self {
@@ -43,7 +44,7 @@ where
);
debug.draw_started();
- let primitive = user_interface.draw(renderer);
+ let primitive = user_interface.draw(renderer, cursor_position);
debug.draw_finished();
let cache = Some(user_interface.into_cache());
@@ -104,8 +105,9 @@ where
/// [`Program`]: trait.Program.html
pub fn update(
&mut self,
- clipboard: Option<&dyn Clipboard>,
bounds: Size,
+ cursor_position: Point,
+ clipboard: Option<&dyn Clipboard>,
renderer: &mut P::Renderer,
debug: &mut Debug,
) -> Option<Command<P::Message>> {
@@ -120,6 +122,7 @@ where
debug.event_processing_started();
let mut messages = user_interface.update(
self.queued_events.drain(..),
+ cursor_position,
clipboard,
renderer,
);
@@ -128,7 +131,7 @@ where
if messages.is_empty() {
debug.draw_started();
- self.primitive = user_interface.draw(renderer);
+ self.primitive = user_interface.draw(renderer, cursor_position);
debug.draw_finished();
self.cache = Some(user_interface.into_cache());
@@ -159,7 +162,7 @@ where
);
debug.draw_started();
- self.primitive = user_interface.draw(renderer);
+ self.primitive = user_interface.draw(renderer, cursor_position);
debug.draw_finished();
self.cache = Some(user_interface.into_cache());