#ifndef MODULEUNIT_H
#define MODULEUNIT_H

#include <QWidget>
#include <QVBoxLayout>
#include <QPen>

#define m_handleLen 10
class ExpertWin;
class ModuleUnit : public QWidget {
    Q_OBJECT
public:
    explicit ModuleUnit(ExpertWin *, const QString &name, int x, int y, int w, int h, QWidget *parent = nullptr);

    ExpertWin *expertWin{0};
    QString name;
    int mX, mY, mW, mH;
protected:
    void paintEvent(QPaintEvent *) override;
    void mousePressEvent(QMouseEvent *) override;
    void mouseReleaseEvent(QMouseEvent *) override;
    void mouseMoveEvent(QMouseEvent *) override;
    void leaveEvent(QEvent *) override;

    void setFrmSec(const QPoint &);
    void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
    void clearSnap();
    QPen mSidePen{Qt::white};

    QPoint mPressRel{INT_MIN, INT_MIN};
    Qt::WindowFrameSection mFrmSec{Qt::NoSection};
    char mLRSnap{0}, mTBSnap{0};
    QList<ModuleUnit *> mOtherEles;

};

#endif // MODULEUNIT_H
