Skip to content

Commit d263268

Browse files
committed
https://github.com/neu-rah/ArduinoMenu/issues/177
`changed` check cases review
1 parent d62836e commit d263268

File tree

2 files changed

+6
-101
lines changed

2 files changed

+6
-101
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.7.0
2+
version=4.7.1
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/items.cpp

Lines changed: 5 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -185,81 +185,11 @@ Used textField::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len
185185
bool menuNode::changed(const navNode &nav,const menuOut& out,bool sub,bool test) {
186186
trace(MENU_DEBUG_OUT<<*this<<" menuNode::changed"<<endl);
187187
return menuNode::_changes<false>(nav,out,sub,test);
188-
/*if (dirty) {
189-
trace(if (test) MENU_DEBUG_OUT<<"just dirty!"<<endl);
190-
return true;
191-
}
192-
bool appd=has((systemStyles)(_asPad|_parentDraw));
193-
if (appd) {
194-
trace(MENU_DEBUG_OUT<<"appd!"<<endl;);
195-
for(int i=0;i<sz();i++)
196-
if (operator[](i).changed(nav,out,false,test)) {
197-
// trace(if (test) MENU_DEBUG_OUT<<"APPD! "<<operator[](i).type()<<endl);
198-
return true;
199-
}
200-
} else {
201-
trace(MENU_DEBUG_OUT<<*this<<"!appd"<<endl;);
202-
if (!(nav.target==this&&sub)) {
203-
trace(if (test&&dirty) MENU_DEBUG_OUT<<"indirect!"<<endl);
204-
return dirty;// second hand check, just report self
205-
}
206-
idx_t level=nav.root->level;
207-
if (parentDraw()) {
208-
trace(MENU_DEBUG_OUT<<"return changed of parent-draw element"<<endl);
209-
trace(if (test) MENU_DEBUG_OUT<<"parentDraw()!"<<endl);
210-
return nav.root->path[level-1].target->changed(nav.root->path[level-1],out,sub,test);
211-
}
212-
// idx_t tit=hasTitle(nav.root->path[lev])?1:0;//TODO: this might not be correct.. checking
213-
idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0);
214-
// trace(MENU_DEBUG_OUT<<"level:"<<level<<" target:"<<*nav.root->navFocus<<" "<<nav.root->navFocus->has(_parentDraw)<<" "<<nav.root->navFocus->has(_asPad)<<endl);
215-
// idx_t lev=level-(nav.root->navFocus->has(_parentDraw)&&nav.root->navFocus->isMenu());
216-
idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)&&has(_asPad)];
217-
// trace(MENU_DEBUG_OUT<<"tit:"<<tit<<endl;);
218-
// idx_t t=out.tops[lev];
219-
trace(MENU_DEBUG_OUT<<"t:"<<t<<endl;);
220-
if (sub) for(int i=0;i<my;i++,t++) {
221-
if (t>=sz()) break;
222-
trace(MENU_DEBUG_OUT<<"checking:"<<operator[](t)<<endl);
223-
if (operator[](t).changed(nav,out,false,test)) {
224-
trace(if (test) MENU_DEBUG_OUT<<"sub changed!"<<endl);
225-
return true;
226-
}
227-
}
228-
}
229-
return false;*/
230188
}
231189

232190
void menuNode::clearChanged(const navNode &nav,const menuOut& out,bool sub) {
233191
trace(MENU_DEBUG_OUT<<" menuOut::clearChanged "<<nav);
234192
_changes<true>(nav,out,sub,false);
235-
/*dirty=false;
236-
if (has((systemStyles)(_asPad|_parentDraw))) {
237-
for(int i=0;i<sz();i++)
238-
operator[](i).clearChanged(nav,out,false);
239-
} else {
240-
if (!(nav.target==this&&sub)) return;
241-
idx_t level=nav.root->level;
242-
if (parentDraw())
243-
return nav.root->path[level-1].target->clearChanged(nav.root->path[level-1],out,sub);
244-
idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0);
245-
// idx_t lev=level-(nav.root->navFocus->has(_parentDraw)&&nav.root->navFocus->isMenu());
246-
// idx_t t=out.tops[lev];
247-
idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)&&has(_asPad)];
248-
for(idx_t i=0;i<my;i++,t++) {//only signal visible
249-
if (t>=sz()) break;//menu ended
250-
operator[](t).clearChanged(nav,out,false);
251-
}
252-
}
253-
#ifdef MENU_DEBUG
254-
if(changed(nav,out,sub,true)) {
255-
MENU_DEBUG_OUT<<"ERROR clear changed fail!"<<endl;
256-
MENU_DEBUG_OUT<<*this<<endl;
257-
MENU_DEBUG_OUT<<"level:"<<nav.root->level<<endl;
258-
// MENU_DEBUG_OUT<<"type:"<<type()<<endl;
259-
MENU_DEBUG_OUT.flush();
260-
while(1);
261-
}
262-
#endif*/
263193
}
264194

265195
////////////////////////////////////////////////////////////////////////////////
@@ -375,9 +305,6 @@ void fieldBase::doNav(navNode& nav,navCmd cmd) {
375305
break;
376306
default:break;
377307
}
378-
/*if (ch==options->getCmdChar(enterCmd)&&!tunning) {
379-
nav.event(enterEvent);
380-
}*/
381308
if (dirty)//sending enter or update event
382309
nav.event(nav.root->useUpdateEvent?updateEvent:enterEvent);
383310
}
@@ -481,60 +408,38 @@ template<bool clear>
481408
bool menuNode::_changes(const navNode &nav,const menuOut& out,bool sub,bool test) {
482409
if (clear) dirty=false;
483410
else if (dirty) {
484-
_trace(if (test) MENU_DEBUG_OUT<<"just dirty!"<<endl);
411+
trace(if (test) MENU_DEBUG_OUT<<"just dirty!"<<endl);
485412
return true;
486413
}
487414
if (has((systemStyles)(_asPad|_parentDraw))) {
488415
trace(MENU_DEBUG_OUT<<*this<<" sz:"<<sz()<<" asPad or parentDraw"<<endl);
489416
for(int i=0;i<sz();i++)
490417
if (clear) operator[](i).clearChanged(nav,out,false);
491418
else if (operator[](i).changed(nav,out,false,test)) {
492-
_trace(if (test) MENU_DEBUG_OUT<<"APPD! "<<operator[](i)<<endl);
419+
trace(if (test) MENU_DEBUG_OUT<<"APPD! "<<operator[](i)<<endl);
493420
return true;
494421
}
495422
return false;
496423
} else {
497-
// if (!(nav.target==this&&sub)) return;???
498424
if (!(clear||(nav.target==this&&sub))) {
499-
_trace(if (test&&dirty) MENU_DEBUG_OUT<<"indirect!"<<endl);
425+
trace(if (test&&dirty) MENU_DEBUG_OUT<<"indirect!"<<endl);
500426
return dirty;// second hand check, just report self
501427
}
502428
idx_t level=nav.root->level;
503429
if (parentDraw()) {
504430
if (clear) nav.root->path[level-1].target->clearChanged(nav.root->path[level-1],out,sub);
505431
else {
506-
_trace(MENU_DEBUG_OUT<<"return changed of parent-draw element"<<endl);
507-
_trace(if (test) MENU_DEBUG_OUT<<"parentDraw()!"<<endl);
432+
trace(MENU_DEBUG_OUT<<"return changed of parent-draw element"<<endl);
433+
trace(if (test) MENU_DEBUG_OUT<<"parentDraw()!"<<endl);
508434
return nav.root->path[level-1].target->changed(nav.root->path[level-1],out,sub,test);
509435
}
510436
}
511-
// idx_t tit=hasTitle(nav.root->path[lev])?1:0;//TODO: this might not be correct.. checking
512437
idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0);
513-
// trace(MENU_DEBUG_OUT<<"level:"<<level<<" target:"<<*nav.root->navFocus<<" "<<nav.root->navFocus->has(_parentDraw)<<" "<<nav.root->navFocus->has(_asPad)<<endl);
514-
// idx_t lev=level-(nav.root->navFocus->has(_parentDraw)&&(nav.root->navFocus->isMenu()||nav.root->navFocus->has(_asPad)));
515-
// idx_t t=out.tops[lev];
516-
// idx_t t=out.tops[level];//-nav.root->navFocus->has(_parentDraw)&&has(_asPad)];
517-
// idx_t t=out.tops[level-((nav.root->navFocus->has(_parentDraw)&&nav.root->navFocus->has(_menuData))||nav.root->navFocus->has(_asPad))];
518-
// idx_t t=out.tops[level-(nav.root->path[level].target->has(_asPad))];
519438
menuNode* target=nav.root->path[level].target;
520439
idx_t t=out.tops[level-(target->has(_asPad)||target->has(_parentDraw))];
521440
trace(MENU_DEBUG_OUT<<"t:"<<t<<endl;);
522441
if (sub) for(int i=0;i<my;i++,t++) {
523442
if (t>=sz()) break;
524-
_trace(if (debugFlag) {
525-
MENU_DEBUG_OUT<<*this
526-
<<" level:"<<nav.root->level
527-
<<" focus:"<<*nav.root->navFocus
528-
<<" root target:"<<*nav.root->path[nav.root->level].target
529-
<<" nav target:"<<*nav.target
530-
<<" top:"<<out.tops[nav.root->level]
531-
<<" asPad:"<<has(_asPad)
532-
<<" parentdraw:"<<has(_parentDraw)
533-
<<" menuData:"<<has(_menuData)
534-
<<" draw level:"<<nav.root->drawLevel()
535-
<<" cur panel:"<<out.panels.cur
536-
<<endl;
537-
});
538443
if (clear) operator[](t).clearChanged(nav,out,false);
539444
{
540445
trace(MENU_DEBUG_OUT<<"checking:"<<operator[](t)<<endl);

0 commit comments

Comments
 (0)