diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5f4d90a26..c706f2cb5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20120305 +-------- +include/ui.h, ui/file.c, ui/gadget.c, ui/keypress.c, ui/listbox.c, ui/menu.c, ui/message.c, ui/popup.c: Use the gadget-sent events in the dialogs in ui + 20120303 -------- d1x-Info.plist, d1xgl-Info.plist, English.lproj/InfoPlist.strings, RELEASE-NOTES.txt: Increment version to 0.57.2 for Mac and RELEASE-NOTES diff --git a/include/ui.h b/include/ui.h index 709a78996..2b39738d3 100644 --- a/include/ui.h +++ b/include/ui.h @@ -278,6 +278,8 @@ extern struct window *ui_dialog_get_window(UI_DIALOG *dlg); extern void ui_dialog_set_current_canvas(UI_DIALOG *dlg); extern void ui_close_dialog( UI_DIALOG * dlg ); +#define GADGET_PRESSED(g) ((event->type == EVENT_UI_GADGET_PRESSED) && (ui_event_get_gadget(event) == (UI_GADGET *)g)) + extern UI_GADGET * ui_gadget_add( UI_DIALOG * dlg, short kind, short x1, short y1, short x2, short y2 ); extern UI_GADGET_BUTTON * ui_add_gadget_button( UI_DIALOG * dlg, short x, short y, short w, short h, char * text, int (*function_to_call)(void) ); extern void ui_gadget_delete_all( UI_DIALOG * dlg ); diff --git a/ui/file.c b/ui/file.c index e13cb4f8e..09958b763 100644 --- a/ui/file.c +++ b/ui/file.c @@ -128,7 +128,7 @@ static int browser_handler(UI_DIALOG *dlg, d_event *event, browser *b) { int rval = 0; - if ( b->button2->pressed ) + if (GADGET_PRESSED(b->button2)) { PHYSFS_freeList(b->filename_list); b->filename_list = NULL; PHYSFS_freeList(b->directory_list); b->directory_list = NULL; @@ -136,35 +136,32 @@ static int browser_handler(UI_DIALOG *dlg, d_event *event, browser *b) return 1; } - if ( b->help_button->pressed ) + if (GADGET_PRESSED(b->help_button)) { MessageBox( -1, -1, 1, "Sorry, no help is available!", "Ok" ); rval = 1; } - if (b->listbox1->moved || b->new_listboxes) + if ((event->type == EVENT_UI_LISTBOX_MOVED) || b->new_listboxes) { if (b->listbox1->current_item >= 0 ) ui_inputbox_set_text(b->user_file, b->filename_list[b->listbox1->current_item]); - rval = 1; - } - - if (b->listbox2->moved || b->new_listboxes) - { + if (b->listbox2->current_item >= 0 ) ui_inputbox_set_text(b->user_file, b->directory_list[b->listbox2->current_item]); + rval = 1; } b->new_listboxes = 0; - if (b->button1->pressed || b->user_file->pressed || (b->listbox1->selected_item > -1 ) || (b->listbox2->selected_item > -1 )) + if (GADGET_PRESSED(b->button1) || GADGET_PRESSED(b->user_file) || (event->type == EVENT_UI_LISTBOX_SELECTED)) { char *p; ui_mouse_hide(); - if (b->listbox2->selected_item > -1 ) - strcpy(b->user_file->text, b->directory_list[b->listbox2->selected_item]); + if (ui_event_get_gadget(event) == (UI_GADGET *)listbox2) + strcpy(b->user_file->text, b->directory_list[b->listbox2->current_item]); strncpy(b->filename, b->view_dir, PATH_MAX); diff --git a/ui/gadget.c b/ui/gadget.c index e6a6e7c05..39460f9c5 100644 --- a/ui/gadget.c +++ b/ui/gadget.c @@ -237,7 +237,7 @@ int ui_gadget_send_event(UI_DIALOG *dlg, event_type type, UI_GADGET *gadget) UI_GADGET *ui_event_get_gadget(d_event *event) { - Assert(event->type == EVENT_UI_GADGET_PRESSED); // more to come? + Assert(event->type >= EVENT_UI_GADGET_PRESSED); // Any UI event return ((event_gadget *) event)->gadget; } diff --git a/ui/keypress.c b/ui/keypress.c index 7b88b0d76..c5fbcc852 100644 --- a/ui/keypress.c +++ b/ui/keypress.c @@ -118,7 +118,7 @@ static int key_dialog_handler(UI_DIALOG *dlg, d_event *event, UI_GADGET_BUTTON * rval = 1; } - if ((*DoneButton)->pressed) + if (GADGET_PRESSED(*DoneButton)) { ui_close_dialog(dlg); rval = 1; diff --git a/ui/listbox.c b/ui/listbox.c index 6448f51fd..fe86fee5a 100644 --- a/ui/listbox.c +++ b/ui/listbox.c @@ -182,8 +182,7 @@ int ui_listbox_do( UI_DIALOG *dlg, UI_GADGET_LISTBOX * listbox, d_event *event ) listbox->old_first_item = listbox->first_item; - if ((event->type == EVENT_UI_GADGET_PRESSED) && - (ui_event_get_gadget(event) == (UI_GADGET *)listbox->scrollbar)) + if (GADGET_PRESSED(listbox->scrollbar)) { listbox->moved = 1; diff --git a/ui/menu.c b/ui/menu.c index 9b938a6ce..1d4a4781f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -44,7 +44,7 @@ static int menu_handler(UI_DIALOG *dlg, d_event *event, menu *m) for (i=0; inum_buttons; i++ ) { - if (m->button_g[i]->pressed) + if (GADGET_PRESSED(m->button_g[i])) { *(m->choice) = i+1; return 1; diff --git a/ui/message.c b/ui/message.c index b9d9c4642..5736071e2 100644 --- a/ui/message.c +++ b/ui/message.c @@ -52,7 +52,7 @@ static int messagebox_handler(UI_DIALOG *dlg, d_event *event, messagebox *m) for (i=0; inum_buttons; i++ ) { - if (m->button_g[i]->pressed) + if (GADGET_PRESSED(m->button_g[i])) { *(m->choice) = i+1; return 1; diff --git a/ui/popup.c b/ui/popup.c index bd8129dfa..e5b40211a 100644 --- a/ui/popup.c +++ b/ui/popup.c @@ -41,7 +41,7 @@ static int popup_handler(UI_DIALOG *dlg, d_event *event, popup *p) for (i=0; inum_buttons; i++ ) { - if (p->button_g[i]->pressed) + if (GADGET_PRESSED(p->button_g[i])) { *(p->choice) = i+1; return 1;