Fix implicit function declaration in last commit, make ui_icon_do fully event-responsive
This commit is contained in:
parent
d2d68bc4ee
commit
ee05f99a3c
|
@ -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)
|
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
|
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: 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
|
20111103
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -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 "event.h"
|
||||||
#include "gr.h"
|
#include "gr.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
#include "mouse.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
|
||||||
#define Middle(x) ((2*(x)+1)/4)
|
#define Middle(x) ((2*(x)+1)/4)
|
||||||
|
|
58
ui/icon.c
58
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 "event.h"
|
||||||
#include "gr.h"
|
#include "gr.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
#include "mouse.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
|
||||||
#define Middle(x) ((2*(x)+1)/4)
|
#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 ui_icon_do( UI_GADGET_ICON * icon, d_event *event )
|
||||||
{
|
{
|
||||||
int OnMe;
|
|
||||||
int keypress = 0;
|
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
|
|
||||||
if (event->type == EVENT_KEY_COMMAND)
|
icon->oldposition = icon->position;
|
||||||
keypress = event_key_get(event);
|
icon->pressed = 0;
|
||||||
|
|
||||||
|
if (event->type == EVENT_MOUSE_BUTTON_DOWN || event->type == EVENT_MOUSE_BUTTON_UP)
|
||||||
|
{
|
||||||
|
int OnMe;
|
||||||
|
|
||||||
OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon );
|
OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon );
|
||||||
|
|
||||||
icon->oldposition = icon->position;
|
if (B1_JUST_PRESSED && OnMe)
|
||||||
|
|
||||||
if ( B1_PRESSED && OnMe )
|
|
||||||
{
|
{
|
||||||
icon->position = 1;
|
icon->position = 1;
|
||||||
} else {
|
rval = 1;
|
||||||
icon->position = 0;
|
|
||||||
}
|
}
|
||||||
|
else if (B1_JUST_RELEASED)
|
||||||
icon->pressed = 0;
|
{
|
||||||
|
if ((icon->position == 1) && OnMe)
|
||||||
if ((icon->position==0) && (icon->oldposition==1) && OnMe )
|
|
||||||
icon->pressed = 1;
|
icon->pressed = 1;
|
||||||
|
|
||||||
if (icon->pressed == 1 || keypress==icon->trap_key )
|
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->status = 1;
|
||||||
icon->flag = (sbyte)icon->user_function();
|
icon->flag = (sbyte)icon->user_function();
|
||||||
if (keypress==icon->trap_key) last_keypress = 0;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_draw_icon( icon );
|
ui_draw_icon( icon );
|
||||||
|
|
Loading…
Reference in a new issue