#pragma once
// tooltip — layout math + text helper behind the bank_panel's custom hover-delay tooltip. Button
// faces stay short; hovering pops a small tooltip with the full action name, "ReaSampler:"
// display prefix stripped. Custom LICE-kit draw, not the native Win32/SWELL tooltip control, for
// cross-platform uniformity with the rest of the kit.

#include <string>

namespace reasampler::ui {

// Zero-area means "do not draw" (degenerate inputs); caller checks empty() first.
struct TooltipBox {
    int x = 0;
    int y = 0;
    int width = 0;
    int height = 0;

    bool empty() const { return width <= 0 || height <= 0; }

    bool operator==(const TooltipBox& o) const {
        return x == o.x && y == o.y && width == o.width && height == o.height;
    }
};

// gap: vertical gap between anchor button and tooltip. padX/padY: text padding inside the box.
// margin: minimum clearance from client edges when clamping.
struct TooltipSpec {
    int gap = 4;
    int padX = 6;
    int padY = 3;
    int margin = 2;
};

// Strips the action display prefix (e.g. "ReaSampler: ") from a full action name for the
// tooltip face. If fullName doesn't start with prefix, returned unchanged (defensive). Empty
// prefix returns fullName unchanged.
std::string stripActionPrefix(const std::string& fullName, const std::string& prefix);

// Places a tooltip of size (textW + 2*padX) x (textH + 2*padY) for the anchor button rect,
// clamped inside the client rect. Prefers BELOW the anchor, centered; flips ABOVE if it would
// clip the bottom edge, then clamps to stay within `margin` of the client edges. Empty when the
// text extent or client is degenerate. textW/textH are measured by the shell before calling.
TooltipBox computeTooltip(int anchorX, int anchorY, int anchorW, int anchorH,
                          int textW, int textH, int clientW, int clientH,
                          const TooltipSpec& spec);

} // namespace reasampler::ui
