//
//  ColorPlotWindowController.h
//  SnoopX
//
//  Owns the popup window that hosts a ColorPlotView. Handles geometry
//  (waveform window matches the snoop window's width and sits directly
//  above or below it), and reports user-initiated closes back to its
//  delegate so the menu state can reset.
//

#import <Cocoa/Cocoa.h>
#import "ColorPlotView.h"

@class ColorPlotWindowController;

@protocol ColorPlotWindowControllerDelegate <NSObject>
- (void) colorPlotWindowDidUserClose:(ColorPlotWindowController*)wc;
@end

@interface ColorPlotWindowController : NSWindowController <NSWindowDelegate> {
	ColorPlotView *plotView;
	ColorPlotMode plotMode;
	BOOL closingProgrammatically;
	id<ColorPlotWindowControllerDelegate> plotDelegate; // unretained
}

@property(nonatomic, assign) id<ColorPlotWindowControllerDelegate> plotDelegate;
@property(nonatomic, readonly) ColorPlotMode plotMode;

- (instancetype) initWithMode:(ColorPlotMode)mode;
- (void) setMode:(ColorPlotMode)mode;

// Replaces the displayed snapshot. Takes ownership of newSnap.pixels.
- (void) updateSnapshot:(SnoopxFrameSnapshot)newSnap;

// Tells the popup the current snoop-window cursor pixel color, so the vectorscope
// can mark its HSV position with an open red square.
- (void) updateCursorR:(float)r G:(float)g B:(float)b;

// Position relative to the snoop window. For Waveform: width-match snoop window
// and sit directly above (or below if no room above, or anywhere visible if neither).
// For Vectorscope: place a fixed-size square to the right of the snoop window when
// possible, else wherever fits on screen.
- (void) repositionRelativeToWindow:(NSWindow*)mainWindow;

// Programmatic close that suppresses the user-close delegate callback.
- (void) closeProgrammatically;

@end
