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)
This commit is contained in:
parent
de3c04c582
commit
008b24a451
|
@ -1,5 +1,9 @@
|
||||||
D2X-Rebirth Changelog
|
D2X-Rebirth Changelog
|
||||||
|
|
||||||
|
20111103
|
||||||
|
--------
|
||||||
|
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)
|
||||||
|
|
||||||
20111103
|
20111103
|
||||||
--------
|
--------
|
||||||
main/net_udp.c, main/net_udp.h: Do not attempt to check for MULTI_PROTO_VERSION when requesting lite_info
|
main/net_udp.c, main/net_udp.h: Do not attempt to check for MULTI_PROTO_VERSION when requesting lite_info
|
||||||
|
|
|
@ -243,7 +243,7 @@ typedef struct {
|
||||||
|
|
||||||
#define B1_PRESSED (Mouse.b1_status & BUTTON_PRESSED)
|
#define B1_PRESSED (Mouse.b1_status & BUTTON_PRESSED)
|
||||||
#define B1_RELEASED (Mouse.b1_status & BUTTON_RELEASED)
|
#define B1_RELEASED (Mouse.b1_status & BUTTON_RELEASED)
|
||||||
#define B1_JUST_PRESSED (Mouse.b1_status & BUTTON_JUST_PRESSED)
|
#define B1_JUST_PRESSED (event->type == EVENT_MOUSE_BUTTON_DOWN && event_mouse_get_button(event) == 0)
|
||||||
#define B1_JUST_RELEASED (Mouse.b1_status & BUTTON_JUST_RELEASED)
|
#define B1_JUST_RELEASED (Mouse.b1_status & BUTTON_JUST_RELEASED)
|
||||||
#define B1_DOUBLE_CLICKED (Mouse.b1_status & BUTTON_DOUBLE_CLICKED)
|
#define B1_DOUBLE_CLICKED (Mouse.b1_status & BUTTON_DOUBLE_CLICKED)
|
||||||
|
|
||||||
|
|
90
ui/button.c
90
ui/button.c
|
@ -26,6 +26,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#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)
|
||||||
|
@ -130,65 +131,63 @@ UI_GADGET_BUTTON * ui_add_gadget_button( UI_DIALOG * dlg, short x, short y, shor
|
||||||
|
|
||||||
int ui_button_do( UI_GADGET_BUTTON * button, d_event *event )
|
int ui_button_do( UI_GADGET_BUTTON * button, d_event *event )
|
||||||
{
|
{
|
||||||
int OnMe, ButtonLastSelected;
|
|
||||||
int keypress = 0;
|
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
|
|
||||||
if (event->type == EVENT_KEY_COMMAND)
|
button->oldposition = button->position;
|
||||||
keypress = event_key_get(event);
|
button->pressed = 0;
|
||||||
|
|
||||||
|
if (event->type == EVENT_MOUSE_BUTTON_DOWN || event->type == EVENT_MOUSE_BUTTON_UP)
|
||||||
|
{
|
||||||
|
int OnMe;
|
||||||
|
|
||||||
OnMe = ui_mouse_on_gadget( (UI_GADGET *)button );
|
OnMe = ui_mouse_on_gadget( (UI_GADGET *)button );
|
||||||
|
|
||||||
button->oldposition = button->position;
|
if (B1_JUST_PRESSED && OnMe)
|
||||||
|
|
||||||
if (selected_gadget != NULL)
|
|
||||||
{
|
{
|
||||||
if (selected_gadget->kind==1)
|
|
||||||
ButtonLastSelected = 1;
|
|
||||||
else
|
|
||||||
ButtonLastSelected = 0;
|
|
||||||
} else
|
|
||||||
ButtonLastSelected = 1;
|
|
||||||
|
|
||||||
|
|
||||||
if ( B1_PRESSED && OnMe && ButtonLastSelected )
|
|
||||||
{
|
|
||||||
|
|
||||||
button->position = 1;
|
button->position = 1;
|
||||||
} else {
|
rval = 1;
|
||||||
|
}
|
||||||
|
else if (B1_JUST_RELEASED)
|
||||||
|
{
|
||||||
|
if ((button->position == 1) && OnMe)
|
||||||
|
button->pressed = 1;
|
||||||
|
|
||||||
button->position = 0;
|
button->position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keypress == button->hotkey )
|
|
||||||
{
|
|
||||||
button->position = 2;
|
|
||||||
last_keypress = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((keypress == button->hotkey1) && button->user_function1 )
|
|
||||||
|
if (event->type == EVENT_KEY_COMMAND)
|
||||||
|
{
|
||||||
|
int keypress;
|
||||||
|
|
||||||
|
keypress = event_key_get(event);
|
||||||
|
|
||||||
|
if ((keypress == button->hotkey) ||
|
||||||
|
((keypress == button->hotkey1) && button->user_function1) ||
|
||||||
|
((CurWindow->keyboard_focus_gadget==(UI_GADGET *)button) && ((keypress==KEY_SPACEBAR) || (keypress==KEY_ENTER)) ))
|
||||||
|
{
|
||||||
|
button->position = 2;
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event->type == EVENT_KEY_RELEASE)
|
||||||
|
{
|
||||||
|
int keypress;
|
||||||
|
|
||||||
|
keypress = event_key_get(event);
|
||||||
|
|
||||||
|
button->position = 0;
|
||||||
|
|
||||||
|
if ((keypress == button->hotkey) ||
|
||||||
|
((CurWindow->keyboard_focus_gadget==(UI_GADGET *)button) && ((keypress==KEY_SPACEBAR) || (keypress==KEY_ENTER)) ))
|
||||||
|
button->pressed = 1;
|
||||||
|
|
||||||
|
if ((keypress == button->hotkey1) && button->user_function1)
|
||||||
{
|
{
|
||||||
button->user_function1();
|
button->user_function1();
|
||||||
last_keypress = 0;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)button) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) )
|
|
||||||
// button->position = 2;
|
|
||||||
|
|
||||||
if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)button) && ((keypress==KEY_SPACEBAR) || (keypress==KEY_ENTER)) )
|
|
||||||
button->position = 2;
|
|
||||||
|
|
||||||
if (CurWindow->keyboard_focus_gadget==(UI_GADGET *)button)
|
|
||||||
if ((button->oldposition==2) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) )
|
|
||||||
button->position = 2;
|
|
||||||
|
|
||||||
button->pressed = 0;
|
|
||||||
|
|
||||||
if (button->position==0) {
|
|
||||||
if ( (button->oldposition==1) && OnMe )
|
|
||||||
button->pressed = 1;
|
|
||||||
if ( (button->oldposition==2) && (CurWindow->keyboard_focus_gadget==(UI_GADGET *)button) )
|
|
||||||
button->pressed = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_draw_button( button );
|
ui_draw_button( button );
|
||||||
|
@ -196,6 +195,7 @@ int ui_button_do( UI_GADGET_BUTTON * button, d_event *event )
|
||||||
if (button->pressed && button->user_function )
|
if (button->pressed && button->user_function )
|
||||||
{
|
{
|
||||||
button->user_function();
|
button->user_function();
|
||||||
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -233,6 +233,7 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_KEY_COMMAND:
|
case EVENT_KEY_COMMAND:
|
||||||
|
case EVENT_KEY_RELEASE:
|
||||||
return ui_dialog_do_gadgets(dlg, event);
|
return ui_dialog_do_gadgets(dlg, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,9 @@ int ui_dialog_do_gadgets(UI_DIALOG * dlg, d_event *event)
|
||||||
if (tmp1 != NULL )
|
if (tmp1 != NULL )
|
||||||
tmp1->status = 1;
|
tmp1->status = 1;
|
||||||
rval = 1;
|
rval = 1;
|
||||||
|
|
||||||
|
if (keypress)
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = dlg->gadget;
|
tmp = dlg->gadget;
|
||||||
|
|
|
@ -23,6 +23,7 @@ static char rcsid[] = "$Id: scroll.c,v 1.1.1.1 2006/03/17 19:52:16 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"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ static char rcsid[] = "$Id: userbox.c,v 1.1.1.1 2006/03/17 19:52:22 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"
|
||||||
|
|
||||||
void ui_draw_userbox( UI_GADGET_USERBOX * userbox )
|
void ui_draw_userbox( UI_GADGET_USERBOX * userbox )
|
||||||
|
|
Loading…
Reference in a new issue