Skip to content
Closed
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
13 changes: 11 additions & 2 deletions Free Ruler/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
settingsController.close()
}
}
manager.onStateChanged = { [weak self] _ in
self?.saveRulerSetState()
manager.onStateChanged = { [weak self] manager in
guard let self = self else { return }

self.saveRulerSetState()

let activeController = manager.activeController
guard let settingsController = self.rulerSettingsController,
settingsController.currentRulerController === activeController,
settingsController.window?.isVisible == true else { return }

settingsController.updateView()
}
return manager
}()
Expand Down
10 changes: 8 additions & 2 deletions Free Ruler/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Ruler" id="bib-Uj-vzu">
<items>
<menuItem title="New Ruler" keyEquivalent="n" id="rWt-KM-qSf">
<connections>
<action selector="newRuler:" target="Voe-Tx-rLC" id="yGQ-9l-C8Y"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="SXc-41-n3S"/>
<menuItem title="Hide Horizontal Ruler" keyEquivalent="h" id="fLB-gk-0Jy">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand All @@ -98,8 +104,8 @@
<action selector="showRulers:" target="Voe-Tx-rLC" id="NLA-hk-Wbc"/>
</connections>
</menuItem>
<menuItem title="Ruler Settings…" id="rSt-Tg-232">
<modifierMask key="keyEquivalentModifierMask"/>
<menuItem title="Ruler Settings…" keyEquivalent="," id="rSt-Tg-232">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="openRulerSettings:" target="Voe-Tx-rLC" id="RSa-Tg-232"/>
</connections>
Expand Down
183 changes: 35 additions & 148 deletions Free Ruler/Base.lproj/PreferencesController.xib

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions Free Ruler/Base.lproj/RulerSettingsController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RulerSettingsController" customModule="Free_Ruler" customModuleProvider="target">
<connections>
<outlet property="resetDefaultsButton" destination="RSET-reset-defaults-button" id="RSET-reset-defaults-outlet"/>
<outlet property="setDefaultsButton" destination="RSET-save-defaults-button" id="RSET-save-defaults-outlet"/>
<outlet property="settingsControlsView" destination="RSET-controls" id="RSET-controls-outlet"/>
<outlet property="window" destination="RSET-window" id="RSET-window-outlet"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<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="300"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<view key="contentView" id="RSET-content">
<rect key="frame" x="0.0" y="0.0" width="280" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="RSET-controls" customClass="RulerSettingsControlsView" customModule="Free_Ruler" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="280" height="250"/>
</customView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RSET-reset-defaults-button">
<rect key="frame" x="11" y="11" width="130" height="32"/>
<buttonCell key="cell" type="push" title="Reset to default" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RSET-reset-defaults-cell">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="resetToDefault:" target="-2" id="RSET-reset-defaults-action"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RSET-save-defaults-button">
<rect key="frame" x="139" y="11" width="127" height="32"/>
<buttonCell key="cell" type="push" title="Save as default" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RSET-save-defaults-cell">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="setDefaultsForNewRulers:" target="-2" id="RSET-save-defaults-action"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="RSET-controls" firstAttribute="leading" secondItem="RSET-content" secondAttribute="leading" id="RSET-controls-leading"/>
<constraint firstItem="RSET-controls" firstAttribute="top" secondItem="RSET-content" secondAttribute="top" id="RSET-controls-top"/>
<constraint firstAttribute="trailing" secondItem="RSET-controls" secondAttribute="trailing" id="RSET-controls-trailing"/>
<constraint firstItem="RSET-reset-defaults-button" firstAttribute="top" secondItem="RSET-controls" secondAttribute="bottom" constant="12" id="RSET-reset-below-controls"/>
<constraint firstAttribute="bottom" secondItem="RSET-reset-defaults-button" secondAttribute="bottom" constant="18" id="RSET-reset-bottom"/>
<constraint firstItem="RSET-reset-defaults-button" firstAttribute="leading" secondItem="RSET-content" secondAttribute="leading" constant="18" id="RSET-reset-leading"/>
<constraint firstItem="RSET-save-defaults-button" firstAttribute="leading" secondItem="RSET-reset-defaults-button" secondAttribute="trailing" constant="12" id="RSET-save-after-reset"/>
<constraint firstItem="RSET-save-defaults-button" firstAttribute="centerY" secondItem="RSET-reset-defaults-button" secondAttribute="centerY" id="RSET-save-center-y"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="RSET-save-defaults-button" secondAttribute="trailing" constant="20" id="RSET-save-trailing-min"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="RSET-delegate-outlet"/>
</connections>
<point key="canvasLocation" x="121" y="228"/>
</window>
</objects>
</document>
117 changes: 117 additions & 0 deletions Free Ruler/Base.lproj/RulerSettingsControlsView.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RulerSettingsControlsView" customModule="Free_Ruler" customModuleProvider="target">
<connections>
<outlet property="backgroundOpacityLabel" destination="RSV-bg-value" id="RSV-bg-value-outlet"/>
<outlet property="backgroundOpacitySlider" destination="RSV-bg-slider" id="RSV-bg-slider-outlet"/>
<outlet property="contentView" destination="RSV-content" id="RSV-content-outlet"/>
<outlet property="floatRulersCheckbox" destination="RSV-float-checkbox" id="RSV-float-outlet"/>
<outlet property="foregroundOpacityLabel" destination="RSV-fg-value" id="RSV-fg-value-outlet"/>
<outlet property="foregroundOpacitySlider" destination="RSV-fg-slider" id="RSV-fg-slider-outlet"/>
<outlet property="resetRulerColorButton" destination="RSV-reset-button" id="RSV-reset-outlet"/>
<outlet property="rulerColorWell" destination="RSV-color-well" id="RSV-color-outlet"/>
<outlet property="rulerShadowCheckbox" destination="RSV-shadow-checkbox" id="RSV-shadow-outlet"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="RSV-content">
<rect key="frame" x="0.0" y="0.0" width="312" height="250"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RSV-color-label">
<rect key="frame" x="15" y="213" width="160" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Ruler Color" id="RSV-color-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" id="RSV-reset-button">
<rect key="frame" x="204" y="207" width="28" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" imageScaling="proportionallyDown" id="RSV-reset-cell">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<color key="bezelColor" name="labelColor" catalog="System" colorSpace="catalog"/>
</button>
<colorWell id="RSV-color-well" customClass="RulerColorWell" customModule="Free_Ruler" customModuleProvider="target">
<rect key="frame" x="235" y="206" width="60" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<color key="color" name="systemYellowColor" catalog="System" colorSpace="catalog"/>
</colorWell>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RSV-fg-label">
<rect key="frame" x="15" y="172" width="210" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Foreground Opacity" id="RSV-fg-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RSV-fg-value">
<rect key="frame" x="247" y="172" width="44" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="100%" id="RSV-fg-value-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" id="RSV-fg-slider">
<rect key="frame" x="15" y="138" width="276" height="28"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<sliderCell key="cell" continuous="YES" state="on" alignment="left" minValue="5" maxValue="100" doubleValue="90" tickMarkPosition="below" numberOfTickMarks="20" allowsTickMarkValuesOnly="YES" sliderType="linear" id="RSV-fg-slider-cell"/>
</slider>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RSV-bg-label">
<rect key="frame" x="15" y="108" width="210" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Background Opacity" id="RSV-bg-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RSV-bg-value">
<rect key="frame" x="247" y="108" width="44" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="50%" id="RSV-bg-value-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" id="RSV-bg-slider">
<rect key="frame" x="15" y="74" width="276" height="28"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<sliderCell key="cell" continuous="YES" state="on" alignment="left" minValue="5" maxValue="100" doubleValue="50" tickMarkPosition="below" numberOfTickMarks="20" allowsTickMarkValuesOnly="YES" sliderType="linear" id="RSV-bg-slider-cell"/>
</slider>
<button verticalHuggingPriority="750" id="RSV-float-checkbox">
<rect key="frame" x="15" y="50" width="277" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Float rulers above other applications" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="RSV-float-cell">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="RSV-shadow-checkbox">
<rect key="frame" x="15" y="22" width="277" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Show ruler shadow" bezelStyle="regularSquare" imagePosition="left" inset="2" id="RSV-shadow-cell">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</subviews>
<point key="canvasLocation" x="141" y="209.5"/>
</customView>
</objects>
</document>
Loading