StarArawn / kayak_ui

Other
469 stars 50 forks source link

Using kayak-ui without primary window? #202

Open laundmo opened 1 year ago

laundmo commented 1 year ago

I'm working on a application which doesn't use a primary window, and instead relies on running in the background and sometimes opening other windows.

Kayak doesn't seem to allow for this, as it .unwrap()s on trying to get the primary window.

Error:

2022-12-21T22:38:26.846011Z  WARN kayak_ui::input: Couldn't find primiary window!    
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\laundmo\.cargo\git\checkouts\kayak_ui-299a0b6ac8320811\910a00c\src\widgets\app.rs:63:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Due to: https://github.com/StarArawn/kayak_ui/blob/910a00cdd3857cc7515f153580afd057de0abaf0/src/widgets/app.rs#L63

Is this something which is planned to be supported?

Hello World based minimal reproduction ```rs use bevy::prelude::*; use kayak_ui::prelude::{widgets::*, *}; fn startup( mut commands: Commands, mut font_mapping: ResMut, asset_server: Res, ) { font_mapping.set_default(asset_server.load("roboto.kayak_font")); let mut widget_context = KayakRootContext::new(); widget_context.add_plugin(KayakWidgetsContextPlugin); let parent_id = None; rsx! { }; commands.spawn(UICameraBundle::new(widget_context)); } fn main() { App::new() .add_plugins(DefaultPlugins.set(WindowPlugin { add_primary_window: false, exit_on_all_closed: false, ..default() })) .add_plugin(KayakContextPlugin) .add_plugin(KayakWidgets) .add_startup_system(startup) .run() } ```
RaminKav commented 1 year ago

I noticed this happens when i run any of the examples now, cloning main.

StarArawn commented 1 year ago

I noticed this happens when i run any of the examples now, cloning main.

I think this is an issue with linux, but I don't have a linux setup to test right now, and is likely related to this:

215

Instead of assuming the primary window exists we should check to see. I think if you need a more complicated windowing setup the default App probably will not work well for you as it'll always only check the primary window.