Merge pull request #2735 from Exidex/closable-and-minimizable
Add ability to hide close and minimize title bar buttons
This commit is contained in:
commit
5195a59e20
2 changed files with 23 additions and 6 deletions
|
|
@ -56,6 +56,12 @@ pub struct Settings {
|
|||
/// Whether the window should be resizable or not.
|
||||
pub resizable: bool,
|
||||
|
||||
/// Whether the title bar has Close button or not
|
||||
pub closeable: bool,
|
||||
|
||||
/// Whether the title bar has Minimize button or not
|
||||
pub minimizable: bool,
|
||||
|
||||
/// Whether the window should have a border, a title bar, etc. or not.
|
||||
pub decorations: bool,
|
||||
|
||||
|
|
@ -105,6 +111,8 @@ impl Default for Settings {
|
|||
max_size: None,
|
||||
visible: true,
|
||||
resizable: true,
|
||||
minimizable: true,
|
||||
closeable: true,
|
||||
decorations: true,
|
||||
transparent: false,
|
||||
blur: false,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,20 @@ pub fn window_attributes(
|
|||
) -> winit::window::WindowAttributes {
|
||||
let mut attributes = winit::window::WindowAttributes::default();
|
||||
|
||||
let mut buttons = winit::window::WindowButtons::empty();
|
||||
|
||||
if settings.resizable {
|
||||
buttons |= winit::window::WindowButtons::MAXIMIZE;
|
||||
}
|
||||
|
||||
if settings.closeable {
|
||||
buttons |= winit::window::WindowButtons::CLOSE;
|
||||
}
|
||||
|
||||
if settings.minimizable {
|
||||
buttons |= winit::window::WindowButtons::MINIMIZE;
|
||||
}
|
||||
|
||||
attributes = attributes
|
||||
.with_title(title)
|
||||
.with_inner_size(winit::dpi::LogicalSize {
|
||||
|
|
@ -33,12 +47,7 @@ pub fn window_attributes(
|
|||
.then_some(winit::window::Fullscreen::Borderless(None)),
|
||||
)
|
||||
.with_resizable(settings.resizable)
|
||||
.with_enabled_buttons(if settings.resizable {
|
||||
winit::window::WindowButtons::all()
|
||||
} else {
|
||||
winit::window::WindowButtons::CLOSE
|
||||
| winit::window::WindowButtons::MINIMIZE
|
||||
})
|
||||
.with_enabled_buttons(buttons)
|
||||
.with_decorations(settings.decorations)
|
||||
.with_transparent(settings.transparent)
|
||||
.with_blur(settings.blur)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue