floatpump-firmware/Middlewares/floatpump/Inc/Menu_Entry.h

53 lines
1.2 KiB
C
Raw Normal View History

2023-01-04 12:22:45 +00:00
//
// Created by robtor on 04.01.23.
//
#ifndef FLOATPUMP_MENU_ENTRY_H
#define FLOATPUMP_MENU_ENTRY_H
#include <Menu_Entry_Type_Delegate.h>
2023-01-05 09:54:19 +00:00
#include <Config_Entry_Delegate.h>
2023-01-04 12:22:45 +00:00
namespace floatpump {
namespace menu {
class Menu_Entry {
public:
2023-01-05 09:54:19 +00:00
menu::Menu_Entry_Type_Delegate *m_type;
config::Config_Entry_Delegate *m_config;
2023-01-04 12:22:45 +00:00
Menu_Entry(Menu_Entry_Type_Delegate *type, std::string name) : m_type(type), m_name(name) {};
std::string printLine() {
2023-01-04 13:54:51 +00:00
int spaces = 19 - (m_name.length() + m_type->toString().length());
std::string spacer;
spacer.append(spaces, ' ');
return m_name + spacer + m_type->toString();
2023-01-04 12:22:45 +00:00
}
void action_press() {
m_type->u_press();
}
void action_increase() {
m_type->u_increase(1);
}
void action_decrease() {
m_type->u_decrease(1);
}
2023-01-04 13:54:51 +00:00
bool isEntered() {
return m_type->isEntered();
}
2023-01-04 12:22:45 +00:00
private:
std::string m_name;
};
} // floatpump
} // menu
#endif //FLOATPUMP_MENU_ENTRY_H