portico/Sources/Portico/Extensions/View+StyleClasses.swift

511 lines
25 KiB
Swift

import Gtk
extension View {
/// Applies the `.dimmed` style class.
///
/// Partially transparent. The opacity is tracked by the `--dim-opacity` CSS variable and differs under high contrast. Since libadwaita 1.7.
///
/// - 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.
public func dimmed(_ enabled: Bool = true) -> AnyView {
styleClass("dimmed", enabled)
}
/// Applies the `.dimmed` style class.
///
/// Partially transparent. The opacity is tracked by the `--dim-opacity` CSS variable and differs under high contrast. Since libadwaita 1.7.
///
/// - 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.
public func dimmed(_ enabled: Binding<Bool>) -> AnyView {
styleClass("dimmed", enabled)
}
/// Applies the `.title-1` style class.
///
/// Largest of four title levels indicating hierarchy; suits big views with plenty of whitespace.
///
/// - 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.
public func title1(_ enabled: Bool = true) -> AnyView {
styleClass("title-1", enabled)
}
/// Applies the `.title-1` style class.
///
/// Largest of four title levels indicating hierarchy; suits big views with plenty of whitespace.
///
/// - 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.
public func title1(_ enabled: Binding<Bool>) -> AnyView {
styleClass("title-1", enabled)
}
/// Applies the `.title-2` style class.
///
/// Second of four title levels indicating hierarchy.
///
/// - 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.
public func title2(_ enabled: Bool = true) -> AnyView {
styleClass("title-2", enabled)
}
/// Applies the `.title-2` style class.
///
/// Second of four title levels indicating hierarchy.
///
/// - 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.
public func title2(_ enabled: Binding<Bool>) -> AnyView {
styleClass("title-2", enabled)
}
/// Applies the `.title-3` style class.
///
/// Third of four title levels indicating hierarchy.
///
/// - 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.
public func title3(_ enabled: Bool = true) -> AnyView {
styleClass("title-3", enabled)
}
/// Applies the `.title-3` style class.
///
/// Third of four title levels indicating hierarchy.
///
/// - 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.
public func title3(_ enabled: Binding<Bool>) -> AnyView {
styleClass("title-3", enabled)
}
/// Applies the `.title-4` style class.
///
/// Fourth and smallest of four title levels indicating hierarchy.
///
/// - 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.
public func title4(_ enabled: Bool = true) -> AnyView {
styleClass("title-4", enabled)
}
/// Applies the `.title-4` style class.
///
/// Fourth and smallest of four title levels indicating hierarchy.
///
/// - 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.
public func title4(_ enabled: Binding<Bool>) -> AnyView {
styleClass("title-4", enabled)
}
/// Applies the `.heading` style class.
///
/// Standard UI heading at the default text size, e.g. for window titles or boxed-list labels.
///
/// - 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.
public func heading(_ enabled: Bool = true) -> AnyView {
styleClass("heading", enabled)
}
/// Applies the `.heading` style class.
///
/// Standard UI heading at the default text size, e.g. for window titles or boxed-list labels.
///
/// - 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.
public func heading(_ enabled: Binding<Bool>) -> AnyView {
styleClass("heading", enabled)
}
/// Applies the `.document` style class.
///
/// Document font: larger size and line height for the app's main content. Since libadwaita 1.8. Use ``body`` for other long text.
///
/// - 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.
public func document(_ enabled: Bool = true) -> AnyView {
styleClass("document", enabled)
}
/// Applies the `.document` style class.
///
/// Document font: larger size and line height for the app's main content. Since libadwaita 1.8. Use ``body`` for other long text.
///
/// - 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.
public func document(_ enabled: Binding<Bool>) -> AnyView {
styleClass("document", enabled)
}
/// Applies the `.body` style class.
///
/// Increased line height for UI text such as descriptions or dialog bodies. Avoid for non-wrapping text; use ``document`` for main content.
///
/// - 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.
public func body(_ enabled: Bool = true) -> AnyView {
styleClass("body", enabled)
}
/// Applies the `.body` style class.
///
/// Increased line height for UI text such as descriptions or dialog bodies. Avoid for non-wrapping text; use ``document`` for main content.
///
/// - 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.
public func body(_ enabled: Binding<Bool>) -> AnyView {
styleClass("body", enabled)
}
/// Applies the `.caption-heading` style class.
///
/// Smaller text that differentiates sub-text accompanying body text.
///
/// - 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.
public func captionHeading(_ enabled: Bool = true) -> AnyView {
styleClass("caption-heading", enabled)
}
/// Applies the `.caption-heading` style class.
///
/// Smaller text that differentiates sub-text accompanying body text.
///
/// - 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.
public func captionHeading(_ enabled: Binding<Bool>) -> AnyView {
styleClass("caption-heading", enabled)
}
/// Applies the `.caption` style class.
///
/// Smaller text for captions and supplementary labels.
///
/// - 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.
public func caption(_ enabled: Bool = true) -> AnyView {
styleClass("caption", enabled)
}
/// Applies the `.caption` style class.
///
/// Smaller text for captions and supplementary labels.
///
/// - 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.
public func caption(_ enabled: Binding<Bool>) -> AnyView {
styleClass("caption", enabled)
}
/// Applies the `.monospace` style class.
///
/// Monospace font, for code, logs, or shell output. On `Adw.EntryRow` only the editable part becomes monospace - apply it to the surrounding `Gtk.ListBox` to cover the whole row. Named `monospaceStyle` because `Gtk.TextView` already has a `monospace(_:)` property modifier.
///
/// - 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.
public func monospaceStyle(_ enabled: Bool = true) -> AnyView {
styleClass("monospace", enabled)
}
/// Applies the `.monospace` style class.
///
/// Monospace font, for code, logs, or shell output. On `Adw.EntryRow` only the editable part becomes monospace - apply it to the surrounding `Gtk.ListBox` to cover the whole row. Named `monospaceStyle` because `Gtk.TextView` already has a `monospace(_:)` property modifier.
///
/// - 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.
public func monospaceStyle(_ enabled: Binding<Bool>) -> AnyView {
styleClass("monospace", enabled)
}
/// Applies the `.numeric` style class.
///
/// Tabular figures, equivalent to Pango "tnum=1"; use for vertically aligned numbers, clocks, and progress. Named `numericStyle` because `Gtk.SpinButton` / `Adw.SpinRow` already has a `numeric(_:)` property modifier.
///
/// - 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.
public func numericStyle(_ enabled: Bool = true) -> AnyView {
styleClass("numeric", enabled)
}
/// Applies the `.numeric` style class.
///
/// Tabular figures, equivalent to Pango "tnum=1"; use for vertically aligned numbers, clocks, and progress. Named `numericStyle` because `Gtk.SpinButton` / `Adw.SpinRow` already has a `numeric(_:)` property modifier.
///
/// - 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.
public func numericStyle(_ enabled: Binding<Bool>) -> AnyView {
styleClass("numeric", enabled)
}
/// Applies the `.accent` style class.
///
/// Recolors the widget with the accent color.
///
/// - 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.
public func accent(_ enabled: Bool = true) -> AnyView {
styleClass("accent", enabled)
}
/// Applies the `.accent` style class.
///
/// Recolors the widget with the accent color.
///
/// - 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.
public func accent(_ enabled: Binding<Bool>) -> AnyView {
styleClass("accent", enabled)
}
/// Applies the `.success` style class.
///
/// Success color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func success(_ enabled: Bool = true) -> AnyView {
styleClass("success", enabled)
}
/// Applies the `.success` style class.
///
/// Success color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func success(_ enabled: Binding<Bool>) -> AnyView {
styleClass("success", enabled)
}
/// Applies the `.warning` style class.
///
/// Warning color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func warning(_ enabled: Bool = true) -> AnyView {
styleClass("warning", enabled)
}
/// Applies the `.warning` style class.
///
/// Warning color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func warning(_ enabled: Binding<Bool>) -> AnyView {
styleClass("warning", enabled)
}
/// Applies the `.error` style class.
///
/// Error color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func error(_ enabled: Bool = true) -> AnyView {
styleClass("error", enabled)
}
/// Applies the `.error` style class.
///
/// Error color. Also usable on `Gtk.Entry` to signal input validation state, where it additionally changes the accent color.
///
/// - 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.
public func error(_ enabled: Binding<Bool>) -> AnyView {
styleClass("error", enabled)
}
/// Applies the `.card` style class.
///
/// Gives any widget a boxed-list-like card appearance. Combined with ``activatableStyle`` it gains hover and active states; a `Gtk.Button` gets those states automatically without ``activatableStyle``.
///
/// - 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.
public func card(_ enabled: Bool = true) -> AnyView {
styleClass("card", enabled)
}
/// Applies the `.card` style class.
///
/// Gives any widget a boxed-list-like card appearance. Combined with ``activatableStyle`` it gains hover and active states; a `Gtk.Button` gets those states automatically without ``activatableStyle``.
///
/// - 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.
public func card(_ enabled: Binding<Bool>) -> AnyView {
styleClass("card", enabled)
}
/// Applies the `.activatable` style class.
///
/// Only meaningful together with ``card``; adds hover and active states to the card. Named `activatableStyle` because `Gtk.ListBoxRow` already has an `activatable(_:)` property modifier.
///
/// - 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.
public func activatableStyle(_ enabled: Bool = true) -> AnyView {
styleClass("activatable", enabled)
}
/// Applies the `.activatable` style class.
///
/// Only meaningful together with ``card``; adds hover and active states to the card. Named `activatableStyle` because `Gtk.ListBoxRow` already has an `activatable(_:)` property modifier.
///
/// - 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.
public func activatableStyle(_ enabled: Binding<Bool>) -> AnyView {
styleClass("activatable", enabled)
}
/// Applies the `.osd` style class.
///
/// Dark, partially transparent background with a white accent. On `Gtk.Button` it produces large standalone overlay buttons (combinable with ``circular`` / ``pill``). Combine with ``toolbar`` on a `Gtk.Box` for a floating toolbar. On `Gtk.ProgressBar` it makes the bar thinner and removes the trough.
///
/// - 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.
public func osd(_ enabled: Bool = true) -> AnyView {
styleClass("osd", enabled)
}
/// Applies the `.osd` style class.
///
/// Dark, partially transparent background with a white accent. On `Gtk.Button` it produces large standalone overlay buttons (combinable with ``circular`` / ``pill``). Combine with ``toolbar`` on a `Gtk.Box` for a floating toolbar. On `Gtk.ProgressBar` it makes the bar thinner and removes the trough.
///
/// - 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.
public func osd(_ enabled: Binding<Bool>) -> AnyView {
styleClass("osd", enabled)
}
/// Applies the `.background` style class.
///
/// Default window background and foreground colors; useful when a widget needs an opaque background.
///
/// - 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.
public func background(_ enabled: Bool = true) -> AnyView {
styleClass("background", enabled)
}
/// Applies the `.background` style class.
///
/// Default window background and foreground colors; useful when a widget needs an opaque background.
///
/// - 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.
public func background(_ enabled: Binding<Bool>) -> AnyView {
styleClass("background", enabled)
}
/// Applies the `.view` style class.
///
/// Default view background and foreground colors.
///
/// - 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.
public func view(_ enabled: Bool = true) -> AnyView {
styleClass("view", enabled)
}
/// Applies the `.view` style class.
///
/// Default view background and foreground colors.
///
/// - 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.
public func view(_ enabled: Binding<Bool>) -> AnyView {
styleClass("view", enabled)
}
/// Applies the `.frame` style class.
///
/// Default 1px border.
///
/// - 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.
public func frame(_ enabled: Bool = true) -> AnyView {
styleClass("frame", enabled)
}
/// Applies the `.frame` style class.
///
/// Default 1px border.
///
/// - 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.
public func frame(_ enabled: Binding<Bool>) -> AnyView {
styleClass("frame", enabled)
}
/// Applies the `.sidebar` style class.
///
/// Border at the end of the widget plus background removal from a contained list.
///
/// - 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 navigationSidebar() on the list widget plus a Separator for the border.")
public func sidebar(_ enabled: Bool = true) -> AnyView {
styleClass("sidebar", enabled)
}
/// Applies the `.sidebar` style class.
///
/// Border at the end of the widget plus background removal from a contained list.
///
/// - 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 navigationSidebar() on the list widget plus a Separator for the border.")
public func sidebar(_ enabled: Binding<Bool>) -> AnyView {
styleClass("sidebar", enabled)
}
/// Applies the `.large-title` style class.
///
/// Large thin display heading.
///
/// - 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 since libadwaita 1.2. Use title1() instead.")
public func largeTitle(_ enabled: Bool = true) -> AnyView {
styleClass("large-title", enabled)
}
/// Applies the `.large-title` style class.
///
/// Large thin display heading.
///
/// - 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 since libadwaita 1.2. Use title1() instead.")
public func largeTitle(_ enabled: Binding<Bool>) -> AnyView {
styleClass("large-title", enabled)
}
/// Applies the `.dim-label` style class.
///
/// Equivalent to ``dimmed``.
///
/// - 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 since libadwaita 1.7. Use dimmed() instead.")
public func dimLabel(_ enabled: Bool = true) -> AnyView {
styleClass("dim-label", enabled)
}
/// Applies the `.dim-label` style class.
///
/// Equivalent to ``dimmed``.
///
/// - 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 since libadwaita 1.7. Use dimmed() instead.")
public func dimLabel(_ enabled: Binding<Bool>) -> AnyView {
styleClass("dim-label", enabled)
}
}