Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.
Swift
Size in the menu bar: small, medium or large photos
Alejandro Buján3192e1ee4dbb
diff --git a/Sources/Tendedero/AppDelegate.swift b/Sources/Tendedero/AppDelegate.swiftindex ffd72d1..6fa09bd 100644--- a/Sources/Tendedero/AppDelegate.swift+++ b/Sources/Tendedero/AppDelegate.swift@@ -488,6 +488,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {}}+ private func setSize(_ size: Layout.Size) {+ guard size != Layout.size else { return }+ Layout.size = size+ panel.placeOnScreen(panel.screen)+ updateCapacity()+ line.reloadThumbnails()+ }+private func updateCapacity() {let usable = panel.frame.width - 200line.maxItems = max(3, min(12, Int(usable / Layout.spacing)))@@ -565,6 +573,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {bringDown.submenu = optionsmenu.addItem(bringDown)+ let sizeItem = NSMenuItem(title: L("Size"), action: nil, keyEquivalent: "")+ let sizes = NSMenu()+ for (size, title) in [(Layout.Size.small, L("Small")), (.medium, L("Medium")), (.large, L("Large"))] {+ let item = ClosureMenuItem(title) { [weak self] in self?.setSize(size) }+ item.state = Layout.size == size ? .on : .off+ sizes.addItem(item)+ }+ sizeItem.submenu = sizes+ menu.addItem(sizeItem)+menu.addItem(ClosureMenuItem(L("Open screenshots folder")) { [weak self] inguard let self else { return }NSWorkspace.shared.open(self.watcher.folder)diff --git a/Sources/Tendedero/Line.swift b/Sources/Tendedero/Line.swiftindex ea532f9..2cdd301 100644--- a/Sources/Tendedero/Line.swift+++ b/Sources/Tendedero/Line.swift@@ -226,6 +226,13 @@ final class Line: ObservableObject {items[i].thumb = thumb}+ /// After a change of size, every photo is redrawn sharp at the new one.+ func reloadThumbnails() {+ for i in items.indices where !items[i].falling {+ if let thumb = makeThumbnail(items[i].url) { items[i].thumb = thumb }+ }+ }+func reveal(_ id: UUID) {guard let item = items.first(where: { $0.id == id }) else { return }NSWorkspace.shared.activateFileViewerSelecting([item.url])@@ -285,7 +292,7 @@ func isRecording(_ url: URL) -> Bool {/// The default size covers a card at twice its size in points, as on a/// Retina screen, and no more: every photo on the line keeps one in memory.-func makeThumbnail(_ url: URL, maxPixels: Int = 320) -> NSImage? {+func makeThumbnail(_ url: URL, maxPixels: Int = Int(320 * Layout.size.scale)) -> NSImage? {if isRecording(url) { return firstFrame(url, maxPixels: maxPixels) }guard let source = CGImageSourceCreateWithURL(url as CFURL, nil) else { return nil }let options: [CFString: Any] = [diff --git a/Sources/Tendedero/LineView.swift b/Sources/Tendedero/LineView.swiftindex 9de27f1..9132361 100644--- a/Sources/Tendedero/LineView.swift+++ b/Sources/Tendedero/LineView.swift@@ -1,10 +1,31 @@import SwiftUIenum Layout {- static let panelHeight: CGFloat = 210+ /// How big the photos hang, from Size in the menu bar. The clip, the rope+ /// and the glass frame keep their size; the photos and the room they take+ /// grow or shrink. Medium is the original size.+ enum Size: String, CaseIterable {+ case small, medium, large++ var scale: CGFloat {+ switch self {+ case .small: 0.8+ case .medium: 1+ case .large: 1.35+ }+ }+ }++ static var size: Size {+ get { Size(rawValue: UserDefaults.standard.string(forKey: "lineSize") ?? "") ?? .medium }+ set { UserDefaults.standard.set(newValue.rawValue, forKey: "lineSize") }+ }++ static var photoMaxHeight: CGFloat { (104 * size.scale).rounded() }+ static var cardWidth: CGFloat { (150 * size.scale).rounded() }+ static var spacing: CGFloat { cardWidth + 24 }+ static var panelHeight: CGFloat { photoMaxHeight + 106 }static let ropeTop: CGFloat = 10- static let spacing: CGFloat = 174- static let cardWidth: CGFloat = 150static let pinAbove: CGFloat = 9.5/// The rope hangs as a parabola from edge to edge of the screen.diff --git a/Sources/Tendedero/PeggedView.swift b/Sources/Tendedero/PeggedView.swiftindex 548716f..d0df646 100644--- a/Sources/Tendedero/PeggedView.swift+++ b/Sources/Tendedero/PeggedView.swift@@ -36,7 +36,7 @@ struct PeggedView: View {/// The photo fits inside the card area keeping its proportions, so the/// white border hugs it whether the screenshot is wide or tall.static func photoSize(for size: CGSize) -> CGSize {- let maxW = Layout.cardWidth - 14, maxH: CGFloat = 104+ let maxW = Layout.cardWidth - 14, maxH = Layout.photoMaxHeightguard size.width > 0, size.height > 0 else { return CGSize(width: maxW, height: maxH) }let scale = min(maxW / size.width, maxH / size.height)return CGSize(width: size.width * scale, height: size.height * scale)diff --git a/Sources/Tendedero/Resources/az.lproj/Localizable.strings b/Sources/Tendedero/Resources/az.lproj/Localizable.stringsindex 61c6a4c..346acfb 100644--- a/Sources/Tendedero/Resources/az.lproj/Localizable.strings+++ b/Sources/Tendedero/Resources/az.lproj/Localizable.strings@@ -18,6 +18,10 @@"Quit Tendedero" = "Tendedero-dan çıx";"Could not change the login setting" = "Giriş ayarını dəyişmək alınmadı";"Move Tendedero to the Applications folder and try again." = "Tendedero-nu Applications (Proqramlar) qovluğuna köçürün və yenidən cəhd edin.";+"Size" = "Ölçü";+"Small" = "Kiçik";+"Medium" = "Orta";+"Large" = "Böyük";"Bring the line down" = "İpi endir";"When the pointer rests in the menu bar" = "Göstərici menyu panelində dayananda";"When something new hangs" = "Yeni bir şey asılanda";diff --git a/Sources/Tendedero/Resources/en.lproj/Localizable.strings b/Sources/Tendedero/Resources/en.lproj/Localizable.stringsindex 05fe13b..c0df23f 100644--- a/Sources/Tendedero/Resources/en.lproj/Localizable.strings+++ b/Sources/Tendedero/Resources/en.lproj/Localizable.strings@@ -18,6 +18,10 @@"Quit Tendedero" = "Quit Tendedero";"Could not change the login setting" = "Could not change the login setting";"Move Tendedero to the Applications folder and try again." = "Move Tendedero to the Applications folder and try again.";+"Size" = "Size";+"Small" = "Small";+"Medium" = "Medium";+"Large" = "Large";"Bring the line down" = "Bring the line down";"When the pointer rests in the menu bar" = "When the pointer rests in the menu bar";"When something new hangs" = "When something new hangs";diff --git a/Sources/Tendedero/Resources/es.lproj/Localizable.strings b/Sources/Tendedero/Resources/es.lproj/Localizable.stringsindex 5933053..57b4709 100644--- a/Sources/Tendedero/Resources/es.lproj/Localizable.strings+++ b/Sources/Tendedero/Resources/es.lproj/Localizable.strings@@ -16,6 +16,10 @@"Quit Tendedero" = "Salir de Tendedero";"Could not change the login setting" = "No se pudo cambiar el inicio de sesión";"Move Tendedero to the Applications folder and try again." = "Mueve Tendedero a la carpeta Aplicaciones y vuelve a intentarlo.";+"Size" = "Tamaño";+"Small" = "Pequeño";+"Medium" = "Mediano";+"Large" = "Grande";"Bring the line down" = "Bajar la cuerda";"When the pointer rests in the menu bar" = "Al dejar el puntero en la barra de menús";"When something new hangs" = "Cuando se cuelga algo nuevo";diff --git a/Sources/Tendedero/Resources/tr.lproj/Localizable.strings b/Sources/Tendedero/Resources/tr.lproj/Localizable.stringsindex e89c7a6..88d9f89 100644--- a/Sources/Tendedero/Resources/tr.lproj/Localizable.strings+++ b/Sources/Tendedero/Resources/tr.lproj/Localizable.strings@@ -16,6 +16,10 @@"Quit Tendedero" = "Tendedero'yu kapat";"Could not change the login setting" = "Giriş ayarı değiştirilemedi";"Move Tendedero to the Applications folder and try again." = "Tendedero'yu Uygulamalar klasörüne taşıyın ve tekrar deneyin.";+"Size" = "Boyut";+"Small" = "Küçük";+"Medium" = "Orta";+"Large" = "Büyük";"Bring the line down" = "İpi indir";"When the pointer rests in the menu bar" = "İşaretçi menü çubuğunda durduğunda";"When something new hangs" = "Yeni bir şey asıldığında";diff --git a/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings b/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.stringsindex 9395ab6..a01e8bd 100644--- a/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings+++ b/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings@@ -16,6 +16,10 @@"Quit Tendedero" = "退出 Tendedero";"Could not change the login setting" = "无法更改登录项设置";"Move Tendedero to the Applications folder and try again." = "请先把 Tendedero 移到「应用程序」文件夹,再试一次。";+"Size" = "大小";+"Small" = "小";+"Medium" = "中";+"Large" = "大";"Bring the line down" = "放下晾衣绳";"When the pointer rests in the menu bar" = "指针停在菜单栏时";"When something new hangs" = "有新内容挂上时";