Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
colorgriditem.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2012-2017 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 #ifndef COLORGRIDITEM_H
17 #define COLORGRIDITEM_H
18 
19 #include <QWidget>
20 #include <QMenu>
21 
22 class ColorGridItem : public QWidget
23 {
24  Q_OBJECT
25 public:
26  explicit ColorGridItem(int id, QWidget *parent = 0);
27  QColor color();
28  virtual QSize sizeHint () const;
29  virtual QSize minimumSizeHint () const;
30 
31 signals:
32  void colorDroped(int);
33  void colorPicked(int, const QColor &);
34 
35 public slots:
36 // void setSource(ColorWheel * wheel);
37  void setColor(const QColor& color);
38  void onColorPicked();
39  void onColorDroped();
40  void onColorCleared();
41 protected:
42  void drawTransparent();
43  void paintEvent(QPaintEvent *);
44  void enterEvent(QEvent* event);
45  void leaveEvent(QEvent* event);
46  void mousePressEvent(QMouseEvent *event);
47  void initMenu();
48 
49 private:
50  int mGridId;
51  QMenu menu;
52  QColor mColor;
53  QPixmap mBackgroundImg;
54  bool mHovered;
55  QCursor picker;
56 };
57 
58 #endif // COLORGRIDITEM_H