pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/gui button.hxx,1.2,1.3 component.hxx,


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/gui button.hxx,1.2,1.3 component.hxx,1.5,1.6 gui_manager.cxx,1.6,1.7 gui_manager.hxx,1.5,1.6 surface_button.cxx,1.1,1.2 surface_button.hxx,1.1,1.2
Date: 2 Aug 2002 22:55:22 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/gui
In directory dark:/tmp/cvs-serv16623/gui

Modified Files:
        button.hxx component.hxx gui_manager.cxx gui_manager.hxx 
        surface_button.cxx surface_button.hxx 
Log Message:
cleaned up the forward/pause/armageddon button mess a bit
on_button_press to on_primary_button_press  rename
added on_secondary_press


Index: button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/button.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- button.hxx  29 Jul 2002 10:44:12 -0000      1.2
+++ button.hxx  2 Aug 2002 22:55:19 -0000       1.3
@@ -29,8 +29,8 @@
     bool mouse_over;
 
   public:
-    void on_button_press (int x, int y);
-    void on_button_release (int x, int y);
+    void on_primary_button_press (int x, int y);
+    void on_primary_button_release (int x, int y);
 
     void on_pointer_enter ();
     void on_pointer_leave ();

Index: component.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/component.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- component.hxx       1 Aug 2002 21:40:02 -0000       1.5
+++ component.hxx       2 Aug 2002 22:55:19 -0000       1.6
@@ -36,14 +36,19 @@
 
     // Events
     /** Gets issued once the primary button is pressed */
-    virtual void on_button_press (int x, int y) {}
+    virtual void on_primary_button_press (int x, int y) {}
     
     /** Gets issued once the primary button is released */
-    virtual void on_button_release (int x, int y) {}
+    virtual void on_primary_button_release (int x, int y) {}
+
+    virtual void on_secondary_button_press (int x, int y) {}
+    virtual void on_secondary_button_release (int x, int y) {}
 
     /** Gets emmited when a button is pressed and released over the
        same component */
-    virtual void on_button_click (int x, int y) {}
+    virtual void on_primary_button_click (int x, int y) {}
+
+    virtual void on_secondary_button_click (int x, int y) {}
 
     /** Emmitted when pointer enters the region of the component */
     virtual void on_pointer_enter () {}

Index: gui_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/gui_manager.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gui_manager.cxx     2 Aug 2002 11:53:52 -0000       1.6
+++ gui_manager.cxx     2 Aug 2002 22:55:19 -0000       1.7
@@ -31,7 +31,9 @@
 using namespace Input;
 
 GUIManager::GUIManager ()
-  : pressed_component (0), mouse_over_component (0),
+  : primary_pressed_component (0),
+    secondary_pressed_component (0),
+    mouse_over_component (0),
     x_pos (400), y_pos (300)
 {
 }
@@ -73,8 +75,8 @@
 
            Component* comp = component_at (x_pos, y_pos);//FIXME
 
-           if (pressed_component)
-             pressed_component->on_pointer_move (x_pos, y_pos);
+           if (primary_pressed_component)
+             primary_pressed_component->on_pointer_move (x_pos, y_pos);
            else if (comp)
              {
                comp->on_pointer_move (x_pos, y_pos);
@@ -109,7 +111,7 @@
        case Input::ButtonEventType:
          {
            ButtonEvent* event = dynamic_cast<ButtonEvent*>(*i);
-           //std::cout << "RootGUIManager: Got button event: " << event->name 
<< " " << event->state << std::endl;
+           std::cout << "GUIManager: Got button event: " << event->name << " " 
<< event->state << std::endl;
 
            Component* comp = component_at (x_pos, y_pos);//FIXME
 
@@ -117,47 +119,85 @@
              {
                if (event->name == primary && event->state == Input::pressed) 
                  {
-                   pressed_component = comp;
-                   comp->on_button_press (x_pos, y_pos); // FIXME: dummy data
+                   primary_pressed_component = comp;
+                   comp->on_primary_button_press (x_pos, y_pos);
                  }
                else if (event->name == primary && event->state == 
Input::released) 
                  {
                    /** Send the release event to the same component
                        which got the press event */
-                   if (pressed_component)
+                   if (primary_pressed_component)
                      {
-                       pressed_component->on_button_release (x_pos, y_pos);
+                       primary_pressed_component->on_primary_button_release 
(x_pos, y_pos);
 
-                       if (pressed_component == comp)
+                       if (primary_pressed_component == comp)
                          {
-                           comp->on_button_click (x_pos, y_pos);
+                           std::cout << "GUIManager: calling 
on_primary_button_click ()" << std::endl;
+                           comp->on_primary_button_click (x_pos, y_pos);
                          }
                        else
                          {
                            // discard click
                          }
-                       pressed_component = 0;
+                       primary_pressed_component = 0;
                      }
                    else
                      {
                        /* FIXME: This happens when you press a button
                           FIXME: in one GUIManager and switch in the
-                          FIXME: on_button_press() method to another
+                          FIXME: on_primary_button_press() method to another
+                          FIXME: manager, not sure if there is or
+                          FIXME: should be a workaround */
+                       std::cout << "GUIManager: Got a release without a 
press, possibly a bug" << std::endl;
+                     }
+                 }
+               
+               // Secondary button
+               if (event->name == secondary && event->state == Input::pressed) 
+                 {
+                   secondary_pressed_component = comp;
+                   comp->on_secondary_button_press (x_pos, y_pos);
+                 }
+               else if (event->name == secondary && event->state == 
Input::released) 
+                 {
+                   /** Send the release event to the same component
+                       which got the press event */
+                   if (secondary_pressed_component)
+                     {
+                       
secondary_pressed_component->on_secondary_button_release (x_pos, y_pos);
+
+                       if (secondary_pressed_component == comp)
+                         {
+                           std::cout << "GUIManager: calling 
on_secondary_button_click ()" << std::endl;
+                           comp->on_secondary_button_click (x_pos, y_pos);
+                         }
+                       else
+                         {
+                           // discard click
+                         }
+                       secondary_pressed_component = 0;
+                     }
+                   else
+                     {
+                       /* FIXME: This happens when you press a button
+                          FIXME: in one GUIManager and switch in the
+                          FIXME: on_secondary_button_press() method to another
                           FIXME: manager, not sure if there is or
                           FIXME: should be a workaround */
                        std::cout << "GUIManager: Got a release without a 
press, possibly a bug" << std::endl;
                      }
                  }
+
              }
            else
              {
                std::cout << "GUIManager: Clicked into a non managed region" << 
std::endl;
                unhandled_event ();
 
-               if (pressed_component)
+               if (secondary_pressed_component)
                  {
-                   pressed_component->on_button_release (x_pos, y_pos);
-                   pressed_component = 0;
+                   secondary_pressed_component->on_secondary_button_release 
(x_pos, y_pos);
+                   secondary_pressed_component = 0;
                  }
              }
            break;

Index: gui_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/gui_manager.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gui_manager.hxx     1 Aug 2002 21:40:02 -0000       1.5
+++ gui_manager.hxx     2 Aug 2002 22:55:19 -0000       1.6
@@ -40,7 +40,7 @@
       FIXME: We translate GameDelta into another 'language' which is
       then understood by the GUI, this seems unclear, not sure at
       which point it is best to split the GameDelta into
-      on_button_press(), etc.
+      on_primary_button_press(), etc.
   */
   class GUIManager : public Component
   {
@@ -48,7 +48,8 @@
     std::vector<Component*> components;
 
     /** The component which recieved the last pressed event */
-    Component* pressed_component;
+    Component* primary_pressed_component;
+    Component* secondary_pressed_component;
 
     /** The component over which the mouse was in the last update,
        used to detecte enter/leave events */

Index: surface_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/surface_button.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- surface_button.cxx  29 Jul 2002 10:44:12 -0000      1.1
+++ surface_button.cxx  2 Aug 2002 22:55:19 -0000       1.2
@@ -61,14 +61,14 @@
 }
 
 void
-SurfaceButton::on_button_press (int x, int y)
+SurfaceButton::on_primary_button_press (int x, int y)
 {
   std::cout << "XXXXXXXXX press" << std::endl;
   pressed = true;
 }
 
 void
-SurfaceButton::on_button_release (int x, int y)
+SurfaceButton::on_primary_button_release (int x, int y)
 {
   std::cout << "XXXXXXXXX release" << std::endl;
   pressed = false;
@@ -89,7 +89,7 @@
 }
 
 void
-SurfaceButton::on_button_click (int x, int y)
+SurfaceButton::on_primary_button_click (int x, int y)
 {
   std::cout << "Surfacebutton got click" << std::endl;
 }

Index: surface_button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/surface_button.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- surface_button.hxx  29 Jul 2002 10:44:12 -0000      1.1
+++ surface_button.hxx  2 Aug 2002 22:55:19 -0000       1.2
@@ -50,9 +50,9 @@
     void draw ();
     bool is_at (int x, int y);
 
-    void on_button_press (int x, int y);
-    void on_button_release (int x, int y);
-    void on_button_click (int x, int y);
+    void on_primary_button_press (int x, int y);
+    void on_primary_button_release (int x, int y);
+    void on_primary_button_click (int x, int y);
 
     void on_pointer_enter ();
     void on_pointer_leave ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]