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
// Adwaita
//
// Created by auto-generation on 09.04.25.
// Created by auto-generation on 15.04.25.
//
import CAdw

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
// ToolbarView.swift
// Adwaita
//
// Created by auto-generation on 09.04.25.
// Created by auto-generation on 15.04.25.
//
import CAdw
@ -90,6 +90,31 @@ public struct ToolbarView: AdwaitaWidget {
///
/// See [property@ToolbarView:top-bar-height].
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.
var content: (() -> Body)?
/// Whether the content widget can extend behind bottom bars.
@ -134,6 +159,31 @@ public struct ToolbarView: AdwaitaWidget {
///
/// See [property@ToolbarView:bottom-bar-height].
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".
var bottom: () -> Body = { [] }
/// 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 {
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 {
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 {
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"] {
for (index, view) in bottom().enumerated() {
@ -246,6 +302,36 @@ public struct ToolbarView: AdwaitaWidget {
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.
public func content(@ViewBuilder _ content: @escaping (() -> Body)) -> Self {
var newSelf = self
@ -320,6 +406,36 @@ public struct ToolbarView: AdwaitaWidget {
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".
/// - Parameter body: The body.
/// - Returns: The widget.

View File

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

View File

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