1 #pragma once
2 
3 #ifndef LEVELSETTINGSPOPUP_H
4 #define LEVELSETTINGSPOPUP_H
5 
6 #include "toonzqt/dvdialog.h"
7 
8 #include "toonz/txshsimplelevel.h"
9 #include "toonz/txshpalettelevel.h"
10 #include "toonz/txshchildlevel.h"
11 #include "toonz/txshsoundlevel.h"
12 
13 #include <QSet>
14 
15 // forward declaration
16 class QLabel;
17 class QComboBox;
18 class QPushButton;
19 class TXshLevel;
20 class TSelection;
21 
22 namespace DVGui {
23 class FileField;
24 class DoubleField;
25 class LineEdit;
26 class IntLineEdit;
27 class DoubleLineEdit;
28 class MeasuredDoubleLineEdit;
29 class CheckBox;
30 }  // namespace DVGui
31 
32 enum SelectedLevelType {
33   None        = 0x0,
34   ToonzRaster = 0x1,
35   Raster      = 0x2,
36   Mesh        = 0x4,
37   ToonzVector = 0x8,
38   Palette     = 0x10,
39   SubXsheet   = 0x20,
40   Sound       = 0x40,
41   Others      = 0x80,
42 
43   MultiSelection  = 0x100,
44   HideOnPixelMode = 0x200,
45   NoSelection     = 0x400,
46 
47   SimpleLevel = ToonzRaster | Raster | Mesh | ToonzVector,
48   HasDPILevel = ToonzRaster | Raster | Mesh,
49   AllTypes    = SimpleLevel | Palette | SubXsheet | Sound
50 };
51 
52 struct LevelSettingsValues {
53   QString name, path, scanPath, typeStr, imageDpi, imageRes;
54   int dpiType = -1, softness = -1, subsampling = -1;
55   TPointD dpi               = TPointD(0, 0);
56   Qt::CheckState doPremulti = Qt::Unchecked, whiteTransp = Qt::Unchecked,
57                  doAntialias = Qt::Unchecked, isDirty = Qt::Unchecked;
58   double width = 0.0, height = 0.0;
59 };
60 
61 //=============================================================================
62 // LevelSettingsPopup
63 //-----------------------------------------------------------------------------
64 
65 class LevelSettingsPopup final : public DVGui::Dialog {
66   Q_OBJECT
67 
68   QSet<TXshLevelP> m_selectedLevels;
69   QMap<QWidget *, unsigned int> m_activateFlags;
70 
71   DVGui::LineEdit *m_nameFld;
72   DVGui::FileField *m_pathFld;
73   DVGui::FileField *m_scanPathFld;
74   QLabel *m_typeLabel;
75   QComboBox *m_dpiTypeOm;
76   DVGui::DoubleLineEdit *m_dpiFld;
77   DVGui::CheckBox *m_squarePixCB;
78   DVGui::MeasuredDoubleLineEdit *m_widthFld;
79   DVGui::MeasuredDoubleLineEdit *m_heightFld;
80   QPushButton *m_useCameraDpiBtn;
81   QLabel *m_cameraDpiLabel;
82   QLabel *m_imageDpiLabel;
83   QLabel *m_imageResLabel;
84   DVGui::CheckBox *m_doPremultiply;
85   DVGui::CheckBox *m_whiteTransp;
86   DVGui::CheckBox *m_doAntialias;
87   QLabel *m_softnessLabel;
88   DVGui::IntLineEdit *m_antialiasSoftness;
89 
90   QLabel *m_subsamplingLabel;
91   DVGui::IntLineEdit *m_subsamplingFld;
92 
93   SelectedLevelType getType(TXshLevelP);
94   LevelSettingsValues getValues(TXshLevelP);
95 
96 public:
97   LevelSettingsPopup();
98 
99 protected:
100   void showEvent(QShowEvent *e) override;
101   void hideEvent(QHideEvent *e) override;
102 
103 protected slots:
104 
105   void onCastSelectionChanged();
106   void onSelectionSwitched(TSelection *oldSelection, TSelection *newSelection);
107   void updateLevelSettings();
108   void onNameChanged();
109   void onPathChanged();
110   void onScanPathChanged();
111   void onDpiTypeChanged(int);
112   void onDpiFieldChanged();
113   void onWidthFieldChanged();
114   void onHeightFieldChanged();
115   void onSquarePixelChanged(int);
116   void useCameraDpi();
117   void onSubsamplingChanged();
118   void onDoPremultiplyClicked();
119   void onDoAntialiasClicked();
120   void onAntialiasSoftnessChanged();
121   void onWhiteTranspClicked();
122   void onSceneChanged();
123   void onPreferenceChanged(const QString &);
124 };
125 
126 #endif  // LEVELSETTINGSPOPUP_H
127