Add support for AdwToolbarStyle
Some checks failed
Deploy Docs / publish (push) Failing after 1s
SwiftLint / SwiftLint (push) Failing after 1s

This commit is contained in:
david-swift 2025-04-15 16:44:20 +02:00
parent 513a5d36a3
commit f209c8387c
49 changed files with 193 additions and 51 deletions

View File

@ -0,0 +1,25 @@
//
// ToolbarStyle.swift
// Adwaita
//
// Created by david-swift on 15.04.25.
//
import CAdw
/// The top and bottom bar styles.
public enum ToolbarStyle: UInt32 {
/// No background, shadow only for scrolled content.
case flat
/// Opaque background with a persistent shadow.
case raised
/// Opaque background with a persistent border.
case raisedBorder
/// The ToolbarStyle value as an AdwToolbarStyle value.
var gtkValue: AdwToolbarStyle {
.init(rawValue)
}
}

View File

@ -2,7 +2,7 @@
// ActionRow.swift // ActionRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// AspectFrame.swift // AspectFrame.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Avatar.swift // Avatar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Banner.swift // Banner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Bin.swift // Bin.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Box.swift // Box.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Button.swift // Button.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ButtonContent.swift // ButtonContent.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Carousel.swift // Carousel.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// CenterBox.swift // CenterBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// CheckButton.swift // CheckButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Clamp.swift // Clamp.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ComboRow.swift // ComboRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// DropDown.swift // DropDown.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// EntryRow.swift // EntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ExpanderRow.swift // ExpanderRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Fixed.swift // Fixed.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// FlowBox.swift // FlowBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// HeaderBar.swift // HeaderBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Label.swift // Label.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// LevelBar.swift // LevelBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// LinkButton.swift // LinkButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ListBox.swift // ListBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Menu.swift // Menu.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// NavigationView.swift // NavigationView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Overlay.swift // Overlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// OverlaySplitView.swift // OverlaySplitView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PasswordEntryRow.swift // PasswordEntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Picture.swift // Picture.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Popover.swift // Popover.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesGroup.swift // PreferencesGroup.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesPage.swift // PreferencesPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesRow.swift // PreferencesRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ProgressBar.swift // ProgressBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ScrolledWindow.swift // ScrolledWindow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SearchBar.swift // SearchBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SearchEntry.swift // SearchEntry.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Separator.swift // Separator.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SpinRow.swift // SpinRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Spinner.swift // Spinner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SplitButton.swift // SplitButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// StatusPage.swift // StatusPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SwitchRow.swift // SwitchRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToastOverlay.swift // ToastOverlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToggleButton.swift // ToggleButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToolbarView.swift // ToolbarView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw
@ -90,6 +90,31 @@ public struct ToolbarView: AdwaitaWidget {
/// ///
/// See [property@ToolbarView:top-bar-height]. /// See [property@ToolbarView:top-bar-height].
var bottomBarHeight: Int? var bottomBarHeight: Int?
/// Appearance of the bottom bars.
///
/// If set to `ADW_TOOLBAR_FLAT`, bottom bars are flat and scrolling content
/// has a subtle undershoot shadow when touching them, same as the
/// [`.undershoot-bottom`](style-classes.html#undershoot-indicators)
/// style class. This works well for simple content, e.g. [class@StatusPage] or
/// [class@PreferencesPage], where the background at the bottom of the page is
/// uniform. Additionally, windows with sidebars should always use this style.
///
/// Undershoot shadow is only present if a bottom bar is actually present and
/// visible. It is also never present if
/// [property@ToolbarView:extend-content-to-bottom-edge] is set to `TRUE`.
///
/// If set to `ADW_TOOLBAR_RAISED`, bottom bars have an opaque background and a
/// persistent shadow, this is suitable for content such as
/// [utility panes](https://developer.gnome.org/hig/patterns/containers/utility-panes.html),
/// where some elements are directly adjacent to the bottom bars, or
/// [class@TabView], where each page can have a different background.
///
/// `ADW_TOOLBAR_RAISED_BORDER` is similar to `ADW_TOOLBAR_RAISED`, but the
/// shadow is replaced with a more subtle border. This can be useful for
/// applications like image viewers.
///
/// See also [property@ToolbarView:top-bar-style].
var bottomBarStyle: ToolbarStyle?
/// The content widget. /// The content widget.
var content: (() -> Body)? var content: (() -> Body)?
/// Whether the content widget can extend behind bottom bars. /// Whether the content widget can extend behind bottom bars.
@ -134,6 +159,31 @@ public struct ToolbarView: AdwaitaWidget {
/// ///
/// See [property@ToolbarView:bottom-bar-height]. /// See [property@ToolbarView:bottom-bar-height].
var topBarHeight: Int? var topBarHeight: Int?
/// Appearance of the top bars.
///
/// If set to `ADW_TOOLBAR_FLAT`, top bars are flat and scrolling content has a
/// subtle undershoot shadow when touching them, same as the
/// [`.undershoot-top`](style-classes.html#undershoot-indicators)
/// style class. This works well for simple content, e.g. [class@StatusPage] or
/// [class@PreferencesPage], where the background at the top of the page is
/// uniform. Additionally, windows with sidebars should always use this style.
///
/// Undershoot shadow is only present if a top bar is actually present and
/// visible. It is also never present if
/// [property@ToolbarView:extend-content-to-top-edge] is set to `TRUE`.
///
/// If set to `ADW_TOOLBAR_RAISED`, top bars have an opaque background and a
/// persistent shadow, this is suitable for content such as
/// [utility panes](https://developer.gnome.org/hig/patterns/containers/utility-panes.html),
/// where some elements are directly adjacent to the top bars, or
/// [class@TabView], where each page can have a different background.
///
/// `ADW_TOOLBAR_RAISED_BORDER` is similar to `ADW_TOOLBAR_RAISED`, but the
/// shadow is replaced with a more subtle border. This can be useful for
/// applications like image viewers.
///
/// See also [property@ToolbarView:bottom-bar-style].
var topBarStyle: ToolbarStyle?
/// The body for the widget "bottom". /// The body for the widget "bottom".
var bottom: () -> Body = { [] } var bottom: () -> Body = { [] }
/// The body for the widget "top". /// The body for the widget "top".
@ -183,6 +233,9 @@ public struct ToolbarView: AdwaitaWidget {
public func update<Data>(_ storage: ViewStorage, data: WidgetData, updateProperties: Bool, type: Data.Type) where Data: ViewRenderData { public func update<Data>(_ storage: ViewStorage, data: WidgetData, updateProperties: Bool, type: Data.Type) where Data: ViewRenderData {
storage.modify { widget in storage.modify { widget in
if let bottomBarStyle, updateProperties, (storage.previousState as? Self)?.bottomBarStyle != bottomBarStyle {
adw_toolbar_view_set_bottom_bar_style(widget, bottomBarStyle.gtkValue)
}
if let widget = storage.content["content"]?.first { if let widget = storage.content["content"]?.first {
content?().updateStorage(widget, data: data, updateProperties: updateProperties, type: type) content?().updateStorage(widget, data: data, updateProperties: updateProperties, type: type)
} }
@ -198,6 +251,9 @@ public struct ToolbarView: AdwaitaWidget {
if let revealTopBars, updateProperties, (storage.previousState as? Self)?.revealTopBars != revealTopBars { if let revealTopBars, updateProperties, (storage.previousState as? Self)?.revealTopBars != revealTopBars {
adw_toolbar_view_set_reveal_top_bars(widget, revealTopBars.cBool) adw_toolbar_view_set_reveal_top_bars(widget, revealTopBars.cBool)
} }
if let topBarStyle, updateProperties, (storage.previousState as? Self)?.topBarStyle != topBarStyle {
adw_toolbar_view_set_top_bar_style(widget, topBarStyle.gtkValue)
}
if let bottomStorage = storage.content["bottom"] { if let bottomStorage = storage.content["bottom"] {
for (index, view) in bottom().enumerated() { for (index, view) in bottom().enumerated() {
@ -246,6 +302,36 @@ public struct ToolbarView: AdwaitaWidget {
return newSelf return newSelf
} }
/// Appearance of the bottom bars.
///
/// If set to `ADW_TOOLBAR_FLAT`, bottom bars are flat and scrolling content
/// has a subtle undershoot shadow when touching them, same as the
/// [`.undershoot-bottom`](style-classes.html#undershoot-indicators)
/// style class. This works well for simple content, e.g. [class@StatusPage] or
/// [class@PreferencesPage], where the background at the bottom of the page is
/// uniform. Additionally, windows with sidebars should always use this style.
///
/// Undershoot shadow is only present if a bottom bar is actually present and
/// visible. It is also never present if
/// [property@ToolbarView:extend-content-to-bottom-edge] is set to `TRUE`.
///
/// If set to `ADW_TOOLBAR_RAISED`, bottom bars have an opaque background and a
/// persistent shadow, this is suitable for content such as
/// [utility panes](https://developer.gnome.org/hig/patterns/containers/utility-panes.html),
/// where some elements are directly adjacent to the bottom bars, or
/// [class@TabView], where each page can have a different background.
///
/// `ADW_TOOLBAR_RAISED_BORDER` is similar to `ADW_TOOLBAR_RAISED`, but the
/// shadow is replaced with a more subtle border. This can be useful for
/// applications like image viewers.
///
/// See also [property@ToolbarView:top-bar-style].
public func bottomBarStyle(_ bottomBarStyle: ToolbarStyle?) -> Self {
var newSelf = self
newSelf.bottomBarStyle = bottomBarStyle
return newSelf
}
/// The content widget. /// The content widget.
public func content(@ViewBuilder _ content: @escaping (() -> Body)) -> Self { public func content(@ViewBuilder _ content: @escaping (() -> Body)) -> Self {
var newSelf = self var newSelf = self
@ -320,6 +406,36 @@ public struct ToolbarView: AdwaitaWidget {
return newSelf return newSelf
} }
/// Appearance of the top bars.
///
/// If set to `ADW_TOOLBAR_FLAT`, top bars are flat and scrolling content has a
/// subtle undershoot shadow when touching them, same as the
/// [`.undershoot-top`](style-classes.html#undershoot-indicators)
/// style class. This works well for simple content, e.g. [class@StatusPage] or
/// [class@PreferencesPage], where the background at the top of the page is
/// uniform. Additionally, windows with sidebars should always use this style.
///
/// Undershoot shadow is only present if a top bar is actually present and
/// visible. It is also never present if
/// [property@ToolbarView:extend-content-to-top-edge] is set to `TRUE`.
///
/// If set to `ADW_TOOLBAR_RAISED`, top bars have an opaque background and a
/// persistent shadow, this is suitable for content such as
/// [utility panes](https://developer.gnome.org/hig/patterns/containers/utility-panes.html),
/// where some elements are directly adjacent to the top bars, or
/// [class@TabView], where each page can have a different background.
///
/// `ADW_TOOLBAR_RAISED_BORDER` is similar to `ADW_TOOLBAR_RAISED`, but the
/// shadow is replaced with a more subtle border. This can be useful for
/// applications like image viewers.
///
/// See also [property@ToolbarView:bottom-bar-style].
public func topBarStyle(_ topBarStyle: ToolbarStyle?) -> Self {
var newSelf = self
newSelf.topBarStyle = topBarStyle
return newSelf
}
/// Set the body for "bottom". /// Set the body for "bottom".
/// - Parameter body: The body. /// - Parameter body: The body.
/// - Returns: The widget. /// - Returns: The widget.

View File

@ -2,7 +2,7 @@
// WindowTitle.swift // WindowTitle.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 09.04.25. // Created by auto-generation on 15.04.25.
// //
import CAdw import CAdw

View File

@ -150,8 +150,7 @@ struct GenerationConfiguration {
staticWidgets: [ staticWidgets: [
.init(name: "bottom", add: "adw_toolbar_view_add_bottom_bar"), .init(name: "bottom", add: "adw_toolbar_view_add_bottom_bar"),
.init(name: "top", add: "adw_toolbar_view_add_top_bar") .init(name: "top", add: "adw_toolbar_view_add_top_bar")
], ]
excludeProperties: ["top-bar-style", "bottom-bar-style"]
), ),
.init(class: "ToastOverlay"), .init(class: "ToastOverlay"),
.init( .init(
@ -331,7 +330,8 @@ struct GenerationConfiguration {
"GdkPaintable*": "OpaquePointer", "GdkPaintable*": "OpaquePointer",
"NavigationPage": "NavigationPage", "NavigationPage": "NavigationPage",
"ContentFit": "ContentFit", "ContentFit": "ContentFit",
"PolicyType": "ScrollbarVisibility" "PolicyType": "ScrollbarVisibility",
"ToolbarStyle": "ToolbarStyle"
] ]
/// Modifications for converting a Swift into a C type. /// Modifications for converting a Swift into a C type.
@ -340,7 +340,8 @@ struct GenerationConfiguration {
"Int": "cInt", "Int": "cInt",
"UInt": "cInt", "UInt": "cInt",
"ContentFit": "gtkValue", "ContentFit": "gtkValue",
"ScrollbarVisibility": "gtkValue" "ScrollbarVisibility": "gtkValue",
"ToolbarStyle": "gtkValue"
] ]
/// Default values for modifiers with a certain type. /// Default values for modifiers with a certain type.