1+ #include "gui_top_buttons.h"
2+
3+ void elements_button_top_left (Canvas * canvas , const char * str ) {
4+ const Icon * icon = & I_ButtonUp_7x4 ;
5+
6+ const uint8_t button_height = 12 ;
7+ const uint8_t vertical_offset = 3 ;
8+ const uint8_t horizontal_offset = 3 ;
9+ const uint8_t string_width = canvas_string_width (canvas , str );
10+ const uint8_t icon_h_offset = 3 ;
11+ const uint8_t icon_width_with_offset = icon_get_width (icon ) + icon_h_offset ;
12+ const uint8_t icon_v_offset = icon_get_height (icon ) + vertical_offset ;
13+ const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset ;
14+
15+ const uint8_t x = 0 ;
16+ const uint8_t y = 0 + button_height ;
17+
18+ uint8_t line_x = x + button_width ;
19+ uint8_t line_y = y - button_height ;
20+ canvas_draw_box (canvas , x , line_y , button_width , button_height );
21+ canvas_draw_line (canvas , line_x + 0 , line_y , line_x + 0 , y - 1 );
22+ canvas_draw_line (canvas , line_x + 1 , line_y , line_x + 1 , y - 2 );
23+ canvas_draw_line (canvas , line_x + 2 , line_y , line_x + 2 , y - 3 );
24+
25+ canvas_invert_color (canvas );
26+ canvas_draw_icon (canvas , x + horizontal_offset , y - icon_v_offset , icon );
27+ canvas_draw_str (
28+ canvas , x + horizontal_offset + icon_width_with_offset , y - vertical_offset , str );
29+ canvas_invert_color (canvas );
30+ }
31+
32+ void elements_button_top_right (Canvas * canvas , const char * str ) {
33+ const Icon * icon = & I_ButtonDown_7x4 ;
34+
35+ const uint8_t button_height = 12 ;
36+ const uint8_t vertical_offset = 3 ;
37+ const uint8_t horizontal_offset = 3 ;
38+ const uint8_t string_width = canvas_string_width (canvas , str );
39+ const uint8_t icon_h_offset = 3 ;
40+ const uint8_t icon_width_with_offset = icon_get_width (icon ) + icon_h_offset ;
41+ const uint8_t icon_v_offset = icon_get_height (icon ) + vertical_offset + 1 ;
42+ const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset ;
43+
44+ const uint8_t x = canvas_width (canvas );
45+ const uint8_t y = 0 + button_height ;
46+
47+ uint8_t line_x = x - button_width ;
48+ uint8_t line_y = y - button_height ;
49+ canvas_draw_box (canvas , line_x , line_y , button_width , button_height );
50+ canvas_draw_line (canvas , line_x - 1 , line_y , line_x - 1 , y - 1 );
51+ canvas_draw_line (canvas , line_x - 2 , line_y , line_x - 2 , y - 2 );
52+ canvas_draw_line (canvas , line_x - 3 , line_y , line_x - 3 , y - 3 );
53+
54+ canvas_invert_color (canvas );
55+ canvas_draw_str (canvas , x - button_width + horizontal_offset , y - vertical_offset , str );
56+ canvas_draw_icon (
57+ canvas , x - horizontal_offset - icon_get_width (icon ), y - icon_v_offset , icon );
58+ canvas_invert_color (canvas );
59+ }
0 commit comments