From ee05f99a3c05b37304ddcce8d9fd3aa9a6d1a6f9 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Sat, 5 Nov 2011 19:43:54 +0800 Subject: [PATCH] Fix implicit function declaration in last commit, make ui_icon_do fully event-responsive --- CHANGELOG.txt | 1 + ui/checkbox.c | 1 + ui/icon.c | 66 ++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ef4e06d24..1a1530db4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ D1X-Rebirth Changelog include/ui.h, ui/button.c, ui/dialog.c, ui/gadget.c, ui/scroll.c, ui/userbox.c: Make B1_JUST_PRESSED event-based, leave ui_dialog_do_gadgets early if a key makes another gadget current, make ui_button_do fully event-responsive (but won't *send* events yet) editor/med.c: Fix crash on exit for non-Linux, when it tries to show an editor warning (unfreed blocks) but doesn't have the images to render it ui/checkbox.c: Make ui_checkbox_do fully event-responsive +ui/checkbox.c, ui/icon.c: Fix implicit function declaration in last commit, make ui_icon_do fully event-responsive 20111103 -------- diff --git a/ui/checkbox.c b/ui/checkbox.c index 6b443b0ab..7a6c4ff8a 100644 --- a/ui/checkbox.c +++ b/ui/checkbox.c @@ -25,6 +25,7 @@ static char rcsid[] = "$Id: checkbox.c,v 1.1.1.1 2006/03/17 19:52:20 zicodxx Exp #include "event.h" #include "gr.h" #include "ui.h" +#include "mouse.h" #include "key.h" #define Middle(x) ((2*(x)+1)/4) diff --git a/ui/icon.c b/ui/icon.c index 76c6e436e..be1681a82 100644 --- a/ui/icon.c +++ b/ui/icon.c @@ -49,6 +49,7 @@ static char rcsid[] = "$Id: icon.c,v 1.1.1.1 2006/03/17 19:39:11 zicodxx Exp $"; #include "event.h" #include "gr.h" #include "ui.h" +#include "mouse.h" #include "key.h" #define Middle(x) ((2*(x)+1)/4) @@ -142,34 +143,61 @@ UI_GADGET_ICON * ui_add_gadget_icon( UI_DIALOG * dlg, char * text, short x, shor int ui_icon_do( UI_GADGET_ICON * icon, d_event *event ) { - int OnMe; - int keypress = 0; int rval = 0; - if (event->type == EVENT_KEY_COMMAND) - keypress = event_key_get(event); - - OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon ); - icon->oldposition = icon->position; - - if ( B1_PRESSED && OnMe ) - { - icon->position = 1; - } else { - icon->position = 0; - } - icon->pressed = 0; - if ((icon->position==0) && (icon->oldposition==1) && OnMe ) - icon->pressed = 1; + if (event->type == EVENT_MOUSE_BUTTON_DOWN || event->type == EVENT_MOUSE_BUTTON_UP) + { + int OnMe; + + OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon ); - if (icon->pressed == 1 || keypress==icon->trap_key ) + if (B1_JUST_PRESSED && OnMe) + { + icon->position = 1; + rval = 1; + } + else if (B1_JUST_RELEASED) + { + if ((icon->position == 1) && OnMe) + icon->pressed = 1; + + icon->position = 0; + } + } + + + if (event->type == EVENT_KEY_COMMAND) + { + int key; + + key = event_key_get(event); + + if (key == icon->trap_key) + { + icon->position = 1; + rval = 1; + } + } + else if (event->type == EVENT_KEY_RELEASE) + { + int key; + + key = event_key_get(event); + + icon->position = 0; + + if (key == icon->trap_key) + icon->pressed = 1; + } + + if (icon->pressed == 1) { icon->status = 1; icon->flag = (sbyte)icon->user_function(); - if (keypress==icon->trap_key) last_keypress = 0; + rval = 1; } ui_draw_icon( icon );