Skip to content

Commit

Permalink
Merge branch 'master' of github.com:boinx/BXSwiftUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
peterb180369 committed Oct 17, 2018
2 parents 00a33bd + 12b6809 commit a4b9ef5
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 1,082 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ fastlane/screenshots
fastlane/test_output

.DS_Store
.bx_build_env
Artifacts
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ os: osx
xcode_project: BXSwiftUtils.xcodeproj
before_install:
- gem install xcpretty
env:
global:
# GH_TOKEN
- secure: Chw5iyaWS4vid3Eoam8ouuhmZ+Gb65FxyJZsHH0wXfgXTR8T3CCx0lJa2JPFjFw8gY+pkvhyVzMGqqDGyiPK80La2Ah5wHWDurvdM9oLVT1OhloQPGKRZIwn35xVVhkQnYz+vs4pPb4/quVAtfMStCUZ4aKbXmrFh5sKQtvXzK3wwYvfWOnbxy9TJk0LYm+EHHktp541TNC2/BBNG7glQp5tzGX/nFxdE58bOWRZzF6ZDILd/hzDMCw8kyUC8305c+WqivpWK+n8yC4rT+pGvJt2RstcjcS8I2kb4ZNSBoiVT8ZWXFMP/dwSXDPMXdi8OJNfd3MGPC5SXeY1rpTNidbzwkhnlQLOqcUVVUeQtZfhfukjw2EFj0b9c4kKfE7zQxUHShcC6/iNCz5MplgoCXUZjrCI1Wacr7GUqRh+SZl6dE/oua8FcwihIWRrJdKIn6s0nu18RipkPsI3U1h74792kS1CmaN3oigSj5hJbrg2ygziWf3Zlb8CcpLhqZWJscIPo+MU1/lGOysKJ4ZI6pKRBZdKeu0OYjdx9GGU4ZtAuwR4+3QXtYD4C+KY4DdoKg8Hi/4CRcjyiAafD6yxBUoOGhj2Kgm+9eNnl2zYdPtUC57bHyHb0uMY73QulxJqFYxozYzu1euk9xzsZxvcs676Vph2iUNMFE4HSbz2LY8=
# Don't build tags as the build script itself creates new tags...
if: tag IS blank
matrix:
include:
- osx_image: xcode9.2
Expand All @@ -17,9 +23,21 @@ matrix:
env: SCHEME="BXSwiftUtils-macOS" DESTINATION="platform=macOS,arch=x86_64"
- osx_image: xcode10
env: SCHEME="BXSwiftUtils-iOS" DESTINATION="platform=iOS Simulator,name=iPhone X,OS=12.0"
- osx_image: xcode10
env: CREATE_RELEASE="true"
script: sh deploy.sh
script: set -o pipefail; xcodebuild -scheme "$SCHEME" -destination "$DESTINATION" clean build test | xcpretty
notifications:
slack:
template:
- "%{repository_slug}@%{branch} (<%{compare_url}|%{commit}>) by %{author} %{result} in %{duration}"
secure: UovCzpghaeeBGXjTjvZGMr0jWpxwdOaT6tkGlzdOjwaMK8yS8EId7pP3/voe5FFt60t9QJtXi53dy//jccfCOKGDqmAyn71QnSG3Pw5wuBdNwTS+6EMWFJeJzcp/5mvbdxzfTUnmgdJYAUdcfQqcSdccQe/lPr9kvxO5nDuXGI+Tboofb2/DazktmRrbM8Dlq61q2jYrZ4KQihtBLlcl3+XZsWL2+Qfs4arG5S7DZjhrDWpTUYw8FPvumsIZ8j4PuvfKDEqB8J139bRMuj+NbLO+7Ki2Wucg96XPPf7co4qsLM8FMUN5GG3DReIKqR4+K8BQadpp8hJXtNqfRSG8miqMMe7hONwLXcVGHALCUHEy19JhWLeHYdpMMoVTnFG9qG4X39GDdCpPphCRCRT0HqJyljpIj1PSXPHc2W1Zy6mQa9C6bJ2zN9CGBmG6Pf5/glbtx7ahmUQcnFMgnysnupffa01akDjOvDs742lyxfKdAHasvY27TtOwh6yjUa5HrSuYXo5XZ3oYslpUAAeWEOpykNhgmRnUU5tkLMH8/R3CGMA8hyTPnbLXFElmycSiu8pChXFY8B7EbjqnbGGir3ebsNyUtByEUwKgbMRz6EYJZoMVCVRcY5pd93Kyqe4nYJSohrrabhwVoa1GoEJHtKeypC9e0UIgAYtkHEg6Rlc=
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: ezqVw0RZCz55IKJNs3mQboM2r1WbiyJnXI1gCMsMOicvp++NXR1X7eJVdJG/uho+/Pb1fQMPjyQeLUoAvVZste1LovnfJy+0PYup2fvQHGPtzntpaVUBSmPEvTRsOVbWdMkHnxztTdJZYoUMfQHtdm1R3rFSen41FNplc3INAeNtYVeGXVXDpRJ7lwOov+G1SgmMlYns10eT2S+6Iw/F9BK8eQMwShtM8JedI+Hy9e5UQ9O3qk36g2neYDTLR8fKVp8Gq7rUta5qP/j1ZcC9BZHawzsivaAfWio3PpV4UZXr7I+w1JQp9PQdbNJ4VZqYNBgwgRSF5eLHD6WV9oxhFMkZ0evh/90quFN+FTzXz16u2aSOJ/E83aqoaFVTy4ZNFppt4MmDlWLGW1AZDJyJt4a4wX7If06UPlQ1G3mR6kJxwgFW/wRxAKeSF1xiAeizA/FYnNiOfuq942LB+1BOTokE+50EFME9nvxYQzr66Z3v+G9SLFeDxTtEYsmjqOAJSKLf4wKG11cpYNzY+E0eRuxZGq278ukbYLkH2d8IEKKqRmTaan/ZhNAZUsS9go1hBlBJMiLgTCbCKuzb3GiqaQRQ71j8/sK2anPCpogJVidgv2gpHXg1E5tlXNevUJNlmBPtWReRRaNTLbEgNIayLwF2wh8IPgle3PxrtGoMPPA=
file: Artifacts/*
file_glob: true
on:
condition: $CREATE_RELEASE = true
125 changes: 81 additions & 44 deletions BXSwiftUtils.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

41 changes: 0 additions & 41 deletions BXSwiftUtils/AppKit/BXMenuItem.swift

This file was deleted.

70 changes: 0 additions & 70 deletions BXSwiftUtils/AppKit/NSEvent+ModifierKeys.swift

This file was deleted.

20 changes: 0 additions & 20 deletions BXSwiftUtils/AppKit/NSMenu+Concatenation.swift

This file was deleted.

38 changes: 0 additions & 38 deletions BXSwiftUtils/AppKit/NSMenuItem+ConvenienceInit.swift

This file was deleted.

38 changes: 36 additions & 2 deletions BXSwiftUtils/KVO/KVO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,45 @@

import Foundation

// Importing AppKit is needed for the NSIsControllerMarker() function. On iOS BXSwiftUtils provides its own
// implementation of this function.
// Importing AppKit is needed for the NSIsControllerMarker() function. For iOS, provide our own implementation of this function.

#if os(macOS)

import AppKit

#elseif os(iOS)

public let NSNoSelectionMarker = "NSNoSelectionMarker" as AnyObject
public let NSMultipleValuesMarker = "NSMultipleValuesMarker" as AnyObject
public let NSNotApplicableMarker = "NSNotApplicableMarker" as AnyObject

public func NSIsControllerMarker(_ value:Any?) -> Bool
{
let object = value as AnyObject

return object === NSNoSelectionMarker ||
object === NSMultipleValuesMarker ||
object === NSNotApplicableMarker
}

public func NSIsMultipleValuesMarker(_ value:Any?) -> Bool
{
let object = value as AnyObject
return object === NSMultipleValuesMarker
}

public func NSIsNoSelectionMarker(_ value:Any?) -> Bool
{
let object = value as AnyObject
return object === NSNoSelectionMarker
}

public func NSIsNotApplicableMarker(_ value:Any?) -> Bool
{
let object = value as AnyObject
return object === NSNotApplicableMarker
}

#endif


Expand Down
51 changes: 51 additions & 0 deletions BXSwiftUtils/Math & Geometry/CACornerMask+Convenience.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// CACornerMask+Accessors.swift
// BXSwiftUtils
//
// Created by Stefan Fochler on 16.10.18.
// Copyright © 2018 Boinx Software Ltd. & Imagine GbR. All rights reserved.
//

import QuartzCore.CoreAnimation

public extension CACornerMask
{
public static let allCorners: CACornerMask = [
.layerMaxXMaxYCorner,
.layerMaxXMinYCorner,
.layerMinXMaxYCorner,
.layerMinXMinYCorner
]

#if os(macOS)
public static let bottomCorners: CACornerMask = [
.layerMaxXMinYCorner,
.layerMinXMinYCorner
]

public static let topCorners: CACornerMask = [
.layerMinXMaxYCorner,
.layerMaxXMaxYCorner
]
#elseif os(iOS)
public static let bottomCorners: CACornerMask = [
.layerMaxXMaxYCorner,
.layerMinXMaxYCorner
]

public static let topCorners: CACornerMask = [
.layerMinXMinYCorner,
.layerMaxXMinYCorner
]
#endif

public static let leftCorners: CACornerMask = [
.layerMinXMinYCorner,
.layerMinXMaxYCorner
]

public static let rightCorners: CACornerMask = [
.layerMaxXMinYCorner,
.layerMaxXMaxYCorner
]
}
73 changes: 73 additions & 0 deletions BXSwiftUtils/Math & Geometry/CGPath+RoundedRect.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// CGPath+RoundedRect.swift
// BXSwiftUtils
//
// Created by Stefan Fochler on 16.10.18.
// Copyright © 2018 Boinx Software Ltd. & Imagine GbR. All rights reserved.
//

import Foundation
import QuartzCore.CoreAnimation

public extension CGPath
{
/**
Creates the path of a rounded rect of size `bounds` where only the cordners of `corners` are rounded using `radius`.

- parameter bounds: The outer bounds of the rect.
- parameter corners: The corner mask containing the corners to be rounded. If empty, no corners will be rounded.
- parameter radius: The radius to be applied to the rounded corners.
*/
public static func roundedRect(inBounds bounds: CGRect, corners: CACornerMask, radius: CGFloat) -> CGPath
{
let path = CGMutablePath()

if corners.contains(.layerMinXMaxYCorner)
{
let start = CGPoint(x: bounds.minX, y: bounds.maxY - radius)
path.move(to: start)
path.addArc(tangent1End: start, tangent2End: CGPoint(x: bounds.minX + radius, y: bounds.maxY), radius: radius)
}
else
{
path.move(to: CGPoint(x: bounds.minX, y: bounds.maxY))
}

if corners.contains(.layerMaxXMaxYCorner)
{
let start = CGPoint(x: bounds.maxX - radius, y: bounds.maxY)
path.addLine(to: start)
path.addArc(tangent1End: start, tangent2End: CGPoint(x: bounds.maxX, y: bounds.maxY - radius), radius: radius)
}
else
{
path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.maxY))
}

if corners.contains(.layerMaxXMinYCorner)
{
let start = CGPoint(x: bounds.maxX, y: bounds.minY + radius)
path.addLine(to: start)
path.addArc(tangent1End: start, tangent2End: CGPoint(x: bounds.maxX - radius, y: bounds.minY), radius: radius)
}
else
{
path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.minY))
}

if corners.contains(.layerMinXMinYCorner)
{
let start = CGPoint(x: bounds.minX + radius, y: bounds.minY)
path.addLine(to: start)
path.addArc(tangent1End: start, tangent2End: CGPoint(x: bounds.minX, y: bounds.minY + radius), radius: radius)
}
else
{
path.addLine(to: CGPoint(x: bounds.minX, y: bounds.minY))
}

path.closeSubpath()

return path
}
}
Loading

0 comments on commit a4b9ef5

Please sign in to comment.