Skip to content

Commit 2cdc89b

Browse files
committed
Added indicator size modifiers, which should close #2
1 parent 85b831c commit 2cdc89b

File tree

8 files changed

+84
-18
lines changed

8 files changed

+84
-18
lines changed

Demo/Shared/KeyboardDemoView.swift

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct KeyboardDemoView: View {
5353
.backgroundColor(.gray.opacity(0.5))
5454
.foregroundColor(.white.opacity(0.5))
5555
.cornerRadius(20)
56+
.indicatorSize(CGSize(width: 15, height: 15))
5657
.squareFrame(140)
5758
ArcKnob("FIL", value: $filter)
5859
.backgroundColor(.gray.opacity(0.5))

Demo/Shared/PitchModWheelDemoView.swift

+2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ struct PitchModWheelDemoView: View {
2424
PitchWheel(value: $pitchBend)
2525
.foregroundColor(.black.opacity(0.5))
2626
.cornerRadius(10)
27+
.indicatorHeight(100)
2728
.frame(width: proxy.size.width / 10)
2829
ModWheel(value: $modulation)
2930
.foregroundColor(.white.opacity(0.5))
31+
.indicatorHeight(100)
3032
.frame(width: proxy.size.width / 10)
3133
Spacer()
3234
}

Demo/Shared/RibbonDemoView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ struct RibbonDemoView: View {
2626
height: proxy.size.height / 10)
2727
Ribbon(position: $position)
2828
.foregroundColor(.white.opacity(0.5))
29-
.cornerRadius(20)
29+
.cornerRadius(100)
30+
.indicatorWidth(200)
3031
.frame(height: proxy.size.height / 10)
3132
}
3233
}

Demo/Shared/XYPadDemoView.swift

+2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ struct XYPadDemoView: View {
2929
XYPad(x: $x, y: $y)
3030
.foregroundColor(.white.opacity(0.5))
3131
.cornerRadius(10)
32+
.indicatorSize(CGSize(width: 60, height: 60))
3233
.squareFrame(proxy.size.height / 3)
3334
VStack{
3435
XYPad(x: $x, y: $y)
3536
.backgroundColor(.primary)
3637
.foregroundColor(.accentColor)
38+
.indicatorSize(CGSize(width: 120, height: 50))
3739
.cornerRadius(20)
3840
.squareFrame(proxy.size.height / 3)
3941

Sources/Controls/Implementations/ModWheel.swift

+19-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ extension ModWheel {
3939
internal init(location: Binding<Float>,
4040
backgroundColor: Color,
4141
foregroundColor: Color,
42-
cornerRadius: CGFloat) {
42+
cornerRadius: CGFloat,
43+
indicatorHeight: CGFloat) {
4344
self._location = location
4445
self.backgroundColor = backgroundColor
4546
self.foregroundColor = foregroundColor
4647
self.cornerRadius = cornerRadius
48+
self.indicatorHeight = indicatorHeight
4749
}
4850

4951

@@ -53,7 +55,8 @@ extension ModWheel {
5355
return .init(location: _location,
5456
backgroundColor: backgroundColor,
5557
foregroundColor: foregroundColor,
56-
cornerRadius: cornerRadius)
58+
cornerRadius: cornerRadius,
59+
indicatorHeight: indicatorHeight)
5760
}
5861

5962
/// Modifer to change the foreground color of the wheel
@@ -62,7 +65,8 @@ extension ModWheel {
6265
return .init(location: _location,
6366
backgroundColor: backgroundColor,
6467
foregroundColor: foregroundColor,
65-
cornerRadius: cornerRadius)
68+
cornerRadius: cornerRadius,
69+
indicatorHeight: indicatorHeight)
6670
}
6771

6872
/// Modifer to change the corner radius of the wheel and the indicator
@@ -71,6 +75,17 @@ extension ModWheel {
7175
return .init(location: _location,
7276
backgroundColor: backgroundColor,
7377
foregroundColor: foregroundColor,
74-
cornerRadius: cornerRadius)
78+
cornerRadius: cornerRadius,
79+
indicatorHeight: indicatorHeight)
80+
}
81+
82+
/// Modifier to change the size of the indicator
83+
/// - Parameter indicatorHeight: preferred height
84+
public func indicatorHeight(_ indicatorHeight: CGFloat) -> ModWheel {
85+
return .init(location: _location,
86+
backgroundColor: backgroundColor,
87+
foregroundColor: foregroundColor,
88+
cornerRadius: cornerRadius,
89+
indicatorHeight: indicatorHeight)
7590
}
7691
}

Sources/Controls/Implementations/PitchWheel.swift

+19-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ extension PitchWheel {
5252
internal init(location: Binding<Float>,
5353
backgroundColor: Color,
5454
foregroundColor: Color,
55-
cornerRadius: CGFloat) {
55+
cornerRadius: CGFloat,
56+
indicatorHeight: CGFloat) {
5657
self._location = location
5758
self.backgroundColor = backgroundColor
5859
self.foregroundColor = foregroundColor
5960
self.cornerRadius = cornerRadius
61+
self.indicatorHeight = indicatorHeight
6062
}
6163

6264

@@ -66,7 +68,8 @@ extension PitchWheel {
6668
return .init(location: _location,
6769
backgroundColor: backgroundColor,
6870
foregroundColor: foregroundColor,
69-
cornerRadius: cornerRadius)
71+
cornerRadius: cornerRadius,
72+
indicatorHeight: indicatorHeight)
7073
}
7174

7275
/// Modifer to change the foreground color of the wheel
@@ -75,7 +78,8 @@ extension PitchWheel {
7578
return .init(location: _location,
7679
backgroundColor: backgroundColor,
7780
foregroundColor: foregroundColor,
78-
cornerRadius: cornerRadius)
81+
cornerRadius: cornerRadius,
82+
indicatorHeight: indicatorHeight)
7983
}
8084

8185
/// Modifer to change the corner radius of the wheel and the indicator
@@ -84,6 +88,17 @@ extension PitchWheel {
8488
return .init(location: _location,
8589
backgroundColor: backgroundColor,
8690
foregroundColor: foregroundColor,
87-
cornerRadius: cornerRadius)
91+
cornerRadius: cornerRadius,
92+
indicatorHeight: indicatorHeight)
93+
}
94+
95+
/// Modifier to change the size of the indicator
96+
/// - Parameter indicatorHeight: preferred height
97+
public func indicatorHeight(_ indicatorHeight: CGFloat) -> PitchWheel {
98+
return .init(location: _location,
99+
backgroundColor: backgroundColor,
100+
foregroundColor: foregroundColor,
101+
cornerRadius: cornerRadius,
102+
indicatorHeight: indicatorHeight)
88103
}
89104
}

Sources/Controls/Implementations/Ribbon.swift

+19-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ extension Ribbon {
3939
internal init(position: Binding<Float>,
4040
backgroundColor: Color,
4141
foregroundColor: Color,
42-
cornerRadius: CGFloat) {
42+
cornerRadius: CGFloat,
43+
indicatorWidth: CGFloat) {
4344
self._position = position
4445
self.backgroundColor = backgroundColor
4546
self.foregroundColor = foregroundColor
4647
self.cornerRadius = cornerRadius
48+
self.indicatorWidth = indicatorWidth
4749
}
4850

4951

@@ -53,7 +55,8 @@ extension Ribbon {
5355
return .init(position: _position,
5456
backgroundColor: backgroundColor,
5557
foregroundColor: foregroundColor,
56-
cornerRadius: cornerRadius)
58+
cornerRadius: cornerRadius,
59+
indicatorWidth: indicatorWidth)
5760
}
5861

5962
/// Modifer to change the foreground color of the ribbon
@@ -62,7 +65,8 @@ extension Ribbon {
6265
return .init(position: _position,
6366
backgroundColor: backgroundColor,
6467
foregroundColor: foregroundColor,
65-
cornerRadius: cornerRadius)
68+
cornerRadius: cornerRadius,
69+
indicatorWidth: indicatorWidth)
6670
}
6771

6872
/// Modifer to change the corner radius of the ribbon bar and the indicator
@@ -71,6 +75,17 @@ extension Ribbon {
7175
return .init(position: _position,
7276
backgroundColor: backgroundColor,
7377
foregroundColor: foregroundColor,
74-
cornerRadius: cornerRadius)
78+
cornerRadius: cornerRadius,
79+
indicatorWidth: indicatorWidth)
80+
}
81+
82+
/// Modifier to change the size of the indicator
83+
/// - Parameter indicatorWidth: preferred width
84+
public func indicatorWidth(_ indicatorWidth: CGFloat) -> Ribbon {
85+
return .init(position: _position,
86+
backgroundColor: backgroundColor,
87+
foregroundColor: foregroundColor,
88+
cornerRadius: cornerRadius,
89+
indicatorWidth: indicatorWidth)
7590
}
7691
}

Sources/Controls/Implementations/XYPad.swift

+20-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct XYPad: View {
4343

4444
cx.fill(ind, with: .color(foregroundColor))
4545
}
46-
}.padding(indicatorSize.width * indicatorPadding)
46+
}.padding(indicatorSize.height * indicatorPadding)
4747
}
4848
}
4949
}
@@ -53,12 +53,14 @@ extension XYPad {
5353
y: Binding<Float>,
5454
backgroundColor: Color,
5555
foregroundColor: Color,
56-
cornerRadius: CGFloat) {
56+
cornerRadius: CGFloat,
57+
indicatorSize: CGSize) {
5758
self._x = x
5859
self._y = y
5960
self.backgroundColor = backgroundColor
6061
self.foregroundColor = foregroundColor
6162
self.cornerRadius = cornerRadius
63+
self.indicatorSize = indicatorSize
6264
}
6365

6466

@@ -68,7 +70,8 @@ extension XYPad {
6870
return .init(x: _x, y: _y,
6971
backgroundColor: backgroundColor,
7072
foregroundColor: foregroundColor,
71-
cornerRadius: cornerRadius)
73+
cornerRadius: cornerRadius,
74+
indicatorSize: indicatorSize)
7275
}
7376

7477
/// Modifer to change the foreground color of the xy pad
@@ -77,7 +80,8 @@ extension XYPad {
7780
return .init(x: _x, y: _y,
7881
backgroundColor: backgroundColor,
7982
foregroundColor: foregroundColor,
80-
cornerRadius: cornerRadius)
83+
cornerRadius: cornerRadius,
84+
indicatorSize: indicatorSize)
8185
}
8286

8387
/// Modifer to change the corner radius of the xy pad and the indicator
@@ -86,6 +90,17 @@ extension XYPad {
8690
return .init(x: _x, y: _y,
8791
backgroundColor: backgroundColor,
8892
foregroundColor: foregroundColor,
89-
cornerRadius: cornerRadius)
93+
cornerRadius: cornerRadius,
94+
indicatorSize: indicatorSize)
95+
}
96+
97+
/// Modifer to change the size of the indicator
98+
/// - Parameter indicatorSize: size of the indicator
99+
public func indicatorSize(_ indicatorSize: CGSize) -> XYPad {
100+
return .init(x: _x, y: _y,
101+
backgroundColor: backgroundColor,
102+
foregroundColor: foregroundColor,
103+
cornerRadius: cornerRadius,
104+
indicatorSize: indicatorSize)
90105
}
91106
}

0 commit comments

Comments
 (0)