exposurses

Check-in [878d5d8315]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:For ref: Try separate win and menu functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | temp
Files: files | file ages | folders
SHA3-256: 878d5d8315b891d5147adeb1b27d141b65341c357412fd369ab72147d2e54e13
User & Date: base@atomicules.co.uk 2013-09-11 21:46:00
Context
2013-09-12
11:59
Make the add_menu and add_win subs work Seg faults on exit, but haven't fixed that bit yet. check-in: ecdc9d9bca user: base@atomicules.co.uk tags: trunk, temp
2013-09-11
21:46
For ref: Try separate win and menu functions check-in: 878d5d8315 user: base@atomicules.co.uk tags: trunk, temp
21:44
Add debug options to Makefile check-in: 095cfb3932 user: base@atomicules.co.uk tags: trunk, temp2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to exposurses.c.

    83     83   MENU *aperture_menu;
    84     84   WINDOW *exposure_win;
    85     85   WINDOW *iso_win;
    86     86   WINDOW *shutter_win;
    87     87   WINDOW *aperture_win;
    88     88   
    89     89   void selection(char *name);
    90         -void add_menu(char **array, ITEM **items, MENU *men, WINDOW *win, int n, int xpos, char *title);
    91     90   void remove_menu(ITEM **items, MENU *men, int n);
    92     91   void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
           92  +MENU *add_menu(char **array, ITEM **items, int n);
           93  +WINDOW *add_window(MENU *men, int xpos, char *title);
    93     94   int exposure(int iso);
    94     95   double shutter(int exposure, double aperture);
    95     96   double aperture(int exposure, double shutter);
    96     97   int nearest_match(double x, int menu);
    97     98   double fraction_to_double(char *fraction);
    98     99   /* No one will ever need more than 9 bytes! */
    99    100   char exposure_sel[9] = "";
................................................................................
   124    125   
   125    126   	/* Create items */
   126    127   	/* Can't really avoid finding array sizes here */
   127    128   	n_exposure = ARRAY_SIZE(exposure_array);
   128    129   	n_iso = ARRAY_SIZE(iso_array);
   129    130   	n_shutter = ARRAY_SIZE(shutter_array);
   130    131   	n_aperture = ARRAY_SIZE(aperture_array);
   131         -	add_menu(exposure_array, exposure_items, exposure_menu, exposure_win, n_exposure, 4, "EV");
   132         -	add_menu(iso_array, iso_items, iso_menu, iso_win, n_iso, 45, "ISO");
   133         -	add_menu(shutter_array, shutter_items, shutter_menu, shutter_win, n_shutter, 86, "Shutter");
   134         -	add_menu(aperture_array, aperture_items, aperture_menu, aperture_win, n_aperture, 127, "Aperture");
          132  +	/* http://stackoverflow.com/a/2620158/208793 */
          133  +	exposure_menu = add_menu(exposure_array, exposure_items, n_exposure);
          134  +	iso_menu = add_menu(iso_array, iso_items, n_iso);
          135  +	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
          136  +	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
          137  +	exposure_win = add_window(exposure_menu, 4, "EV");
          138  +	iso_win = add_window(iso_menu, 45, "ISO");
          139  +	shutter_win = add_window(shutter_menu, 86, "Shutter");
          140  +	aperture_win = add_window(aperture_menu, 127, "Aperture");
   135    141   
   136    142   	attron(COLOR_PAIR(2));
   137    143   	mvprintw(LINES - 2, 0, "Select EV");
   138    144   	/*mvprintw(LINES - 2, 0, "Select ISO and then one of Shutter/Aperture to calculate other of Shutter/Aperture");*/
   139    145   	mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit");
   140    146   	attroff(COLOR_PAIR(2));
   141    147   	refresh();
................................................................................
   257    263   	remove_menu(exposure_items, exposure_menu, n_exposure);
   258    264   	remove_menu(iso_items, iso_menu, n_iso);
   259    265   	remove_menu(shutter_items, shutter_menu, n_shutter);
   260    266   	remove_menu(aperture_items, aperture_menu, n_aperture);
   261    267   	endwin();
   262    268   }
   263    269   
   264         -void add_menu(char **array, ITEM **items, MENU *men, WINDOW *win, int n, int xpos, char *title) {
          270  +MENU *add_menu(char **array, ITEM **items, int n) {
   265    271   	int i;
          272  +	MENU *local_menu;
   266    273   
   267    274   	items = (ITEM **)calloc(n, sizeof(ITEM *));
   268    275   	for(i = 0; i<n; ++i) {
   269    276   		items[i] = new_item(array[i], array[i]);
   270    277   		set_item_userptr(items[i], selection);
   271    278   	}
   272         -	men = new_menu((ITEM **)items);
   273         -	win = newwin(10, 40, 4, xpos);
   274         -	keypad(win, TRUE);
   275         -	set_menu_win(men, win);
   276         -	set_menu_sub(men, derwin(win, 6, 38, 3, 1));
   277         -	set_menu_format(men, 5, 1);
   278         -	set_menu_mark(men, " * ");
   279         -	box(win, 0, 0);
   280         -	print_in_middle(win, 1, 0, 40, title, COLOR_PAIR(1));
   281         -	mvwaddch(win, 2, 0, ACS_LTEE);
   282         -	mvwhline(win, 2, 1, ACS_HLINE, 38);
   283         -	mvwaddch(win, 2, 39, ACS_RTEE);
   284         -	post_menu(men);
   285         -	wrefresh(win);
          279  +	local_menu = new_menu((ITEM **)items);
          280  +	set_menu_format(local_menu, 5, 1);
          281  +	set_menu_mark(local_menu, " * ");
          282  +	post_menu(local_menu);
          283  +	return local_menu;
          284  +}
          285  +
          286  +WINDOW *add_window(MENU *men, int xpos, char *title) {
          287  +	WINDOW *local_win;
          288  +
          289  +	local_win = newwin(10, 40, 4, xpos);
          290  +	keypad(local_win, TRUE);
          291  +	set_menu_win(*men, local_win);
          292  +	set_menu_sub(*men, derwin(local_win, 6, 38, 3, 1));
          293  +	box(local_win, 0, 0);
          294  +	print_in_middle(local_win, 1, 0, 40, title, COLOR_PAIR(1));
          295  +	mvwaddch(local_win, 2, 0, ACS_LTEE);
          296  +	mvwhline(local_win, 2, 1, ACS_HLINE, 38);
          297  +	mvwaddch(local_win, 2, 39, ACS_RTEE);
          298  +	wrefresh(local_win);
          299  +	return local_win;
   286    300   }
   287    301   
   288    302   void remove_menu(ITEM **items, MENU *men, int n) {
   289    303   	int i;
   290    304   
   291    305   	unpost_menu(men);
   292    306   	free_menu(men);