Files
OpenRGB/qt/DeviceView.h
Adam Honse 2b93788fe3 RGBController API changes and segment configuration updates
* Make the Get/Set RGBControler descriptor functions static
  * Add functions for getting the matrix_map_type for zone and segment matrix maps
  * Rename zone resize dialog to zone editor dialog
  * Add additional segment types
  * Add option to import segments configuration from JSON file in zone editor dialog
  * Update device view to be able to display matrix segment types
  * Add matrix map editor dialog for creating/editing segment matrix maps
  * Add option to export segments configuration to JSON file in zone editor dialog
2026-04-03 13:46:35 -05:00

89 lines
2.5 KiB
C++

/*---------------------------------------------------------*\
| DeviceView.h |
| |
| OpenRGB Device view widget for Qt |
| |
| Adam Honse (calcprogrammer1@gmail.com) |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#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
public:
explicit DeviceView(QWidget *parent = 0);
~DeviceView();
virtual QSize sizeHint () const;
virtual QSize minimumSizeHint () const;
void setChanged();
void setController(RGBController * controller_ptr);
void setNumericalLabels(bool enable);
void setPerLED(bool per_led_mode);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *);
private:
QSize initSize;
bool mouseDown;
bool ctrlDown;
bool mouseMoved;
bool changed;
int size;
int offset_x;
QRect selectionRect;
QPoint lastMousePos;
QVector<int> previousSelection;
QVector<int> selectedLeds;
QVector<bool> selectionFlags;
QVector<bool> previousFlags;
bool per_led;
std::vector<matrix_pos_size_type> zone_pos;
std::vector<matrix_pos_size_type> segment_pos;
std::vector<matrix_pos_size_type> led_pos;
std::vector<QString> led_labels;
float matrix_h;
bool numerical_labels;
RGBController* controller;
QColor posColor(const QPoint &point);
void InitDeviceView();
void updateSelection();
signals:
void selectionChanged(QVector<int>);
public slots:
bool selectLed(int);
bool selectLeds(QVector<int>);
bool selectSegment(int zone, int segment, bool add = false);
bool selectZone(int zone, bool add = false);
void clearSelection(); // Same as selecting the entire device
void setSelectionColor(RGBColor);
};