-
-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a loop count setting #218
Merged
Merged
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
1841740
feat: gifski cli can limit animation loops
0bmay dee11e7
feat: max loops for conversions
0bmay 8eb2c2d
Update EditVideoViewController.swift
sindresorhus 49215fe
fix: revert Development Team updates
0bmay 439473b
Merge remote-tracking branch 'origin/master'
0bmay 2faf66f
fix: timesShown is now loopCount
0bmay 50d4861
fix: loop count for gifsicle
0bmay b052902
fix: looping Controls UI flow
0bmay 725e769
feat: stepper control for loop count
0bmay 38e0981
fix: variable fixes while updating upstream gifski
0bmay 0411ade
fix: logic flow change for looping in gifski library
0bmay 66e6fe4
fix: loop controls
0bmay 13b5696
fix: Looping Logic
0bmay 50cf2ef
Update EditVideoViewController.swift
sindresorhus 731fc92
fix: ui updates and ease of change modifications
0bmay 4c9e717
Merge branch 'master' into master
sindresorhus 7b5e039
fix: code review updates
0bmay 87612c2
Merge remote-tracking branch 'origin/master'
0bmay 7837ab3
fix: UI Contraints
0bmay 61caefa
feat: animation repeat
0bmay b311da4
feat: animation looping updates from gifski cli
0bmay d4a9694
Update EditVideoViewController.swift
sindresorhus d647ba3
Update EditVideoViewController.swift
sindresorhus b40f2be
fix: Loop Forever and Loop Count states
0bmay 9bce926
fix: Animation Preview Warning
0bmay cded813
Update Gifski/EditVideoViewController.swift
0bmay 0b6189c
fix: changed gif loop warning message
0bmay 359097b
fix: shortened looping warning message
0bmay 51f6863
fix: updated code comment and warning text for specific loop counts
0bmay 6e2db7f
Update EditVideoViewController.swift
sindresorhus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ final class EditVideoViewController: NSViewController { | |
@IBOutlet private var dimensionsTypeDropdown: MenuPopUpButton! | ||
@IBOutlet private var cancelButton: NSButton! | ||
@IBOutlet private var playerViewWrapper: NSView! | ||
@IBOutlet private var loopCountTextField: IntTextField! | ||
@IBOutlet private var loopCountStepper: NSStepper! | ||
|
||
var inputUrl: URL! | ||
var asset: AVAsset! | ||
|
@@ -50,14 +52,28 @@ final class EditVideoViewController: NSViewController { | |
maxWidth: 300 | ||
) | ||
|
||
private var loopCount: Int { | ||
/* | ||
Looping values are: | ||
-1 | No loops | ||
0 | Loop forever | ||
>=1 | Loop n times | ||
*/ | ||
guard Defaults[.loopGif] else { | ||
return Int(loopCountTextField.intValue) == 0 ? -1 : Int(loopCountTextField.intValue) | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
private var conversionSettings: Gifski.Conversion { | ||
.init( | ||
video: inputUrl, | ||
timeRange: timeRange, | ||
quality: Defaults[.outputQuality], | ||
dimensions: resizableDimensions.changed(dimensionsType: .pixels).currentDimensions.value, | ||
frameRate: frameRateSlider.integerValue, | ||
loopGif: Defaults[.loopGif] | ||
loopCount: loopCount | ||
) | ||
} | ||
|
||
|
@@ -97,6 +113,7 @@ final class EditVideoViewController: NSViewController { | |
setUpDropdowns() | ||
setUpSliders() | ||
setUpWidthAndHeightTextFields() | ||
setUpLoopCountControls() | ||
setUpDropView() | ||
setUpTrimmingView() | ||
} | ||
|
@@ -282,6 +299,20 @@ final class EditVideoViewController: NSViewController { | |
} | ||
} | ||
|
||
private func showConversionCompletedAnimationWarningIfNeeded() { | ||
// TODO: This function can be removed once NSImageView respects the looping counter in the GIF header. | ||
// https://github.com/feedback-assistant/reports/issues/187 | ||
SSApp.runOnce(identifier: "gifLoopCountWarning") { | ||
DispatchQueue.main.async { [self] in | ||
NSAlert.showModal( | ||
for: view.window, | ||
message: "Animated GIF Preview Limitation", | ||
informativeText: "The after conversion preview and Quick Look will may not loop as expect, but the exorted file is valid." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 3 typos in this text. I think it also could be more explicit about in what case it may not loop as expected. Try to spend some more effort on the text. |
||
) | ||
} | ||
} | ||
} | ||
|
||
private func setUpWidthAndHeightTextFields() { | ||
widthTextField.onBlur = { [weak self] width in | ||
self?.resizableDimensions.resize(usingWidth: CGFloat(width)) | ||
|
@@ -314,6 +345,63 @@ final class EditVideoViewController: NSViewController { | |
updateTextFieldsMinMax() | ||
} | ||
|
||
private func setUpLoopCountControls() { | ||
loopCountTextField.onBlur = { [weak self] loopCount in | ||
guard let self = self else { | ||
return | ||
} | ||
|
||
self.loopCountTextField.stringValue = "\(loopCount)" | ||
self.loopCountStepper.intValue = Int32(loopCount) | ||
|
||
if loopCount > 0 { | ||
self.loopCheckbox.state = .off | ||
} | ||
} | ||
|
||
loopCountTextField.onValueChange = { [weak self] loopCount in | ||
guard let self = self else { | ||
return | ||
} | ||
|
||
let validLoopCount = loopCount.clamped(to: Constants.loopCountRange) | ||
self.loopCountTextField.stringValue = "\(validLoopCount)" | ||
self.loopCountStepper.intValue = Int32(validLoopCount) | ||
|
||
if validLoopCount > 0 { | ||
self.loopCheckbox.state = .off | ||
} | ||
} | ||
|
||
loopCheckbox.onAction = { [weak self] _ in | ||
guard let self = self else { | ||
return | ||
} | ||
|
||
if self.loopCheckbox.state == .on { | ||
self.loopCountTextField.stringValue = "0" | ||
self.loopCountStepper.intValue = 0 | ||
} else { | ||
self.showConversionCompletedAnimationWarningIfNeeded() | ||
} | ||
} | ||
|
||
Defaults.observe(.loopGif) { [weak self] in | ||
self?.loopCountTextField.isEnabled = $0.newValue == false | ||
self?.loopCountStepper.isEnabled = $0.newValue == false | ||
} | ||
.tieToLifetime(of: self) | ||
|
||
|
||
loopCountStepper.onAction = { [weak self] _ in | ||
guard let self = self else { | ||
return | ||
} | ||
|
||
self.loopCountTextField.stringValue = "\(self.loopCountStepper.intValue)" | ||
} | ||
} | ||
|
||
private func setUpDropView() { | ||
let videoDropController = VideoDropViewController(dropLabelIsHidden: true) | ||
add(childController: videoDropController) | ||
|
@@ -342,7 +430,8 @@ final class EditVideoViewController: NSViewController { | |
heightTextField.nextKeyView = dimensionsTypeDropdown | ||
dimensionsTypeDropdown.nextKeyView = frameRateSlider | ||
frameRateSlider.nextKeyView = qualitySlider | ||
qualitySlider.nextKeyView = loopCheckbox | ||
qualitySlider.nextKeyView = loopCountTextField | ||
loopCountTextField.nextKeyView = loopCheckbox | ||
loopCheckbox.nextKeyView = cancelButton | ||
} | ||
|
||
|
@@ -351,6 +440,7 @@ final class EditVideoViewController: NSViewController { | |
let heightMinMax = resizableDimensions.heightMinMax | ||
widthTextField.minMax = Int(widthMinMax.lowerBound)...Int(widthMinMax.upperBound) | ||
heightTextField.minMax = Int(heightMinMax.lowerBound)...Int(heightMinMax.upperBound) | ||
loopCountTextField.minMax = Constants.loopCountRange | ||
} | ||
|
||
private func dimensionsUpdated() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you mirror the FB you submitted to Apple over at https://github.com/feedback-assistant/reports (follow the template) and then link to it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and thank you! I didn't know this resource existed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is now outdated. The code should not be removed when it's fixed as it also applies to Quick Look. Rather the text should be modified to only mention Quick Look when it's fixed.