Skip to main content

ak_vis/ui/
build.rs

1#[path = "build_inspector.rs"]
2mod inspector;
3#[path = "build_playback_panel.rs"]
4mod playback_panel;
5
6use bevy::prelude::*;
7
8use crate::viewer::{ViewerConfig, ViewerFonts};
9
10use super::{ACCENT_COLOR, BODY_COLOR};
11
12pub fn setup_ui(mut commands: Commands, asset_server: Res<AssetServer>, config: Res<ViewerConfig>) {
13    let font = asset_server.load("fonts/RobotoMono-VariableFont_wght.ttf");
14    let symbol_font = asset_server.load("fonts/NotoSansSymbols2-Regular.ttf");
15
16    spawn_ui(&mut commands, &font, &symbol_font, config.as_ref());
17}
18
19pub(crate) fn setup_viewer_ui(
20    mut commands: Commands,
21    fonts: Res<ViewerFonts>,
22    config: Res<ViewerConfig>,
23) {
24    spawn_ui(&mut commands, &fonts.mono, &fonts.symbols, config.as_ref());
25}
26
27fn spawn_ui(
28    commands: &mut Commands,
29    font: &Handle<Font>,
30    symbol_font: &Handle<Font>,
31    config: &ViewerConfig,
32) {
33    inspector::spawn_inspector_panel(commands, font, symbol_font);
34    playback_panel::spawn_playback_panel(commands, font, symbol_font, config);
35}
36
37pub(super) fn section_title_bundle(text: &str, font: &Handle<Font>) -> impl Bundle {
38    (
39        Text::new(text),
40        TextFont {
41            font: font.clone(),
42            font_size: 12.0,
43            ..default()
44        },
45        TextColor(ACCENT_COLOR),
46    )
47}
48
49pub(super) fn section_body_bundle(text: &str, font: &Handle<Font>) -> impl Bundle {
50    (
51        Text::new(text),
52        TextFont {
53            font: font.clone(),
54            font_size: 11.0,
55            ..default()
56        },
57        TextColor(BODY_COLOR),
58    )
59}