diff --git a/TODO.md b/TODO.md deleted file mode 100644 index eb3997b..0000000 --- a/TODO.md +++ /dev/null @@ -1,26 +0,0 @@ -# Exploration - -## Inspectors - -### Model Inspector - -- [ ] Construct Scene from Nodes/Meshes (not auto-scene builder) -- [ ] Show debug info about selected model -- [ ] Wireframe view -- [ ] Automatic tighter bounding box for selection - -### Audio Inspector - -- [ ] UI for selecting sound -- [ ] Play/Pause/Volume -- [x] Load sounds -- [ ] Scrolling list of sounds - -## WASM - -- [ ] Build and run using model/text inspector - - https://github.com/bevyengine/bevy/blob/main/examples/README.md#wasm - -## Text Inspector - -- [ ] Performance improvements? diff --git a/bin/editor.rs b/bin/editor.rs index 1ff76fe..d11babe 100644 --- a/bin/editor.rs +++ b/bin/editor.rs @@ -5,9 +5,10 @@ // TODO: // * Tree Organization: GLTF contains Animations and Scenes // * Camera can only select one at a time. -// * (easy) Better Colorscheme +// * (hard) Better Colorscheme // * (medium) Visual errors for bad GLTFs // * (medium) Collapsable containers (Gltfs, Animations, Scenes, Audio Clips, Cameras) +// * (medium) Show/hide entire UI // * (medium) Spawn clicked scene // * (medium) Play clicked animation // * (idea) Use enum instead of markers for exclusive UI @@ -104,6 +105,7 @@ fn initialize_ui(mut commands: Commands) { Name::new("GLTFs"), NodeBundle { ..default() }, GltfsUi, + UiCollapse::Show, )) .with_children(|parent| { parent.spawn(( @@ -111,18 +113,21 @@ fn initialize_ui(mut commands: Commands) { Name::new("Scenes"), NodeBundle { ..default() }, ScenesUi, + UiCollapse::Show, )); parent.spawn(( GameUiList, Name::new("Cameras"), NodeBundle { ..default() }, CamerasUi, + UiCollapse::Show, )); parent.spawn(( GameUiList, Name::new("Animations"), NodeBundle { ..default() }, AnimationsUi, + UiCollapse::Show, )); }); parent.spawn(( @@ -130,6 +135,7 @@ fn initialize_ui(mut commands: Commands) { Name::new("Audio Clips"), NodeBundle { ..default() }, AudioClipsUi, + UiCollapse::Show, )); }); } @@ -358,7 +364,7 @@ fn load_audio( fn manage_audio_ui( mut events: EventReader>, - root: Query, Without>>)>, + root: Query, Without)>, mut commands: Commands, server: Res, ) { diff --git a/bin/ui-wtf.rs b/bin/ui-wtf.rs index aa8e16b..5aa0cda 100644 --- a/bin/ui-wtf.rs +++ b/bin/ui-wtf.rs @@ -1,4 +1,8 @@ -use bevy::{input::mouse::MouseWheel, prelude::*}; +use bevy::{ + input::{keyboard::KeyboardInput, ButtonState}, + prelude::*, + window::PrimaryWindow, +}; fn main() { App::new() @@ -10,92 +14,209 @@ fn main() { }), ..default() })) - .add_systems(Startup, (init,)) - .add_systems(Update, (scroll,)) + .init_resource::() + .add_systems(Startup, (init, init_cursors, init_container)) + .add_systems(Update, (cursors, container)) .run(); } -#[derive(Component)] -struct ScrollingList; +const CURSORS: [CursorIcon; 35] = [ + CursorIcon::Default, + CursorIcon::Crosshair, + CursorIcon::Hand, + CursorIcon::Arrow, + CursorIcon::Move, + CursorIcon::Text, + CursorIcon::Wait, + CursorIcon::Help, + CursorIcon::Progress, + CursorIcon::NotAllowed, + CursorIcon::ContextMenu, + CursorIcon::Cell, + CursorIcon::VerticalText, + CursorIcon::Alias, + CursorIcon::Copy, + CursorIcon::NoDrop, + CursorIcon::Grab, + CursorIcon::Grabbing, + CursorIcon::AllScroll, + CursorIcon::ZoomIn, + CursorIcon::ZoomOut, + CursorIcon::EResize, + CursorIcon::NResize, + CursorIcon::NeResize, + CursorIcon::NwResize, + CursorIcon::SResize, + CursorIcon::SeResize, + CursorIcon::SwResize, + CursorIcon::WResize, + CursorIcon::EwResize, + CursorIcon::NsResize, + CursorIcon::NeswResize, + CursorIcon::NwseResize, + CursorIcon::ColResize, + CursorIcon::RowResize, +]; + +#[derive(Debug, Component, Resource, Default)] +struct Icon(CursorIcon); fn init(mut commands: Commands) { info!("Spawning camera"); - commands.spawn(Camera2dBundle { ..default() }); + commands.spawn(( + Camera2dBundle { ..default() }, + UiCameraConfig { show_ui: true }, + )); +} - info!("Initializing UI"); +fn init_cursors(mut commands: Commands) { + info!("Spawning Cursor Icons"); commands .spawn(NodeBundle { - background_color: BackgroundColor(Color::WHITE), style: Style { - justify_content: JustifyContent::Center, - width: Val::Percent(90.0), - height: Val::Percent(90.0), - overflow: Overflow::clip(), + flex_direction: FlexDirection::Column, ..default() }, + background_color: BackgroundColor(Color::BLACK), ..default() }) .with_children(|parent| { + parent.spawn( + TextBundle::from_section("Cursor Icons", TextStyle { ..default() }) + .with_style(Style { + max_width: Val::Percent(100.0), + justify_self: JustifySelf::Stretch, + ..default() + }) + .with_background_color(Color::PINK), + ); + parent - .spawn(( - NodeBundle { - background_color: BackgroundColor(Color::OLIVE), - style: Style { - flex_wrap: FlexWrap::Wrap, - flex_direction: FlexDirection::Row, - justify_content: JustifyContent::SpaceAround, - width: Val::Auto, - height: Val::Auto, - max_width: Val::Auto, - max_height: Val::Auto, - ..default() - }, + .spawn(NodeBundle { + style: Style { + align_items: AlignItems::FlexStart, + flex_direction: FlexDirection::Column, + flex_wrap: FlexWrap::Wrap, ..default() }, - ScrollingList, - )) + ..default() + }) .with_children(|parent| { - info!("Initializing Child Element"); - let colors = [ - Color::ORANGE, - Color::BLUE, - Color::GREEN, - Color::SALMON, - Color::SEA_GREEN, - Color::MAROON, - Color::ORANGE, - Color::BLUE, - Color::GREEN, - Color::SALMON, - Color::SEA_GREEN, - Color::MAROON, - ]; - for i in 0..12 { - parent.spawn(NodeBundle { - background_color: BackgroundColor(colors[i]), - style: Style { - width: Val::Px(256.0), - height: Val::Px(256.0), - padding: UiRect::all(Val::Px(5.0)), - ..default() - }, - ..default() - }); - } + CURSORS.iter().for_each(|&icon| { + parent + .spawn(( + ButtonBundle { + style: Style { + padding: UiRect::all(Val::Px(5.0)), + margin: UiRect::all(Val::Px(5.0)), + border: UiRect::all(Val::Px(2.0)), + ..default() + }, + background_color: BackgroundColor(Color::GRAY), + border_color: BorderColor(Color::WHITE), + ..default() + }, + Icon(icon), + )) + .with_children(|parent| { + parent.spawn(TextBundle::from_section( + format!("{:?}", icon), + TextStyle { ..default() }, + )); + }); + }); }); }); } -fn scroll( - mut scroll_evr: EventReader, - mut query: Query<&mut Style, With>, +fn cursors( + events: Query<(&Interaction, &Icon), (Changed, With