Warning, file /graphics/glaxnimate/src/gui/widgets/flow_layout.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include <QLayout>
0012 #include <QStyle>
0013 #include <QBoxLayout>
0014 
0015 namespace glaxnimate::gui {
0016 
0017 class FlowLayout : public QLayout
0018 {
0019 public:
0020     explicit FlowLayout(int items_per_row = 3, int min_w = 32, int max_w = 80, QWidget *parent = nullptr);
0021     ~FlowLayout();
0022 
0023     void addItem(QLayoutItem *item) override;
0024     bool hasHeightForWidth() const override;
0025     int heightForWidth(int width) const override;
0026     int count() const override;
0027     QLayoutItem *itemAt(int index) const override;
0028     QSize minimumSize() const override;
0029     void setGeometry(const QRect &rect) override;
0030     QSize sizeHint() const override;
0031     QLayoutItem *takeAt(int index) override;
0032     Qt::Orientations expandingDirections() const override;
0033     void set_fixed_item_size(const QSize& size);
0034     void set_orientation(Qt::Orientation orientation);
0035 
0036 private:
0037     QSize do_layout(const QRect &rect, bool test_only) const;
0038     bool valid_index(int index) const;
0039 
0040     std::vector<QLayoutItem *> items;
0041     int min_w;
0042     int max_w;
0043     int items_per_row;
0044     QSize fixed_size;
0045     Qt::Orientation orient = Qt::Horizontal;
0046     mutable QSize contents;
0047 };
0048 
0049 } // namespace glaxnimate::gui