mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:10:48 +00:00
Merge pull request #229 from gnustep/NSShadow_implementation_issue217
Update NSView with setShadow:/shadow methods
This commit is contained in:
commit
79fd2c8c43
5 changed files with 95 additions and 11 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2023-12-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSView.h: Add ivar for NSShadow, update
|
||||
version of class for NSArchiver so this can be properly
|
||||
read and saved in .gorm files.
|
||||
* Source/GSXib5KeyedUnarchiver.m: Add code to handle XIB
|
||||
keys for NSShadow.
|
||||
* Source/NSShadow.m: Minor cleanup to use ASSIGN macro
|
||||
in -initWithCoder:
|
||||
* Source/NSView.m: Add code to -encodeWithCoder: and
|
||||
-initWithCoder: to properly handle NSViewShadow.
|
||||
|
||||
2023-11-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSGormLoading.m
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
@class NSScrollView;
|
||||
@class NSView;
|
||||
@class NSWindow;
|
||||
@class NSShadow;
|
||||
|
||||
typedef NSInteger NSTrackingRectTag;
|
||||
typedef NSInteger NSToolTipTag;
|
||||
|
@ -193,6 +194,7 @@ PACKAGE_SCOPE
|
|||
NSUInteger _autoresizingMask;
|
||||
NSFocusRingType _focusRingType;
|
||||
NSRect _autoresizingFrameError;
|
||||
NSShadow *_shadow;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -735,6 +737,20 @@ PACKAGE_SCOPE
|
|||
@end
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
/*
|
||||
* Core Animation support methods. More methods will be added here as more are implemented.
|
||||
*/
|
||||
|
||||
@interface NSView (CoreAnimationSupport)
|
||||
|
||||
- (NSShadow *) shadow;
|
||||
|
||||
- (void) setShadow: (NSShadow *)shadow;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
@class NSAffineTransform;
|
||||
|
||||
/*
|
||||
|
|
|
@ -325,6 +325,9 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"middleViews", @"NSStackViewMiddleContainer",
|
||||
@"endViews", @"NSStackViewEndContainer",
|
||||
@"collectionViewLayout", @"NSCollectionViewLayout",
|
||||
@"shadow", @"NSViewShadow",
|
||||
@"blurRadius", @"NSShadowBlurRadius",
|
||||
@"color", @"NSShadowColor",
|
||||
nil];
|
||||
RETAIN(XmlKeyMapTable);
|
||||
|
||||
|
@ -445,6 +448,8 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"decodeSecondAttribute:", @"NSSecondAttribute",
|
||||
@"decodeRelation:", @"NSRelation",
|
||||
@"decodeTransitionStyle:", @"NSTransitionStyle",
|
||||
@"decodeShadowOffsetHoriz:", @"NSShadowHoriz",
|
||||
@"decodeShadowOffsetVert:", @"NSShadowVert",
|
||||
nil];
|
||||
RETAIN(XmlKeyToDecoderSelectorMap);
|
||||
|
||||
|
@ -870,12 +875,12 @@ didStartElement: (NSString*)elementName
|
|||
// Need to store element for making the connections...
|
||||
[self addConnection: element];
|
||||
}
|
||||
/*
|
||||
/*
|
||||
else if ([XmlConstraintRecordTags containsObject: elementName])
|
||||
{
|
||||
[self objectForXib: element]; // decode the constraint...
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2984,6 +2989,18 @@ didStartElement: (NSString*)elementName
|
|||
return num;
|
||||
}
|
||||
|
||||
- (id) decodeShadowOffsetHoriz: (GSXibElement *)element
|
||||
{
|
||||
NSSize size = [self decodeSizeForKey: @"offset"];
|
||||
return [NSNumber numberWithFloat: size.width];
|
||||
}
|
||||
|
||||
- (id) decodeShadowOffsetVert: (GSXibElement *)element
|
||||
{
|
||||
NSSize size = [self decodeSizeForKey: @"offset"];
|
||||
return [NSNumber numberWithFloat: size.height];
|
||||
}
|
||||
|
||||
- (id) _decodePlacementForObject: (id)obj
|
||||
{
|
||||
NSGridRowAlignment alignment = NSGridCellPlacementNone;
|
||||
|
@ -3186,13 +3203,13 @@ didStartElement: (NSString*)elementName
|
|||
if (toolTipString != nil)
|
||||
{
|
||||
if ([object respondsToSelector: @selector(setToolTip:)])
|
||||
{
|
||||
[object setToolTip: toolTipString];
|
||||
}
|
||||
{
|
||||
[object setToolTip: toolTipString];
|
||||
}
|
||||
else if ([object respondsToSelector: @selector(setHeaderToolTip:)])
|
||||
{
|
||||
[object setHeaderToolTip: toolTipString];
|
||||
}
|
||||
{
|
||||
[object setHeaderToolTip: toolTipString];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
_radius = [aDecoder decodeFloatForKey: @"NSShadowBlurRadius"];
|
||||
_offset = NSMakeSize([aDecoder decodeFloatForKey: @"NSShadowHoriz"],
|
||||
[aDecoder decodeFloatForKey: @"NSShadowVert"]);
|
||||
_color = [[aDecoder decodeObjectForKey: @"NSShadowColor"] retain];
|
||||
_color = RETAIN([aDecoder decodeObjectForKey: @"NSShadowColor"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -136,7 +136,7 @@
|
|||
[aDecoder decodeValueOfObjCType: @encode(float) at: &radius];
|
||||
_radius = radius;
|
||||
_offset = [aDecoder decodeSize];
|
||||
_color = [[aDecoder decodeObject] retain];
|
||||
_color = RETAIN([aDecoder decodeObject]);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#import "AppKit/NSPrintInfo.h"
|
||||
#import "AppKit/NSPrintOperation.h"
|
||||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSShadow.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSWorkspace.h"
|
||||
|
@ -569,7 +570,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
viewClass = [NSView class];
|
||||
rectClass = [GSTrackingRect class];
|
||||
NSDebugLLog(@"NSView", @"Initialize NSView class\n");
|
||||
[self setVersion: 1];
|
||||
[self setVersion: 2];
|
||||
|
||||
// expose bindings
|
||||
[self exposeBinding: NSToolTipBinding];
|
||||
|
@ -771,6 +772,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
TEST_RELEASE(_cursor_rects);
|
||||
TEST_RELEASE(_tracking_rects);
|
||||
TEST_RELEASE(_shadow);
|
||||
|
||||
[self unregisterDraggedTypes];
|
||||
[self releaseGState];
|
||||
|
||||
|
@ -4608,6 +4611,12 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
|
|||
{
|
||||
[aCoder encodeConditionalObject: _super_view forKey: @"NSSuperview"];
|
||||
}
|
||||
|
||||
// Encode the shadow...
|
||||
if (_shadow != nil)
|
||||
{
|
||||
[aCoder encodeConditionalObject: _shadow forKey: @"NSViewShadow"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4625,6 +4634,9 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
|
|||
[aCoder encodeConditionalObject: [self nextKeyView]];
|
||||
[aCoder encodeConditionalObject: [self previousKeyView]];
|
||||
[aCoder encodeObject: _sub_views];
|
||||
|
||||
// Encode view effects attributes...
|
||||
[aCoder encodeConditionalObject: [self shadow]];
|
||||
NSDebugLLog(@"NSView", @"NSView: finish encoding\n");
|
||||
}
|
||||
}
|
||||
|
@ -4737,12 +4749,19 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
|
|||
[self didAddSubview: sub];
|
||||
}
|
||||
|
||||
// Decode the shadow...
|
||||
if ([aDecoder containsValueForKey: @"NSViewShadow"])
|
||||
{
|
||||
_shadow = RETAIN([aDecoder decodeObjectForKey: @"NSViewShadow"]);
|
||||
}
|
||||
|
||||
// the superview...
|
||||
//[aDecoder decodeObjectForKey: @"NSSuperview"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRect rect;
|
||||
int version = [aDecoder versionForClassName: @"NSView"];
|
||||
|
||||
NSDebugLLog(@"NSView", @"NSView: start decoding\n");
|
||||
|
||||
|
@ -4798,6 +4817,12 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
|
|||
[self didAddSubview: sub];
|
||||
}
|
||||
RELEASE(subs);
|
||||
|
||||
// Decode the shadow if this is version 2 or greater...
|
||||
if (version >= 2)
|
||||
{
|
||||
_shadow = RETAIN([aDecoder decodeObject]);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -5484,3 +5509,17 @@ cmpFrame(id view1, id view2, void *context)
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSView (CoreAnimationSupport)
|
||||
|
||||
- (NSShadow *) shadow
|
||||
{
|
||||
return _shadow;
|
||||
}
|
||||
|
||||
- (void) setShadow: (NSShadow *)shadow
|
||||
{
|
||||
ASSIGN(_shadow, shadow);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue