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

unimplemented function #1589

Closed
Zenthae opened this issue Feb 13, 2021 · 4 comments
Closed

unimplemented function #1589

Zenthae opened this issue Feb 13, 2021 · 4 comments
Labels
shell/win concerns the Windows backend

Comments

@Zenthae
Copy link

Zenthae commented Feb 13, 2021

Can't use WindowSizePolicy::Content on windows until https://github.com/linebender/druid/blob/master/druid-shell/src/platform/windows/window.rs#L1661-L1664 is implemented

@cmyr cmyr added the shell/win concerns the Windows backend label Feb 17, 2021
@HoNile
Copy link
Contributor

HoNile commented Feb 18, 2021

I think it's better to continue here than in the merge PR.

Reminder:

@Zenthae did you have an example to reproduce this ? Myself I test using WindowSizePolicy::Content, with no size set on the tree example from nursery and it work fine.

it's the beginning of a new app i'm doing. i used this as a test

use druid::{
    widget::{Label, Padding},
    AppLauncher, Data, Lens, Widget, WindowDesc, WindowSizePolicy,
};

#[derive(Debug, Default, Data, Clone, Lens)]
struct AppState {}

fn ui_builder() -> impl Widget<AppState> {
    Padding::new(5., Label::new("Hello Bluetooth monitor"))
}

fn main() -> windows::Result<()> {
    let main_window = WindowDesc::new(ui_builder())
        .title("Bluetooth Monitor")
        // .window_size((100.0, 40.0))
        .window_size_policy(WindowSizePolicy::Content);

    AppLauncher::with_window(main_window)
        .use_simple_logger()
        .launch(AppState::default())
        .expect("Failed to start the app");

    Ok(())
}

So it looks like that if the window has no initial size, there is an issue, but I don't think content_insets(&self) should do more than what it does I think this should be solved elsewhere. Still an easy workaround is to just set a temporary window_size.

Ex:

    WindowDesc::new(Padding::new(5., Label::new("Hello Bluetooth monitor")))
        .window_size((1., 1.))
        .window_size_policy(WindowSizePolicy::Content)
        .resizable(false)

This I think did what you want.

@Zenthae
Copy link
Author

Zenthae commented Feb 18, 2021

indeed, i just find it "sad" to have to define a size even when it should take the Content size by default.

@HoNile
Copy link
Contributor

HoNile commented Feb 18, 2021

I think an okay solution could be to change window_size_policy on windows, to set the size to (1., 1.) if size_policy == WindowSizePolicy::Content. (@cmyr Is it okay for you ?)

Or just handle the thing in the windows druid-shell but set the size is a DeferredOp so I don't know how this could be done.

I know @Ciantic want to do some refactoring on the windows druid-shell he may have a idea.

@cmyr
Copy link
Member

cmyr commented Feb 18, 2021

yes, this sounds like a reasonable workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shell/win concerns the Windows backend
Projects
None yet
Development

No branches or pull requests

3 participants