Skip to content

Commit 44ad5a3

Browse files
committed
fixed failing changed state report
#138
1 parent 3ea6d83 commit 44ad5a3

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
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.0.11
2+
version=4.0.12
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=AVR generic menu/interactivity system

src/items.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using namespace Menu;
44
bool prompt::hasTitle(navNode& nav) const {return (nav.target->has(showTitle)||(nav.root->showTitle&&!nav.target->has(noTitle)));}
55

66
idx_t prompt::printRaw(menuOut& out,idx_t len) const {
7-
trace(Serial<<"prompt::printRaw"<<endl);
7+
trace(Serial<<"prompt::printRaw"<<endl;print_P(Serial,getText(),len));
88
return print_P(out,getText(),len);
99
}
1010

@@ -155,26 +155,31 @@ bool menuNode::changed(const navNode &nav,const menuOut& out,bool sub) {
155155
bool appd=is((systemStyles)(_asPad|_parentDraw));
156156
if (dirty) return true;
157157
if (appd) {
158+
trace(Serial<<"appd!"<<endl;);
158159
for(int i=0;i<sz();i++)
159160
if (operator[](i).changed(nav,out,false))
160161
return true;
161162
} else {
163+
trace(Serial<<*this<<"!appd"<<endl;);
162164
if (!(nav.target==this&&sub)) return dirty;// second hand check, just report self
163165
idx_t level=nav.root->level;
164166
if (parentDraw())
165167
return nav.root->path[level-1].target->changed(nav.root->path[level-1],out,sub);
166168
idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0);
167-
idx_t t=out.tops[level];
169+
trace(Serial<<"target:"<<*nav.root->navFocus<<" "<<nav.root->navFocus->has(_parentDraw)<<endl);
170+
idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)];
171+
trace(Serial<<"t:"<<t<<endl;);
168172
if (sub) for(int i=0;i<my;i++,t++) {
169173
if (t>=sz()) break;
174+
trace(Serial<<"checking:"<<operator[](t)<<endl);
170175
if (operator[](t).changed(nav,out,false)) return true;
171176
}
172177
}
173178
return false;
174179
}
175180

176181
void menuNode::clearChanged(const navNode &nav,const menuOut& out,bool sub) {
177-
trace(Serial<<endl<<*this<<" menuOut::clearChanged "<<nav);
182+
trace(Serial<<" menuOut::clearChanged "<<nav);
178183
dirty=false;
179184
if (is((systemStyles)(_asPad|_parentDraw))) {
180185
for(int i=0;i<sz();i++)
@@ -185,7 +190,7 @@ void menuNode::clearChanged(const navNode &nav,const menuOut& out,bool sub) {
185190
if (parentDraw())
186191
return nav.root->path[level-1].target->clearChanged(nav.root->path[level-1],out,sub);
187192
idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0);
188-
idx_t t=out.tops[level];
193+
idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)];
189194
for(idx_t i=0;i<my;i++,t++) {//only signal visible
190195
if (t>=sz()) break;//menu ended
191196
operator[](t).clearChanged(nav,out,false);

src/items.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,5 @@
439439
return proceed;
440440
}
441441
}
442-
443-
#ifdef DEBUG
444-
inline String& operator<<(String&s,prompt &p) {return s+=p.getText();}
445-
inline Stream& operator<<(Stream&o,prompt& p) {print_P(o,p.getText());return o;}
446-
#endif
447-
448442
}//namespace Menu
449443
#endif

src/menu.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ result Menu::maxDepthError(menuOut& o,idleEvent e) {
1818
o.print(F("Error: maxDepth reached!\n\rincrease maxDepth on your scketch."));
1919
return proceed;
2020
}
21+
22+
#ifdef DEBUG
23+
String& operator<<(String&s,prompt &p) {return s+=p.getText();}
24+
Stream& operator<<(Stream&o,prompt& p) {print_P(o,p.getText());return o;}
25+
Print& operator<<(Print&o,prompt& p) {print_P(o,p.getText());return o;}
26+
#endif

src/menu.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,27 @@ warranty, express or implied, as to its usefulness for any purpose.
1414
#ifndef RSITE_ARDUINO_MENU_SYSTEM
1515
#define RSITE_ARDUINO_MENU_SYSTEM
1616
#include <Arduino.h>
17-
#if defined(DEBUG)
18-
#include <Streaming.h>
19-
#endif
17+
2018
#include "menuBase.h"
2119
#include "shadows.h"
2220

2321
using namespace Menu;
2422

23+
#ifdef DEBUG
24+
String& operator<<(String&s,prompt &p);
25+
Stream& operator<<(Stream&o,prompt& p);
26+
Print& operator<<(Print&o,prompt& p);
27+
#endif
28+
29+
#if defined(DEBUG)
30+
#ifndef ARDUINO_STREAMING
31+
#include <streamFlow.h>
32+
#else
33+
#include <Streaming.h>
34+
#endif
35+
#endif
36+
37+
2538
#if defined(DEBUG) && defined(TRACE)
2639
#define trace(x) x
2740
#else

src/nav.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ navCmd navNode::doNavigation(navCmd cmd) {
2525
idx_t nsel=sel;
2626
navCmd rCmd=cmd;
2727
bool changed=false;
28+
// trace(if(cmd.cmd!=noCmd) Serial<<"navigate "<<*target<<" with command:"<<cmd.cmd<<" index:"<<nsel<<endl);
2829
switch(cmd.cmd) {
2930
/*case scrlDownCmd:
3031
if (!target->isVariant())
3132
root->out.doNav(cmd,*this);*/
3233
case upCmd:
33-
nsel++;
34-
if (nsel>=sz()) {if(wrap()) nsel=0; else nsel=sz()-1;}
35-
break;
34+
// trace(Serial<<"up"<<endl;);
35+
nsel++;
36+
if (nsel>=sz()) {if(wrap()) nsel=0; else nsel=sz()-1;}
37+
// trace(Serial<<"new sel:"<<nsel<<endl);
38+
break;
3639
/*case scrlUpCmd:
3740
if (!target->isVariant())
3841
root->out.doNav(cmd,*this);*/
3942
case downCmd:
43+
// trace(Serial<<"down"<<endl);
4044
if (nsel||!target->is(_asPad)) {
4145
nsel--;
4246
if (nsel<0) {if(wrap()) nsel=sz()-1; else nsel=0;}
@@ -62,9 +66,14 @@ navCmd navNode::doNavigation(navCmd cmd) {
6266
case noCmd:
6367
default: break;
6468
}
65-
if(osel!=nsel||changed) {//selection changed, must have been and idx/sel or an up/down movement
69+
// trace(Serial<<"changed:"<<changed<<" sels?"<<(osel!=nsel)<<endl);
70+
if((osel!=nsel)||changed) {//selection changed, must have been and idx/sel or an up/down movement
71+
// trace(Serial<<"changed"<<endl);
6672
if (target->sysStyles()&(_parentDraw|_isVariant)) {
73+
trace(Serial<<"setting dirty"<<endl);
6774
target->dirty=true;
75+
//this works but might be too much, we dont want to invaludate all the menu!
76+
// if (_parentDraw/*&&root->level*/) root->path[root->level-1].target->dirty=true;
6877
} else {
6978
operator[](osel).dirty=true;
7079
operator[](nsel).dirty=true;

0 commit comments

Comments
 (0)