#include "menu.h" 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"<operator[](idx))==this) ) { trace(Serial<<*(prompt*)this<<" some parentDraw or asPad menu... idx:"<=sz()) n=sz()-1;//never trusting web! else if (n<0) n=0; return n; } bool menuNode::async(const char*uri,navRoot& root,idx_t lvl) { trace(Serial<<*(prompt*)this<<" menuNode::async "<lvl)) { root.escTo(lvl/*+(lvl&&root.path[lvl].sel==n?-1:0)*/); root.doNav(navCmd(idxCmd,n)); } return operator[](n).async(uri,root,lvl+1); } #endif void textField::doNav(navNode& nav,navCmd cmd) { trace(Serial<<"textField::doNav:"<exit(); } else { charEdit=!charEdit; dirty=true; edited=true; } break; case escCmd: dirty=true; if (charEdit) charEdit=false; else { edited=false; cursor=0; nav.root->exit(); } break; case upCmd: if (charEdit) { const char* v=validator(cursor); char *at=strchr(v,buffer()[cursor]); idx_t pos=at?at-v+1:1; if (pos>=(idx_t)strlen(v)) pos=0; buffer()[cursor]=v[pos]; dirty=true; } else { if(cursor<(idx_t)strlen(buffer())-1) cursor++; edited=false; } dirty=true; break; case downCmd: if (charEdit) { const char* v=validator(cursor); char *at=strchr(v,buffer()[cursor]);//at is not stored on the class to save memory idx_t pos=at?at-v-1:0; if (pos<0) pos=strlen(v)-1; buffer()[cursor]=v[pos]; dirty=true; } else { if (cursor) cursor--; edited=false; } dirty=true; break; default:break; } trace(Serial<<"cursor:"<level; if (parentDraw()) { trace(Serial<<"return changed of parent-draw element"<path[level-1].target->changed(nav.root->path[level-1],out,sub,test); } // idx_t tit=hasTitle(nav.root->path[lev])?1:0;//TODO: this might not be correct.. checking idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0); // trace(Serial<<"level:"<navFocus<<" "<navFocus->has(_parentDraw)<<" "<navFocus->has(_asPad)<navFocus->has(_parentDraw)&&nav.root->navFocus->isMenu()); idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)&&has(_asPad)]; // trace(Serial<<"tit:"<=sz()) break; trace(Serial<<"checking:"<level; if (parentDraw()) return nav.root->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 lev=level-(nav.root->navFocus->has(_parentDraw)&&nav.root->navFocus->isMenu()); // idx_t t=out.tops[lev]; idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)&&has(_asPad)]; for(idx_t i=0;i=sz()) break;//menu ended operator[](t).clearChanged(nav,out,false); } } #ifdef MENU_DEBUG if(changed(nav,out,sub,true)) { Serial<<"ERROR clear changed fail!"<level<exit(); return; case 0x08://backspace in.getCmd(); buffer()[cursor]=validator(cursor)[0]; if (cursor) cursor--; dirty=true; return; default: { const char* v=validator(cursor); char *at=strchr(v,c); if (at) { in.getCmd(); buffer()[cursor]=c; if (cursor<(idx_t)strlen(buffer())-1) cursor++; dirty=true; return; } // Serial<nav2D||!canTune()) {//then exit edition tunning=false; dirty=true; constrainField(); nav.event(nav.root->useUpdateEvent?updateEvent:enterEvent); nav.root->exit(); return; } else tunning=true; dirty=true; break; case upCmd: stepit(1); break; case downCmd: stepit(-1); break; default:break; } /*if (ch==options->getCmdChar(enterCmd)&&!tunning) { nav.event(enterEvent); }*/ if (dirty)//sending enter or update event nav.event(nav.root->useUpdateEvent?updateEvent:enterEvent); } Used fieldBase::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) { trace(Serial<<"fieldBase::printTo"<':':'):' '); l++; if (l0) l-=operator[](at).printRaw(out,l); #ifdef MENU_FMT_WRAPS } #endif #ifdef MENU_FMT_WRAPS out.fmtEnd(*this,type()==selectClass?menuOut::fmtSelect:menuOut::fmtChoose,root.node(),idx); #endif trace(Serial<<"menuVariantBase::printTo ended!"<0) { #ifdef MENU_FMT_WRAPS out.fmtStart(*this,menuOut::fmtToggle,root.node(),idx); #endif l+=operator[](at).printRaw(out,len-l); #ifdef MENU_FMT_WRAPS out.fmtEnd(*this,menuOut::fmtToggle,root.node(),idx); #endif } return l; } void menuVariantBase::doNav(navNode& nav,navCmd cmd) { trace(Serial<<"menuVariantBase::doNav"<exit(); } } // template // bool menuNode::_changes(const navNode &nav,const menuOut& out,bool sub,bool test) { // trace(Serial<<*this<<" menuNode::"<<(clear?"clearChanged":"changed")<<" test:"<level; // if (parentDraw()) { // if (clear) nav.root->path[level-1].target->clearChanged(nav.root->path[level-1],out,sub); // else { // trace(Serial<<"return changed of parent-draw element"<path[level-1].target->changed(nav.root->path[level-1],out,sub,test); // } // } // // idx_t tit=hasTitle(nav.root->path[lev])?1:0;//TODO: this might not be correct.. checking // idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0); // // trace(Serial<<"level:"<navFocus<<" "<navFocus->has(_parentDraw)<<" "<navFocus->has(_asPad)<navFocus->has(_parentDraw)&&(nav.root->navFocus->isMenu()||nav.root->navFocus->has(_asPad))); // // idx_t t=out.tops[lev]; // idx_t t=out.tops[level-nav.root->navFocus->has(_parentDraw)&&has(_asPad)]; // trace(Serial<<"t:"<=sz()) break; // if (clear) operator[](t).clearChanged(nav,out,false); // { // trace(Serial<<"checking:"<level<