I love control flow
This commit is contained in:
39
src/core/position/scroll.rs
Normal file
39
src/core/position/scroll.rs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user