1use gpui::{App, Bounds, Context, Window, WindowBounds, WindowOptions, div, prelude::*, px, size};
2use gpui_platform::application;
3
4struct Scrollable {}
5
6impl Render for Scrollable {
7 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
8 div()
9 .size_full()
10 .id("vertical")
11 .p_4()
12 .overflow_scroll()
13 .bg(gpui::white())
14 .child("Example for test 2 way scroll in nested layout")
15 .child(
16 div()
17 .h(px(5000.))
18 .border_1()
19 .border_color(gpui::blue())
20 .bg(gpui::blue().opacity(0.05))
21 .p_4()
22 .child(
23 div()
24 .mb_5()
25 .w_full()
26 .id("horizontal")
27 .overflow_scroll()
28 .child(
29 div()
30 .w(px(2000.))
31 .h(px(150.))
32 .bg(gpui::green().opacity(0.1))
33 .hover(|this| this.bg(gpui::green().opacity(0.2)))
34 .border_1()
35 .border_color(gpui::green())
36 .p_4()
37 .child("Scroll Horizontal"),
38 ),
39 )
40 .child("Scroll Vertical"),
41 )
42 }
43}
44
45fn main() {
46 application().run(|cx: &mut App| {
47 let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
48 cx.open_window(
49 WindowOptions {
50 window_bounds: Some(WindowBounds::Windowed(bounds)),
51 ..Default::default()
52 },
53 |_, cx| cx.new(|_| Scrollable {}),
54 )
55 .unwrap();
56 cx.activate(true);
57 });
58}