Fyrox icon indicating copy to clipboard operation
Fyrox copied to clipboard

[Bug?] Multiple Calls of with_content to WindowBuilder seems to have unexpected behavior.

Open DomtronVox opened this issue 2 years ago • 1 comments

I was messing around with an edge case of calling .with_content multiple time. I had assumed that the widget provided by the second call would just replace the previous widget. Instead the new widget is placed into the Window and the first widget just pops out of it and is placed on the application window at 0,0.

Is this a bug or is my assumption wrong and this is perfectly valid behavior?

Thanks!

Example code:

use fyrox::{
    core::{pool::Handle, algebra::Vector2},
    gui::{
        window::{WindowBuilder, WindowTitle}, 
        text::TextBuilder, 
        widget::WidgetBuilder, 
        UiNode, 
        UserInterface
    },
};

fn create_window(ui: &mut UserInterface) {
    WindowBuilder::new(
        WidgetBuilder::new()
            .with_desired_position(Vector2::new(300.0, 0.0))
            .with_width(300.0),
    )
    .with_content(
        TextBuilder::new(WidgetBuilder::new())
            .with_text("Example Window content.")
            .build(&mut ui.build_ctx())
    )
    .with_content(
        TextBuilder::new(WidgetBuilder::new())
            .with_text("Replacement text.")
            .build(&mut ui.build_ctx())
    )
    .with_title(WindowTitle::text("Window"))
    .can_close(true)
    .can_minimize(true)
    .open(true)
    .can_resize(false)
    .build(&mut ui.build_ctx());
}

DomtronVox avatar Apr 28 '22 02:04 DomtronVox

This is perfectly valid behavior, because .with_content just sets a handle to inner content variable. Later this content will be attached to the inner panel of the window.

mrDIMAS avatar Apr 28 '22 13:04 mrDIMAS