refactor doric panel; add blend method
This commit is contained in:
parent
7ced952a57
commit
ea0b87df24
@ -1,7 +1,7 @@
|
||||
#include "DoricPanel.h"
|
||||
#include "shader/DoricRootNode.h"
|
||||
|
||||
DoricPanel::DoricPanel() {}
|
||||
DoricPanel::DoricPanel(QQuickItem *quickItem) { mQuickItem = quickItem; }
|
||||
|
||||
void DoricPanel::config(QString script, QString alias, QString extra) {
|
||||
DoricContext *context = DoricContext::create(script, alias, extra);
|
||||
@ -10,6 +10,6 @@ void DoricPanel::config(QString script, QString alias, QString extra) {
|
||||
|
||||
void DoricPanel::config(DoricContext *context) {
|
||||
this->mContext = context;
|
||||
this->mContext->getRootNode()->setRootView(this);
|
||||
this->mContext->build(width(), height());
|
||||
this->mContext->getRootNode()->setRootView(mQuickItem);
|
||||
this->mContext->build(mQuickItem->width(), mQuickItem->height());
|
||||
}
|
||||
|
@ -5,14 +5,16 @@
|
||||
|
||||
#include "DoricContext.h"
|
||||
|
||||
class DoricPanel : public QQuickItem {
|
||||
class DoricPanel {
|
||||
private:
|
||||
DoricContext *mContext;
|
||||
int renderedWidth = -1;
|
||||
int renderedHeight = -1;
|
||||
|
||||
QQuickItem *mQuickItem;
|
||||
|
||||
public:
|
||||
DoricPanel();
|
||||
DoricPanel(QQuickItem *quickItem);
|
||||
|
||||
void config(QString script, QString alias, QString extra);
|
||||
|
||||
|
@ -21,23 +21,18 @@ void DoricDemoBridge::navigate(QVariant route) {
|
||||
view->setHeight(800);
|
||||
}
|
||||
|
||||
DoricPanel *panel = new DoricPanel();
|
||||
panel->setParentItem(view->rootObject());
|
||||
panel->setWidth(450);
|
||||
panel->setHeight(800);
|
||||
panel->config(script, name, NULL);
|
||||
{
|
||||
QQmlComponent component(view->engine());
|
||||
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
||||
component.loadUrl(url);
|
||||
QQuickItem *quickItem = qobject_cast<QQuickItem *>(component.create());
|
||||
DoricPanel *panel = new DoricPanel(quickItem);
|
||||
quickItem->setWidth(450);
|
||||
quickItem->setHeight(800);
|
||||
quickItem->setParentItem(view->rootObject());
|
||||
|
||||
QQmlEngine *engine = view->engine();
|
||||
QQmlComponent component(engine);
|
||||
const QUrl empty(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
||||
component.loadUrl(empty);
|
||||
QQuickItem *childItem = qobject_cast<QQuickItem *>(component.create());
|
||||
|
||||
if (childItem == nullptr) {
|
||||
qCritical() << component.errorString();
|
||||
return;
|
||||
panel->config(script, name, NULL);
|
||||
}
|
||||
childItem->setParentItem(view->rootObject());
|
||||
|
||||
view->show();
|
||||
break;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.14.0, 2021-02-19T15:04:39. -->
|
||||
<!-- Written by QtCreator 4.14.0, 2021-02-19T18:27:52. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -1,8 +1,5 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.5
|
||||
|
||||
Rectangle {
|
||||
width: 100
|
||||
height: 100
|
||||
color: 'red'
|
||||
StackView {
|
||||
}
|
||||
|
@ -1 +1,19 @@
|
||||
#include "DoricGroupNode.h"
|
||||
|
||||
void DoricGroupNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
if (name == "children") {
|
||||
mChildViewIds.clear();
|
||||
if (prop.isArray()) {
|
||||
qDebug() << prop.toString();
|
||||
}
|
||||
} else {
|
||||
DoricSuperNode::blend(view, name, prop);
|
||||
}
|
||||
}
|
||||
|
||||
void DoricGroupNode::blend(QJSValue jsValue) {
|
||||
DoricViewNode::blend(jsValue);
|
||||
configChildNode();
|
||||
}
|
||||
|
||||
void DoricGroupNode::configChildNode() {}
|
||||
|
@ -6,6 +6,17 @@
|
||||
class DoricGroupNode : public DoricSuperNode {
|
||||
public:
|
||||
using DoricSuperNode::DoricSuperNode;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
|
||||
virtual void blend(QJSValue jsValue) override;
|
||||
|
||||
protected:
|
||||
QList<DoricViewNode *> mChildNodes;
|
||||
|
||||
QList<QString> mChildViewIds;
|
||||
|
||||
void configChildNode();
|
||||
};
|
||||
|
||||
#endif // DORICGROUPNODE_H
|
||||
|
@ -1 +1,11 @@
|
||||
#include "DoricSuperNode.h"
|
||||
|
||||
void DoricSuperNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
if (name == "subviews") {
|
||||
if (prop.isArray()) {
|
||||
qDebug() << prop.toString();
|
||||
}
|
||||
} else {
|
||||
DoricViewNode::blend(view, name, prop);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
class DoricSuperNode : public DoricViewNode {
|
||||
|
||||
protected:
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
|
||||
void blendSubLayoutConfig(DoricViewNode *viewNode);
|
||||
|
||||
public:
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "DoricViewNode.h"
|
||||
#include <QJSValueIterator>
|
||||
|
||||
#include "../utils/DoricUtils.h"
|
||||
#include "DoricSuperNode.h"
|
||||
#include "DoricViewNode.h"
|
||||
|
||||
void DoricViewNode::blendLayoutConfig() {}
|
||||
|
||||
@ -19,4 +21,18 @@ QString DoricViewNode::getId() { return mId; }
|
||||
|
||||
void DoricViewNode::setId(QString id) { mId = id; }
|
||||
|
||||
void DoricViewNode::blend(QJSValue jsValue) { qDebug() << jsValue.toString(); }
|
||||
void DoricViewNode::blend(QJSValue jsValue) {
|
||||
QJSValueIterator it(jsValue);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
qDebug() << it.name() << ": " << it.value().toString();
|
||||
blend(mView, it.name(), it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void DoricViewNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
if (name == "width") {
|
||||
|
||||
} else if (name == "height") {
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
|
||||
void setId(QString id);
|
||||
|
||||
void blend(QJSValue jsValue);
|
||||
virtual void blend(QJSValue jsValue);
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop);
|
||||
};
|
||||
#endif // DORICVIEWNODE_H
|
||||
|
Reference in New Issue
Block a user