@ -30,7 +30,7 @@ class MenuItem; //forward declaration of the menu item
struct MenuChangeEvent
struct MenuChangeEvent
{
{
const MenuItem & from ;
//const MenuItem &from;
const MenuItem & to ;
const MenuItem & to ;
} ;
} ;
@ -264,11 +264,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onChangeFrom ( cb_change cb )
MenuItem & onChangeFrom ( cb_change cb )
{
{
cb_onChangeFrom = cb ;
cb_onChangeFrom = cb ;
return * this ;
return * this ;
}
} */
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired after any ' move ' function is called with this item
| | | Set a callback to be fired after any ' move ' function is called with this item
@ -278,12 +279,13 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onChangeTo ( cb_change cb )
MenuItem & onChangeTo ( cb_change cb )
{
{
cb_onChangeTo = cb ;
cb_onChangeTo = cb ;
return * this ;
return * this ;
}
}
*/
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired when ' moveUp ' is called with this item as the current MenuItem
| | | Set a callback to be fired when ' moveUp ' is called with this item as the current MenuItem
@ -292,11 +294,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onUp ( cb_move cb )
MenuItem & onUp ( cb_move cb )
{
{
cb_onUp = cb ;
cb_onUp = cb ;
return * this ;
return * this ;
}
} */
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired when ' moveDown ' is called with this item as the current MenuItem
| | | Set a callback to be fired when ' moveDown ' is called with this item as the current MenuItem
@ -305,11 +308,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onDown ( cb_move cb )
MenuItem & onDown ( cb_move cb )
{
{
cb_onDown = cb ;
cb_onDown = cb ;
return * this ;
return * this ;
}
} */
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired when ' moveLeft ' is called with this item as the current MenuItem
| | | Set a callback to be fired when ' moveLeft ' is called with this item as the current MenuItem
@ -318,11 +322,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onLeft ( cb_move cb )
MenuItem & onLeft ( cb_move cb )
{
{
cb_onLeft = cb ;
cb_onLeft = cb ;
return * this ;
return * this ;
}
} */
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired when ' moveRight ' is called with this item as the current MenuItem
| | | Set a callback to be fired when ' moveRight ' is called with this item as the current MenuItem
@ -331,11 +336,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onRight ( cb_move cb )
MenuItem & onRight ( cb_move cb )
{
{
cb_onRight = cb ;
cb_onRight = cb ;
return * this ;
return * this ;
}
} */
/*
/*
| | @ description
| | @ description
| | | Set a callback to be fired when ' use ' is called with this item as the current MenuItem
| | | Set a callback to be fired when ' use ' is called with this item as the current MenuItem
@ -344,11 +350,12 @@ class MenuItem
| | @ paramter cb The callback to be fired
| | @ paramter cb The callback to be fired
| | @ return this MenuItem
| | @ return this MenuItem
*/
*/
/*
MenuItem & onUse ( cb_use cb )
MenuItem & onUse ( cb_use cb )
{
{
cb_onUse = cb ;
cb_onUse = cb ;
return * this ;
return * this ;
}
} */
protected :
protected :
uint8_t shortkey ;
uint8_t shortkey ;
@ -358,13 +365,13 @@ class MenuItem
MenuItem * after ;
MenuItem * after ;
MenuItem * left ;
MenuItem * left ;
cb_change cb_onChangeFrom ;
//cb_change cb_onChangeFrom;
cb_change cb_onChangeTo ;
// cb_change cb_onChangeTo;
cb_move cb_onUp ;
// cb_move cb_onUp;
cb_move cb_onDown ;
// cb_move cb_onDown;
cb_move cb_onLeft ;
// cb_move cb_onLeft;
cb_move cb_onRight ;
// cb_move cb_onRight;
cb_use cb_onUse ;
// cb_use cb_onUse;
MenuBackend * menuBackend ;
MenuBackend * menuBackend ;
@ -396,7 +403,7 @@ class MenuItem
class MenuBackend
class MenuBackend
{
{
public :
public :
MenuBackend ( cb_use menuUse , cb_change menuChange = 0 ) : root ( F ( " MenuRoot ") )
MenuBackend ( cb_use menuUse , cb_change menuChange = 0 ) : root ( F ( " ") )
{
{
current = & root ;
current = & root ;
cb_menuChange = menuChange ;
cb_menuChange = menuChange ;
@ -432,12 +439,12 @@ class MenuBackend
| | #
| | #
*/
*/
void moveUp ( )
void moveUp ( )
{
{ /*
if ( current - > cb_onUp )
if ( current - > cb_onUp )
{
{
MenuMoveEvent mme = { * current } ;
MenuMoveEvent mme = { * current } ;
( * current - > cb_onUp ) ( mme ) ;
( * current - > cb_onUp ) ( mme ) ;
}
} */
setCurrent ( current - > moveUp ( ) ) ;
setCurrent ( current - > moveUp ( ) ) ;
}
}
/*
/*
@ -446,12 +453,12 @@ class MenuBackend
| | #
| | #
*/
*/
void moveDown ( )
void moveDown ( )
{
{ /*
if ( current - > cb_onDown )
if ( current - > cb_onDown )
{
{
MenuMoveEvent mme = { * current } ;
MenuMoveEvent mme = { * current } ;
( * current - > cb_onDown ) ( mme ) ;
( * current - > cb_onDown ) ( mme ) ;
}
} */
setCurrent ( current - > moveDown ( ) ) ;
setCurrent ( current - > moveDown ( ) ) ;
}
}
/*
/*
@ -461,11 +468,12 @@ class MenuBackend
*/
*/
void moveLeft ( )
void moveLeft ( )
{
{
/*
if ( current - > cb_onLeft )
if ( current - > cb_onLeft )
{
{
MenuMoveEvent mme = { * current } ;
MenuMoveEvent mme = { * current } ;
( * current - > cb_onLeft ) ( mme ) ;
( * current - > cb_onLeft ) ( mme ) ;
}
} */
setCurrent ( current - > moveLeft ( ) ) ;
setCurrent ( current - > moveLeft ( ) ) ;
}
}
/*
/*
@ -474,12 +482,12 @@ class MenuBackend
| | #
| | #
*/
*/
void moveRight ( )
void moveRight ( )
{
{ /*
if ( current - > cb_onRight )
if ( current - > cb_onRight )
{
{
MenuMoveEvent mme = { * current } ;
MenuMoveEvent mme = { * current } ;
( * current - > cb_onRight ) ( mme ) ;
( * current - > cb_onRight ) ( mme ) ;
}
} */
setCurrent ( current - > moveRight ( ) ) ;
setCurrent ( current - > moveRight ( ) ) ;
}
}
/*
/*
@ -514,11 +522,12 @@ class MenuBackend
void use ( )
void use ( )
{
{
//current->use();
//current->use();
/*
if ( current - > cb_onUse )
if ( current - > cb_onUse )
{
{
MenuUseEvent mue = { * current } ;
MenuUseEvent mue = { * current } ;
( * current - > cb_onUse ) ( mue ) ;
( * current - > cb_onUse ) ( mue ) ;
}
} */
if ( cb_menuUse )
if ( cb_menuUse )
{
{
MenuUseEvent mue = { * current } ;
MenuUseEvent mue = { * current } ;
@ -540,15 +549,17 @@ class MenuBackend
{
{
if ( next )
if ( next )
{
{
MenuChangeEvent mce = { * current , * next } ;
MenuChangeEvent mce = { * next } ;
/*
if ( current - > cb_onChangeFrom )
if ( current - > cb_onChangeFrom )
{
{
( * current - > cb_onChangeFrom ) ( mce ) ;
( * current - > cb_onChangeFrom ) ( mce ) ;
}
} */
/*
if ( next - > cb_onChangeTo )
if ( next - > cb_onChangeTo )
{
{
( * next - > cb_onChangeTo ) ( mce ) ;
( * next - > cb_onChangeTo ) ( mce ) ;
}
} */
if ( cb_menuChange )
if ( cb_menuChange )
{
{
( * cb_menuChange ) ( mce ) ;
( * cb_menuChange ) ( mce ) ;