//! Experimental port of https://github.com/aevyrie/bevy_mod_picking/blob/main/examples/many_buttons.rs. use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, prelude::*, }; use haalka::prelude::*; fn main() { App::new() .add_plugins(( DefaultPlugins, HaalkaPlugin, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default(), )) .add_systems(Startup, (setup, spawn_ui_root)) .run(); } const SIZE: usize = 110; // SIZE^2 buttons const FONT_SIZE: f32 = 7.0; const HOVERED_COLOR: Color = Color::srgb(0.25, 0.25, 0.25); const PRESSED_COLOR: Color = Color::srgb(0.35, 0.75, 0.35); fn button(i: usize, j: usize) -> RawHaalkaEl { let color = as_rainbow(j % i.max(1)); let (_pressed, pressed_signal) = Mutable::new_and_signal(false); let (_hovered, hovered_signal) = Mutable::new_and_signal(false); let background_color_signal = { map_ref!(pressed_signal, hovered_signal => { if *pressed_signal { PRESSED_COLOR } else if *hovered_signal { HOVERED_COLOR } else { color } }) .map(BackgroundColor) }; let total = SIZE as f32; let width = 90. / total; RawHaalkaEl::new() .insert(NodeBundle::default()) .with_component::