mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-01 03:37:49 -05:00
Add direction support
This commit is contained in:
@@ -35,6 +35,19 @@ enum
|
||||
MODE_FLAG_PER_LED_COLOR = (1 << 7), /* Mode uses device LED colors */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Directions |
|
||||
\*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
|
||||
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
|
||||
MODE_DIRECTION_UP = 2, /* Mode direction up */
|
||||
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
|
||||
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
|
||||
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Type |
|
||||
\*------------------------------------------------------------------*/
|
||||
@@ -53,6 +66,7 @@ typedef struct
|
||||
| Mode Settings |
|
||||
\*--------------------------------------------------------------*/
|
||||
unsigned int speed; /* Mode speed parameter value */
|
||||
unsigned int direction; /* Mode direction value */
|
||||
bool random; /* Random color mode enabled */
|
||||
} mode;
|
||||
|
||||
|
||||
@@ -153,7 +153,15 @@ void Ui::OpenRGBDevicePage::on_RandomCheck_clicked()
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int value)
|
||||
void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int /*value*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_DirectionBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
@@ -176,7 +184,11 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
||||
bool supports_random = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_COLOR )
|
||||
&& ( device->modes[selected_mode].flags & MODE_FLAG_RANDOM_COLOR );
|
||||
bool supports_speed = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_SPEED );
|
||||
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 );
|
||||
bool random = device->modes[selected_mode].random;
|
||||
unsigned int dir = device->modes[selected_mode].direction;
|
||||
|
||||
if(supports_speed)
|
||||
{
|
||||
@@ -200,6 +212,74 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
||||
{
|
||||
ui->SpeedSlider->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->DirectionBox->clear();
|
||||
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
ui->DirectionBox->addItem("Left");
|
||||
ui->DirectionBox->addItem("Right");
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->addItem("Up");
|
||||
ui->DirectionBox->addItem("Down");
|
||||
}
|
||||
|
||||
if(supports_dir_hv)
|
||||
{
|
||||
ui->DirectionBox->addItem("Horizontal");
|
||||
ui->DirectionBox->addItem("Vertical");
|
||||
}
|
||||
|
||||
if(supports_dir_lr || supports_dir_ud || supports_dir_hv)
|
||||
{
|
||||
if((supports_dir_lr)
|
||||
&&((dir == MODE_DIRECTION_LEFT)
|
||||
||(dir == MODE_DIRECTION_RIGHT)))
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
|
||||
if((supports_dir_ud)
|
||||
&&((dir == MODE_DIRECTION_UP)
|
||||
||(dir == MODE_DIRECTION_DOWN)))
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 2);
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_hv)
|
||||
&&((dir == MODE_DIRECTION_HORIZONTAL)
|
||||
||(dir == MODE_DIRECTION_VERTICAL)))
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 4);
|
||||
}
|
||||
}
|
||||
|
||||
ui->DirectionBox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setEnabled(false);
|
||||
}
|
||||
|
||||
if(supports_random)
|
||||
{
|
||||
@@ -218,9 +298,53 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
||||
/*-----------------------------------------------------*\
|
||||
| Read user interface |
|
||||
\*-----------------------------------------------------*/
|
||||
int current_mode = ui->ModeBox->currentIndex();
|
||||
int current_speed = ui->SpeedSlider->value();
|
||||
bool current_random = ui->RandomCheck->checkState();
|
||||
int current_mode = ui->ModeBox->currentIndex();
|
||||
int current_speed = ui->SpeedSlider->value();
|
||||
bool current_random = ui->RandomCheck->checkState();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the direction value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(supports_dir_hv)
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 4;
|
||||
}
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_lr)
|
||||
&&(current_dir_idx < 2))
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
|
||||
device->modes[current_mode].direction = current_direction;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Speed Slider is inverted, invert value |
|
||||
|
||||
@@ -48,6 +48,8 @@ private slots:
|
||||
|
||||
void on_SpeedSlider_valueChanged(int value);
|
||||
|
||||
void on_DirectionBox_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::OpenRGBDevicePageUi *ui;
|
||||
RGBController *device;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>50</y>
|
||||
<y>30</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -27,7 +27,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>50</y>
|
||||
<y>30</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -40,7 +40,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>90</y>
|
||||
<y>70</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -53,7 +53,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>90</y>
|
||||
<y>70</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -63,7 +63,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>210</y>
|
||||
<y>190</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -76,7 +76,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>210</y>
|
||||
<y>190</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -86,7 +86,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -99,7 +99,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -346,7 +346,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -359,7 +359,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -372,7 +372,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>170</y>
|
||||
<y>150</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -385,7 +385,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>240</y>
|
||||
<y>220</y>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@@ -398,7 +398,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>270</y>
|
||||
<y>240</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -411,7 +411,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>270</y>
|
||||
<y>240</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -420,6 +420,29 @@
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="DirectionBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>270</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="DirectionLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>270</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dir:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user