Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Move druid::WindowConfig to glazier #23

Open
PoignardAzur opened this issue Oct 26, 2022 · 0 comments · May be fixed by #176
Open

Move druid::WindowConfig to glazier #23

PoignardAzur opened this issue Oct 26, 2022 · 0 comments · May be fixed by #176

Comments

@PoignardAzur
Copy link
Contributor

PoignardAzur commented Oct 26, 2022

Druid has the following data structure.

pub struct WindowConfig {
    pub(crate) size_policy: WindowSizePolicy,
    pub(crate) size: Option<Size>,
    pub(crate) min_size: Option<Size>,
    pub(crate) position: Option<Point>,
    pub(crate) resizable: Option<bool>,
    pub(crate) transparent: Option<bool>,
    pub(crate) show_titlebar: Option<bool>,
    pub(crate) level: Option<WindowLevel>,
    pub(crate) state: Option<WindowState>,
}

That struct is directly tied to WindowBuilder. Eg it has an apply_to_builder method:

/// Apply this window configuration to the given WindowBuilder
pub fn apply_to_builder(&self, builder: &mut WindowBuilder) {
    if let Some(resizable) = self.resizable {
        builder.resizable(resizable);
    }

    if let Some(show_titlebar) = self.show_titlebar {
        builder.show_titlebar(show_titlebar);
    }

    if let Some(size) = self.size {
        builder.set_size(size);
    } else if let WindowSizePolicy::Content = self.size_policy {
        builder.set_size(Size::new(0., 0.));
    }

    if let Some(position) = self.position {
        builder.set_position(position);
    }

    if let Some(transparent) = self.transparent {
        builder.set_transparent(transparent);
    }

    if let Some(level) = &self.level {
        builder.set_level(level.clone())
    }

    if let Some(state) = self.state {
        builder.set_window_state(state);
    }

    if let Some(min_size) = self.min_size {
        builder.set_min_size(min_size);
    }
}

Almost every method of WindowBuilder has a matching field in WindowConfig. So I think it would make sense to move WindowConfig to glazier directly. (And it would remove redundant interfaces from druid / masonry).

@DJMcNab DJMcNab linked a pull request Dec 28, 2023 that will close this issue
13 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant