Initial commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file menuAction.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the MenuAction class
|
||||
* @version 0.1
|
||||
* @date 2022-01-12
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#ifndef MENU_ENTRY_H
|
||||
#define MENU_ENTRY_H
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
class MenuControl;
|
||||
|
||||
class MenuActionWrapper {
|
||||
public:
|
||||
virtual ~MenuActionWrapper() {}
|
||||
virtual void action() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class forms the transition between menus.
|
||||
*
|
||||
* In the Menu these are the entries.
|
||||
* This class can be call an submenu or a function.
|
||||
*/
|
||||
class MenuAction {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Construct a new Menu Action object
|
||||
*
|
||||
* @param name shown in the Menu
|
||||
* @param function to call when activate the entry
|
||||
* @param callback to call when leave the entry
|
||||
*/
|
||||
MenuAction(const char* name, void (*function) (), void (*callback) () = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Menu Action object
|
||||
*
|
||||
* @param name shown in the Menu
|
||||
* @param action to call when activate the entry
|
||||
*/
|
||||
MenuAction(const char* name, MenuActionWrapper* action);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Menu Action object
|
||||
*
|
||||
* This constructer is used for submenus.
|
||||
*
|
||||
* @param name shown in the Menu
|
||||
* @param menu to call when activate the entry
|
||||
*/
|
||||
MenuAction(const char* name, MenuControl* menu);
|
||||
|
||||
~MenuAction();
|
||||
|
||||
/**
|
||||
* @brief activates the entry
|
||||
*/
|
||||
void runAction();
|
||||
|
||||
/**
|
||||
* @brief Get the Name string
|
||||
*
|
||||
* @return const char*
|
||||
*/
|
||||
const char* getName();
|
||||
|
||||
/**
|
||||
* @brief Get the Is Menu object
|
||||
*
|
||||
* @return true runAction calls a submenu
|
||||
* @return false runAction call a function
|
||||
*/
|
||||
bool getIsMenu();
|
||||
|
||||
/**
|
||||
* @brief Get the Menu object
|
||||
*
|
||||
* Before call this function it may be useful
|
||||
* to check if is it a submenu with getIsMenu.
|
||||
*
|
||||
* @return MenuControl*
|
||||
*/
|
||||
MenuControl* getMenu();
|
||||
|
||||
private:
|
||||
const char* name;
|
||||
|
||||
void (*function) () = nullptr;
|
||||
void (*callback) () = nullptr;
|
||||
|
||||
bool isMenu = false;
|
||||
MenuControl* menu = nullptr;
|
||||
MenuActionWrapper* action = nullptr;
|
||||
};
|
||||
|
||||
#endif // MENU_ENTRY_H
|
||||
Reference in New Issue
Block a user