This source file includes following definitions.
- gui_osd_draw
- osd_font_scale
- gui_osd_kbd_process
- gui_osd_menu_kbd_process
- _run
- _module_can_unload
- _module_exit_alt
1 #include "camera_info.h"
2 #include "keyboard.h"
3 #include "histogram.h"
4 #include "lang.h"
5 #include "conf.h"
6 #include "gui.h"
7 #include "gui_draw.h"
8 #include "gui_lang.h"
9 #include "gui_batt.h"
10 #include "gui_usb.h"
11 #include "gui_space.h"
12 #include "gui_osd.h"
13
14 #include "module_def.h"
15 #include "simple_module.h"
16
17
18
19 #define SCX(x) (FONT_WIDTH*(x)/FONT_REAL_WIDTH)
20 #define SCY(y) (FONT_HEIGHT*(y)/FONT_REAL_HEIGHT)
21
22 typedef struct {
23 int title;
24 OSD_pos *pos;
25 OSD_pos size;
26 OSD_scale *scale;
27 } OSD_elem;
28
29 static OSD_elem osd[]={
30 {LANG_OSD_LAYOUT_EDITOR_CLOCK, &conf.clock_pos, {5*FONT_WIDTH, FONT_HEIGHT}, &conf.clock_scale },
31 {LANG_OSD_LAYOUT_EDITOR_TEMP, &conf.temp_pos, {9*FONT_WIDTH, FONT_HEIGHT}, &conf.temp_scale },
32 {LANG_OSD_LAYOUT_EDITOR_RAW, &conf.mode_raw_pos, {7*FONT_WIDTH, FONT_HEIGHT}, &conf.mode_raw_scale },
33 {LANG_OSD_LAYOUT_EDITOR_BAT_ICON, &conf.batt_icon_pos, {SCX(28), SCY(12)}, &conf.batt_icon_scale },
34 {LANG_OSD_LAYOUT_EDITOR_BAT_TEXT, &conf.batt_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT}, &conf.batt_txt_scale },
35 {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_icon_pos, {23, 15}, &conf.space_icon_scale },
36 {LANG_OSD_LAYOUT_EDITOR_SPACE_TEXT, &conf.space_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT}, &conf.space_txt_scale },
37 {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_ver_pos, {3, 50}, &conf.space_ver_scale },
38 {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_hor_pos, {50, 3}, &conf.space_hor_scale },
39 {LANG_OSD_LAYOUT_EDITOR_USB_INFO, &conf.usb_info_pos, {SCX(31), SCY(14)}, &conf.usb_info_scale },
40 {LANG_OSD_LAYOUT_EDITOR_EV, &conf.mode_ev_pos, {12*FONT_WIDTH, FONT_HEIGHT}, &conf.mode_ev_scale },
41 {LANG_OSD_LAYOUT_EDITOR_EV_VIDEO, &conf.ev_video_pos, {SCX(70), SCY(24)}, &conf.ev_video_scale },
42 {LANG_OSD_LAYOUT_EDITOR_VIDEO, &conf.mode_video_pos, {9*FONT_WIDTH, 4*FONT_HEIGHT}, &conf.mode_video_scale },
43 {LANG_OSD_LAYOUT_EDITOR_DOF_CALC, &conf.dof_pos, {23*FONT_WIDTH, 2*FONT_HEIGHT}, &conf.dof_scale },
44 {LANG_OSD_LAYOUT_EDITOR_HISTO, &conf.histo_pos, {HISTO_WIDTH+2, HISTO_HEIGHT}, &conf.histo_scale },
45 {LANG_OSD_LAYOUT_EDITOR_STATES, &conf.mode_state_pos, {12*FONT_WIDTH, 4*FONT_HEIGHT}, &conf.mode_state_scale },
46 {LANG_OSD_LAYOUT_EDITOR_MISC, &conf.values_pos, {9*FONT_WIDTH, 9*FONT_HEIGHT}, &conf.values_scale },
47 {0}
48 };
49
50 static int scalemul[5] = {1,2,4,6,8};
51
52 #define SCL(v,s) ((scalemul[s]*(v))>>1)
53
54 static int osd_to_draw;
55 static int curr_item;
56 static int step;
57
58
59 void gui_osd_draw()
60 {
61 char osd_buf[64];
62
63 if (osd_to_draw)
64 {
65 int i;
66 draw_restore();
67 libhisto->gui_osd_draw_histo(1);
68 gui_draw_osd_elements(1,0);
69 int xscale = osd[curr_item].scale->x;
70 int yscale = osd[curr_item].scale->y;
71 #if (FONT_HEIGHT <= FONT_REAL_HEIGHT)
72 if ( xscale == 0) xscale = 1 ;
73 if ( yscale == 0) yscale = 1 ;
74 #endif
75 for (i=1; i<=2; ++i)
76 {
77 draw_rectangle((osd[curr_item].pos->x>=i)?osd[curr_item].pos->x-i:0, (osd[curr_item].pos->y>=i)?osd[curr_item].pos->y-i:0,
78 (osd[curr_item].pos->x+SCL(osd[curr_item].size.x,xscale))+i-1,
79 (osd[curr_item].pos->y+SCL(osd[curr_item].size.y,yscale))+i-1,
80 MAKE_COLOR(COLOR_GREEN,COLOR_GREEN), RECT_BORDER1);
81 }
82 sprintf(osd_buf, " %s: x:%d y:%d s:%d f:%d:%d ", lang_str(osd[curr_item].title), osd[curr_item].pos->x, osd[curr_item].pos->y, step, xscale, yscale);
83 draw_string(0, (osd[curr_item].pos->x<strlen(osd_buf)*FONT_WIDTH+4 && osd[curr_item].pos->y<FONT_HEIGHT+4)?camera_screen.height-FONT_HEIGHT:0,
84 osd_buf, MAKE_COLOR(COLOR_RED, COLOR_WHITE));
85 osd_to_draw = 0;
86 }
87 }
88
89 void osd_font_scale(int dir)
90 {
91 int xscale, yscale ;
92
93 xscale = osd[curr_item].scale->x ;
94 yscale = osd[curr_item].scale->y ;
95 switch ((xscale<<4)+yscale)
96 {
97 #if (FONT_HEIGHT > FONT_REAL_HEIGHT)
98 case 0x00 :
99 case 0x01 :
100 case 0x10 :
101 if ( dir>=0) { xscale=1; yscale=1; } else { xscale=0; yscale=0; }
102 break ;
103 #endif
104 case 0x11 :
105 if ( dir>=0) { xscale=2; yscale=1 ; }
106 #if (FONT_HEIGHT > FONT_REAL_HEIGHT)
107 else { xscale=0; yscale=0; }
108 #endif
109 break ;
110 case 0x21 :
111 if ( dir>=0) { xscale=2; yscale=2; } else { xscale=1; yscale=1; }
112 break ;
113 case 0x22 :
114 if ( dir>=0) { xscale=3; yscale=2; } else { xscale=2; yscale=1; }
115 break ;
116 case 0x32 :
117 if ( dir>=0) { xscale=4; yscale=2; } else { xscale=2; yscale=2; }
118 break ;
119 case 0x42 :
120 if ( dir>=0) { xscale=3; yscale=3; } else { xscale=3; yscale=2; }
121 break ;
122 case 0x33 :
123 if ( dir>=0) { xscale=4; yscale=4; } else { xscale=4; yscale=2; }
124 break ;
125 case 0x44 :
126 if ( dir == -1) { xscale=3; yscale=3; }
127 #if (FONT_HEIGHT > FONT_REAL_HEIGHT)
128 else if ( dir == 0) { xscale=0; yscale=0; }
129 #else
130 else if ( dir == 0) { xscale=1; yscale=1; }
131 #endif
132 break ;
133 default :
134 xscale=0; yscale=0 ;
135 break ;
136 }
137 osd[curr_item].scale->x = xscale ;
138 osd[curr_item].scale->y = yscale ;
139 osd_to_draw = 1;
140 }
141
142
143 int gui_osd_kbd_process()
144 {
145 switch (kbd_get_autoclicked_key() | get_jogdial_direction())
146 {
147 case KEY_LEFT:
148 if (osd[curr_item].pos->x > 0)
149 {
150 osd[curr_item].pos->x-=(osd[curr_item].pos->x>=step)?step:osd[curr_item].pos->x;
151 osd_to_draw = 1;
152 }
153 break;
154 case KEY_RIGHT:
155 if (osd[curr_item].pos->x < camera_screen.width-SCL(osd[curr_item].size.x,0))
156 {
157 osd[curr_item].pos->x+=(camera_screen.width-SCL(osd[curr_item].size.x,0)-osd[curr_item].pos->x>step)?step:camera_screen.width-SCL(osd[curr_item].size.x,0)-osd[curr_item].pos->x;
158 osd_to_draw = 1;
159 } else
160 osd[curr_item].pos->x = camera_screen.width-SCL(osd[curr_item].size.x,0);
161 break;
162 case KEY_UP:
163 if (osd[curr_item].pos->y > 0)
164 {
165 osd[curr_item].pos->y-=(osd[curr_item].pos->y>=step)?step:osd[curr_item].pos->y;
166 osd_to_draw = 1;
167 }
168 break;
169 case KEY_DOWN:
170 if (osd[curr_item].pos->y < camera_screen.height-osd[curr_item].size.y)
171 {
172 osd[curr_item].pos->y+=(camera_screen.height-osd[curr_item].size.y-osd[curr_item].pos->y>step)?step:camera_screen.height-osd[curr_item].size.y-osd[curr_item].pos->y;
173 osd_to_draw = 1;
174 } else
175 osd[curr_item].pos->y = camera_screen.height-osd[curr_item].size.y;
176 break;
177 case KEY_SET:
178 ++curr_item;
179 if ((osd[curr_item].title == LANG_OSD_LAYOUT_EDITOR_EV_VIDEO) && !camera_info.cam_ev_in_video) curr_item++;
180 if (!osd[curr_item].pos)
181 curr_item = 0;
182 osd_to_draw = 1;
183 break;
184
185
186 case KEY_VIDEO:
187 case KEY_DISPLAY:
188 step=(step==1)?10:1;
189 osd_to_draw = 1;
190 break;
191 case KEY_SHOOT_HALF:
192 osd_font_scale(0) ;
193 break;
194 case KEY_ZOOM_IN:
195 case JOGDIAL_RIGHT:
196 osd_font_scale(1) ;
197 break;
198 case KEY_ZOOM_OUT:
199 case JOGDIAL_LEFT:
200 osd_font_scale(-1) ;
201 break;
202 }
203 return 0;
204 }
205
206 static int running = 0;
207
208 void gui_osd_menu_kbd_process()
209 {
210 running = 0;
211 gui_default_kbd_process_menu_btn();
212 }
213
214
215
216 gui_handler layoutGuiHandler =
217 {
218
219 GUI_MODE_OSD, gui_osd_draw, gui_osd_kbd_process, gui_osd_menu_kbd_process, 0, GUI_MODE_FLAG_NODRAWRESTORE
220 };
221
222
223
224
225
226
227
228 int _run()
229 {
230 running = 1;
231
232 osd_to_draw = 1;
233 curr_item = 0;
234 step = 10;
235
236 gui_set_mode(&layoutGuiHandler);
237
238 return 0;
239 }
240
241 int _module_can_unload()
242 {
243 return running == 0;
244 }
245
246 int _module_exit_alt()
247 {
248 running = 0;
249 return 0;
250 }
251
252
253
254 libsimple_sym _librun =
255 {
256 {
257 0, 0, _module_can_unload, _module_exit_alt, _run
258 }
259 };
260
261 ModuleInfo _module_info =
262 {
263 MODULEINFO_V1_MAGICNUM,
264 sizeof(ModuleInfo),
265 SIMPLE_MODULE_VERSION,
266
267 ANY_CHDK_BRANCH, 0, OPT_ARCHITECTURE,
268 ANY_PLATFORM_ALLOWED,
269
270 (int32_t)"OSD Editor",
271 MTYPE_EXTENSION,
272
273 &_librun.base,
274
275 CONF_VERSION,
276 CAM_SCREEN_VERSION,
277 ANY_VERSION,
278 CAM_INFO_VERSION,
279
280 0,
281 };
282
283