| 195 | } |
| 196 | |
| 197 | void ScrollViewCore::updateContent(const std::shared_ptr<View> &content) |
| 198 | { |
| 199 | _childGeometry.reset(); |
| 200 | _jContentParent.removeAllViews(); |
| 201 | |
| 202 | if (auto childCore = contentView->core<android::ViewCore>()) { |
| 203 | _jContentParent.addView(childCore->getJView()); |
| 204 | _childGeometry = std::make_unique<Property<Rect>>(); |
| 205 | _childGeometry->bind(childCore->geometry, BindMode::unidirectional); |
| 206 | _childGeometry->onChange() += [=](auto &property) { |
| 207 | _jContentParent.setSize(std::lround(property.get().width * getUIScaleFactor()), |
| 208 | std::lround(property.get().height * getUIScaleFactor())); |
| 209 | }; |
| 210 | } else { |
| 211 | throw std::runtime_error("Cannot add Child with this type of core"); |
| 212 | } |
| 213 | |
| 214 | updateChildren(); |
| 215 | } |
| 216 | |
| 217 | void ScrollViewCore::updateGeometry() |
| 218 | { |