Skip to content

Commit

Permalink
Fix waveform slider knob
Browse files Browse the repository at this point in the history
  • Loading branch information
lbrndnr committed Jul 10, 2023
1 parent 5c46715 commit 615fbcd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Nuage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 53;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -255,8 +255,9 @@
4969F3BD257CFA7F0048E29B /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1220;
LastUpgradeCheck = 1230;
LastUpgradeCheck = 1430;
TargetAttributes = {
4969F3C4257CFA7F0048E29B = {
CreatedOnToolsVersion = 12.2;
Expand Down Expand Up @@ -385,6 +386,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -446,6 +448,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -476,6 +479,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Nuage/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Nuage/Info.plist;
Expand All @@ -501,6 +505,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Nuage/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Nuage/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion Nuage.xcodeproj/xcshareddata/xcschemes/Nuage.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 3 additions & 3 deletions Nuage/Views/WaveformSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ struct WaveformSlider<Value : BinaryFloatingPoint, MinValueLabel: View, MaxValue
}

@ViewBuilder private func slider() -> some View {
let knobRadius: CGFloat = 13
let knobDiameter: CGFloat = 13

GeometryReader { geometry in
let currentValue = updatingValue ?? value
let rangeWidth = range.upperBound - range.lowerBound
let relativeValue = rangeWidth > 0 ? CGFloat(currentValue/rangeWidth) : CGFloat(0)
let barValue = geometry.size.width * relativeValue
let knobValue = (geometry.size.width - knobRadius) * relativeValue
let knobValue = geometry.size.width * relativeValue - knobDiameter/2.0
let currentKnobColor = highlighted ? highlightedKnobColor : knobColor

let drag = DragGesture(minimumDistance: 0, coordinateSpace: .local).onChanged { gesture in
Expand Down Expand Up @@ -72,7 +72,7 @@ struct WaveformSlider<Value : BinaryFloatingPoint, MinValueLabel: View, MaxValue
Circle()
.strokeBorder(knobBorderColor, lineWidth: 1)
.background(Circle().foregroundColor(currentKnobColor))
.frame(width: knobRadius, height: knobRadius)
.frame(width: knobDiameter, height: knobDiameter)
.offset(x: knobValue)
}
}.gesture(drag)
Expand Down

0 comments on commit 615fbcd

Please sign in to comment.