Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
colorpalettewidget.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#ifndef COLOR_PALETTE_WIDGET_H
19#define COLOR_PALETTE_WIDGET_H
20
21#include "basedockwidget.h"
22
23class QToolButton;
24class QListWidget;
25class QListWidgetItem;
26class Object;
27class Editor;
28class ColorBox;
29class QActionGroup;
30class QMenu;
31class QString;
32
33namespace Ui
34{
35 class ColorPalette;
36}
37
38class ColorPaletteWidget : public BaseDockWidget
39{
40 Q_OBJECT
41
42public:
43
44 explicit ColorPaletteWidget(QWidget* parent);
45 ~ColorPaletteWidget() override;
46
47 void initUI() override;
48 void updateUI() override;
49 void setCore(Editor* editor);
50
51 int currentColorNumber();
52
53 void selectColorNumber(int) const;
54 void refreshColorList();
55
56 void adjustSwatches();
57
58 void showContextMenu(const QPoint&);
59
60signals:
61 void colorNumberChanged(int);
62
63protected:
64 void resizeEvent(QResizeEvent* event) override;
65
66private slots:
67 void clickColorListItem(QListWidgetItem*);
68 void changeColorName(QListWidgetItem*);
69 void onItemChanged(QListWidgetItem* item);
70 void onRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
71 void clickAddColorButton();
72 void clickColorDialogButton();
73 void clickRemoveColorButton();
74 void palettePreferences();
75 void setListMode();
76 void setGridMode();
77 void setSwatchSizeSmall();
78 void setSwatchSizeMedium();
79 void setSwatchSizeLarge();
80 void fitSwatchSize();
81 void addItem();
82 void replaceItem();
83 void removeItem();
84 void showPaletteReminder();
85
86 bool showPaletteWarning();
87
88private:
89 void updateItemColor(int, QColor);
90 void updateGridUI();
91 void addSwatch(int colorIndex) const;
92
93 Ui::ColorPalette* ui = nullptr;
94 QActionGroup* mLayoutModeActionGroup = nullptr;
95 QAction* mListModeAction = nullptr;
96 QAction* mGridModeAction = nullptr;
97 QActionGroup* mIconSizesActionGroup = nullptr;
98 QAction* mSmallSwatchAction = nullptr;
99 QAction* mMediumSwatchAction = nullptr;
100 QAction* mLargeSwatchAction = nullptr;
101 QAction* mSeparator = nullptr;
102
103 QSize mIconSize{ 34, 34 };
104 QMenu* mToolMenu = nullptr;
105 int stepper = 0;
106
107 QString buttonStylesheet;
108
109 bool mIsColorDialog = false;
110 bool mMultipleSelected = false;
111 bool mFitSwatches = false;
112
113 const int MIN_ICON_SIZE = 19;
114 const int MEDIUM_ICON_SIZE = 26;
115 const int MAX_ICON_SIZE = 36;
116
117 Editor* mEditor = nullptr;
118 Object* mObject = nullptr;
119};
120
121#endif
122
BaseDockWidget
Definition: basedockwidget.h:27
ColorBox
Definition: colorbox.h:24
ColorPaletteWidget
Definition: colorpalettewidget.h:39
Editor
Definition: editor.h:71
Object
Definition: object.h:42
QAction
QActionGroup
QColor
QDockWidget::event
virtual bool event(QEvent *event) override
QListWidget
QListWidgetItem
QMenu
QModelIndex
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::parent
QObject * parent() const const
QPoint
QResizeEvent
QSize
QString
QToolButton
QWidget
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39