1 #pragma once
2 
3 #ifndef STYLEPICKERTOOL_H
4 #define STYLEPICKERTOOL_H
5 
6 #include "tools/tool.h"
7 #include "tproperty.h"
8 #include <QObject>
9 // For Qt translation support
10 #include <QCoreApplication>
11 
12 class StylePickerTool final : public TTool, public QObject {
13   Q_DECLARE_TR_FUNCTIONS(StylePickerTool)
14 
15   int m_oldStyleId, m_currentStyleId;
16 
17   TEnumProperty m_colorType;
18   TPropertyGroup m_prop;
19   TBoolProperty m_passivePick;
20 
21   TBoolProperty m_organizePalette;
22   TPalette *m_paletteToBeOrganized;
23 
24   bool startOrganizePalette();
25 
26 public:
getProperties(int targetType)27   TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
28 
29   StylePickerTool();
30 
getToolType()31   ToolType getToolType() const override { return TTool::LevelReadTool; }
32 
draw()33   void draw() override {}
34 
35   void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
36 
37   void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
38 
39   void pick(const TPointD &pos, const TMouseEvent &e, bool isDragging = true);
40 
41   void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
42 
43   int getCursorId() const override;
44 
45   bool onPropertyChanged(std::string propertyName) override;
46 
isOrganizePaletteActive()47   bool isOrganizePaletteActive() { return m_organizePalette.getValue(); }
48 
49   /*
50      This function is called when either frame/column/level/scene is switched or
51      either scene/level/object is changed (see tapp.cpp).
52      If the working palette is changed, then deactivate the "organize palette"
53      toggle.
54   */
55   void onImageChanged() override;
56 
57   void updateTranslation() override;
58 };
59 
60 #endif
61