Author: fredkiefer
Date: Sat Oct 17 00:01:41 2015
New Revision: 39077
URL: http://svn.gna.org/viewcvs/gnustep?rev=39077&view=rev
Log:
* Source/NSCell.m (-trackMouse:...untilMouseUp:): Check enabled
and use isContinuous method.
* Source/NSSliderCell.m: Replace specific implementation of
-trackMouse:...untilMouseUp: with super class one and move
specific code into helper methods.
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/NSCell.m
libs/gui/trunk/Source/NSSliderCell.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=39077&r1=39076&r2=39077&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Sat Oct 17 00:01:41 2015
@@ -1,3 +1,11 @@
+2015-10-16 Fred Kiefer <[email protected]>
+
+ * Source/NSCell.m (-trackMouse:...untilMouseUp:): Check enabled
+ and use isContinuous method.
+ * Source/NSSliderCell.m: Replace specific implementation of
+ -trackMouse:...untilMouseUp: with super class one and move
+ specific code into helper methods.
+
2015-10-15 Riccardo Mottola <[email protected]>
* Headers/AppKit/AppKit.h
Modified: libs/gui/trunk/Source/NSCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSCell.m?rev=39077&r1=39076&r2=39077&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSCell.m (original)
+++ libs/gui/trunk/Source/NSCell.m Sat Oct 17 00:01:41 2015
@@ -1643,8 +1643,15 @@
NSStringFromRect(cellFrame), point.x, point.y);
_mouse_down_flags = [theEvent modifierFlags];
+ if (![self isEnabled])
+ {
+ return NO;
+ }
+
if (![self startTrackingAt: point inView: controlView])
- return NO;
+ {
+ return NO;
+ }
if (![controlView mouse: point inRect: cellFrame])
return NO; // point is not in cell
@@ -1653,7 +1660,7 @@
&& [theEvent type] == NSLeftMouseDown)
[self _sendActionFrom: controlView];
- if (_action_mask & NSPeriodicMask)
+ if ([self isContinuous])
{
[self getPeriodicDelay: &delay interval: &interval];
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
@@ -1759,8 +1766,10 @@
inView: controlView
mouseIsUp: mouseWentUp];
- if (_action_mask & NSPeriodicMask)
- [NSEvent stopPeriodicEvents];
+ if ([self isContinuous])
+ {
+ [NSEvent stopPeriodicEvents];
+ }
if (mouseWentUp)
{
Modified: libs/gui/trunk/Source/NSSliderCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSSliderCell.m?rev=39077&r1=39076&r2=39077&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSSliderCell.m (original)
+++ libs/gui/trunk/Source/NSSliderCell.m Sat Oct 17 00:01:41 2015
@@ -848,116 +848,77 @@
return 0.0;
}
-- (BOOL) trackMouse: (NSEvent*)theEvent
- inRect: (NSRect)cellFrame
- ofView: (NSView*)controlView
- untilMouseUp: (BOOL)flag
-{
- float delay;
- float interval;
- id target = [self target];
- SEL action = [self action];
- NSUInteger eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
- | NSLeftMouseDraggedMask | NSMouseMovedMask;
- NSEventType eventType = [theEvent type];
- BOOL isContinuous = [self isContinuous];
- float oldFloatValue = [self floatValue];
- NSRect slotRect = [self trackRect];
- BOOL isVertical = [self isVertical];
- double minValue = [self minValue];
- double maxValue = [self maxValue];
- BOOL isFlipped = [controlView isFlipped];
- NSPoint location = [theEvent locationInWindow];
- NSPoint point = [controlView convertPoint: location fromView: nil];
- NSRect knobRect = [self knobRectFlipped: isFlipped];
-
- _mouse_down_flags = [theEvent modifierFlags];
- if (![self isEnabled])
+- (BOOL) startTrackingAt: (NSPoint)startPoint inView: (NSView*)controlView
+{
+ // If the point is in the view then yes start tracking
+ if ([controlView mouse: startPoint inRect: [controlView bounds]])
+ {
+ BOOL isFlipped = [controlView isFlipped];
+ NSRect knobRect = [self knobRectFlipped: isFlipped];
+
+ if (![controlView mouse: startPoint inRect: knobRect])
+ {
+ // Mouse is not on the knob, move the knob to the mouse position
+ float floatValue;
+ NSRect slotRect = [self trackRect];
+ BOOL isVertical = [self isVertical];
+ double minValue = [self minValue];
+ double maxValue = [self maxValue];
+
+ floatValue = _floatValueForMousePoint(startPoint, knobRect,
+ slotRect, isVertical,
+ minValue, maxValue,
+ self, isFlipped,
+ (_type == NSCircularSlider));
+ if (_allowsTickMarkValuesOnly)
+ {
+ floatValue = [self closestTickMarkValueToValue: floatValue];
+ }
+ [self setFloatValue: floatValue];
+ if ([self isContinuous])
+ {
+ [(NSControl*)controlView sendAction: [self action] to: [self
target]];
+ }
+ }
+
+ return YES;
+ }
+ else
{
return NO;
}
-
- if (![controlView mouse: point inRect: knobRect])
- {
- // Mouse is not on the knob, move the knob to the mouse position
+}
+
+- (BOOL) continueTracking: (NSPoint)lastPoint
+ at: (NSPoint)currentPoint
+ inView: (NSView*)controlView
+{
+ if (currentPoint.x != lastPoint.x || currentPoint.y != lastPoint.y)
+ {
float floatValue;
-
- floatValue = _floatValueForMousePoint(point, knobRect,
- slotRect, isVertical,
- minValue, maxValue,
- self, isFlipped,
- (_type == NSCircularSlider));
- [self setFloatValue: floatValue];
- if (isContinuous)
+ BOOL isFlipped = [controlView isFlipped];
+ NSRect knobRect = [self knobRectFlipped: isFlipped];
+ float oldFloatValue = [self floatValue];
+ NSRect slotRect = [self trackRect];
+ BOOL isVertical = [self isVertical];
+ double minValue = [self minValue];
+ double maxValue = [self maxValue];
+
+ floatValue = _floatValueForMousePoint(currentPoint, knobRect,
+ slotRect, isVertical,
+ minValue, maxValue,
+ self, isFlipped,
+ (_type == NSCircularSlider));
+ if (_allowsTickMarkValuesOnly)
{
- [(NSControl*)controlView sendAction: action to: target];
- }
- }
-
- if (isContinuous)
- {
- [self getPeriodicDelay: &delay interval: &interval];
- [NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
- eventMask |= NSPeriodicMask;
- }
-
- while (eventType != NSLeftMouseUp)
- {
- theEvent = [NSApp nextEventMatchingMask: eventMask
- untilDate: [NSDate distantFuture]
- inMode: NSEventTrackingRunLoopMode
- dequeue: YES];
- eventType = [theEvent type];
-
- if (eventType == NSPeriodic)
+ floatValue = [self closestTickMarkValueToValue: floatValue];
+ }
+ if (floatValue != oldFloatValue)
{
- NSWindow *w = [controlView window];
-
- location = [w mouseLocationOutsideOfEventStream];
- }
- else
- {
- location = [theEvent locationInWindow];
- }
- point = [controlView convertPoint: location fromView: nil];
-
- if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
- {
- float floatValue;
-
- floatValue = _floatValueForMousePoint(point, knobRect,
- slotRect, isVertical,
- minValue, maxValue,
- self, isFlipped,
- (_type == NSCircularSlider));
- if (floatValue != oldFloatValue)
- {
- if (_allowsTickMarkValuesOnly)
- {
- floatValue = [self closestTickMarkValueToValue:floatValue];
- }
-
- [self setFloatValue: floatValue];
- if (isContinuous)
- {
- [(NSControl*)controlView sendAction: action to: target];
- }
- oldFloatValue = floatValue;
- }
- knobRect.origin = point;
- }
- }
-
- // If the cell is not continuous send the action at the end of the drag
- if (!isContinuous)
- {
- [(NSControl*)controlView sendAction: action to: target];
- }
- else
- {
- [NSEvent stopPeriodicEvents];
- }
-
+ [self setFloatValue: floatValue];
+ // The action gets triggered in trackMouse:...untilMouseUp:
+ }
+ }
return YES;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs