scroller implements

This commit is contained in:
王劲鹏
2021-04-16 10:06:15 +08:00
committed by osborn
parent 5e72a97a41
commit 3207cc2581
7 changed files with 100 additions and 94 deletions

View File

@@ -11,17 +11,14 @@ QQuickItem *DoricScrollerNode::build() {
}
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
this->createLayouts(item);
getLayouts()->setLayoutType(DoricLayoutType::DoricStack);
item->setProperty("wrapper", QString::number((qint64)this));
return item;
}
void DoricScrollerNode::blendSubNode(QJsonValue subProperties) {
if (mChildNode != nullptr) {
mChildNode->blend(subProperties["props"]);
}
}
void DoricScrollerNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
if (name == "content") {
if (!prop.isString()) {
@@ -43,8 +40,7 @@ void DoricScrollerNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
}
}
void DoricScrollerNode::blend(QJsonValue jsValue) {
DoricViewNode::blend(jsValue);
void DoricScrollerNode::afterBlended(QJsonValue jsValue) {
QJsonValue contentModel = getSubModel(mChildViewId);
if (contentModel == QJsonValue::Undefined) {
return;
@@ -54,7 +50,7 @@ void DoricScrollerNode::blend(QJsonValue jsValue) {
QString type = contentModel["type"].toString();
QJsonValue props = contentModel["props"];
QQuickItem *parent = mView->childItems().at(1);
QQuickItem *parent = mView;
if (mChildNode != nullptr) {
if (viewId == mChildNode->getId()) {
@@ -88,3 +84,14 @@ void DoricScrollerNode::blend(QJsonValue jsValue) {
mChildNode->getNodeView()->setParentItem(parent);
}
}
void DoricScrollerNode::requestLayout() {
this->mChildNode->requestLayout();
getLayouts()->apply(mView->width(), mView->height());
}
void DoricScrollerNode::blendSubNode(QJsonValue subProperties) {
if (mChildNode != nullptr) {
mChildNode->blend(subProperties["props"]);
}
}

View File

@@ -18,9 +18,11 @@ public:
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
virtual void blend(QJsonValue jsValue) override;
virtual void blendSubNode(QJsonValue subProperties) override;
virtual void afterBlended(QJsonValue jsValue) override;
virtual void requestLayout() override;
};
#endif // DORICSCROLLERNODE_H