Revision: 7339
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7339&view=rev
Author:   rtv
Date:     2009-02-17 07:31:10 +0000 (Tue, 17 Feb 2009)

Log Message:
-----------
interface improvements

Modified Paths:
--------------
    code/stage/trunk/libstage/canvas.cc
    code/stage/trunk/libstage/options_dlg.cc
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/libstage/worldgui.cc

Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2009-02-17 06:13:41 UTC (rev 7338)
+++ code/stage/trunk/libstage/canvas.cc 2009-02-17 07:31:10 UTC (rev 7339)
@@ -508,63 +508,6 @@
         case FL_KEYBOARD:
                switch( Fl::event_key() )
                  {
-                 case 'p': // pause
-                        world->TogglePause();
-                        
-                        if( ! world->paused )
-                               {
-                                 // // start the timer that causes regular 
redraws
-                                 Fl::add_timeout( ((double)interval/1000), 
-                                                                               
 (Fl_Timeout_Handler)Canvas::TimerCallback, 
-                                                                               
 this);
-                               }
-                        else
-                               { // remove the timeout
-                                 Fl::remove_timeout( 
(Fl_Timeout_Handler)Canvas::TimerCallback );
-                               }
-
-                        redraw(); // in case something happened that will 
never be
-                                                 // drawn 'cos we cancelled 
the timeout
-
-                        break;
-                 case ' ': // space bar
-                 
-                        // if the worldfile doesn't have the fields you need, 
you get
-                        // a weird view.  need to think this through a bit 
before
-                        // eliminating the old behaviour - rtv
-
-                        //if ( wf )
-                        //current_camera->Load( wf, wf->LookupEntity( "window" 
) );
-                        //else
-                        current_camera->reset();
-                                       
-                        //invalidate();
-                        if( Fl::event_state( FL_CTRL ) ) {
-                               resetCamera();
-                        }
-                        redraw();
-                        break;                 
-
-                 case '[': // slow down
-                        if( world->interval_real == 0 )
-                               world->interval_real = 10;
-                        else
-                               {
-                                 world->interval_real *= 1.2;
-                               }
-                        break; // need the parens above
-
-                 case ']': // speed up
-                        if( world->interval_real == 0 )
-                               putchar( 7 ); // bell!
-                        else
-                               {
-                                 world->interval_real *= 0.8;
-                                 if( world->interval_real < 10 )
-                                        world->interval_real = 0;
-                               }
-                        break;
-
                  case FL_Left:
                         if( pCamOn == false ) { camera.move( -10, 0 ); } 
                         else { perspective_camera.strafe( -0.5 ); } break;
@@ -595,6 +538,8 @@
                return Fl_Gl_Window::handle(event);
                        
     } // end switch( event )
+
+  return 0;
 }
 
 void Canvas::FixViewport(int W,int H) 
@@ -715,7 +660,7 @@
   glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
 }
 
-inline void Canvas::resetCamera()
+void Canvas::resetCamera()
 {
   float max_x = 0, max_y = 0, min_x = 0, min_y = 0;
        

Modified: code/stage/trunk/libstage/options_dlg.cc
===================================================================
--- code/stage/trunk/libstage/options_dlg.cc    2009-02-17 06:13:41 UTC (rev 
7338)
+++ code/stage/trunk/libstage/options_dlg.cc    2009-02-17 07:31:10 UTC (rev 
7339)
@@ -16,9 +16,7 @@
         showAllCheck->callback( checkChanged, this );
         showAllCheck->box( FL_UP_FRAME );
 
-        //scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-btnH-3*vm );
         scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-3*vm );
-        //scroll->box( FL_ENGRAVED_BOX );
         resizable( scroll );
         scroll->type( Fl_Scroll::VERTICAL );
         scroll->end();

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-02-17 06:13:41 UTC (rev 7338)
+++ code/stage/trunk/libstage/stage.hh  2009-02-17 07:31:10 UTC (rev 7339)
@@ -1390,7 +1390,13 @@
     static void viewOptionsCb( OptionsDlg* oDlg, WorldGui* worldGui  );
     static void optionsDlgCb( OptionsDlg* oDlg, WorldGui* worldGui  );
     static void helpAboutCb( Fl_Widget* w, void* p );
-       
+    static void pauseCb( Fl_Widget* w, WorldGui* worldGui );
+    static void fasterCb( Fl_Widget* w, WorldGui* worldGui );
+    static void slowerCb( Fl_Widget* w, WorldGui* worldGui );
+    static void realtimeCb( Fl_Widget* w, WorldGui* worldGui );
+    static void fasttimeCb( Fl_Widget* w, WorldGui* worldGui );
+        static void resetViewCb( Fl_Widget* w, WorldGui* worldGui );
+
     // GUI functions
     bool saveAsDialog();
     bool closeWindowQuery();

Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc       2009-02-17 06:13:41 UTC (rev 
7338)
+++ code/stage/trunk/libstage/worldgui.cc       2009-02-17 07:31:10 UTC (rev 
7339)
@@ -179,6 +179,8 @@
   
   label( PROJECT );
   
+  // make this menu's shortcuts work whoever has focus
+  mbar->global();
   mbar->textsize(12);
   
   mbar->add( "&File", 0, 0, 0, FL_SUBMENU );
@@ -192,8 +194,18 @@
   mbar->add( "File/E&xit", FL_CTRL+'q', WorldGui::fileExitCb, this );
   
   mbar->add( "&View", 0, 0, 0, FL_SUBMENU );
+
+  mbar->add( "View/Reset", ' ', (Fl_Callback*) WorldGui::resetViewCb, this );
+
   mbar->add( "View/Filter data...", FL_SHIFT + 'd', 
(Fl_Callback*)WorldGui::viewOptionsCb, this );
   canvas->createMenuItems( mbar, "View" );
+
+  mbar->add( "Run", 0,0,0, FL_SUBMENU );
+  mbar->add( "Run/Pause", 'p', (Fl_Callback*) WorldGui::pauseCb, this );
+  mbar->add( "Run/Faster", ']', (Fl_Callback*) WorldGui::fasterCb, this );
+  mbar->add( "Run/Slower", '[', (Fl_Callback*) WorldGui::slowerCb, this );
+  mbar->add( "Run/Realtime", '{', (Fl_Callback*) WorldGui::realtimeCb, this );
+  mbar->add( "Run/Fast", '}', (Fl_Callback*) WorldGui::fasttimeCb, this );
   
   mbar->add( "&Help", 0, 0, 0, FL_SUBMENU );
   mbar->add( "Help/&About Stage...", 0, WorldGui::helpAboutCb, this );
@@ -212,6 +224,7 @@
   delete canvas;
 }
 
+
 void WorldGui::Show()
 {
   show(); // fltk
@@ -531,6 +544,69 @@
   return (*a) < (*b);
 }
 
+void WorldGui::resetViewCb( Fl_Widget* w, WorldGui* worldGui )
+{
+  worldGui->canvas->current_camera->reset();
+  
+  if( Fl::event_state( FL_CTRL ) ) 
+        {
+               worldGui->canvas->resetCamera();
+        }
+  worldGui->canvas->redraw();
+}
+
+void WorldGui::slowerCb( Fl_Widget* w, WorldGui* wg )
+{
+  if( wg->interval_real == 0 )
+        wg->interval_real = 10;
+  else
+        {
+               wg->interval_real *= 1.2;
+        }
+}
+
+void WorldGui::fasterCb( Fl_Widget* w, WorldGui* wg )
+{
+  if( wg->interval_real == 0 )
+        putchar( 7 ); // bell!
+  else
+        {
+               wg->interval_real *= 0.8;
+               if( wg->interval_real < 10 )
+                 wg->interval_real = 0;
+        }
+}
+
+void WorldGui::realtimeCb( Fl_Widget* w, WorldGui* wg )
+{
+  wg->interval_real = wg->interval_sim;
+}
+
+void WorldGui::fasttimeCb( Fl_Widget* w, WorldGui* wg )
+{
+  wg->interval_real = 0;
+}
+
+void WorldGui::pauseCb( Fl_Widget* w, WorldGui* worldGui )
+{
+  worldGui->TogglePause();
+
+  if( ! worldGui->paused )
+        {
+               // // start the timer that causes regular redraws
+               Fl::add_timeout( ((double)worldGui->canvas->interval/1000), 
+                                                         
(Fl_Timeout_Handler)Canvas::TimerCallback, 
+                                                         worldGui->canvas );
+        }
+  else
+        { // remove the timeout
+               Fl::remove_timeout( (Fl_Timeout_Handler)Canvas::TimerCallback );
+        }
+  
+  worldGui->canvas->redraw(); // in case something happened that will never be
+  // drawn 'cos we cancelled the timeout
+}
+
 void WorldGui::viewOptionsCb( OptionsDlg* oDlg, WorldGui* worldGui ) 
 {
   // the options dialog expects a std::vector of options (annoyingly)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to