87 lines
1.8 KiB
C++
87 lines
1.8 KiB
C++
#pragma once
|
|
#include <QPaintEvent>
|
|
#include <QPainter>
|
|
namespace Psc {
|
|
enum class Direction {
|
|
First,
|
|
Middle,
|
|
Last,
|
|
Default
|
|
};
|
|
class Layout_Item {
|
|
public:
|
|
enum Size_Policy {
|
|
Get_Main_By_Cross = 1,
|
|
Cross_Expand = 2,
|
|
Grow = 4,
|
|
Shrink = 8,
|
|
Ignore = 16
|
|
};
|
|
Direction direction = Direction::Default;
|
|
QFlags<Size_Policy> size_policy;
|
|
bool use_get_main_by_cros = false;
|
|
virtual int get_main_by_cros(int cros) {
|
|
return cros;
|
|
}
|
|
virtual ~Layout_Item() = default;
|
|
[[nodiscard]] int x() const {
|
|
return _x;
|
|
}
|
|
[[nodiscard]] int y() const {
|
|
return _y;
|
|
}
|
|
[[nodiscard]] int w() const {
|
|
return _w;
|
|
}
|
|
[[nodiscard]] int h() const {
|
|
return _h;
|
|
}
|
|
void set_x(int x) {
|
|
_x = x;
|
|
}
|
|
void set_y(int y) {
|
|
_y = y;
|
|
}
|
|
void set_w(int w) {
|
|
_w = w;
|
|
}
|
|
void set_h(int h) {
|
|
_h = h;
|
|
}
|
|
void set_size(int w, int h) {
|
|
_w = w;
|
|
_h = h;
|
|
}
|
|
void set_size(QSize size) {
|
|
_w = size.width();
|
|
_h = size.height();
|
|
}
|
|
virtual QSize sizeHint() const {
|
|
return QSize(_w, _h);
|
|
}
|
|
virtual QSize minimumSize() const {
|
|
return QSize(_w, _h);
|
|
}
|
|
virtual QSize maximumSize() const {
|
|
return QSize(_w, _h);
|
|
}
|
|
[[nodiscard]] QRect rect() const {
|
|
return {_x, _y, _w, _h};
|
|
}
|
|
protected:
|
|
int _x = 0, _y = 0, _w = 0, _h = 0;
|
|
};
|
|
class E : public Layout_Item {
|
|
public:
|
|
virtual ~E() = default;
|
|
virtual void paint(QPainter* painter, QRect r, QPaintEvent* event) {
|
|
}
|
|
virtual void event(QEvent::Type t, QEvent* e) {
|
|
}
|
|
void update() {
|
|
need_update = true;
|
|
}
|
|
bool need_update = false;
|
|
};
|
|
} // namespace Psc
|