2021-04-13 21:14:17 +08:00
|
|
|
#ifndef DORICLAYOUTS_H
|
|
|
|
#define DORICLAYOUTS_H
|
|
|
|
|
|
|
|
#include <QQuickItem>
|
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
#include "DoricExport.h"
|
|
|
|
|
|
|
|
class DORIC_EXPORT DoricLayoutType {
|
2021-04-13 21:14:17 +08:00
|
|
|
public:
|
|
|
|
const static int DoricUndefined = 0;
|
|
|
|
const static int DoricStack = 1;
|
|
|
|
const static int DoricVLayout = 2;
|
|
|
|
const static int DoricHLayout = 3;
|
|
|
|
};
|
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
class DORIC_EXPORT DoricLayoutSpec {
|
2021-04-13 21:14:17 +08:00
|
|
|
public:
|
|
|
|
const static int DoricLayoutJust = 0;
|
|
|
|
const static int DoricLayoutFit = 1;
|
|
|
|
const static int DoricLayoutMost = 2;
|
|
|
|
};
|
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
class DORIC_EXPORT DoricGravity {
|
2021-04-13 21:14:17 +08:00
|
|
|
public:
|
|
|
|
const static int DoricGravitySpecified = 1;
|
|
|
|
const static int DoricGravityStart = 1 << 1;
|
|
|
|
const static int DoricGravityEnd = 1 << 2;
|
|
|
|
const static int DoricGravityShiftX = 0;
|
|
|
|
const static int DoricGravityShiftY = 4;
|
|
|
|
const static int DoricGravityLeft =
|
|
|
|
(DoricGravityStart | DoricGravitySpecified) << DoricGravityShiftX;
|
|
|
|
const static int DoricGravityRight = (DoricGravityEnd | DoricGravitySpecified)
|
|
|
|
<< DoricGravityShiftX;
|
|
|
|
const static int DoricGravityTop = (DoricGravityStart | DoricGravitySpecified)
|
|
|
|
<< DoricGravityShiftY;
|
|
|
|
const static int DoricGravityBottom =
|
|
|
|
(DoricGravityEnd | DoricGravitySpecified) << DoricGravityShiftY;
|
|
|
|
const static int DoricGravityCenterX = DoricGravitySpecified
|
|
|
|
<< DoricGravityShiftX;
|
|
|
|
const static int DoricGravityCenterY = DoricGravitySpecified
|
|
|
|
<< DoricGravityShiftY;
|
|
|
|
const static int DoricGravityCenter =
|
|
|
|
DoricGravityCenterX | DoricGravityCenterY;
|
|
|
|
};
|
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
class DORIC_EXPORT DoricLayouts : public QObject {
|
2021-04-13 21:14:17 +08:00
|
|
|
public:
|
2021-04-14 12:42:03 +08:00
|
|
|
explicit DoricLayouts(QObject *parent = nullptr);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
void setWidthSpec(int widthSpec);
|
|
|
|
void setHeightSpec(int heightSpec);
|
|
|
|
|
|
|
|
void setAlignment(int alignment);
|
|
|
|
|
|
|
|
void setGravity(int gravity);
|
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
void setWidth(qreal width);
|
|
|
|
void setHeight(qreal height);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
void setSpacing(qreal spacing);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
void setMarginLeft(qreal marginLeft);
|
|
|
|
void setMarginTop(qreal marginTop);
|
|
|
|
void setMarginRight(qreal marginRight);
|
|
|
|
void setMarginBottom(qreal marginBottom);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
void setPaddingLeft(qreal paddingLeft);
|
2021-05-27 10:56:58 +08:00
|
|
|
qreal getPaddingLeft();
|
2021-04-15 10:20:55 +08:00
|
|
|
void setPaddingTop(qreal paddingTop);
|
2021-05-27 10:56:58 +08:00
|
|
|
qreal getPaddingTop();
|
2021-04-15 10:20:55 +08:00
|
|
|
void setPaddingRight(qreal paddingRight);
|
2021-05-27 10:56:58 +08:00
|
|
|
qreal getPaddingRight();
|
2021-04-15 10:20:55 +08:00
|
|
|
void setPaddingBottom(qreal paddingBottom);
|
2021-05-27 10:56:58 +08:00
|
|
|
qreal getPaddingBottom();
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
void setWeight(int weight);
|
|
|
|
|
|
|
|
void setView(QQuickItem *view);
|
|
|
|
|
|
|
|
void setLayoutType(int layoutType);
|
|
|
|
|
|
|
|
void setDisabled(bool disabled);
|
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
void setMaxWidth(qreal maxWidth);
|
|
|
|
void setMaxHeight(qreal maxHeight);
|
|
|
|
void setMinWidth(qreal minWidth);
|
|
|
|
void setMinHeight(qreal minHeight);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-19 19:22:10 +08:00
|
|
|
void apply(QSizeF frameSize);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
void apply();
|
|
|
|
|
2021-04-16 16:44:08 +08:00
|
|
|
qreal getMeasuredWidth();
|
|
|
|
qreal getMeasuredHeight();
|
|
|
|
|
2021-04-13 21:14:17 +08:00
|
|
|
private:
|
|
|
|
QString tag;
|
|
|
|
|
|
|
|
int widthSpec;
|
|
|
|
int heightSpec;
|
|
|
|
|
|
|
|
int alignment;
|
|
|
|
|
|
|
|
int gravity;
|
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal width;
|
|
|
|
qreal height;
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal spacing;
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal marginLeft;
|
|
|
|
qreal marginTop;
|
|
|
|
qreal marginRight;
|
|
|
|
qreal marginBottom;
|
2021-04-13 21:14:17 +08:00
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal paddingLeft;
|
|
|
|
qreal paddingTop;
|
|
|
|
qreal paddingRight;
|
|
|
|
qreal paddingBottom;
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
int weight;
|
|
|
|
|
|
|
|
QQuickItem *view;
|
|
|
|
|
|
|
|
int layoutType;
|
|
|
|
|
|
|
|
bool disabled;
|
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal maxWidth;
|
|
|
|
qreal maxHeight;
|
|
|
|
qreal minWidth;
|
|
|
|
qreal minHeight;
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
bool resolved;
|
|
|
|
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal measuredWidth;
|
|
|
|
void setMeasuredWidth(qreal measuredWidth);
|
|
|
|
qreal measuredHeight;
|
|
|
|
void setMeasuredHeight(qreal measuredHeight);
|
|
|
|
qreal measuredX;
|
|
|
|
void setMeasuredX(qreal measuredX);
|
|
|
|
qreal measuredY;
|
|
|
|
void setMeasuredY(qreal measuredY);
|
2021-04-13 21:14:17 +08:00
|
|
|
|
|
|
|
bool undefined;
|
|
|
|
|
|
|
|
//
|
2021-04-15 10:20:55 +08:00
|
|
|
qreal contentWidth;
|
|
|
|
qreal contentHeight;
|
|
|
|
|
2021-04-19 19:22:10 +08:00
|
|
|
void measure(QSizeF targetSize);
|
2021-04-15 10:20:55 +08:00
|
|
|
|
2021-04-19 19:22:10 +08:00
|
|
|
void measureSelf(QSizeF targetSize);
|
2021-04-15 10:20:55 +08:00
|
|
|
|
2021-04-19 19:22:10 +08:00
|
|
|
void measureContent(QSizeF targetSize);
|
2021-04-15 10:20:55 +08:00
|
|
|
|
2021-04-19 19:22:10 +08:00
|
|
|
void measureUndefinedContent(QSizeF targetSize);
|
|
|
|
void measureStackContent(QSizeF targetSize);
|
|
|
|
void measureVLayoutContent(QSizeF targetSize);
|
|
|
|
void measureHLayoutContent(QSizeF targetSize);
|
2021-04-15 10:20:55 +08:00
|
|
|
|
|
|
|
qreal takenWidth();
|
|
|
|
qreal takenHeight();
|
2021-04-19 19:22:10 +08:00
|
|
|
QSizeF removeMargin(QSizeF targetSize);
|
2021-04-15 10:20:55 +08:00
|
|
|
|
|
|
|
bool restrainSize();
|
|
|
|
|
|
|
|
void layout();
|
|
|
|
|
|
|
|
void layoutStack();
|
|
|
|
void layoutVLayout();
|
|
|
|
void layoutHLayout();
|
|
|
|
|
|
|
|
void setFrame();
|
2021-04-13 21:14:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DORICLAYOUTS_H
|