From 41c422ed03ed6195d7698980cb9bd4181619d0b6 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 29 May 2026 10:55:22 +0200 Subject: [PATCH] new: visual feedback when "tearing off" --- AppKit/CPTextView/CPRulerView.j | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTextView/CPRulerView.j b/AppKit/CPTextView/CPRulerView.j index 1683dc83b..dc69a131c 100644 --- a/AppKit/CPTextView/CPRulerView.j +++ b/AppKit/CPTextView/CPRulerView.j @@ -240,6 +240,23 @@ CPRulerOrientationVertical = 1 [_draggingMarker setImageValue:newLocation]; [self _positionMarker:_draggingMarker]; + // Check if dragged off the ruler (more than 15px off the boundary) + var draggedOff = isHorizontal ? (localPoint.y < -15 || localPoint.y > CGRectGetHeight([self bounds]) + 15) + : (localPoint.x < -15 || localPoint.x > CGRectGetWidth([self bounds]) + 15); + + if (draggedOff) + { + // Visual feedback: Dim the handle to 40% and turn the triangle icon gray + [_draggingMarker setAlphaValue:0.4]; + [[_draggingMarker label] setTextColor:[CPColor grayColor]]; + } + else + { + // Restore standard styling when dragged back into the active strip + [_draggingMarker setAlphaValue:1.0]; + [[_draggingMarker label] setTextColor:[CPColor colorWithWhite:0.2 alpha:1.0]]; + } + // Notify the CPTextView that the marker coordinates shifted var client = [self clientView]; if (client && [client respondsToSelector:@selector(rulerView:didMoveMarker:)]) @@ -266,11 +283,16 @@ CPRulerOrientationVertical = 1 [self removeMarker:_draggingMarker]; } + else + { + // Ensure marker style is fully restored if not deleted + [_draggingMarker setAlphaValue:1.0]; + [[_draggingMarker label] setTextColor:[CPColor colorWithWhite:0.2 alpha:1.0]]; + } _draggingMarker = nil; } - #pragma mark - #pragma mark DOM Layout Builder