1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use makepad_render::*;
use crate::widgetstyle::*;
#[derive(Clone)]
pub struct ScrollShadow {
pub bg: Quad,
pub z: f32,
}
impl ScrollShadow {
pub fn proto(cx: &mut Cx) -> Self {
Self {
bg: Quad ::proto(cx),
z: 10.,
}
}
pub fn shadow_size() -> FloatId {uid!()}
pub fn shadow_top() -> InstanceFloat {uid!()}
pub fn shader_bg() -> ShaderId {uid!()}
pub fn style(cx: &mut Cx, _opt: &StyleOptions) {
Self::shadow_size().set(cx, 4.0);
Self::shader_bg().set(cx, Quad::def_quad_shader().compose(shader_ast !({
let is_viz: float<Varying>;
let shadow_top: Self::shadow_top();
fn scroll() -> vec2 {
if shadow_top > 0.5 {
is_viz = clamp(draw_scroll.w*0.1,0.,1.)
}
else {
is_viz = clamp(draw_scroll.z*0.1,0.,1.)
}
return draw_scroll.xy;
}
fn pixel() -> vec4 {
if shadow_top > 0.5{
return mix(vec4(0., 0., 0., is_viz), vec4(0., 0., 0., 0.), pow(geom.y, 0.5));
}
return mix(vec4(0., 0., 0., is_viz), vec4(0., 0., 0., 0.), pow(geom.x, 0.5));
}
})));
}
pub fn draw_shadow_top(&mut self, cx:&mut Cx){
self.draw_shadow_top_at(cx, Rect {
x: 0.,
y: 0.,
w: cx.get_width_total(),
h: 0.
});
}
pub fn draw_shadow_top_at(&mut self, cx:&mut Cx, rect:Rect){
self.bg.shader = Self::shader_bg().get(cx);
self.bg.z = self.z;
let inst = self.bg.draw_quad_rel(cx, Rect{h:ScrollShadow::shadow_size().get(cx),..rect});
inst.set_do_scroll(cx, false, false);
inst.push_float(cx, 1.0);
}
pub fn draw_shadow_left(&mut self, cx:&mut Cx){
self.draw_shadow_left_at(cx, Rect {
x: 0.,
y: 0.,
w: 0.,
h: cx.get_height_total()
});
}
pub fn draw_shadow_left_at(&mut self, cx:&mut Cx, rect:Rect){
self.bg.shader = Self::shader_bg().get(cx);
self.bg.z = self.z;
let inst = self.bg.draw_quad_rel(cx, Rect{w:ScrollShadow::shadow_size().get(cx),..rect});
inst.set_do_scroll(cx, false, false);
inst.push_float(cx, 0.0);
}
}