pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2741 - in branches/pingus_sdl/src: . gui


From: nehalmistry
Subject: [Pingus-CVS] r2741 - in branches/pingus_sdl/src: . gui
Date: Tue, 17 Jul 2007 03:59:20 +0200

Author: nehalmistry
Date: 2007-07-17 03:59:15 +0200 (Tue, 17 Jul 2007)
New Revision: 2741

Modified:
   branches/pingus_sdl/src/exit_menu.cpp
   branches/pingus_sdl/src/file_dialog.cpp
   branches/pingus_sdl/src/gui/surface_button.hpp
Log:
allow clicking on the text for GUI::SurfaceButton items

Modified: branches/pingus_sdl/src/exit_menu.cpp
===================================================================
--- branches/pingus_sdl/src/exit_menu.cpp       2007-07-16 23:26:19 UTC (rev 
2740)
+++ branches/pingus_sdl/src/exit_menu.cpp       2007-07-17 01:59:15 UTC (rev 
2741)
@@ -46,6 +46,12 @@
                    (float)Display::get_height()/2 + 15, _("Yes"));
   }
 
+  bool is_at(int x, int y) {
+         return x > x_pos - Fonts::chalk_large.get_width(_("Yes"))
+               && x < x_pos + int(button_surface.get_width())
+               && y > y_pos && y < y_pos + int(button_surface.get_height());
+  }
+
   void on_click()
   {
     Sound::PingusSound::play_sound ("yipee");
@@ -64,7 +70,7 @@
 private:
   PingusMenuManager* manager;
 public:
-  ExitMenuNoButton (PingusMenuManager* m)
+  ExitMenuNoButton(PingusMenuManager* m)
     : GUI::SurfaceButton(Display::get_width()/2 + 80, Display::get_height()/2 
+ 15,
                          ResDescriptor("core/menu/exit_button_normal"),
                          ResDescriptor("core/menu/exit_button_pressed"),
@@ -73,12 +79,18 @@
   {
   }
 
-  void draw (DrawingContext& gc) {
+  void draw(DrawingContext& gc) {
     SurfaceButton::draw(gc);
     gc.print_right(Fonts::chalk_large, (float)Display::get_width()/2 + 80,
                    (float)Display::get_height()/2 + 15, _("No"));
   }
 
+  bool is_at(int x, int y) {
+         return x > x_pos - Fonts::chalk_large.get_width(_("No"))
+               && x < x_pos + int(button_surface.get_width())
+               && y > y_pos && y < y_pos + int(button_surface.get_height());
+  }
+
   void on_click() {
     Sound::PingusSound::play_sound ("yipee");
     manager->pop_menu();
@@ -91,14 +103,14 @@
   }
 };
 
-ExitMenu::ExitMenu (PingusMenuManager* manager_)
-  : PingusSubMenu (manager_)
+ExitMenu::ExitMenu(PingusMenuManager* manager_)
+  : PingusSubMenu(manager_)
 {
   gui_manager->add(new ExitMenuYesButton(manager), true);
-  gui_manager->add(new ExitMenuNoButton (manager), true);
+  gui_manager->add(new ExitMenuNoButton(manager), true);
 }
 
-ExitMenu::~ExitMenu ()
+ExitMenu::~ExitMenu()
 {
 }
 
@@ -107,15 +119,15 @@
 {
   //gc.draw_fillrect (0, 0, Display::get_width (), Display::get_height (),
   //0, 0, 0, 0.5);
-  gc.draw(sur, Vector3f(gc.get_width ()/2 - sur.get_width ()/2,
-                        gc.get_height ()/2 - sur.get_height ()/2));
+  gc.draw(sur, Vector3f(gc.get_width()/2 - sur.get_width()/2,
+                        gc.get_height()/2 - sur.get_height()/2));
   gc.print_center(Fonts::chalk_large, gc.get_width()/2, gc.get_height()/2 - 
70, _("Exit Pingus?"));
   PingusSubMenu::draw(gc);
   return true;
 }
 
 void
-ExitMenu::preload ()
+ExitMenu::preload()
 {
   sur = Resource::load_sprite("core/menu/exit_menu");
 }

Modified: branches/pingus_sdl/src/file_dialog.cpp
===================================================================
--- branches/pingus_sdl/src/file_dialog.cpp     2007-07-16 23:26:19 UTC (rev 
2740)
+++ branches/pingus_sdl/src/file_dialog.cpp     2007-07-17 01:59:15 UTC (rev 
2741)
@@ -65,6 +65,12 @@
                }
        }
 
+       bool is_at(int x, int y) {
+               return x > x_pos - Fonts::chalk_large.get_width(label)
+                       && x < x_pos + int(button_surface.get_width())
+                       && y > y_pos && y < y_pos + 
int(button_surface.get_height());
+       }
+
        void on_click()
        {
                if (!is_hidden)
@@ -110,6 +116,12 @@
                        (float)Display::get_height()/2 + 160, CANCEL_TEXT);
        }
 
+       bool is_at(int x, int y) {
+               return x > x_pos - Fonts::chalk_large.get_width(CANCEL_TEXT)
+                       && x < x_pos + int(button_surface.get_width())
+                       && y > y_pos && y < y_pos + 
int(button_surface.get_height());
+       }
+
        void on_click()
        {
                Sound::PingusSound::play_sound ("yipee");

Modified: branches/pingus_sdl/src/gui/surface_button.hpp
===================================================================
--- branches/pingus_sdl/src/gui/surface_button.hpp      2007-07-16 23:26:19 UTC 
(rev 2740)
+++ branches/pingus_sdl/src/gui/surface_button.hpp      2007-07-17 01:59:15 UTC 
(rev 2741)
@@ -49,7 +49,7 @@
   virtual ~SurfaceButton ();
 
   virtual void draw (DrawingContext& gc);
-  bool is_at (int x, int y);
+  virtual bool is_at (int x, int y);
 
   void on_primary_button_press (int x, int y);
   void on_primary_button_release (int x, int y);





reply via email to

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