Skip to content

Commit

Permalink
Merge pull request #37 from ReDetection/fix-transparent
Browse files Browse the repository at this point in the history
Fix old format incompatibility
  • Loading branch information
Patrick-Kladek authored Apr 21, 2023
2 parents ac1acf0 + 57e1873 commit 44f799a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Screenshot Framer Tests/ScreenshotFramerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ScreenshotFramerTests: XCTestCase {

let layerState = LayerState(title: "First Operation",
layers: [LayoutableObject(type: .background, title: "Background", frame: CGRect(x: 0, y: 0, width: 800, height: 1200), file: "")],
outputConfig: OutputConfig(output: "", fromImageNumber: 1, toImageNumber: 5))
outputConfig: OutputConfig(transparent: false, output: "", fromImageNumber: 1, toImageNumber: 5))
self.layerStateHistory.append(layerState)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ final class ContentViewController: NSViewController, NSMenuItemValidation {
self.scrollView.documentView = self.layoutController.layoutHierarchy(layers: self.lastLayerState.layers)
self.layoutWarningButton.isHidden = self.layoutController.layoutErrors.isEmpty

self.transparencyCheckbox.state = self.lastLayerState.outputConfig.transparent ? .on : .off
self.transparencyCheckbox.state = (self.lastLayerState.outputConfig.transparent ?? false) ? .on : .off
self.textFieldOutput.stringValue = self.lastLayerState.outputConfig.output
self.textFieldFromImageNumber.integerValue = self.lastLayerState.outputConfig.fromImageNumber
self.textFieldToImageNumber.integerValue = self.lastLayerState.outputConfig.toImageNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class ExportController {
guard let url = self.fileController.outputURL(for: self.lastLayerState, viewState: viewState) else { return [.noOutputFile] }

try? fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent) {
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false) {
try? data.write(to: url, options: .atomic)
}

Expand Down Expand Up @@ -97,7 +97,7 @@ final class ExportController {
guard let url = self.fileController.outputURL(for: self.lastLayerState, viewState: viewStateController.viewState) else { return [.noOutputFile] }

try? fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent) {
if let data = view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false) {
try? data.write(to: url, options: .atomic)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ final class ExportController {
let tempURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Preview \(name).png")

do {
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent)?.write(to: tempURL)
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false)?.write(to: tempURL)
} catch {
let alert = NSAlert(error: error)
alert.runModal()
Expand Down Expand Up @@ -175,7 +175,7 @@ final class ExportController {
let tempURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Preview Languages of \(name).png")

do {
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent)?.write(to: tempURL)
try view.pngData(transparent: self.lastLayerState.outputConfig.transparent ?? false)?.write(to: tempURL)
} catch {
let alert = NSAlert(error: error)
alert.runModal()
Expand Down
2 changes: 1 addition & 1 deletion Screenshot Framer/Model/OutputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct OutputConfig: Codable {

// MARK: - Properties

let transparent: Bool
let transparent: Bool?
let output: String
let fromImageNumber: Int
let toImageNumber: Int
Expand Down

0 comments on commit 44f799a

Please sign in to comment.