Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions Free Ruler/Base.lproj/PreferencesController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Free Ruler Settings" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" frameAutosaveName="preferencesWindow" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="602" y="400" width="360" height="426"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<rect key="contentRect" x="602" y="400" width="360" height="415"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="360" height="426"/>
<rect key="frame" x="0.0" y="0.0" width="360" height="415"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PREF-defaults-header">
<rect key="frame" x="22" y="398" width="290" height="16"/>
<rect key="frame" x="22" y="387" width="290" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Default settings for new rulers" id="PREF-defaults-header-cell">
<font key="font" textStyle="headline" name=".SFNS-Bold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<box borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="PREF-defaults-box">
<rect key="frame" x="9" y="58" width="342" height="330"/>
<rect key="frame" x="9" y="58" width="342" height="319"/>
<view key="contentView" id="PREF-defaults-box-content">
<rect key="frame" x="4" y="5" width="334" height="322"/>
<rect key="frame" x="4" y="5" width="334" height="311"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<customView id="PREF-controls" customClass="RulerSettingsControlsView" customModule="Free_Ruler" customModuleProvider="target">
<rect key="frame" x="-4" y="0.0" width="340" height="320"/>
<rect key="frame" x="-4" y="4" width="340" height="309"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</customView>
</subviews>
Expand Down
2 changes: 1 addition & 1 deletion Free Ruler/Base.lproj/RulerSettingsController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<window title="Ruler Settings" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" animationBehavior="default" titlebarAppearsTransparent="YES" id="RSET-window" customClass="RulerSettingsWindow" customModule="Free_Ruler" customModuleProvider="target">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="602" y="400" width="280" height="370"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<view key="contentView" id="RSET-content">
<rect key="frame" x="0.0" y="0.0" width="280" height="370"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
173 changes: 138 additions & 35 deletions Free Ruler/Base.lproj/RulerSettingsControlsView.xib

Large diffs are not rendered by default.

84 changes: 0 additions & 84 deletions Free Ruler/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -971,90 +971,6 @@
}
}
},
"RulerSettingsControls.Dimensions" : {
"comment" : "Label for active ruler width and height fields",
"extractionState" : "manual",
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Abmessungen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Dimensions"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Dimensiones"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Mitat"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "寸法"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "尺寸"
}
}
}
},
"RulerSettingsControls.Unit" : {
"comment" : "Label for the active ruler measurement unit setting",
"extractionState" : "manual",
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Einheit"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unit"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unidad"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Yksikkö"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "単位"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "单位"
}
}
}
},
"Unit.Inches.Abbreviation" : {
"comment" : "Inches unit abbreviation",
"extractionState" : "manual",
Expand Down
131 changes: 10 additions & 121 deletions Free Ruler/PreferencesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,61 +206,25 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
weak var delegate: RulerSettingsControlsViewDelegate?

@IBOutlet var contentView: NSView!
@IBOutlet weak var unitLabel: NSTextField!
@IBOutlet weak var unitSegmentedControl: NSSegmentedControl!
@IBOutlet weak var dimensionsLabel: NSTextField!
@IBOutlet weak var dimensionWidthField: NSTextField!
@IBOutlet weak var dimensionsSeparatorLabel: NSTextField!
@IBOutlet weak var dimensionHeightField: NSTextField!
@IBOutlet weak var rulerColorLabel: NSTextField!
@IBOutlet weak var rulerColorWell: RulerColorWell!
@IBOutlet weak var resetRulerColorButton: NSButton!
@IBOutlet weak var foregroundOpacityTitleLabel: NSTextField!
@IBOutlet weak var foregroundOpacitySlider: NSSlider!
@IBOutlet weak var backgroundOpacityTitleLabel: NSTextField!
@IBOutlet weak var backgroundOpacitySlider: NSSlider!
@IBOutlet weak var foregroundOpacityLabel: NSTextField!
@IBOutlet weak var backgroundOpacityLabel: NSTextField!
@IBOutlet weak var floatRulersCheckbox: NSButton!
@IBOutlet weak var rulerShadowCheckbox: NSButton!

let unitLabel = NSTextField(labelWithString: NSLocalizedString(
"RulerSettingsControls.Unit",
value: "Unit",
comment: "Label for the active ruler measurement unit setting"
))
let unitSegmentedControl = NSSegmentedControl(
labels: [
NSLocalizedString(
"Unit.Pixels.Abbreviation",
value: "px",
comment: "Pixels unit abbreviation"
),
NSLocalizedString(
"Unit.Millimeters.Abbreviation",
value: "mm",
comment: "Millimeters unit abbreviation"
),
NSLocalizedString(
"Unit.Inches.Abbreviation",
value: "in",
comment: "Inches unit abbreviation"
),
],
trackingMode: .selectOne,
target: nil,
action: nil
)
let dimensionsLabel = NSTextField(labelWithString: NSLocalizedString(
"RulerSettingsControls.Dimensions",
value: "Dimensions",
comment: "Label for active ruler width and height fields"
))
let dimensionWidthField = NSTextField()
let dimensionsSeparatorLabel = NSTextField(labelWithString: "x")
let dimensionHeightField = NSTextField()

private var showsDimensions = true
private var dimensionScreen: NSScreen?
private var dimensionControls: [NSView] {
return [
dimensionsLabel,
dimensionWidthField,
dimensionsSeparatorLabel,
dimensionHeightField,
]
}

var selectedUnit: Unit {
return Unit(rawValue: unitSegmentedControl.selectedSegment) ?? .pixels
Expand Down Expand Up @@ -301,8 +265,6 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
}

func configureForPreferences() {
showsDimensions = true
updateDimensionsVisibility()
configureControls(
unitSegmentedControlIdentifier: "ruler-unit-segmented-control",
widthFieldIdentifier: "ruler-width-field",
Expand All @@ -321,8 +283,6 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
}

func configureForRulerSettings() {
showsDimensions = true
updateDimensionsVisibility()
configureControls(
unitSegmentedControlIdentifier: "ruler-settings-unit-segmented-control",
widthFieldIdentifier: "ruler-settings-width-field",
Expand Down Expand Up @@ -413,12 +373,6 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
}
}

override func layout() {
super.layout()

layoutTopControls()
}

func performRulerSettingsKeyEquivalent(with event: NSEvent) -> Bool {
guard event.type == .keyDown,
event.modifierFlags
Expand Down Expand Up @@ -463,18 +417,9 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
contentView.topAnchor.constraint(equalTo: topAnchor),
contentView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
installTopControls()
configureBaseControls()
}

private func installTopControls() {
for control in [unitLabel, unitSegmentedControl] + dimensionControls {
control.translatesAutoresizingMaskIntoConstraints = true
contentView.addSubview(control)
}
updateDimensionsVisibility()
}

private func configureBaseControls() {
unitSegmentedControl.target = self
unitSegmentedControl.action = #selector(setUnit(_:))
Expand Down Expand Up @@ -571,7 +516,7 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
}

private func configureKeyViewLoop() {
unitSegmentedControl.nextKeyView = showsDimensions ? dimensionWidthField : rulerColorWell
unitSegmentedControl.nextKeyView = dimensionWidthField
dimensionWidthField.nextKeyView = dimensionHeightField
dimensionHeightField.nextKeyView = rulerColorWell
rulerColorWell.nextKeyView = resetRulerColorButton.isHidden
Expand Down Expand Up @@ -601,62 +546,6 @@ final class RulerSettingsControlsView: NSView, NSTextFieldDelegate {
field.action = #selector(setDimensions(_:))
}

private func updateDimensionsVisibility() {
for control in dimensionControls {
control.isHidden = !showsDimensions
}
needsLayout = true
configureKeyViewLoop()
}

private func layoutTopControls() {
guard contentView != nil else { return }

let labelX: CGFloat = 15
let labelWidth: CGFloat = 150
let labelHeight: CGFloat = 16
let rightMargin: CGFloat = 21
let contentWidth = contentView.bounds.width
let controlRight = contentWidth - rightMargin

let unitControlWidth: CGFloat = 108
let unitY: CGFloat = showsDimensions ? 285 : 249
unitLabel.frame = NSRect(x: labelX, y: unitY, width: labelWidth, height: labelHeight)
unitSegmentedControl.frame = NSRect(
x: controlRight - unitControlWidth,
y: unitY - 4,
width: unitControlWidth,
height: 24
)

let dimensionsY: CGFloat = 249
let fieldWidth: CGFloat = 56
let separatorWidth: CGFloat = 18
let heightFieldX = controlRight - fieldWidth
let separatorX = heightFieldX - separatorWidth
let widthFieldX = separatorX - fieldWidth

dimensionsLabel.frame = NSRect(x: labelX, y: dimensionsY, width: labelWidth, height: labelHeight)
dimensionWidthField.frame = NSRect(
x: widthFieldX,
y: dimensionsY - 4,
width: fieldWidth,
height: 24
)
dimensionsSeparatorLabel.frame = NSRect(
x: separatorX,
y: dimensionsY,
width: separatorWidth,
height: labelHeight
)
dimensionHeightField.frame = NSRect(
x: heightFieldX,
y: dimensionsY - 4,
width: fieldWidth,
height: 24
)
}

private func toggleFloatRulersFromKeyEquivalent() -> Bool {
guard floatRulersCheckbox.isEnabled else { return false }

Expand Down
6 changes: 6 additions & 0 deletions Free Ruler/de.lproj/RulerSettingsControlsView.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/* Class = "NSTextFieldCell"; title = "Ruler Color"; ObjectID = "RSV-color-cell"; */
"RSV-color-cell.title" = "Linealfarbe";

/* Class = "NSTextFieldCell"; title = "Dimensions"; ObjectID = "RSV-dimensions-cell"; */
"RSV-dimensions-cell.title" = "Abmessungen";

/* Class = "NSTextFieldCell"; title = "Foreground Opacity"; ObjectID = "RSV-fg-cell"; */
"RSV-fg-cell.title" = "Deckkraft im Vordergrund";

Expand All @@ -13,3 +16,6 @@

/* Class = "NSButtonCell"; title = "Show ruler shadow"; ObjectID = "RSV-shadow-cell"; */
"RSV-shadow-cell.title" = "Linealschatten anzeigen";

/* Class = "NSTextFieldCell"; title = "Unit"; ObjectID = "RSV-unit-cell"; */
"RSV-unit-cell.title" = "Einheit";
6 changes: 6 additions & 0 deletions Free Ruler/es.lproj/RulerSettingsControlsView.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/* Class = "NSTextFieldCell"; title = "Ruler Color"; ObjectID = "RSV-color-cell"; */
"RSV-color-cell.title" = "Color de la regla";

/* Class = "NSTextFieldCell"; title = "Dimensions"; ObjectID = "RSV-dimensions-cell"; */
"RSV-dimensions-cell.title" = "Dimensiones";

/* Class = "NSTextFieldCell"; title = "Foreground Opacity"; ObjectID = "RSV-fg-cell"; */
"RSV-fg-cell.title" = "Opacidad del primer plano";

Expand All @@ -13,3 +16,6 @@

/* Class = "NSButtonCell"; title = "Show ruler shadow"; ObjectID = "RSV-shadow-cell"; */
"RSV-shadow-cell.title" = "Mostrar sombra de la regla";

/* Class = "NSTextFieldCell"; title = "Unit"; ObjectID = "RSV-unit-cell"; */
"RSV-unit-cell.title" = "Unidad";
6 changes: 6 additions & 0 deletions Free Ruler/fi.lproj/RulerSettingsControlsView.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/* Class = "NSTextFieldCell"; title = "Ruler Color"; ObjectID = "RSV-color-cell"; */
"RSV-color-cell.title" = "Viivaimen väri";

/* Class = "NSTextFieldCell"; title = "Dimensions"; ObjectID = "RSV-dimensions-cell"; */
"RSV-dimensions-cell.title" = "Mitat";

/* Class = "NSTextFieldCell"; title = "Foreground Opacity"; ObjectID = "RSV-fg-cell"; */
"RSV-fg-cell.title" = "Peittävyys edustalla";

Expand All @@ -13,3 +16,6 @@

/* Class = "NSButtonCell"; title = "Show ruler shadow"; ObjectID = "RSV-shadow-cell"; */
"RSV-shadow-cell.title" = "Näytä viivainten varjot";

/* Class = "NSTextFieldCell"; title = "Unit"; ObjectID = "RSV-unit-cell"; */
"RSV-unit-cell.title" = "Yksikkö";
6 changes: 6 additions & 0 deletions Free Ruler/ja.lproj/RulerSettingsControlsView.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/* Class = "NSTextFieldCell"; title = "Ruler Color"; ObjectID = "RSV-color-cell"; */
"RSV-color-cell.title" = "定規の色";

/* Class = "NSTextFieldCell"; title = "Dimensions"; ObjectID = "RSV-dimensions-cell"; */
"RSV-dimensions-cell.title" = "寸法";

/* Class = "NSTextFieldCell"; title = "Foreground Opacity"; ObjectID = "RSV-fg-cell"; */
"RSV-fg-cell.title" = "前景の不透明度";

Expand All @@ -13,3 +16,6 @@

/* Class = "NSButtonCell"; title = "Show ruler shadow"; ObjectID = "RSV-shadow-cell"; */
"RSV-shadow-cell.title" = "定規の影を表示";

/* Class = "NSTextFieldCell"; title = "Unit"; ObjectID = "RSV-unit-cell"; */
"RSV-unit-cell.title" = "単位";
Loading