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 checkerboard background for the trim view #140

Conversation

SergeyKuryanov
Copy link
Contributor

@SergeyKuryanov SergeyKuryanov commented Oct 5, 2019

Fixes #113

Seems like background color of AVPlayerView can't be modified, but we can use a trick.
We can add overlay with with a window for video preview. This makes effect of checkerboard background.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


IssueHunt has been backed by the following sponsors. Become a sponsor

class CheckerboardView: NSView {
let gridSize = CGSize(width: 10, height: 10)
let firstColor = NSColor.white
let secondColor = NSColor.lightGray
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit too dark. I would use #d1d1d1 (preferably a semantic color close to this).

Gifski/CheckerboardView.swift Outdated Show resolved Hide resolved
secondColor.setFill()

for y in 0...Int(bounds.size.height / gridSize.height) {
for x in 0...Int(bounds.size.width / gridSize.width) where x % 2 == y % 2 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this for readability:

extension BinaryInteger {
	var isEven: Bool { isMultiple(of: 2) }
	var isOdd: Bool { !isEven }
}

import Cocoa

class CheckerboardView: NSView {
private let gridSize = CGSize(width: 10, height: 10)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for 7px.

@sindresorhus
Copy link
Owner

Nice trick!

@sindresorhus sindresorhus changed the title Add Checkerboard background for Trimming view Add checkerboard background for the trim view Oct 7, 2019
@sindresorhus
Copy link
Owner

Should we use a dark checkerboard version in dark mode?

@SergeyKuryanov
Copy link
Contributor Author

SergeyKuryanov commented Oct 7, 2019

Should we use a dark checkerboard version in dark mode?

I think we should. Maybe flip white to black for dark mode?

@SergeyKuryanov
Copy link
Contributor Author

@sindresorhus grid size 7px looks not okay at top, so I set 8px:
Снимок экрана 2019-10-07 в 15 25 31

static let first = NSColor(named: "CheckerboardFirstColor") ?? NSColor.white
static let second = NSColor(named: "CheckerboardSecondColor") ?? NSColor.lightGray
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this in https://github.com/sindresorhus/Gifski/blob/master/Gifski/Constants.swift and you can just force-unwrap the colors.

@sindresorhus
Copy link
Owner

Make the second color in dark mode #838485.

@sindresorhus sindresorhus merged commit b3e741f into sindresorhus:master Oct 8, 2019
@sindresorhus
Copy link
Owner

Looks great 👌

sindresorhus added a commit that referenced this pull request Oct 8, 2019
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@SergeyKuryanov SergeyKuryanov deleted the 113-add-checkerboard-background-for-trimming-view branch October 8, 2019 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace black background on trimming view with a checkerboard NSColor
2 participants