mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:00:47 +00:00
Color dragging minor improvement.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9162 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a002d02682
commit
7106a1459a
3 changed files with 57 additions and 60 deletions
|
@ -5,6 +5,9 @@
|
||||||
1. colorwell should not deactivate when panel is closed.
|
1. colorwell should not deactivate when panel is closed.
|
||||||
2. setting color of an active well should set the color of the panel
|
2. setting color of an active well should set the color of the panel
|
||||||
(though it should not raise it).
|
(though it should not raise it).
|
||||||
|
* Source/NSColorPanel.m: Minor tidy.
|
||||||
|
* Images/common_ColorSwatch.tiff: Updated to same size as NeXTstep
|
||||||
|
color swatch.
|
||||||
|
|
||||||
Sun Feb 18 13:35:55 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
Sun Feb 18 13:35:55 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -72,17 +72,17 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
|
|
||||||
- (void) _loadPickers
|
- (void) _loadPickers
|
||||||
{
|
{
|
||||||
NSArray *paths;
|
NSArray *paths;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
NSEnumerator *pathEnumerator;
|
NSEnumerator *pathEnumerator;
|
||||||
NSArray *bundles;
|
NSArray *bundles;
|
||||||
NSEnumerator *bundleEnumerator;
|
NSEnumerator *bundleEnumerator;
|
||||||
NSString *bundleName;
|
NSString *bundleName;
|
||||||
|
|
||||||
_pickers = [NSMutableArray new];
|
_pickers = [NSMutableArray new];
|
||||||
|
|
||||||
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||||
NSAllDomainsMask, YES);
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
pathEnumerator = [paths objectEnumerator];
|
pathEnumerator = [paths objectEnumerator];
|
||||||
while ((path = [pathEnumerator nextObject]))
|
while ((path = [pathEnumerator nextObject]))
|
||||||
|
@ -92,8 +92,10 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
|
|
||||||
bundleEnumerator = [bundles objectEnumerator];
|
bundleEnumerator = [bundles objectEnumerator];
|
||||||
while ((bundleName = [bundleEnumerator nextObject]))
|
while ((bundleName = [bundleEnumerator nextObject]))
|
||||||
[self _loadPickerAtPath:
|
{
|
||||||
|
[self _loadPickerAtPath:
|
||||||
[path stringByAppendingPathComponent: bundleName]];
|
[path stringByAppendingPathComponent: bundleName]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = [[NSBundle mainBundle] pathsForResourcesOfType: @"bundle"
|
paths = [[NSBundle mainBundle] pathsForResourcesOfType: @"bundle"
|
||||||
|
@ -101,14 +103,16 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
|
|
||||||
pathEnumerator = [paths objectEnumerator];
|
pathEnumerator = [paths objectEnumerator];
|
||||||
while ((path = [pathEnumerator nextObject]))
|
while ((path = [pathEnumerator nextObject]))
|
||||||
[self _loadPickerAtPath: path];
|
{
|
||||||
|
[self _loadPickerAtPath: path];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _loadPickerAtPath: (NSString *)path
|
- (void) _loadPickerAtPath: (NSString *)path
|
||||||
{
|
{
|
||||||
NSBundle *bundle;
|
NSBundle *bundle;
|
||||||
Class pickerClass;
|
Class pickerClass;
|
||||||
NSColorPicker *picker;
|
NSColorPicker *picker;
|
||||||
|
|
||||||
bundle = [NSBundle bundleWithPath: path];
|
bundle = [NSBundle bundleWithPath: path];
|
||||||
if (bundle && (pickerClass = [bundle principalClass]))
|
if (bundle && (pickerClass = [bundle principalClass]))
|
||||||
|
@ -121,7 +125,9 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[_pickers addObject: picker];
|
[_pickers addObject: picker];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
NSLog(@"%@ does not contain a valid color picker.", path);
|
{
|
||||||
|
NSLog(@"%@ does not contain a valid color picker.", path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,22 +347,19 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
|
|
||||||
@implementation NSColorPanel
|
@implementation NSColorPanel
|
||||||
|
|
||||||
//
|
/*
|
||||||
// Class methods
|
* Class methods
|
||||||
//
|
*/
|
||||||
+ (void)initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSColorPanel class])
|
if (self == [NSColorPanel class])
|
||||||
{
|
{
|
||||||
// Initial version
|
// Initial version
|
||||||
[self setVersion:1];
|
[self setVersion: 1];
|
||||||
_gs_gui_color_panel_lock = [NSLock new];
|
_gs_gui_color_panel_lock = [NSLock new];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Creating the NSColorPanel
|
|
||||||
//
|
|
||||||
+ (NSColorPanel *)sharedColorPanel
|
+ (NSColorPanel *)sharedColorPanel
|
||||||
{
|
{
|
||||||
if (_gs_gui_color_panel == nil)
|
if (_gs_gui_color_panel == nil)
|
||||||
|
@ -364,7 +367,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[_gs_gui_color_panel_lock lock];
|
[_gs_gui_color_panel_lock lock];
|
||||||
if (!_gs_gui_color_panel)
|
if (!_gs_gui_color_panel)
|
||||||
{
|
{
|
||||||
_gs_gui_color_panel = [[self alloc] _initWithoutGModel];
|
_gs_gui_color_panel = [[self alloc] _initWithoutGModel];
|
||||||
/*
|
/*
|
||||||
GSAppKitPanelController *panelCtrl = [GSAppKitPanelController new];
|
GSAppKitPanelController *panelCtrl = [GSAppKitPanelController new];
|
||||||
|
|
||||||
|
@ -374,9 +377,9 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[_gs_gui_color_panel _fixupMatrix];
|
[_gs_gui_color_panel _fixupMatrix];
|
||||||
*/
|
*/
|
||||||
[_gs_gui_color_panel _loadPickers];
|
[_gs_gui_color_panel _loadPickers];
|
||||||
[_gs_gui_color_panel _setupPickers];
|
[_gs_gui_color_panel _setupPickers];
|
||||||
[_gs_gui_color_panel setMode: _gs_gui_color_picker_mode];
|
[_gs_gui_color_panel setMode: _gs_gui_color_picker_mode];
|
||||||
[_gs_gui_color_panel setShowsAlpha: ![NSColor ignoresAlpha]];
|
[_gs_gui_color_panel setShowsAlpha: ![NSColor ignoresAlpha]];
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
[_gs_gui_color_panel_lock unlock];
|
[_gs_gui_color_panel_lock unlock];
|
||||||
|
@ -385,33 +388,27 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
return _gs_gui_color_panel;
|
return _gs_gui_color_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)sharedColorPanelExists
|
+ (BOOL) sharedColorPanelExists
|
||||||
{
|
{
|
||||||
return (_gs_gui_color_panel == nil) ? NO : YES;
|
return (_gs_gui_color_panel == nil) ? NO : YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
+ (void) setPickerMask: (int)mask
|
||||||
// Setting the NSColorPanel
|
|
||||||
//
|
|
||||||
+ (void)setPickerMask:(int)mask
|
|
||||||
{
|
{
|
||||||
_gs_gui_color_picker_mask = mask;
|
_gs_gui_color_picker_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)setPickerMode:(int)mode
|
+ (void) setPickerMode: (int)mode
|
||||||
{
|
{
|
||||||
_gs_gui_color_picker_mode = mode;
|
_gs_gui_color_picker_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
+ (BOOL) dragColor: (NSColor *)aColor
|
||||||
// Setting Color
|
withEvent: (NSEvent *)anEvent
|
||||||
//
|
fromView: (NSView *)sourceView
|
||||||
+ (BOOL)dragColor:(NSColor *)aColor
|
|
||||||
withEvent:(NSEvent *)anEvent
|
|
||||||
fromView:(NSView *)sourceView
|
|
||||||
{
|
{
|
||||||
NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSDragPboard];
|
NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSDragPboard];
|
||||||
NSImage *image = [NSImage imageNamed: @"common_ColorSwatch"];
|
NSImage *image = [NSImage imageNamed: @"common_ColorSwatch"];
|
||||||
|
|
||||||
[pb declareTypes: [NSArray arrayWithObjects: NSColorPboardType, nil]
|
[pb declareTypes: [NSArray arrayWithObjects: NSColorPboardType, nil]
|
||||||
owner: aColor];
|
owner: aColor];
|
||||||
|
@ -429,9 +426,9 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/*
|
||||||
// Instance methods
|
* Instance methods
|
||||||
//
|
*/
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
@ -448,20 +445,17 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
- (NSView *) accessoryView
|
||||||
// Setting the NSColorPanel
|
|
||||||
//
|
|
||||||
- (NSView *)accessoryView
|
|
||||||
{
|
{
|
||||||
return _accessoryView;
|
return _accessoryView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isContinuous
|
- (BOOL) isContinuous
|
||||||
{
|
{
|
||||||
return _isContinuous;
|
return _isContinuous;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)mode
|
- (int) mode
|
||||||
{
|
{
|
||||||
if (_currentPicker != nil)
|
if (_currentPicker != nil)
|
||||||
return [_currentPicker currentMode];
|
return [_currentPicker currentMode];
|
||||||
|
@ -469,7 +463,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAccessoryView:(NSView *)aView
|
- (void) setAccessoryView: (NSView *)aView
|
||||||
{
|
{
|
||||||
if (_accessoryView == aView)
|
if (_accessoryView == aView)
|
||||||
return;
|
return;
|
||||||
|
@ -480,17 +474,17 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[_splitView addSubview: _accessoryView];
|
[_splitView addSubview: _accessoryView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAction:(SEL)aSelector
|
- (void) setAction: (SEL)aSelector
|
||||||
{
|
{
|
||||||
_action = aSelector;
|
_action = aSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setContinuous:(BOOL)flag
|
- (void) setContinuous: (BOOL)flag
|
||||||
{
|
{
|
||||||
_isContinuous = flag;
|
_isContinuous = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMode:(int)mode
|
- (void) setMode: (int)mode
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
|
@ -510,7 +504,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setShowsAlpha:(BOOL)flag
|
- (void) setShowsAlpha: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (flag == _showsAlpha)
|
if (flag == _showsAlpha)
|
||||||
return;
|
return;
|
||||||
|
@ -542,12 +536,12 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
[_topView setNeedsDisplay: YES];
|
[_topView setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTarget:(id)anObject
|
- (void) setTarget: (id)anObject
|
||||||
{
|
{
|
||||||
_target = anObject;
|
_target = anObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)showsAlpha
|
- (BOOL) showsAlpha
|
||||||
{
|
{
|
||||||
return _showsAlpha;
|
return _showsAlpha;
|
||||||
}
|
}
|
||||||
|
@ -555,13 +549,13 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
//
|
//
|
||||||
// Attaching a Color List
|
// Attaching a Color List
|
||||||
//
|
//
|
||||||
- (void)attachColorList:(NSColorList *)aColorList
|
- (void) attachColorList: (NSColorList *)aColorList
|
||||||
{
|
{
|
||||||
[_pickers makeObjectsPerformSelector: @selector(attachColorList:)
|
[_pickers makeObjectsPerformSelector: @selector(attachColorList:)
|
||||||
withObject: aColorList];
|
withObject: aColorList];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)detachColorList:(NSColorList *)aColorList
|
- (void) detachColorList: (NSColorList *)aColorList
|
||||||
{
|
{
|
||||||
[_pickers makeObjectsPerformSelector: @selector(detachColorList:)
|
[_pickers makeObjectsPerformSelector: @selector(detachColorList:)
|
||||||
withObject: aColorList];
|
withObject: aColorList];
|
||||||
|
@ -570,7 +564,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
//
|
//
|
||||||
// Setting Color
|
// Setting Color
|
||||||
//
|
//
|
||||||
- (float)alpha
|
- (float) alpha
|
||||||
{
|
{
|
||||||
if ([self showsAlpha])
|
if ([self showsAlpha])
|
||||||
return [_alphaSlider floatValue] / MAX_ALPHA_VALUE;
|
return [_alphaSlider floatValue] / MAX_ALPHA_VALUE;
|
||||||
|
@ -578,12 +572,12 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor *)color
|
- (NSColor *) color
|
||||||
{
|
{
|
||||||
return [_colorWell color];
|
return [_colorWell color];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setColor:(NSColor *)aColor
|
- (void) setColor: (NSColor *)aColor
|
||||||
{
|
{
|
||||||
[_colorWell setColor: aColor];
|
[_colorWell setColor: aColor];
|
||||||
[_currentPicker setColor: aColor];
|
[_currentPicker setColor: aColor];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue