use bevy::{
input::{keyboard::KeyboardInput, ElementState},
prelude::*,
};
use crossbeam_channel::{Receiver, Sender};
use headless_webview::types::{Texture, WindowSize};
use crate::{events::InputEvent, Webview, WebviewCommand};
#[derive(Debug)]
pub(crate) enum WebviewAction {
SetRPCInitialized(Entity),
Launch(LaunchEvent),
MouseMotion((Entity, Vec2)),
Click((Entity, MouseButton, ElementState, Vec2)),
Hover((Entity, Vec2)),
TypeKeyboard((Entity, KeyboardInput)),
Resize((Entity, Vec2)),
Remove(Entity),
SendOutputEvent(Option<Entity>, String, String),
Tick,
AppExit,
RunCommand(Option<Entity>, WebviewCommand),
SetVisibility(Entity, bool),
}
#[derive(Debug)]
pub(crate) struct LaunchEvent {
pub entity: Entity,
pub webview: Webview,
pub size: WindowSize,
}
#[derive(Debug)]
pub(crate) struct TextureReceivedEvent {
pub entity: Entity,
pub texture: Texture,
}
pub(crate) struct EventTransport {
pub webview_action_tx: Sender<WebviewAction>,
pub texture_rx: Receiver<TextureReceivedEvent>,
pub input_event_rx: Receiver<InputEvent>,
}