mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 03:51:00 +00:00
* 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. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39077 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
60ecc2d599
commit
f05dfd55c3
3 changed files with 82 additions and 104 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2015-10-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* 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 <rm@gnu.org>
|
2015-10-15 Riccardo Mottola <rm@gnu.org>
|
||||||
|
|
||||||
* Headers/AppKit/AppKit.h
|
* Headers/AppKit/AppKit.h
|
||||||
|
|
|
@ -1643,8 +1643,15 @@ static NSColor *dtxtCol;
|
||||||
NSStringFromRect(cellFrame), point.x, point.y);
|
NSStringFromRect(cellFrame), point.x, point.y);
|
||||||
|
|
||||||
_mouse_down_flags = [theEvent modifierFlags];
|
_mouse_down_flags = [theEvent modifierFlags];
|
||||||
|
if (![self isEnabled])
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
if (![self startTrackingAt: point inView: controlView])
|
if (![self startTrackingAt: point inView: controlView])
|
||||||
return NO;
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
if (![controlView mouse: point inRect: cellFrame])
|
if (![controlView mouse: point inRect: cellFrame])
|
||||||
return NO; // point is not in cell
|
return NO; // point is not in cell
|
||||||
|
@ -1653,7 +1660,7 @@ static NSColor *dtxtCol;
|
||||||
&& [theEvent type] == NSLeftMouseDown)
|
&& [theEvent type] == NSLeftMouseDown)
|
||||||
[self _sendActionFrom: controlView];
|
[self _sendActionFrom: controlView];
|
||||||
|
|
||||||
if (_action_mask & NSPeriodicMask)
|
if ([self isContinuous])
|
||||||
{
|
{
|
||||||
[self getPeriodicDelay: &delay interval: &interval];
|
[self getPeriodicDelay: &delay interval: &interval];
|
||||||
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
|
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
|
||||||
|
@ -1759,8 +1766,10 @@ static NSColor *dtxtCol;
|
||||||
inView: controlView
|
inView: controlView
|
||||||
mouseIsUp: mouseWentUp];
|
mouseIsUp: mouseWentUp];
|
||||||
|
|
||||||
if (_action_mask & NSPeriodicMask)
|
if ([self isContinuous])
|
||||||
[NSEvent stopPeriodicEvents];
|
{
|
||||||
|
[NSEvent stopPeriodicEvents];
|
||||||
|
}
|
||||||
|
|
||||||
if (mouseWentUp)
|
if (mouseWentUp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -848,116 +848,77 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) trackMouse: (NSEvent*)theEvent
|
- (BOOL) startTrackingAt: (NSPoint)startPoint inView: (NSView*)controlView
|
||||||
inRect: (NSRect)cellFrame
|
|
||||||
ofView: (NSView*)controlView
|
|
||||||
untilMouseUp: (BOOL)flag
|
|
||||||
{
|
{
|
||||||
float delay;
|
// If the point is in the view then yes start tracking
|
||||||
float interval;
|
if ([controlView mouse: startPoint inRect: [controlView bounds]])
|
||||||
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])
|
|
||||||
{
|
{
|
||||||
return NO;
|
BOOL isFlipped = [controlView isFlipped];
|
||||||
}
|
NSRect knobRect = [self knobRectFlipped: isFlipped];
|
||||||
|
|
||||||
if (![controlView mouse: point inRect: knobRect])
|
if (![controlView mouse: startPoint inRect: knobRect])
|
||||||
{
|
|
||||||
// Mouse is not on the knob, move the knob to the mouse position
|
|
||||||
float floatValue;
|
|
||||||
|
|
||||||
floatValue = _floatValueForMousePoint(point, knobRect,
|
|
||||||
slotRect, isVertical,
|
|
||||||
minValue, maxValue,
|
|
||||||
self, isFlipped,
|
|
||||||
(_type == NSCircularSlider));
|
|
||||||
[self setFloatValue: floatValue];
|
|
||||||
if (isContinuous)
|
|
||||||
{
|
{
|
||||||
[(NSControl*)controlView sendAction: action to: target];
|
// Mouse is not on the knob, move the knob to the mouse position
|
||||||
}
|
float floatValue;
|
||||||
}
|
NSRect slotRect = [self trackRect];
|
||||||
|
BOOL isVertical = [self isVertical];
|
||||||
if (isContinuous)
|
double minValue = [self minValue];
|
||||||
{
|
double maxValue = [self maxValue];
|
||||||
[self getPeriodicDelay: &delay interval: &interval];
|
|
||||||
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
|
floatValue = _floatValueForMousePoint(startPoint, knobRect,
|
||||||
eventMask |= NSPeriodicMask;
|
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]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (eventType != NSLeftMouseUp)
|
return YES;
|
||||||
{
|
|
||||||
theEvent = [NSApp nextEventMatchingMask: eventMask
|
|
||||||
untilDate: [NSDate distantFuture]
|
|
||||||
inMode: NSEventTrackingRunLoopMode
|
|
||||||
dequeue: YES];
|
|
||||||
eventType = [theEvent type];
|
|
||||||
|
|
||||||
if (eventType == NSPeriodic)
|
|
||||||
{
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
[NSEvent stopPeriodicEvents];
|
return NO;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) continueTracking: (NSPoint)lastPoint
|
||||||
|
at: (NSPoint)currentPoint
|
||||||
|
inView: (NSView*)controlView
|
||||||
|
{
|
||||||
|
if (currentPoint.x != lastPoint.x || currentPoint.y != lastPoint.y)
|
||||||
|
{
|
||||||
|
float floatValue;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
floatValue = [self closestTickMarkValueToValue: floatValue];
|
||||||
|
}
|
||||||
|
if (floatValue != oldFloatValue)
|
||||||
|
{
|
||||||
|
[self setFloatValue: floatValue];
|
||||||
|
// The action gets triggered in trackMouse:...untilMouseUp:
|
||||||
|
}
|
||||||
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue