Debian Codegraph @

src/context/applets/analyzer/plugin/BlockAnalyzer.h

raw
1 /****************************************************************************************
2 * Copyright (c) 2003-2005 Max Howell <[email protected]> *
3 * Copyright (c) 2005-2013 Mark Kretschmann <[email protected]> *
4 * *
5 * This program is free software; you can redistribute it and/or modify it under *
6 * the terms of the GNU General Public License as published by the Free Software *
7 * Foundation; either version 2 of the License, or (at your option) any later *
8 * version. *
9 * *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
12 * PARTICULAR PURPOSE. See the GNU General Pulic License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along with *
15 * this program. If not, see <http://www.gnu.org/licenses/>. *
16 ****************************************************************************************/
17
18 #ifndef BLOCKANALYZER_H
19 #define BLOCKANALYZER_H
20
21 #include "AnalyzerBase.h"
22
23 #include <QPixmap>
24 #include <QQuickWindow>
25 #include <QSharedPointer>
26
27 class QPalette;
28
29 class BlockAnalyzer : public Analyzer::Base
30 {
31 friend class BlockRenderer;
32
33 Q_OBJECT
34 Q_PROPERTY(FallSpeed fallSpeed READ fallSpeed WRITE setFallSpeed NOTIFY fallSpeedChanged)
35 Q_PROPERTY(int columnWidth READ columnWidth WRITE setColumnWidth NOTIFY columnWidthChanged)
36 Q_PROPERTY(bool showFadebars READ showFadebars WRITE setShowFadebars NOTIFY showFadebarsChanged)
37
38 public:
39 enum FallSpeed
40 {
41 VerySlow = 0,
42 Slow = 1,
43 Medium = 2,
44 Fast = 3,
45 VeryFast = 4
46 };
47 Q_ENUM( FallSpeed )
48
49 explicit BlockAnalyzer( QQuickItem *parent = nullptr );
50
51 Renderer* createRenderer() const override;
52
53 FallSpeed fallSpeed() const { return m_fallSpeed; }
54 void setFallSpeed( FallSpeed fallSpeed );
55 int columnWidth() const { return m_columnWidth; }
56 void setColumnWidth( int columnWidth );
57 bool showFadebars() const { return m_showFadebars; }
58 void setShowFadebars( bool showFadebars );
59
60 // Signed ints because most of what we compare them against are ints
61 static const int BLOCK_HEIGHT = 2;
62 static const int FADE_SIZE = 90;
63
64 Q_SIGNALS:
65 void fallSpeedChanged();
66 void columnWidthChanged();
67 void showFadebarsChanged( bool );
68 void stepChanged( qreal );
69 void rowsChanged( int );
70 void columnsChanged( int );
71 void refreshRateChanged( qreal );
72
73 protected:
74 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
75 Analyzer::Worker* createWorker() const override;
76 virtual void paletteChange( const QPalette& );
77
78 void drawBackground( const QPalette &palette );
79 void determineStep();
80
81 private:
82 void newWindow( QQuickWindow *window );
83
84 int m_columns, m_rows; //number of rows and columns of blocks
85 int m_columnWidth;
86 bool m_showFadebars;
87 QPixmap m_barPixmap;
88 QPixmap m_topBarPixmap;
89 QPixmap m_backgroundPixmap;
90 QVector<QPixmap> m_fadeBarsPixmaps;
91 bool m_pixmapsChanged;
92
93 qreal m_step; //rows to fall per frame
94 FallSpeed m_fallSpeed;
95 };
96
97 #endif