@@ -15,7 +15,6 @@ final class ImageConverterViewController: PageViewController {
15
15
@RestorableState ( " imc.resize " ) private var resize = false
16
16
@RestorableState ( " imc.width " ) private var width = 1280.0
17
17
@RestorableState ( " imc.height " ) private var height = 720.0
18
- @RestorableState ( " imc.width " ) private var padding = true
19
18
20
19
@Observable var task : [ ImageConvertTask ] = [ ]
21
20
@@ -34,8 +33,6 @@ final class ImageConverterViewController: PageViewController {
34
33
. sink { [ unowned self] in self . cell. widthField. value = $0 } . store ( in: & objectBag)
35
34
self . $height
36
35
. sink { [ unowned self] in self . cell. heightField. value = $0 } . store ( in: & objectBag)
37
- self . $padding
38
- . sink { [ unowned self] in self . cell. paddingSwitch. isOn = $0 } . store ( in: & objectBag)
39
36
40
37
self . cell. resizeSwitch. isOnPublisher
41
38
. sink { [ unowned self] in self . resize = $0 } . store ( in: & objectBag)
@@ -49,17 +46,17 @@ final class ImageConverterViewController: PageViewController {
49
46
. sink { [ unowned self] in self . format = $0 } . store ( in: & objectBag)
50
47
self . cell. dragPublisher
51
48
. sink { [ unowned self] in self . readURLs ( $0) } . store ( in: & objectBag)
52
- self . cell. paddingSwitch. isOnPublisher
53
- . sink { [ unowned self] in self . padding = $0 } . store ( in: & objectBag)
54
49
}
55
50
56
51
private func readURLs( _ pasteboard: NSPasteboard ) {
57
52
let newImageItems = ImageDropper . images ( fromPasteboard: pasteboard)
58
53
guard !newImageItems. isEmpty else { return }
59
54
60
55
self . task. append ( contentsOf: newImageItems. map {
61
- ImageConverter . convert ( $0, format: format, resize: self . resize, size: [ CGFloat ( width) , CGFloat ( height) ] , scale: scaleMode, padding: padding)
62
- } )
56
+ ImageConverter . convert ( $0, format: format, resize: self . resize, size: [ CGFloat ( width) , CGFloat ( height) ] , scale: scaleMode)
57
+ } )
58
+
59
+ self . cell. listView. scrollView. contentView. scrollToBottom ( )
63
60
}
64
61
}
65
62
@@ -73,14 +70,12 @@ enum ImageFormatType: String, TextItem {
73
70
enum ImageScaleMode : String , TextItem {
74
71
case scaleToFill = " Scale to Fill "
75
72
case scaleToFit = " Scale to Fit "
76
- case stretch = " Stretch "
77
73
}
78
74
79
75
final private class ImageConverterView : Page {
80
76
81
77
let formatTypePicker = EnumPopupButton < ImageFormatType > ( )
82
78
let resizeSwitch = NSSwitch ( )
83
- let paddingSwitch = NSSwitch ( )
84
79
let widthField = NumberField ( )
85
80
let heightField = NumberField ( )
86
81
let scaleModePicker = EnumPopupButton < ImageScaleMode > ( )
@@ -98,7 +93,6 @@ final private class ImageConverterView: Page {
98
93
$0. addArrangedSubview ( NSTextField ( labelWithString: " x " ) )
99
94
$0. addArrangedSubview ( heightField)
100
95
} ) )
101
- $0. addArrangedSubview ( Area ( title: " Padding " , control: paddingSwitch) )
102
96
}
103
97
104
98
override func draggingEntered( _ sender: NSDraggingInfo ) -> NSDragOperation {
@@ -129,7 +123,7 @@ final private class ImageConverterView: Page {
129
123
] )
130
124
)
131
125
132
- self . addSection ( Section ( title: " Images " , items: [ listView] ) )
126
+ self . addSection ( Section ( title: " Converted Images" , items: [ listView] ) )
133
127
}
134
128
}
135
129
@@ -155,7 +149,7 @@ final private class ImageListView: NSLoadView {
155
149
156
150
extension ImageListView : NSTableViewDataSource , NSTableViewDelegate {
157
151
func numberOfRows( in tableView: NSTableView ) -> Int { convertTasks. count }
158
- func tableView( _ tableView: NSTableView , heightOfRow row: Int ) -> CGFloat { 80 }
152
+ func tableView( _ tableView: NSTableView , heightOfRow row: Int ) -> CGFloat { 46 }
159
153
160
154
func tableView( _ tableView: NSTableView , viewFor tableColumn: NSTableColumn ? , row: Int ) -> NSView ? {
161
155
let cell = ImageListCell ( )
@@ -200,14 +194,15 @@ final private class ImageListCell: NSLoadStackView {
200
194
self . spacing = 16
201
195
self . edgeInsets = . init( x: 16 , y: 4 )
202
196
self . imageView. snp. makeConstraints { make in
203
- make. width. equalTo ( 100 )
204
- make. height. equalTo ( 64 )
197
+ make. width. equalTo ( 48 )
198
+ make. height. equalTo ( 28 )
205
199
}
206
200
207
201
let titleStack = NSStackView ( )
208
202
self . addArrangedSubview ( titleStack)
209
203
titleStack. orientation = . vertical
210
204
titleStack. alignment = . left
205
+ titleStack. spacing = 4
211
206
titleStack. distribution = . fillProportionally
212
207
titleStack. addArrangedSubview ( titleLabel)
213
208
titleStack. addArrangedSubview ( sizeLabel)
0 commit comments