#pragma once
// sample_chrome.h — interior geometry of the Sample face's CHROME band: the toolbar row
// (title + the whole right-anchored control run + Browse) over the strip row, which the
// piano strip has to itself. Reads the band rect the allocator hands it (sample_bands) and
// never allocates vertical space of its own. The run is right-anchored and the title takes
// the remainder, so a member added to the run costs the title, never the window's floor.

#include "core/instrument/ui/editor_geometry.h"  // Rect

namespace reasampler::instrument::ui {

inline constexpr int kNavButtonWidth = 62;  // the Browse toolbar button
inline constexpr int kBakeButtonWidth = 54;  // the resample-bake trigger

// Every interactive rect inside the chrome band, in one pass so draw and hit-test cannot
// derive them differently. The toolbar's fixed run is right-anchored and the title takes
// what is left of that row; the strip row carries nothing but the strip, so the strip grows
// with the window in both directions.
struct ChromeRects {
    Rect toolbar;     // full-width top row
    Rect title;       // the title text slot: the toolbar left of the control run
    // The bake Hold cell. Its width is RESERVED unconditionally even though the control is
    // only drawn for a looped Gate sound (bake_plan.h's bakeWindowNeedsHold). It is the
    // LEFTMOST member of the right-anchored run, so no other member moves either way — what
    // the reservation buys is a title slot that holds still: dialling a loop in or out would
    // otherwise re-measure and re-ellipsize the capture name. The cost is ~62 px of dead
    // toolbar in the common non-looped case.
    Rect holdCell;    // ---- the right-anchored run, left to right ----
    Rect holdKnob;
    Rect holdLabel;
    Rect bake;
    Rect preview;
    Rect velCell;     // preview-velocity knob cell (knob + label band)
    Rect velKnob;
    Rect velLabel;
    // The sustain loop's enable. Immediately left of the channel toggle because it is the same
    // class of control — a playback mode of the loaded capture — and because the run is
    // right-anchored, so the title slot absorbs its width and the editor's floor does not move.
    Rect loopOff;
    Rect loopOn;
    Rect chanMono;
    Rect chanStereo;
    Rect navBrowse;
    Rect controls;    // full-width second row
    Rect rootStrip;   // the piano strip: the whole row, inset only by the shared band pad
};

// `knobSize` is the deck knob square, passed in so this module does not depend on knob_deck.
ChromeRects chromeRects(const Rect& chrome, int knobSize);

// A right-pointing play triangle centered in the preview button: the button's whole label.
// Three vertices, handed straight to one filled-triangle draw. Drawn rather than embedded as a
// bitmap so it inherits the palette role of whatever interaction state the button is in.
struct PreviewGlyph {
    int leftX = 0;   // the vertical edge
    int topY = 0;
    int bottomY = 0;
    int apexX = 0;   // the point, on the button's vertical centre line
    int apexY = 0;
    bool empty() const { return apexX <= leftX || bottomY <= topY; }
};

// Sized off the button's shorter dimension and clamped, so the glyph stays legible in a squat
// button and never outgrows a generous one. An unusably small button yields an empty glyph.
PreviewGlyph previewGlyph(const Rect& button);

}  // namespace reasampler::instrument::ui
