Repository navigation
Expand file tree
/
Copy pathheadless_split_pane.rs
More file actions
81 lines (76 loc) · 2.09 KB
/
Copy pathheadless_split_pane.rs
File metadata and controls
81 lines (76 loc) · 2.09 KB
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
//! Demonstrates the behavior-only split pane widget in `bevy_ui_widgets`.
use bevy::{
picking::cursor::{CursorIconPlugin, EntityCursor},
prelude::*,
ui_widgets::{split_pane_self_update, ControlOrientation, Pane, SplitPane, SplitPaneHandle},
window::SystemCursorIcon,
};
fn main() {
App::new()
.add_plugins((DefaultPlugins, CursorIconPlugin))
.add_systems(Startup, showcase.spawn())
.run();
}
fn showcase() -> impl SceneList {
bsn_list! {
Camera2d
--
Node {
width: percent(100),
height: percent(100),
}
SplitPane
on(split_pane_self_update)
Children [
@pane(1.0, Color::srgb(0.16, 0.20, 0.28))
--
@handle(ControlOrientation::Horizontal)
--
Pane {
size: 2.0,
min_size: 120.0,
}
Node
SplitPane {
orientation: ControlOrientation::Vertical,
}
on(split_pane_self_update)
Children [
@pane(3.0, Color::srgb(0.10, 0.11, 0.14))
--
@handle(ControlOrientation::Vertical)
--
@pane(1.0, Color::srgb(0.22, 0.17, 0.24))
]
--
@handle(ControlOrientation::Horizontal)
--
@pane(1.0, Color::srgb(0.15, 0.24, 0.19))
]
}
}
fn pane(size: f32, color: Color) -> impl Scene {
bsn! {
Pane {
size,
min_size: 60.0,
}
Node
BackgroundColor(color)
}
}
fn handle(orientation: ControlOrientation) -> impl Scene {
let (width, height, icon) = match orientation {
ControlOrientation::Horizontal => (px(6), Val::Auto, SystemCursorIcon::ColResize),
ControlOrientation::Vertical => (Val::Auto, px(6), SystemCursorIcon::RowResize),
};
bsn! {
SplitPaneHandle
Node {
width,
height,
}
BackgroundColor(Color::srgb(0.32, 0.34, 0.40))
EntityCursor::System(icon)
}
}