portico/Sources/Portico/Extensions/Box+Extras.swift

176 lines
No EOL
8.5 KiB
Swift

import Gtk
extension WidgetView where Target: Gtk.Box {
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func linked(_ enabled: Bool = true) -> Self {
styleClass("linked", enabled)
}
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func linked(_ enabled: Binding<Bool>) -> Self {
styleClass("linked", enabled)
}
/// Applies the `.toolbar` style class.
///
/// Horizontal box only; same appearance Adw.HeaderBar and similar widgets use automatically. Adds 6px margins and spacing; pair with ``spacer`` to separate groups. Combine with ``osd`` for a floating toolbar.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func toolbar(_ enabled: Bool = true) -> Self {
styleClass("toolbar", enabled)
}
/// Applies the `.toolbar` style class.
///
/// Horizontal box only; same appearance Adw.HeaderBar and similar widgets use automatically. Adds 6px margins and spacing; pair with ``spacer`` to separate groups. Combine with ``osd`` for a floating toolbar.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func toolbar(_ enabled: Binding<Bool>) -> Self {
styleClass("toolbar", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
public func appNotification(_ enabled: Bool = true) -> Self {
styleClass("app-notification", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
public func appNotification(_ enabled: Binding<Bool>) -> Self {
styleClass("app-notification", enabled)
}
}
public extension HStack {
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func linked(_ enabled: Bool = true) -> AnyView {
styleClass("linked", enabled)
}
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func linked(_ enabled: Binding<Bool>) -> AnyView {
styleClass("linked", enabled)
}
/// Applies the `.toolbar` style class.
///
/// Horizontal box only; same appearance Adw.HeaderBar and similar widgets use automatically. Adds 6px margins and spacing; pair with ``spacer`` to separate groups. Combine with ``osd`` for a floating toolbar.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func toolbar(_ enabled: Bool = true) -> AnyView {
styleClass("toolbar", enabled)
}
/// Applies the `.toolbar` style class.
///
/// Horizontal box only; same appearance Adw.HeaderBar and similar widgets use automatically. Adds 6px margins and spacing; pair with ``spacer`` to separate groups. Combine with ``osd`` for a floating toolbar.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func toolbar(_ enabled: Binding<Bool>) -> AnyView {
styleClass("toolbar", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
func appNotification(_ enabled: Bool = true) -> AnyView {
styleClass("app-notification", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
func appNotification(_ enabled: Binding<Bool>) -> AnyView {
styleClass("app-notification", enabled)
}
}
public extension VStack {
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func linked(_ enabled: Bool = true) -> AnyView {
styleClass("linked", enabled)
}
/// Applies the `.linked` style class.
///
/// Children appear as a single group; the box must have no spacing. Works horizontally and vertically.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
func linked(_ enabled: Binding<Bool>) -> AnyView {
styleClass("linked", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
func appNotification(_ enabled: Bool = true) -> AnyView {
styleClass("app-notification", enabled)
}
/// Applies the `.app-notification` style class.
///
/// Gives the box osd appearance with rounded bottom corners; historically combined with Gtk.Overlay and Gtk.Revealer for in-app notifications.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A type-erased view that carries the class. Further widget-specific modifiers are not available after this call.
@available(*, deprecated, message: "Deprecated by libadwaita. Use Adw.ToastOverlay instead.")
func appNotification(_ enabled: Binding<Bool>) -> AnyView {
styleClass("app-notification", enabled)
}
}