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

126 lines
No EOL
5.7 KiB
Swift

import Gtk
extension WidgetView where Target: Gtk.MenuButton {
/// Applies the `.suggested-action` style class.
///
/// Accent colors; denotes the important/affirmative action. Combines with ``circular`` or ``pill``. Keeps its raised appearance inside a toolbar.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func suggestedAction(_ enabled: Bool = true) -> Self {
styleClass("suggested-action", enabled)
}
/// Applies the `.suggested-action` style class.
///
/// Accent colors; denotes the important/affirmative action. Combines with ``circular`` or ``pill``. Keeps its raised appearance inside a toolbar.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func suggestedAction(_ enabled: Binding<Bool>) -> Self {
styleClass("suggested-action", enabled)
}
/// Applies the `.destructive-action` style class.
///
/// Destructive colors, warning the user about damaging consequences. Combines with ``flat``, ``circular`` or ``pill``. Keeps its default appearance inside a toolbar.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func destructiveAction(_ enabled: Bool = true) -> Self {
styleClass("destructive-action", enabled)
}
/// Applies the `.destructive-action` style class.
///
/// Destructive colors, warning the user about damaging consequences. Combines with ``flat``, ``circular`` or ``pill``. Keeps its default appearance inside a toolbar.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func destructiveAction(_ enabled: Binding<Bool>) -> Self {
styleClass("destructive-action", enabled)
}
/// Applies the `.flat` style class.
///
/// Flat appearance, looking like a label or icon until hovered. Menu buttons inside toolbars are flat by default. Combines with ``circular``. Equivalent to `hasFrame(false)` on `Gtk.MenuButton`.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func flat(_ enabled: Bool = true) -> Self {
styleClass("flat", enabled)
}
/// Applies the `.flat` style class.
///
/// Flat appearance, looking like a label or icon until hovered. Menu buttons inside toolbars are flat by default. Combines with ``circular``. Equivalent to `hasFrame(false)` on `Gtk.MenuButton`.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func flat(_ enabled: Binding<Bool>) -> Self {
styleClass("flat", enabled)
}
/// Applies the `.raised` style class.
///
/// Regular appearance instead of the flat one; only useful inside toolbars and similar widgets. Combines with ``circular``.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func raised(_ enabled: Bool = true) -> Self {
styleClass("raised", enabled)
}
/// Applies the `.raised` style class.
///
/// Regular appearance instead of the flat one; only useful inside toolbars and similar widgets. Combines with ``circular``.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func raised(_ enabled: Binding<Bool>) -> Self {
styleClass("raised", enabled)
}
/// Applies the `.circular` style class.
///
/// Round menu button, for icons. Combines with ``suggestedAction``, ``destructiveAction``, ``flat``, ``raised``, ``opaque``, or ``osd``.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func circular(_ enabled: Bool = true) -> Self {
styleClass("circular", enabled)
}
/// Applies the `.circular` style class.
///
/// Round menu button, for icons. Combines with ``suggestedAction``, ``destructiveAction``, ``flat``, ``raised``, ``opaque``, or ``osd``.
///
/// - Parameter enabled: A binding that controls whether the class is applied.
/// - Returns: A copy of this view with the modifier applied.
public func circular(_ enabled: Binding<Bool>) -> Self {
styleClass("circular", enabled)
}
/// Applies the `.opaque` style class.
///
/// Opaque background intended to be paired with custom `background-color`/`color` overrides.
///
/// - Parameter enabled: Whether the style class is applied.
/// - Returns: A copy of this view with the modifier applied.
@available(*, deprecated, message: "Deprecated since libadwaita 1.6. Use suggestedAction() and override the accent color instead.")
public func opaque(_ enabled: Bool = true) -> Self {
styleClass("opaque", enabled)
}
/// Applies the `.opaque` style class.
///
/// Opaque background intended to be paired with custom `background-color`/`color` overrides.
///
/// - 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 since libadwaita 1.6. Use suggestedAction() and override the accent color instead.")
public func opaque(_ enabled: Binding<Bool>) -> Self {
styleClass("opaque", enabled)
}
}