/* Copyright 2020, Michele Santullo * This file is part of memoserv. * * Memoserv is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Memoserv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Memoserv. If not, see . */ #pragma once #include "../animated_pixmap.hpp" #include #include #include #include class QTimer; namespace duck::widget { class BlockGrid : public QWidget { Q_OBJECT public: explicit BlockGrid (QWidget* parent=nullptr, unsigned int rows=0, unsigned int columns=0, float fps=24.0f); ~BlockGrid() noexcept; QSize minimumSizeHint() const override; QSize sizeHint() const override; void set_icon_size (const QSize& sz); void set_icon_size (int sz); QSize icon_size() const; void push_back (AnimatedPixmap&& anim); std::size_t size() const; protected: void paintEvent (QPaintEvent* event) override; private slots: void advance_frame(); private: unsigned int rows() const; unsigned int columns() const; std::vector m_icons; QTimer* m_anim_timer; std::unique_ptr m_empty_icon; QSize m_icon_size; unsigned int m_rows; unsigned int m_columns; }; } //namespace duck::widget