Skip to content

Commit

Permalink
Merge pull request #4 from ricobeck/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
trispo authored Sep 22, 2016
2 parents 72c326f + 858aaeb commit 71644da
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 78 deletions.
53 changes: 22 additions & 31 deletions Assets/osx/KFAboutWindow.xib
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="KFAboutWindowController">
<connections>
<outlet property="appIconImageView" destination="d1v-7U-eFh" id="YP7-JS-YLJ"/>
<outlet property="backgroundImageView" destination="Mai-NF-7SZ" id="10m-Jv-EuA"/>
<outlet property="backgroundView" destination="pAY-dC-RMX" id="UHh-p1-Hvf"/>
<outlet property="backgroundView" destination="2" id="HGm-AR-4tc"/>
<outlet property="bundleNameLabel" destination="jBb-2a-idr" id="r72-EN-fwg"/>
<outlet property="humanReadableCopyrightLabel" destination="TmW-xh-BIy" id="kl6-l6-ZPf"/>
<outlet property="scrollTextView" destination="s7r-p9-WmY" id="whF-h1-EN1"/>
Expand All @@ -25,7 +24,7 @@
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="KFAboutWindow" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="196" y="240" width="560" height="320"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="800"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="560" height="320"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -38,16 +37,16 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="HyX-dY-9qp"/>
</imageView>
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KPY-md-Kp1" customClass="KFGradientScrollView">
<rect key="frame" x="214" y="51" width="328" height="140"/>
<rect key="frame" x="214" y="51" width="328" height="142"/>
<clipView key="contentView" copiesOnScroll="NO" id="unt-4E-7mq">
<rect key="frame" x="0.0" y="0.0" width="328" height="142"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" selectable="NO" importsGraphics="NO" richText="NO" findStyle="panel" continuousSpellChecking="YES" verticallyResizable="YES" quoteSubstitution="YES" dashSubstitution="YES" smartInsertDelete="YES" id="s7r-p9-WmY" customClass="KFAutoScrollTextView">
<rect key="frame" x="0.0" y="0.0" width="328" height="142"/>
<textView editable="NO" selectable="NO" importsGraphics="NO" richText="NO" findStyle="panel" continuousSpellChecking="YES" quoteSubstitution="YES" dashSubstitution="YES" smartInsertDelete="YES" id="s7r-p9-WmY" customClass="KFAutoScrollTextView">
<rect key="frame" x="0.0" y="2" width="328" height="142"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="328" height="140"/>
<size key="minSize" width="328" height="142"/>
<size key="maxSize" width="463" height="10000000"/>
<attributedString key="textStorage">
<fragment content="Text">
Expand All @@ -58,8 +57,6 @@
</fragment>
</attributedString>
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="328" height="140"/>
<size key="maxSize" width="463" height="10000000"/>
<connections>
<binding destination="-2" name="attributedString" keyPath="self.attributedString" id="qEi-SN-Ok3"/>
<binding destination="-2" name="editable" keyPath="self.disabledOption" id="cBH-xi-Vty"/>
Expand Down Expand Up @@ -92,7 +89,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="14L-ty-8V1">
<rect key="frame" x="212" y="199" width="332" height="15"/>
<rect key="frame" x="212" y="209" width="332" height="15"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="h36-g5-cyM">
<font key="font" size="11" name="HelveticaNeue"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -138,7 +135,7 @@
<constraint firstItem="Mai-NF-7SZ" firstAttribute="leading" secondItem="pAY-dC-RMX" secondAttribute="leading" id="A84-rp-KXB"/>
<constraint firstItem="d1v-7U-eFh" firstAttribute="top" secondItem="jBb-2a-idr" secondAttribute="top" id="IiF-gG-ppj"/>
<constraint firstItem="d1v-7U-eFh" firstAttribute="top" secondItem="pAY-dC-RMX" secondAttribute="top" constant="20" symbolic="YES" id="RTQ-af-ZyD"/>
<constraint firstItem="14L-ty-8V1" firstAttribute="top" secondItem="jBb-2a-idr" secondAttribute="bottom" constant="8" symbolic="YES" id="RZ5-T2-1eu"/>
<constraint firstItem="14L-ty-8V1" firstAttribute="top" secondItem="jBb-2a-idr" secondAttribute="bottom" constant="-2" id="RZ5-T2-1eu"/>
<constraint firstItem="TmW-xh-BIy" firstAttribute="trailing" secondItem="KPY-md-Kp1" secondAttribute="trailing" id="ST5-Eq-dTR"/>
<constraint firstItem="KPY-md-Kp1" firstAttribute="leading" secondItem="TmW-xh-BIy" secondAttribute="leading" id="SxE-fM-drQ"/>
<constraint firstAttribute="trailing" secondItem="14L-ty-8V1" secondAttribute="trailing" constant="20" symbolic="YES" id="WAa-ZF-8Qv"/>
Expand All @@ -150,15 +147,12 @@
<constraint firstItem="KPY-md-Kp1" firstAttribute="trailing" secondItem="14L-ty-8V1" secondAttribute="trailing" id="oeG-d5-pqm"/>
<constraint firstItem="TmW-xh-BIy" firstAttribute="top" secondItem="KPY-md-Kp1" secondAttribute="bottom" constant="16" id="qAV-bF-KGg"/>
<constraint firstAttribute="trailing" secondItem="jBb-2a-idr" secondAttribute="trailing" constant="20" symbolic="YES" id="r8g-Hl-Gpe"/>
<constraint firstItem="KPY-md-Kp1" firstAttribute="top" secondItem="14L-ty-8V1" secondAttribute="bottom" constant="8" symbolic="YES" id="u5P-vH-Oyp"/>
<constraint firstItem="KPY-md-Kp1" firstAttribute="top" secondItem="14L-ty-8V1" secondAttribute="bottom" constant="16" id="u5P-vH-Oyp"/>
</constraints>
</customView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KpE-Xt-NXa">
<rect key="frame" x="385" y="8" width="161" height="32"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="EA8-Yf-pEA"/>
</constraints>
<buttonCell key="cell" type="push" title="Acknowledgements" bezelStyle="rounded" alignment="center" refusesFirstResponder="YES" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oGf-Ti-3qh">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KpE-Xt-NXa" customClass="ColoredButton" customModule="KFAboutWindow" customModuleProvider="target">
<rect key="frame" x="254" y="15" width="115" height="19"/>
<buttonCell key="cell" type="roundRect" title="Acknowledgements" bezelStyle="roundedRect" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyDown" inset="2" id="oGf-Ti-3qh">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
Expand All @@ -172,12 +166,9 @@
<binding destination="-2" name="title" keyPath="self.toggleButtonText" id="JQ4-6v-TlA"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IWS-wC-pcR">
<rect key="frame" x="172" y="8" width="213" height="32"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="jvZ-uW-Q86"/>
</constraints>
<buttonCell key="cell" type="push" title="Visit BundleName's Website" bezelStyle="rounded" alignment="center" refusesFirstResponder="YES" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="eik-H8-4NU">
<button horizontalHuggingPriority="1000" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IWS-wC-pcR" customClass="ColoredButton" customModule="KFAboutWindow" customModuleProvider="target">
<rect key="frame" x="377" y="15" width="163" height="19"/>
<buttonCell key="cell" type="roundRect" title="Visit BundleName's Website" bezelStyle="roundedRect" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyDown" inset="2" id="eik-H8-4NU">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
Expand All @@ -198,11 +189,11 @@
</subviews>
<constraints>
<constraint firstItem="pAY-dC-RMX" firstAttribute="top" secondItem="2" secondAttribute="top" id="Hi1-jq-fXt"/>
<constraint firstAttribute="trailing" secondItem="KpE-Xt-NXa" secondAttribute="trailing" constant="20" symbolic="YES" id="O7e-Ce-07Z"/>
<constraint firstAttribute="bottom" secondItem="IWS-wC-pcR" secondAttribute="bottom" constant="15" id="R0B-lI-XWC"/>
<constraint firstAttribute="bottom" secondItem="KpE-Xt-NXa" secondAttribute="bottom" constant="15" id="VLU-Ce-sJa"/>
<constraint firstItem="KpE-Xt-NXa" firstAttribute="baseline" secondItem="IWS-wC-pcR" secondAttribute="baseline" id="TZC-20-1vk"/>
<constraint firstAttribute="trailing" secondItem="IWS-wC-pcR" secondAttribute="trailing" constant="20" id="WNF-gt-NUM"/>
<constraint firstAttribute="bottom" secondItem="IWS-wC-pcR" secondAttribute="bottom" constant="15" id="mbk-zK-eos"/>
<constraint firstItem="pAY-dC-RMX" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="nKL-xr-mBc"/>
<constraint firstItem="KpE-Xt-NXa" firstAttribute="leading" secondItem="IWS-wC-pcR" secondAttribute="trailing" constant="12" symbolic="YES" id="oNv-97-7vt"/>
<constraint firstItem="IWS-wC-pcR" firstAttribute="leading" secondItem="KpE-Xt-NXa" secondAttribute="trailing" constant="8" id="pBR-7p-xeE"/>
<constraint firstAttribute="trailing" secondItem="pAY-dC-RMX" secondAttribute="trailing" constant="-2" id="yb8-5M-iIQ"/>
</constraints>
</view>
Expand Down
68 changes: 68 additions & 0 deletions Classes/osx/ColoredButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// ColoredButton.swift
// KFAboutWindowPreview
//
// Created by Gunnar Herzog on 22/09/2016.
// Copyright © 2016 KF Interactive. All rights reserved.
//

import AppKit

@available(OSX 10.10, *)
public class ColoredButton: NSButton {
public var color: NSColor = .black {
didSet {
redraw()
}
}

required public init?(coder: NSCoder) {
super.init(coder: coder)
redraw()
}

public override var title: String {
didSet {
redraw()
}
}

private func redraw() {
wantsLayer = true
layerContentsRedrawPolicy = .onSetNeedsDisplay
layer?.cornerRadius = 10
layer?.borderWidth = 1.0
layer?.borderColor = color.cgColor

let paragraphStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.alignment = .center
attributedTitle = NSAttributedString(string: title, attributes: [NSFontAttributeName: font!, NSParagraphStyleAttributeName: paragraphStyle, NSForegroundColorAttributeName: color])
}

override public var wantsUpdateLayer:Bool{
return true
}

override public func updateLayer() {
if isHighlighted {
layer?.backgroundColor = color.lighter.cgColor
} else {
layer?.backgroundColor = nil
}
super.updateLayer()
}

override public var intrinsicContentSize: NSSize {
let width = attributedTitle.size().width

var size = super.intrinsicContentSize
size.width = width + 3.0 * (layer?.cornerRadius ?? 0)
return size
}
}

extension NSColor {
var lighter: NSColor {
return NSColor(calibratedRed: redComponent, green: greenComponent, blue: blueComponent, alpha: 0.15)
}
}
40 changes: 11 additions & 29 deletions Classes/osx/KFAboutWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "KFAutoScrollTextView.h"
#import "KFAboutWindowStyleModel.h"
#import "KFGradientScrollView.h"
#import <KFAboutWindow/KFAboutWindow-Swift.h>

#import <QuartzCore/QuartzCore.h>

Expand All @@ -35,8 +36,8 @@ @interface KFAboutWindowController ()
@property (weak) IBOutlet KFGradientScrollView *scrollView;
@property (unsafe_unretained) IBOutlet KFAutoScrollTextView *scrollTextView;

@property (weak) IBOutlet NSButton *toggleDisplayButton;
@property (weak) IBOutlet NSButton *visitWebsiteButton;
@property (weak) IBOutlet ColoredButton *toggleDisplayButton;
@property (weak) IBOutlet ColoredButton *visitWebsiteButton;

@property (nonatomic, copy) NSAttributedString *attributedString;
@property (nonatomic) KFAboutDisplayMode displayMode;
Expand Down Expand Up @@ -74,7 +75,7 @@ - (void)windowDidLoad
[self.backgroundView setWantsLayer:YES];

self.backgroundViewSeparator = [CALayer layer];
self.backgroundViewSeparator.borderWidth = 1;
self.backgroundViewSeparator.borderWidth = 0;
CGRect borderRect = CGRectInset(self.backgroundView.layer.bounds, -2, -1);
borderRect.origin.y += 1;
self.backgroundViewSeparator.frame = borderRect;
Expand Down Expand Up @@ -194,6 +195,13 @@ - (void)applyStyle:(KFAboutWindowStyleModel *)styleModel
if (styleModel.humanReadableCopyrightLabelFont) {
self.humanReadableCopyrightLabel.font = styleModel.humanReadableCopyrightLabelFont;
}

if (styleModel.visitWebsiteButtonColor) {
self.visitWebsiteButton.color = styleModel.visitWebsiteButtonColor;
}
if (styleModel.toggleDisplayButtonColor) {
self.toggleDisplayButton.color = styleModel.toggleDisplayButtonColor;
}
}

#pragma mark - Window show/hide
Expand All @@ -208,36 +216,10 @@ - (void)showWindow:(id)sender

[self updateModeValues];

[self addObservers];
[super showWindow:sender];

}


- (void)addObservers
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignKeyOrMainNotification:) name:NSWindowDidResignKeyNotification object:self.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignKeyOrMainNotification:) name:NSWindowDidResignMainNotification object:self.window];
}


- (void)windowDidResignKeyOrMainNotification:(NSNotification *)notification
{
[self removeObservers];
[self.window setIsVisible:NO];
[self.scrollTextView stopScrolling];

self.displayMode = KFAboutDisplayModeCredits;
[self updateModeValues];
}


- (void)removeObservers
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignMainNotification object:self];
}

#pragma mark - Keystroke Handling

- (void)setupEventMonitor {
Expand Down
3 changes: 3 additions & 0 deletions Classes/osx/KFAboutWindowStyleModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
@property (nonatomic, strong) NSFont *versionLabelFont;
@property (nonatomic, strong) NSFont *humanReadableCopyrightLabelFont;

@property (nonatomic, strong) NSColor *visitWebsiteButtonColor;
@property (nonatomic, strong) NSColor *toggleDisplayButtonColor;

+ (KFAboutWindowStyleModel *)defaultStyle;

@end
3 changes: 3 additions & 0 deletions Classes/osx/KFAboutWindowStyleModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ + (KFAboutWindowStyleModel *)defaultStyle {
defaultStyle.versionLabelFont = [NSFont boldSystemFontOfSize:11.0];
defaultStyle.humanReadableCopyrightLabelFont = [NSFont systemFontOfSize:11.0];

defaultStyle.visitWebsiteButtonColor = [NSColor blackColor];
defaultStyle.toggleDisplayButtonColor = [NSColor blackColor];

return defaultStyle;
}

Expand Down
Loading

0 comments on commit 71644da

Please sign in to comment.