Skip to content
Repos

DevPlaceApp

C++ 666 B23 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-posts 5.2 (onGeometryChange height of the comment text feeds the edit editor's initial height).
// Reports its placed height to a callback; layout and drawing are those of the child.
#include <functional>

#include "ui/Modifiers.hpp"

namespace dp {

class MeasuredView : public ui::WrapperView {
 public:
  MeasuredView(ui::ViewPtr child, std::function<void(float height)> onHeight)
      : WrapperView(std::move(child)), onHeight_(std::move(onHeight)) {}
  void place(const ui::Rect& r) override {
    WrapperView::place(r);
    if (onHeight_) onHeight_(r.h);
  }

 private:
  std::function<void(float)> onHeight_;
};

}  // namespace dp
41.7ms