1 /*
2    Drawpile - a collaborative drawing program.
3 
4    Copyright (C) 2013-2017 Calle Laakkonen
5 
6    Drawpile is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation, either version 3 of the License, or
9    (at your option) any later version.
10 
11    Drawpile is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with Drawpile.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef RESIZEDIALOG_H
20 #define RESIZEDIALOG_H
21 
22 #include <QDialog>
23 
24 class Ui_ResizeDialog;
25 
26 namespace dialogs {
27 
28 struct ResizeVector {
29 	int top, right, bottom, left;
30 
isZeroResizeVector31 	bool isZero() const {
32 		return top==0 && right==0 && bottom==0 && left==0;
33 	}
34 };
35 
36 class ResizeDialog : public QDialog
37 {
38 	Q_OBJECT
39 public:
40 	explicit ResizeDialog(const QSize &oldsize, QWidget *parent=nullptr);
41 	~ResizeDialog();
42 
43 	void setPreviewImage(const QImage &image);
44 	void setBounds(const QRect &rect);
45 
46 	QSize newSize() const;
47 	QPoint newOffset() const;
48 	ResizeVector resizeVector() const;
49 
50 public slots:
51 	void done(int r);
52 
53 private slots:
54 	void widthChanged(int);
55 	void heightChanged(int);
56 	void toggleAspectRatio(bool keep);
57 	void reset();
58 
59 private:
60 	Ui_ResizeDialog *m_ui;
61 
62 	QSize m_oldsize;
63 	float m_aspectratio;
64 	int m_lastchanged;
65 };
66 
67 }
68 
69 #endif
70