Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting window building-process in multiple builder functions does not show all windows but only the last one beeing called #1708

Closed
2 tasks done
kernelPanic0x opened this issue Feb 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@kernelPanic0x
Copy link

kernelPanic0x commented Feb 16, 2023

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I have multiple windows that i need to build and in order to keep the main function neat and clean i wanted to split the build process of these windows into their own files/build functions.

// main.rs

let app = app::App::default().with_scheme(app::Scheme::Gleam);

// ...

// build new entry window
new_entry_window::build_ui();

// build loading window
loading_window::build_ui();

// build info window
info_window::build_ui();

// build main window
main_window::build_ui();

app.run().unwrap();
// loading_window.rs
// example builder of one of the windows

pub fn build_ui() {
    // app state
    let state = app::GlobalState::<AppState>::get();
    let cfg = state.with(|s| s.cfg.clone());

    // screen working area
    let (x, y, w, h) = app::screen_work_area(cfg.screen_num);

    // loading window
    let mut loading_window = window::Window::default().with_size(400, 90).center_screen();

    loading_window.set_label("Lade PDF...");
    loading_window.make_modal(true);
    loading_window.set_pos(x + (w / 2 - 400 / 2), y + (h / 2 - 90 / 2));
    loading_window.set_cursor(enums::Cursor::Wait);

    let mut loading =
        image::PngImage::load(std::path::Path::new("assets/hourglass1.png")).unwrap();

    loading.scale(60, 60, true, true);

    let mut loading_frame = frame::Frame::default().center_of_parent();

    loading_frame.set_image(Some(loading));

    loading_window.end();

    // add window to app state
    state.with(move |s| s.wnd_load = loading_window.clone());
}

I am using the global state to be able to get a referance to one of the windows. When i .show() on any window, it only shows the last one. In this case the main window and not my "info" window which should open ontop of the main window. The main window gets displayed tho. Both have the .show() method beeing called on them.

I have also tried to use the global state in the main rust file to show both windows but it has exactly the same result.

I also noticed that the window i want to show too is flickering at startup so it gets created but closes immediatly and only the last one beeing called is visable.

My guess is it has something to do with scoping of the build functions. In that case, what is the best way to split out the build process of larger projects without that happening?

What is the expected behavior?

The main window and the info window should both be visible at the same time.

Version

master

Operative System

Windows

Do you have any log output?

No response

@kernelPanic0x kernelPanic0x added the bug Something isn't working label Feb 16, 2023
@geom3trik
Copy link

Iced does not yet support multiple windows. See #27

@hecrj
Copy link
Member

hecrj commented Feb 16, 2023

The code seems unrelated to iced. iced exposes no way to build a window.

@kernelPanic0x
Copy link
Author

I'm so sorry i had the wrong repository selected!! It's a fltk-rs related problem.

Sorry for the inconvinience :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants