exposurses

Check-in [ecdc9d9bca]
Login

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

Overview
Comment:Make the add_menu and add_win subs work Seg faults on exit, but haven't fixed that bit yet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | temp
Files: files | file ages | folders
SHA3-256: ecdc9d9bca4f8499f8e2350f20b3adb512ae350e04e88d7f627367b76e382c16
User & Date: base@atomicules.co.uk 2013-09-12 11:59:15
Context
2013-09-13
09:31
Fix menu numbering (from adding exposure menu in) check-in: b12e9bb5c7 user: base@atomicules.co.uk tags: trunk, temp
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to exposurses.c.

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
130
131
132
133
134
135
136
137
138
139
140
141
















142
143
144
145
146
147
148
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
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
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(MENU *men, 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);
double fraction_to_double(char *fraction);
/* No one will ever need more than 9 bytes! */
char exposure_sel[9] = "";
................................................................................
	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(exposure_menu, 4, "EV");
	iso_win = add_window(iso_menu, 45, "ISO");
	shutter_win = add_window(shutter_menu, 86, "Shutter");
	aperture_win = add_window(aperture_menu, 127, "Aperture");

















	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();

................................................................................
						refresh();
					}
					break;
				}
			}
			break;
		}
		wrefresh(win);
	}	
	/* Unpost and free all the memory taken up */
	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();
................................................................................
	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, " * ");
	post_menu(local_menu);
	return local_menu;
}

WINDOW *add_window(MENU *men, int xpos, char *title) {
	WINDOW *local_win;

	local_win = newwin(10, 40, 4, xpos);
	keypad(local_win, TRUE);
	set_menu_win(*men, local_win);
	set_menu_sub(*men, derwin(local_win, 6, 38, 3, 1));
	box(local_win, 0, 0);
	print_in_middle(local_win, 1, 0, 40, title, COLOR_PAIR(1));
	mvwaddch(local_win, 2, 0, ACS_LTEE);
	mvwhline(local_win, 2, 1, ACS_HLINE, 38);
	mvwaddch(local_win, 2, 39, ACS_RTEE);
	wrefresh(local_win);
	return local_win;
}

void remove_menu(ITEM **items, MENU *men, int n) {
	int i;

	unpost_menu(men);







|







 







|
|
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







<



|




<
<





<







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
130
131
132
133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
...
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
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);
double fraction_to_double(char *fraction);
/* No one will ever need more than 9 bytes! */
char exposure_sel[9] = "";
................................................................................
	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");

	set_menu_win(exposure_menu, exposure_win);
	set_menu_win(iso_menu, iso_win);
	set_menu_win(shutter_menu, shutter_win);
	set_menu_win(aperture_menu, aperture_win);
	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
	set_menu_sub(aperture_menu, derwin(aperture_win, 6, 38, 3, 1));
	post_menu(exposure_menu);
	post_menu(iso_menu);
	post_menu(shutter_menu);
	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();

................................................................................
						refresh();
					}
					break;
				}
			}
			break;
		}
		wrefresh(*win);
	}	
	/* Unpost and free all the memory taken up */
	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();
................................................................................
	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) {
	WINDOW *local_win;

	local_win = newwin(10, 40, 4, xpos);
	keypad(local_win, TRUE);


	box(local_win, 0, 0);
	print_in_middle(local_win, 1, 0, 40, title, COLOR_PAIR(1));
	mvwaddch(local_win, 2, 0, ACS_LTEE);
	mvwhline(local_win, 2, 1, ACS_HLINE, 38);
	mvwaddch(local_win, 2, 39, ACS_RTEE);

	return local_win;
}

void remove_menu(ITEM **items, MENU *men, int n) {
	int i;

	unpost_menu(men);