diff --git a/OpenRGB.pro b/OpenRGB.pro index aebb76f6..055f61a6 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -22,9 +22,12 @@ INCLUDEPATH += \ SOURCES += \ main.cpp \ OpenAuraSDK.cpp \ + qt/OpenRGBDevicePage.cpp \ qt/OpenRGBDialog.cpp \ i2c_smbus/i2c_smbus.cpp \ net_port/net_port.cpp \ + qt/OpenRGBDialog2.cpp \ + qt/hsv.cpp \ serial_port/serial_port.cpp \ Controllers/AuraController/AuraController.cpp \ Controllers/AuraController/AuraControllerDetect.cpp \ @@ -49,9 +52,11 @@ SOURCES += \ RGBController/RGBController_RGBFusion.cpp HEADERS += \ + qt/OpenRGBDevicePage.h \ qt/OpenRGBDialog.h \ i2c_smbus/i2c_smbus.h \ net_port/net_port.h \ + qt/OpenRGBDialog2.h \ serial_port/serial_port.h \ Controllers/AuraController/AuraController.h \ Controllers/CorsairController/CorsairController.h \ @@ -71,7 +76,9 @@ RESOURCES += \ qt/resources.qrc FORMS += \ - qt/OpenRGBDialog.ui + qt/OpenRGBDevicePage.ui \ + qt/OpenRGBDialog.ui \ + qt/OpenRGBDialog2.ui #----------------------------------------------- # Windows specific project configuration diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index 5f2ec90c..f7093862 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -39,6 +39,21 @@ enum ZONE_TYPE_MATRIX }; +typedef int device_type; + +enum +{ + DEVICE_TYPE_MOTHERBOARD, + DEVICE_TYPE_DRAM, + DEVICE_TYPE_GPU, + DEVICE_TYPE_COOLER, + DEVICE_TYPE_LEDSTRIP, + DEVICE_TYPE_KEYBOARD, + DEVICE_TYPE_MOUSE, + DEVICE_TYPE_HEADSET, + DEVICE_TYPE_UNKNOWN +}; + typedef struct { std::string name; /* Zone name */ @@ -55,6 +70,7 @@ public: std::vector zones; /* Zones */ std::vector modes; /* Modes */ std::vector colors; /* Color buffer */ + device_type type; /* device type */ virtual int GetMode() = 0; virtual void SetMode(int mode) = 0; @@ -63,4 +79,4 @@ public: virtual void SetAllZoneLEDs(int zone, RGBColor color) = 0; virtual void SetLED(int led, RGBColor color) = 0; virtual void UpdateLEDs() = 0; -}; \ No newline at end of file +}; diff --git a/RGBController/RGBController_Aura.cpp b/RGBController/RGBController_Aura.cpp index c1b55342..2ba9a730 100644 --- a/RGBController/RGBController_Aura.cpp +++ b/RGBController/RGBController_Aura.cpp @@ -120,6 +120,15 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr) name = aura->GetDeviceName(); + if((name.rfind("DRAM", 0) == 0) || (name.rfind("AUDA", 0) == 0) ) + { + type = DEVICE_TYPE_DRAM; + } + else + { + type = DEVICE_TYPE_MOTHERBOARD; + } + mode aura_modes[AURA_NUMBER_MODES + 1]; aura_modes[0].name = "Direct"; @@ -200,4 +209,4 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr) zones.push_back(*new_zone); } } -} \ No newline at end of file +} diff --git a/RGBController/RGBController_Corsair.cpp b/RGBController/RGBController_Corsair.cpp index acda80c3..026e11c0 100644 --- a/RGBController/RGBController_Corsair.cpp +++ b/RGBController/RGBController_Corsair.cpp @@ -68,6 +68,8 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr) name = corsair->GetDeviceName(); + type = DEVICE_TYPE_DRAM; + mode corsair_modes[CORSAIR_NUMBER_MODES]; corsair_modes[0].name = "Static"; @@ -104,4 +106,4 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr) new_zone.map.push_back(zone_row); zones.push_back(new_zone); -} \ No newline at end of file +} diff --git a/RGBController/RGBController_CorsairPro.cpp b/RGBController/RGBController_CorsairPro.cpp index ebb3985c..ae7782a6 100644 --- a/RGBController/RGBController_CorsairPro.cpp +++ b/RGBController/RGBController_CorsairPro.cpp @@ -104,6 +104,8 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair name = corsair->GetDeviceName(); + type = DEVICE_TYPE_DRAM; + mode corsair_modes[CORSAIR_PRO_NUMBER_MODES]; corsair_modes[0].name = "Color Shift"; @@ -147,4 +149,4 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair new_zone.map.push_back(zone_row); zones.push_back(new_zone); -} \ No newline at end of file +} diff --git a/RGBController/RGBController_HuePlus.cpp b/RGBController/RGBController_HuePlus.cpp index 30c5611b..16eea35f 100644 --- a/RGBController/RGBController_HuePlus.cpp +++ b/RGBController/RGBController_HuePlus.cpp @@ -15,6 +15,8 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr) name = "LED Strip"; + type = DEVICE_TYPE_LEDSTRIP; + mode led_mode; led_mode.name = "Custom"; modes.push_back(led_mode); @@ -83,4 +85,4 @@ void RGBController_HuePlus::SetLED(int led, RGBColor color) void RGBController_HuePlus::UpdateLEDs() { strip->SetLEDs(colors); -} \ No newline at end of file +} diff --git a/RGBController/RGBController_HyperX.cpp b/RGBController/RGBController_HyperX.cpp index fdbd0756..13ab7007 100644 --- a/RGBController/RGBController_HyperX.cpp +++ b/RGBController/RGBController_HyperX.cpp @@ -68,6 +68,8 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr) name = hyperx->GetDeviceName(); + type = DEVICE_TYPE_DRAM; + mode hyperx_modes[HYPERX_NUMBER_MODES]; hyperx_modes[0].name = "Static"; @@ -109,4 +111,4 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr) new_zone.map.push_back(zone_row); zones.push_back(new_zone); -} \ No newline at end of file +} diff --git a/RGBController/RGBController_LEDStrip.cpp b/RGBController/RGBController_LEDStrip.cpp index 5243bc36..dfac5d06 100644 --- a/RGBController/RGBController_LEDStrip.cpp +++ b/RGBController/RGBController_LEDStrip.cpp @@ -16,6 +16,8 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr) name = "LED Strip"; + type = DEVICE_TYPE_LEDSTRIP; + mode led_mode; led_mode.name = "Custom"; modes.push_back(led_mode); @@ -84,4 +86,4 @@ void RGBController_LEDStrip::SetLED(int led, RGBColor color) void RGBController_LEDStrip::UpdateLEDs() { strip->SetLEDs(colors); -} \ No newline at end of file +} diff --git a/RGBController/RGBController_RGBFusion.cpp b/RGBController/RGBController_RGBFusion.cpp index ea9c6cde..950cedb3 100644 --- a/RGBController/RGBController_RGBFusion.cpp +++ b/RGBController/RGBController_RGBFusion.cpp @@ -75,6 +75,8 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion name = rgb_fusion->GetDeviceName(); + type = DEVICE_TYPE_MOTHERBOARD; + mode rgb_fusion_modes[RGB_FUSION_NUMBER_MODES]; rgb_fusion_modes[0].name = "Static"; @@ -110,4 +112,4 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion // Push new zone to zones vector zones.push_back(*new_zone); } -} \ No newline at end of file +} diff --git a/main.cpp b/main.cpp index 1f32d855..26818777 100644 --- a/main.cpp +++ b/main.cpp @@ -13,7 +13,7 @@ #include #include -#include "OpenRGBDialog.h" +#include "OpenRGBDialog2.h" extern std::vector busses; @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) QApplication a(argc, argv); - Ui::OpenRGBDialog dlg(busses, rgb_controllers); + Ui::OpenRGBDialog2 dlg(busses, rgb_controllers); dlg.show(); return a.exec(); diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp new file mode 100644 index 00000000..66f448be --- /dev/null +++ b/qt/OpenRGBDevicePage.cpp @@ -0,0 +1,293 @@ +#include "OpenRGBDevicePage.h" +#include "hsv.h" + +using namespace Ui; + +OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : + QFrame(parent), + ui(new Ui::OpenRGBDevicePageUi) +{ + ui->setupUi(this); + + /*-----------------------------------------------------*\ + | Store device pointer | + \*-----------------------------------------------------*/ + device = dev; + + /*-----------------------------------------------------*\ + | Set up the color palette buttons | + \*-----------------------------------------------------*/ + QPalette pal; + + pal = ui->ButtonRed->palette(); + pal.setColor(QPalette::Button, QColor(255, 0, 0)); + ui->ButtonRed->setAutoFillBackground(true); + ui->ButtonRed->setPalette(pal); + ui->ButtonRed->setFlat(true); + ui->ButtonRed->update(); + + pal = ui->ButtonYellow->palette(); + pal.setColor(QPalette::Button, QColor(255, 255, 0)); + ui->ButtonYellow->setAutoFillBackground(true); + ui->ButtonYellow->setPalette(pal); + ui->ButtonYellow->setFlat(true); + ui->ButtonYellow->update(); + + pal = ui->ButtonGreen->palette(); + pal.setColor(QPalette::Button, QColor(0, 255, 0)); + ui->ButtonGreen->setAutoFillBackground(true); + ui->ButtonGreen->setPalette(pal); + ui->ButtonGreen->setFlat(true); + ui->ButtonGreen->update(); + + pal = ui->ButtonCyan->palette(); + pal.setColor(QPalette::Button, QColor(0, 255, 255)); + ui->ButtonCyan->setAutoFillBackground(true); + ui->ButtonCyan->setPalette(pal); + ui->ButtonCyan->setFlat(true); + ui->ButtonCyan->update(); + + pal = ui->ButtonBlue->palette(); + pal.setColor(QPalette::Button, QColor(0, 0, 255)); + ui->ButtonBlue->setAutoFillBackground(true); + ui->ButtonBlue->setPalette(pal); + ui->ButtonBlue->setFlat(true); + ui->ButtonBlue->update(); + + pal = ui->ButtonMagenta->palette(); + pal.setColor(QPalette::Button, QColor(255, 0, 255)); + ui->ButtonMagenta->setAutoFillBackground(true); + ui->ButtonMagenta->setPalette(pal); + ui->ButtonMagenta->setFlat(true); + ui->ButtonMagenta->update(); + + /*-----------------------------------------------------*\ + | Fill in the combo boxes with device information | + \*-----------------------------------------------------*/ + ui->ModeBox->clear(); + + for (int i = 0; i < device->modes.size(); i++) + { + ui->ModeBox->addItem(device->modes[i].name.c_str()); + } + + ui->ModeBox->setCurrentIndex(device->GetMode()); + + ui->ZoneBox->clear(); + + for (int i = 0; i < device->zones.size(); i++) + { + ui->ZoneBox->addItem(device->zones[i].name.c_str()); + } + + ui->ZoneBox->setCurrentIndex(0); + + ui->LEDBox->clear(); + + for (int i = 0; i < device->leds.size(); i++) + { + ui->LEDBox->addItem(device->leds[i].name.c_str()); + } + + ui->LEDBox->setCurrentIndex(0); +} + +OpenRGBDevicePage::~OpenRGBDevicePage() +{ + delete ui; +} + +void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int index) +{ + +} + +void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int index) +{ + +} + +void Ui::OpenRGBDevicePage::on_ModeBox_currentIndexChanged(int index) +{ + /*-----------------------------------------------------*\ + | Change device mode | + \*-----------------------------------------------------*/ + device->SetMode(ui->ModeBox->currentIndex()); +} + +void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked() +{ + /*-----------------------------------------------------*\ + | Set all device LEDs to the current color | + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); + + device->SetAllLEDs(color); +} + +void Ui::OpenRGBDevicePage::on_SetZoneButton_clicked() +{ + /*-----------------------------------------------------*\ + | Set all LEDs in the selected zone to the current color| + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); + + device->SetAllZoneLEDs(ui->ZoneBox->currentIndex(), color); +} + +void Ui::OpenRGBDevicePage::on_SetLEDButton_clicked() +{ + /*-----------------------------------------------------*\ + | Set the selected LED to the current color | + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); + + device->SetLED(ui->LEDBox->currentIndex(), color); +} + +void Ui::OpenRGBDevicePage::on_ButtonRed_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(255); + ui->GreenSpinBox->setValue(0); + ui->BlueSpinBox->setValue(0); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ButtonYellow_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(255); + ui->GreenSpinBox->setValue(255); + ui->BlueSpinBox->setValue(0); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ButtonGreen_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(0); + ui->GreenSpinBox->setValue(255); + ui->BlueSpinBox->setValue(0); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ButtonCyan_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(0); + ui->GreenSpinBox->setValue(255); + ui->BlueSpinBox->setValue(255); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ButtonBlue_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(0); + ui->GreenSpinBox->setValue(0); + ui->BlueSpinBox->setValue(255); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ButtonMagenta_clicked() +{ + UpdatingColor = true; + ui->RedSpinBox->setValue(255); + ui->GreenSpinBox->setValue(0); + ui->BlueSpinBox->setValue(255); + UpdatingColor = false; + updateHSV(); +} + +void Ui::OpenRGBDevicePage::updateRGB() +{ + if(UpdatingColor) + { + return; + } + + UpdatingColor = true; + + hsv_t hsv; + hsv.hue = ui->HueSpinBox->value(); + hsv.saturation = ui->SatSpinBox->value(); + hsv.value = ui->ValSpinBox->value(); + + RGBColor rgb = hsv2rgb(&hsv); + + ui->RedSpinBox->setValue(RGBGetRValue(rgb)); + ui->GreenSpinBox->setValue(RGBGetGValue(rgb)); + ui->BlueSpinBox->setValue(RGBGetBValue(rgb)); + + UpdatingColor = false; +} + +void Ui::OpenRGBDevicePage::updateHSV() +{ + if(UpdatingColor) + { + return; + } + + UpdatingColor = true; + + RGBColor rgb = ToRGBColor(ui->RedSpinBox->value(), ui->GreenSpinBox->value(), ui->BlueSpinBox->value()); + + hsv_t hsv; + + rgb2hsv(rgb, &hsv); + + ui->HueSpinBox->setValue(hsv.hue); + ui->SatSpinBox->setValue(hsv.saturation); + ui->ValSpinBox->setValue(hsv.value); + + UpdatingColor = false; +} + +void Ui::OpenRGBDevicePage::on_RedSpinBox_valueChanged(int arg1) +{ + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_HueSpinBox_valueChanged(int arg1) +{ + updateRGB(); +} + +void Ui::OpenRGBDevicePage::on_GreenSpinBox_valueChanged(int arg1) +{ + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_SatSpinBox_valueChanged(int arg1) +{ + updateRGB(); +} + +void Ui::OpenRGBDevicePage::on_BlueSpinBox_valueChanged(int arg1) +{ + updateHSV(); +} + +void Ui::OpenRGBDevicePage::on_ValSpinBox_valueChanged(int arg1) +{ + updateRGB(); +} diff --git a/qt/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage.h new file mode 100644 index 00000000..6d90f71c --- /dev/null +++ b/qt/OpenRGBDevicePage.h @@ -0,0 +1,52 @@ +#ifndef OPENRGBDEVICEPAGE_H +#define OPENRGBDEVICEPAGE_H + +#include "ui_OpenRGBDevicePage.h" +#include "RGBController.h" + +#include + +namespace Ui { +class OpenRGBDevicePage; +} + +class Ui::OpenRGBDevicePage : public QFrame +{ + Q_OBJECT + +public: + explicit OpenRGBDevicePage(RGBController *dev, QWidget *parent = nullptr); + ~OpenRGBDevicePage(); + +private slots: + void on_ButtonRed_clicked(); + void on_ButtonYellow_clicked(); + void on_ButtonGreen_clicked(); + void on_ButtonCyan_clicked(); + void on_ButtonBlue_clicked(); + void on_ButtonMagenta_clicked(); + void on_ZoneBox_currentIndexChanged(int index); + void on_LEDBox_currentIndexChanged(int index); + void on_ModeBox_currentIndexChanged(int index); + void on_SetDeviceButton_clicked(); + void on_SetZoneButton_clicked(); + void on_SetLEDButton_clicked(); + void on_RedSpinBox_valueChanged(int arg1); + void on_HueSpinBox_valueChanged(int arg1); + void on_GreenSpinBox_valueChanged(int arg1); + void on_SatSpinBox_valueChanged(int arg1); + void on_BlueSpinBox_valueChanged(int arg1); + void on_ValSpinBox_valueChanged(int arg1); + +private: + Ui::OpenRGBDevicePageUi *ui; + RGBController *device; + + bool UpdatingColor = false; + + void updateRGB(); + + void updateHSV(); +}; + +#endif // OPENRGBDEVICEPAGE_H diff --git a/qt/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage.ui new file mode 100644 index 00000000..32fcc04c --- /dev/null +++ b/qt/OpenRGBDevicePage.ui @@ -0,0 +1,374 @@ + + + OpenRGBDevicePageUi + + + + 0 + 0 + 500 + 300 + + + + Frame + + + + + 71 + 50 + 160 + 22 + + + + + + + 31 + 50 + 40 + 22 + + + + Zone: + + + + + + 31 + 90 + 40 + 22 + + + + LED: + + + + + + 71 + 90 + 160 + 22 + + + + + + + 31 + 210 + 40 + 22 + + + + Mode: + + + + + + 71 + 210 + 160 + 22 + + + + + + + 190 + 150 + 41 + 22 + + + + LED + + + + + + 130 + 150 + 41 + 22 + + + + Zone + + + + + + 310 + 120 + 50 + 22 + + + + 255 + + + + + + 310 + 160 + 50 + 22 + + + + 255 + + + + + + 310 + 200 + 50 + 22 + + + + 255 + + + + + + 290 + 120 + 20 + 22 + + + + R: + + + + + + 290 + 160 + 20 + 22 + + + + G: + + + + + + 290 + 200 + 20 + 22 + + + + B: + + + + + + 350 + 250 + 21 + 20 + + + + + + + + + + 410 + 250 + 21 + 20 + + + + + + + + + + 380 + 250 + 21 + 20 + + + + + + + + + + 440 + 250 + 21 + 20 + + + + + + + + + + 290 + 250 + 21 + 20 + + + + + + + + + + 320 + 250 + 21 + 20 + + + + + + + + + + 410 + 120 + 50 + 22 + + + + 359 + + + + + + 390 + 120 + 20 + 22 + + + + H: + + + + + + 390 + 160 + 20 + 22 + + + + S: + + + + + + 410 + 160 + 50 + 22 + + + + 255 + + + + + + 410 + 200 + 50 + 22 + + + + 255 + + + + + + 390 + 200 + 20 + 22 + + + + V: + + + + + + 70 + 150 + 41 + 22 + + + + Device + + + + + + 30 + 150 + 40 + 22 + + + + Set: + + + + + + diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp new file mode 100644 index 00000000..b21621aa --- /dev/null +++ b/qt/OpenRGBDialog2.cpp @@ -0,0 +1,78 @@ +#include "OpenRGBDialog2.h" +#include "OpenRGBDevicePage.h" +#include "OpenAuraSDK.h" +#include +#include + +using namespace Ui; + +OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vector& control, QWidget *parent) : QMainWindow(parent), busses(bus), controllers (control), ui(new OpenRGBDialog2Ui) +{ + ui->setupUi(this); + + QIcon logo(":OpenRGB.png"); + setWindowIcon(logo); + + /*-----------------------------------------------------*\ + | Set up list of devices | + \*-----------------------------------------------------*/ + QTabBar *DevicesTabBar = ui->DevicesTabBar->tabBar(); + + for(int dev_idx = 0; dev_idx < control.size(); dev_idx++) + { + OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(control[dev_idx]); + ui->DevicesTabBar->addTab(NewPage, ""); + + /*-----------------------------------------------------*\ + | Use Qt's HTML capabilities to display both icon and | + | text in the tab label. Choose icon based on device | + | type and append device name string. | + \*-----------------------------------------------------*/ + QString NewLabelString = "
" + QString::fromStdString(control[dev_idx]->name) + "
"; + + QLabel *NewTabLabel = new QLabel(); + NewTabLabel->setText(NewLabelString); + NewTabLabel->setIndent(20); + NewTabLabel->setGeometry(0, 0, 200, 20); + + DevicesTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel); + } + +} + +OpenRGBDialog2::~OpenRGBDialog2() +{ + delete ui; +} + +void OpenRGBDialog2::show() +{ + QMainWindow::show(); +} diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h new file mode 100644 index 00000000..8531efca --- /dev/null +++ b/qt/OpenRGBDialog2.h @@ -0,0 +1,39 @@ +#ifndef OPENRGBDIALOG2_H +#define OPENRGBDIALOG2_H + +#include "ui_OpenRGBDialog2.h" + +#include +#include "i2c_smbus.h" +#include "RGBController.h" + +#include +#include +#include +#include + +namespace Ui +{ + class OpenRGBDialog2; +} + +class Ui::OpenRGBDialog2 : public QMainWindow +{ + Q_OBJECT + +public: + explicit OpenRGBDialog2(std::vector& bus, std::vector& control, QWidget *parent = 0); + ~OpenRGBDialog2(); + + void show(); + void setMode(unsigned char mode_val); + +protected: + std::vector& busses; + std::vector& controllers; + +private: + Ui::OpenRGBDialog2Ui *ui; +}; + +#endif // OPENRGBDIALOG2_H diff --git a/qt/OpenRGBDialog2.ui b/qt/OpenRGBDialog2.ui new file mode 100644 index 00000000..3cdca33e --- /dev/null +++ b/qt/OpenRGBDialog2.ui @@ -0,0 +1,123 @@ + + + OpenRGBDialog2Ui + + + + 0 + 0 + 700 + 350 + + + + OpenRGB + + + + + + 0 + 0 + 700 + 351 + + + + QTabWidget::Rounded + + + 0 + + + + 20 + 20 + + + + + Devices + + + + + 0 + 0 + 700 + 320 + + + + QTabWidget::West + + + + + + Synchronized Effects + + + + + 0 + 0 + 700 + 321 + + + + QTabWidget::West + + + 0 + + + + Static + + + + + Tab 2 + + + + + + + Information + + + + + 0 + 0 + 700 + 321 + + + + QTabWidget::West + + + 0 + + + + System + + + + + Tab 2 + + + + + + + + + + diff --git a/qt/fan.svg b/qt/fan.svg new file mode 100644 index 00000000..afb97805 --- /dev/null +++ b/qt/fan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/qt/graphics-card.svg b/qt/graphics-card.svg new file mode 100644 index 00000000..f9b2f7db --- /dev/null +++ b/qt/graphics-card.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/qt/hsv.cpp b/qt/hsv.cpp new file mode 100644 index 00000000..bc9b6331 --- /dev/null +++ b/qt/hsv.cpp @@ -0,0 +1,157 @@ +/* +* RGB <--> HSV conversion in integer arithmetics, to be used on Windows. +* Copyright (c) 2013 Martin Mitas +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include "hsv.h" + + +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define MAX(a,b) ((a) > (b) ? (a) : (b)) + +#define MIN3(a,b,c) MIN((a), MIN((b), (c))) +#define MAX3(a,b,c) MAX((a), MAX((b), (c))) + +#define RGBGetRValue(rgb) (rgb & 0x000000FF) +#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF) +#define RGBGetBValue(rgb) ((rgb >> 16) & 0x000000FF) + +#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r)) + +void rgb2hsv(unsigned int rgb, hsv_t* hsv) +{ + int r = RGBGetRValue(rgb); + int g = RGBGetGValue(rgb); + int b = RGBGetBValue(rgb); + int m = MIN3(r, g, b); + int M = MAX3(r, g, b); + int delta = M - m; + + if (delta == 0) { + /* Achromatic case (i.e. grayscale) */ + hsv->hue = -1; /* undefined */ + hsv->saturation = 0; + } + else { + int h; + + if (r == M) + h = ((g - b) * 60 * HUE_DEGREE) / delta; + else if (g == M) + h = ((b - r) * 60 * HUE_DEGREE) / delta + 120 * HUE_DEGREE; + else /*if(b == M)*/ + h = ((r - g) * 60 * HUE_DEGREE) / delta + 240 * HUE_DEGREE; + + if (h < 0) + h += 360 * HUE_DEGREE; + + hsv->hue = h; + + /* The constatnt 8 is tuned to statistically cause as little + * tolerated mismatches as possible in RGB -> HSV -> RGB conversion. + * (See the unit test at the bottom of this file.) + */ + hsv->saturation = (256 * delta - 8) / M; + } + hsv->value = M; +} + +unsigned int hsv2rgb(hsv_t* hsv) +{ + unsigned char r, g, b; + + if (hsv->saturation == 0) { + r = g = b = hsv->value; + } + else { + int h = (hsv->hue)%360; + int s = hsv->saturation; + int v = hsv->value; + int i = h / (60 * HUE_DEGREE); + int p = (256 * v - s*v) / 256; + + if (i & 1) { + int q = (256 * 60 * HUE_DEGREE*v - h*s*v + 60 * HUE_DEGREE*s*v*i) / (256 * 60 * HUE_DEGREE); + switch (i) { + case 1: r = q; g = v; b = p; break; + case 3: r = p; g = q; b = v; break; + case 5: r = v; g = p; b = q; break; + } + } + else { + int t = (256 * 60 * HUE_DEGREE*v + h*s*v - 60 * HUE_DEGREE*s*v*(i + 1)) / (256 * 60 * HUE_DEGREE); + switch (i) { + case 0: r = v; g = t; b = p; break; + case 2: r = p; g = v; b = t; break; + case 4: r = t; g = p; b = v; break; + } + } + } + + return ToRGBColor(r, g, b); +} + + +#ifdef TEST + +#include + +#define DIFF(a,b) ((a) >= (b) ? (a) - (b) : (b) - (a)) + +int +main(int argc, char** argv) +{ + int r0, g0, b0; + hsv_t hsv; + int r1, g1, b1; + int ok = 0, fuzzy = 0, ko = 0, total; + + for (r0 = 0; r0 < 256; r0++) { + for (g0 = 0; g0 < 256; g0++) { + for (b0 = 0; b0 < 256; b0++) { + COLORREF tmp; + + rgb2hsv(RGB(r0, g0, b0), &hsv); + tmp = hsv2rgb(&hsv); + r1 = GetRValue(tmp); + g1 = GetGValue(tmp); + b1 = GetBValue(tmp); + + if (r0 == r1 && b0 == b1 && g0 == g1) + ok++; + else if (DIFF(r0, r1) <= 1 && DIFF(b0, b1) <= 1 && DIFF(g0, g1) <= 1) + fuzzy++; + else + ko++; + } + } + } + + total = ok + fuzzy + ko; + + printf("Test results:\n"); + printf(" * exact matches: %8d (%5.2f%%)\n", ok, (100.0 * ok) / total); + printf(" * fuzzy matches: %8d (%5.2f%%)\n", fuzzy, (100.0 * fuzzy) / total); + printf(" * mismatches: %8d (%5.2f%%)\n", ko, (100.0 * ko) / total); + + return (ko == 0 ? 0 : 1); +} +#endif /* TEST */ diff --git a/qt/hsv.h b/qt/hsv.h new file mode 100644 index 00000000..3b8a85bd --- /dev/null +++ b/qt/hsv.h @@ -0,0 +1,42 @@ +/* +* RGB <--> HSV conversion in integer arithmetics, to be used on Windows. +* Copyright (c) 2013 Martin Mitas +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef HSV_H +#define HSV_H + +#define HUE_DEGREE 1 + +typedef struct hsv_tag hsv_t; +struct hsv_tag { + unsigned int hue; /* 0 ... (360*HUE_DEGREE - 1) */ + unsigned char saturation; /* 0 ... 255 */ + unsigned char value; /* 0 ... 255 */ +}; + + +void rgb2hsv(unsigned int rgb, hsv_t* hsv); + +unsigned int hsv2rgb(hsv_t* hsv); + + +#endif /* HSV_H */ diff --git a/qt/keyboard.svg b/qt/keyboard.svg new file mode 100644 index 00000000..e8cfc7a1 --- /dev/null +++ b/qt/keyboard.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt/motherboard.svg b/qt/motherboard.svg new file mode 100644 index 00000000..f56b1f8d --- /dev/null +++ b/qt/motherboard.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt/mouse.svg b/qt/mouse.svg new file mode 100644 index 00000000..8bdb6065 --- /dev/null +++ b/qt/mouse.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/qt/ram.svg b/qt/ram.svg new file mode 100644 index 00000000..83df533a --- /dev/null +++ b/qt/ram.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/qt/resources.qrc b/qt/resources.qrc index dd5f26ef..4e7697c2 100644 --- a/qt/resources.qrc +++ b/qt/resources.qrc @@ -1,5 +1,11 @@ - - - OpenRGB.png - + + + OpenRGB.png + motherboard.svg + ram.svg + graphics-card.svg + fan.svg + keyboard.svg + mouse.svg +