From 8d9b59314ae3b522dff7726b5522384f0ec9826d Mon Sep 17 00:00:00 2001 From: david Date: Tue, 26 Mar 2002 17:14:48 +0000 Subject: [PATCH] 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. --- src/Input/input.cxx | 23 +++++++++++++++++++++ src/Input/input.hxx | 1 + src/Main/fg_commands.cxx | 43 ---------------------------------------- 3 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 20024c4d2..93f83d588 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -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? 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) { SG_LOG(SG_INPUT, SG_ALERT, "Mouse button " << b << " 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) return; 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) { int delta = x - m.x; for (int i = 0; i < mode.x_bindings[modifiers].size(); i++) @@ -611,6 +632,7 @@ FGInput::_init_mouse () // Read other properties for this mode 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 m.modes[j].buttons = new button[MAX_MOUSE_BUTTONS]; @@ -889,6 +911,7 @@ FGInput::joystick::~joystick () FGInput::mouse_mode::mouse_mode () : cursor(GLUT_CURSOR_INHERIT), constrained(false), + pass_through(false), buttons(0) { } diff --git a/src/Input/input.hxx b/src/Input/input.hxx index f0c99491d..4a28edc96 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -302,6 +302,7 @@ private: virtual ~mouse_mode (); int cursor; bool constrained; + bool pass_through; button * buttons; binding_list_t x_bindings[FG_MOD_MAX]; binding_list_t y_bindings[FG_MOD_MAX]; diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index b9060df06..d8677b50f 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -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. * @@ -672,8 +631,6 @@ static struct { { "exit", do_exit }, { "load", do_load }, { "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-mouse-click", do_panel_mouse_click }, { "preferences-load", do_preferences_load }, -- 2.39.5