Skip to content

Commit

Permalink
Mass rename
Browse files Browse the repository at this point in the history
This renames `ColorWell` to `CWColorWell` and `ColorWellView` to `ColorWell`
  • Loading branch information
jordanbaird committed Dec 17, 2023
1 parent 0f9987f commit e86fee7
Show file tree
Hide file tree
Showing 25 changed files with 164 additions and 164 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add the following dependency to your `Package.swift` file:

### SwiftUI

Create a `ColorWellView` and add it to your view hierarchy. There are a wide range of initializers and modifiers to choose from, allowing you to set the color well's color, label, and style.
Create a `ColorWell` and add it to your view hierarchy. There are a wide range of initializers and modifiers to choose from, allowing you to set the color well's color, label, and style.

```swift
import SwiftUI
Expand All @@ -45,7 +45,7 @@ struct ContentView: View {

var body: some View {
VStack {
ColorWellView("Text Color", selection: $textColor)
ColorWell("Text Color", selection: $textColor)
.colorWellStyle(.expanded)

MyCustomTextEditor(textColor: $textColor)
Expand All @@ -56,14 +56,14 @@ struct ContentView: View {

### Cocoa

Create a `ColorWell` using one of the available initializers, or use an `IBOutlet` to create a connection to a Storyboard or NIB file. Respond to color changes using your preferred design pattern.
Create a `CWColorWell` using one of the available initializers, or use an `IBOutlet` to create a connection to a Storyboard or NIB file. Respond to color changes using your preferred design pattern.

```swift
import Cocoa
import ColorWellKit

class ViewController: NSViewController {
@IBOutlet var colorWell: ColorWell!
@IBOutlet var colorWell: CWColorWell!
@IBOutlet var textEditor: NSTextView!

override func viewDidLoad() {
Expand All @@ -73,7 +73,7 @@ class ViewController: NSViewController {
}
}

@IBAction func updateTextColor(sender: ColorWell) {
@IBAction func updateTextColor(sender: CWColorWell) {
textEditor.textColor = sender.color
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Overview

``ColorWell`` provides support for several common design patterns:
``CWColorWell`` provides support for several common design patterns:

### Key-value observing

To implement key-value observing, call the `observe(_:options:changeHandler:)` method with a key path to the color well's ``ColorWell/color`` property and store the returned observation.
To implement key-value observing, call the `observe(_:options:changeHandler:)` method with a key path to the color well's ``CWColorWell/color`` property and store the returned observation.

```swift
class MyCustomViewController: NSViewController {
let colorWell = ColorWell(style: .expanded)
let colorWell = CWColorWell(style: .expanded)
var observation: NSKeyValueObservation?

override func viewDidLoad() {
Expand All @@ -35,7 +35,7 @@ To implement the target-action mechanism, assign a target object and an action m

```swift
class MyCustomViewController: NSViewController {
let colorWell = ColorWell(style: .expanded)
let colorWell = CWColorWell(style: .expanded)

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -45,7 +45,7 @@ class MyCustomViewController: NSViewController {
colorWell.action = #selector(colorDidChange(_:))
}

@objc func colorDidChange(_ sender: ColorWell) {
@objc func colorDidChange(_ sender: CWColorWell) {
print("Color changed to: \(sender.color)")
}
}
Expand All @@ -57,13 +57,13 @@ For more information about the target-action mechanism, see the [NSControl docum

> Note: The [`Combine`](https://developer.apple.com/documentation/combine) framework is available starting in macOS 10.15.
After importing `Combine`, call the `publisher(for:)` method with a key path to the color well's ``ColorWell/color`` property. Chain the publisher to a call to `sink(receiveValue:)`, and store the returned `Cancellable` to retain the subscription.
After importing `Combine`, call the `publisher(for:)` method with a key path to the color well's ``CWColorWell/color`` property. Chain the publisher to a call to `sink(receiveValue:)`, and store the returned `Cancellable` to retain the subscription.

```swift
import Combine

class MyCustomViewController: NSViewController {
let colorWell = ColorWell(style: .expanded)
let colorWell = CWColorWell(style: .expanded)
var cancellable: Cancellable?

override func viewDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``ColorWellKit/ColorWell``
# ``ColorWellKit/CWColorWell``

## Overview

Expand Down Expand Up @@ -33,5 +33,5 @@ Color wells provide an interface in your app for users to select custom colors.

### Supporting Types

- ``ColorWellDelegate``
- ``CWColorWellDelegate``
- ``Style-swift.enum``
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``ColorWellKit/ColorWell/Style-swift.enum/init(rawValue:)``
# ``ColorWellKit/CWColorWell/Style-swift.enum/init(rawValue:)``

Creates a new color well style with the specified raw value.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``ColorWellKit/ColorWell/Style-swift.enum``
# ``ColorWellKit/CWColorWell/Style-swift.enum``

## Topics

Expand Down
8 changes: 4 additions & 4 deletions Sources/ColorWellKit/Documentation.docc/ColorWellKit.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ColorWellKit is designed to mimic the appearance and behavior of the color well

## SwiftUI

Create a ``ColorWellView`` and add it to your view hierarchy. There are a wide range of initializers, as well as several modifiers to choose from, allowing you to set the color well's color, label, and style.
Create a ``ColorWell`` and add it to your view hierarchy. There are a wide range of initializers, as well as several modifiers to choose from, allowing you to set the color well's color, label, and style.

```swift
import SwiftUI
Expand All @@ -23,7 +23,7 @@ struct ContentView: View {

var body: some View {
VStack {
ColorWellView("Font Color", selection: $fontColor)
ColorWell("Font Color", selection: $fontColor)
.colorWellStyle(.expanded)

MyCustomTextEditor(fontColor: fontColor)
Expand All @@ -34,7 +34,7 @@ struct ContentView: View {

## Cocoa

Create a ``ColorWell`` using one of the available initializers. Respond to color changes using your preferred design pattern (see <doc:ColorObservation>):
Create a ``CWColorWell`` using one of the available initializers. Respond to color changes using your preferred design pattern (see <doc:ColorObservation>):

```swift
import Cocoa
Expand All @@ -47,7 +47,7 @@ class ContentViewController: NSViewController {
private var colorObservation: NSKeyValueObservation?

override func viewDidLoad() {
let colorWell = ColorWell(style: .expanded)
let colorWell = CWColorWell(style: .expanded)
colorWell.color = textEditor.fontColor

colorObservation = colorWell.observe(\.color) { colorWell, _ in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``ColorWellKit/ColorWellView``
# ``ColorWellKit/ColorWell``

Color wells provide an interface in your app for users to select custom colors. A color well displays the currently selected color, and provides options for selecting new colors. There are a number of styles to choose from, letting you customize the color well's appearance and behavior.

Expand All @@ -13,8 +13,8 @@ struct TextFormatter: View {

var body: some View {
HStack {
ColorWellView("Foreground", selection: $fgColor)
ColorWellView("Background", selection: $bgColor)
ColorWell("Foreground", selection: $fgColor)
ColorWell("Background", selection: $bgColor)
}
}
}
Expand All @@ -28,8 +28,8 @@ You can customize a color well's appearance using one of the available color wel

```swift
HStack {
ColorWellView("Foreground", selection: $fgColor)
ColorWellView("Background", selection: $bgColor)
ColorWell("Foreground", selection: $fgColor)
ColorWell("Background", selection: $bgColor)
}
.colorWellStyle(.expanded)
```
Expand All @@ -43,7 +43,7 @@ If you apply the style to a container view, as in the example above, all the col
When you use the ``ColorWellStyle/expanded`` or ``ColorWellStyle/minimal`` color well styles, the color well displays a popover with a grid of selectable color swatches. You can customize the colors that are displayed using the ``colorWellSwatchColors(_:)`` modifier:

```swift
ColorWellView(selection: $color)
ColorWell(selection: $color)
.colorWellSwatchColors([
.red, .orange, .yellow, .green, .blue, .indigo,
.purple, .brown, .gray, .white, .black,
Expand All @@ -56,7 +56,7 @@ ColorWellView(selection: $color)
As a control, the main action of a color well is always a color selection. By default, a color well's secondary action displays a popover with a grid of selectable color swatches, as described above. You can replace this behavior using the ``colorWellSecondaryAction(_:)`` modifier:

```swift
ColorWellView(selection: $color)
ColorWell(selection: $color)
.colorWellSecondaryAction {
print("color well was pressed")
}
Expand All @@ -68,17 +68,17 @@ The example above will print the text "color well was pressed" to the console in

### Creating a color well

- ``init(selection:supportsOpacity:)-49a1c``
- ``init(selection:supportsOpacity:label:)-1nrle``
- ``init(_:selection:supportsOpacity:)-94x5b``
- ``init(_:selection:supportsOpacity:)-23d0k``
- ``init(selection:supportsOpacity:)-9kcgy``
- ``init(selection:supportsOpacity:label:)-4cxuv``
- ``init(_:selection:supportsOpacity:)-3hqzm``
- ``init(_:selection:supportsOpacity:)-55b4y``

### Creating a Core Graphics color well

- ``init(selection:supportsOpacity:)-fckw``
- ``init(selection:supportsOpacity:label:)-5x6i1``
- ``init(_:selection:supportsOpacity:)-36cvh``
- ``init(_:selection:supportsOpacity:)-5i525``
- ``init(selection:supportsOpacity:)-4de3k``
- ``init(selection:supportsOpacity:label:)-3o6c7``
- ``init(_:selection:supportsOpacity:)-7metg``
- ``init(_:selection:supportsOpacity:)-2hp6``

### Modifying color wells

Expand Down
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Utilities/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ extension NSColorPanel {
if let color: NSColor = newValue[0].color {
self.color = color
}
for case let colorWell as ColorWell in newValue[1...] {
for case let colorWell as CWColorWell in newValue[1...] {
colorWell.updateColor(color, options: [
.informDelegate,
.informObservers,
Expand Down
8 changes: 4 additions & 4 deletions Sources/ColorWellKit/Utilities/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ extension LogCategory {
/// The main log category.
static let main = LogCategory(rawValue: "main")

/// The log category to use for the `ColorWellPopover` type.
static let popover = LogCategory(rawValue: "ColorWellPopover")
/// The log category to use for the `CWColorWellPopover` type.
static let popover = LogCategory(rawValue: "CWColorWellPopover")

/// The log category to use for the `ColorComponents` type.
static let components = LogCategory(rawValue: "ColorComponents")
/// The log category to use for the `CWColorComponents` type.
static let components = LogCategory(rawValue: "CWColorComponents")
}

/// Sends a message to the logging system using the given category and log level.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Utilities/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct Path {
static func segmentPath(
rect: CGRect,
controlSize: NSControl.ControlSize?,
segmentType: ColorWellSegment.Type,
segmentType: CWColorWellSegment.Type,
shouldClose: Bool = true
) -> Path {
// flatten the opposite edge to join up with the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//
// ColorWell.swift
// CWColorWell.swift
// ColorWellKit
//

import AppKit

/// A control that displays a user-selectable color value.
public class ColorWell: _ColorWellBaseControl {
public class CWColorWell: _CWColorWellBaseControl {

// MARK: Static Properties

private static let popoverStorage = ObjectAssociation<ColorWellPopover>()
private static let popoverStorage = ObjectAssociation<CWColorWellPopover>()

/// Hexadecimal strings used to construct the default colors shown
/// in a color well's popover.
Expand All @@ -34,7 +34,7 @@ public class ColorWell: _ColorWellBaseControl {
private var isExclusive = true

/// The color well's delegate object.
public weak var delegate: ColorWellDelegate?
public weak var delegate: CWColorWellDelegate?

/// A Boolean value that indicates whether the color well supports being
/// included in group selections.
Expand Down Expand Up @@ -65,7 +65,7 @@ public class ColorWell: _ColorWellBaseControl {
/// You can add and remove values to change the swatches that are displayed.
///
/// ```swift
/// let colorWell = ColorWell()
/// let colorWell = CWColorWell()
/// colorWell.swatchColors += [
/// .systemPurple,
/// .controlColor,
Expand Down Expand Up @@ -248,15 +248,15 @@ public class ColorWell: _ColorWellBaseControl {
///
/// - Returns: `true` on success, `false` otherwise.
@discardableResult
func makeAndShowPopover(relativeTo segment: ColorWellSegment) -> Bool {
func makeAndShowPopover(relativeTo segment: CWColorWellSegment) -> Bool {
if Self.popoverStorage[self] != nil {
// a popover is already being shown
return false
}
guard layoutView.segments.contains(segment) else {
return false
}
let popover = ColorWellPopover(colorWell: self)
let popover = CWColorWellPopover(colorWell: self)

// the popover is removed from storage when it is closed; we use the
// presence of the popover to determine whether the next call to this
Expand Down Expand Up @@ -284,7 +284,7 @@ public class ColorWell: _ColorWellBaseControl {

// set up a series of deferred blocks to execute in reverse order
// once the color has been set
var deferredBlocks = [(ColorWell) -> Void]()
var deferredBlocks = [(CWColorWell) -> Void]()

// these get executed regardless of the options passed in
deferredBlocks.append { colorWell in
Expand Down
Loading

0 comments on commit e86fee7

Please sign in to comment.