// embed_strip.h — layout + hit-test for the embedded TCP/MCP strip. Mirror of
// editor_geometry/mode_switch; the embed shell marshals REAPER's embed messages (paint
// bitmap + mouse coords) into these functions.
//
// A single compact band REAPER draws inline in the track/mixer control panel via the
// Cockos embedded-UI surface: the loaded capture across the keyboard span (MIDI 0..127
// mapped to the strip width) with its root marked, plus a thin activity level band at the
// bottom. Read-only — the strip displays, it never edits.

#pragma once

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

namespace reasampler::instrument::ui {

inline constexpr int kEmbedKeyCount = 128;

// Fixed metrics for the strip, exposed so the shell and tests agree.
inline constexpr int kEmbedLevelBandHeight = 4;
inline constexpr int kEmbedKeymapMinHeight = 6;

// Clamped to the area so a degenerate (tiny) size never yields a region spilling outside
// the surface.
struct EmbedLayout {
    Rect keymap;      // top: keyboard-span band
    Rect levelBand;   // bottom: level/activity indicator
};

// Divide a (w x h) embed area into the strip's regions. The level band takes a fixed
// height at the bottom (clamped so it never starves the keymap below
// kEmbedKeymapMinHeight); the keymap takes the rest.
EmbedLayout layoutEmbed(int w, int h);

// Horizontal sub-rect of the keymap band for the inclusive key span [lowNote, highNote].
// Spans the half-open pixel range so adjacent spans tile without a gap or overlap. Notes
// clamp to [0,127] and low clamps to <= high. The loaded capture uses the full span; a
// single-key span (low == high) is the root marker.
Rect keySpanRect(const EmbedLayout& layout, int lowNote, int highNote);

// Filled portion of the level band for a 0..1 level (clamped); left sub-rect of levelBand
// whose width is level * band width.
Rect levelFillRect(const EmbedLayout& layout, double level);

}  // namespace reasampler::instrument::ui
