I love control flow

This commit is contained in:
2025-11-20 22:48:08 -05:00
parent f6f9ebbe51
commit dff72d2c43
19 changed files with 126 additions and 63 deletions

View File

@@ -0,0 +1,39 @@
use crate::prelude::*;
pub struct Scroll {
inner: WidgetId,
axis: Axis,
snap_end: bool,
amt: f32,
draw_len: f32,
}
impl Widget for Scroll {
fn draw(&mut self, painter: &mut Painter) {
let output_len = painter.output_size().axis(self.axis);
let container_len = painter.region().axis(self.axis).len();
let content_len = painter
.len_axis(&self.inner, self.axis)
.apply_rest()
.within_len(container_len)
.to_abs(output_len);
let container_len = container_len.to_abs(output_len);
self.draw_len = content_len;
// let region = UiRegion::FULL.offset(self.amt);
// painter.widget_within(&self.inner, region);
}
fn desired_width(&mut self, _: &mut SizeCtx) -> Len {
Len::default()
}
fn desired_height(&mut self, _: &mut SizeCtx) -> Len {
Len::default()
}
}
impl Scroll {
pub fn scroll(&mut self, amt: f32) {
self.amt += amt;
}
}