More cleanups. Removed the pui-* commands, and added a pass-through
property to indicate when mouse events should be offset to PUI and the panel first.
This commit is contained in:
parent
94bd81c1de
commit
8d9b59314a
3 changed files with 24 additions and 43 deletions
|
@ -357,7 +357,20 @@ FGInput::doMouseClick (int b, int updown, int x, int y)
|
||||||
int modifiers = FG_MOD_NONE; // FIXME: any way to get the real ones?
|
int modifiers = FG_MOD_NONE; // FIXME: any way to get the real ones?
|
||||||
|
|
||||||
mouse &m = _mouse_bindings[0];
|
mouse &m = _mouse_bindings[0];
|
||||||
|
mouse_mode &mode = m.modes[m.current_mode];
|
||||||
|
|
||||||
|
// Pass on to PUI and the panel if
|
||||||
|
// requested, and return if one of
|
||||||
|
// them consumes the event.
|
||||||
|
if (mode.pass_through) {
|
||||||
|
if (puMouse(b, updown, x, y))
|
||||||
|
return;
|
||||||
|
else if ((current_panel != 0) &&
|
||||||
|
current_panel->doMouseAction(b, updown, x, y))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OK, PUI and the panel didn't want the click
|
||||||
if (b >= MAX_MOUSE_BUTTONS) {
|
if (b >= MAX_MOUSE_BUTTONS) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Mouse button " << b
|
SG_LOG(SG_INPUT, SG_ALERT, "Mouse button " << b
|
||||||
<< " where only " << MAX_MOUSE_BUTTONS << " expected");
|
<< " where only " << MAX_MOUSE_BUTTONS << " expected");
|
||||||
|
@ -378,6 +391,14 @@ FGInput::doMouseMotion (int x, int y)
|
||||||
if (m.current_mode < 0 || m.current_mode >= m.nModes)
|
if (m.current_mode < 0 || m.current_mode >= m.nModes)
|
||||||
return;
|
return;
|
||||||
mouse_mode &mode = m.modes[m.current_mode];
|
mouse_mode &mode = m.modes[m.current_mode];
|
||||||
|
|
||||||
|
// Pass on to PUI if requested, and return
|
||||||
|
// if PUI consumed the event.
|
||||||
|
if (mode.pass_through && puMouse(x, y))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// OK, PUI didn't want the event,
|
||||||
|
// so we can play with it.
|
||||||
if (x != m.x) {
|
if (x != m.x) {
|
||||||
int delta = x - m.x;
|
int delta = x - m.x;
|
||||||
for (int i = 0; i < mode.x_bindings[modifiers].size(); i++)
|
for (int i = 0; i < mode.x_bindings[modifiers].size(); i++)
|
||||||
|
@ -611,6 +632,7 @@ FGInput::_init_mouse ()
|
||||||
|
|
||||||
// Read other properties for this mode
|
// Read other properties for this mode
|
||||||
m.modes[j].constrained = mode_node->getBoolValue("constrained", false);
|
m.modes[j].constrained = mode_node->getBoolValue("constrained", false);
|
||||||
|
m.modes[j].pass_through = mode_node->getBoolValue("pass-through", false);
|
||||||
|
|
||||||
// Read the button bindings for this mode
|
// Read the button bindings for this mode
|
||||||
m.modes[j].buttons = new button[MAX_MOUSE_BUTTONS];
|
m.modes[j].buttons = new button[MAX_MOUSE_BUTTONS];
|
||||||
|
@ -889,6 +911,7 @@ FGInput::joystick::~joystick ()
|
||||||
FGInput::mouse_mode::mouse_mode ()
|
FGInput::mouse_mode::mouse_mode ()
|
||||||
: cursor(GLUT_CURSOR_INHERIT),
|
: cursor(GLUT_CURSOR_INHERIT),
|
||||||
constrained(false),
|
constrained(false),
|
||||||
|
pass_through(false),
|
||||||
buttons(0)
|
buttons(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,6 +302,7 @@ private:
|
||||||
virtual ~mouse_mode ();
|
virtual ~mouse_mode ();
|
||||||
int cursor;
|
int cursor;
|
||||||
bool constrained;
|
bool constrained;
|
||||||
|
bool pass_through;
|
||||||
button * buttons;
|
button * buttons;
|
||||||
binding_list_t x_bindings[FG_MOD_MAX];
|
binding_list_t x_bindings[FG_MOD_MAX];
|
||||||
binding_list_t y_bindings[FG_MOD_MAX];
|
binding_list_t y_bindings[FG_MOD_MAX];
|
||||||
|
|
|
@ -185,47 +185,6 @@ do_save (const SGPropertyNode * arg, SGCommandState ** state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Built-in command: let PUI handle a mouse click.
|
|
||||||
*
|
|
||||||
* button: the mouse button number, zero-based.
|
|
||||||
* is-down: true if the button is down, false if it is up.
|
|
||||||
* x-pos: the x position of the mouse click.
|
|
||||||
* y-pos: the y position of the mouse click.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
do_pui_mouse_click (const SGPropertyNode * arg, SGCommandState ** state)
|
|
||||||
{
|
|
||||||
return puMouse(arg->getIntValue("button"),
|
|
||||||
arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
|
|
||||||
arg->getIntValue("x-pos"),
|
|
||||||
arg->getIntValue("y-pos"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Built-in command: let PUI *or* the panel handle a mouse click.
|
|
||||||
*
|
|
||||||
* button: the mouse button number, zero-based.
|
|
||||||
* is-down: true if the button is down, false if it is up.
|
|
||||||
* x-pos: the x position of the mouse click.
|
|
||||||
* y-pos: the y position of the mouse click.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
do_pui_or_panel_mouse_click (const SGPropertyNode * arg,
|
|
||||||
SGCommandState ** state)
|
|
||||||
{
|
|
||||||
int button = arg->getIntValue("button");
|
|
||||||
bool is_down = arg->getBoolValue("is-down");
|
|
||||||
int x = arg->getIntValue("x-pos");
|
|
||||||
int y = arg->getIntValue("y-pos");
|
|
||||||
return (puMouse(button, is_down ? PU_DOWN : PU_UP, x, y) ||
|
|
||||||
(current_panel != 0 &&
|
|
||||||
current_panel->doMouseAction(button,
|
|
||||||
is_down ? PU_DOWN : PU_UP, x, y)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Built-in command: (re)load the panel.
|
* Built-in command: (re)load the panel.
|
||||||
*
|
*
|
||||||
|
@ -672,8 +631,6 @@ static struct {
|
||||||
{ "exit", do_exit },
|
{ "exit", do_exit },
|
||||||
{ "load", do_load },
|
{ "load", do_load },
|
||||||
{ "save", do_save },
|
{ "save", do_save },
|
||||||
{ "pui-mouse-click", do_pui_mouse_click },
|
|
||||||
{ "pui-or-panel-mouse-click", do_pui_or_panel_mouse_click },
|
|
||||||
{ "panel-load", do_panel_load },
|
{ "panel-load", do_panel_load },
|
||||||
{ "panel-mouse-click", do_panel_mouse_click },
|
{ "panel-mouse-click", do_panel_mouse_click },
|
||||||
{ "preferences-load", do_preferences_load },
|
{ "preferences-load", do_preferences_load },
|
||||||
|
|
Loading…
Reference in a new issue