diff --git a/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.init(rawValue:).md b/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.init(rawValue:).md index a58bbc2..a65e117 100644 --- a/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.init(rawValue:).md +++ b/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.init(rawValue:).md @@ -6,10 +6,10 @@ If the specified raw value does not correspond to any of the existing color well ```swift print(Style(rawValue: 0)) -// Prints "Optional(Style.standard)" +// Prints "Optional(Style.default)" print(Style(rawValue: 1)) -// Prints "Optional(Style.swatches)" +// Prints "Optional(Style.minimal)" print(Style(rawValue: 2)) // Prints "Optional(Style.expanded)" diff --git a/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.md b/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.md index a144b2d..18e34ee 100644 --- a/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.md +++ b/Sources/ColorWellKit/Documentation.docc/Cocoa/Extensions/ColorWell/Style/Style.md @@ -4,10 +4,15 @@ ### Getting the available styles -- ``standard`` -- ``swatches`` +- ``default`` +- ``minimal`` - ``expanded`` ### Creating a style from a raw value - ``init(rawValue:)`` + +### Deprecated styles + +- ``standard`` +- ``swatches`` diff --git a/Sources/ColorWellKit/Documentation.docc/Resources/standard-style@2x.png b/Sources/ColorWellKit/Documentation.docc/Resources/default-style@2x.png similarity index 100% rename from Sources/ColorWellKit/Documentation.docc/Resources/standard-style@2x.png rename to Sources/ColorWellKit/Documentation.docc/Resources/default-style@2x.png diff --git a/Sources/ColorWellKit/Documentation.docc/Resources/standard-style~dark@2x.png b/Sources/ColorWellKit/Documentation.docc/Resources/default-style~dark@2x.png similarity index 100% rename from Sources/ColorWellKit/Documentation.docc/Resources/standard-style~dark@2x.png rename to Sources/ColorWellKit/Documentation.docc/Resources/default-style~dark@2x.png diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/ColorWellStyle.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/ColorWellStyle.md index 1b70f55..3f2d8f0 100644 --- a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/ColorWellStyle.md +++ b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/ColorWellStyle.md @@ -4,12 +4,19 @@ ### Types of styles -- ``StandardColorWellStyle`` -- ``SwatchesColorWellStyle`` +- ``DefaultColorWellStyle`` +- ``MinimalColorWellStyle`` - ``ExpandedColorWellStyle`` ### Creating a color well style +- ``ColorWellStyle/default`` +- ``ColorWellStyle/minimal`` +- ``ColorWellStyle/expanded`` + +### Deprecated styles + +- ``StandardColorWellStyle`` +- ``SwatchesColorWellStyle`` - ``ColorWellStyle/standard`` - ``ColorWellStyle/swatches`` -- ``ColorWellStyle/expanded`` diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/DefaultColorWellStyle.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/DefaultColorWellStyle.md new file mode 100644 index 0000000..f007eb1 --- /dev/null +++ b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/DefaultColorWellStyle.md @@ -0,0 +1,11 @@ +# ``ColorWellKit/DefaultColorWellStyle`` + +## Topics + +### Getting the style + +- ``ColorWellStyle/default`` + +### Creating a default color well style + +- ``init()`` diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/StandardColorWellStyle.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/Deprecated/StandardColorWellStyle.md similarity index 100% rename from Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/StandardColorWellStyle.md rename to Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/Deprecated/StandardColorWellStyle.md diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/SwatchesColorWellStyle.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/Deprecated/SwatchesColorWellStyle.md similarity index 100% rename from Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/SwatchesColorWellStyle.md rename to Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/Deprecated/SwatchesColorWellStyle.md diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/MinimalColorWellStyle.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/MinimalColorWellStyle.md new file mode 100644 index 0000000..0171fad --- /dev/null +++ b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellStyle/MinimalColorWellStyle.md @@ -0,0 +1,11 @@ +# ``ColorWellKit/MinimalColorWellStyle`` + +## Topics + +### Getting the style + +- ``ColorWellStyle/minimal`` + +### Creating a minimal color well style + +- ``init()`` diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellView.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellView.md index d87ee0d..c832859 100644 --- a/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellView.md +++ b/Sources/ColorWellKit/Documentation.docc/SwiftUI/Extensions/ColorWellView.md @@ -20,7 +20,7 @@ struct TextFormatter: View { } ``` -![Two color wells, both displayed in the standard style](standard-style) +![Two color wells, both displayed in the default style](default-style) ### Styling color wells diff --git a/Sources/ColorWellKit/Views/Cocoa/ColorWell.swift b/Sources/ColorWellKit/Views/Cocoa/ColorWell.swift index e0db961..60938d2 100644 --- a/Sources/ColorWellKit/Views/Cocoa/ColorWell.swift +++ b/Sources/ColorWellKit/Views/Cocoa/ColorWell.swift @@ -48,7 +48,7 @@ public class ColorWell: _ColorWellBaseControl { /// The action to perform when the color area of the color well is pressed. /// - /// By default, color wells with the ``Style-swift.enum/swatches`` or + /// By default, color wells with the ``Style-swift.enum/minimal`` or /// ``Style-swift.enum/expanded`` style display a popover with a grid of /// color swatches when the color area is pressed. If you specify a value /// for this property and the ``secondaryTarget`` property, clicks inside @@ -58,7 +58,7 @@ public class ColorWell: _ColorWellBaseControl { /// The target object that defines the action to perform when the color /// area of the color well is pressed. /// - /// By default, color wells with the ``Style-swift.enum/swatches`` or + /// By default, color wells with the ``Style-swift.enum/minimal`` or /// ``Style-swift.enum/expanded`` style display a popover with a grid of /// color swatches when the color area is pressed. If you specify a value /// for this property and the ``secondaryAction`` property, clicks inside diff --git a/Sources/ColorWellKit/Views/Cocoa/ColorWellBaseControl.swift b/Sources/ColorWellKit/Views/Cocoa/ColorWellBaseControl.swift index 2f609d8..afcecda 100644 --- a/Sources/ColorWellKit/Views/Cocoa/ColorWellBaseControl.swift +++ b/Sources/ColorWellKit/Views/Cocoa/ColorWellBaseControl.swift @@ -20,7 +20,7 @@ public class _ColorWellBaseControl: NSControl { struct BackingStorage { static let defaultColor = NSColor(red: 1, green: 1, blue: 1, alpha: 1) - static let defaultStyle = ColorWell.Style.standard + static let defaultStyle = ColorWell.Style.default static let defaultSize = NSSize(width: 38, height: 24) @@ -144,7 +144,7 @@ public class _ColorWellBaseControl: NSControl { // this implementation returns the same sizes as NSColorWell var size = BackingStorage.defaultSize switch backingStorage.style { - case .standard, .swatches: + case .default, .minimal: switch controlSize { case .large: size.height += 8 diff --git a/Sources/ColorWellKit/Views/Cocoa/Layout/ColorWellLayoutView.swift b/Sources/ColorWellKit/Views/Cocoa/Layout/ColorWellLayoutView.swift index 4436e09..c2296bc 100644 --- a/Sources/ColorWellKit/Views/Cocoa/Layout/ColorWellLayoutView.swift +++ b/Sources/ColorWellKit/Views/Cocoa/Layout/ColorWellLayoutView.swift @@ -116,11 +116,11 @@ class ColorWellLayoutView: NSGridView { return } switch colorWell.style { - case .standard: + case .default: layer.shadowRadius = 0.5 layer.shadowOpacity = 0.3 layer.shadowOffset = NSSize(width: 0, height: -0.25) - case .swatches: + case .minimal: layer.shadowRadius = 0 layer.shadowOpacity = 0 layer.shadowOffset = NSSize(width: 0, height: 0) @@ -139,10 +139,10 @@ class ColorWellLayoutView: NSGridView { } resetLayoutView() switch colorWell.style { - case .standard: + case .default: segments.append(ColorWellBorderedSwatchSegment(colorWell: colorWell)) widthConstant = 0 - case .swatches: + case .minimal: segments.append(ColorWellSinglePullDownSwatchSegment(colorWell: colorWell)) widthConstant = 0 case .expanded: @@ -179,7 +179,7 @@ class ColorWellLayoutView: NSGridView { ) .stroked(lineWidth: lineWidth) .nsBezierPath() - case .standard, .swatches: + case .default, .minimal: bezelPath = Path.fullColorWellPath( rect: bounds.insetBy(lineWidth / 2), controlSize: colorWell.controlSize diff --git a/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Content.swift b/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Content.swift index e46c9e3..29e570f 100644 --- a/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Content.swift +++ b/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Content.swift @@ -47,14 +47,14 @@ extension ColorWellPopover { let padding = with(colorWell.style) { style in switch style { - case .standard, .expanded: + case .default, .expanded: return ( leading: configuration.contentLayout.padding.leading.max ?? fallbackPadding, trailing: configuration.contentLayout.padding.trailing.max ?? fallbackPadding, top: configuration.contentLayout.padding.top.max ?? fallbackPadding, bottom: configuration.contentLayout.padding.bottom.max ?? fallbackPadding ) - case .swatches: + case .minimal: return ( leading: configuration.contentLayout.padding.leading.min ?? fallbackPadding, trailing: configuration.contentLayout.padding.trailing.min ?? fallbackPadding, diff --git a/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Layout.swift b/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Layout.swift index dbaed3b..9c49e6b 100644 --- a/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Layout.swift +++ b/Sources/ColorWellKit/Views/Cocoa/Popover/ColorWellPopover+Layout.swift @@ -32,7 +32,7 @@ extension ColorWellPopover { addRow(with: [swatchLayout]) swatchLayout.assignLayoutViewIfAble(self) - if colorWell.style == .swatches { + if colorWell.style == .minimal { let activationButton = NSButton( title: "Show More Colors…", target: self, diff --git a/Sources/ColorWellKit/Views/Cocoa/Style.swift b/Sources/ColorWellKit/Views/Cocoa/Style.swift index a33228d..549c828 100644 --- a/Sources/ColorWellKit/Views/Cocoa/Style.swift +++ b/Sources/ColorWellKit/Views/Cocoa/Style.swift @@ -10,14 +10,14 @@ extension ColorWell { @objc public enum Style: Int { /// The color well is displayed as a rectangular control that displays /// the selected color and shows the system color panel when clicked. - case standard = 0 + case `default` = 0 /// The color well is displayed as a rectangular control that displays /// the selected color and shows a popover containing the color well's /// swatch colors when clicked. /// /// The popover contains an option to show the system color panel. - case swatches = 1 + case minimal = 1 /// The color well is displayed as a segmented control that displays /// the selected color alongside a dedicated button to show the system @@ -33,12 +33,28 @@ extension ColorWell.Style: CustomStringConvertible { public var description: String { let prefix = String(describing: Self.self) + "." switch self { - case .standard: - return prefix + "standard" - case .swatches: - return prefix + "swatches" + case .default: + return prefix + "default" + case .minimal: + return prefix + "minimal" case .expanded: return prefix + "expanded" } } } + +// MARK: - Deprecated +extension ColorWell.Style { + /// The color well is displayed as a rectangular control that displays + /// the selected color and shows the system color panel when clicked. + @available(*, deprecated, renamed: "default") + public static let standard = Self.default + + /// The color well is displayed as a rectangular control that displays + /// the selected color and shows a popover containing the color well's + /// swatch colors when clicked. + /// + /// The popover contains an option to show the system color panel. + @available(*, deprecated, renamed: "minimal") + public static let swatches = Self.minimal +} diff --git a/Sources/ColorWellKit/Views/SwiftUI/ColorWellRepresentable.swift b/Sources/ColorWellKit/Views/SwiftUI/ColorWellRepresentable.swift index 619382f..9796f88 100644 --- a/Sources/ColorWellKit/Views/SwiftUI/ColorWellRepresentable.swift +++ b/Sources/ColorWellKit/Views/SwiftUI/ColorWellRepresentable.swift @@ -53,7 +53,7 @@ struct ColorWellRepresentable: NSViewRepresentable { override func computeIntrinsicContentSize(for controlSize: ControlSize) -> NSSize { var size = BackingStorage.defaultSize switch backingStorage.style { - case .standard, .swatches: + case .default, .minimal: switch controlSize { case .large: size.width += 17 diff --git a/Sources/ColorWellKit/Views/SwiftUI/ColorWellStyle.swift b/Sources/ColorWellKit/Views/SwiftUI/ColorWellStyle.swift index 5ca48ca..d358ba7 100644 --- a/Sources/ColorWellKit/Views/SwiftUI/ColorWellStyle.swift +++ b/Sources/ColorWellKit/Views/SwiftUI/ColorWellStyle.swift @@ -33,47 +33,47 @@ public protocol ColorWellStyle { var _configuration: _ColorWellStyleConfiguration { get } } -// MARK: - StandardColorWellStyle +// MARK: - DefaultColorWellStyle /// A color well style that displays the color well's color inside of a /// rectangular control, and toggles the system color panel when clicked. /// -/// You can also use ``standard`` to construct this style. -public struct StandardColorWellStyle: ColorWellStyle { - public let _configuration = _ColorWellStyleConfiguration(style: .standard) +/// You can also use ``default`` to construct this style. +public struct DefaultColorWellStyle: ColorWellStyle { + public let _configuration = _ColorWellStyleConfiguration(style: .default) - /// Creates an instance of the standard color well style. + /// Creates an instance of the default color well style. public init() { } } -extension ColorWellStyle where Self == StandardColorWellStyle { +extension ColorWellStyle where Self == DefaultColorWellStyle { /// A color well style that displays the color well's color inside of a /// rectangular control, and toggles the system color panel when clicked. - public static var standard: StandardColorWellStyle { - StandardColorWellStyle() + public static var `default`: DefaultColorWellStyle { + DefaultColorWellStyle() } } -// MARK: - SwatchesColorWellStyle +// MARK: - MinimalColorWellStyle /// A color well style that displays the color well's color inside of a /// rectangular control, and shows a popover containing the color well's /// swatch colors when clicked. /// -/// You can also use ``swatches`` to construct this style. -public struct SwatchesColorWellStyle: ColorWellStyle { - public let _configuration = _ColorWellStyleConfiguration(style: .swatches) +/// You can also use ``minimal`` to construct this style. +public struct MinimalColorWellStyle: ColorWellStyle { + public let _configuration = _ColorWellStyleConfiguration(style: .minimal) - /// Creates an instance of the swatches color well style. + /// Creates an instance of the minimal color well style. public init() { } } -extension ColorWellStyle where Self == SwatchesColorWellStyle { +extension ColorWellStyle where Self == MinimalColorWellStyle { /// A color well style that displays the color well's color inside of a /// rectangular control, and shows a popover containing the color well's /// swatch colors when clicked. - public static var swatches: SwatchesColorWellStyle { - SwatchesColorWellStyle() + public static var minimal: MinimalColorWellStyle { + MinimalColorWellStyle() } } @@ -103,4 +103,56 @@ extension ColorWellStyle where Self == ExpandedColorWellStyle { ExpandedColorWellStyle() } } + +// MARK: - Deprecated - + +// MARK: - StandardColorWellStyle + +/// A color well style that displays the color well's color inside of a +/// rectangular control, and toggles the system color panel when clicked. +/// +/// You can also use ``standard`` to construct this style. +@available(*, deprecated, renamed: "DefaultColorWellStyle") +public struct StandardColorWellStyle: ColorWellStyle { + public let _configuration = _ColorWellStyleConfiguration(style: .standard) + + /// Creates an instance of the standard color well style. + public init() { } +} + +@available(*, deprecated) +extension ColorWellStyle where Self == StandardColorWellStyle { + /// A color well style that displays the color well's color inside of a + /// rectangular control, and toggles the system color panel when clicked. + @available(*, deprecated, renamed: "default") + public static var standard: StandardColorWellStyle { + StandardColorWellStyle() + } +} + +// MARK: - SwatchesColorWellStyle + +/// A color well style that displays the color well's color inside of a +/// rectangular control, and shows a popover containing the color well's +/// swatch colors when clicked. +/// +/// You can also use ``swatches`` to construct this style. +@available(*, deprecated, renamed: "MinimalColorWellStyle") +public struct SwatchesColorWellStyle: ColorWellStyle { + public let _configuration = _ColorWellStyleConfiguration(style: .swatches) + + /// Creates an instance of the swatches color well style. + public init() { } +} + +@available(*, deprecated) +extension ColorWellStyle where Self == SwatchesColorWellStyle { + /// A color well style that displays the color well's color inside of a + /// rectangular control, and shows a popover containing the color well's + /// swatch colors when clicked. + @available(*, deprecated, renamed: "minimal") + public static var swatches: SwatchesColorWellStyle { + SwatchesColorWellStyle() + } +} #endif