WIP: Multiple selection test

Rework of LED position data from RGBController into DeviceView, code style cleanup modified by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
k1-801 2020-08-19 09:01:02 +04:00 committed by Adam Honse
parent c6b10d9316
commit a2a394492b
5 changed files with 644 additions and 114 deletions

View file

@ -4,6 +4,14 @@
#include <QWidget>
#include "RGBController.h"
typedef struct
{
float matrix_x;
float matrix_y;
float matrix_w;
float matrix_h;
} matrix_pos_size_type;
class DeviceView : public QWidget
{
Q_OBJECT
@ -12,7 +20,7 @@ public:
virtual QSize sizeHint () const;
virtual QSize minimumSizeHint () const;
void setController(RGBController * controller_ptr);
protected:
@ -21,14 +29,38 @@ protected:
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *);
private:
QSize initSize;
bool mouseDown;
QPoint lastPos;
bool ctrlDown;
bool mouseMoved;
QRect selectionRect;
QPoint lastMousePos;
QVector<int> previousSelection;
QVector<int> selectedLeds;
QVector<bool> selectionFlags;
QVector<bool> previousFlags;
std::vector<matrix_pos_size_type> zone_pos;
std::vector<matrix_pos_size_type> led_pos;
float matrix_h;
RGBController* controller;
QColor posColor(const QPoint &point);
QColor posColor(const QPoint &point);
void updateSelection();
signals:
void selectionChanged(QVector<int>);
public slots:
bool selectLed(int);
bool selectLeds(QVector<int>);
bool selectZone(int zone, bool add = false);
void clearSelection(); // Same as selecting the entire device
void setSelectionColor(RGBColor);
};
#endif // DEVICEVIEW_H