Add modifier for window devel style

This commit is contained in:
david-swift 2024-05-18 12:06:44 +02:00
parent be9cf996a0
commit f53c194045
2 changed files with 15 additions and 0 deletions

View File

@ -43,6 +43,8 @@ public struct Window: WindowScene {
var setDefaultSize = false
/// Whether the window is maximized.
var maximized: Binding<Bool>?
/// Whether the window uses the development style.
var devel = false
/// Create a window type with a certain identifier and user interface.
/// - Parameters:
@ -66,6 +68,9 @@ public struct Window: WindowScene {
windowStorage.destroy = true
}
windowStorage.parentID = parentID
if devel {
gtk_widget_add_css_class(window.pointer?.cast(), "devel")
}
return windowStorage
}
@ -341,6 +346,15 @@ public struct Window: WindowScene {
return newSelf
}
/// Whether the window used the development style.
/// - Parameter active: Whether the style is active.
/// - Returns: The window.
public func devel(_ active: Bool = true) -> Self {
var newSelf = self
newSelf.devel = active
return newSelf
}
}
// swiftlint:enable discouraged_optional_collection

View File

@ -22,6 +22,7 @@ struct Demo: App {
Window(id: "main") { window in
DemoContent(window: window, app: app, pictureURL: pictureURL)
}
.devel()
HelperWindows()
FileDialog(importer: "picture", extensions: ["jpg", "jpeg", "png", "svg"]) { pictureURL = $0 } onClose: { }
}