#pragma once
// Spec: INV-posts 7.4 (ReactionRowLayout). One row of chips that never wraps: when not everything fits the longest
// prefix that leaves room for the trailing "more" chip is shown, the rest is parked off screen.
// Children: chip 0..n-1 followed by the "more" chip.
#include <vector>
#include "ui/View.hpp"
namespace dp {
class ReactionRowView : public ui::View {
public:
ReactionRowView(std::vector<ui::ViewPtr> chips, ui::ViewPtr more, float spacing);
struct Plan {
std::vector<ui::Size> sizes;
std::vector<bool> visible; // per child, "more" last
ui::Size size;
};
// Pure planning step (unit tested): widths of the chips then of the more chip.
static Plan plan(const std::vector<ui::Size>& chipSizes, ui::Size moreSize, float spacing, float available);
void place(const ui::Rect& r) override;
void draw(ui::Canvas& c) override;
void hits(ui::Point p, std::vector<ui::View*>& out) override;
int visibleChipCount() const { return visibleChips_; }
protected:
ui::Size compute(const ui::Proposal& p) override;
private:
Plan planFor(const ui::Proposal& p);
float spacing_;
std::vector<bool> visible_;
int visibleChips_ = 0;
};
} // namespace dp