This source file includes following definitions.
- get_space_perc
- space_color
- spacebar_outer
- gui_space_draw_spacebar_horizontal
- gui_space_draw_spacebar_vertical
- gui_space_draw_icon
- gui_space_draw_value
- gui_space_draw_osd
1 #include "camera_info.h"
2 #include "conf.h"
3 #include "sd_card.h"
4 #include "gui_draw.h"
5 #include "gui_space.h"
6
7
8 static char osd_buf[32];
9
10
11
12 unsigned long get_space_perc() {
13
14 return (GetFreeCardSpaceKb()>>6)*100/(GetTotalCardSpaceKb()>>6);
15 }
16
17
18 static twoColors cl;
19 static coord xx, yy;
20 static int perc, width, height;
21
22
23 static void space_color()
24 {
25 perc = get_space_perc();
26 cl = user_color(conf.space_color);
27 if (((conf.space_warn_type == 0) && (perc <= conf.space_perc_warn)) ||
28 ((conf.space_warn_type == 1) && (GetFreeCardSpaceKb() <= (unsigned)conf.space_mb_warn*1024)))
29 {
30 cl = user_color(conf.osd_color_warn);
31 }
32 }
33
34
35 static void spacebar_outer(OSD_pos pos, int w, int h)
36 {
37
38 space_color();
39
40
41 xx = pos.x;
42 yy = pos.y;
43
44
45 width = w;
46 height = h;
47
48
49 if (xx > (camera_screen.width-width-4)) {
50 xx = camera_screen.width-width-4;
51 }
52 if (yy > (camera_screen.height-height-4)) {
53 yy = camera_screen.height-height-4;
54 }
55
56 draw_rectangle(xx, yy, xx+width+3, yy+height+3, MAKE_COLOR(COLOR_BLACK,COLOR_BLACK), RECT_BORDER1);
57 draw_rectangle(xx+1, yy+1, xx+width+2, yy+height+2, cl, RECT_BORDER1);
58 }
59
60 static void gui_space_draw_spacebar_horizontal()
61 {
62 coord x;
63
64
65 spacebar_outer(conf.space_hor_pos, (camera_screen.width / (4 >> conf.space_bar_size)) - 4, conf.space_bar_width);
66
67
68 x = width - ((perc*width)/100);
69 if (x < 1) x = 1;
70 if (x >= width) x = width;
71 else draw_rectangle(xx+x+2, yy+2, xx+width+1, yy+height+1, MAKE_COLOR(FG_COLOR(cl), FG_COLOR(cl)), RECT_BORDER0|DRAW_FILLED);
72 draw_rectangle(xx+2, yy+2, xx+x+1, yy+height+1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK), RECT_BORDER1|DRAW_FILLED);
73 }
74
75 static void gui_space_draw_spacebar_vertical() {
76 coord y;
77
78
79 spacebar_outer(conf.space_ver_pos, conf.space_bar_width, (camera_screen.height / (4 >> conf.space_bar_size)) - 4);
80
81
82 y = height - ((perc*height)/100);
83 if (y < 1) y = 1;
84 if (y >= height) y = height;
85 else draw_rectangle(xx+2, yy+y+2, xx+width+1, yy+height+1, MAKE_COLOR(FG_COLOR(cl), FG_COLOR(cl)), RECT_BORDER0|DRAW_FILLED);
86 draw_rectangle(xx+2, yy+2, xx+width+1, yy+y+1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK), RECT_BORDER1|DRAW_FILLED);
87 }
88
89 static icon_cmd space_icon[] =
90 {
91 { IA_HLINE, 0, 0, 30, 0, IDX_COLOR_GREY_LT, IDX_COLOR_GREY_LT },
92 { IA_VLINE, 0, 0, 0, 13, IDX_COLOR_GREY_LT, IDX_COLOR_GREY_LT },
93 { IA_VLINE, 31, 0, 0, 19, IDX_COLOR_GREY, IDX_COLOR_GREY },
94 { IA_LINE, 1, 13, 5, 17, IDX_COLOR_GREY, IDX_COLOR_GREY },
95 { IA_HLINE, 6, 18, 24, 0, IDX_COLOR_GREY, IDX_COLOR_GREY },
96 { IA_FILLED_RECT, 1, 1, 30, 13, IDX_COLOR_GREY_DK, IDX_COLOR_GREY_DK },
97 { IA_FILLED_RECT, 5, 14, 30, 17, IDX_COLOR_GREY_DK, IDX_COLOR_GREY_DK },
98 { IA_FILLED_RECT, 3, 14, 6, 15, IDX_COLOR_GREY_DK, IDX_COLOR_GREY_DK },
99 { IA_FILLED_RECT, 2, 2, 6, 4, IDX_COLOR_YELLOW_DK, IDX_COLOR_YELLOW_DK },
100 { IA_FILLED_RECT, 2, 6, 6, 7, IDX_COLOR_YELLOW_DK, IDX_COLOR_YELLOW_DK },
101 { IA_FILLED_RECT, 2, 9, 6, 10, IDX_COLOR_YELLOW_DK, IDX_COLOR_YELLOW_DK },
102 { IA_FILLED_RECT, 2, 12, 6, 13, IDX_COLOR_YELLOW_DK, IDX_COLOR_YELLOW_DK },
103 { IA_FILLED_RECT, 5, 15, 9, 13, IDX_COLOR_YELLOW_DK, IDX_COLOR_YELLOW_DK },
104 { IA_HLINE, 8, 0, 2, 0, IDX_COLOR_TRANSPARENT, IDX_COLOR_TRANSPARENT },
105 { IA_HLINE, 11, 0, 3, 0, IDX_COLOR_WHITE, IDX_COLOR_WHITE },
106 { IA_HLINE, 11, 18, 2, 0, IDX_COLOR_TRANSPARENT, IDX_COLOR_TRANSPARENT },
107 { IA_RECT, 9, 5, 28, 13, 0, 0 },
108 { IA_FILLED_RECT, 27, 6, 27, 12, 0, 0 },
109 { IA_END }
110 };
111
112 static void gui_space_draw_icon()
113 {
114 space_color();
115
116 color cl1 = IDX_COLOR_GREEN_DK;
117 color cl2 = IDX_COLOR_GREEN;
118 if (((conf.space_warn_type == 0) && (perc <= conf.space_perc_warn)) ||
119 ((conf.space_warn_type == 1) && (GetFreeCardSpaceKb() <= (unsigned)conf.space_mb_warn*1024)))
120 {
121 cl1 = IDX_COLOR_RED_DK;
122 cl2 = IDX_COLOR_RED;
123 }
124
125
126 space_icon[16].cb = cl1;
127 space_icon[17].x1 = 27 - (17 * perc / 100);
128 space_icon[17].cf = space_icon[17].cb = cl2;
129
130
131 draw_icon_cmds(conf.space_icon_pos.x, conf.space_icon_pos.y, space_icon);
132 }
133
134
135 static void gui_space_draw_value(int force)
136 {
137 int offset = 0;
138
139 space_color();
140
141 if ((conf.show_partition_nr) && (get_part_count() > 1))
142 {
143 sprintf(osd_buf, "%1d:\0", get_active_partition());
144 offset = 2;
145 }
146
147 if (is_partition_changed())
148 {
149 sprintf(osd_buf+offset, "???\0");
150 }
151 else
152 {
153 if (conf.space_perc_show || force)
154 {
155 sprintf(osd_buf+offset, "%3d%%\0", perc);
156 }
157 else if (conf.space_mb_show)
158 {
159 unsigned int freemb = GetFreeCardSpaceKb()/1024;
160 if (freemb < 10000) sprintf(osd_buf+offset, "%4dM\0",freemb);
161 else sprintf(osd_buf+offset, "%4dG\0",freemb/1024);
162 }
163 }
164
165 draw_osd_string(conf.space_txt_pos, 0, 0, osd_buf, cl, conf.space_txt_scale);
166 }
167
168
169
170 void gui_space_draw_osd(int is_osd_edit)
171 {
172 if (conf.space_icon_show || is_osd_edit)
173 gui_space_draw_icon();
174
175 if (conf.space_perc_show || conf.space_mb_show || is_osd_edit)
176 gui_space_draw_value(is_osd_edit);
177
178 if ((conf.space_bar_show == 1) || is_osd_edit)
179 gui_space_draw_spacebar_horizontal();
180
181 if (conf.space_bar_show == 2 || is_osd_edit)
182 gui_space_draw_spacebar_vertical();
183 }