Fix implicit function declaration in last commit, make ui_icon_do fully event-responsive

This commit is contained in:
Chris Taylor 2011-11-05 19:43:54 +08:00
parent d2d68bc4ee
commit ee05f99a3c
3 changed files with 49 additions and 19 deletions

View file

@ -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
--------

View file

@ -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)

View file

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