handle input on text change & padding
This commit is contained in:
17
doric-Qt/example/doric/utils/DoricInputBridge.cpp
Normal file
17
doric-Qt/example/doric/utils/DoricInputBridge.cpp
Normal 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);
|
||||
}
|
22
doric-Qt/example/doric/utils/DoricInputBridge.h
Normal file
22
doric-Qt/example/doric/utils/DoricInputBridge.h
Normal 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
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user