Resizable Effects-Only Zones

This commit is contained in:
Adam Honse 2024-01-13 02:30:11 +00:00
parent e1a821f3c9
commit 032b6c6300
5 changed files with 117 additions and 31 deletions

View file

@ -147,23 +147,37 @@ void RGBController_MSIMysticLight185::SetupZones()
zone new_zone;
new_zone.name = zd->name;
new_zone.flags = 0;
int maxLeds = (int)controller->GetMaxDirectLeds(zd->zone_type);
/*-------------------------------------------------*\
| This is a fixed size zone |
| Either this is a board which only supports zone |
| control or this is not an ARGB header zone |
\*-------------------------------------------------*/
if((controller->GetSupportedDirectMode() == MSIMysticLight185Controller::DIRECT_MODE_ZONE_BASED)
|| ((zd->zone_type != MSI_ZONE_J_RAINBOW_1) && (zd->zone_type != MSI_ZONE_J_RAINBOW_2) && (zd->zone_type != MSI_ZONE_J_RAINBOW_3) && (zd->zone_type != MSI_ZONE_J_CORSAIR)))
if(((zd->zone_type != MSI_ZONE_J_RAINBOW_1)
&& (zd->zone_type != MSI_ZONE_J_RAINBOW_2)
&& (zd->zone_type != MSI_ZONE_J_RAINBOW_3)
&& (zd->zone_type != MSI_ZONE_J_CORSAIR)))
{
new_zone.leds_min = maxLeds;
new_zone.leds_max = maxLeds;
new_zone.leds_count = maxLeds;
}
/*--------------------------------------------------\
| This is a resizable zone on a per-LED board |
| This is a resizable zone on a board that does not |
| support per-LED direct mode |
\*-------------------------------------------------*/
else if(controller->GetSupportedDirectMode() == MSIMysticLight185Controller::DIRECT_MODE_ZONE_BASED)
{
new_zone.leds_min = 0;
new_zone.leds_max = 30;//maxLeds;
new_zone.leds_count = 0;
last_resizable_zone = zd->zone_type;
new_zone.flags |= ZONE_FLAG_RESIZE_EFFECTS_ONLY;
}
/*--------------------------------------------------\
| This is a resizable zone on a board that does |
| support per-LED direct mode |
\*-------------------------------------------------*/
else
{
@ -176,7 +190,7 @@ void RGBController_MSIMysticLight185::SetupZones()
/*-------------------------------------------------*\
| Determine zone type based on max number of LEDs |
\*-------------------------------------------------*/
if(new_zone.leds_max == 1)
if((new_zone.leds_max == 1) || (new_zone.flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY))
{
new_zone.type = ZONE_TYPE_SINGLE;
}
@ -199,16 +213,28 @@ void RGBController_MSIMysticLight185::SetupZones()
{
controller->SetCycleCount(zone_description[zone_idx]->zone_type, zones[zone_idx].leds_count);
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; ++led_idx)
if((zones[zone_idx].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY) == 0)
{
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; ++led_idx)
{
led new_led;
new_led.name = zones[zone_idx].name;
if(zones[zone_idx].leds_count > 1)
{
new_led.name.append(" LED " + std::to_string(led_idx + 1));
}
new_led.value = zone_description[zone_idx]->zone_type;
leds.push_back(new_led);
}
}
else if(zones[zone_idx].leds_count > 0)
{
led new_led;
new_led.name = zones[zone_idx].name + " LED ";
if(zones[zone_idx].leds_count > 1)
{
new_led.name.append(std::to_string(led_idx + 1));
}
new_led.name = zones[zone_idx].name;
new_led.value = zone_description[zone_idx]->zone_type;
leds.push_back(new_led);

View file

@ -37,6 +37,25 @@ mode::~mode()
colors.clear();
}
zone::zone()
{
name = "";
type = 0;
leds = NULL;
colors = NULL;
start_idx = 0;
leds_count = 0;
leds_min = 0;
leds_max = 0;
matrix_map = NULL;
flags = 0;
}
zone::~zone()
{
}
RGBController::RGBController()
{
DeviceThreadRunning = true;
@ -1515,6 +1534,7 @@ void RGBController::SetSingleLEDColorDescription(unsigned char* data_buf)
void RGBController::SetupColors()
{
unsigned int total_led_count;
unsigned int zone_led_count;
/*---------------------------------------------------------*\
| Determine total number of LEDs on the device |
@ -1523,7 +1543,7 @@ void RGBController::SetupColors()
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
total_led_count += zones[zone_idx].leds_count;
total_led_count += GetLEDsInZone(zone_idx);
}
/*---------------------------------------------------------*\
@ -1538,9 +1558,10 @@ void RGBController::SetupColors()
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
zones[zone_idx].start_idx=total_led_count;
zones[zone_idx].start_idx = total_led_count;
zone_led_count = GetLEDsInZone(zone_idx);
if((colors.size() > 0) && (zones[zone_idx].leds_count > 0))
if((colors.size() > 0) && (zone_led_count > 0))
{
zones[zone_idx].colors = &colors[total_led_count];
}
@ -1549,7 +1570,7 @@ void RGBController::SetupColors()
zones[zone_idx].colors = NULL;
}
if((leds.size() > 0) && (zones[zone_idx].leds_count > 0))
if((leds.size() > 0) && (zone_led_count > 0))
{
zones[zone_idx].leds = &leds[total_led_count];
}
@ -1559,10 +1580,25 @@ void RGBController::SetupColors()
}
total_led_count += zones[zone_idx].leds_count;
total_led_count += zone_led_count;
}
}
unsigned int RGBController::GetLEDsInZone(unsigned int zone)
{
unsigned int leds_count = zones[zone].leds_count;
if(zones[zone].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY)
{
if(leds_count > 1)
{
leds_count = 1;
}
}
return(leds_count);
}
RGBColor RGBController::GetLED(unsigned int led)
{
if(led < colors.size())
@ -1593,7 +1629,7 @@ void RGBController::SetAllLEDs(RGBColor color)
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
{
for (std::size_t color_idx = 0; color_idx < zones[zone].leds_count; color_idx++)
for (std::size_t color_idx = 0; color_idx < GetLEDsInZone(zone); color_idx++)
{
zones[zone].colors[color_idx] = color;
}

View file

@ -116,6 +116,15 @@ typedef struct
unsigned int value; /* Device-specific LED value */
} led;
/*------------------------------------------------------------------*\
| Zone Flags |
\*------------------------------------------------------------------*/
enum
{
ZONE_FLAG_RESIZE_EFFECTS_ONLY = (1 << 0), /* Zone is resizable, but only for */
/* effects - treat as single LED */
};
/*------------------------------------------------------------------*\
| Zone Types |
\*------------------------------------------------------------------*/
@ -150,10 +159,11 @@ typedef struct
} segment;
/*------------------------------------------------------------------*\
| Zone Struct |
| Zone Class |
\*------------------------------------------------------------------*/
typedef struct
class zone
{
public:
std::string name; /* Zone name */
zone_type type; /* Zone type */
led * leds; /* List of LEDs in zone */
@ -164,7 +174,14 @@ typedef struct
unsigned int leds_max; /* Maximum number of LEDs */
matrix_map_type * matrix_map; /* Matrix map pointer */
std::vector<segment> segments; /* Segments in zone */
} zone;
unsigned int flags; /* Zone flags bitfield */
/*--------------------------------------------------------------*\
| Zone Constructor / Destructor |
\*--------------------------------------------------------------*/
zone();
~zone();
};
/*------------------------------------------------------------------*\
| Device Types |
@ -210,6 +227,8 @@ class RGBControllerInterface
public:
virtual void SetupColors() = 0;
virtual unsigned int GetLEDsInZone(unsigned int zone) = 0;
virtual RGBColor GetLED(unsigned int led) = 0;
virtual void SetLED(unsigned int led, RGBColor color) = 0;
virtual void SetAllLEDs(RGBColor color) = 0;
@ -291,6 +310,8 @@ public:
\*---------------------------------------------------------*/
void SetupColors();
unsigned int GetLEDsInZone(unsigned int zone);
RGBColor GetLED(unsigned int led);
void SetLED(unsigned int led, RGBColor color);
void SetAllLEDs(RGBColor color);

View file

@ -305,7 +305,7 @@ void DeviceView::InitDeviceView()
}
else
{
unsigned int count = controller->zones[zone_idx].leds_count;
unsigned int count = controller->GetLEDsInZone(zone_idx);
zone_pos[zone_idx].matrix_w = std::min(count, (unsigned int)MAX_COLS);
totalHeight += (count / MAX_COLS) + ((count % MAX_COLS) > 0);
}
@ -473,7 +473,7 @@ void DeviceView::InitDeviceView()
/*-----------------------------------------------------*\
| Calculate LED box positions for single/linear zones |
\*-----------------------------------------------------*/
unsigned int leds_count = controller->zones[zone_idx].leds_count;
unsigned int leds_count = controller->GetLEDsInZone(zone_idx);
for(unsigned int led_idx = 0; led_idx < leds_count; led_idx++)
{
@ -1033,7 +1033,7 @@ bool DeviceView::selectZone(int zone, bool add)
int zoneStart = controller->zones[zone].start_idx;
for(int led_idx = 0; led_idx < (int)controller->zones[zone].leds_count; led_idx++)
for(int led_idx = 0; led_idx < controller->GetLEDsInZone(zone); led_idx++)
{
if(!selectionFlags[zoneStart + led_idx])
{

View file

@ -307,13 +307,15 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int index)
\*-----------------------------------------*/
else if(selected_zone != -1 && selected_segment == -1)
{
unsigned int leds_in_zone = device->GetLEDsInZone(selected_zone);
/*-------------------------------------*\
| If there are multiple LEDs, add the |
| "Entire Zone" option to the LED box |
| and enable it, otherwise there is |
| only one LED so disable it |
\*-------------------------------------*/
if(device->zones[selected_zone].leds_count > 1)
if(leds_in_zone > 1)
{
ui->LEDBox->addItem(tr("Entire Zone"));
ui->LEDBox->setEnabled(1);
@ -327,7 +329,7 @@ void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int index)
| Fill in the LED list with all LEDs in |
| the zone |
\*-------------------------------------*/
for(std::size_t led_idx = 0; led_idx < device->zones[selected_zone].leds_count; led_idx++)
for(std::size_t led_idx = 0; led_idx < leds_in_zone; led_idx++)
{
ui->LEDBox->addItem(device->zones[selected_zone].leds[led_idx].name.c_str());
}
@ -591,9 +593,9 @@ void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int index)
/*-------------------------------------*\
| Handle single selected LED |
\*-------------------------------------*/
if(device->zones[selected_zone].leds_count == 1 || selected_led != -1)
if(device->GetLEDsInZone(selected_zone) == 1 || selected_led != -1)
{
if((unsigned int)selected_led < device->zones[selected_zone].leds_count)
if((unsigned int)selected_led < device->GetLEDsInZone(selected_zone))
{
/*-----------------------------*\
| Get selected LED's current |
@ -1624,9 +1626,10 @@ void Ui::OpenRGBDevicePage::on_EditZoneButton_clicked()
}
/*-----------------------------------------*\
| Only allow resizing linear zones |
| Only allow resizing linear zones or |
| effects-only resizable zones |
\*-----------------------------------------*/
if(device->zones[selected_zone].type == ZONE_TYPE_LINEAR)
if((device->zones[selected_zone].type == ZONE_TYPE_LINEAR) || (device->zones[selected_zone].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY))
{
OpenRGBZoneResizeDialog dlg(device, selected_zone);