Skip to content

Commit e7449b4

Browse files
authored
Merge pull request wled#2959 from Aircoookie/selall-bugfix
maximum segments reached and Select all bugfix
2 parents b94e0ef + bfbc1eb commit e7449b4

File tree

4 files changed

+1652
-1648
lines changed

4 files changed

+1652
-1648
lines changed

wled00/FX_fcn.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
13241324
// disabled segments should get removed using purgeSegments()
13251325
DEBUG_PRINT(F("-- Segment ")); DEBUG_PRINT(n); DEBUG_PRINTLN(F(" marked inactive."));
13261326
seg.stop = 0;
1327+
seg.options = 0b0000000000000101; // on & selected
13271328
//if (seg.name) {
13281329
// delete[] seg.name;
13291330
// seg.name = nullptr;

wled00/data/index.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ button {
128128
display: inline-block;
129129
}
130130

131-
.icons.on {
132-
color: var(--c-g);
131+
.on {
132+
color: var(--c-g) !important;
133133
}
134134

135-
.icons.off {
136-
color: var(--c-6);
135+
.off {
136+
color: var(--c-6) !important;
137+
cursor: default !important;
137138
}
138139

139140
.top .icons, .bot .icons {
@@ -981,7 +982,7 @@ textarea {
981982

982983
.segname, .pname {
983984
white-space: nowrap;
984-
cursor: pointer;
985+
/*cursor: pointer;*/
985986
text-align: center;
986987
overflow: clip;
987988
text-overflow: ellipsis;

wled00/data/index.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//page js
22
var loc = false, locip;
3-
var noNewSegs = false;
43
var isOn = false, nlA = false, isLv = false, isInfo = false, isNodes = false, syncSend = false, syncTglRecv = true;
54
var hasWhite = false, hasRGB = false, hasCCT = false;
65
var nlDur = 60, nlTar = 0;
@@ -795,18 +794,14 @@ function populateSegments(s)
795794
}
796795

797796
gId('segcont').innerHTML = cn;
798-
if (lowestUnused >= maxSeg) {
799-
gId('segutil').innerHTML = '<span class="h">Maximum number of segments reached.</span>';
800-
noNewSegs = true;
801-
} else if (noNewSegs) {
802-
resetUtil();
803-
noNewSegs = false;
804-
}
797+
let noNewSegs = (lowestUnused >= maxSeg);
798+
resetUtil(noNewSegs);
799+
if (gId('selall')) gId('selall').checked = true;
805800
for (var i = 0; i <= lSeg; i++) {
806801
updateLen(i);
807802
updateTrail(gId(`seg${i}bri`));
808803
gId(`segr${i}`).style.display = "none";
809-
if (!gId(`seg${i}sel`).checked) gId(`selall`).checked = false;
804+
if (!gId(`seg${i}sel`).checked && gId('selall')) gId('selall').checked = false; // uncheck if at least one is unselected.
810805
}
811806
if (segCount < 2) gId(`segd${lSeg}`).style.display = "none";
812807
if (!isM && !noNewSegs && (cfg.comp.seglen?parseInt(gId(`seg${lSeg}s`).value):0)+parseInt(gId(`seg${lSeg}e`).value)<ledCount) gId(`segr${lSeg}`).style.display = "inline";
@@ -1694,15 +1689,15 @@ function makeSeg()
16941689
gId('segutil').innerHTML = cn;
16951690
}
16961691

1697-
function resetUtil()
1692+
function resetUtil(off=false)
16981693
{
1699-
// gId('segutil').innerHTML = '<button class="btn btn-s" onclick="makeSeg()"><i class="icons btn-icon">&#xe18a;</i>segment</button>';
1700-
gId('segutil').innerHTML = '<div class="seg btn btn-s" style="border-radius:24px;padding:0;">'
1694+
gId('segutil').innerHTML = `<div class="seg btn btn-s ${off?'off':''}" style="border-radius:24px;padding:0;">`
17011695
+ '<label class="check schkl"><input type="checkbox" id="selall" onchange="selSegAll(this)"><span class="checkmark"></span></label>'
1702-
+ '<div class="segname" onclick="makeSeg()"><i class="icons btn-icon">&#xe18a;</i>Add segment</div></div>';
1696+
+ `<div class="segname" ${off?'':'onclick="makeSeg()"'}><i class="icons btn-icon">&#xe18a;</i>Add segment</div></div>`;
17031697
}
17041698

1705-
function makePlSel(el, incPl=false) {
1699+
function makePlSel(el, incPl=false)
1700+
{
17061701
var plSelContent = "";
17071702
delete pJson["0"]; // remove filler preset
17081703
var arr = Object.entries(pJson);
@@ -1714,7 +1709,8 @@ function makePlSel(el, incPl=false) {
17141709
return plSelContent;
17151710
}
17161711

1717-
function refreshPlE(p) {
1712+
function refreshPlE(p)
1713+
{
17181714
var plEDiv = gId(`ple${p}`);
17191715
if (!plEDiv) return;
17201716
var content = "<div class=\"first c\">Playlist entries</div>";
@@ -1736,36 +1732,42 @@ function refreshPlE(p) {
17361732
}
17371733

17381734
// p: preset ID, i: ps index
1739-
function addPl(p,i) {
1735+
function addPl(p,i)
1736+
{
17401737
plJson[p].ps.splice(i+1,0,0);
17411738
plJson[p].dur.splice(i+1,0,plJson[p].dur[i]);
17421739
plJson[p].transition.splice(i+1,0,plJson[p].transition[i]);
17431740
refreshPlE(p);
17441741
}
17451742

1746-
function delPl(p,i) {
1743+
function delPl(p,i)
1744+
{
17471745
if (plJson[p].ps.length < 2) return;
17481746
plJson[p].ps.splice(i,1);
17491747
plJson[p].dur.splice(i,1);
17501748
plJson[p].transition.splice(i,1);
17511749
refreshPlE(p);
17521750
}
17531751

1754-
function plePs(p,i,field) {
1752+
function plePs(p,i,field)
1753+
{
17551754
plJson[p].ps[i] = parseInt(field.value);
17561755
}
17571756

1758-
function pleDur(p,i,field) {
1757+
function pleDur(p,i,field)
1758+
{
17591759
if (field.validity.valid)
17601760
plJson[p].dur[i] = Math.floor(field.value*10);
17611761
}
17621762

1763-
function pleTr(p,i,field) {
1763+
function pleTr(p,i,field)
1764+
{
17641765
if (field.validity.valid)
17651766
plJson[p].transition[i] = Math.floor(field.value*10);
17661767
}
17671768

1768-
function plR(p) {
1769+
function plR(p)
1770+
{
17691771
var pl = plJson[p];
17701772
pl.r = gId(`pl${p}rtgl`).checked;
17711773
if (gId(`pl${p}rptgl`).checked) { // infinite
@@ -1779,7 +1781,8 @@ function plR(p) {
17791781
}
17801782
}
17811783

1782-
function makeP(i,pl) {
1784+
function makeP(i,pl)
1785+
{
17831786
var content = "";
17841787
if (pl) {
17851788
if (i===0) plJson[0] = {
@@ -1963,7 +1966,7 @@ function selSegAll(o)
19631966

19641967
function selSegEx(s)
19651968
{
1966-
gId(`selall`).checked = false;
1969+
if (gId('selall')) gId('selall').checked = false;
19671970
var obj = {"seg":[]};
19681971
for (let i=0; i<=lSeg; i++) obj.seg.push({"id":i,"sel":(i==s)});
19691972
obj.mainseg = s;
@@ -1972,7 +1975,7 @@ function selSegEx(s)
19721975

19731976
function selSeg(s)
19741977
{
1975-
gId(`selall`).checked = false;
1978+
if (gId('selall')) gId('selall').checked = false;
19761979
var sel = gId(`seg${s}sel`).checked;
19771980
var obj = {"seg": {"id": s, "sel": sel}};
19781981
requestJson(obj);

0 commit comments

Comments
 (0)