Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Add support for picture's content fit modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Jul 19, 2024
1 parent 9bcf802 commit 46d4fc1
Show file tree
Hide file tree
Showing 47 changed files with 100 additions and 48 deletions.
31 changes: 31 additions & 0 deletions Sources/Adwaita/Model/Enumerations/ContentFit.swift
Original file line number Diff line number Diff line change
@@ -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)
}

}
7 changes: 6 additions & 1 deletion Sources/Adwaita/View/Generated/ActionRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Banner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Bin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Box.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ButtonContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Carousel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/CenterBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/CheckButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Clamp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ComboRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/EntryRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ExpanderRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/FlowBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/Adwaita/View/Generated/HeaderBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Label.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/LevelBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/LinkButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ListBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/NavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/OverlaySplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/PasswordEntryRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion Sources/Adwaita/View/Generated/Picture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/Popover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/PreferencesGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/PreferencesPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/PreferencesRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/ScrolledWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/SearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Adwaita/View/Generated/SearchEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 46d4fc1

Please sign in to comment.