@@ -350,6 +350,44 @@ class SettingsViewController: NSViewController {
350350 integerFormatter. minimum = 1
351351 widthStepField. formatter = integerFormatter
352352
353+ let splitRatioHeaderLabel = NSTextField ( labelWithString: NSLocalizedString ( " Half Split Ratios " , tableName: " Main " , value: " " , comment: " " ) )
354+ splitRatioHeaderLabel. font = NSFont . boldSystemFont ( ofSize: NSFont . systemFontSize)
355+ splitRatioHeaderLabel. alignment = . center
356+ splitRatioHeaderLabel. translatesAutoresizingMaskIntoConstraints = false
357+
358+ let hSplitLabel = NSTextField ( labelWithString: NSLocalizedString ( " Horizontal (L/R, %) " , tableName: " Main " , value: " " , comment: " " ) )
359+ hSplitLabel. alignment = . right
360+ hSplitLabel. translatesAutoresizingMaskIntoConstraints = false
361+
362+ let vSplitLabel = NSTextField ( labelWithString: NSLocalizedString ( " Vertical (T/B, %) " , tableName: " Main " , value: " " , comment: " " ) )
363+ vSplitLabel. alignment = . right
364+ vSplitLabel. translatesAutoresizingMaskIntoConstraints = false
365+
366+ let percentFormatter = NumberFormatter ( )
367+ percentFormatter. allowsFloats = false
368+ percentFormatter. minimum = 1
369+ percentFormatter. maximum = 99
370+
371+ let hSplitField = AutoSaveFloatField ( frame: NSRect ( x: 0 , y: 0 , width: 160 , height: 19 ) )
372+ hSplitField. stringValue = String ( Int ( Defaults . horizontalSplitRatio. value) )
373+ hSplitField. delegate = self
374+ hSplitField. defaults = Defaults . horizontalSplitRatio
375+ hSplitField. fallbackValue = 50
376+ hSplitField. translatesAutoresizingMaskIntoConstraints = false
377+ hSplitField. refusesFirstResponder = true
378+ hSplitField. alignment = . right
379+ hSplitField. formatter = percentFormatter
380+
381+ let vSplitField = AutoSaveFloatField ( frame: NSRect ( x: 0 , y: 0 , width: 160 , height: 19 ) )
382+ vSplitField. stringValue = String ( Int ( Defaults . verticalSplitRatio. value) )
383+ vSplitField. delegate = self
384+ vSplitField. defaults = Defaults . verticalSplitRatio
385+ vSplitField. fallbackValue = 50
386+ vSplitField. translatesAutoresizingMaskIntoConstraints = false
387+ vSplitField. refusesFirstResponder = true
388+ vSplitField. alignment = . right
389+ vSplitField. formatter = percentFormatter
390+
353391 largerWidthShortcutView. setAssociatedUserDefaultsKey ( WindowAction . largerWidth. name, withTransformerName: MASDictionaryTransformerName)
354392 smallerWidthShortcutView. setAssociatedUserDefaultsKey ( WindowAction . smallerWidth. name, withTransformerName: MASDictionaryTransformerName)
355393
@@ -572,6 +610,20 @@ class SettingsViewController: NSViewController {
572610 widthStepRow. spacing = 18
573611 widthStepRow. addArrangedSubview ( widthStepLabel)
574612 widthStepRow. addArrangedSubview ( widthStepField)
613+
614+ let hSplitRow = NSStackView ( )
615+ hSplitRow. orientation = . horizontal
616+ hSplitRow. alignment = . centerY
617+ hSplitRow. spacing = 18
618+ hSplitRow. addArrangedSubview ( hSplitLabel)
619+ hSplitRow. addArrangedSubview ( hSplitField)
620+
621+ let vSplitRow = NSStackView ( )
622+ vSplitRow. orientation = . horizontal
623+ vSplitRow. alignment = . centerY
624+ vSplitRow. spacing = 18
625+ vSplitRow. addArrangedSubview ( vSplitLabel)
626+ vSplitRow. addArrangedSubview ( vSplitField)
575627
576628 let topVerticalThirdRow = NSStackView ( )
577629 topVerticalThirdRow. orientation = . horizontal
@@ -682,9 +734,14 @@ class SettingsViewController: NSViewController {
682734 mainStackView. addArrangedSubview ( bottomCenterLeftEighthRow)
683735 mainStackView. addArrangedSubview ( bottomCenterRightEighthRow)
684736 mainStackView. addArrangedSubview ( bottomRightEighthRow)
737+ mainStackView. addArrangedSubview ( splitRatioHeaderLabel)
738+ mainStackView. setCustomSpacing ( 10 , after: splitRatioHeaderLabel)
739+ mainStackView. addArrangedSubview ( hSplitRow)
740+ mainStackView. addArrangedSubview ( vSplitRow)
685741
686742 NSLayoutConstraint . activate ( [
687743 headerLabel. widthAnchor. constraint ( equalTo: mainStackView. widthAnchor) ,
744+ splitRatioHeaderLabel. widthAnchor. constraint ( equalTo: mainStackView. widthAnchor) ,
688745 largerWidthLabel. widthAnchor. constraint ( equalTo: smallerWidthLabel. widthAnchor) ,
689746 smallerWidthLabel. widthAnchor. constraint ( equalTo: widthStepLabel. widthAnchor) ,
690747 widthStepLabel. widthAnchor. constraint ( equalTo: topVerticalThirdLabel. widthAnchor) ,
@@ -700,6 +757,8 @@ class SettingsViewController: NSViewController {
700757 bottomLeftEighthLabel. widthAnchor. constraint ( equalTo: bottomCenterLeftEighthLabel. widthAnchor) ,
701758 bottomCenterLeftEighthLabel. widthAnchor. constraint ( equalTo: bottomCenterRightEighthLabel. widthAnchor) ,
702759 bottomCenterRightEighthLabel. widthAnchor. constraint ( equalTo: bottomRightEighthLabel. widthAnchor) ,
760+ bottomVerticalTwoThirdsLabel. widthAnchor. constraint ( equalTo: hSplitLabel. widthAnchor) ,
761+ hSplitLabel. widthAnchor. constraint ( equalTo: vSplitLabel. widthAnchor) ,
703762 largerWidthLabelStack. widthAnchor. constraint ( equalTo: smallerWidthLabelStack. widthAnchor) ,
704763 largerWidthShortcutView. widthAnchor. constraint ( equalToConstant: 160 ) ,
705764 smallerWidthShortcutView. widthAnchor. constraint ( equalToConstant: 160 ) ,
@@ -717,7 +776,12 @@ class SettingsViewController: NSViewController {
717776 bottomCenterLeftEighthShortcutView. widthAnchor. constraint ( equalToConstant: 160 ) ,
718777 bottomCenterRightEighthShortcutView. widthAnchor. constraint ( equalToConstant: 160 ) ,
719778 bottomRightEighthShortcutView. widthAnchor. constraint ( equalToConstant: 160 ) ,
720- widthStepField. trailingAnchor. constraint ( equalTo: largerWidthShortcutView. trailingAnchor)
779+ widthStepField. trailingAnchor. constraint ( equalTo: largerWidthShortcutView. trailingAnchor) ,
780+ hSplitField. widthAnchor. constraint ( equalToConstant: 160 ) ,
781+ vSplitField. widthAnchor. constraint ( equalToConstant: 160 ) ,
782+ widthStepField. trailingAnchor. constraint ( equalTo: largerWidthShortcutView. trailingAnchor) ,
783+ hSplitField. trailingAnchor. constraint ( equalTo: largerWidthShortcutView. trailingAnchor) ,
784+ vSplitField. trailingAnchor. constraint ( equalTo: largerWidthShortcutView. trailingAnchor)
721785 ] )
722786
723787 let containerView = NSView ( )
@@ -966,8 +1030,9 @@ extension SettingsViewController: NSTextFieldDelegate {
9661030 let defaults: FloatDefault = sender. defaults else { return }
9671031
9681032 if sender. stringValue. isEmpty {
969- sender. stringValue = " 30 "
970- defaults. value = 30
1033+ let fallback = sender. fallbackValue
1034+ sender. stringValue = " \( Int ( fallback) ) "
1035+ defaults. value = fallback
9711036 sender. defaultsSetAction ? ( )
9721037 }
9731038 }
@@ -976,4 +1041,5 @@ extension SettingsViewController: NSTextFieldDelegate {
9761041class AutoSaveFloatField : NSTextField {
9771042 var defaults : FloatDefault ?
9781043 var defaultsSetAction : ( ( ) -> Void ) ?
1044+ var fallbackValue : Float = 30
9791045}
0 commit comments