Segment UI bugfix.

This commit is contained in:
Blaz Kristan 2024-03-09 12:37:35 +01:00
parent f2ad10bbce
commit da5c12f466

View File

@ -869,10 +869,11 @@ function populateSegments(s)
updateLen(i); updateLen(i);
updateTrail(gId(`seg${i}bri`)); updateTrail(gId(`seg${i}bri`));
gId(`segr${i}`).classList.add("hide"); gId(`segr${i}`).classList.add("hide");
//if (i<lSeg) gId(`segd${i}`).classList.add("hide"); // hide delete button for all but last
if (!gId(`seg${i}sel`).checked && gId('selall')) gId('selall').checked = false; // uncheck if at least one is unselected. if (!gId(`seg${i}sel`).checked && gId('selall')) gId('selall').checked = false; // uncheck if at least one is unselected.
} }
if (segCount < 2) { if (segCount < 2) {
gId(`segd${lSeg}`).classList.add("hide"); gId(`segd${lSeg}`).classList.add("hide"); // hide delete if only one segment
if (parseInt(gId("seg0bri").value)==255) gId(`segp0`).classList.add("hide"); if (parseInt(gId("seg0bri").value)==255) gId(`segp0`).classList.add("hide");
// hide segment controls if there is only one segment in simplified UI // hide segment controls if there is only one segment in simplified UI
if (simplifiedUI) gId("segcont").classList.add("hide"); if (simplifiedUI) gId("segcont").classList.add("hide");
@ -1440,7 +1441,7 @@ function readState(s,command=false)
if (s.seg[i].sel) { if (s.seg[i].sel) {
if (sellvl < 2) selc = i; // get first selected segment if (sellvl < 2) selc = i; // get first selected segment
sellvl = 2; sellvl = 2;
var lc = lastinfo.leds.seglc[s.seg[i].id]; var lc = lastinfo.leds.seglc[i];
hasRGB |= !!(lc & 0x01); hasRGB |= !!(lc & 0x01);
hasWhite |= !!(lc & 0x02); hasWhite |= !!(lc & 0x02);
hasCCT |= !!(lc & 0x04); hasCCT |= !!(lc & 0x04);
@ -1450,7 +1451,7 @@ function readState(s,command=false)
} }
var i=s.seg[selc]; var i=s.seg[selc];
if (sellvl == 1) { if (sellvl == 1) {
var lc = lastinfo.leds.seglc[i.id]; var lc = lastinfo.leds.seglc[selc];
hasRGB = !!(lc & 0x01); hasRGB = !!(lc & 0x01);
hasWhite = !!(lc & 0x02); hasWhite = !!(lc & 0x02);
hasCCT = !!(lc & 0x04); hasCCT = !!(lc & 0x04);
@ -1819,17 +1820,16 @@ function toggleNodes()
function makeSeg() function makeSeg()
{ {
var ns = 0, ct = 0; var ns = 0, ct = isM ? mw : ledCount;
var lu = lowestUnused; var lu = lowestUnused;
let li = lastinfo; let li = lastinfo;
if (lu > 0) { if (lu > 0) {
let xend = parseInt(gId(`seg${lu -1}e`).value,10) + (cfg.comp.seglen?parseInt(gId(`seg${lu -1}s`).value,10):0); let xend = parseInt(gId(`seg${lu -1}e`).value,10) + (cfg.comp.seglen?parseInt(gId(`seg${lu -1}s`).value,10):0);
if (isM) { if (isM) {
ns = 0; ns = 0;
ct = mw;
} else { } else {
if (xend < ledCount) ns = xend; if (xend < ledCount) ns = xend;
ct = ledCount-(cfg.comp.seglen?ns:0) ct -= cfg.comp.seglen?ns:0;
} }
} }
gId('segutil').scrollIntoView({ gId('segutil').scrollIntoView({