diff --git a/doric-Qt/example/app/demo/DoricDemoBridge.cpp b/doric-Qt/example/app/demo/DoricDemoBridge.cpp index f66643f3..fbd5a976 100644 --- a/doric-Qt/example/app/demo/DoricDemoBridge.cpp +++ b/doric-Qt/example/app/demo/DoricDemoBridge.cpp @@ -27,33 +27,36 @@ void DoricDemoBridge::navigate(QVariant route) { name = "ImageDemo.js"; break; case 4: - name = "LayoutDemo.js"; + name = "InputDemo.js"; break; case 5: - name = "LayoutTestDemo.js"; + name = "LayoutDemo.js"; break; case 6: - name = "ModalDemo.js"; + name = "LayoutTestDemo.js"; break; case 7: - name = "NetworkDemo.js"; + name = "ModalDemo.js"; break; case 8: - name = "PopoverDemo.js"; + name = "NetworkDemo.js"; break; case 9: - name = "ScrollerDemo.js"; + name = "PopoverDemo.js"; break; case 10: - name = "SimpleDemo.js"; + name = "ScrollerDemo.js"; break; case 11: - name = "Snake.js"; + name = "SimpleDemo.js"; break; case 12: - name = "StorageDemo.js"; + name = "Snake.js"; break; case 13: + name = "StorageDemo.js"; + break; + case 14: name = "TextDemo.js"; break; } diff --git a/doric-Qt/example/app/main.qml b/doric-Qt/example/app/main.qml index 147b67e4..8811add5 100644 --- a/doric-Qt/example/app/main.qml +++ b/doric-Qt/example/app/main.qml @@ -15,7 +15,7 @@ ApplicationWindow { ListView { width: parent.width - model: 14 + model: 15 delegate: Rectangle { Column { anchors.centerIn: parent @@ -31,24 +31,26 @@ ApplicationWindow { case 3: return "ImageDemo.js" case 4: - return "LayoutDemo.js" + return "InputDemo.js" case 5: - return "LayoutTestDemo.js" + return "LayoutDemo.js" case 6: - return "ModalDemo.js" + return "LayoutTestDemo.js" case 7: - return "NetworkDemo.js" + return "ModalDemo.js" case 8: - return "PopoverDemo.js" + return "NetworkDemo.js" case 9: - return "ScrollerDemo.js" + return "PopoverDemo.js" case 10: - return "SimpleDemo.js" + return "ScrollerDemo.js" case 11: - return "Snake.js" + return "SimpleDemo.js" case 12: - return "StorageDemo.js" + return "Snake.js" case 13: + return "StorageDemo.js" + case 14: return "TextDemo.js" } } diff --git a/doric-Qt/example/app/qml.qrc b/doric-Qt/example/app/qml.qrc index 168d1688..8347b124 100644 --- a/doric-Qt/example/app/qml.qrc +++ b/doric-Qt/example/app/qml.qrc @@ -9,6 +9,7 @@ ../../../doric-demo/bundle/src/EffectsDemo.js ../../../doric-demo/bundle/src/Gobang.js ../../../doric-demo/bundle/src/ImageDemo.js + ../../../doric-demo/bundle/src/InputDemo.js ../../../doric-demo/bundle/src/LayoutDemo.js ../../../doric-demo/bundle/src/LayoutTestDemo.js ../../../doric-demo/bundle/src/ModalDemo.js @@ -35,6 +36,7 @@ ../doric/resources/scroller.qml ../doric/resources/image.qml ../doric/resources/slider.qml + ../doric/resources/input.qml ../doric/resources/toast.qml ../doric/resources/alert.qml diff --git a/doric-Qt/example/doric/DoricRegistry.cpp b/doric-Qt/example/doric/DoricRegistry.cpp index 3cd10062..0bd0bf87 100644 --- a/doric-Qt/example/doric/DoricRegistry.cpp +++ b/doric-Qt/example/doric/DoricRegistry.cpp @@ -9,6 +9,7 @@ #include "shader/DoricHLayoutNode.h" #include "shader/DoricImageNode.h" +#include "shader/DoricInputNode.h" #include "shader/DoricRootNode.h" #include "shader/DoricScrollerNode.h" #include "shader/DoricStackNode.h" @@ -33,6 +34,7 @@ DoricRegistry::DoricRegistry() { registerViewNode("Image"); registerViewNode("Slider"); registerViewNode("SlideItem"); + registerViewNode("Input"); } bool DoricRegistry::acquirePluginInfo(QString name) { diff --git a/doric-Qt/example/doric/doric.pro b/doric-Qt/example/doric/doric.pro index 2044dde3..cbc501a7 100644 --- a/doric-Qt/example/doric/doric.pro +++ b/doric-Qt/example/doric/doric.pro @@ -45,6 +45,7 @@ SOURCES += \ shader/DoricGroupNode.cpp \ shader/DoricHLayoutNode.cpp \ shader/DoricImageNode.cpp \ + shader/DoricInputNode.cpp \ shader/DoricRootNode.cpp \ shader/DoricScrollerNode.cpp \ shader/DoricStackNode.cpp \ @@ -123,6 +124,7 @@ HEADERS += \ shader/DoricGroupNode.h \ shader/DoricHLayoutNode.h \ shader/DoricImageNode.h \ + shader/DoricInputNode.h \ shader/DoricRootNode.h \ shader/DoricScrollerNode.h \ shader/DoricStackNode.h \ diff --git a/doric-Qt/example/doric/resources/input.qml b/doric-Qt/example/doric/resources/input.qml new file mode 100644 index 00000000..e6fd8a39 --- /dev/null +++ b/doric-Qt/example/doric/resources/input.qml @@ -0,0 +1,86 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.5 + +import "util.mjs" as Util +import "gravity.mjs" as Gravity + +TextArea { + property var wrapper + + property var uuid: Util.uuidv4() + + property var tag: "Input" + + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 + + property int textAlignment: 0 + + background: Rectangle { + id: bg + color: 'transparent' + } + + property var backgroundColor + + onBackgroundColorChanged: { + bg.color = backgroundColor + } + + horizontalAlignment: TextInput.AlignLeft + verticalAlignment: TextInput.AlignVCenter + + onTextAlignmentChanged: { + let gravity = Gravity.enumerate() + let result = this.textAlignment | gravity.CENTER_Y + console.log(tag, uuid + " onTextAlignmentChanged: " + this.textAlignment) + switch(result) { + case gravity.CENTER: + this.horizontalAlignment = TextInput.AlignHCenter + this.verticalAlignment = TextInput.AlignVCenter + break + } + } + + onWidthChanged: { + bg.implicitWidth = width + console.log(tag, uuid + " onWidthChanged: " + this.width) + + let tempText = this.text + this.text = "" + this.text = tempText + } + + onHeightChanged: { + bg.implicitHeight = height + console.log(tag, uuid + " onHeightChanged: " + this.height) + + let tempText = this.text + this.text = "" + this.text = tempText + } + + onTextChanged: { + console.log(tag, uuid + " onTextChanged: " + this.text) + } + + property var borderWidth: 0 + onBorderWidthChanged: { + bg.border.width = borderWidth + } + + property var borderColor: "" + onBorderColorChanged: { + bg.border.color = borderColor + } + + MouseArea { + anchors.fill: parent + onClicked: { + console.log(tag, uuid + " wrapper: " + wrapper) + mouseAreaBridge.onClick(wrapper) + } + } +} diff --git a/doric-Qt/example/doric/shader/DoricInputNode.cpp b/doric-Qt/example/doric/shader/DoricInputNode.cpp new file mode 100644 index 00000000..d57280a0 --- /dev/null +++ b/doric-Qt/example/doric/shader/DoricInputNode.cpp @@ -0,0 +1,22 @@ +#include "DoricInputNode.h" + +QQuickItem *DoricInputNode::build() { + QQmlComponent component(getContext()->getQmlEngine()); + + const QUrl url(QStringLiteral("qrc:/doric/qml/input.qml")); + component.loadUrl(url); + + if (component.isError()) { + qCritical() << component.errorString(); + } + + QQuickItem *item = qobject_cast(component.create()); + this->createLayouts(item); + + item->setProperty("wrapper", QString::number((qint64)this)); + return item; +} + +void DoricInputNode::blend(QQuickItem *view, QString name, QJsonValue prop) { + { DoricViewNode::blend(view, name, prop); } +} diff --git a/doric-Qt/example/doric/shader/DoricInputNode.h b/doric-Qt/example/doric/shader/DoricInputNode.h new file mode 100644 index 00000000..9cac63e5 --- /dev/null +++ b/doric-Qt/example/doric/shader/DoricInputNode.h @@ -0,0 +1,17 @@ +#ifndef DORICINPUTNODE_H +#define DORICINPUTNODE_H + +#include "DoricExport.h" + +#include "DoricViewNode.h" + +class DORIC_EXPORT DoricInputNode : public DoricViewNode { +public: + using DoricViewNode::DoricViewNode; + + QQuickItem *build() override; + + virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; +}; + +#endif // DORICINPUTNODE_H