#pragma once
// rect.h — the one concrete pixel rectangle. XYWH storage, half-open on both axes: a rect
// covers [x, x+width) x [y, y+height) — matches the LICE/SWELL RECT convention.

namespace reasampler::ui {

struct Rect {
    int x = 0;
    int y = 0;
    int width = 0;
    int height = 0;

    int right() const { return x + width; }
    int bottom() const { return y + height; }

    // Zero-or-negative area means "not placed / suppressed" — caller must not draw or hit-test it.
    bool empty() const { return width <= 0 || height <= 0; }

    // LTRB constructor for call sites that think in edges rather than extents.
    static Rect ltrb(int left, int top, int right, int bottom) {
        return Rect{left, top, right - left, bottom - top};
    }

    bool operator==(const Rect& o) const {
        return x == o.x && y == o.y && width == o.width && height == o.height;
    }
    bool operator!=(const Rect& o) const { return !(*this == o); }
};

// Half-open containment; an empty rect contains nothing, so a suppressed affordance never
// claims a click.
inline bool contains(const Rect& r, int px, int py) {
    return px >= r.x && px < r.x + r.width && py >= r.y && py < r.y + r.height;
}

}  // namespace reasampler::ui
