Add support for picture's content fit modifier
This commit is contained in:
parent
9bcf802b54
commit
46d4fc1173
31
Sources/Adwaita/Model/Enumerations/ContentFit.swift
Normal file
31
Sources/Adwaita/Model/Enumerations/ContentFit.swift
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// ContentFit.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by david-swift on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
||||
/// Control how a content should be made to fit inside an allocation.
|
||||
public enum ContentFit: UInt32 {
|
||||
|
||||
/// Make the content fill the entire allocation,
|
||||
/// without taking its aspect ratio in consideration.
|
||||
case fill
|
||||
/// Scale the content to fit the allocation,
|
||||
/// while taking its aspect ratio in consideration.
|
||||
case contain
|
||||
/// Cover the entire allocation,
|
||||
/// while taking the content aspect ratio in consideration.
|
||||
case cover
|
||||
/// The content is scaled down to fit the allocation, if needed,
|
||||
/// otherwise its original size is used.
|
||||
case scaleDown
|
||||
|
||||
/// The ContentFit value as a GtkContentFit value.
|
||||
var gtkValue: GtkContentFit {
|
||||
.init(rawValue)
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// ActionRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
@ -39,6 +39,11 @@ import LevenshteinTransformations
|
||||
///
|
||||
/// It contains subnodes `label.title` and `label.subtitle` representing
|
||||
/// respectively the title label and subtitle label.
|
||||
///
|
||||
/// `AdwActionRow` can use the
|
||||
/// [`.property`](style-classes.html#property-rows) style class to emphasize
|
||||
/// the row subtitle instead of the row title, which is useful for
|
||||
/// displaying read-only properties.
|
||||
public struct ActionRow: Widget {
|
||||
|
||||
/// Additional update functions for type extensions.
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Avatar.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Banner.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Bin.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Box.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Button.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ButtonContent.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Carousel.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// CenterBox.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// CheckButton.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Clamp.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ComboRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// EntryRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ExpanderRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// FlowBox.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// HeaderBar.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
@ -40,7 +40,7 @@ import LevenshteinTransformations
|
||||
///
|
||||
/// ## Split View Integration
|
||||
///
|
||||
/// When placed inside `AdwNavigationSplitView` or `AdwOverlaySplitView`,
|
||||
/// When placed inside [class@NavigationSplitView] or [class@OverlaySplitView],
|
||||
/// `AdwHeaderBar` will automatically hide the title buttons other than at the
|
||||
/// edges of the window.
|
||||
///
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Label.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// LevelBar.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// LinkButton.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ListBox.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Menu.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// NavigationView.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Overlay.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// OverlaySplitView.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// PasswordEntryRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Picture.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
@ -69,6 +69,8 @@ public struct Picture: Widget {
|
||||
var alternativeText: String?
|
||||
/// If the `GtkPicture` can be made smaller than the natural size of its contents.
|
||||
var canShrink: Bool?
|
||||
/// How the content should be resized to fit inside the `GtkPicture`.
|
||||
var contentFit: ContentFit?
|
||||
/// Whether the GtkPicture will render its contents trying to preserve the aspect
|
||||
/// ratio.
|
||||
var keepAspectRatio: Bool?
|
||||
@ -108,6 +110,9 @@ public struct Picture: Widget {
|
||||
if let canShrink, updateProperties {
|
||||
gtk_picture_set_can_shrink(widget, canShrink.cBool)
|
||||
}
|
||||
if let contentFit, updateProperties {
|
||||
gtk_picture_set_content_fit(widget, contentFit.gtkValue)
|
||||
}
|
||||
if let keepAspectRatio, updateProperties {
|
||||
gtk_picture_set_keep_aspect_ratio(widget, keepAspectRatio.cBool)
|
||||
}
|
||||
@ -145,6 +150,14 @@ public struct Picture: Widget {
|
||||
return newSelf
|
||||
}
|
||||
|
||||
/// How the content should be resized to fit inside the `GtkPicture`.
|
||||
public func contentFit(_ contentFit: ContentFit?) -> Self {
|
||||
var newSelf = self
|
||||
newSelf.contentFit = contentFit
|
||||
|
||||
return newSelf
|
||||
}
|
||||
|
||||
/// Whether the GtkPicture will render its contents trying to preserve the aspect
|
||||
/// ratio.
|
||||
public func keepAspectRatio(_ keepAspectRatio: Bool? = true) -> Self {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Popover.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// PreferencesGroup.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// PreferencesPage.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// PreferencesRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ProgressBar.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ScrolledWindow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SearchBar.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SearchEntry.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SpinRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Spinner.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SplitButton.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// StatusPage.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SwitchRow.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ToastOverlay.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ToggleButton.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// ToolbarView.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -2,7 +2,7 @@
|
||||
// WindowTitle.swift
|
||||
// Adwaita
|
||||
//
|
||||
// Created by auto-generation on 22.05.24.
|
||||
// Created by auto-generation on 19.07.24.
|
||||
//
|
||||
|
||||
import CAdw
|
||||
|
@ -24,6 +24,8 @@ struct GIRType: Decodable {
|
||||
func generate(configuration: GenerationConfiguration) throws -> String {
|
||||
if let cType {
|
||||
return cType.convertCType(configuration: configuration)
|
||||
} else if let name, let type = configuration.cTypeReplacements[name] {
|
||||
return type
|
||||
}
|
||||
return "String"
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ struct GenerationConfiguration {
|
||||
excludeProperties: ["input-hints", "input-purpose"]
|
||||
),
|
||||
.init(class: "SearchBar"),
|
||||
.init(class: "Picture", excludeProperties: ["content-fit", "file", "paintable"])
|
||||
.init(class: "Picture", excludeProperties: ["file", "paintable"])
|
||||
]
|
||||
|
||||
/// The unshortening map.
|
||||
@ -284,14 +284,16 @@ struct GenerationConfiguration {
|
||||
"GIcon*": "OpaquePointer",
|
||||
"GdkPixbuf*": "OpaquePointer",
|
||||
"GdkPaintable*": "OpaquePointer",
|
||||
"NavigationPage": "NavigationPage"
|
||||
"NavigationPage": "NavigationPage",
|
||||
"ContentFit": "ContentFit"
|
||||
]
|
||||
|
||||
/// Modifications for converting a Swift into a C type.
|
||||
var cTypeProperties = [
|
||||
"Bool": "cBool",
|
||||
"Int": "cInt",
|
||||
"UInt": "cInt"
|
||||
"UInt": "cInt",
|
||||
"ContentFit": "gtkValue"
|
||||
]
|
||||
|
||||
/// Default values for modifiers with a certain type.
|
||||
|
@ -8,7 +8,6 @@
|
||||
// swiftlint:disable missing_docs
|
||||
|
||||
import Adwaita
|
||||
import CAdw
|
||||
import Foundation
|
||||
|
||||
struct PictureDemo: View {
|
||||
|
Loading…
Reference in New Issue
Block a user