add on_exit to panelscreen
[clinton/Smoothieware.git] / src / modules / utils / panel / screens / ModifyValuesScreen.h
1 /*
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 #ifndef MODIFYVALUESSCREEN_H
9 #define MODIFYVALUESSCREEN_H
10
11 #include "PanelScreen.h"
12
13 #include <string>
14 #include <vector>
15 #include <tuple>
16 #include <functional>
17 #include <cmath>
18
19 class ModifyValuesScreen : public PanelScreen
20 {
21 public:
22 ModifyValuesScreen(bool delete_on_exit= false);
23 virtual ~ModifyValuesScreen();
24
25 void on_refresh();
26 void on_enter();
27 void on_exit();
28 void on_main_loop();
29 void display_menu_line(uint16_t line);
30 void clicked_menu_entry(uint16_t line);
31 int idle_timeout_secs(){ return 60; }
32
33 typedef std::tuple<char *, std::function<float()>, std::function<void(float)>, float, float, float> MenuItemType;
34 void addMenuItem(const char *name, std::function<float()> getter, std::function<void(float)> setter, float inc= 1.0F, float min= NAN, float max= NAN);
35
36
37 private:
38 void addMenuItem(const MenuItemType& item);
39
40 int execute_function;
41 float new_value, min_value, max_value;
42 int selected_item;
43 // name, getter function, setter function, increment
44 std::vector<MenuItemType> menu_items;
45
46 char control_mode;
47 bool delete_on_exit;
48
49 };
50
51 #endif