]> git.mxchange.org Git - flightgear.git/commitdiff
More cleanups. Removed the pui-* commands, and added a pass-through
authordavid <david>
Tue, 26 Mar 2002 17:14:48 +0000 (17:14 +0000)
committerdavid <david>
Tue, 26 Mar 2002 17:14:48 +0000 (17:14 +0000)
property to indicate when mouse events should be offset to PUI and the
panel first.

src/Input/input.cxx
src/Input/input.hxx
src/Main/fg_commands.cxx

index 20024c4d291b5d43cf9c786719931bd77e9924bf..93f83d58882236a5f039be7c1b010014fb3574f6 100644 (file)
@@ -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)
 {
 }
index f0c99491dd515d00b7c6c6222ee3e093fb0e7cd4..4a28edc961859b94226ad7a4449b81b88c48565a 100644 (file)
@@ -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];
index b9060df069df77071fdaff772fe4eab561eb0f50..d8677b50febaf2526cca367e1e9bb3bb93fa2f7d 100644 (file)
@@ -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 },