Skip to content

Commit 962e96a

Browse files
Address review feedback: drop dead dragOrigin state, fix misplaced doc comment
Round-18 review flagged dragOrigin as write-only dead state left over from a refactor, and a doc comment block describing stableDecimalPlaces sitting above naturalDecimalPlaces instead.
1 parent 87c3ce5 commit 962e96a

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

Pika/Views/EditableColorValue.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,6 @@ struct ColorComponentField: View {
707707
}
708708
}
709709

710-
/// Decimal places for a scrub session's live display: 2 by default — finer than that isn't a
711-
/// meaningful step to scrub by (0.0001 of a 0...1 range is imperceptible per pixel) — unless
712-
/// the value already displays with more precision than that, in which case keep it. Otherwise
713-
/// starting a scrub would itself immediately truncate the value and reflow the row, before
714-
/// any actual dragging has happened.
715710
/// Decimal places at which this component's per-pixel drag step is actually visible: the
716711
/// step is range-scaled (`dragUnitsPerPixel`), so a fixed 2 places leaves a fine-ranged
717712
/// component like OKLCH chroma advancing its last digit only every ~4px — which reads as the
@@ -723,6 +718,11 @@ struct ColorComponentField: View {
723718
return max(0, Int(ceil(-log10(step))))
724719
}
725720

721+
/// Decimal places for a scrub session's live display: 2 by default — finer than that isn't a
722+
/// meaningful step to scrub by (0.0001 of a 0...1 range is imperceptible per pixel) — unless
723+
/// the value already displays with more precision than that, in which case keep it. Otherwise
724+
/// starting a scrub would itself immediately truncate the value and reflow the row, before
725+
/// any actual dragging has happened.
726726
static func stableDecimalPlaces(for text: String) -> Int {
727727
guard let dotIndex = text.firstIndex(of: ".") else { return 2 }
728728
let decimals = text.distance(from: text.index(after: dotIndex), to: text.endIndex)

Pika/Views/ScrubTextField.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ final class ScrubTextField: NSTextField {
284284
/// see the note at the `onFocusChange` assignment in `ScrubbableColorField.updateNSView`.
285285
var onFocusChange: ((Bool) -> Void)?
286286

287-
private var dragOrigin: Double?
288287
/// The most recent value `onDragChanged` reported — always set by the time `finishDrag` can
289288
/// run, since `updateDrag` fires at least once (immediately after `beginDrag`) before a
290289
/// `mouseUp` can be reached. Read once, then cleared, to hand `onDragEnd` its final value.
@@ -441,8 +440,7 @@ final class ScrubTextField: NSTextField {
441440
}
442441

443442
private func beginDrag(at location: NSPoint) {
444-
dragOrigin = Double(stringValue.trimmingCharacters(in: .whitespaces)) ?? 0
445-
dragAnchorValue = dragOrigin
443+
dragAnchorValue = Double(stringValue.trimmingCharacters(in: .whitespaces)) ?? 0
446444
dragAnchorX = location.x
447445
// Whichever is finer: the precision this component's drag step can actually resolve, or
448446
// the precision already on display (so starting a scrub never truncates what's shown).
@@ -508,7 +506,6 @@ final class ScrubTextField: NSTextField {
508506
}
509507

510508
private func finishDrag() {
511-
dragOrigin = nil
512509
dragAnchorValue = nil
513510
NSCursor.arrow.set()
514511
if let lastDragValue {

0 commit comments

Comments
 (0)