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

feat: Add methods for window settings in Application #2470

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ impl<P: Program> Application<P> {
self
}

/// Sets the [`window::Settings`] of the [`Application`].
///
/// Overwrites any previous [`window::Settings`].
pub fn window(self, window: window::Settings) -> Self {
Self { window, ..self }
}

/// Sets the [`window::Settings::position`] to [`window::Position::Centered`] in the [`Application`].
pub fn centered(self) -> Self {
Self {
Expand Down Expand Up @@ -256,6 +263,50 @@ impl<P: Program> Application<P> {
}
}

/// Sets the [`window::Settings::resizable`] of the [`Application`].
pub fn resizable(self, resizable: bool) -> Self {
Self {
window: window::Settings {
resizable,
..self.window
},
..self
}
}

/// Sets the [`window::Settings::decorations`] of the [`Application`].
pub fn decorations(self, decorations: bool) -> Self {
Self {
window: window::Settings {
decorations,
..self.window
},
..self
}
}

/// Sets the [`window::Settings::position`] of the [`Application`].
pub fn position(self, position: window::Position) -> Self {
Self {
window: window::Settings {
position,
..self.window
},
..self
}
}

/// Sets the [`window::Settings::level`] of the [`Application`].
pub fn level(self, level: window::Level) -> Self {
Self {
window: window::Settings {
level,
..self.window
},
..self
}
}

/// Sets the [`Title`] of the [`Application`].
pub(crate) fn title(
self,
Expand Down
Loading