//
//  ColorPlotView.h
//  SnoopX
//
//  NSView that renders either an HSV-polar vectorscope or an RGB waveform plot
//  summarizing the most recent capture frame.
//

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

typedef enum {
	ColorPlotModeVectorscope = 0,
	ColorPlotModeWaveform = 1,
	ColorPlotModeHistogram = 2
} ColorPlotMode;

// Vertical margins inside the waveform view, reserved for axis labels.
// The chart area's height = view height − (top + bottom).
extern const CGFloat ColorPlotWaveformTopMargin;
extern const CGFloat ColorPlotWaveformBottomMargin;

// RGB → HSV (H in degrees 0..360, S in 0..1, V is the max channel and may
// exceed 1.0 in HDR). Inputs may be negative or > 1; caller should clamp/use
// at its discretion.
void SnoopxRGBToHSV(float r, float g, float b, float *outH, float *outS, float *outV);

@interface ColorPlotView : NSView {
	ColorPlotMode plotMode;
	SnoopxFrameSnapshot snapshot;
	BOOL hasCursorColor;
	float cursorR, cursorG, cursorB;
}

- (void) setPlotMode:(ColorPlotMode)mode;

// Replaces the current snapshot. Takes ownership of newSnap->pixels (the view will
// free it on the next replacement or on dealloc). Pass {0} to clear.
- (void) setSnapshot:(SnoopxFrameSnapshot)newSnap;

// Set the snoop window's center-pixel color so the vectorscope can mark its
// HSV position with an open red square. Pass r=g=b=NAN (or call -clearCursorColor)
// to remove the marker.
- (void) setCursorR:(float)r G:(float)g B:(float)b;
- (void) clearCursorColor;

@end
