diff --git a/ChangeLog b/ChangeLog index 6aee2761d..857c0a785 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2002-10-27 Pierre-Yves Rivaille + + * Source/NSMenuView.m ([NSMenuView -trackWithEvent:]): + new tracking code. The menu feels snappier now (at least for me). + + * Source/NSColorWell.m ([-activate:], [-deactivate]) + register/unregister for NSColorPanelColorChangedNotification. + ([NSColorWell _takeColorFromPanel:]): new method to prevent endless + loop when setting the well's color from the color panel. + ([NSColorWell -initWithCoder:]): register for NSColorPboardType. + + * Source/NSColorPanel.m ([NSColorPanel -_bottomWellAction:]): + called when hitting one of the well at the bottom of the panel. + Previous behaviour would not send a + NSColorPanelColorChangedNotification. + ([NSColorPanel -initWithCoder:]): update bottom wells construction to + call _bottomWellAction: instead of takeColorFrom:. + 2002-10-26 Adam Fedor * Source/NSOutlineView.m (-drawRow:clipRect:): Release imageCell diff --git a/Source/NSColorPanel.m b/Source/NSColorPanel.m index 9462bc1b4..4e928f3b6 100644 --- a/Source/NSColorPanel.m +++ b/Source/NSColorPanel.m @@ -324,7 +324,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel; [well setBordered: NO]; [well setEnabled: NO]; [well setTarget: _colorWell]; - [well setAction: @selector(takeColorFrom:)]; + [well setAction: @selector(_bottomWellAction:)]; [swatchView addSubview: well]; RELEASE(well); } @@ -355,6 +355,11 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel; [_currentPicker setColor: [_colorWell color]]; } +- (void) _bottomWellAction: (id) sender +{ + [self setColor: [sender color]]; +} + @end @implementation NSColorPanel diff --git a/Source/NSColorWell.m b/Source/NSColorWell.m index 7e3c11f97..d675d2f70 100644 --- a/Source/NSColorWell.m +++ b/Source/NSColorWell.m @@ -86,6 +86,11 @@ static NSString *GSColorWellDidBecomeExclusiveNotification = name: GSColorWellDidBecomeExclusiveNotification object: nil]; + [nc addObserver: self + selector: @selector(_takeColorFromPanel:) + name: NSColorPanelColorChangedNotification + object: nil]; + _is_active = YES; [colorPanel setColor: _the_color]; @@ -233,6 +238,8 @@ static NSString *GSColorWellDidBecomeExclusiveNotification = // Undo RETAIN by decoder TEST_RELEASE(_target); [aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action]; + [self registerForDraggedTypes: + [NSArray arrayWithObjects: NSColorPboardType, nil]]; } return self; } @@ -346,6 +353,19 @@ static NSString *GSColorWellDidBecomeExclusiveNotification = } } +- (void) _takeColorFromPanel: (NSNotification *) notification +{ + id sender = [notification object]; + + if ([sender respondsToSelector: @selector(color)]) + { + ASSIGN(_the_color, [(id)sender color]); + + [self sendAction: _action to: _target]; + [self setNeedsDisplay: YES]; + } +} + - (id) target { return _target; diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index ac6829354..07bf40839 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -885,7 +885,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal) } #define MOVE_THRESHOLD_DELTA 2.0 -#define DELAY_MULTIPLIER 6 +#define DELAY_MULTIPLIER 10 - (BOOL) trackWithEvent: (NSEvent*)event { @@ -899,7 +899,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal) BOOL delayedSelect = NO; int delayCount = 0; float xDelta = MOVE_THRESHOLD_DELTA; - float yDelta = 0.0; NSEvent *original; NSEventType type = [event type]; NSEventType end; @@ -951,45 +950,18 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal) if (delayedSelect && mouseMoved && [event type] == NSPeriodic) { float xDiff = location.x - lastLocation.x; - float yDiff = location.y - lastLocation.y; - /* - * Once the mouse movement has started in one vertical - * direction, it must continue in the same direction if - * selection is to be delayed. - */ - if (yDelta == 0.0) + if (xDiff > xDelta) { - if (yDiff < 0.0) - yDelta = -MOVE_THRESHOLD_DELTA; - else if (yDiff > 0.0) - yDelta = MOVE_THRESHOLD_DELTA; - } - /* - * Check to see if movement is less than the threshold. - */ - if (xDiff < xDelta - || (yDelta < 0.0 && yDiff > yDelta) - || (yDelta > 0.0 && yDiff < yDelta)) - { - /* - * if we have had too many successive small movements, or - * a single movement too far in the wrong direction, we - * leave 'delayedSelect' mode. - */ delayCount++; - if (delayCount >= DELAY_MULTIPLIER - || (xDiff < 0) - || (yDelta < 0.0 && yDiff > -yDelta) - || (yDelta > 0.0 && yDiff < -yDelta)) - { - delayedSelect = NO; - } + if (delayCount >= DELAY_MULTIPLIER) + delayedSelect = NO; } else { - delayCount = 0; + delayedSelect = NO; } + lastLocation = location; } } @@ -1047,7 +1019,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal) mouseMoved = NO; delayedSelect = YES; delayCount = 0; - yDelta = 0.0; } else {