exposurses

Check-in [cf92beadf9]
Login

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

Overview
Comment:Split out ITEM creation into separate func so can clean on exit As otherwise can't free up the memory, etc. This makes clean up work Yay, pretty much done.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk | temp
Files: files | file ages | folders
SHA3-256: cf92beadf96dd867d8220f8131a3e2ff5bf77cea38d475ea75ed31f9521625ab
User & Date: base@atomicules.co.uk 2013-09-17 22:43:51
Context
2013-09-17
22:43
Split out ITEM creation into separate func so can clean on exit As otherwise can't free up the memory, etc. This makes clean up work Yay, pretty much done. Leaf check-in: cf92beadf9 user: base@atomicules.co.uk tags: trunk, temp
2013-09-15
21:25
Ignore selection of OVER/UNDER check-in: d4b0749e89 user: base@atomicules.co.uk tags: trunk, temp
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to exposurses.c.

85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
...
126
127
128
129
130
131
132




133
134
135
136
137
138
139
140
141
142
143
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309






310
311
312
313
314
315
316
WINDOW *iso_win;
WINDOW *shutter_win;
WINDOW *aperture_win;

void selection(char *name);
void remove_menu(ITEM **items, MENU *men, int n);
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
MENU *add_menu(char **array, ITEM **items, int n);
WINDOW *add_window(int xpos, char *title);

int exposure(int iso);
double shutter(int exposure, double aperture);
double aperture(int exposure, double shutter);
int nearest_match(double x, int menu, int n_array);
double fraction_to_double(char *fraction);
/* No one will ever need more than 9 bytes! */
char exposure_sel[9] = "";
................................................................................
	/* Create items */
	/* Can't really avoid finding array sizes here */
	n_exposure = ARRAY_SIZE(exposure_array);
	n_iso = ARRAY_SIZE(iso_array);
	n_shutter = ARRAY_SIZE(shutter_array);
	n_aperture = ARRAY_SIZE(aperture_array);
	/* http://stackoverflow.com/a/2620158/208793 */




	exposure_menu = add_menu(exposure_array, exposure_items, n_exposure);
	iso_menu = add_menu(iso_array, iso_items, n_iso);
	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
	exposure_win = add_window(4, "EV");
	iso_win = add_window(45, "ISO");
	shutter_win = add_window(86, "Shutter");
	aperture_win = add_window(127, "Aperture");
	/* Don't know how to avoid the repition below */
	set_menu_win(exposure_menu, exposure_win);
	set_menu_win(iso_menu, iso_win);
................................................................................
	remove_menu(exposure_items, exposure_menu, n_exposure);
	remove_menu(iso_items, iso_menu, n_iso);
	remove_menu(shutter_items, shutter_menu, n_shutter);
	remove_menu(aperture_items, aperture_menu, n_aperture);
	endwin();
}

MENU *add_menu(char **array, ITEM **items, int n) {
	int i;
	MENU *local_menu;

	items = (ITEM **)calloc(n, sizeof(ITEM *));
	for(i = 0; i<n; ++i) {
		items[i] = new_item(array[i], array[i]);
		set_item_userptr(items[i], selection);
	}






	local_menu = new_menu((ITEM **)items);
	set_menu_format(local_menu, 5, 1);
	set_menu_mark(local_menu, " * ");
	return local_menu;
}

WINDOW *add_window(int xpos, char *title) {







|

>







 







>
>
>
>
|
|
|
|







 







|

|

|

|
|

>
>
>
>
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
...
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
WINDOW *iso_win;
WINDOW *shutter_win;
WINDOW *aperture_win;

void selection(char *name);
void remove_menu(ITEM **items, MENU *men, int n);
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
MENU *add_menu(ITEM **items);
WINDOW *add_window(int xpos, char *title);
ITEM **add_item(char **array, int n);
int exposure(int iso);
double shutter(int exposure, double aperture);
double aperture(int exposure, double shutter);
int nearest_match(double x, int menu, int n_array);
double fraction_to_double(char *fraction);
/* No one will ever need more than 9 bytes! */
char exposure_sel[9] = "";
................................................................................
	/* Create items */
	/* Can't really avoid finding array sizes here */
	n_exposure = ARRAY_SIZE(exposure_array);
	n_iso = ARRAY_SIZE(iso_array);
	n_shutter = ARRAY_SIZE(shutter_array);
	n_aperture = ARRAY_SIZE(aperture_array);
	/* http://stackoverflow.com/a/2620158/208793 */
	exposure_items = add_item(exposure_array, n_exposure);
	iso_items = add_item(iso_array, n_iso);
	aperture_items = add_item(aperture_array, n_aperture);
	shutter_items = add_item(shutter_array, n_shutter);
	exposure_menu = add_menu(exposure_items);
	iso_menu = add_menu(iso_items);
	shutter_menu = add_menu(shutter_items);
	aperture_menu = add_menu(aperture_items);
	exposure_win = add_window(4, "EV");
	iso_win = add_window(45, "ISO");
	shutter_win = add_window(86, "Shutter");
	aperture_win = add_window(127, "Aperture");
	/* Don't know how to avoid the repition below */
	set_menu_win(exposure_menu, exposure_win);
	set_menu_win(iso_menu, iso_win);
................................................................................
	remove_menu(exposure_items, exposure_menu, n_exposure);
	remove_menu(iso_items, iso_menu, n_iso);
	remove_menu(shutter_items, shutter_menu, n_shutter);
	remove_menu(aperture_items, aperture_menu, n_aperture);
	endwin();
}

ITEM **add_item(char **array, int n) {
	int i;
	ITEM **local_items;

	local_items = (ITEM **)calloc(n, sizeof(ITEM *));
	for(i = 0; i<n; ++i) {
		local_items[i] = new_item(array[i], array[i]);
		set_item_userptr(local_items[i], selection);
	}
	return local_items;
}

MENU *add_menu(ITEM **items) {
	MENU *local_menu;

	local_menu = new_menu((ITEM **)items);
	set_menu_format(local_menu, 5, 1);
	set_menu_mark(local_menu, " * ");
	return local_menu;
}

WINDOW *add_window(int xpos, char *title) {