//
//  GlyphsReporterProtocol.h
//  GlyphsReporter
//
//  Created by Georg Seifert on 9.1.12.
//  Copyright 2012 schriftgestaltung.de. All rights reserved.
//

/** GlyphsReporter: The protocol defining the reporter plugin protocol
 The plugin will show in the View menu and can be enabled like other view settings. It has no functionality other then draw something in the active layer.
 */

@class GSEditViewController;
@class GSLayer;

NS_SWIFT_UI_ACTOR
@protocol GlyphsReporter

/// The interface version.
@property (readonly, nonatomic) NSUInteger interfaceVersion NS_SWIFT_NONISOLATED;
/// The title of the plugin.
@property (readonly, nonatomic) NSString *title;

/// Edit view controller containing the layer that is processed.
@property (weak) GSEditViewController *controller;

@optional

/** Is called to asked the plugin to draw anything it likes behind the normal outlines

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")

 @since 2.3 (839)
 */
- (void)drawBackgroundForLayer:(GSLayer *)layer options:(NSDictionary *)options;

/** Is called to asked the plugin to draw anything it likes behind the normal outlines

 implement this method if the automatic scaling gets into your way. You need to check for the current layer and position of the layer yourself.
 @since 2.3 (849)
 @param options A dictionary with some info about the environment (currently "Scale")
 */
- (void)drawBackgroundWithOptions:(NSDictionary *)options;

/** Implement this and return NO if you did all drawing yourself and don’t need the regular outline drawn on top of it.

 This is for inactive layers

 @param layer the layer

 @return return NO if the normal outline drawing should be suppressed.
 */
- (BOOL)needsExtraMainOutlineDrawingForInactiveLayer:(GSLayer *)layer;

/** Implement this and return NO to disable the accent cloud.

 @param layer the layer
 */
- (BOOL)shouldDrawAccentCloudForLayer:(GSLayer *)layer;

/** Implement this and return NO if you did all drawing yourself and don’t need the regular outline drawn on top of it.

 This is for active layers

 @param layer the layer

 @return return NO if the normal outline drawing should be suppressed.
 */
- (BOOL)needsExtraMainOutlineDrawingForActiveLayer:(GSLayer *)layer;

/** Is called to asked the plugin to draw anything it likes above the normal outlines

 @warning Deprecated in version 2.3, Use @see drawForegroundForLayer:options:

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 */
- (void)drawForegroundForLayer:(GSLayer *)layer __attribute__((unavailable("use: drawForegroundForLayer:options:")));

/** Is called to asked the plugin to draw anything it likes above the normal outlines

 implement this method if the automatic scaling gets into your way. You need to check for the current layer and position of the layer yourself.
 @since 2.3 (849)

 @param options A dictionary with some info about the environment (currently "Scale")
 */
- (void)drawForegroundWithOptions:(NSDictionary *)options;

/** Is called to asked the plugin to draw anything it likes above the normal outlines

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")
 @since 2.3 (839)
 */
- (void)drawForegroundForLayer:(GSLayer *)layer options:(NSDictionary *)options;

/** Is called to asked the plugin to draw anything it likes behind the normal outlines in an inactive layer

 @warning Deprecated in version 2.3, Use @see drawBackgroundForInactiveLayer:options:

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 */
- (void)drawBackgroundForInactiveLayer:(GSLayer *)layer __attribute__((unavailable("use: drawBackgroundForInactiveLayer:options:")));

/** Is called to asked the plugin to draw anything it likes behind the normal outlines in an inactive layer

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")
 @since 2.3 (839)
 */
- (void)drawBackgroundForInactiveLayer:(GSLayer *)layer options:(NSDictionary *)options;

/** Is called to asked the plugin to draw anything it likes in front the normal outlines in an inactive layer

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")
 @since 2.5 (1120)
 */
- (void)drawForegroundForInactiveLayer:(GSLayer *)layer options:(NSDictionary *)options;

#pragma mark Preview Drawing

/** Is called to asked the plugin to draw anything it likes in behind the normal outlines in the Preview View

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")
 @since 3.2
 */
- (void)drawBackgroundInPreviewLayer:(GSLayer *)layer options:(NSDictionary *)options;

/** Draw in the preview view in view coordinates

 @param options A dictionary with some info about the environment (currently "Scale")
 @since 4
 */

- (void)drawPreviewWithOptions:(NSDictionary *)options;

/** Implement this and return NO if you did all drawing yourself and don’t need the regular outline drawn on top of it.

 @return return NO if the normal outline drawing should be suppressed.
 */
- (BOOL)needsExtraMainOutlineDrawingInPreview;

/** Is called to asked the plugin to draw anything it likes in front the normal outlines in the Preview View

 The scaling and positioning is taken care of. That means you need to draw unscaled and the scaling will be done automatically. If you need to draw something with absolute size, you need to counter scale it.

 @param layer The Layer to draw
 @param options A dictionary with some info about the environment (currently "Scale")
 @since 3.2
 */
- (void)drawForegroundInPreviewLayer:(GSLayer *)layer options:(NSDictionary *)options;

/** Implement this and return NO if you did all drawing yourself and don’t need the regular outline drawn on top of it.

 @param layer the layer

 @return return NO if the normal outline drawing should be suppressed.
 @since 3.2
 */
- (BOOL)needsExtraMainOutlineDrawingInPreviewLayer:(GSLayer *)layer;

/** Is called when a reporter is activated.

 Use it to run expensive operations to initialize the plugin
 */
- (void)willActivate;

/** Is called when a reporter is deactivated.

 Use this to clean up.
 */
- (void)willDeactivate;

/** The keyEquivalent to select the reporter.

 @see modifierMask
 */
- (NSString *)keyEquivalent;

#if !TARGET_OS_IOS
/** The modifier mask that is combined with the keyEquivalent.

 @see keyEquivalent
 */
- (NSEventModifierFlags)modifierMask;

/** add something to the context menu

 Will be called for active reporter plugins. This allows to have some settings.

 @param theEvent the Event that initiated the context menu. That can be used to determine mouse position.
 @param theMenu  the NSMenu where you can add your menu items.
 */
- (void)addMenuItemsForEvent:(NSEvent *)theEvent toMenu:(NSMenu *)theMenu;

- (void)addMenuItemsForEvent:(NSEvent *)theEvent controller:(GSEditViewController *)controller toMenu:(NSMenu *)theMenu;

- (void)drawFontViewBackgroundForLayer:(GSLayer *)layer inFrame:(NSRect)frame options:(NSDictionary *)options NS_SWIFT_NONISOLATED;

- (void)drawFontViewForegroundForLayer:(GSLayer *)layer inFrame:(NSRect)frame options:(NSDictionary *)options NS_SWIFT_NONISOLATED;

- (void)drawFontViewBackgroundForLayer:(GSLayer *)layer inFrame:(NSRect)frame NS_SWIFT_NONISOLATED GSDeprecated("drawFontViewBackgroundForLayer:inFrame:options:");

- (void)drawFontViewForegroundForLayer:(GSLayer *)layer inFrame:(NSRect)frame NS_SWIFT_NONISOLATED GSDeprecated("drawFontViewForegroundForLayer:inFrame:options:");
#endif

- (void)viewWillDraw;

@end
