add input demo
This commit is contained in:
@@ -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<DoricImageNode>("Image");
|
||||
registerViewNode<DoricSliderNode>("Slider");
|
||||
registerViewNode<DoricSlideItemNode>("SlideItem");
|
||||
registerViewNode<DoricInputNode>("Input");
|
||||
}
|
||||
|
||||
bool DoricRegistry::acquirePluginInfo(QString name) {
|
||||
|
@@ -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 \
|
||||
|
86
doric-Qt/example/doric/resources/input.qml
Normal file
86
doric-Qt/example/doric/resources/input.qml
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
22
doric-Qt/example/doric/shader/DoricInputNode.cpp
Normal file
22
doric-Qt/example/doric/shader/DoricInputNode.cpp
Normal file
@@ -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<QQuickItem *>(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); }
|
||||
}
|
17
doric-Qt/example/doric/shader/DoricInputNode.h
Normal file
17
doric-Qt/example/doric/shader/DoricInputNode.h
Normal file
@@ -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
|
Reference in New Issue
Block a user