Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Make exposure menu functional
- Make it function so that user is constrained to exposure menu This is not very pretty: - I don't like having both the selection_counter and menu_counter. Seems |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
580afe6ab4978ab68c4f6a0268daf0e9 |
User & Date: | base@atomicules.co.uk 2013-09-10 08:51:12 |
2013-09-18
| ||
10:33 |
For ref: Try wrapping menu and window creation in single function
Got this so it drew everything ok, but segfaults as soon as a key is | |
2013-09-11
| ||
21:41 | For ref: Wrap menu and window creation in function check-in: 284f5d1a81 user: base@atomicules.co.uk tags: temp2, trunk | |
2013-09-10
| ||
13:40 | For ref check-in: de620ef542 user: base@atomicules.co.uk tags: refs/stash, trunk | |
08:51 |
Make exposure menu functional
- Make it function so that user is constrained to exposure menu This is not very pretty: - I don't like having both the selection_counter and menu_counter. Seems | |
2013-09-03
| ||
12:38 |
Add in EV menu, doesn't function yet though
- Add in free memory bits, also missed some for the other menus check-in: 6c315c3200 user: base@atomicules.co.uk tags: origin/master, trunk | |
Changes to exposurses.c.
︙ | ︙ | |||
85 86 87 88 89 90 91 | WINDOW *iso_win; WINDOW *shutter_win; WINDOW *aperture_win; void selection(char *name); void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color); int exposure(int iso); | < > < < | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | WINDOW *iso_win; WINDOW *shutter_win; WINDOW *aperture_win; void selection(char *name); void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color); int exposure(int iso); double shutter(int exposure, double aperture); double aperture(int exposure, double shutter); int nearest_match(double x, int menu); double fraction_to_double(char *fraction); /* No one will ever need more than 9 bytes! */ char exposure_sel[9] = ""; char iso_sel[9] = ""; char shutter_sel[9] = ""; char aperture_sel[9] = ""; int selection_counter = 1; int menu_counter = 1; int main() { int c; MENU **menu; WINDOW **win; int i; int n_exposure; int n_iso; int n_shutter; int n_aperture; /* Initialize curses */ initscr(); start_color(); cbreak(); noecho(); keypad(stdscr, TRUE); |
︙ | ︙ | |||
214 215 216 217 218 219 220 | post_menu(aperture_menu); wrefresh(exposure_win); wrefresh(iso_win); wrefresh(shutter_win); wrefresh(aperture_win); attron(COLOR_PAIR(2)); | > | | | | | < < < < < < | | < < < < < | | < < < < < < < < < < | | < | | | | > > > > > > > | < > > | | < > | < < < < < > | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | > > > > > > > > | | | | > > | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | post_menu(aperture_menu); wrefresh(exposure_win); wrefresh(iso_win); wrefresh(shutter_win); wrefresh(aperture_win); attron(COLOR_PAIR(2)); mvprintw(LINES - 2, 0, "Select EV"); /*mvprintw(LINES - 2, 0, "Select ISO and then one of Shutter/Aperture to calculate other of Shutter/Aperture");*/ mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit"); attroff(COLOR_PAIR(2)); refresh(); /* set default menu */ menu = &exposure_menu; win = &exposure_win; while((c = getch()) != 81) { /* 81 is Q */ switch(c) { case KEY_LEFT: if (selection_counter > 2) { menu_counter = 3; menu = &shutter_menu; win = &shutter_win; } break; case KEY_RIGHT: if (selection_counter > 2) { menu_counter = 4; menu = &aperture_menu; win = &aperture_win; } break; case KEY_DOWN: menu_driver(*menu, REQ_DOWN_ITEM); break; case KEY_UP: menu_driver(*menu, REQ_UP_ITEM); break; case 10: { /* ENTER */ ITEM *cur; void (*p)(char *); cur = current_item(*menu); p = item_userptr(cur); /* Learning notes - Don't understand this bit */ p((char *)item_name(cur)); switch (selection_counter) { case 1: { /* Exposure selected */ selection_counter += 1; menu_counter += 1; move(LINES - 2, 0); clrtoeol(); mvprintw(LINES - 2, 0, "Select ISO"); refresh(); menu = &iso_menu; win = &iso_win; } break; case 2: { /* ISO Selected */ selection_counter += 1; menu_counter += 1; move(LINES - 2, 0); clrtoeol(); mvprintw(LINES - 2, 0, "Select Shutter or Aperture"); refresh(); menu = &shutter_menu; win = &shutter_win; } break; case 3: { /* Shutter or Aperture selected */ if (strcmp("", shutter_sel) == 0) { char aperture_sel_[4] = ""; strncpy(aperture_sel_, aperture_sel+2, 3); /* Using menu_driver to go up/down to force refresh and correct highlighting */ menu_driver(shutter_menu, REQ_SCR_UPAGE); menu_driver(shutter_menu, REQ_SCR_DPAGE); /* There is probably a nicer way to format the below */ set_menu_pattern( shutter_menu, shutter_array[nearest_match( shutter(exposure(atoi(iso_sel)), strtod(aperture_sel_, NULL)), 2 )] ); menu_driver(shutter_menu, REQ_DOWN_ITEM); menu_driver(shutter_menu, REQ_UP_ITEM); wrefresh(shutter_win); } if (strcmp("", aperture_sel) == 0) { menu_driver(aperture_menu, REQ_SCR_UPAGE); menu_driver(aperture_menu, REQ_SCR_DPAGE); set_menu_pattern( aperture_menu, aperture_array[nearest_match( aperture(exposure(atoi(iso_sel)), fraction_to_double(shutter_sel)), 3 )] ); menu_driver(aperture_menu, REQ_DOWN_ITEM); menu_driver(aperture_menu, REQ_UP_ITEM); wrefresh(aperture_win); } /* clear the selections for next time */ strcpy(iso_sel, ""); strcpy(shutter_sel, ""); strcpy(aperture_sel, ""); /* And set defaults back to start */ selection_counter = 1; menu_counter = 1; menu = &exposure_menu; win = &exposure_win; move(LINES - 2, 0); clrtoeol(); mvprintw(LINES - 2, 0, "Select EV"); refresh(); } break; } } break; } wrefresh(*win); } /* Unpost and free all the memory taken up */ unpost_menu(exposure_menu); unpost_menu(iso_menu); unpost_menu(shutter_menu); unpost_menu(aperture_menu); free_menu(exposure_menu); free_menu(iso_menu); free_menu(shutter_menu); free_menu(aperture_menu); |
︙ | ︙ | |||
382 383 384 385 386 387 388 389 390 | wattroff(win, color); refresh(); } void selection(char *name) { switch(menu_counter) { case 1: strcpy(iso_sel, name); break; | > > > | | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | wattroff(win, color); refresh(); } void selection(char *name) { switch(menu_counter) { case 1: strcpy(exposure_sel, name); break; case 2: strcpy(iso_sel, name); break; case 3: strcpy(shutter_sel, name); break; case 4: strcpy(aperture_sel, name); break; } } int exposure (int iso) { int ev100; |
︙ | ︙ | |||
478 479 480 481 482 483 484 | /*then split*/ strncpy(denominator, fraction+2, 5); fraction_as_db = 1 / strtod(denominator, NULL); } else { fraction_as_db = strtod(fraction, NULL); } | | | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | /*then split*/ strncpy(denominator, fraction+2, 5); fraction_as_db = 1 / strtod(denominator, NULL); } else { fraction_as_db = strtod(fraction, NULL); } return fraction_as_db; } /* Debug lines * sprintf(temp, "%f", x); * mvprintw(LINES - 4, 0, temp); * refresh();*/ |