iris: drive animation from painter frame time

This commit is contained in:
iris committed 2026-09-12 21:37:47 -04:00
1 parent 5f4975285d
commit eb30a01f2d
14 files changed
+148 -116

No files matched your search

+6 -14
View File
@@ -1,5 +1,4 @@
use crate::prelude::*;
use std::time::Instant;
pub struct ScrollArea {
inner: StrongWidget,
@@ -19,11 +18,10 @@ impl Scrollable for ScrollArea {
}
impl Widget for ScrollArea {
fn tick(&mut self, now: Instant) -> bool {
self.tick_fling(now)
}
fn draw(&mut self, painter: &mut Painter) {
if self.ctl.advance(painter.frame_time()) {
painter.request_next_frame();
}
let axis = self.ctl.axis();
let container_len = painter.px_size().axis(axis);
self.container_len = container_len;
@@ -87,7 +85,7 @@ mod tests {
use super::*;
use crate::layout_tests::TestRsc;
use crate::sense::{CursorButton, DRAG_SLOP, PointerRequests};
use std::time::Duration;
use std::time::{Duration, Instant};
fn area() -> (Fixture, WidgetId) {
area_on(Axis::Y)
@@ -146,9 +144,7 @@ mod tests {
}
fn fling_frame(&mut self, now: Instant) -> bool {
let still = self.get().tick(now);
self.draw();
still
self.render.update_at(&self.root, &mut self.rsc, now)
}
}
@@ -158,11 +154,7 @@ mod tests {
fn drag(f: &mut Fixture, id: WidgetId, sense: CursorSense, pos: Vec2, t: Instant) {
let pointer = PointerRequests::default();
let flung = f.get().drag(&pointer, id, sense, pos, t);
if flung {
let id = f.area.id();
f.rsc.ui.animate(id);
}
f.get().drag(&pointer, id, sense, pos, t);
f.draw();
}