add doric layout
This commit is contained in:
parent
63c8e864d1
commit
46ecc85ece
@ -4,6 +4,7 @@
|
|||||||
#include "shader/DoricRootNode.h"
|
#include "shader/DoricRootNode.h"
|
||||||
#include "shader/DoricStackNode.h"
|
#include "shader/DoricStackNode.h"
|
||||||
#include "shader/DoricVLayoutNode.h"
|
#include "shader/DoricVLayoutNode.h"
|
||||||
|
#include "shader/DoricHLayoutNode.h"
|
||||||
|
|
||||||
DoricRegistry::DoricRegistry() {
|
DoricRegistry::DoricRegistry() {
|
||||||
registerNativePlugin<DoricShaderPlugin>("shader");
|
registerNativePlugin<DoricShaderPlugin>("shader");
|
||||||
@ -11,7 +12,7 @@ DoricRegistry::DoricRegistry() {
|
|||||||
registerViewNode<DoricRootNode>("Root");
|
registerViewNode<DoricRootNode>("Root");
|
||||||
registerViewNode<DoricStackNode>("Stack");
|
registerViewNode<DoricStackNode>("Stack");
|
||||||
registerViewNode<DoricVLayoutNode>("VLayout");
|
registerViewNode<DoricVLayoutNode>("VLayout");
|
||||||
registerViewNode<DoricVLayoutNode>("HLayout");
|
registerViewNode<DoricHLayoutNode>("HLayout");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoricRegistry::acquirePluginInfo(QString name) {
|
bool DoricRegistry::acquirePluginInfo(QString name) {
|
||||||
|
@ -33,6 +33,7 @@ SOURCES += \
|
|||||||
plugin/DoricShaderPlugin.cpp \
|
plugin/DoricShaderPlugin.cpp \
|
||||||
shader/DoricGroupNode.cpp \
|
shader/DoricGroupNode.cpp \
|
||||||
shader/DoricHLayoutNode.cpp \
|
shader/DoricHLayoutNode.cpp \
|
||||||
|
shader/DoricLayout.cpp \
|
||||||
shader/DoricRootNode.cpp \
|
shader/DoricRootNode.cpp \
|
||||||
shader/DoricStackNode.cpp \
|
shader/DoricStackNode.cpp \
|
||||||
shader/DoricSuperNode.cpp \
|
shader/DoricSuperNode.cpp \
|
||||||
@ -78,6 +79,7 @@ HEADERS += \
|
|||||||
plugin/DoricShaderPlugin.h \
|
plugin/DoricShaderPlugin.h \
|
||||||
shader/DoricGroupNode.h \
|
shader/DoricGroupNode.h \
|
||||||
shader/DoricHLayoutNode.h \
|
shader/DoricHLayoutNode.h \
|
||||||
|
shader/DoricLayout.h \
|
||||||
shader/DoricRootNode.h \
|
shader/DoricRootNode.h \
|
||||||
shader/DoricStackNode.h \
|
shader/DoricStackNode.h \
|
||||||
shader/DoricSuperNode.h \
|
shader/DoricSuperNode.h \
|
||||||
|
@ -2,5 +2,6 @@ import QtQuick 2.12
|
|||||||
import QtQuick.Controls 2.5
|
import QtQuick.Controls 2.5
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
|||||||
view->setProperty("spacing", prop.toInt());
|
view->setProperty("spacing", prop.toInt());
|
||||||
} else if (name == "gravity") {
|
} else if (name == "gravity") {
|
||||||
qWarning() << "gravity: " << prop.toInt();
|
qWarning() << "gravity: " << prop.toInt();
|
||||||
|
switch (prop.toInt()) {
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DoricGroupNode::blend(view, name, prop);
|
DoricGroupNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
|
10
doric-Qt/doric/shader/DoricLayout.cpp
Normal file
10
doric-Qt/doric/shader/DoricLayout.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "DoricLayout.h"
|
||||||
|
|
||||||
|
void DoricLayout::apply(int frameSizeWidth, int frameSizeHeight) {
|
||||||
|
this->resolved = false;
|
||||||
|
this->measure(frameSizeWidth, frameSizeHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoricLayout::apply() {}
|
||||||
|
|
||||||
|
void DoricLayout::measure(int targetSizeWidth, int targetSizeHeight) {}
|
94
doric-Qt/doric/shader/DoricLayout.h
Normal file
94
doric-Qt/doric/shader/DoricLayout.h
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#ifndef DORICLAYOUT_H
|
||||||
|
#define DORICLAYOUT_H
|
||||||
|
|
||||||
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
enum DoricLayoutType {
|
||||||
|
DoricUndefined = 0,
|
||||||
|
DoricStack = 1,
|
||||||
|
DoricVLayout = 2,
|
||||||
|
DoricHLayout = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DoricLayoutSpec {
|
||||||
|
DoricLayoutJust = 0,
|
||||||
|
DoricLayoutFit = 1,
|
||||||
|
DoricLayoutMost = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DoricGravity {
|
||||||
|
DoricGravitySpecified = 1,
|
||||||
|
DoricGravityStart = 1 << 1,
|
||||||
|
DoricGravityEnd = 1 << 2,
|
||||||
|
DoricGravityShiftX = 0,
|
||||||
|
DoricGravityShiftY = 4,
|
||||||
|
DoricGravityLeft = (DoricGravityStart | DoricGravitySpecified)
|
||||||
|
<< DoricGravityShiftX,
|
||||||
|
DoricGravityRight = (DoricGravityEnd | DoricGravitySpecified)
|
||||||
|
<< DoricGravityShiftX,
|
||||||
|
DoricGravityTop = (DoricGravityStart | DoricGravitySpecified)
|
||||||
|
<< DoricGravityShiftY,
|
||||||
|
DoricGravityBottom = (DoricGravityEnd | DoricGravitySpecified)
|
||||||
|
<< DoricGravityShiftY,
|
||||||
|
DoricGravityCenterX = DoricGravitySpecified << DoricGravityShiftX,
|
||||||
|
DoricGravityCenterY = DoricGravitySpecified << DoricGravityShiftY,
|
||||||
|
DoricGravityCenter = DoricGravityCenterX | DoricGravityCenterY,
|
||||||
|
};
|
||||||
|
|
||||||
|
class DoricLayout : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DoricLayoutSpec widthSpec;
|
||||||
|
DoricLayoutSpec heightSpec;
|
||||||
|
DoricGravity alignment;
|
||||||
|
DoricGravity gravity;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int marginLeft;
|
||||||
|
int marginTop;
|
||||||
|
int marginRight;
|
||||||
|
int marginBottom;
|
||||||
|
int paddingLeft;
|
||||||
|
int paddingTop;
|
||||||
|
int paddingRight;
|
||||||
|
int paddingBottom;
|
||||||
|
|
||||||
|
int weight;
|
||||||
|
|
||||||
|
QQuickItem *view;
|
||||||
|
|
||||||
|
DoricLayoutType layoutType;
|
||||||
|
bool disabled;
|
||||||
|
int maxWidth;
|
||||||
|
int maxHeight;
|
||||||
|
int minWidth;
|
||||||
|
int minHeight;
|
||||||
|
|
||||||
|
bool resolved;
|
||||||
|
int measuredWidth;
|
||||||
|
int measuredHeight;
|
||||||
|
int measuredX;
|
||||||
|
int measuredY;
|
||||||
|
|
||||||
|
bool undefined;
|
||||||
|
|
||||||
|
DoricLayout(QObject *parent = nullptr) : QObject(parent) {
|
||||||
|
widthSpec = DoricLayoutJust;
|
||||||
|
heightSpec = DoricLayoutJust;
|
||||||
|
maxWidth = INT_MAX;
|
||||||
|
maxHeight = INT_MAX;
|
||||||
|
minWidth = INT_MIN;
|
||||||
|
minHeight = INT_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
void measure(int targetSizeWidth, int targetSizeHeight);
|
||||||
|
|
||||||
|
void apply();
|
||||||
|
|
||||||
|
void apply(int frameSizeWidth, int frameSizeHeight);
|
||||||
|
|
||||||
|
int contentWidth;
|
||||||
|
int contentHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DORICLAYOUT_H
|
@ -19,6 +19,10 @@ void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
|||||||
view->setProperty("spacing", prop.toInt());
|
view->setProperty("spacing", prop.toInt());
|
||||||
} else if (name == "gravity") {
|
} else if (name == "gravity") {
|
||||||
qWarning() << "gravity: " << prop.toInt();
|
qWarning() << "gravity: " << prop.toInt();
|
||||||
|
switch (prop.toInt()) {
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DoricGroupNode::blend(view, name, prop);
|
DoricGroupNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user