exposurses

Check-in [c2741c67e7]
Login

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

Overview
Comment:Make the add_menu and add_win subs work I was still using the "variable pointers" technique, well trying to, and it wasn't working for things like `set_menu_win` so pull this back out into main. Seg faults on exit, but haven't fixed that bit yet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: c2741c67e786c6913fc647bd699e16a141e9c1eece410e4ddee6f56776417f14
User & Date: base@atomicules.co.uk 2013-09-18 11:01:38
Original User & Date: base@atomicules.co.uk 2013-09-18 11:01:39
Context
2013-09-18
11:01
Fix menu numbering (from adding exposure menu in) Didn't change functionality (it was still working), but just gives better consistency to the code. check-in: 4a3cabadc2 user: base@atomicules.co.uk tags: origin/master, trunk
11:01
Make the add_menu and add_win subs work I was still using the "variable pointers" technique, well trying to, and it wasn't working for things like `set_menu_win` so pull this back out into main. Seg faults on exit, but haven't fixed that bit yet. check-in: c2741c67e7 user: base@atomicules.co.uk tags: origin/master, trunk
11:01
Try separate win and menu functions instead of trying to wrap everything in one. This way I know I can return the correct thing and I know I'm setting things as expected. As opposed to previous attempt where I was (trying) to use variable pointers, but with pointers to pointers, etc. And was obviously a bit beyond me. check-in: e4268c4b4e user: base@atomicules.co.uk tags: origin/master, trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to exposurses.c.

    86     86   WINDOW *shutter_win;
    87     87   WINDOW *aperture_win;
    88     88   
    89     89   void selection(char *name);
    90     90   void remove_menu(ITEM **items, MENU *men, int n);
    91     91   void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
    92     92   MENU *add_menu(char **array, ITEM **items, int n);
    93         -WINDOW *add_window(MENU *men, int xpos, char *title);
           93  +WINDOW *add_window(int xpos, char *title);
    94     94   int exposure(int iso);
    95     95   double shutter(int exposure, double aperture);
    96     96   double aperture(int exposure, double shutter);
    97     97   int nearest_match(double x, int menu);
    98     98   double fraction_to_double(char *fraction);
    99     99   /* No one will ever need more than 9 bytes! */
   100    100   char exposure_sel[9] = "";
................................................................................
   129    129   	n_iso = ARRAY_SIZE(iso_array);
   130    130   	n_shutter = ARRAY_SIZE(shutter_array);
   131    131   	n_aperture = ARRAY_SIZE(aperture_array);
   132    132   	exposure_menu = add_menu(exposure_array, exposure_items, n_exposure);
   133    133   	iso_menu = add_menu(iso_array, iso_items, n_iso);
   134    134   	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
   135    135   	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
   136         -	exposure_win = add_window(exposure_menu, 4, "EV");
   137         -	iso_win = add_window(iso_menu, 45, "ISO");
   138         -	shutter_win = add_window(shutter_menu, 86, "Shutter");
   139         -	aperture_win = add_window(aperture_menu, 127, "Aperture");
   140         -
          136  +	exposure_win = add_window(4, "EV");
          137  +	iso_win = add_window(45, "ISO");
          138  +	shutter_win = add_window(86, "Shutter");
          139  +	aperture_win = add_window(127, "Aperture");
          140  +	set_menu_win(exposure_menu, exposure_win);
          141  +	set_menu_win(iso_menu, iso_win);
          142  +	set_menu_win(shutter_menu, shutter_win);
          143  +	set_menu_win(aperture_menu, aperture_win);
          144  +	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
          145  +	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
          146  +	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
          147  +	set_menu_sub(aperture_menu, derwin(aperture_win, 6, 38, 3, 1));
          148  +	post_menu(exposure_menu);
          149  +	post_menu(iso_menu);
          150  +	post_menu(shutter_menu);
          151  +	post_menu(aperture_menu);
          152  +	wrefresh(exposure_win);
          153  +	wrefresh(iso_win);
          154  +	wrefresh(shutter_win);
          155  +	wrefresh(aperture_win);
   141    156   	attron(COLOR_PAIR(2));
   142    157   	mvprintw(LINES - 2, 0, "Select EV");
   143    158   	/*mvprintw(LINES - 2, 0, "Select ISO and then one of Shutter/Aperture to calculate other of Shutter/Aperture");*/
   144    159   	mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit");
   145    160   	attroff(COLOR_PAIR(2));
   146    161   	refresh();
   147    162   
................................................................................
   274    289   	for(i = 0; i<n; ++i) {
   275    290   		items[i] = new_item(array[i], array[i]);
   276    291   		set_item_userptr(items[i], selection);
   277    292   	}
   278    293   	local_menu = new_menu((ITEM **)items);
   279    294   	set_menu_format(local_menu, 5, 1);
   280    295   	set_menu_mark(local_menu, " * ");
   281         -	post_menu(local_menu);
   282    296   	return local_menu;
   283    297   }
   284    298   
   285         -WINDOW *add_window(MENU *men, int xpos, char *title) {
          299  +WINDOW *add_window(int xpos, char *title) {
   286    300   	WINDOW *local_win;
   287    301   
   288    302   	local_win = newwin(10, 40, 4, xpos);
   289    303   	keypad(local_win, TRUE);
   290         -	set_menu_win(*men, local_win);
   291         -	set_menu_sub(*men, derwin(local_win, 6, 38, 3, 1));
   292    304   	box(local_win, 0, 0);
   293    305   	print_in_middle(local_win, 1, 0, 40, title, COLOR_PAIR(1));
   294    306   	mvwaddch(local_win, 2, 0, ACS_LTEE);
   295    307   	mvwhline(local_win, 2, 1, ACS_HLINE, 38);
   296    308   	mvwaddch(local_win, 2, 39, ACS_RTEE);
   297         -	wrefresh(local_win);
   298    309   	return local_win;
   299    310   }
   300    311   
   301    312   void remove_menu(ITEM **items, MENU *men, int n) {
   302    313   	int i;
   303    314   
   304    315   	unpost_menu(men);