1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-30 07:55:01 +00:00

Use modern constraint specification, add layers to XIBs.

This commit is contained in:
Thomas Harte 2021-07-12 22:55:53 -04:00
parent b01561712c
commit d24d153c08
3 changed files with 9 additions and 29 deletions

View File

@ -13,7 +13,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<visualEffectView hidden="YES" appearanceType="vibrantDark" misplaced="YES" blendingMode="withinWindow" material="HUDWindow" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="fX1-EX-wGf">
<visualEffectView hidden="YES" wantsLayer="YES" appearanceType="vibrantDark" blendingMode="withinWindow" material="HUDWindow" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="fX1-EX-wGf">
<rect key="frame" x="0.0" y="0.0" width="202" height="112"/>
<subviews>
<button wantsLayer="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pzn-mL-BPh">

View File

@ -30,7 +30,7 @@
<view hidden="YES" wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DEG-fq-cjd" customClass="CSScanTargetView">
<rect key="frame" x="0.0" y="0.0" width="600" height="450"/>
</view>
<visualEffectView hidden="YES" appearanceType="vibrantDark" blendingMode="withinWindow" material="HUDWindow" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="l9e-qt-jMo" userLabel="Volume View">
<visualEffectView hidden="YES" wantsLayer="YES" appearanceType="vibrantDark" blendingMode="withinWindow" material="HUDWindow" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="l9e-qt-jMo" userLabel="Volume View">
<rect key="frame" x="130" y="20" width="340" height="36"/>
<subviews>
<imageView wantsLayer="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3hK-SA-aKj">

View File

@ -139,8 +139,7 @@ class MachineDocument:
aController.window?.contentAspectRatio = self.aspectRatio()
volumeSlider.floatValue = userDefaultsVolume()
volumeView.wantsLayer = true
volumeView.layer?.cornerRadius = 5.0
volumeView.layer!.cornerRadius = 5.0
}
private var missingROMs: String = ""
@ -227,36 +226,17 @@ class MachineDocument:
}
if let optionsView = self.optionsView, let superview = self.volumeView.superview {
// Apply rounded edges.
optionsView.wantsLayer = true
optionsView.layer?.cornerRadius = 5.0
// optionsView.translatesAutoresizingMaskIntoConstraints = false
optionsView.layer!.cornerRadius = 5.0
// Add to the superview.
superview.addSubview(optionsView)
// Apply constraints to appear centred and above the volume view.
let centreConstraint = NSLayoutConstraint(
item: optionsView,
attribute: .centerX,
relatedBy: .equal,
toItem: self.volumeView,
attribute: .centerX,
multiplier: 1.0,
constant: 0.0
)
superview.addConstraint(centreConstraint)
let verticalConstraint = NSLayoutConstraint(
item: optionsView,
attribute: .bottom,
relatedBy: .equal,
toItem: self.volumeView,
attribute: .top,
multiplier: 1.0,
constant: -8.0 // TODO: find a way to use an OS-supplied standard value here.
)
superview.addConstraint(verticalConstraint)
let constraints = [
optionsView.centerXAnchor.constraint(equalTo: volumeView.centerXAnchor),
optionsView.bottomAnchor.constraint(equalTo: volumeView.topAnchor, constant: -8.0),
]
superview.addConstraints(constraints)
}
}