Skip to content
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 30 commits into from
Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 Nov 24, 2020
dee11e7
feat: max loops for conversions
0bmay Nov 25, 2020
8eb2c2d
Update EditVideoViewController.swift
sindresorhus Nov 25, 2020
49215fe
fix: revert Development Team updates
0bmay Nov 25, 2020
439473b
Merge remote-tracking branch 'origin/master'
0bmay Nov 25, 2020
2faf66f
fix: timesShown is now loopCount
0bmay Nov 25, 2020
50d4861
fix: loop count for gifsicle
0bmay Nov 25, 2020
b052902
fix: looping Controls UI flow
0bmay Nov 25, 2020
725e769
feat: stepper control for loop count
0bmay Nov 25, 2020
38e0981
fix: variable fixes while updating upstream gifski
0bmay Nov 25, 2020
0411ade
fix: logic flow change for looping in gifski library
0bmay Nov 26, 2020
66e6fe4
fix: loop controls
0bmay Nov 26, 2020
13b5696
fix: Looping Logic
0bmay Nov 26, 2020
50cf2ef
Update EditVideoViewController.swift
sindresorhus Nov 27, 2020
731fc92
fix: ui updates and ease of change modifications
0bmay Nov 27, 2020
4c9e717
Merge branch 'master' into master
sindresorhus Nov 28, 2020
7b5e039
fix: code review updates
0bmay Nov 28, 2020
87612c2
Merge remote-tracking branch 'origin/master'
0bmay Nov 28, 2020
7837ab3
fix: UI Contraints
0bmay Nov 28, 2020
61caefa
feat: animation repeat
0bmay Dec 17, 2020
b311da4
feat: animation looping updates from gifski cli
0bmay Dec 18, 2020
d4a9694
Update EditVideoViewController.swift
sindresorhus Dec 18, 2020
d647ba3
Update EditVideoViewController.swift
sindresorhus Dec 18, 2020
b40f2be
fix: Loop Forever and Loop Count states
0bmay Dec 18, 2020
9bce926
fix: Animation Preview Warning
0bmay Dec 22, 2020
cded813
Update Gifski/EditVideoViewController.swift
0bmay Dec 23, 2020
0b6189c
fix: changed gif loop warning message
0bmay Dec 23, 2020
359097b
fix: shortened looping warning message
0bmay Dec 23, 2020
51f6863
fix: updated code comment and warning text for specific loop counts
0bmay Dec 25, 2020
6e2db7f
Update EditVideoViewController.swift
sindresorhus Dec 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gifski.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
DEVELOPMENT_TEAM = 8JPUXG2X2Z;
sindresorhus marked this conversation as resolved.
Show resolved Hide resolved
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = ShareExtension/Info.plist;
Expand Down Expand Up @@ -539,7 +539,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
DEVELOPMENT_TEAM = 8JPUXG2X2Z;
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = ShareExtension/Info.plist;
Expand Down Expand Up @@ -682,7 +682,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
DEVELOPMENT_TEAM = 8JPUXG2X2Z;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -719,7 +719,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
DEVELOPMENT_TEAM = 8JPUXG2X2Z;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
34 changes: 32 additions & 2 deletions Gifski/EditVideoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class EditVideoViewController: NSViewController {
@IBOutlet private var dimensionsTypeDropdown: MenuPopUpButton!
@IBOutlet private var cancelButton: NSButton!
@IBOutlet private var playerViewWrapper: NSView!
@IBOutlet private var timesShownTextField: IntTextField!

var inputUrl: URL!
var asset: AVAsset!
Expand All @@ -41,6 +42,9 @@ final class EditVideoViewController: NSViewController {
private let formatter = ByteCountFormatter()
private var playerViewController: TrimmingAVPlayerViewController!

// a loop of 1 is times shown of 2.. a loop of 2 is timesShown of 3
private var timesShown: Int = 1
0bmay marked this conversation as resolved.
Show resolved Hide resolved

private var timeRange: ClosedRange<Double>? { playerViewController?.timeRange }

private let tooltip = Tooltip(
Expand All @@ -57,7 +61,8 @@ final class EditVideoViewController: NSViewController {
quality: Defaults[.outputQuality],
dimensions: resizableDimensions.changed(dimensionsType: .pixels).currentDimensions.value,
frameRate: frameRateSlider.integerValue,
loopGif: Defaults[.loopGif]
loopGif: Defaults[.loopGif],
timesShown: timesShown
)
}

Expand Down Expand Up @@ -97,6 +102,7 @@ final class EditVideoViewController: NSViewController {
setUpDropdowns()
setUpSliders()
setUpWidthAndHeightTextFields()
setUpTimesShownTextField()
setUpDropView()
setUpTrimmingView()
}
Expand Down Expand Up @@ -314,6 +320,28 @@ final class EditVideoViewController: NSViewController {
updateTextFieldsMinMax()
}

private func setUpTimesShownTextField() {
timesShownTextField.onBlur = { [weak self] timesShown in
0bmay marked this conversation as resolved.
Show resolved Hide resolved
self?.loopCheckbox.isEnabled = (timesShown == 0)
self?.timesShown = timesShown == 0 ? 1 : Int(self?.timesShownTextField.intValue ?? 1) + 1
if timesShown > 0 {
self?.loopCheckbox.state = NSControl.StateValue.off
}
}

timesShownTextField.onValueChange = { [weak self] timesShown in
guard let self = self else {
return
}

self.loopCheckbox.isEnabled = (timesShown == 0)
self.timesShown = timesShown == 0 ? 1 : Int(self.timesShownTextField.intValue) + 1
if timesShown > 0 {
self.loopCheckbox.state = NSControl.StateValue.off
}
}
}

private func setUpDropView() {
let videoDropController = VideoDropViewController(dropLabelIsHidden: true)
add(childController: videoDropController)
Expand Down Expand Up @@ -342,7 +370,8 @@ final class EditVideoViewController: NSViewController {
heightTextField.nextKeyView = dimensionsTypeDropdown
dimensionsTypeDropdown.nextKeyView = frameRateSlider
frameRateSlider.nextKeyView = qualitySlider
qualitySlider.nextKeyView = loopCheckbox
qualitySlider.nextKeyView = timesShownTextField
timesShownTextField.nextKeyView = loopCheckbox
loopCheckbox.nextKeyView = cancelButton
}

Expand All @@ -351,6 +380,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)
timesShownTextField.minMax = 0...9999
}

private func dimensionsUpdated() {
Expand Down
77 changes: 53 additions & 24 deletions Gifski/EditVideoViewController.xib

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Gifski/Gifski.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class Gifski {
var dimensions: CGSize?
var frameRate: Int?
var loopGif: Bool = true
var timesShown: Int = 9999
0bmay marked this conversation as resolved.
Show resolved Hide resolved
}

private var gifData = NSMutableData()
Expand Down Expand Up @@ -97,7 +98,8 @@ final class Gifski {
height: UInt32(conversion.dimensions?.height ?? 0),
quality: UInt8(conversion.quality * 100),
once: !conversion.loopGif,
fast: false
fast: false,
times_shown: UInt16(conversion.timesShown)
0bmay marked this conversation as resolved.
Show resolved Hide resolved
)

self.gifski = GifskiWrapper(settings: settings)
Expand Down
Loading