Repository navigation
Expand file tree
/
Copy pathbarField.h
More file actions
74 lines (57 loc) · 1.85 KB
/
Copy pathbarField.h
File metadata and controls
74 lines (57 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* -*- C++ -*- */
/********************
May 2017 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com
www.r-site.net
custom field edit (experimental)
this edit is an example of a navTarget element ,
nomally drawn as part of the parent (inplace edit)
being draw on its own screen (quite radical change)
the element still draws inline when not editing
the ideal of settings would be by output device
and as functions instead of data
...
eventually on this schema plugins will speciallize on device types
but hopefully simpler to write
use it as:
altFIELD(barField,...)
or
BARFIELD(...)
the remaining parameters are the same as the regular FIELD
***/
#ifndef RSITE_ARDUINO_MENU_BAR_FIELD
#define RSITE_ARDUINO_MENU_BAR_FIELD
#include "../menuDefs.h"
#include "cancelField.h"
using namespace Menu;
#define BARFIELD(...) altFIELD(barField,__VA_ARGS__)
class barFieldOptions {
public:
//these are made string to allow unicode,
//BUT you should only provide ONE character
//otherwise stuff will overflow!
static const char* fill;
static const char* empty;
};
template<typename T>
class barField:public cancelField<T>,public barFieldOptions {
public:
barField(constMEM menuFieldShadow<T>& shadow):cancelField<T>(shadow) {}
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr=0) override {
bool ed=this==root.navFocus;
if (ed) {
//out.clear();
out.clearLine(0);
out.setCursor(0,0);
if (out.maxX()>1) {
cancelField<T>::printTo(root,sel,out,idx,len);
out.clearLine(1);
out.setCursor(0,1);
}
int bar=map(menuField<T>::target(),menuField<T>::low(),menuField<T>::high(),0,out.maxX());
for (int n=0;n<bar;n++) out.print(fill);
for (int n=bar;n<out.maxX();n++) out.print(empty);
return 0;
} else return cancelField<T>::printTo(root,sel,out,idx,len);
}
};
#endif