ff7tk  1.2.0.13
Work with Final Fantasy 7 game data
ColorDisplay.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009 - 2022 Arzel Jérôme <myst6re@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #pragma once
5 
6 
7 #include <QWidget>
8 #include <ff7tkqtwidgets_export.h>
9 
10 #define COLOR_DISPLAY_MIN_CELL_SIZE 9
11 #define COLOR_DISPLAY_BORDER_WIDTH 1
12 
13 class FF7TKQTWIDGETS_EXPORT ColorDisplay : public QWidget
14 {
15  Q_OBJECT
16 public:
17  explicit ColorDisplay(QWidget *parent = nullptr);
18  void setColors(const QList<QRgb> &colors);
19  const QList<QRgb> &colors() const;
20  bool isReadOnly() const;
21  void setReadOnly(bool ro);
22  QSize sizeHint() const override;
23  QSize minimumSizeHint() const override;
24  inline int cellWidth() const {
25  return cellWidth(width());
26  }
27  inline int cellHeight() const {
28  return cellHeight(height());
29  }
30 signals:
31  void colorEdited(int id, QRgb value);
32  void colorHovered(int id);
33 private:
34  int colorId(const QPoint &pos) const;
35  int cellWidth(int w) const;
36  int cellHeight(int h) const;
37  QSize cellSize() const;
38  QList<QRgb> _colors;
39  bool _ro, _hover;
40 protected:
41  void paintEvent(QPaintEvent *event) override;
42  void enterEvent(QEnterEvent *event) override;
43  void leaveEvent(QEvent *event) override;
44  void mouseMoveEvent(QMouseEvent *event) override;
45  void mouseReleaseEvent(QMouseEvent *event) override;
46 };
ColorDisplay::cellWidth
int cellWidth() const
Definition: ColorDisplay.h:24
ColorDisplay
Definition: ColorDisplay.h:13
ColorDisplay::cellHeight
int cellHeight() const
Definition: ColorDisplay.h:27