mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-24 23:11:04 +00:00
Various improvements in GormImage/GormSound and their editors. Also a very very temporary fix for a recently discovered crash.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20426 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
39b9a92fd4
commit
b1efb8b092
6 changed files with 82 additions and 48 deletions
|
@ -1935,7 +1935,7 @@ static NSImage *fileImage = nil;
|
|||
|
||||
NSDebugLog(@"Add the sound %@", file);
|
||||
soundPath = [documentPath stringByAppendingPathComponent: file];
|
||||
[soundsView addObject: [GormSound soundForPath: soundPath]];
|
||||
[soundsView addObject: [[GormSound alloc] initWithPath: soundPath]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1954,15 +1954,10 @@ static NSImage *fileImage = nil;
|
|||
if ([fileTypes containsObject: [file pathExtension]])
|
||||
{
|
||||
NSString *imagePath;
|
||||
id placeHolder;
|
||||
|
||||
NSDebugLog(@"Add the image %@", file);
|
||||
imagePath = [documentPath stringByAppendingPathComponent: file];
|
||||
placeHolder = [GormImage imageForPath: imagePath];
|
||||
if (placeHolder)
|
||||
{
|
||||
NSDebugLog(@"Add the image %@", file);
|
||||
[imagesView addObject: placeHolder];
|
||||
}
|
||||
[imagesView addObject: [GormImage imageForPath: imagePath]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
}
|
||||
|
||||
+ (GormImage *) imageForPath: (NSString *)path;
|
||||
- (id) initWithPath: (NSString *)aPath;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath;
|
||||
- (void) setImageName: (NSString *)aName;
|
||||
|
|
89
GormImage.m
89
GormImage.m
|
@ -27,51 +27,68 @@
|
|||
|
||||
// image proxy object...
|
||||
@implementation GormImage
|
||||
+ (GormImage*)imageForPath: (NSString *)apath
|
||||
+ (GormImage*)imageForPath: (NSString *)aPath
|
||||
{
|
||||
NSString *aname = [[apath lastPathComponent] stringByDeletingPathExtension];
|
||||
return AUTORELEASE([[GormImage alloc] initWithName: aname path: apath]);
|
||||
return AUTORELEASE([[GormImage alloc] initWithPath: aPath]);
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
{
|
||||
NSString *aName = [[aPath lastPathComponent] stringByDeletingPathExtension];
|
||||
if((self = [self initWithName: aName path: aPath]) == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
{
|
||||
NSSize originalSize;
|
||||
float ratioH;
|
||||
float ratioW;
|
||||
[super init];
|
||||
ASSIGN(name, aName);
|
||||
ASSIGN(path, aPath);
|
||||
image = [[NSImage alloc] initByReferencingFile: aPath];
|
||||
smallImage = [[NSImage alloc] initWithContentsOfFile: aPath];
|
||||
[image setName: aName];
|
||||
|
||||
if (smallImage == nil)
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
RELEASE(name);
|
||||
RELEASE(path);
|
||||
return nil;
|
||||
NSSize originalSize;
|
||||
float ratioH;
|
||||
float ratioW;
|
||||
|
||||
ASSIGN(name, aName);
|
||||
ASSIGN(path, aPath);
|
||||
image = RETAIN([[NSImage alloc] initByReferencingFile: aPath]);
|
||||
smallImage = RETAIN([[NSImage alloc] initWithContentsOfFile: aPath]);
|
||||
[image setName: aName];
|
||||
|
||||
if (smallImage == nil)
|
||||
{
|
||||
RELEASE(name);
|
||||
RELEASE(path);
|
||||
return nil;
|
||||
}
|
||||
|
||||
originalSize = [smallImage size];
|
||||
ratioW = originalSize.width / 70;
|
||||
ratioH = originalSize.height / 55;
|
||||
|
||||
if (ratioH > 1 || ratioW > 1)
|
||||
{
|
||||
[smallImage setScalesWhenResized: YES];
|
||||
if (ratioH > ratioW)
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(originalSize.width / ratioH, 55)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(70, originalSize.height / ratioW)];
|
||||
}
|
||||
}
|
||||
|
||||
isSystemImage = NO;
|
||||
isInWrapper = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
originalSize = [smallImage size];
|
||||
ratioW = originalSize.width / 70;
|
||||
ratioH = originalSize.height / 55;
|
||||
|
||||
if (ratioH > 1 || ratioW > 1)
|
||||
{
|
||||
[smallImage setScalesWhenResized: YES];
|
||||
if (ratioH > ratioW)
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(originalSize.width / ratioH, 55)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(70, originalSize.height / ratioW)];
|
||||
}
|
||||
}
|
||||
|
||||
isSystemImage = NO;
|
||||
isInWrapper = NO;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,6 +256,17 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if(closed == NO)
|
||||
[self close];
|
||||
|
||||
// TODO: This is a band-aid fix until I find the actual problem.
|
||||
// This *WILL* leak, but I don't want it crashing on people.
|
||||
|
||||
NSLog(@"Released...");
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
[super close];
|
||||
|
@ -448,7 +459,7 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
id obj = [objects objectAtIndex: index];
|
||||
NSButtonCell *but = [self cellAtRow: index/cols column: index%cols];
|
||||
NSString *name = [obj imageName];
|
||||
|
||||
|
||||
[but setImage: [obj image]];
|
||||
[but setTitle: name];
|
||||
[but setShowsStateBy: NSChangeGrayCellMask];
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
BOOL isInWrapper;
|
||||
}
|
||||
+ (GormSound*) soundForPath: (NSString *)path;
|
||||
- (id) initWithPath: (NSString *)aPath;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath;
|
||||
- (void) setSoundName: (NSString *)aName;
|
||||
|
|
15
GormSound.m
15
GormSound.m
|
@ -28,10 +28,19 @@
|
|||
|
||||
// sound proxy object...
|
||||
@implementation GormSound
|
||||
+ (GormSound*) soundForPath: (NSString *)apath
|
||||
+ (GormSound*) soundForPath: (NSString *)aPath
|
||||
{
|
||||
NSString *aname = [[apath lastPathComponent] stringByDeletingPathExtension];
|
||||
return AUTORELEASE([[GormSound alloc] initWithName: aname path: apath]);
|
||||
return AUTORELEASE([[GormSound alloc] initWithPath: aPath]);
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
{
|
||||
NSString *aName = [[aPath lastPathComponent] stringByDeletingPathExtension];
|
||||
if((self = [self initWithName: aName path: aPath]) == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
|
|
Loading…
Reference in a new issue