From 44ad5a31fbf2add5ec9d181507dea529cee09251 Mon Sep 17 00:00:00 2001 From: Rui Azevedo Date: Fri, 1 Dec 2017 23:15:06 -0100 Subject: [PATCH] fixed failing changed state report https://github.com/neu-rah/ArduinoMenu/issues/138 --- library.properties | 2 +- src/items.cpp | 13 +++++++++---- src/items.h | 6 ------ src/menu.cpp | 6 ++++++ src/menu.h | 19 ++++++++++++++++--- src/nav.cpp | 17 +++++++++++++---- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/library.properties b/library.properties index abbe4f19..96b05cfe 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoMenu library -version=4.0.11 +version=4.0.12 author=Rui Azevedo, ruihfazevedo@gmail.com maintainer=neu-rah, ruihfazevedo@gmail.com sentence=AVR generic menu/interactivity system diff --git a/src/items.cpp b/src/items.cpp index 0e6782d0..c79dea71 100644 --- a/src/items.cpp +++ b/src/items.cpp @@ -4,7 +4,7 @@ using namespace Menu; bool prompt::hasTitle(navNode& nav) const {return (nav.target->has(showTitle)||(nav.root->showTitle&&!nav.target->has(noTitle)));} idx_t prompt::printRaw(menuOut& out,idx_t len) const { - trace(Serial<<"prompt::printRaw"<level; if (parentDraw()) return nav.root->path[level-1].target->changed(nav.root->path[level-1],out,sub); idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0); - idx_t t=out.tops[level]; + trace(Serial<<"target:"<<*nav.root->navFocus<<" "<navFocus->has(_parentDraw)<navFocus->has(_parentDraw)]; + trace(Serial<<"t:"<=sz()) break; + trace(Serial<<"checking:"<path[level-1].target->clearChanged(nav.root->path[level-1],out,sub); idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0); - idx_t t=out.tops[level]; + idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)]; for(idx_t i=0;i=sz()) break;//menu ended operator[](t).clearChanged(nav,out,false); diff --git a/src/items.h b/src/items.h index 6500ffd3..ef2bbc41 100644 --- a/src/items.h +++ b/src/items.h @@ -439,11 +439,5 @@ return proceed; } } - - #ifdef DEBUG - inline String& operator<<(String&s,prompt &p) {return s+=p.getText();} - inline Stream& operator<<(Stream&o,prompt& p) {print_P(o,p.getText());return o;} - #endif - }//namespace Menu #endif diff --git a/src/menu.cpp b/src/menu.cpp index 46267e47..17e830af 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -18,3 +18,9 @@ result Menu::maxDepthError(menuOut& o,idleEvent e) { o.print(F("Error: maxDepth reached!\n\rincrease maxDepth on your scketch.")); return proceed; } + +#ifdef DEBUG + String& operator<<(String&s,prompt &p) {return s+=p.getText();} + Stream& operator<<(Stream&o,prompt& p) {print_P(o,p.getText());return o;} + Print& operator<<(Print&o,prompt& p) {print_P(o,p.getText());return o;} +#endif diff --git a/src/menu.h b/src/menu.h index 48b6ac18..2a0b84ba 100644 --- a/src/menu.h +++ b/src/menu.h @@ -14,14 +14,27 @@ warranty, express or implied, as to its usefulness for any purpose. #ifndef RSITE_ARDUINO_MENU_SYSTEM #define RSITE_ARDUINO_MENU_SYSTEM #include - #if defined(DEBUG) - #include - #endif + #include "menuBase.h" #include "shadows.h" using namespace Menu; + #ifdef DEBUG + String& operator<<(String&s,prompt &p); + Stream& operator<<(Stream&o,prompt& p); + Print& operator<<(Print&o,prompt& p); + #endif + + #if defined(DEBUG) + #ifndef ARDUINO_STREAMING + #include + #else + #include + #endif + #endif + + #if defined(DEBUG) && defined(TRACE) #define trace(x) x #else diff --git a/src/nav.cpp b/src/nav.cpp index 9a5e986c..2c84ba01 100644 --- a/src/nav.cpp +++ b/src/nav.cpp @@ -25,18 +25,22 @@ navCmd navNode::doNavigation(navCmd cmd) { idx_t nsel=sel; navCmd rCmd=cmd; bool changed=false; + // trace(if(cmd.cmd!=noCmd) Serial<<"navigate "<<*target<<" with command:"<isVariant()) root->out.doNav(cmd,*this);*/ case upCmd: - nsel++; - if (nsel>=sz()) {if(wrap()) nsel=0; else nsel=sz()-1;} - break; + // trace(Serial<<"up"<=sz()) {if(wrap()) nsel=0; else nsel=sz()-1;} + // trace(Serial<<"new sel:"<isVariant()) root->out.doNav(cmd,*this);*/ case downCmd: + // trace(Serial<<"down"<is(_asPad)) { nsel--; if (nsel<0) {if(wrap()) nsel=sz()-1; else nsel=0;} @@ -62,9 +66,14 @@ navCmd navNode::doNavigation(navCmd cmd) { case noCmd: default: break; } - if(osel!=nsel||changed) {//selection changed, must have been and idx/sel or an up/down movement + // trace(Serial<<"changed:"<sysStyles()&(_parentDraw|_isVariant)) { + trace(Serial<<"setting dirty"<dirty=true; + //this works but might be too much, we dont want to invaludate all the menu! + // if (_parentDraw/*&&root->level*/) root->path[root->level-1].target->dirty=true; } else { operator[](osel).dirty=true; operator[](nsel).dirty=true;