a lot of changes

int -> qreal; set width & height property only under change; code refactor; v8 isolate npe try fix
This commit is contained in:
王劲鹏 2021-04-15 10:20:55 +08:00 committed by osborn
parent 65e5f8af19
commit 6452b469a2
5 changed files with 166 additions and 143 deletions

View File

@ -22,7 +22,7 @@ QQuickItem *DoricHLayoutNode::build() {
void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) { void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
QQuickItem *container = view; QQuickItem *container = view;
if (name == "space") { if (name == "space") {
getLayouts()->setSpacing(prop.toInt()); getLayouts()->setSpacing(prop.toDouble());
} else if (name == "gravity") { } else if (name == "gravity") {
getLayouts()->setGravity(prop.toInt()); getLayouts()->setGravity(prop.toInt());
} else { } else {

View File

@ -22,7 +22,7 @@ QQuickItem *DoricVLayoutNode::build() {
void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) { void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
QQuickItem *container = view; QQuickItem *container = view;
if (name == "space") { if (name == "space") {
getLayouts()->setSpacing(prop.toInt()); getLayouts()->setSpacing(prop.toDouble());
} else if (name == "gravity") { } else if (name == "gravity") {
getLayouts()->setGravity(prop.toInt()); getLayouts()->setGravity(prop.toInt());
} else { } else {

View File

@ -15,16 +15,16 @@ void DoricViewNode::blendLayoutConfig(QJsonValue jsValue) {
QJsonObject margin = jsObject["margin"].toObject(); QJsonObject margin = jsObject["margin"].toObject();
if (margin.contains("left")) if (margin.contains("left"))
getLayouts()->setMarginLeft(margin["left"].toInt()); getLayouts()->setMarginLeft(margin["left"].toDouble());
if (margin.contains("top")) if (margin.contains("top"))
getLayouts()->setMarginTop(margin["top"].toInt()); getLayouts()->setMarginTop(margin["top"].toDouble());
if (margin.contains("right")) if (margin.contains("right"))
getLayouts()->setMarginRight(margin["right"].toInt()); getLayouts()->setMarginRight(margin["right"].toDouble());
if (margin.contains("bottom")) if (margin.contains("bottom"))
getLayouts()->setMarginBottom(margin["bottom"].toInt()); getLayouts()->setMarginBottom(margin["bottom"].toDouble());
} }
if (jsObject.contains("alignment")) if (jsObject.contains("alignment"))
@ -34,16 +34,16 @@ void DoricViewNode::blendLayoutConfig(QJsonValue jsValue) {
getLayouts()->setWeight(jsObject["weight"].toInt()); getLayouts()->setWeight(jsObject["weight"].toInt());
if (jsObject.contains("maxWidth")) if (jsObject.contains("maxWidth"))
getLayouts()->setMaxWidth(jsObject["maxWidth"].toInt()); getLayouts()->setMaxWidth(jsObject["maxWidth"].toDouble());
if (jsObject.contains("maxHeight")) if (jsObject.contains("maxHeight"))
getLayouts()->setMaxHeight(jsObject["maxHeight"].toInt()); getLayouts()->setMaxHeight(jsObject["maxHeight"].toDouble());
if (jsObject.contains("minWidth")) if (jsObject.contains("minWidth"))
getLayouts()->setMinWidth(jsObject["minWidth"].toInt()); getLayouts()->setMinWidth(jsObject["minWidth"].toDouble());
if (jsObject.contains("minHeight")) if (jsObject.contains("minHeight"))
getLayouts()->setMinHeight(jsObject["minHeight"].toInt()); getLayouts()->setMinHeight(jsObject["minHeight"].toDouble());
} }
void DoricViewNode::createLayouts(QQuickItem *view) { void DoricViewNode::createLayouts(QQuickItem *view) {
@ -101,26 +101,26 @@ void DoricViewNode::blend(QJsonValue jsValue) {
void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) { void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
if (name == "width") { if (name == "width") {
getLayouts()->setWidth(prop.toInt()); getLayouts()->setWidth(prop.toDouble());
} else if (name == "height") { } else if (name == "height") {
getLayouts()->setHeight(prop.toInt()); getLayouts()->setHeight(prop.toDouble());
} else if (name == "backgroundColor") { } else if (name == "backgroundColor") {
QString color = DoricUtils::doricColor(prop.toInt()).name(); QString color = DoricUtils::doricColor(prop.toInt()).name();
view->setProperty("backgroundColor", color); view->setProperty("backgroundColor", color);
} else if (name == "x") { } else if (name == "x") {
getLayouts()->setMarginLeft(prop.toInt()); getLayouts()->setMarginLeft(prop.toDouble());
} else if (name == "y") { } else if (name == "y") {
getLayouts()->setMarginTop(prop.toInt()); getLayouts()->setMarginTop(prop.toDouble());
} else if (name == "corners") { } else if (name == "corners") {
view->setProperty("radius", prop.toInt()); view->setProperty("radius", prop.toInt());
} else if (name == "onClick") { } else if (name == "onClick") {
if (prop.isString()) if (prop.isString())
clickFunction = prop.toString(); clickFunction = prop.toString();
} else if (name == "padding") { } else if (name == "padding") {
getLayouts()->setPaddingLeft(prop["left"].toInt()); getLayouts()->setPaddingLeft(prop["left"].toDouble());
getLayouts()->setPaddingRight(prop["right"].toInt()); getLayouts()->setPaddingRight(prop["right"].toDouble());
getLayouts()->setPaddingTop(prop["top"].toInt()); getLayouts()->setPaddingTop(prop["top"].toDouble());
getLayouts()->setPaddingBottom(prop["bottom"].toInt()); getLayouts()->setPaddingBottom(prop["bottom"].toDouble());
} else if (name == "hidden") { } else if (name == "hidden") {
getLayouts()->setDisabled(prop.toBool()); getLayouts()->setDisabled(prop.toBool());
} else if (name != "layoutConfig") { } else if (name != "layoutConfig") {

View File

@ -54,32 +54,34 @@ void DoricLayouts::setAlignment(int alignment) { this->alignment = alignment; }
void DoricLayouts::setGravity(int gravity) { this->gravity = gravity; } void DoricLayouts::setGravity(int gravity) { this->gravity = gravity; }
void DoricLayouts::setWidth(int width) { this->width = width; } void DoricLayouts::setWidth(qreal width) { this->width = width; }
void DoricLayouts::setHeight(int height) { this->height = height; } void DoricLayouts::setHeight(qreal height) { this->height = height; }
void DoricLayouts::setSpacing(int spacing) { this->spacing = spacing; } void DoricLayouts::setSpacing(qreal spacing) { this->spacing = spacing; }
void DoricLayouts::setMarginLeft(int marginLeft) { void DoricLayouts::setMarginLeft(qreal marginLeft) {
this->marginLeft = marginLeft; this->marginLeft = marginLeft;
} }
void DoricLayouts::setMarginTop(int marginTop) { this->marginTop = marginTop; } void DoricLayouts::setMarginTop(qreal marginTop) {
void DoricLayouts::setMarginRight(int marginRight) { this->marginTop = marginTop;
}
void DoricLayouts::setMarginRight(qreal marginRight) {
this->marginRight = marginRight; this->marginRight = marginRight;
} }
void DoricLayouts::setMarginBottom(int marginBottom) { void DoricLayouts::setMarginBottom(qreal marginBottom) {
this->marginBottom = marginBottom; this->marginBottom = marginBottom;
} }
void DoricLayouts::setPaddingLeft(int paddingLeft) { void DoricLayouts::setPaddingLeft(qreal paddingLeft) {
this->paddingLeft = paddingLeft; this->paddingLeft = paddingLeft;
} }
void DoricLayouts::setPaddingTop(int paddingTop) { void DoricLayouts::setPaddingTop(qreal paddingTop) {
this->paddingTop = paddingTop; this->paddingTop = paddingTop;
} }
void DoricLayouts::setPaddingRight(int paddingRight) { void DoricLayouts::setPaddingRight(qreal paddingRight) {
this->paddingRight = paddingRight; this->paddingRight = paddingRight;
} }
void DoricLayouts::setPaddingBottom(int paddingBottom) { void DoricLayouts::setPaddingBottom(qreal paddingBottom) {
this->paddingBottom = paddingBottom; this->paddingBottom = paddingBottom;
} }
@ -97,12 +99,16 @@ void DoricLayouts::setLayoutType(int layoutType) {
void DoricLayouts::setDisabled(bool disabled) { this->disabled = disabled; } void DoricLayouts::setDisabled(bool disabled) { this->disabled = disabled; }
void DoricLayouts::setMaxWidth(int maxWidth) { this->maxWidth = maxWidth; } void DoricLayouts::setMaxWidth(qreal maxWidth) { this->maxWidth = maxWidth; }
void DoricLayouts::setMaxHeight(int maxHeight) { this->maxHeight = maxHeight; } void DoricLayouts::setMaxHeight(qreal maxHeight) {
void DoricLayouts::setMinWidth(int minWidth) { this->minWidth = minWidth; } this->maxHeight = maxHeight;
void DoricLayouts::setMinHeight(int minHeight) { this->minHeight = minHeight; } }
void DoricLayouts::setMinWidth(qreal minWidth) { this->minWidth = minWidth; }
void DoricLayouts::setMinHeight(qreal minHeight) {
this->minHeight = minHeight;
}
void DoricLayouts::apply(int targetWidth, int targetHeight) { void DoricLayouts::apply(qreal targetWidth, qreal targetHeight) {
this->resolved = false; this->resolved = false;
this->measure(targetWidth, targetHeight); this->measure(targetWidth, targetHeight);
@ -115,14 +121,14 @@ void DoricLayouts::apply() {
this->apply(this->view->width(), this->view->height()); this->apply(this->view->width(), this->view->height());
} }
void DoricLayouts::measure(int targetWidth, int targetHeight) { void DoricLayouts::measure(qreal targetWidth, qreal targetHeight) {
this->measureSelf(targetWidth, targetHeight); this->measureSelf(targetWidth, targetHeight);
this->layout(); this->layout();
} }
void DoricLayouts::measureSelf(int targetWidth, int targetHeight) { void DoricLayouts::measureSelf(qreal targetWidth, qreal targetHeight) {
// measure width // measure width
int width; qreal width;
if (this->widthSpec == DoricLayoutSpec::DoricLayoutMost) { if (this->widthSpec == DoricLayoutSpec::DoricLayoutMost) {
QQuickItem *parent = this->view->parentItem(); QQuickItem *parent = this->view->parentItem();
DoricLayouts *parentDoricLayout = DoricLayouts *parentDoricLayout =
@ -143,7 +149,7 @@ void DoricLayouts::measureSelf(int targetWidth, int targetHeight) {
} }
// measure height // measure height
int height; qreal height;
if (this->heightSpec == DoricLayoutSpec::DoricLayoutMost) { if (this->heightSpec == DoricLayoutSpec::DoricLayoutMost) {
QQuickItem *parent = this->view->parentItem(); QQuickItem *parent = this->view->parentItem();
DoricLayouts *parentDoricLayout = DoricLayouts *parentDoricLayout =
@ -176,7 +182,7 @@ void DoricLayouts::measureSelf(int targetWidth, int targetHeight) {
this->restrainSize(); this->restrainSize();
} }
void DoricLayouts::measureContent(int targetWidth, int targetHeight) { void DoricLayouts::measureContent(qreal targetWidth, qreal targetHeight) {
qCritical() << "measureContent: " << tag << this->view->property("uuid"); qCritical() << "measureContent: " << tag << this->view->property("uuid");
switch (this->layoutType) { switch (this->layoutType) {
case DoricLayoutType::DoricStack: { case DoricLayoutType::DoricStack: {
@ -214,9 +220,10 @@ void DoricLayouts::measureContent(int targetWidth, int targetHeight) {
} }
} }
void DoricLayouts::measureUndefinedContent(int targetWidth, int targetHeight) { void DoricLayouts::measureUndefinedContent(qreal targetWidth,
int width = this->view->width(); qreal targetHeight) {
int height = this->view->height(); qreal width = this->view->width();
qreal height = this->view->height();
if (width > targetWidth) { if (width > targetWidth) {
width = targetWidth; width = targetWidth;
@ -231,8 +238,8 @@ void DoricLayouts::measureUndefinedContent(int targetWidth, int targetHeight) {
setMeasuredHeight(height + this->paddingTop + this->paddingBottom); setMeasuredHeight(height + this->paddingTop + this->paddingBottom);
} }
} }
void DoricLayouts::measureStackContent(int targetWidth, int targetHeight) { void DoricLayouts::measureStackContent(qreal targetWidth, qreal targetHeight) {
int contentWidth = 0, contentHeight = 0; qreal contentWidth = 0, contentHeight = 0;
foreach (QQuickItem *subview, this->view->childItems()) { foreach (QQuickItem *subview, this->view->childItems()) {
DoricLayouts *layout = DoricLayouts *layout =
(DoricLayouts *)(subview->property("doricLayout").toULongLong()); (DoricLayouts *)(subview->property("doricLayout").toULongLong());
@ -260,8 +267,9 @@ void DoricLayouts::measureStackContent(int targetWidth, int targetHeight) {
this->contentWidth = contentWidth; this->contentWidth = contentWidth;
this->contentHeight = contentHeight; this->contentHeight = contentHeight;
} }
void DoricLayouts::measureVLayoutContent(int targetWidth, int targetHeight) { void DoricLayouts::measureVLayoutContent(qreal targetWidth,
int contentWidth = 0, contentHeight = 0, contentWeight = 0; qreal targetHeight) {
qreal contentWidth = 0, contentHeight = 0, contentWeight = 0;
bool had = false; bool had = false;
foreach (QQuickItem *subview, this->view->childItems()) { foreach (QQuickItem *subview, this->view->childItems()) {
DoricLayouts *layout = DoricLayouts *layout =
@ -288,7 +296,7 @@ void DoricLayouts::measureVLayoutContent(int targetWidth, int targetHeight) {
} }
if (contentWeight > 0) { if (contentWeight > 0) {
int remaining = targetHeight - contentHeight; qreal remaining = targetHeight - contentHeight;
contentWidth = 0; contentWidth = 0;
foreach (QQuickItem *subview, this->view->childItems()) { foreach (QQuickItem *subview, this->view->childItems()) {
DoricLayouts *layout = DoricLayouts *layout =
@ -300,7 +308,7 @@ void DoricLayouts::measureVLayoutContent(int targetWidth, int targetHeight) {
if (layout->disabled) { if (layout->disabled) {
continue; continue;
} }
int measuredHeight = qreal measuredHeight =
layout->measuredHeight + remaining / contentWeight * layout->weight; layout->measuredHeight + remaining / contentWeight * layout->weight;
layout->measuredHeight = measuredHeight; layout->measuredHeight = measuredHeight;
// Need Remeasure // Need Remeasure
@ -324,8 +332,9 @@ void DoricLayouts::measureVLayoutContent(int targetWidth, int targetHeight) {
this->contentWidth = contentWidth; this->contentWidth = contentWidth;
this->contentHeight = contentHeight; this->contentHeight = contentHeight;
} }
void DoricLayouts::measureHLayoutContent(int targetWidth, int targetHeight) { void DoricLayouts::measureHLayoutContent(qreal targetWidth,
int contentWidth = 0, contentHeight = 0, contentWeight = 0; qreal targetHeight) {
qreal contentWidth = 0, contentHeight = 0, contentWeight = 0;
bool had = false; bool had = false;
foreach (QQuickItem *subview, this->view->childItems()) { foreach (QQuickItem *subview, this->view->childItems()) {
DoricLayouts *layout = DoricLayouts *layout =
@ -351,7 +360,7 @@ void DoricLayouts::measureHLayoutContent(int targetWidth, int targetHeight) {
} }
if (contentWeight > 0) { if (contentWeight > 0) {
int remaining = targetWidth - contentWidth; qreal remaining = targetWidth - contentWidth;
contentHeight = 0; contentHeight = 0;
foreach (QQuickItem *subview, this->view->childItems()) { foreach (QQuickItem *subview, this->view->childItems()) {
DoricLayouts *layout = DoricLayouts *layout =
@ -363,7 +372,7 @@ void DoricLayouts::measureHLayoutContent(int targetWidth, int targetHeight) {
if (layout->disabled) { if (layout->disabled) {
continue; continue;
} }
int measuredWidth = qreal measuredWidth =
layout->measuredWidth + remaining / contentWeight * layout->weight; layout->measuredWidth + remaining / contentWeight * layout->weight;
layout->measuredWidth = measuredWidth; layout->measuredWidth = measuredWidth;
// Need Remeasure // Need Remeasure
@ -388,13 +397,14 @@ void DoricLayouts::measureHLayoutContent(int targetWidth, int targetHeight) {
this->contentHeight = contentHeight; this->contentHeight = contentHeight;
} }
int DoricLayouts::takenWidth() { qreal DoricLayouts::takenWidth() {
return this->measuredWidth + this->marginLeft + this->marginRight; return this->measuredWidth + this->marginLeft + this->marginRight;
} }
int DoricLayouts::takenHeight() { qreal DoricLayouts::takenHeight() {
return this->measuredHeight + this->marginTop + this->marginBottom; return this->measuredHeight + this->marginTop + this->marginBottom;
} }
QPair<int, int> DoricLayouts::removeMargin(int targetWidth, int targetHeight) { QPair<qreal, qreal> DoricLayouts::removeMargin(qreal targetWidth,
qreal targetHeight) {
QPair<int, int> pair(targetWidth - this->marginLeft - this->marginRight, QPair<int, int> pair(targetWidth - this->marginLeft - this->marginRight,
targetHeight - this->marginTop - this->marginBottom); targetHeight - this->marginTop - this->marginBottom);
return pair; return pair;
@ -457,11 +467,16 @@ void DoricLayouts::setFrame() {
qCritical() << "DoricLayouts: " << tag << this->view->property("uuid") qCritical() << "DoricLayouts: " << tag << this->view->property("uuid")
<< " measuredWidth: " << this->measuredWidth << " measuredWidth: " << this->measuredWidth
<< " measuredHeight: " << this->measuredHeight << " measuredHeight: " << this->measuredHeight
<< " width: " << this->view->width()
<< " height: " << this->view->height()
<< " measuredX: " << this->measuredX << " measuredX: " << this->measuredX
<< " measuredY: " << this->measuredY; << " measuredY: " << this->measuredY;
if (qFabs(this->measuredWidth - this->view->width() >= 0.00001f))
this->view->setProperty("width", this->measuredWidth); this->view->setProperty("width", this->measuredWidth);
if (qFabs(this->measuredHeight - this->view->height() >= 0.00001f))
this->view->setProperty("height", this->measuredHeight); this->view->setProperty("height", this->measuredHeight);
this->view->setProperty("x", this->measuredX); this->view->setProperty("x", this->measuredX);
this->view->setProperty("y", this->measuredY); this->view->setProperty("y", this->measuredY);
} }
@ -492,19 +507,19 @@ void DoricLayouts::layoutStack() {
int gravity = layout->alignment; int gravity = layout->alignment;
if ((gravity & DoricGravity::DoricGravityLeft) == if ((gravity & DoricGravity::DoricGravityLeft) ==
DoricGravity::DoricGravityLeft) { DoricGravity::DoricGravityLeft) {
layout->measuredX = this->paddingLeft; layout->setMeasuredX(this->paddingLeft);
} else if ((gravity & DoricGravity::DoricGravityRight) == } else if ((gravity & DoricGravity::DoricGravityRight) ==
DoricGravity::DoricGravityRight) { DoricGravity::DoricGravityRight) {
layout->measuredX = layout->setMeasuredX(this->measuredWidth - this->paddingRight -
this->measuredWidth - this->paddingRight - layout->measuredWidth; layout->measuredWidth);
} else if ((gravity & DoricGravity::DoricGravityCenterX) == } else if ((gravity & DoricGravity::DoricGravityCenterX) ==
DoricGravity::DoricGravityCenterX) { DoricGravity::DoricGravityCenterX) {
layout->measuredX = this->measuredWidth / 2 - layout->measuredWidth / 2; layout->setMeasuredX(this->measuredWidth / 2 - layout->measuredWidth / 2);
} else { } else {
if (layout->marginLeft || layout->marginRight) { if (layout->marginLeft || layout->marginRight) {
layout->measuredX = this->paddingLeft; layout->setMeasuredX(this->paddingLeft);
} else { } else {
layout->measuredX = 0; layout->setMeasuredX(0);
} }
} }
@ -549,7 +564,7 @@ void DoricLayouts::layoutStack() {
} }
void DoricLayouts::layoutVLayout() { void DoricLayouts::layoutVLayout() {
int yStart = this->paddingTop; qreal yStart = this->paddingTop;
if ((this->gravity & DoricGravity::DoricGravityTop) == if ((this->gravity & DoricGravity::DoricGravityTop) ==
DoricGravity::DoricGravityTop) { DoricGravity::DoricGravityTop) {
yStart = this->paddingTop; yStart = this->paddingTop;
@ -588,16 +603,16 @@ void DoricLayouts::layoutVLayout() {
int gravity = layout->alignment | this->gravity; int gravity = layout->alignment | this->gravity;
if ((gravity & DoricGravity::DoricGravityLeft) == if ((gravity & DoricGravity::DoricGravityLeft) ==
DoricGravity::DoricGravityLeft) { DoricGravity::DoricGravityLeft) {
layout->measuredX = this->paddingLeft; layout->setMeasuredX(this->paddingLeft);
} else if ((gravity & DoricGravity::DoricGravityRight) == } else if ((gravity & DoricGravity::DoricGravityRight) ==
DoricGravity::DoricGravityRight) { DoricGravity::DoricGravityRight) {
layout->measuredX = layout->setMeasuredX(this->measuredWidth - this->paddingRight -
this->measuredWidth - this->paddingRight - layout->measuredWidth; layout->measuredWidth);
} else if ((gravity & DoricGravity::DoricGravityCenterX) == } else if ((gravity & DoricGravity::DoricGravityCenterX) ==
DoricGravity::DoricGravityCenterX) { DoricGravity::DoricGravityCenterX) {
layout->measuredX = this->measuredWidth / 2 - layout->measuredWidth / 2; layout->setMeasuredX(this->measuredWidth / 2 - layout->measuredWidth / 2);
} else { } else {
layout->measuredX = this->paddingLeft; layout->setMeasuredX(this->paddingLeft);
} }
if (!gravity) { if (!gravity) {
gravity = DoricGravity::DoricGravityLeft; gravity = DoricGravity::DoricGravityLeft;
@ -616,7 +631,7 @@ void DoricLayouts::layoutVLayout() {
} }
void DoricLayouts::layoutHLayout() { void DoricLayouts::layoutHLayout() {
int xStart = this->paddingLeft; qreal xStart = this->paddingLeft;
if ((this->gravity & DoricGravity::DoricGravityLeft) == if ((this->gravity & DoricGravity::DoricGravityLeft) ==
DoricGravity::DoricGravityLeft) { DoricGravity::DoricGravityLeft) {
xStart = this->paddingLeft; xStart = this->paddingLeft;
@ -680,26 +695,32 @@ void DoricLayouts::layoutHLayout() {
DoricGravity::DoricGravityTop)) { DoricGravity::DoricGravityTop)) {
layout->measuredY -= layout->marginBottom; layout->measuredY -= layout->marginBottom;
} }
layout->measuredX = xStart + layout->marginLeft; layout->setMeasuredX(xStart + layout->marginLeft);
xStart += this->spacing + layout->takenWidth(); xStart += this->spacing + layout->takenWidth();
} }
} }
// Private Section // Private Section
void DoricLayouts::setMeasuredWidth(int measuredWidth) { void DoricLayouts::setMeasuredWidth(qreal measuredWidth) {
this->measuredWidth = measuredWidth; this->measuredWidth = measuredWidth;
qCritical() << "DoricLayouts: " << tag << this->view->property("uuid") qCritical() << "DoricLayouts: " << tag << this->view->property("uuid")
<< " measuredWidth: " << this->measuredWidth; << " measuredWidth: " << this->measuredWidth;
if (this->measuredWidth > 1000 || this->measuredWidth < 0) {
qDebug() << "";
}
} }
void DoricLayouts::setMeasuredHeight(int measuredHeight) { void DoricLayouts::setMeasuredHeight(qreal measuredHeight) {
this->measuredHeight = measuredHeight; this->measuredHeight = measuredHeight;
qCritical() << "DoricLayouts: " << tag << this->view->property("uuid") qCritical() << "DoricLayouts: " << tag << this->view->property("uuid")
<< " measuredHeight: " << this->measuredHeight; << " measuredHeight: " << this->measuredHeight;
if (this->measuredHeight > 2000 || this->measuredHeight < 0) {
qDebug() << "";
} }
void DoricLayouts::setMeasuredX(qreal measuredX) {
this->measuredX = measuredX;
qCritical() << "DoricLayouts: " << tag << this->view->property("uuid")
<< " measuredX: " << this->measuredX;
}
void DoricLayouts::setMeasuredY(qreal measuredY) {
this->measuredY = measuredY;
qCritical() << "DoricLayouts: " << tag << this->view->property("uuid")
<< " measuredY: " << this->measuredY;
} }

View File

@ -52,20 +52,20 @@ public:
void setGravity(int gravity); void setGravity(int gravity);
void setWidth(int width); void setWidth(qreal width);
void setHeight(int height); void setHeight(qreal height);
void setSpacing(int spacing); void setSpacing(qreal spacing);
void setMarginLeft(int marginLeft); void setMarginLeft(qreal marginLeft);
void setMarginTop(int marginTop); void setMarginTop(qreal marginTop);
void setMarginRight(int marginRight); void setMarginRight(qreal marginRight);
void setMarginBottom(int marginBottom); void setMarginBottom(qreal marginBottom);
void setPaddingLeft(int paddingLeft); void setPaddingLeft(qreal paddingLeft);
void setPaddingTop(int paddingTop); void setPaddingTop(qreal paddingTop);
void setPaddingRight(int paddingRight); void setPaddingRight(qreal paddingRight);
void setPaddingBottom(int paddingBottom); void setPaddingBottom(qreal paddingBottom);
void setWeight(int weight); void setWeight(int weight);
@ -75,40 +75,15 @@ public:
void setDisabled(bool disabled); void setDisabled(bool disabled);
void setMaxWidth(int maxWidth); void setMaxWidth(qreal maxWidth);
void setMaxHeight(int maxHeight); void setMaxHeight(qreal maxHeight);
void setMinWidth(int minWidth); void setMinWidth(qreal minWidth);
void setMinHeight(int minHeight); void setMinHeight(qreal minHeight);
void apply(int targetWidth, int targetHeight); void apply(qreal targetWidth, qreal targetHeight);
void apply(); void apply();
void measure(int targetWidth, int targetHeight);
void measureSelf(int targetWidth, int targetHeight);
void measureContent(int targetWidth, int targetHeight);
void measureUndefinedContent(int targetWidth, int targetHeight);
void measureStackContent(int targetWidth, int targetHeight);
void measureVLayoutContent(int targetWidth, int targetHeight);
void measureHLayoutContent(int targetWidth, int targetHeight);
int takenWidth();
int takenHeight();
QPair<int, int> removeMargin(int targetWidth, int targetHeight);
bool restrainSize();
void layout();
void layoutStack();
void layoutVLayout();
void layoutHLayout();
void setFrame();
private: private:
QString tag; QString tag;
@ -119,20 +94,20 @@ private:
int gravity; int gravity;
int width; qreal width;
int height; qreal height;
int spacing; qreal spacing;
int marginLeft; qreal marginLeft;
int marginTop; qreal marginTop;
int marginRight; qreal marginRight;
int marginBottom; qreal marginBottom;
int paddingLeft; qreal paddingLeft;
int paddingTop; qreal paddingTop;
int paddingRight; qreal paddingRight;
int paddingBottom; qreal paddingBottom;
int weight; int weight;
@ -142,25 +117,52 @@ private:
bool disabled; bool disabled;
int maxWidth; qreal maxWidth;
int maxHeight; qreal maxHeight;
int minWidth; qreal minWidth;
int minHeight; qreal minHeight;
bool resolved; bool resolved;
int measuredWidth; qreal measuredWidth;
void setMeasuredWidth(int measuredWidth); void setMeasuredWidth(qreal measuredWidth);
int measuredHeight; qreal measuredHeight;
void setMeasuredHeight(int measuredHeight); void setMeasuredHeight(qreal measuredHeight);
int measuredX; qreal measuredX;
int measuredY; void setMeasuredX(qreal measuredX);
qreal measuredY;
void setMeasuredY(qreal measuredY);
bool undefined; bool undefined;
// //
int contentWidth; qreal contentWidth;
int contentHeight; qreal contentHeight;
void measure(qreal targetWidth, qreal targetHeight);
void measureSelf(qreal targetWidth, qreal targetHeight);
void measureContent(qreal targetWidth, qreal targetHeight);
void measureUndefinedContent(qreal targetWidth, qreal targetHeight);
void measureStackContent(qreal targetWidth, qreal targetHeight);
void measureVLayoutContent(qreal targetWidth, qreal targetHeight);
void measureHLayoutContent(qreal targetWidth, qreal targetHeight);
qreal takenWidth();
qreal takenHeight();
QPair<qreal, qreal> removeMargin(qreal targetWidth, qreal targetHeight);
bool restrainSize();
void layout();
void layoutStack();
void layoutVLayout();
void layoutHLayout();
void setFrame();
}; };
#endif // DORICLAYOUTS_H #endif // DORICLAYOUTS_H