add modal plugin interface; optimize layouts code

This commit is contained in:
王劲鹏
2021-04-20 11:46:56 +08:00
committed by osborn
parent 8d04d41b19
commit f488f023fa
6 changed files with 38 additions and 14 deletions

View File

@@ -224,31 +224,34 @@ void DoricLayouts::measureContent(QSizeF targetSize) {
void DoricLayouts::measureUndefinedContent(QSizeF targetSize) {
// begin size that fits
qreal width = this->view->width();
qreal height = this->view->height();
QSizeF measuredSize;
if (tag == "Scroller") {
QObject *object =
(QObject *)(this->view->property("wrapper").toULongLong());
DoricScrollerNode *viewNode = dynamic_cast<DoricScrollerNode *>(object);
QSizeF measuredSize = viewNode->sizeThatFits(targetSize);
width = measuredSize.width();
height = measuredSize.height();
measuredSize = viewNode->sizeThatFits(targetSize);
} else {
if (width > targetSize.width()) {
width = targetSize.width();
qreal actualWidth = this->view->width();
qreal actualHeight = this->view->height();
if (actualWidth > targetSize.width()) {
actualWidth = targetSize.width();
}
if (height > targetSize.height()) {
height = targetSize.height();
if (actualHeight > targetSize.height()) {
actualHeight = targetSize.height();
}
measuredSize = QSizeF(actualWidth, actualHeight);
}
// end size that fits
if (this->widthSpec == DoricLayoutSpec::DoricLayoutFit) {
setMeasuredWidth(width + this->paddingLeft + this->paddingRight);
setMeasuredWidth(measuredSize.width() + this->paddingLeft +
this->paddingRight);
}
if (this->heightSpec == DoricLayoutSpec::DoricLayoutFit) {
setMeasuredHeight(height + this->paddingTop + this->paddingBottom);
setMeasuredHeight(measuredSize.height() + this->paddingTop +
this->paddingBottom);
}
}
void DoricLayouts::measureStackContent(QSizeF targetSize) {