mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 07:20:58 +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.
|
@ -92,16 +92,20 @@ 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"
|
||||||
inDirectory: @"ColorPickers"];
|
inDirectory: @"ColorPickers"];
|
||||||
|
|
||||||
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
|
||||||
|
@ -121,8 +125,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - this is a HACK to get around problems in the gmodel code
|
// FIXME - this is a HACK to get around problems in the gmodel code
|
||||||
|
@ -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)
|
||||||
|
@ -385,30 +388,24 @@ 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"];
|
||||||
|
@ -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