handle input on text change & padding

This commit is contained in:
王劲鹏
2021-05-27 10:56:58 +08:00
committed by osborn
parent 143e52ab63
commit 2782552b41
11 changed files with 108 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#include "DoricInputBridge.h"
#include "shader/DoricInputNode.h"
DoricInputBridge::DoricInputBridge(QObject *parent) : QObject(parent) {}
void DoricInputBridge::onTextChange(QString pointer, QString text) {
QObject *object = (QObject *)(pointer.toULongLong());
DoricInputNode *inputNode = dynamic_cast<DoricInputNode *>(object);
inputNode->onTextChange(text);
}
void DoricInputBridge::onFocusChange(QString pointer) {
QObject *object = (QObject *)(pointer.toULongLong());
DoricInputNode *inputNode = dynamic_cast<DoricInputNode *>(object);
}

View File

@@ -0,0 +1,22 @@
#ifndef DORICINPUTBRIDGE_H
#define DORICINPUTBRIDGE_H
#include <QObject>
#include <QVariant>
#include "DoricExport.h"
class DORIC_EXPORT DoricInputBridge : public QObject {
Q_OBJECT
public:
explicit DoricInputBridge(QObject *parent = nullptr);
Q_INVOKABLE
void onTextChange(QString pointer, QString text);
Q_INVOKABLE
void onFocusChange(QString pointer);
signals:
};
#endif // DORICINPUTBRIDGE_H

View File

@@ -1,4 +1,5 @@
#include "DoricLayouts.h"
#include "shader/DoricInputNode.h"
#include "shader/DoricScrollerNode.h"
DoricLayouts::DoricLayouts(QObject *parent) : QObject(parent) {
@@ -76,15 +77,19 @@ void DoricLayouts::setMarginBottom(qreal marginBottom) {
void DoricLayouts::setPaddingLeft(qreal paddingLeft) {
this->paddingLeft = paddingLeft;
}
qreal DoricLayouts::getPaddingLeft() { return this->paddingLeft; }
void DoricLayouts::setPaddingTop(qreal paddingTop) {
this->paddingTop = paddingTop;
}
qreal DoricLayouts::getPaddingTop() { return this->paddingTop; }
void DoricLayouts::setPaddingRight(qreal paddingRight) {
this->paddingRight = paddingRight;
}
qreal DoricLayouts::getPaddingRight() { return this->paddingRight; }
void DoricLayouts::setPaddingBottom(qreal paddingBottom) {
this->paddingBottom = paddingBottom;
}
qreal DoricLayouts::getPaddingBottom() { return this->paddingBottom; }
void DoricLayouts::setWeight(int weight) { this->weight = weight; }
@@ -252,6 +257,11 @@ void DoricLayouts::measureUndefinedContent(QSizeF targetSize) {
(QObject *)(this->view->property("wrapper").toULongLong());
DoricScrollerNode *viewNode = dynamic_cast<DoricScrollerNode *>(object);
measuredSize = viewNode->sizeThatFits(targetSize);
} else if (tag == "Input") {
QObject *object =
(QObject *)(this->view->property("wrapper").toULongLong());
DoricInputNode *viewNode = dynamic_cast<DoricInputNode *>(object);
measuredSize = viewNode->sizeThatFits(targetSize);
} else {
qreal actualWidth = this->view->width();
qreal actualHeight = this->view->height();
@@ -268,6 +278,10 @@ void DoricLayouts::measureUndefinedContent(QSizeF targetSize) {
setMeasuredHeight(measuredSize.height() + this->paddingTop +
this->paddingBottom);
}
this->contentWidth = measuredSize.width();
this->contentHeight = measuredSize.height();
}
void DoricLayouts::measureStackContent(QSizeF targetSize) {
qreal contentWidth = 0, contentHeight = 0;

View File

@@ -65,9 +65,13 @@ public:
void setMarginBottom(qreal marginBottom);
void setPaddingLeft(qreal paddingLeft);
qreal getPaddingLeft();
void setPaddingTop(qreal paddingTop);
qreal getPaddingTop();
void setPaddingRight(qreal paddingRight);
qreal getPaddingRight();
void setPaddingBottom(qreal paddingBottom);
qreal getPaddingBottom();
void setWeight(int weight);