24
24
extern const unsigned char _binary_opensans_regular_ttf_start [];
25
25
extern const unsigned char _binary_opensans_regular_ttf_end [];
26
26
27
+ void draw_exit_button (NVGcontext * vg , int b_x , int b_y , int b_w , int b_h ) {
28
+ nvgBeginPath (vg );
29
+ nvgFillColor (vg , nvgRGBA (8 , 8 , 8 , 178 ));
30
+ nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
31
+ nvgFill (vg );
32
+
33
+ nvgFillColor (vg , nvgRGBA (255 , 255 , 255 , 255 ));
34
+ nvgTextAlign (vg , NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE );
35
+ nvgText (vg , b_x + b_w /2 , b_y + b_h /2 , "Exit" , NULL );
36
+
37
+ nvgBeginPath (vg );
38
+ nvgStrokeColor (vg , nvgRGBA (255 , 255 , 255 , 50 ));
39
+ nvgStrokeWidth (vg , 5 );
40
+ nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
41
+ nvgStroke (vg );
42
+ }
43
+
44
+ void draw_git_button (NVGcontext * vg , int b_x , int b_y , int b_w , int b_h ) {
45
+ nvgBeginPath (vg );
46
+ nvgFillColor (vg , nvgRGBA (8 , 8 , 8 , 178 ));
47
+ nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
48
+ nvgFill (vg );
49
+
50
+ nvgFillColor (vg , nvgRGBA (255 , 255 , 255 , 255 ));
51
+ nvgTextAlign (vg , NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE );
52
+ nvgText (vg , b_x + b_w /2 , b_y + b_h /2 , "Git Reset" , NULL );
53
+
54
+ nvgBeginPath (vg );
55
+ nvgStrokeColor (vg , nvgRGBA (255 , 255 , 255 , 50 ));
56
+ nvgStrokeWidth (vg , 5 );
57
+ nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
58
+ nvgStroke (vg );
59
+ }
60
+
27
61
int main (int argc , char * * argv ) {
28
62
int err ;
29
63
@@ -60,7 +94,7 @@ assert(font >= 0);
60
94
61
95
// Text
62
96
nvgFillColor (vg , COLOR_WHITE );
63
- nvgFontSize (vg , 75 .0f );
97
+ nvgFontSize (vg , 65 .0f );
64
98
65
99
if (argc >= 2 ) {
66
100
float x = 150 ;
@@ -82,26 +116,21 @@ assert(font >= 0);
82
116
}
83
117
}
84
118
85
- // Button
86
- int b_x = 1500 ;
87
- int b_y = 800 ;
88
- int b_w = 300 ;
89
- int b_h = 150 ;
119
+ // Exit Button
120
+ int exit_b_x = 1550 ;
121
+ int exit_b_y = 850 ;
122
+ int exit_b_w = 300 ;
123
+ int exit_b_h = 150 ;
90
124
91
- nvgBeginPath (vg );
92
- nvgFillColor (vg , nvgRGBA (8 , 8 , 8 , 255 ));
93
- nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
94
- nvgFill (vg );
125
+ // Git Pull Button
126
+ int git_b_x = exit_b_x - exit_b_w - 50 ; // 50 px padding
127
+ int git_b_y = exit_b_y ;
128
+ int git_b_w = 300 ;
129
+ int git_b_h = 150 ;
95
130
96
- nvgFillColor (vg , nvgRGBA (255 , 255 , 255 , 255 ));
97
- nvgTextAlign (vg , NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE );
98
- nvgText (vg , b_x + b_w /2 , b_y + b_h /2 , "Exit" , NULL );
131
+ draw_exit_button (vg , exit_b_x , exit_b_y , exit_b_w , exit_b_h );
132
+ draw_git_button (vg , git_b_x , git_b_y , git_b_w , git_b_h );
99
133
100
- nvgBeginPath (vg );
101
- nvgStrokeColor (vg , nvgRGBA (255 , 255 , 255 , 50 ));
102
- nvgStrokeWidth (vg , 5 );
103
- nvgRoundedRect (vg , b_x , b_y , b_w , b_h , 20 );
104
- nvgStroke (vg );
105
134
106
135
// Draw to screen
107
136
nvgEndFrame (vg );
@@ -117,12 +146,16 @@ assert(font >= 0);
117
146
int touch_x = -1 , touch_y = -1 ;
118
147
int res = touch_poll (& touch , & touch_x , & touch_y , 0 );
119
148
if (res ){
120
-
121
- if (touch_x > b_x && touch_x < b_x + b_w ){
122
- if (touch_y > b_y && touch_y < b_y + b_h ){
149
+ if (touch_x > exit_b_x && touch_x < exit_b_x + exit_b_w ){
150
+ if (touch_y > exit_b_y && touch_y < exit_b_y + exit_b_h ){
123
151
return 1 ;
124
152
}
125
153
}
154
+ if (touch_x > git_b_x && touch_x < git_b_x + git_b_w ){
155
+ if (touch_y > git_b_y && touch_y < git_b_y + git_b_h ){
156
+ return 0 ; // touched reset button
157
+ }
158
+ }
126
159
}
127
160
128
161
usleep (1000000 / 60 );
0 commit comments