1 #pragma once
2 
3 #include "traster.h"
4 #include <QWidget>
5 
6 // class QPushButton;
7 class QAction;
8 class CleanupSwatch final : public QWidget {
9   Q_OBJECT
10 
11   class CleanupSwatchArea final : public QWidget {
12     QPoint m_pos;
13     bool m_isLeft, m_panning;
14     CleanupSwatch *m_sw;
15     TRaster32P m_r;
16     TAffine getFinalAff();
17 
18   public:
19     CleanupSwatchArea(CleanupSwatch *parent, bool isLeft);
20     void updateRaster(bool dragging = false);
21     void updateCleanupped(bool dragging = false);
22 
23   protected:
24     void paintEvent(QPaintEvent *event) override;
25     void mousePressEvent(QMouseEvent *event) override;
26     void mouseMoveEvent(QMouseEvent *event) override;
27     void mouseReleaseEvent(QMouseEvent *event) override;
28     void wheelEvent(QWheelEvent *event) override;
29     void keyPressEvent(QKeyEvent *event) override;
30   };
31 
32   int m_lx, m_ly;
33   bool m_enabled;
34   CleanupSwatchArea *m_leftSwatch;
35   CleanupSwatchArea *m_rightSwatch;
36 
37   TAffine m_viewAff, m_resampleAff;
38   TRasterP m_resampledRaster;
39   TRasterP m_origRaster;
40   // TRasterP m_lastRasCleanupped;
41   // TPointD  m_lastCleanuppedPos;
42 public:
43   CleanupSwatch(QWidget *parent, int lx, int ly);
44 
45   void setRaster(TRasterP rasLeft, const TAffine &aff, TRasterP ras);
46   void updateCleanupped();
47   bool isEnabled();
48   void enable(bool state);
49   // void enableRightSwatch(bool state);
50 protected:
51   // void hideEvent(QHideEvent* e);
52   void resizeEvent(QResizeEvent *event) override;
53 
54 signals:
55   void enabled();
56 };
57