//
//  MSFilter.h
//  CoreImage
//
//  Created by Pieter Omvlee on 22-11-06.
//  Copyright 2006 GetDrawIt. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <PluginFramework/PluginFramework.h>

#import "MSChild.h"
#import "MSPointArray.h"

#import "MSSelectImageSheet.h"

@class MSFilterController;
@class MSFilterView;

@interface MSFilter : MSChild
{
  CIFilter *filter;
  NSString *name;
  NSMutableDictionary *attributes;
  MSPointArray *points;
  MSFilterPlugin *filterPlugin;
  BOOL maskResult;
  
  BOOL isHidden;
  BOOL isCollapsed;
  
  NSBezierPath *bezierBounds; //een filter kan de boundingbox wijzigen; crop, rounded edges, etc
}
@property (retain) NSBezierPath *bezierBounds;

+ (id)filterWithName:(NSString *)filterWithName controller:(id)d;
- (id)initWithName:(NSString *)filtername controller:(id)d;
- (CIImage *)applyFilterToImage:(CIImage *)image innerFrame:(NSRect)f specialCase:(BOOL)b originalImage:(id)original;

- (NSString *)displayName;
- (NSString *)name;

- (NSDictionary *)defaultAttributes;
- (NSMutableDictionary *)attributes;
- (void)setAttributes:(NSMutableDictionary *)dict;

- (MSPointArray *)points;
- (void)setPoints:(MSPointArray *)points;

- (BOOL)usesDefaultMaskResult:(NSString *)s;

- (void)sendUpdate;

- (void)applyDefaults;

+ (NSString *)displayNameForFilterName:(NSString *)n;

- (id)filterPlugin;

- (BOOL)visible;
- (IBAction)setVisibleAction:(id)sender;

- (BOOL)isCollapsed;
- (IBAction)setCollapsedAction:(id)sender;

- (void)gotFocus:(id)image rect:(NSRect)layerFrame;
- (void)lostFocus:(id)image rect:(NSRect)layerFrame;

@end

@interface NSObject (MSFilterPluginInterface)
//for example @"Inner Shadow"
+ (NSString *)displayName;
- (NSString *)displayName;
- (id)render:(id)image inFrame:(NSRect)rect effectOnly:(BOOL)effectOnly originalImage:(id)original;
- (NSArray *)attributeKeys;
- (NSString *)displayNameForKey:(NSString *)key;
- (NSString *)typeForKey:(NSString *)key;
- (id)defaultValueForKey:(NSString *)key;
- (NSArray *)defaultValuesForOptionKey:(NSString *)key;
- (id)minValueForKey:(NSString *)key;
- (id)maxValueForKey:(NSString *)key;
- (void)gotFocus:(id)img rect:(NSRect)layerFrame;
- (void)lostFocus:(id)img rect:(NSRect)layerFrame;
- (BOOL)requiresFullUpdate;
- (BOOL)usesDefaultMaskOption;
- (BOOL)ignoresSpecialOption;
@end
