Initial commit for Brightness in RGBController API
* Added DeviceHasBrightness() = false; to RGBController as overridable * Added Brightness to Mode struct * Added BrightnessSlider to the OpenRGBDevicePage ui and the supporting code to pass to the RGBController Commit amended for code style and to split API changes and controller changes out by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
f6c038857a
commit
6fd2ea9276
6 changed files with 234 additions and 155 deletions
|
|
@ -74,6 +74,8 @@ public:
|
|||
unsigned int flags; /* Mode flags bitfield */
|
||||
unsigned int speed_min; /* speed minimum value */
|
||||
unsigned int speed_max; /* speed maximum value */
|
||||
unsigned int brightness_min; /*brightness min value */
|
||||
unsigned int brightness_max; /*brightness max value */
|
||||
unsigned int colors_min; /* minimum number of mode colors*/
|
||||
unsigned int colors_max; /* maximum numver of mode colors*/
|
||||
|
||||
|
|
@ -81,6 +83,7 @@ public:
|
|||
| Mode Settings |
|
||||
\*--------------------------------------------------------------*/
|
||||
unsigned int speed; /* Mode speed parameter value */
|
||||
unsigned int brightness; /* Mode brightness value */
|
||||
unsigned int direction; /* Mode direction value */
|
||||
unsigned int color_mode; /* Mode color selection */
|
||||
std::vector<RGBColor>
|
||||
|
|
|
|||
|
|
@ -405,6 +405,14 @@ void Ui::OpenRGBDevicePage::on_RandomCheck_clicked()
|
|||
UpdateModeUi();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_BrightnessSlider_valueChanged(int /*value*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int /*value*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -443,6 +451,7 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
|||
bool supports_mode_specific = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR );
|
||||
bool supports_random = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_RANDOM_COLOR );
|
||||
bool supports_speed = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_SPEED );
|
||||
bool supports_brightness = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_BRIGHTNESS);
|
||||
bool supports_dir_lr = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
|
@ -484,6 +493,36 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
|||
ui->SpeedSlider->blockSignals(false);
|
||||
}
|
||||
|
||||
if(supports_brightness)
|
||||
{
|
||||
ui->BrightnessSlider->blockSignals(true);
|
||||
InvertedBrightness = device->modes[selected_mode].brightness_min > device->modes[selected_mode].brightness_max;
|
||||
|
||||
if(InvertedBrightness)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| If Brightness Slider is inverted, invert value |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->BrightnessSlider->setMinimum(device->modes[selected_mode].brightness_max);
|
||||
ui->BrightnessSlider->setMaximum(device->modes[selected_mode].brightness_min);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->BrightnessSlider->setMinimum(device->modes[selected_mode].brightness_min);
|
||||
ui->BrightnessSlider->setMaximum(device->modes[selected_mode].brightness_max);
|
||||
}
|
||||
|
||||
ui->BrightnessSlider->setValue(device->modes[selected_mode].brightness);
|
||||
ui->BrightnessSlider->setEnabled(true);
|
||||
ui->BrightnessSlider->blockSignals(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->BrightnessSlider->blockSignals(true);
|
||||
ui->BrightnessSlider->setEnabled(false);
|
||||
ui->BrightnessSlider->blockSignals(false);
|
||||
}
|
||||
|
||||
ui->DirectionBox->blockSignals(true);
|
||||
ui->DirectionBox->clear();
|
||||
|
||||
|
|
@ -694,15 +733,16 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
|||
|
||||
if(current_mode >= 0)
|
||||
{
|
||||
int current_speed = 0;
|
||||
bool current_per_led = ui->PerLEDCheck->isChecked();
|
||||
bool current_mode_specific = ui->ModeSpecificCheck->isChecked();
|
||||
bool current_random = ui->RandomCheck->isChecked();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
int current_speed = 0;
|
||||
int current_brightness = 0;
|
||||
bool current_per_led = ui->PerLEDCheck->isChecked();
|
||||
bool current_mode_specific = ui->ModeSpecificCheck->isChecked();
|
||||
bool current_random = ui->RandomCheck->isChecked();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the direction value |
|
||||
|
|
@ -761,6 +801,24 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
|||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Brightness Slider is enabled, read the value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(ui->BrightnessSlider->isEnabled())
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| If Brightness Slider is inverted, invert value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(InvertedBrightness)
|
||||
{
|
||||
current_brightness = device->modes[(unsigned int)current_mode].brightness_min - ui->BrightnessSlider->value() + device->modes[current_mode].brightness_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_brightness = ui->BrightnessSlider->value();
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Don't set the mode if the current mode is invalid |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -769,7 +827,8 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
|||
/*-----------------------------------------------------*\
|
||||
| Update mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
device->modes[(unsigned int)current_mode].speed = current_speed;
|
||||
device->modes[(unsigned int)current_mode].speed = current_speed;
|
||||
device->modes[(unsigned int)current_mode].brightness = current_brightness;
|
||||
|
||||
if(current_per_led)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ private slots:
|
|||
void on_DirectionBox_currentIndexChanged(int index);
|
||||
void on_ZoneBox_currentIndexChanged(int index);
|
||||
void on_LEDBox_currentIndexChanged(int index);
|
||||
void on_BrightnessSlider_valueChanged(int value);
|
||||
void on_ModeBox_currentIndexChanged(int index);
|
||||
void on_SpeedSlider_valueChanged(int value);
|
||||
void on_RedSpinBox_valueChanged(int arg1);
|
||||
|
|
@ -60,9 +61,10 @@ private:
|
|||
Ui::OpenRGBDevicePageUi *ui;
|
||||
RGBController *device;
|
||||
|
||||
bool UpdatingColor = false;
|
||||
bool InvertedSpeed = false;
|
||||
bool MultipleSelected = false;
|
||||
bool UpdatingColor = false;
|
||||
bool InvertedSpeed = false;
|
||||
bool InvertedBrightness = false;
|
||||
bool MultipleSelected = false;
|
||||
|
||||
void updateRGB();
|
||||
void updateHSV();
|
||||
|
|
|
|||
|
|
@ -14,10 +14,59 @@
|
|||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="1">
|
||||
<widget class="QRadioButton" name="PerLEDCheck">
|
||||
<item row="6" column="5">
|
||||
<widget class="QLabel" name="GreenLabel">
|
||||
<property name="text">
|
||||
<string>Per-LED</string>
|
||||
<string>G:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="8">
|
||||
<widget class="QLabel" name="HueLabel">
|
||||
<property name="text">
|
||||
<string>H:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="SpeedLabel">
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="4">
|
||||
<widget class="QSlider" name="SpeedSlider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="9" colspan="2">
|
||||
<widget class="QSpinBox" name="ValSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QRadioButton" name="RandomCheck">
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="5">
|
||||
<widget class="QLabel" name="BlueLabel">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="LEDLabel">
|
||||
<property name="text">
|
||||
<string>LED:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -28,22 +77,36 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="ZoneLabel">
|
||||
<property name="text">
|
||||
<string>Zone:</string>
|
||||
<item row="5" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="RedSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QPushButton" name="ApplyColorsButton">
|
||||
<item row="5" column="5">
|
||||
<widget class="QLabel" name="RedLabel">
|
||||
<property name="text">
|
||||
<string>Apply Colors To Selection</string>
|
||||
<string>R:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="5" colspan="6">
|
||||
<widget class="Swatches" name="SwatchBox" native="true"/>
|
||||
<item row="9" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="DirectionBox"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="DirectionLabel">
|
||||
<property name="text">
|
||||
<string>Dir:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="GreenSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="9" colspan="2">
|
||||
<widget class="QSpinBox" name="HueSpinBox">
|
||||
|
|
@ -52,6 +115,40 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="8">
|
||||
<widget class="QLabel" name="SatLabel">
|
||||
<property name="text">
|
||||
<string>S:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="BlueSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="LEDBox"/>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="ZoneBox"/>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="SelectAllLEDsButton">
|
||||
<property name="text">
|
||||
<string>Select All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QRadioButton" name="PerLEDCheck">
|
||||
<property name="text">
|
||||
<string>Per-LED</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="9" colspan="2">
|
||||
<widget class="QSpinBox" name="SatSpinBox">
|
||||
<property name="maximum">
|
||||
|
|
@ -59,16 +156,23 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="ZoneBox"/>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="ZoneLabel">
|
||||
<property name="text">
|
||||
<string>Zone:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5" rowspan="3" colspan="6">
|
||||
<widget class="ColorWheel" name="ColorWheelBox" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="4" column="5" colspan="6">
|
||||
<widget class="Swatches" name="SwatchBox" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="SetAllButton">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p align="justify">Sets all devices to<br/><b>Static</b> mode and<br/>applies the selected color.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply All Devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -88,65 +192,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="8">
|
||||
<widget class="QLabel" name="ValLabel">
|
||||
<property name="text">
|
||||
<string>V:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="SelectAllLEDsButton">
|
||||
<property name="text">
|
||||
<string>Select All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="5">
|
||||
<widget class="QLabel" name="GreenLabel">
|
||||
<property name="text">
|
||||
<string>G:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="8">
|
||||
<widget class="QLabel" name="HueLabel">
|
||||
<property name="text">
|
||||
<string>H:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="RedSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="ModeBox"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="SpeedLabel">
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="5">
|
||||
<widget class="QLabel" name="BlueLabel">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="8">
|
||||
<widget class="QLabel" name="SatLabel">
|
||||
<property name="text">
|
||||
<string>S:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="ColorLabel">
|
||||
<property name="text">
|
||||
|
|
@ -154,50 +199,30 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="5">
|
||||
<widget class="QLabel" name="RedLabel">
|
||||
<item row="9" column="8">
|
||||
<widget class="QLabel" name="ValLabel">
|
||||
<property name="text">
|
||||
<string>R:</string>
|
||||
<string>V:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="4">
|
||||
<widget class="QSlider" name="SpeedSlider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="1" column="5" rowspan="3" colspan="6">
|
||||
<widget class="ColorWheel" name="ColorWheelBox" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QRadioButton" name="RandomCheck">
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QPushButton" name="ApplyColorsButton">
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
<string>Apply Colors To Selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="BlueSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="SetAllButton">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p align="justify">Sets all devices to<br/><b>Static</b> mode and<br/>applies the selected color.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply All Devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="DirectionBox"/>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="LEDBox"/>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="ResizeButton">
|
||||
<property name="text">
|
||||
|
|
@ -205,34 +230,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="DirectionLabel">
|
||||
<property name="text">
|
||||
<string>Dir:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="6" colspan="2">
|
||||
<widget class="QSpinBox" name="GreenSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="LEDLabel">
|
||||
<property name="text">
|
||||
<string>LED:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="9" colspan="2">
|
||||
<widget class="QSpinBox" name="ValSpinBox">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="ModeLabel">
|
||||
<property name="text">
|
||||
|
|
@ -240,6 +237,23 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="ModeBox"/>
|
||||
</item>
|
||||
<item row="10" column="1" colspan="4">
|
||||
<widget class="QSlider" name="BrightnessSlider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="BrightnessLabel">
|
||||
<property name="text">
|
||||
<string>Brightness:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
AddSoftwareInfoPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the supported Devices page |
|
||||
| Add the Supported Devices page |
|
||||
\*-----------------------------------------------------*/
|
||||
AddSupportedDevicesPage();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <QTimer>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QSlider>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue