// curve_popup.h — sheet geometry + dismissal test for the velocity-curve popup editor. // Mirror of overflow_menu; the shell draws through the L1 kit and routes clicks via // these rects. // // A centered sheet over the Sample face (a lighter wash than Browse's, since this is a // focused sub-editor, not a view change): width/height each clamp to a fraction of the // window within min/max bounds. A title row sits over the curve box. The curve box rect // here is the border rect — the shell derives the mapping box via its curveBoxFromRect // formula. #pragma once #include "core/instrument/ui/editor_geometry.h" // Rect, contains namespace reasampler::instrument::ui { // Fixed popup metrics, exposed so the shell and tests agree. inline constexpr int kCurvePopupMinW = 360; inline constexpr int kCurvePopupMaxW = 520; inline constexpr int kCurvePopupMinH = 260; inline constexpr int kCurvePopupMaxH = 380; inline constexpr int kCurvePopupTitleH = 22; inline constexpr int kCurvePopupCloseSize = 18; inline constexpr int kCurvePopupPad = 8; // sheet inner padding (title inset + box margins) struct CurvePopupLayout { Rect sheet; Rect title; Rect close; // Close (x) button, right-anchored in the title row Rect curveBox; // full-size curve editor border rect (shell insets via curveBoxFromRect) }; // Popup geometry for a (w x h) window: sheet width clamp(60% w, min..max) and height // clamp(55% h, min..max), each additionally capped at the window dimension so a // degenerate window never yields an overhanging sheet — centered. CurvePopupLayout computeCurvePopup(int w, int h); // True when (x, y) lands outside the sheet (on the wash) — the click-outside dismissal // test. The shell additionally gates on "no drag in flight". bool popupOutsideSheet(const CurvePopupLayout& layout, int x, int y); } // namespace reasampler::instrument::ui