mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
* Performance stuffs. * Actually make widgets track their indices. * Functional stuff. * More display stuff. * Determine where we will insert the card before actually inserting it in the model. * Allow overlap layouts to insert widgets at specific positions. * Modified signals. * Raise trailing widgets on overlap layout widget insertion. * Nix the logging config changes. * Lint. * Address comments. * Address comments. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
54 lines
No EOL
2.1 KiB
C++
54 lines
No EOL
2.1 KiB
C++
#ifndef FLOW_LAYOUT_H
|
|
#define FLOW_LAYOUT_H
|
|
|
|
#include <QLayout>
|
|
#include <QList>
|
|
#include <QLoggingCategory>
|
|
#include <QWidget>
|
|
#include <qstyle.h>
|
|
|
|
inline Q_LOGGING_CATEGORY(FlowLayoutLog, "flow_layout", QtInfoMsg);
|
|
|
|
class FlowLayout : public QLayout
|
|
{
|
|
public:
|
|
explicit FlowLayout(QWidget *parent = nullptr);
|
|
FlowLayout(QWidget *parent, Qt::Orientation _flowDirection, int margin = 0, int hSpacing = 0, int vSpacing = 0);
|
|
~FlowLayout() override;
|
|
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
|
|
|
QSize calculateMinimumSizeHorizontal() const;
|
|
QSize calculateSizeHintVertical() const;
|
|
QSize calculateMinimumSizeVertical() const;
|
|
void addItem(QLayoutItem *item) override;
|
|
[[nodiscard]] int count() const override;
|
|
[[nodiscard]] QLayoutItem *itemAt(int index) const override;
|
|
QLayoutItem *takeAt(int index) override;
|
|
[[nodiscard]] int horizontalSpacing() const;
|
|
|
|
[[nodiscard]] Qt::Orientations expandingDirections() const override;
|
|
[[nodiscard]] bool hasHeightForWidth() const override;
|
|
[[nodiscard]] int heightForWidth(int width) const override;
|
|
[[nodiscard]] int verticalSpacing() const;
|
|
[[nodiscard]] int doLayout(const QRect &rect, bool testOnly) const;
|
|
[[nodiscard]] int smartSpacing(QStyle::PixelMetric pm) const;
|
|
[[nodiscard]] int getParentScrollAreaWidth() const;
|
|
[[nodiscard]] int getParentScrollAreaHeight() const;
|
|
|
|
void setGeometry(const QRect &rect) override;
|
|
virtual int layoutAllRows(int originX, int originY, int availableWidth);
|
|
virtual void layoutSingleRow(const QVector<QLayoutItem *> &rowItems, int x, int y);
|
|
int layoutAllColumns(int originX, int originY, int availableHeight);
|
|
void layoutSingleColumn(const QVector<QLayoutItem *> &colItems, int x, int y);
|
|
[[nodiscard]] QSize sizeHint() const override;
|
|
[[nodiscard]] QSize minimumSize() const override;
|
|
QSize calculateSizeHintHorizontal() const;
|
|
|
|
protected:
|
|
QList<QLayoutItem *> items; // List to store layout items
|
|
Qt::Orientation flowDirection;
|
|
int horizontalMargin;
|
|
int verticalMargin;
|
|
};
|
|
|
|
#endif // FLOW_LAYOUT_H
|