diff --git a/.gitignore b/.gitignore index ad67955..276b8cc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # will have compiled files and executables debug target +logs.txt # These are backup files generated by rustfmt **/*.rs.bk diff --git a/examples/layer_shell_window.rs b/examples/layer_shell_window.rs index d3b1567..aa2ec7d 100644 --- a/examples/layer_shell_window.rs +++ b/examples/layer_shell_window.rs @@ -1,18 +1,192 @@ -use bevy::{prelude::*, winit::WinitPlugin}; -use bevy_wayland::{layer_shell::LayerShellWindow, WaylandPlugin}; +use std::time::Duration; + +use bevy::{ + color::palettes::basic::*, + prelude::*, + window::{WindowCreated, WindowResolution}, + winit::WinitPlugin, +}; +use bevy_wayland::{layer_shell::LayerShellSettings, WaylandPlugin}; +use smithay_client_toolkit::shell::wlr_layer::{Anchor, Layer}; + +const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15); +const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25); +const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35); fn main() { App::new() .add_plugins(( - DefaultPlugins.build().disable::(), + DefaultPlugins + .build() + .disable::() + .set(WindowPlugin { + primary_window: Some(Window { + resolution: WindowResolution::new(400.0, 400.0), + ..Default::default() + }), + ..Default::default() + }), WaylandPlugin, )) + .init_resource::() .add_systems(Startup, setup) + .add_systems(Update, (button_system, setup_new_window, spawn_window)) .run(); } -fn setup(mut commands: Commands, windows: Query>) { - for entity in &windows { - commands.entity(entity).insert(LayerShellWindow::default()); +#[allow(clippy::type_complexity)] +fn button_system( + mut interaction_query: Query< + ( + &Interaction, + &mut BackgroundColor, + &mut BorderColor, + &Children, + ), + (Changed, With