Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c080014c15
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 407 lines (268 sloc) 10.264 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
#import <Cocoa/Cocoa.h>

// pass in -DDEBUG to gcc in development builds to see some output when you
// don't feel like using a debugger.

#ifdef DEBUG
//#define debug(...) NSLog(__VA_ARGS__)
#else
#define debug(...)
#endif

enum {
    ACBitmapLayer = 1,
    ACShapeLayer = 2,
    ACGroupLayer = 3,
};

enum {
    ACRectangleGraphic = 1,
    ACOvalGraphic = 2,
    ACLineGraphic = 3,
    ACTextGraphic = 4,
    ACImageGraphic = 5,
    ACBezierGraphic = 6,
};

#define ACPLUGIN_SUPPORT 1

// forward decl.
@protocol ACBitmapTool;
@protocol ACImageIOProvider;
@protocol ACImageFilter;
@protocol ACLayer;

@protocol ACPluginManager

- (BOOL)addFilterMenuTitle:(NSString*)menuTitle
         withSuperMenuTitle:(NSString*)superMenuTitle
                     target:(id)target
                     action:(SEL)selector
              keyEquivalent:(NSString*)keyEquivalent
  keyEquivalentModifierMask:(NSUInteger)mask
                 userObject:(id)userObject;

- (BOOL)addActionMenuTitle:(NSString*)menuTitle
         withSuperMenuTitle:(NSString*)superMenuTitle
                     target:(id)target
                     action:(SEL)selector
              keyEquivalent:(NSString*)keyEquivalent
  keyEquivalentModifierMask:(NSUInteger)mask
                 userObject:(id)userObject;


- (void)registerIOProviderForReading:(id<ACImageIOProvider>)provider forUTI:(NSString*)uti;
- (void)registerIOProviderForWriting:(id<ACImageIOProvider>)provider forUTI:(NSString*)uti;
- (void)registerFilterName:(NSString*)filterName constructor:(Class<ACImageFilter>)filterClass;
@end



@interface NSApplication (ACPluginManagerAdditions)
- (id<ACPluginManager>)sharedPluginManager;
@end

@protocol ACPlugin

/*
This will create an instance of our plugin. You really shouldn't need to
worry about this at all.
*/
+ (id)plugin;

/*
This gets called right before the plugin manager registers your plugin.
I'm honestly not sure what you would use it for, but it seemed like a good
idea at the time.
*/
- (void)willRegister:(id<ACPluginManager>)thePluginManager;

/*
didRegister is called right after your plugin is all ready to go.
*/
- (void)didRegister;

/*
Can we handle shape layers? If yes, then our action is handed the layer instead of a CIImage
return [NSNumber numberWithBool:YES];
NSNumber is used to be friendly with scripting languages.
*/
- (NSNumber*)worksOnShapeLayers:(id)userObject;

/*
How about a more general type of "do you work on this type of layer" question:
return [NSNumber numberWithBool:YES];
NSNumber is used to be friendly with scripting languages.
Added in version 3.5
*/
- (NSNumber*)validateForLayer:(id<ACLayer>)layer;


@end



@protocol ACLayer <NSObject>
/* There are currently three types of layers. "Bitmap" layers which contain pixels,
and "Shape" layers which contain Text. And then Group layers, which is a group of layers.
And maybe other things eventually.
Check out the ACLayerType enum for the constants to tell which is which.
*/
- (int)layerType;

// grab a CIImage representation of the layer.
- (CIImage*)CIImage;

// opaqueBounds returns the bounds of the image, not counting any 100% transparent pixels along the edges. If you have a layer style that expands the image size (such as a drop shadow) this is not included in this calculation.
// Added in 3.5
- (NSRect)opaqueBounds;

@property (assign) BOOL visible;
@property (assign) float opacity;
@property (assign) CGBlendMode compositingMode; // aka, also the blend mode.
@property (retain, nonatomic) NSString *layerName;

@end



@protocol ACShapeLayer <ACLayer>

- (NSArray *)selectedGraphics;
- (NSArray *)graphics;

- (id)addRectangleWithBounds:(NSRect)bounds;
- (id)addOvalWithBounds:(NSRect)bounds;
- (id)addTextWithBounds:(NSRect)bounds;

/* added in 3.2.2 */
- (id)addBezierPath:(NSBezierPath*)path;

@end

@protocol ACBitmapLayer <ACLayer>

// set a CIImage on the layer, to be a "preview". Make sure to set it to nil when you are
// done with whatever it is you are doing.
- (void)setPreviewCIImage:(CIImage*)img;

// apply a ciimage to the layer.
- (void)applyCIImageFromFilter:(CIImage*)img;

// EXPERIMENTAL new in 1.1
// get a CGBitmapContext that we can draw on.
- (CGContextRef)drawableContext;

// EXPERIMENTAL new in 1.1
// commit the changes we made to the context, for undo support
- (void)commitFrameOfDrawableContext:(NSRect)r;

// EXPERIMENTAL new in 1.1
// find out where on our layer the current mouse event is pointing to
- (NSPoint)layerPointFromEvent:(NSEvent*)theEvent;

// EXPERIMENTAL new in 1.1
// tell the layer it needs to be updated
- (void)setNeedsDisplayInRect:(NSRect)invalidRect;


// what the origin of the bottom left corner of the layer is. It's a silly name, which is why I've added setFrameOrigin: and frameOrigin below.
@property (assign) NSPoint drawDelta;


// same as drawDelta, but with a better name.
- (void)setFrameOrigin:(NSPoint)newOrigin;
- (NSPoint)frameOrigin;


@end

@protocol ACGroupLayer <ACLayer>

- (NSArray *)layers;

- (void)addLayer:(id<ACLayer>)l atIndex:(NSInteger)idx;

- (id<ACBitmapLayer>)insertCGImage:(CGImageRef)img atIndex:(NSUInteger)idx withName:(NSString*)layerName;

+ (id<ACShapeLayer>)addShapeLayer;
+ (id<ACBitmapLayer>)addBitmapLayer;
+ (id<ACGroupLayer>)addGroupLayer;


@end

@protocol ACGraphic <NSObject>

- (int)graphicType;

- (void)setDrawsFill:(BOOL)flag;
- (BOOL)drawsFill;

- (void)setFillColor:(NSColor *)fillColor;
- (NSColor *)fillColor;

- (void)setDrawsStroke:(BOOL)flag;
- (BOOL)drawsStroke;

- (void)setStrokeColor:(NSColor *)strokeColor;
- (NSColor *)strokeColor;

- (void)setStrokeLineWidth:(CGFloat)width;
- (CGFloat)strokeLineWidth;

- (NSRect)bounds;

- (BOOL)hasCornerRadius;
- (void)setHasCornerRadius:(BOOL)flag;

- (CGFloat)cornerRadius;
- (void)setCornerRadius:(CGFloat)newCornerRadius;

- (BOOL)hasShadow;
- (void)setHasShadow:(BOOL)flag;

- (CGFloat)shadowBlurRadius;
- (void)setShadowBlurRadius:(CGFloat)newShadowBlurRadius;

- (NSSize)shadowOffset;
- (void)setShadowOffset:(NSSize)newShadowOffset;

- (NSBezierPath *)bezierPath;

- (int)graphicType;

@end

@protocol ACTextGraphic <ACGraphic>

// added in 3.0.1
- (void)setHTMLString:(NSString*)html;

@end

@protocol ACDocument <NSObject> // this inherits from NSDocument

// grab an array of layers in the document.
- (NSArray*)layers;

// grab the current layer.
- (id<ACLayer>)currentLayer;

// crop to the given rect.
- (void)cropToRect:(NSRect)cropRect;

// start cropping with the given bounds.
- (void)beginCroppingWithRect:(NSRect)cropBounds;

// scale the image to the given size.
- (void)scaleImageToSize:(NSSize)newSize;

- (void)scaleImageToHeight:(CGFloat)newHeight;
- (void)scaleImageToWidth:(CGFloat)newWidth;

// resize the image to the given size.
- (void)resizeImageToSize:(NSSize)newSize;

// find the size of the canvas
- (NSSize)canvasSize;
- (void)setCanvasSize:(NSSize)s;
- (void)setCanvasSize:(NSSize)newSize usingAnchor:(NSString *)anchor;

// new in 2.0

// returns the base group, which contains all the base layers.
- (id<ACGroupLayer>)baseGroup;


- (NSSize)dpi;
- (void)setDpi:(NSSize)newDpi;


- (CGColorSpaceRef)colorSpace;

// new in 2.2:
- (void)askToCommitCurrentAccessory;

// new in 3.3:
- (id<ACLayer>)firstLayerWithName:(NSString*)layerName;

@end

@protocol ACToolPalette <NSObject>

- (NSColor *)frontColor;
- (void)setFrontColor:(NSColor *)newFrontColor;

- (NSColor *)backColor;
- (void)setBackColor:(NSColor *)newBackColor;

@end




// EXPERIMENTAL new in 1.1
// UI taken out in 2.0 - do you want this? Write to support@flyingmeat.com if so.
@protocol ACBitmapTool <NSObject>
- (void)mouseDown:(NSEvent*)theEvent onCanvas:(NSView*)canvas toLayer:(id<ACBitmapLayer>)layer;
- (NSCursor*)toolCursorAtScale:(CGFloat)scale;
- (NSString *)toolName;
- (NSView*)toolPaletteView;
@end


@protocol ACImageIOProvider <NSObject>

- (BOOL)writeDocument:(id<ACDocument>)document toURL:(NSURL *)absoluteURL ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError **)outError;

- (BOOL)readImageForDocument:(id<ACDocument>)document fromURL:(NSURL *)absoluteURL ofType:(NSString *)type error:(NSError **)outError;

@end


@protocol ACUtilities <NSObject>

- (BOOL)crushPNGData:(NSData*)pngData toPath:(NSString*)path;

@end

@interface NSApplication (AcornAdditions)

- (id<ACToolPalette>)toolPalette;
- (id<ACUtilities>)utilitiesHelper;

@end


@protocol ACFilterWindowController <NSObject>
- (void)setNeedsToUpdateImageForFilterController:(id<ACImageFilter>)controller;
@end

@protocol ACImageFilter <NSObject>
+ (id<ACImageFilter>)imageFilterWithName:(NSString*)name;
+ (id<ACImageFilter>)imageFilterWithName:(NSString*)name parameters:(NSDictionary*)params;
+ (BOOL)isLayerStyle;
+ (NSString*)localizedNameForFilterName:(NSString*)filterName;
- (NSString*)localizedName;
- (NSString*)name;
- (id<ACImageFilter>)copy;
- (NSDictionary*)parametersForSaving;
- (BOOL)isEnabled;
- (void)setIsEnabled:(BOOL)enabled;
- (CIImage*)outputImage;
- (void)setInputImage:(CIImage*)image;
- (NSViewController*)viewController;
- (void)unloadViewController;
- (void)assignFilterWindowController:(id<ACFilterWindowController>)filterWindowController; // don't retain this guy!
- (CGFloat)updateExpansion;
- (id<ACImageFilter>)copyWithScale:(CGFloat)scale;
@end





/*
CTGradient is in Acorn, it's just got a different name- "TSGradient".
For more info on CTGradient, visit here:
http://blog.oofn.net/2006/01/15/gradients-in-cocoa/
You can use it like so:
id fade = [NSClassFromString(@"TSGradient") gradientWithBeginningColor:[NSColor clearColor] endingColor:[NSColor blackColor]];
*/
@interface NSObject (TSGradientTrustMeItsThere)
+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end;
- (void)fillRect:(NSRect)rect angle:(CGFloat)angle;
@end

@interface CIImage (PXNSImageAdditions)
- (NSImage *)NSImageFromRect:(CGRect)r;
- (NSImage *)NSImage;

// new in Acorn 3.5
- (BOOL)writeToURL:(NSURL*)fileURL withUTI:(NSString*)uti;
@end

@interface NSImage (PXNSImageAdditions)
- (CIImage *)CIImage;
@end

@interface NSDocumentController (ACNSDocumentControllerAdditions)
- (id)makeUntitledDocumentWithData:(NSData*)data;
- (id)makeUntitledDocumentWithSize:(NSSize)s;
@end




Something went wrong with that request. Please try again.