#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 #include "ui/View.hpp" namespace dp { class ReactionRowView : public ui::View { public: ReactionRowView(std::vector chips, ui::ViewPtr more, float spacing); struct Plan { std::vector sizes; std::vector 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& 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& 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 visible_; int visibleChips_ = 0; }; } // namespace dp