forked from iina/iina
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCropBoxViewController.swift
More file actions
44 lines (36 loc) · 1.06 KB
/
CropBoxViewController.swift
File metadata and controls
44 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// CropBoxViewController.swift
// iina
//
// Created by lhc on 5/9/2017.
// Copyright © 2017 lhc. All rights reserved.
//
import Cocoa
/** The generic view controller of `CropBoxView`. */
class CropBoxViewController: NSViewController {
weak var mainWindow: MainWindowController!
var cropx: Int = 0
var cropy: Int = 0 // in flipped coord
var cropw: Int = 0
var croph: Int = 0
var readableCropString: String {
return "(\(cropx), \(cropy)) (\(cropw)\u{d7}\(croph))"
}
lazy var cropBoxView: CropBoxView = {
let view = CropBoxView()
view.settingsViewController = self
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
func selectedRectUpdated() {
guard mainWindow.isInInteractiveMode else { return }
let rect = cropBoxView.selectedRect
updateCropValues(from: rect)
}
private func updateCropValues(from rect: NSRect) {
cropx = Int(rect.minX)
cropy = Int(CGFloat(mainWindow.player.info.videoHeight!) - rect.height - rect.minY)
cropw = Int(rect.width)
croph = Int(rect.height)
}
}