153 lines
26 KiB
C++
153 lines
26 KiB
C++
#ifndef UI_H
|
|
#define UI_H
|
|
|
|
#include <cstdint>
|
|
#include "../Draw.h"
|
|
#include "../../../Debug.h"
|
|
|
|
|
|
class Setter;
|
|
extern Setter setter;
|
|
|
|
#define UI_FONT 8
|
|
|
|
#if UI_FONT == 1
|
|
static const uint8_t f1_data[] = {84,18,71,192,137,130,0,0,32,135,28,7,250,156,207,113,0,0,112,124,156,199,121,190,207,137,130,162,32,40,114,30,231,113,190,40,10,138,162,239,226,8,16,64,0,64,0,7,4,65,65,0,0,0,0,0,0,0,0,0,0,0,172,1,84,146,170,32,74,164,2,0,160,200,162,8,11,34,40,138,0,0,136,130,162,40,138,130,32,138,130,162,32,40,138,162,40,138,136,40,10,138,34,40,130,20,32,64,0,64,128,0,4,0,65,0,0,0,0,0,32,0,0,0,0,0,34,74,84,191,162,36,40,200,33,0,160,168,32,136,10,2,40,138,10,129,128,178,162,40,136,130,32,136,130,146,96,44,138,162,40,10,136,40,74,138,34,40,130,34,0,206,227,120,142,224,61,65,81,55,143,243,120,153,243,68,81,80,20,125,34,74,4,146,66,34,32,168,34,0,144,140,16,72,122,2,36,138,128,60,65,170,162,40,136,130,32,136,130,138,160,106,138,162,40,10,136,40,74,82,20,36,132,0,0,81,20,69,209,19,69,65,73,73,81,20,69,69,36,68,81,80,20,65,34,74,4,18,7,193,33,136,248,240,144,138,8,38,130,30,194,241,64,0,34,170,162,39,136,142,35,251,130,134,32,169,138,158,232,113,136,40,74,34,8,34,132,0,0,80,20,68,145,16,69,65,69,73,81,20,69,67,32,68,81,146,18,33,33,76,4,18,138,36,34,8,32,0,144,137,4,232,131,34,33,130,128,60,33,170,190,40,136,130,32,138,130,138,32,40,139,130,168,128,136,40,74,82,8,33,132,0,0,94,20,68,159,16,69,65,67,73,81,20,69,129,35,68,81,18,17,17,34,74,4,63,74,42,34,8,32,0,136,136,2,8,130,162,32,130,0,129,32,114,162,40,136,130,32,138,130,146,32,40,138,130,42,129,136,40,74,138,136,32,136,0,0,81,20,68,129,16,69,65,69,73,81,20,69,1,36,68,81,146,18,9,34,74,0,146,10,42,66,4,0,0,136,136,130,8,138,162,32,138,0,0,0,2,162,40,138,130,32,138,138,162,32,40,138,130,36,138,136,72,73,138,136,32,136,0,0,81,20,69,145,224,69,65,73,65,81,20,69,65,36,68,74,82,228,5,34,74,4,18,7,196,131,2,0,2,10,135,62,7,114,156,192,113,10,0,32,124,162,199,121,190,192,139,114,162,47,40,114,2,43,114,8,135,176,137,136,239,232,0,0,222,227,120,142,0,69,65,81,65,145,243,120,129,195,57,132,77,4,125,172,73,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,14,20,28,34,36,40,44,50,56,59,64,66,70,76,80,86,92,98,104,110,116,122,128,130,133,137,142,146,152,160,166,172,178,184,190,196,202,208,210,216,222,228,236,242,248,254,260,266,272,278,284,290,298,304,310,316,320,324,328,334,340,343,349,355,361,367,373,379,385,391,393,399,405,407,415,421,427,433,439,445,451,457,463,469,477,483,489,495,500,502,507,};
|
|
static const FontWrap fnt_f1(512,9,f1_data,f1_offsets);
|
|
#elif UI_FONT == 2
|
|
static const uint8_t f1_data[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,128,0,128,20,0,0,0,0,0,0,0,0,0,0,0,0,0,240,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,53,0,2,229,155,6,162,138,0,128,156,227,251,162,239,251,190,15,8,226,11,250,158,239,249,190,47,250,184,40,136,162,239,249,158,239,139,162,40,138,190,4,34,0,124,207,247,124,223,23,125,92,20,124,223,247,125,223,247,69,81,21,69,159,36,0,130,175,88,18,34,135,0,64,34,2,130,162,32,128,162,168,228,4,234,138,162,32,10,130,32,34,160,36,216,166,40,138,162,128,136,162,72,137,144,8,82,0,64,81,16,69,65,16,17,80,18,84,81,20,69,65,64,68,81,165,68,136,36,0,2,229,35,62,162,239,227,32,34,226,227,190,239,131,190,15,2,136,171,250,190,32,58,142,238,35,160,35,168,170,232,171,190,143,136,162,138,248,136,16,138,0,124,95,16,125,71,247,17,208,17,84,81,244,85,193,71,68,81,69,124,196,100,0,128,143,210,18,34,135,0,16,34,34,128,32,40,130,34,8,228,4,232,139,162,32,10,130,40,34,160,36,136,178,40,72,18,136,136,148,77,33,132,32,2,0,68,81,16,5,65,20,17,80,18,84,81,20,36,1,68,68,74,165,64,130,36,0,2,229,203,62,162,138,8,10,156,239,251,160,231,131,190,175,8,130,8,136,158,239,249,130,47,250,158,232,139,162,47,184,162,143,248,136,40,34,190,64,2,0,124,207,247,124,193,23,125,79,244,85,209,23,92,193,71,124,196,23,125,159,36,0,0,128,0,0,20,0,8,0,0,0,0,0,0,0,0,128,0,0,240,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,3,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,49,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,13,19,25,31,33,36,39,45,51,53,57,59,65,71,77,83,89,95,101,107,113,119,125,127,129,133,137,141,147,155,161,167,173,179,185,191,197,203,209,215,221,227,233,239,245,251,257,263,269,275,281,287,293,299,305,311,314,320,323,329,335,338,344,350,356,362,368,374,380,386,392,398,404,410,416,422,428,434,440,446,452,458,464,470,476,482,488,494,498,500,};
|
|
static const FontWrap fnt_f1(512,9,f1_data,f1_offsets);
|
|
#elif UI_FONT == 3
|
|
static const uint8_t f1_data[] = {40,0,4,0,0,130,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,10,158,16,132,130,42,0,0,64,140,56,142,228,49,15,195,0,16,32,48,0,140,195,57,239,113,210,129,36,33,52,113,56,140,195,249,164,72,80,36,242,137,0,2,4,4,0,1,12,16,36,4,1,0,0,0,0,16,0,0,0,0,48,26,0,2,10,69,9,138,130,8,0,0,32,210,64,144,36,8,136,36,1,8,64,72,0,146,36,72,33,8,146,128,36,97,54,137,72,146,36,32,164,72,144,34,2,9,1,2,12,4,0,1,2,16,0,36,1,0,0,0,0,16,0,0,0,0,16,18,0,130,63,133,4,132,130,0,2,0,16,146,64,144,36,8,136,36,1,196,135,64,60,146,36,72,33,8,146,128,20,161,85,137,72,146,36,32,164,72,146,66,129,8,2,2,192,28,199,25,135,113,36,20,253,112,204,193,53,183,148,130,34,233,17,18,0,2,10,14,194,10,130,0,2,30,8,146,48,12,231,56,4,195,73,2,0,33,66,158,35,72,231,105,158,128,12,33,84,137,56,146,195,32,36,133,10,65,65,8,4,2,0,165,32,37,66,146,36,12,37,145,82,34,141,144,148,146,20,9,9,34,0,130,63,20,9,17,130,128,15,0,4,146,8,16,4,73,132,4,1,196,135,16,89,146,36,72,33,72,146,144,20,33,84,137,8,146,4,33,36,133,138,130,32,8,8,2,192,165,32,29,66,146,36,20,37,145,82,34,5,147,148,146,8,201,16,18,0,2,10,148,20,17,130,0,66,0,2,146,8,16,4,73,132,4,65,8,64,0,85,146,36,72,33,72,146,144,36,33,148,137,8,146,4,33,36,133,138,130,16,8,16,2,32,165,32,5,66,146,36,36,37,145,82,34,5,148,164,146,20,41,16,18,0,2,10,79,136,14,130,0,66,64,1,140,120,14,228,48,4,195,72,16,32,16,57,146,195,57,47,48,210,97,36,47,148,113,8,140,228,32,24,130,77,132,240,9,32,226,193,29,199,25,130,147,36,36,37,145,204,193,133,35,71,108,34,238,49,26,0,0,0,4,0,0,130,0,32,0,0,0,0,0,0,0,0,0,32,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,2,0,0,0,0,0,2,32,0,0,0,64,0,1,0,0,0,0,8,0,0,0,2,0,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,2,0,0,0,0,128,1,16,0,0,0,64,0,1,0,0,0,0,6,0,0,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,15,22,30,38,41,45,49,55,61,65,70,72,80,86,90,96,102,108,114,120,126,132,138,141,144,150,156,162,168,176,182,188,194,200,205,210,216,222,227,233,239,245,252,259,266,272,278,284,290,297,303,310,318,325,332,339,343,351,355,356,362,365,370,375,380,386,391,397,403,409,412,417,423,426,435,441,446,452,458,463,468,471,476,481,489,495,501,507,512,515,};
|
|
static const FontWrap fnt_f1(528,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 4
|
|
static const uint8_t f1_data[] = {42,202,49,130,17,133,0,0,228,144,227,32,158,243,57,14,0,0,224,224,3,225,195,121,124,31,71,40,20,10,130,66,28,15,199,199,243,133,130,33,36,20,228,91,140,0,4,8,0,8,32,32,40,33,0,0,0,0,0,2,0,0,0,0,128,10,42,170,74,65,146,200,1,0,20,89,20,49,66,132,68,17,0,0,16,25,132,34,38,138,4,129,72,40,20,9,198,70,34,145,72,40,68,132,130,81,68,34,2,73,72,1,8,8,0,8,16,32,0,33,0,0,0,0,0,2,0,0,0,0,64,18,170,175,72,65,82,144,16,0,18,21,4,41,65,128,68,81,65,64,0,201,138,34,22,8,5,65,80,40,148,8,198,74,65,81,80,40,64,132,68,82,66,34,130,136,72,1,192,105,28,203,57,171,41,169,158,199,105,172,114,39,138,34,138,162,79,18,2,197,177,128,65,80,17,0,18,17,228,40,207,67,56,17,56,159,131,164,139,226,23,8,125,79,192,47,212,8,170,74,65,81,208,199,64,132,68,82,130,65,129,136,40,2,32,154,162,44,146,108,42,165,165,40,154,178,137,34,138,82,82,34,68,18,2,133,130,70,65,16,124,0,18,17,2,37,80,68,68,30,4,0,68,148,201,38,22,8,5,65,92,40,180,8,170,82,65,79,80,2,67,132,40,138,130,129,64,136,8,0,192,139,130,232,147,40,42,163,164,40,138,162,48,34,82,84,33,20,34,34,130,143,66,41,70,16,16,28,18,17,1,125,80,36,68,16,56,159,67,148,201,39,22,8,5,65,80,168,20,9,170,82,65,65,86,4,68,132,40,138,66,130,64,136,8,0,32,138,130,40,144,40,42,165,164,40,138,162,64,34,82,84,33,20,66,18,128,162,66,41,66,16,16,0,17,145,16,33,81,36,68,17,64,64,0,148,37,40,38,138,4,129,72,168,20,9,146,98,34,129,72,36,68,132,16,4,65,130,32,8,9,0,32,155,162,44,146,44,42,165,164,40,154,178,136,34,35,136,80,8,65,18,130,194,33,198,69,16,0,65,225,208,231,32,142,35,56,78,1,0,64,228,35,232,195,121,124,1,71,40,19,250,146,66,28,1,87,200,67,120,16,4,33,132,240,11,9,0,192,106,28,203,17,43,42,169,164,200,105,172,112,198,34,136,136,136,79,18,0,128,0,0,128,8,0,1,0,0,0,0,0,0,0,0,1,0,0,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,8,32,0,0,0,8,32,0,0,0,0,0,8,64,18,0,0,0,0,0,5,0,1,0,0,0,0,0,0,0,0,1,0,0,240,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,12,248,1,0,0,0,128,7,16,0,0,0,8,32,0,0,0,0,0,4,128,10,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,13,19,29,36,38,42,46,50,56,58,62,64,68,74,78,84,90,96,102,108,114,120,126,128,130,136,142,148,154,165,173,180,187,194,200,206,214,221,223,228,235,241,249,256,264,270,278,285,292,298,305,313,325,332,340,347,350,354,357,363,370,373,379,385,391,397,403,407,413,419,421,424,429,431,439,445,451,457,463,467,473,477,483,489,499,505,511,517,521,523,};
|
|
static const FontWrap fnt_f1(528,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 5
|
|
// GOOD!
|
|
static const uint8_t f1_data[] = {0,0,5,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,137,159,16,35,155,10,0,0,144,179,231,65,62,231,115,28,0,1,193,241,113,30,231,249,62,39,58,40,10,66,145,243,56,30,231,139,162,160,40,250,46,224,4,16,32,0,32,128,1,65,10,1,0,0,0,0,64,0,0,0,0,0,204,102,0,170,95,69,137,164,32,7,0,0,72,36,8,98,130,0,138,34,128,0,34,10,138,162,40,10,130,40,18,40,9,102,81,20,69,162,136,136,162,160,40,130,66,128,10,32,32,0,32,64,0,1,8,1,0,0,0,0,64,0,0,0,0,0,34,137,0,2,73,133,132,164,160,138,0,0,68,38,8,82,130,0,137,162,77,0,4,234,138,162,32,10,130,32,18,168,8,90,83,20,69,162,128,136,162,36,37,66,130,128,0,0,231,113,60,231,120,79,74,253,60,206,227,53,239,69,81,82,20,125,34,136,0,2,137,15,130,131,32,130,0,0,66,37,199,73,158,7,113,188,45,124,8,169,250,158,32,122,158,238,19,104,8,66,85,20,69,34,135,136,162,36,66,33,2,129,0,0,40,138,162,72,68,81,42,37,69,81,20,141,64,68,81,146,18,33,33,8,1,130,31,21,73,138,32,224,195,3,193,164,0,250,160,136,136,32,64,0,132,232,139,162,32,10,130,40,18,168,8,66,89,244,68,30,136,136,20,21,133,16,2,130,0,0,47,10,162,79,68,81,26,37,69,81,20,5,71,68,74,18,17,17,66,132,0,0,9,149,84,132,32,128,24,152,64,164,0,66,160,136,136,160,141,124,2,8,136,162,40,10,130,40,146,40,9,66,81,20,100,146,136,136,20,149,136,8,2,132,0,128,40,138,162,64,68,81,42,37,69,81,20,5,72,68,74,146,18,9,130,130,0,2,192,79,136,11,27,128,24,88,128,163,239,65,30,71,112,156,13,1,129,240,137,30,231,249,2,39,58,39,250,66,145,19,120,34,135,112,8,138,136,248,14,232,224,7,239,113,60,79,120,81,74,37,69,206,227,133,135,57,132,77,228,125,12,97,0,0,0,5,0,0,0,0,16,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,2,0,0,64,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,0,1,0,0,64,0,1,0,0,0,0,224,0,0,0,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,14,22,30,37,39,43,47,53,59,62,67,70,78,84,87,93,99,105,111,117,123,129,135,138,141,146,152,157,163,171,177,183,189,195,201,207,213,219,223,229,235,241,248,254,260,266,273,279,285,291,297,303,311,317,323,329,333,341,345,349,356,359,365,371,377,383,389,394,400,406,408,411,416,418,426,432,438,444,450,455,461,466,472,478,486,492,498,504,509,517,};
|
|
static const FontWrap fnt_f1(528,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 6
|
|
// EXEPixelPerfect.ttf
|
|
static const uint8_t f1_data[] = {0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,197,153,12,41,0,0,0,114,8,199,65,62,231,115,28,0,0,56,142,243,56,207,247,57,209,247,69,65,20,57,143,243,120,95,20,69,81,244,45,70,0,1,2,0,2,24,16,8,133,1,0,0,0,0,32,0,0,0,0,192,26,0,170,175,154,18,69,10,1,0,138,140,40,98,130,40,138,34,64,64,68,81,20,69,81,16,68,17,129,68,65,20,69,81,20,5,68,20,69,81,4,37,164,0,2,2,0,2,4,16,0,4,1,0,0,0,0,112,0,0,0,0,32,34,0,2,165,64,18,68,4,1,0,201,8,8,82,158,0,138,162,36,159,64,93,20,5,81,16,4,17,129,36,193,54,69,81,20,5,68,20,69,74,132,68,20,1,114,30,199,115,132,247,140,37,121,30,199,113,142,39,81,20,69,209,39,34,0,2,197,33,12,68,223,135,15,169,8,134,73,160,7,113,60,16,0,33,213,247,4,209,241,116,31,129,28,65,85,69,79,244,60,68,20,85,132,66,68,4,0,128,162,40,138,78,20,9,21,169,162,40,138,82,32,81,20,69,17,52,98,0,2,133,18,82,68,4,1,0,153,8,1,74,160,8,137,32,32,159,16,93,20,5,81,16,68,17,129,36,65,149,69,65,20,65,68,20,85,10,33,68,4,0,240,162,32,122,68,20,9,13,169,162,40,138,130,35,81,84,57,145,35,34,0,128,175,202,34,68,10,1,128,136,136,32,250,162,136,136,34,64,64,0,65,20,69,81,16,68,17,145,68,65,20,69,65,18,65,68,164,84,17,17,132,4,0,136,162,40,10,68,20,9,21,169,162,40,138,2,36,145,84,69,81,32,34,0,2,197,201,92,40,0,32,160,112,190,207,65,28,135,112,156,4,0,16,94,244,56,207,23,56,209,231,68,95,20,57,129,21,61,132,67,40,17,241,141,6,124,112,30,199,243,132,23,29,165,171,34,231,241,194,99,14,163,68,222,199,26,0,0,128,0,0,0,0,32,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,192,0,0,0,32,128,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,0,32,128,0,0,0,0,0,12,0,0,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,13,19,25,32,34,37,40,46,52,55,61,63,67,73,79,85,91,97,103,109,115,121,127,129,132,136,142,146,152,158,164,170,176,182,188,194,200,206,212,218,224,230,236,242,248,254,260,266,272,278,284,290,296,302,308,314,317,321,324,330,336,339,345,351,357,363,369,374,380,386,390,394,399,403,409,415,421,427,433,438,444,448,454,460,466,472,478,484,489,491,};
|
|
static const FontWrap fnt_f1(504,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 7
|
|
// new-gen.ttf
|
|
static const uint8_t f1_data[] = {42,9,33,2,144,2,0,0,8,0,0,0,0,0,0,0,0,0,112,124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,6,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,1,42,137,83,2,80,84,0,0,200,25,199,73,62,231,115,28,64,64,136,130,136,199,121,190,207,137,238,162,32,138,156,199,121,188,47,138,162,40,250,18,4,0,2,4,0,2,12,8,74,8,0,0,0,0,0,1,0,0,0,0,72,2,130,95,85,193,64,36,4,0,36,146,40,74,130,8,138,34,32,128,128,178,148,40,138,130,32,138,68,146,96,155,162,40,138,2,34,138,162,40,130,34,68,0,4,4,0,2,2,8,64,8,0,0,0,0,0,1,0,0,0,0,72,2,2,73,33,33,66,84,4,0,36,19,8,74,130,0,137,162,18,31,129,170,162,40,136,130,32,136,68,138,160,170,162,40,138,2,34,138,34,69,65,34,164,0,224,61,206,115,194,123,74,234,230,113,28,199,121,23,69,73,81,244,73,2,2,137,131,196,71,4,31,31,162,18,132,249,158,135,112,60,8,0,66,170,162,39,136,158,167,251,68,134,32,202,162,39,122,28,34,138,34,130,32,66,20,1,16,69,33,138,46,138,74,41,41,138,162,40,4,17,69,73,74,132,68,4,130,31,133,42,66,4,4,0,98,18,2,66,160,72,136,32,16,31,33,250,190,40,136,130,32,138,68,138,32,138,162,32,42,32,34,138,42,133,16,66,4,0,16,69,33,250,34,138,202,40,41,138,162,40,56,17,69,73,132,71,72,2,0,73,69,42,66,4,4,0,33,18,33,66,160,40,136,34,32,128,0,2,162,40,138,130,32,138,68,146,32,138,162,32,74,32,34,82,182,136,8,130,4,0,16,69,33,10,34,138,74,41,41,138,162,40,64,17,41,42,10,36,72,2,2,137,67,196,65,4,64,64,193,185,207,65,30,39,112,156,66,64,32,60,162,199,121,190,192,137,78,162,47,138,156,192,137,30,194,33,162,136,248,130,4,0,224,57,206,241,194,139,74,42,41,114,30,47,60,230,17,20,209,243,73,2,0,0,1,0,128,2,64,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,64,0,0,0,0,128,0,0,0,0,0,0,0,6,6,124,0,0,0,0,0,2,8,0,0,0,2,8,0,0,0,0,0,0,80,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,192,1,4,0,0,0,2,8,0,0,0,0,0,0,0,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,14,20,29,36,38,41,44,48,54,56,62,64,69,75,79,85,91,97,103,109,115,121,127,129,131,136,142,147,153,161,167,173,179,185,191,197,203,209,213,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,316,321,324,330,336,340,346,352,357,363,369,373,379,385,387,390,395,397,405,411,417,423,429,434,440,444,450,456,464,470,476,482,486,488,};
|
|
static const FontWrap fnt_f1(496,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 8
|
|
// Comicoro.ttf
|
|
static const uint8_t f1_data[] = {80,0,2,0,64,20,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,0,84,40,206,8,66,34,4,0,0,194,16,199,145,60,230,99,28,0,0,56,0,48,30,204,227,121,120,34,241,2,130,24,8,142,7,199,195,253,68,33,161,80,232,144,144,0,2,4,0,4,8,16,128,32,0,0,0,0,0,0,0,0,0,0,146,0,4,62,35,5,5,65,31,1,0,34,153,8,138,4,1,146,34,128,64,64,60,72,34,66,36,8,4,34,129,66,130,149,16,145,136,72,36,32,68,33,161,72,8,151,80,1,4,4,0,4,4,16,162,32,0,0,0,0,0,2,0,0,0,0,146,0,2,148,34,5,2,65,14,1,0,17,17,8,138,130,0,145,34,96,158,65,66,72,34,65,20,4,2,33,129,34,129,150,145,144,72,72,20,32,68,145,32,69,4,18,17,0,192,28,12,103,142,17,128,168,158,199,105,184,114,23,69,161,68,122,146,0,2,20,199,26,21,65,202,7,0,17,17,132,113,158,135,112,188,20,0,50,153,68,159,32,244,60,121,191,128,18,65,146,82,144,38,72,226,16,66,145,36,130,4,17,17,0,32,37,130,148,68,122,162,164,165,40,154,164,9,18,69,41,35,66,17,1,2,63,10,166,8,65,0,1,7,17,17,2,66,160,72,136,16,96,158,9,165,124,161,32,20,4,65,145,64,12,65,144,82,208,33,232,1,17,66,137,22,6,131,16,17,0,16,69,65,116,36,138,34,163,164,40,138,162,48,18,37,45,35,34,146,0,0,10,10,165,8,65,0,33,128,16,17,33,66,160,72,136,144,132,64,0,181,66,161,32,18,4,33,145,68,28,65,80,84,72,32,36,2,17,34,138,25,9,66,16,18,0,144,69,81,22,196,139,34,163,164,40,122,188,64,18,41,155,196,19,146,0,2,138,7,25,23,65,0,32,160,224,144,207,65,28,71,112,16,4,0,8,105,66,31,239,225,5,30,145,56,100,94,80,152,71,192,35,244,16,28,134,144,16,226,23,18,0,96,57,142,229,4,138,34,165,164,200,9,160,56,226,24,145,8,122,146,0,0,0,2,0,0,34,0,16,128,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,16,18,0,0,0,0,0,64,2,32,0,0,0,8,32,0,0,0,0,0,1,146,0,0,0,2,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,48,24,252,0,0,0,0,128,1,24,0,0,0,8,32,0,0,0,0,192,0,84,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,4,8,15,21,31,38,40,44,48,54,60,63,69,71,75,81,87,93,99,105,111,117,123,129,135,137,140,145,150,155,160,169,176,183,189,196,202,208,216,223,226,233,240,246,254,262,270,277,285,292,298,305,312,319,327,334,341,348,351,355,358,362,369,372,378,384,390,396,401,405,411,417,419,423,429,431,439,445,451,457,463,467,472,476,482,488,495,501,507,512,516,518,};
|
|
static const FontWrap fnt_f1(528,10,f1_data,f1_offsets);
|
|
#elif UI_FONT == 9
|
|
// Nineteen Ninety Six.otf
|
|
static const uint8_t f1_data[] = {84,36,8,66,14,99,134,0,0,0,113,48,30,14,36,30,30,62,30,30,0,2,130,7,31,14,30,14,15,30,30,30,33,225,133,8,8,34,194,225,193,225,225,1,39,18,66,64,144,144,143,5,35,0,2,4,0,4,0,64,64,34,8,0,0,0,0,0,0,0,0,0,0,0,41,0,82,36,60,37,17,18,136,32,0,128,136,72,33,17,34,1,1,65,33,33,0,1,68,136,32,17,33,145,16,33,33,33,161,88,132,4,20,85,36,18,34,18,18,242,16,20,36,136,80,80,144,8,82,0,4,4,0,4,48,64,0,32,8,0,0,0,0,0,8,0,0,0,0,128,72,0,82,127,2,22,17,9,232,35,0,128,4,69,64,32,34,1,31,64,33,65,155,248,8,80,166,160,160,128,160,128,128,0,161,128,100,4,164,84,20,20,20,20,20,128,16,20,20,144,72,16,136,8,138,0,96,52,134,229,72,76,35,36,137,77,195,52,76,99,60,81,34,18,9,143,72,0,2,18,60,8,94,8,136,248,240,65,4,65,48,60,17,62,33,32,62,65,64,0,16,72,169,167,159,128,160,143,143,24,159,128,28,4,68,148,20,20,20,20,228,131,16,20,20,17,135,8,70,16,137,0,144,76,73,22,29,210,20,40,73,210,36,77,210,20,8,81,20,36,69,208,200,0,2,18,65,52,33,8,72,33,0,64,4,65,14,64,81,64,65,32,65,126,128,248,8,71,158,184,160,128,160,128,128,160,144,128,100,4,4,148,20,52,20,245,3,132,16,36,18,145,8,7,65,16,1,0,16,69,65,244,9,81,20,232,72,82,20,69,81,224,8,81,148,228,68,140,68,0,0,127,62,82,33,8,36,34,0,32,132,64,65,65,62,65,66,16,65,64,0,1,4,128,128,160,160,160,144,160,128,160,144,68,132,4,5,20,21,210,19,18,17,132,32,66,33,73,8,130,80,32,1,0,144,77,81,22,8,81,84,41,73,82,20,77,89,0,73,153,146,148,68,130,68,0,6,18,8,33,94,48,3,0,6,44,120,32,62,62,16,62,60,8,62,56,27,2,130,1,31,17,31,31,15,159,0,159,32,57,4,249,4,34,226,17,224,21,230,131,192,129,192,70,16,2,207,160,1,254,96,53,142,229,8,94,34,38,82,74,226,52,86,240,48,22,97,19,121,28,37,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,4,16,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,4,16,0,0,0,0,0,48,0,0,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,4,8,16,24,32,40,43,48,53,59,65,68,74,77,82,90,96,104,112,120,128,136,144,152,160,163,166,171,177,182,190,199,207,215,223,231,239,247,255,263,266,274,282,290,300,308,316,324,332,340,348,356,364,372,382,390,398,406,410,415,419,425,433,436,442,448,454,460,466,472,478,484,488,493,499,502,510,516,522,528,534,540,546,552,558,564,572,578,584,590,594,597,};
|
|
static const FontWrap fnt_f1(608,9,f1_data,f1_offsets);
|
|
#elif UI_FONT == 10
|
|
// RNTG Larger.ttf also good
|
|
static const uint8_t f1_data[] = {42,133,152,140,40,42,0,0,128,131,56,14,243,57,159,227,0,0,0,28,135,120,156,227,251,156,40,40,10,162,232,123,156,199,249,162,168,138,162,239,130,35,128,0,1,0,1,12,16,4,5,3,0,0,0,0,128,0,0,0,0,0,92,7,170,207,155,146,68,28,2,0,80,196,68,145,18,68,80,20,37,0,0,162,136,136,162,36,8,162,40,40,9,182,40,138,162,40,34,162,168,82,34,40,4,82,0,1,1,0,1,18,16,0,4,2,0,0,0,0,128,0,0,0,0,0,68,4,2,165,64,18,130,8,2,0,72,164,64,80,18,4,72,20,1,236,27,160,76,137,130,40,8,130,40,168,8,170,41,138,162,40,32,162,168,82,20,36,4,138,0,28,141,99,25,130,213,4,37,178,52,78,99,53,222,19,69,81,20,125,68,4,2,197,33,12,130,156,15,31,68,132,32,78,226,60,132,227,1,3,96,152,74,121,130,232,121,154,47,104,8,162,42,122,170,199,33,34,165,34,8,34,8,2,0,32,83,148,37,79,54,5,21,82,77,209,148,77,129,16,69,145,146,33,3,24,0,133,18,18,130,42,2,0,66,132,24,208,7,69,68,4,129,224,131,128,206,137,130,40,8,162,168,168,8,162,44,10,146,2,34,34,165,82,8,33,16,2,0,56,81,16,29,130,21,5,13,82,69,209,148,5,142,16,41,21,97,17,68,4,128,239,201,18,68,0,98,0,65,132,4,17,18,69,66,20,53,3,96,128,32,138,162,36,8,178,168,40,9,162,40,10,172,36,34,34,165,82,136,32,16,2,0,36,83,148,69,2,20,21,21,82,69,81,99,5,144,148,41,149,2,9,68,4,2,133,200,60,40,0,64,64,128,131,124,14,226,56,130,227,32,12,24,8,47,122,156,227,11,172,40,39,250,162,232,11,160,200,33,28,194,139,136,239,160,3,62,120,141,99,57,194,19,229,100,87,69,78,0,5,15,99,17,74,244,124,92,7,};
|
|
static const uint16_t f1_offsets[] = {0,1,3,7,13,19,25,31,33,37,41,47,53,56,62,64,70,76,82,88,94,100,106,112,118,124,130,132,135,141,147,153,159,165,171,177,183,189,195,201,207,213,215,221,227,233,239,245,251,257,263,269,275,281,287,293,299,305,311,317,321,327,331,337,343,346,352,358,364,370,376,382,388,394,396,402,408,412,418,424,430,436,442,448,454,460,466,472,478,484,490,496,502,504,};
|
|
static const FontWrap fnt_f1(512,7,f1_data,f1_offsets);
|
|
#elif UI_FONT == 11
|
|
// Bonni-Africa.ttf
|
|
static const uint8_t f1_data[] = {8,0,0,0,0,0,0,0,0,112,16,14,135,194,99,126,28,7,0,0,56,0,8,28,28,14,143,135,67,228,227,35,32,16,17,225,112,112,56,28,95,68,4,72,16,249,25,24,0,0,8,0,2,0,0,1,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,2,0,64,0,0,0,0,136,24,145,136,34,144,64,162,8,0,0,68,0,24,36,34,18,129,64,68,132,128,32,34,16,17,17,145,136,72,162,68,72,36,136,20,1,9,144,0,1,8,0,2,96,24,65,136,32,0,0,104,44,0,0,0,0,0,18,192,48,0,200,24,205,193,72,33,8,140,128,136,22,16,72,226,8,32,162,8,0,0,68,120,40,36,1,18,129,32,64,132,128,160,33,16,17,9,145,132,72,1,68,72,36,137,162,192,72,144,0,96,40,140,194,16,36,33,128,36,22,134,145,18,193,33,4,41,33,148,79,36,0,196,60,193,195,40,114,8,112,64,136,16,8,231,3,105,16,28,15,66,78,32,174,36,28,1,18,135,35,192,135,128,96,32,168,18,9,113,132,56,14,68,72,34,9,65,48,72,80,1,144,88,82,35,49,34,7,144,34,41,73,178,26,39,122,41,149,44,72,68,36,0,4,20,6,193,32,82,190,0,68,68,8,6,8,2,154,16,34,8,48,128,19,170,60,162,0,145,64,16,35,68,64,144,16,168,178,4,9,162,36,16,66,40,162,138,66,8,136,16,0,136,72,65,210,8,60,73,144,33,41,41,82,20,193,32,41,149,16,8,35,68,0,0,62,136,38,33,2,136,0,74,68,8,65,8,18,138,16,161,4,96,206,0,170,66,162,16,137,64,16,34,66,72,144,16,72,170,132,8,66,36,33,66,36,81,70,66,4,136,16,0,200,72,65,18,8,33,73,137,34,41,41,18,48,17,33,169,148,168,132,72,36,0,6,12,9,230,33,2,0,1,36,56,188,159,7,228,113,32,30,3,2,0,24,122,65,31,143,199,39,224,21,242,49,8,249,69,73,120,4,188,66,30,129,227,48,34,36,252,8,17,0,48,53,142,229,4,158,36,70,148,148,196,17,144,224,16,70,104,4,195,71,36,0,0,0,6,0,64,1,0,0,32,0,0,0,0,0,0,0,0,0,2,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,24,120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,52,0,};
|
|
static const uint16_t f1_offsets[] = {0,1,5,9,15,21,28,34,36,40,44,49,55,58,65,69,74,81,87,94,101,108,115,121,128,135,141,144,147,152,157,162,168,176,184,191,199,206,213,220,228,236,243,251,259,266,275,282,290,297,305,312,319,326,333,340,349,356,362,370,374,379,382,387,392,395,402,408,414,420,426,432,439,445,448,454,460,463,471,477,483,489,495,500,507,512,517,522,530,535,542,549,553,556,};
|
|
static const FontWrap fnt_f1(568,8,f1_data,f1_offsets);
|
|
#else
|
|
#error "UI_FONT not defined"
|
|
#endif
|
|
|
|
|
|
#include "UIElement.h"
|
|
#include "UIStructs.h"
|
|
#include "UIPainter.h"
|
|
|
|
#undef min
|
|
#undef max
|
|
#include <vector>
|
|
|
|
class UI {
|
|
|
|
UIPainter p;
|
|
UIElement root;
|
|
|
|
int focusIdx = 0;
|
|
//UIElement* eFocused = nullptr;
|
|
UIElement* eDown = nullptr;
|
|
|
|
Color cBackground = Color::fromRGB(180,240,180);
|
|
|
|
public:
|
|
|
|
UI(int w, int h) {
|
|
root.setRect(0,0,w,h);
|
|
root.setVisible(true);
|
|
p.setFG(cBackground);
|
|
p.fillRect(root.getRect());
|
|
}
|
|
|
|
void add(UIElement* e) {
|
|
root.addChild(e);
|
|
}
|
|
|
|
void onTouch(const uint16_t x, const uint16_t y) {
|
|
|
|
if (eDown) {
|
|
|
|
const uint16_t x1 = x - eDown->getRect().x; // (x,y) relative to elements top-left
|
|
const uint16_t y1 = y - eDown->getRect().y;
|
|
eDown->onTouch(x1, y1);
|
|
|
|
} else {
|
|
|
|
ESP_LOGI("UI", "root_onTouch(%d, %d)", x,y );
|
|
eDown = root._onTouch(x,y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void onTouchDone() {
|
|
if (eDown) {
|
|
eDown->onTouchUp();
|
|
eDown = nullptr;
|
|
}
|
|
}
|
|
|
|
void focusNext() {
|
|
root.children[focusIdx]->setFocus(false);
|
|
focusIdx = (focusIdx + 1) % root.children.size();
|
|
root.children[focusIdx]->setFocus(true);
|
|
}
|
|
void focusPrev() {
|
|
root.children[focusIdx]->setFocus(false);
|
|
focusIdx = ((focusIdx - 1) + root.children.size()) % root.children.size();
|
|
root.children[focusIdx]->setFocus(true);
|
|
}
|
|
|
|
void draw() {
|
|
//debugMod1("UI", "draw %zu elements", elements.size());
|
|
// for (UIElement* e : elements) {
|
|
// e->_draw(p);
|
|
// }
|
|
|
|
//p.setFG(cBackground);
|
|
//p.fillRect(root.getRect());
|
|
|
|
root._draw(p);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // UI_H
|