Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Dec 16, 2023
1 parent acd5f08 commit 4721ef7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 148 deletions.
71 changes: 0 additions & 71 deletions Sources/ColorWellKit/Utilities/Geometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,74 +90,3 @@ enum Edge {
}
}
}

// MARK: - PaddingRanges

/// A type that contains the minimum and maximum padding amounts
/// to apply to the edges of a rectangle.
struct PaddingRanges: Hashable {
/// The padding range for the leading edge of the rectangle.
var leading: PaddingRange
/// The padding range for the trailing edge of the rectangle.
var trailing: PaddingRange
/// The padding range for the top edge of the rectangle.
var top: PaddingRange
/// The padding range for the bottom edge of the rectangle.
var bottom: PaddingRange

/// A padding ranges instance whose ranges are all the empty
/// padding range.
static let empty = PaddingRanges(
leading: .empty,
trailing: .empty,
top: .empty,
bottom: .empty
)

/// Returns a new instance that is the result of adding the
/// ranges of another instance to the ranges of this instance.
func adding(_ other: PaddingRanges) -> PaddingRanges {
PaddingRanges(
leading: leading.adding(other.leading),
trailing: trailing.adding(other.trailing),
top: top.adding(other.top),
bottom: bottom.adding(other.bottom)
)
}
}

extension PaddingRanges {
/// A type that contains a minimum and maximum amount of padding
/// to apply an edge of a rectangle.
struct PaddingRange: Hashable {
/// The minimum padding value of the range.
var min: CGFloat?
/// The maximum padding value of the range.
var max: CGFloat?

/// The empty padding range.
static let empty = PaddingRange(min: nil, max: nil)

/// Returns a padding range with the given minimum and maximum
/// padding values.
static func range(min: CGFloat? = nil, max: CGFloat? = nil) -> PaddingRange {
PaddingRange(min: min, max: max)
}

/// Returns a new padding range that is the result of adding the
/// values of another padding range to the values of this range.
func adding(_ other: PaddingRange) -> PaddingRange {
func add(_ value1: CGFloat?, _ value2: CGFloat?) -> CGFloat? {
if value1 == nil && value2 == nil {
return nil
}
return (value1 ?? 0) + (value2 ?? 0)
}

return PaddingRange(
min: add(min, other.min),
max: add(max, other.max)
)
}
}
}
60 changes: 0 additions & 60 deletions Sources/ColorWellKit/Utilities/IdentifiableBlock.swift

This file was deleted.

9 changes: 0 additions & 9 deletions Sources/ColorWellKit/Utilities/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,6 @@ struct Path {
path.stroke()
}

/// Adds the path to the current context's clipping path.
func clip(using rule: CGPathFillRule = .winding) {
guard let context = NSGraphicsContext.current else {
return
}
context.cgContext.addPath(cgPath())
context.cgContext.clip(using: rule)
}

/// Returns a stroked version of the path.
func stroked(
lineWidth: CGFloat,
Expand Down
13 changes: 5 additions & 8 deletions Sources/ColorWellKit/Views/Cocoa/ColorWellPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ extension ColorWellPopover {
}

@discardableResult
private func addSwatchRow(with swatches: [ColorSwatch], swatchSize: NSSize) -> NSGridRow {
private func addSwatchRow(with swatches: [ColorSwatch]) -> NSGridRow {
let row = addRow(with: swatches)
self.swatches.append(contentsOf: swatches)
return row
Expand All @@ -177,28 +177,25 @@ extension ColorWellPopover {
return
}

let columnCount = 6
let swatchSize = NSSize(width: 37, height: 20)

var currentSwatches = [ColorSwatch]()

for color in colorWell.swatchColors {
if currentSwatches.count >= columnCount {
addSwatchRow(with: currentSwatches, swatchSize: swatchSize)
if currentSwatches.count >= 6 {
addSwatchRow(with: currentSwatches)
currentSwatches.removeAll()
}
currentSwatches.append(
ColorSwatch(
color: color,
size: swatchSize,
size: NSSize(width: 37, height: 20),
colorWell: colorWell,
swatchLayout: self
)
)
}

if !currentSwatches.isEmpty {
addSwatchRow(with: currentSwatches, swatchSize: swatchSize)
addSwatchRow(with: currentSwatches)
}
}

Expand Down

0 comments on commit 4721ef7

Please sign in to comment.