[AD] Grabber - options dialog box (Was: Relatives paths in the grabber)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


As discussed a couple of weeks ago, I modified the grabber interface by 
moving the property checkboxes and such to a seperate dialog box to make 
room for future extensions (which I'm busy rewriting).
Patch against todays CVS attached. This leaves most of the formerly 
cluttered top screen of the grabber barren and empty, which is quite ugly. 
The selection list and properties list could be moved upward a little to 
cover this, though.
I'll also post a patch for relative paths and an improved version of my 
symlink patch hopefully later this week.

-- 
Evert Glebbeek
e-mail: eglebbk@xxxxxxxxxx   ICQ: 48210348
www: http://www.science.uva.nl/~eglebbk/ 


--- allegro_cvs/tools/grabber.c	Sun May 12 00:46:42 2002
+++ allegro/tools/grabber.c	Sun May 12 23:46:16 2002
@@ -194,22 +194,8 @@
    { d_menu_proc,       0,    0,    0,    0,    0,    0,    0,       0,          0,             0,       menu,             NULL, NULL  },
    { d_text_proc,       20,   30,   0,    0,    0,    0,    0,       0,          0,             0,       "Editing:",       NULL, NULL  },
    { edit_mod_proc,     100,  30,   320,  8,    0,    0,    0,       0,          255,           0,       data_file,        NULL, NULL  },
-   { d_text_proc,       20,   42,   0,    0,    0,    0,    0,       0,          0,             0,       "Header:",        NULL, NULL  },
-   { edit_mod_proc,     100,  42,   320,  8,    0,    0,    0,       0,          255,           0,       header_file,      NULL, NULL  },
-   { d_text_proc,       20,   54,   0,    0,    0,    0,    0,       0,          0,             0,       "Prefix:",        NULL, NULL  },
-   { edit_mod_proc,     100,  54,   320,  8,    0,    0,    0,       0,          255,           0,       prefix_string,    NULL, NULL  },
-   { d_text_proc,       20,   66,   0,    0,    0,    0,    0,       0,          0,             0,       "Password:",      NULL, NULL  },
-   { edit_mod_proc,     100,  66,   320,  8,    0,    0,    0,       0,          255,           0,       password,         NULL, NULL  },
-   { d_text_proc,       200,  10,   0,    0,    0,    0,    0,       0,          0,             0,       "X-grid:",        NULL, NULL  },
-   { d_edit_proc,       264,  10,   40,   8,    0,    0,    0,       0,          4,             0,       xgrid_string,     NULL, NULL  },
-   { d_text_proc,       315,  10,   0,    0,    0,    0,    0,       0,          0,             0,       "Y-grid:",        NULL, NULL  },
-   { d_edit_proc,       379,  10,   40,   8,    0,    0,    0,       0,          4,             0,       ygrid_string,     NULL, NULL  },
-   { d_check_proc,      430,  8,    83,   13,   0,    0,    0,       0,          0,             0,       "Backups:",       NULL, NULL  },
-   { colorconv_proc,    550,  8,    75,   13,   0,    0,    0,       0,          0,             0,       "Dither:",        NULL, NULL  },
-   { sort_proc,         430,  24,   59,   13,   0,    0,    0,       D_SELECTED, 0,             1,       "Sort:",          NULL, NULL  },
-   { colorconv_proc,    502,  24,   123,  13,   0,    0,    0,       0,          0,             1,       "Transparency:",  NULL, NULL  },
-   { droplist_mod_proc, 430,  48,   195,  28,   0,    0,    0,       0,          0,             0,       pack_getter,      NULL, NULL  },
    { prop_proc,         260,  86,   365,  107,  0,    0,    0,       D_EXIT,     0,             0,       prop_getter,      NULL, NULL  },
+   { d_button_proc,     24,   40,   114,  16,   0,    0,    0,       D_EXIT,     0,             0,       "Options...",     NULL, NULL  },   
    { d_keyboard_proc,   0,    0,    0,    0,    0,    0,    C('l'),  0,          0,             0,       loader,           NULL, NULL  },
    { d_keyboard_proc,   0,    0,    0,    0,    0,    0,    C('s'),  0,          0,             0,       saver,            NULL, NULL  },
    { d_keyboard_proc,   0,    0,    0,    0,    0,    0,    C('u'),  0,          0,             0,       updater,          NULL, NULL  },
@@ -247,23 +233,50 @@
 
 
 
-#define DLG_FILENAME          3
-#define DLG_HEADERNAME        5
-#define DLG_PREFIXSTRING      7
-#define DLG_PASSWORD          9
-#define DLG_XGRIDSTRING       11
-#define DLG_YGRIDSTRING       13
-#define DLG_BACKUPCHECK       14
-#define DLG_DITHERCHECK       15
-#define DLG_SORTCHECK         16
-#define DLG_TRANSCHECK        17
-#define DLG_PACKLIST          18
-#define DLG_PROP              19
-#define DLG_FIRSTWHITE        20
-#define DLG_LIST              50
-#define DLG_VIEW              51
+static DIALOG options_dlg[] =
+{
+   /* (dialog proc)     (x)   (y)   (w)   (h)   (fg)  (bg)  (key)    (flags)     (d1)           (d2)     (dp)              (dp2) (dp3) */
+   { d_shadow_box_proc, 0,    0,    424,  240,  0,    0,    0,       0,          0,             0,       NULL,             NULL, NULL  },
+   { d_ctext_proc,      212,  4,    0,    0,    0,    0,    0,       0,          0,             0,       "Datafile options",NULL, NULL },
+   { d_text_proc,       20,   16,   0,    0,    0,    0,    0,       0,          0,             0,       "Header:",        NULL, NULL  },
+   { edit_mod_proc,     100,  16,   320,  8,    0,    0,    0,       0,          255,           0,       header_file,      NULL, NULL  },
+   { d_text_proc,       20,   28,   0,    0,    0,    0,    0,       0,          0,             0,       "Prefix:",        NULL, NULL  },
+   { edit_mod_proc,     100,  28,   320,  8,    0,    0,    0,       0,          255,           0,       prefix_string,    NULL, NULL  },
+   { d_text_proc,       20,   40,   0,    0,    0,    0,    0,       0,          0,             0,       "Password:",      NULL, NULL  },
+   { edit_mod_proc,     100,  40,   320,  8,    0,    0,    0,       0,          255,           0,       password,         NULL, NULL  },
+   { d_text_proc,       20,   52,   0,    0,    0,    0,    0,       0,          0,             0,       "X-grid:",        NULL, NULL  },
+   { d_edit_proc,       84,   52,   40,   8,    0,    0,    0,       0,          4,             0,       xgrid_string,     NULL, NULL  },
+   { d_text_proc,       135,  52,   0,    0,    0,    0,    0,       0,          0,             0,       "Y-grid:",        NULL, NULL  },
+   { d_edit_proc,       199,  52,   40,   8,    0,    0,    0,       0,          4,             0,       ygrid_string,     NULL, NULL  },
+   { d_check_proc,      30,   100,  83,   13,   0,    0,    0,       0,          1,             0,       "Keep backups",   NULL, NULL  },
+   { colorconv_proc,    30,   116,  75,   13,   0,    0,    0,       0,          1,             0,       "Dither images",  NULL, NULL  },
+   { sort_proc,         30,   132,  59,   13,   0,    0,    0,       D_SELECTED, 1,             1,       "Sort datafile",  NULL, NULL  },
+   { colorconv_proc,    30,   148,  123,  13,   0,    0,    0,       0,          1,             1,       "Preserve transparency",NULL, NULL  },
+   { droplist_mod_proc, 214,  64,   195,  28,   0,    0,    0,       0,          0,             0,       pack_getter,      NULL, NULL  },
+   { d_button_proc,     155,  216,  114,  16,   0,    0,    0,       D_EXIT,     0,             0,       "&Ok",            NULL, NULL  },
+   { NULL,              0,    0,    0,    0,    0,    0,    0,       0,          0,             0,       NULL,             NULL, NULL  }
+};
 
 
+
+#define DLG_HEADERNAME        3
+#define DLG_PREFIXSTRING      5
+#define DLG_PASSWORD          7
+#define DLG_XGRIDSTRING       9
+#define DLG_YGRIDSTRING       11
+#define DLG_BACKUPCHECK       12
+#define DLG_DITHERCHECK       13
+#define DLG_SORTCHECK         14
+#define DLG_TRANSCHECK        15
+#define DLG_PACKLIST          16
+
+#define DLG_FILENAME          3
+#define DLG_PROP              4
+#define DLG_OPTBUTTON         5
+#define DLG_FIRSTWHITE        5
+#define DLG_LIST              36
+#define DLG_VIEW              37
+
 #define SELECTED_ITEM         main_dlg[DLG_LIST].d1
 #define SELECTED_PROPERTY     main_dlg[DLG_PROP].d1
 
@@ -861,6 +874,8 @@
    main_dlg[DLG_FIRSTWHITE].proc = proc;
    set_dialog_color(main_dlg+DLG_FIRSTWHITE, gui_fg_color, gui_bg_color);
 
+   set_dialog_color(options_dlg, gui_fg_color, gui_bg_color);
+   
    if (!my_mouse_pointer)
       my_mouse_pointer = create_bitmap(16, 16);
 
@@ -1303,7 +1318,7 @@
 
    if (type == DAT_NAME) {
       check_valid_name(val);
-      if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+      if (options_dlg[DLG_SORTCHECK].flags & D_SELECTED)
          datedit_sort_datafile(*dat->parent);
       rebuild_list(old, TRUE);
    }
@@ -1635,18 +1650,18 @@
    datedit_set_property(&datedit_info, DAT_YGRD, ygrid_string);
 
    datedit_set_property(&datedit_info, DAT_BACK, 
-		  (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (options_dlg[DLG_BACKUPCHECK].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_DITH, 
-		  (main_dlg[DLG_DITHERCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (options_dlg[DLG_DITHERCHECK].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_TRAN, 
-		  (main_dlg[DLG_TRANSCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (options_dlg[DLG_TRANSCHECK].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_SORT, 
-		  (main_dlg[DLG_SORTCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (options_dlg[DLG_SORTCHECK].flags & D_SELECTED) ? "y" : "n");
 
-   sprintf(buf, "%d", main_dlg[DLG_PACKLIST].d1);
+   sprintf(buf, "%d", options_dlg[DLG_PACKLIST].d1);
    datedit_set_property(&datedit_info, DAT_PACK, buf);
 }
 
@@ -1658,11 +1673,11 @@
    AL_CONST char *p = get_datafile_property(&datedit_info, type);
 
    if ((p) && (*p))
-      strcpy(main_dlg[object].dp, p);
+      strcpy(options_dlg[object].dp, p);
    else
-      strcpy(main_dlg[object].dp, def);
+      strcpy(options_dlg[object].dp, def);
 
-   main_dlg[object].d2 = strlen(main_dlg[object].dp);
+   main_dlg[object].d2 = strlen(options_dlg[object].dp);
 }
 
 
@@ -1735,31 +1750,31 @@
    retrieve_property(DLG_YGRIDSTRING, DAT_YGRD, "16");
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_BACK)) == 'y')
-      main_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
+      options_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
    else
-      main_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
+      options_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_DITH)) == 'y')
-      main_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
+      options_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
    else
-      main_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
+      options_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_TRAN)) == 'y')
-      main_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
+      options_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
    else
-      main_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
+      options_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
 
    if (sort)
-      main_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
+      options_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
    else
-      main_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
+      options_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
 
-   main_dlg[DLG_PACKLIST].d1 = atoi(get_datafile_property(&datedit_info, DAT_PACK));
+   options_dlg[DLG_PACKLIST].d1 = atoi(get_datafile_property(&datedit_info, DAT_PACK));
    pack_getter(-1, &items_num);
-   if (main_dlg[DLG_PACKLIST].d1 >= items_num)
-      main_dlg[DLG_PACKLIST].d1 = items_num-1;
-   else if (main_dlg[DLG_PACKLIST].d1 < 0)
-      main_dlg[DLG_PACKLIST].d1 = 0;
+   if (options_dlg[DLG_PACKLIST].d1 >= items_num)
+      options_dlg[DLG_PACKLIST].d1 = items_num-1;
+   else if (options_dlg[DLG_PACKLIST].d1 < 0)
+      options_dlg[DLG_PACKLIST].d1 = 0;
 
    rebuild_list(NULL, TRUE);
 
@@ -1833,7 +1848,7 @@
 
       update_info();
 
-      if (!datedit_save_datafile(datafile, data_file, strip, NULL, -1, -1, TRUE, FALSE, (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED), password))
+      if (!datedit_save_datafile(datafile, data_file, strip, NULL, -1, -1, TRUE, FALSE, (options_dlg[DLG_BACKUPCHECK].flags & D_SELECTED), password))
 	 err = TRUE;
       else
 	 set_modified(FALSE);
@@ -2814,7 +2829,7 @@
 	    df = dat->parent;
 
 	 *df = datedit_insert(*df, NULL, prop_value_string, type, v, size);
-	 if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+	 if (options_dlg[DLG_SORTCHECK].flags & D_SELECTED)
 	    datedit_sort_datafile(*df);
 	 rebuild_list(v, TRUE);
 	 select_property(DAT_NAME);
@@ -3144,6 +3159,7 @@
    int bpp = -1;
    int w = 640;
    int h = 480;
+   int focus = -1;
    char *s, tmp[256];
    char *fname = NULL;
    static int color_depths[] = { 32, 16, 15, 8, 0 };
@@ -3251,32 +3267,35 @@
    main_dlg[0].w = SCREEN_W;
    main_dlg[0].h = SCREEN_H;
 
+   centre_dialog(options_dlg);
+   
    if (SCREEN_W < 640) {
-      for (i=DLG_FILENAME-1; i<DLG_PASSWORD; i+=2)
+      for (i=DLG_FILENAME-1; i<DLG_PROP; i+=2)
 	 main_dlg[i].x = main_dlg[i].x * SCREEN_W / 640;
-
+      
       main_dlg[DLG_FILENAME].w = SCREEN_W / 3;
-      main_dlg[DLG_HEADERNAME].w = SCREEN_W / 3;
-      main_dlg[DLG_PREFIXSTRING].w = SCREEN_W / 3;
-      main_dlg[DLG_PASSWORD].w = SCREEN_W / 3;
-
-      main_dlg[DLG_XGRIDSTRING-1].dp = "X:";
-      main_dlg[DLG_XGRIDSTRING-1].x -= 16;
-      main_dlg[DLG_XGRIDSTRING].x -= 56;
-
-      main_dlg[DLG_YGRIDSTRING-1].dp = "Y:";
-      main_dlg[DLG_YGRIDSTRING-1].x -= 64;
-      main_dlg[DLG_YGRIDSTRING].x -= 104;
-
-      main_dlg[DLG_BACKUPCHECK].x = main_dlg[DLG_BACKUPCHECK].x * SCREEN_W / 640;
-      main_dlg[DLG_BACKUPCHECK].y += 20;
-
-      main_dlg[DLG_DITHERCHECK].flags |= (D_HIDDEN | D_DISABLED);
-      main_dlg[DLG_TRANSCHECK].flags |= (D_HIDDEN | D_DISABLED);
-      main_dlg[DLG_SORTCHECK].flags |= (D_HIDDEN | D_DISABLED);
+      
+      options_dlg[DLG_HEADERNAME].w = SCREEN_W / 3;
+      options_dlg[DLG_PREFIXSTRING].w = SCREEN_W / 3;
+      options_dlg[DLG_PASSWORD].w = SCREEN_W / 3;
+
+      options_dlg[DLG_XGRIDSTRING-1].dp = "X:";
+      options_dlg[DLG_XGRIDSTRING-1].x -= 16;
+      options_dlg[DLG_XGRIDSTRING].x -= 56;
+
+      options_dlg[DLG_YGRIDSTRING-1].dp = "Y:";
+      options_dlg[DLG_YGRIDSTRING-1].x -= 64;
+      options_dlg[DLG_YGRIDSTRING].x -= 104;
+
+      options_dlg[DLG_BACKUPCHECK].x = options_dlg[DLG_BACKUPCHECK].x * SCREEN_W / 640;
+      options_dlg[DLG_BACKUPCHECK].y += 20;
+
+      options_dlg[DLG_DITHERCHECK].flags |= (D_HIDDEN | D_DISABLED);
+      options_dlg[DLG_TRANSCHECK].flags |= (D_HIDDEN | D_DISABLED);
+      options_dlg[DLG_SORTCHECK].flags |= (D_HIDDEN | D_DISABLED);
 
-      main_dlg[DLG_PACKLIST].x = main_dlg[DLG_PACKLIST].x * SCREEN_W / 640;
-      main_dlg[DLG_PACKLIST].w = main_dlg[DLG_PACKLIST].w * SCREEN_W / 640;
+      options_dlg[DLG_PACKLIST].x = options_dlg[DLG_PACKLIST].x * SCREEN_W / 640;
+      options_dlg[DLG_PACKLIST].w = options_dlg[DLG_PACKLIST].w * SCREEN_W / 640;
 
       for (i=DLG_PROP; main_dlg[i].proc; i++) {
 	 main_dlg[i].x = main_dlg[i].x * SCREEN_W / 640;
@@ -3298,7 +3317,7 @@
       while (main_dlg[DLG_LIST].y + main_dlg[DLG_LIST].h >= SCREEN_H)
 	 main_dlg[DLG_LIST].h -= 8;
 
-      for (i=DLG_BACKUPCHECK; main_dlg[i].proc; i++) {
+      for (i=DLG_PROP; main_dlg[i].proc; i++) {
 	 if (i != DLG_LIST)
 	    main_dlg[i].x = main_dlg[i].x * SCREEN_W / 640;
 	 main_dlg[i].w = main_dlg[i].w * SCREEN_W / 640;
@@ -3341,7 +3360,7 @@
 
    for (i=0; datedit_menu_info[i]; i++) {
       MENU tmpmenu;
-
+   
       tmpmenu.text = datedit_menu_info[i]->menu->text;
       tmpmenu.proc = hooker;
       tmpmenu.child = datedit_menu_info[i]->menu->child;
@@ -3392,27 +3411,37 @@
       sprintf(ygrid_string, "%d", get_config_int("grabber", "ygrid", 16));
 
       if (strpbrk(get_config_string("grabber", "backups", ""), "yY1"))
-         main_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
+         options_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
       else
-         main_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
+         options_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "dither", ""), "yY1"))
-         main_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
+         options_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
       else
-         main_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
+         options_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "sort", ""), "yY1"))
-         main_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
+         options_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
       else
-         main_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
+         options_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "transparency", ""), "yY1"))
-         main_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
+         options_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
       else
-         main_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
+         options_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
    }
 
-   do_dialog(main_dlg, DLG_LIST);
+   focus = DLG_LIST;
+   do {
+      main_dlg[DLG_OPTBUTTON].flags &= ~D_SELECTED;
+      ret = do_dialog(main_dlg, focus);
+      focus = find_dialog_focus(main_dlg);
+      
+      if (ret == DLG_OPTBUTTON) {
+         do_dialog(options_dlg, -1);
+      }
+   } while (ret==DLG_OPTBUTTON);
+
 
    if (datafile)
       unload_datafile(datafile);
@@ -3429,22 +3458,22 @@
    set_config_string("grabber", "xgrid", xgrid_string);
    set_config_string("grabber", "ygrid", ygrid_string);
 
-   if (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED)
+   if (options_dlg[DLG_BACKUPCHECK].flags & D_SELECTED)
       set_config_string("grabber", "backups", "y");
    else
       set_config_string("grabber", "backups", "n");
 
-   if (main_dlg[DLG_DITHERCHECK].flags & D_SELECTED)
+   if (options_dlg[DLG_DITHERCHECK].flags & D_SELECTED)
       set_config_string("grabber", "dither", "y");
    else
       set_config_string("grabber", "dither", "n");
 
-   if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+   if (options_dlg[DLG_SORTCHECK].flags & D_SELECTED)
       set_config_string("grabber", "sort", "y");
    else
       set_config_string("grabber", "sort", "n");
 
-   if (main_dlg[DLG_TRANSCHECK].flags & D_SELECTED)
+   if (options_dlg[DLG_TRANSCHECK].flags & D_SELECTED)
       set_config_string("grabber", "transparency", "y");
    else
       set_config_string("grabber", "transparency", "n");


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/