diff --git a/RGBController/RGBController.cpp b/RGBController/RGBController.cpp index da8a805c..6357a8c8 100644 --- a/RGBController/RGBController.cpp +++ b/RGBController/RGBController.cpp @@ -1266,8 +1266,6 @@ void RGBController::SetLED(unsigned int led, RGBColor color) if(led < colors.size()) { colors[led] = color; - - UpdateSingleLED(led); } } @@ -1277,8 +1275,6 @@ void RGBController::SetAllLEDs(RGBColor color) { SetAllZoneLEDs(zone_idx, color); } - - UpdateLEDs(); } void RGBController::SetAllZoneLEDs(int zone, RGBColor color) @@ -1287,8 +1283,6 @@ void RGBController::SetAllZoneLEDs(int zone, RGBColor color) { zones[zone].colors[color_idx] = color; } - - UpdateZoneLEDs(zone); } int RGBController::GetMode() diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index 865727c2..0c8cb3fe 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -642,13 +642,72 @@ void Ui::OpenRGBDevicePage::UpdateDevice() UpdateMode(); } -void Ui::OpenRGBDevicePage::SetCustomMode() +void Ui::OpenRGBDevicePage::SetCustomMode(unsigned char red, unsigned char green, unsigned char blue) { + /*-----------------------------------------------------*\ + | Set the selected mode to the custom mode and update UI| + \*-----------------------------------------------------*/ device->SetCustomMode(); ui->ModeBox->blockSignals(true); ui->ModeBox->setCurrentIndex(device->active_mode); ui->ModeBox->blockSignals(false); UpdateModeUi(); + + /*-----------------------------------------------------*\ + | Set the color boxes | + \*-----------------------------------------------------*/ + UpdatingColor = true; + ui->RedSpinBox->setValue(red); + ui->GreenSpinBox->setValue(green); + ui->BlueSpinBox->setValue(blue); + UpdatingColor = false; + updateHSV(); + updateWheel(); + + /*-----------------------------------------------------*\ + | Read selected mode | + \*-----------------------------------------------------*/ + unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex(); + + switch(device->modes[selected_mode].color_mode) + { + case MODE_COLORS_PER_LED: + { + /*-----------------------------------------------------*\ + | 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); + } + break; + + case MODE_COLORS_MODE_SPECIFIC: + { + /*-----------------------------------------------------*\ + | Set all device LEDs to the current color | + \*-----------------------------------------------------*/ + RGBColor color = ToRGBColor( + ui->RedSpinBox->text().toInt(), + ui->GreenSpinBox->text().toInt(), + ui->BlueSpinBox->text().toInt() + ); + + for(std::size_t i = 0; i < device->modes[selected_mode].colors.size(); i++) + { + device->modes[selected_mode].colors[i] = color; + } + } + break; + } + + /*-----------------------------------------------------*\ + | Apply mode and colors | + \*-----------------------------------------------------*/ UpdateMode(); } @@ -673,6 +732,8 @@ void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked() ); device->SetAllLEDs(color); + + device->UpdateLEDs(); } break; @@ -729,6 +790,7 @@ void Ui::OpenRGBDevicePage::on_SetZoneButton_clicked() ); device->SetAllZoneLEDs(index, color); + device->UpdateZoneLEDs(index); } } break; @@ -761,12 +823,14 @@ void Ui::OpenRGBDevicePage::on_SetLEDButton_clicked() if(selected_zone == 0) { device->SetLED(index, color); + device->UpdateSingleLED(index); } else { selected_zone = selected_zone - 1; device->SetLED(device->zones[selected_zone].start_idx + index, color); + device->UpdateSingleLED(device->zones[selected_zone].start_idx + index); } } break; diff --git a/qt/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage.h index baca54e3..cfb571a0 100644 --- a/qt/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage.h @@ -19,7 +19,7 @@ public: ~OpenRGBDevicePage(); void SetDevice(unsigned char red, unsigned char green, unsigned char blue); - void SetCustomMode(); + void SetCustomMode(unsigned char red, unsigned char green, unsigned char blue); void UpdateDevice(); void UpdateMode(); void UpdateModeUi(); diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index cc149e14..ced45308 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -405,8 +405,7 @@ void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, un { for(int device = 0; device < ui->DevicesTabBar->count(); device++) { - qobject_cast(ui->DevicesTabBar->widget(device))->SetCustomMode(); - qobject_cast(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue); + qobject_cast(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue); } }